This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Adding bit position to ptype
- From: Tom Tromey <tromey at redhat dot com>
- To: lin zuojian <manjian2006 at gmail dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 18 Jun 2014 08:31:08 -0600
- Subject: Re: [PATCH] Adding bit position to ptype
- Authentication-results: sourceware.org; auth=none
- References: <20140618031308 dot GA7252 at ubuntu>
>>>>> ">" == lin zuojian <manjian2006@gmail.com> writes:
>> Hi, I am having trouble looking up field offsets when reading
>> disassembled text. So I add an extra field to ptype:
Nice.
You might be interested in pahole.py.
>> diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
>> index 4edc9ec..9fbbc36 100644
>> --- a/gdb/c-typeprint.c
>> +++ b/gdb/c-typeprint.c
>> @@ -1110,6 +1110,12 @@ c_type_print_base (struct type *type, struct ui_file *stream,
>> fprintf_filtered (stream, " : %d",
>> TYPE_FIELD_BITSIZE (type, i));
>> }
>> + else if (!field_is_static (&TYPE_FIELD (type, i)))
>> + {
>> + /* print the bit pos. */
>> + fprintf_filtered (stream, " bitpos: %d",
>> + TYPE_FIELD_BITPOS (type, i));
>> + }
>> fprintf_filtered (stream, ";\n");
To be considered for acceptance all patches require a ChangeLog entry
and must pass regression testing -- which this one probably does not, as
it changes gdb's output by default. Please see the contribution
instructions.
I think it would probably be better to add a flag to ptype to enable
this behavior. Integrating all of the pahole behavior into ptype would
be even better, though I understand if you don't want to go this far.
thanks,
Tom