Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@codesourcery.com>
To: Thiago Jung Bauermann <bauerman@br.ibm.com>
Cc: luisgpm@linux.vnet.ibm.com,  gdb-patches@sourceware.org
Subject: Re: [PATCH] Improve printf DFP support
Date: Tue, 08 Jan 2008 23:54:00 -0000	[thread overview]
Message-ID: <m3d4sblvpt.fsf@codesourcery.com> (raw)
In-Reply-To: <20080108152919.GA21337@caradoc.them.org> (Daniel Jacobowitz's message of "Tue, 8 Jan 2008 10:29:19 -0500")

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


  reply	other threads:[~2008-01-08 23:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-08 13:28 Luis Machado
2008-01-08 15:19 ` Thiago Jung Bauermann
2008-01-08 15:29   ` Daniel Jacobowitz
2008-01-08 23:54     ` Jim Blandy [this message]
2008-01-08 15:29   ` Luis Machado
2008-01-08 20:42 ` Eli Zaretskii
2008-01-09  0:04   ` Luis Machado
2008-01-09  4:14     ` Eli Zaretskii
2008-01-09 12:52     ` Daniel Jacobowitz
2008-01-09 13:51       ` Luis Machado

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3d4sblvpt.fsf@codesourcery.com \
    --to=jimb@codesourcery.com \
    --cc=bauerman@br.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=luisgpm@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox