[PATCH v4] Add new 'print nibbles' feature

Enze Li lienze2010@hotmail.com
Thu Oct 7 12:51:47 GMT 2021


Hi Bruno,

Thanks a lot for the review.

On 10/1/21 4:35 AM, Bruno Larsen wrote:
> On 9/4/21 9:42 AM, Enze Li via Gdb-patches wrote:
>> Make an introduction of a new print setting that can be set by 'set
>> print nibbles [on|off].  The default value is OFF, and it would be
>> changed by users manually.
>>
>> And of course, 'show print nibbles' is also included in the patch.
>>
>> The new feature could display binary values in groups, and each group
>> has four bits.
>>
> 
>> diff --git a/gdb/valprint.c b/gdb/valprint.c
>> index 324055da93f..c797d89798a 100644
>> --- a/gdb/valprint.c
>> +++ b/gdb/valprint.c
>> @@ -108,6 +108,7 @@ struct value_print_options user_print_options =
>>     0,                /* vtblprint */
>>     1,                /* unionprint */
>>     1,                /* addressprint */
>> +  false,            /* nibblesprint */
>>     0,                /* objectprint */
>>     PRINT_MAX_DEFAULT,        /* print_max */
>>     10,                /* repeat_count_threshold */
>> @@ -260,6 +261,15 @@ show_unionprint (struct ui_file *file, int from_tty,
>>               value);
>>   }
>>   +static void
>> +show_nibbles (struct ui_file *file, int from_tty,
>> +               struct cmd_list_element *c, const char *value)
>> +{
>> +  fprintf_filtered (file,
>> +            _("Printing binary values in groups is %s.\n"),
>> +            value);
>> +}
>> +
> 
> I really like this idea, and the implementation looks ok, I just noticed one nit and one problem. The nit is that this function doesn't have a comment documenting it.

I'm glad that you like this feature as much as I do. :)

> The problem is that you forgot to update the gdb.base/options.exp test, which check for print options. Without this update it looks like there are 17 regressions in the testsuite.
> 
> -- 
> Cheers!
> Bruno Larsen
> 

In fact, when I merged the patch into the recent master and resolved some conflicts, I didn't notice that this merge triggered the problem you pointed out. In short, this problem has been fixed. 


Cheers!
Enze



More information about the Gdb-patches mailing list