Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Doug Evans <dje@google.com>
To: Tom Tromey <tromey@redhat.com>
Cc: Tristan Su <sooqing@gmail.com>, gdb <gdb@sourceware.org>
Subject: Re: can pahole print a struct definition in a given CU?
Date: Wed, 02 Jan 2013 18:56:00 -0000	[thread overview]
Message-ID: <CADPb22ToZbGzscJ4gSN+GOLEqdMfF-U30n3eGn9BW7A8hCOpgw@mail.gmail.com> (raw)
In-Reply-To: <87fw2j5w4y.fsf@fleche.redhat.com>

On Wed, Jan 2, 2013 at 10:31 AM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Tristan" == Tristan Su <sooqing@gmail.com> writes:
>
> Tristan> I found pahole (python api) quite useful but jusst could not have it
> Tristan> print a struct in a given compilation unit.
> Tristan> With the ptype command:
> Tristan> (gdb) ptype S
> Tristan> but we can also specify the CU because the struct may have different
> Tristan> define in different CUs.
> Tristan> (gdb) ptype 'foo.c'::S
>
> Tristan> Is that possible/easy to make pahole support this?
>
> I couldn't think of an easy way.  Though maybe that is just imagination
> failure on my part :)
>
> If I were doing this I would start by finding a way to expose
> evaluate_type to Python, say via a flag to parse_and_eval.
> Then I would make pahole use this.

I realize we're talking about types here, but there's a general
problem here, and there's another approach to choosing object foo from
source bar.c.  [This doesn't immediately help with the pahole issue
here, but it's a thought that occurred to me, so I'm writing it down.]

It's seems like what's needed is a handle on the symtab(CU), and then
a way to go from there, instead of encoding the symtab in the
expression.
Since expressions in the source work that way, making things like "p
'bar.c'::foo + 'baz.c'::foo" work seems like excessive generality.
[For completeness sake, I realize that works today and we can't break
it.  Still, I think there's room for improvement.]

Thus,
what about adding a "context" parameter to parse_and_eval, etc.?
And then provide a way to specify that context (e.g., both from the
CLI and from Python).

We'd still have to support "p 'bar.c'::foo + 'baz.c::foo'", but when,
e.g, cut-n-pasting expressions from source we shouldn't have to force
the user to insert 'bar.c::' in front of objects that gdb might end up
otherwise picking the wrong one for.

E.g., something like: (gdb) with-symtab bar.c p foo+baz
or whatever.


  reply	other threads:[~2013-01-02 18:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-24 14:15 Tristan Su
2013-01-02 17:32 ` Tom Tromey
2013-01-02 18:56   ` Doug Evans [this message]
2013-01-02 19:05     ` Tom Tromey
2013-01-02 19:06     ` Doug Evans

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=CADPb22ToZbGzscJ4gSN+GOLEqdMfF-U30n3eGn9BW7A8hCOpgw@mail.gmail.com \
    --to=dje@google.com \
    --cc=gdb@sourceware.org \
    --cc=sooqing@gmail.com \
    --cc=tromey@redhat.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