Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: Thiago Jung Bauermann <bauerman@br.ibm.com>,
	        gdb-patches ml <gdb-patches@sourceware.org>
Subject: Re: [rfc] expose gdb values to python
Date: Wed, 01 Oct 2008 15:12:00 -0000	[thread overview]
Message-ID: <m3ljx8l5cf.fsf@fleche.redhat.com> (raw)
In-Reply-To: <20081001054741.GE3665@adacore.com> (Joel Brobecker's message of "Tue\, 30 Sep 2008 22\:47\:41 -0700")

>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:

>> The underlying question is what type model Value presents.  If a Value
>> has a derived type, should we be able to access fields of the base
>> class using v["f"]?  Or should we need v["Base"]["f"]?

Joel> My initial reaction to this question is that the Value object
Joel> should follow the same semantics as the debugger.

By this I take you to mean the semantics of the currently selected
language...?

Joel> For instance, if class Foo inherits from class Bar, then any
Joel> component of class Bar should be directly visible from class
Joel> Foo. So if X is Value of type class Foo, and class Bar has a
Joel> component named "Baz", then I should be able to access that
Joel> component with X["Baz"].

This is the bad case:

    class B1 { int x; };
    class B2 { int x; };
    class D : B1, B2 { };

Suppose you have a Value v whose type is "D".  An extension author
needs a way to access each 'x'.

I think the current proposal is to try to follow the current language,
and then have the user cast 'v' to B1 or B2 if needed.

The reason I prefer the other, more explicit, approach is that the
meaning of python code does not change depending on a user's language
setting.  However, it is more typing, which is a drawback.

Joel> Better yet, I would love for the object to have one attribute
Joel> for each component that I could simply access using X.baz.
Joel> But I suspect that there is no way we can implement that without
Joel> having to compute the value of each component, which would be
Joel> quite wastful the vast majority of the time. Sigh, is it not
Joel> possible to lazy-initialize attributes?

I think we can do this, but there is a cost, namely conflicts between
methods on Value and field names in the inferior will have to be
resolved in favor of the method.  So, robust programs will always have
to use the [] syntax anyway.

Tom


  reply	other threads:[~2008-10-01 15:12 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-12  6:05 Thiago Jung Bauermann
2008-09-20 21:29 ` Tom Tromey
2008-09-21  4:27   ` Daniel Jacobowitz
2008-09-25  4:33     ` Thiago Jung Bauermann
2008-09-25 11:47       ` Daniel Jacobowitz
2008-09-26  2:00         ` Thiago Jung Bauermann
2008-09-26  9:30           ` Eli Zaretskii
2008-09-28  1:19             ` Thiago Jung Bauermann
2008-09-28 18:19               ` Eli Zaretskii
2008-09-29 16:16                 ` Thiago Jung Bauermann
2008-09-29 17:00                   ` Daniel Jacobowitz
2008-09-30  4:07                     ` Thiago Jung Bauermann
2008-09-30 12:41                       ` Daniel Jacobowitz
2008-10-01  3:18                         ` Thiago Jung Bauermann
2008-10-01 11:40                           ` Daniel Jacobowitz
2008-09-29 18:52                   ` Eli Zaretskii
2008-09-26 20:57           ` Daniel Jacobowitz
2008-10-01  5:39           ` Joel Brobecker
2008-10-04 22:14             ` Thiago Jung Bauermann
2008-09-25  4:49   ` Thiago Jung Bauermann
2008-09-26 23:08     ` Tom Tromey
2008-10-01  5:48   ` Joel Brobecker
2008-10-01 15:12     ` Tom Tromey [this message]
2008-10-01 16:04       ` Joel Brobecker
2008-10-04 22:21       ` Daniel Jacobowitz
2008-10-05  0:00         ` Tom Tromey
2008-10-06 18:49           ` Joel Brobecker
2008-10-06 21:15           ` Daniel Jacobowitz

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=m3ljx8l5cf.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=bauerman@br.ibm.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /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