Re: [PATCH] gdb/python: Introduce gdb.lookup_all_static_symbols

Andrew Burgess
2019-11-11T16:27:36Z

* Christian Biesinger <cbiesinger@google.com> [2019-11-10 16:36:52 -0600]:

> On Sun, Nov 10, 2019 at 4:27 PM Andrew Burgess
> <andrew.burgess@embecosm.com> wrote:
> >
> > * Christian Biesinger <cbiesinger@google.com> [2019-11-09 00:23:00 -0600]:
> >
> > > On Mon, Nov 4, 2019 at 12:28 PM Simon Marchi <simark@simark.ca> wrote:
> > > >
> > > > On 2019-11-04 12:12 p.m., Andrew Burgess wrote:
> > > > > How about I merged patches #1 and #2, but drop #3 for now? This would
> > > > > give:
> > > > >
> > > > > lookup_static_symbol - returns the global static symbol for the
> > > > > current compilation unit, or whatever else GDB can find if
> > > > > there's nothing in the current CU. This is basically inline
> > > > > with what we get from 'print symbol_name' at the CLI (if we
> > > > > limit symbol_name to just global static things).
> > > > >
> > > > > AND,
> > > > >
> > > > > lookup_static_symbols - returns the list of all global static
> > > > > symbols.
> > > > >
> > > > > We no longer have a block parameter passed to 'lookup_static_symbol',
> > > > > so hopefully and confusion can be avoided. If/when we later add a
> > > > > Python wrapper for CU we can _extend_ the API for lookup_static_symbol
> > > > > to also take a CU and so provide the "look over there" type behaviour
> > > > > in a clearer way.
> > > > >
> > > > > Would everyone be happy with this?
> > > >
> > > > I certainly would, I think that brings us back to the same place we were before
> > > > it was suggested to add the block parameter, doesn't it?
> > >
> > > Sorry for the late reply & for confusing things -- yes, after reading
> > > through all the discussions I think that's the best way forward.
> >
> > Thanks for the feedback.
> >
> > I've now pushed patches #1 and #2.
>
> Thanks! By the way, should Objfile also get a lookup_static_symbols
> method now, similar to Objfile.lookup_static_symbol?
>
> (I don't personally have a use-case for this, but figured I should
> ask)

I don't think that's a crazy idea, but I don't plan to write one right
now.

My interest in this area started when I was auditing how the GDB
function lookup_static_function (the one in symtab.c) was used, and I
felt that the way it was used in the python code wasn't quite right.
I don't have any specific use cases to address.

We can always add extra API methods later if/when there's a need for
them without breaking backward compatibility, so I'm happy to leave
this for now.

Thanks,
Andrew