This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Improve printf DFP support


Daniel Jacobowitz <drow at false.org> writes:

> On Tue, Jan 08, 2008 at 01:19:06PM -0200, Thiago Jung Bauermann wrote:
>> param_ptr should be a const gdb_byte *, and the cast here should be
>> removed. In addition, I believe the use of value_offset here is wrong.
>> Other uses of value_offset are to obtain a memory address in the
>> inferior address space, not in GDB's. Also, I think that value_contents
>> should be used intead of value_contents_all so that the value's
>> embedded_offset can be taken into account.
>
> I believe that you are correct.  The value handling is another area of
> GDB that could do with some cleaning up; I am not convinced the
> multiple offsets dance is necessary...

I think the origin of GDB's confusion is that we didn't follow through
with any consistent decision about whether a value should act like an
instance of its static type or its dynamic type.  So value_type (v) is
v's static type, but value_address (v) returns the address of the
instance of the dynamic type --- thus the need to add
value_embedded_offset to it.

So, if I were going to take a shot at it, here are the decisions I
think would make sense:

1) Use the C++ terminology --- 'static type' and 'dynamic type' ---
   whereever the distinction needs to be made, instead of 'embedded'
   and 'enclosing'.  For example, value_enclosing_type should be
   value_dynamic_type.

2) Use the static type as the default for most value_ operations
   within GDB:
   - value_type should return the static type.
   - value_contents should return the contents of the portion of the
     object corresponding to the static type (i.e. it should have
     value_embedded_offset added in)
   - value_contents_all should be called value_dynamic_type_contents

3) Use the dynamic type by default when printing objects.  objectprint
   should be 1 by default.  We can count on run-time type information
   nowadays, right?

I don't know how much of this still applies, but this is what I wrote
on the topic a long time ago:

http://sourceware.org/ml/gdb/2001-05/msg00306.html


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]