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

Christian Biesinger via gdb-patches
2019-11-09T06:23:43Z

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.

My personal use case was & is still addressed, I just wanted a way to
find variables like these:
https://cs.chromium.org/chromium/src/content/renderer/render_frame_impl.cc?q=g_frame_map&sq=package:chromium&g=0&l=332
(^ in an anonymous namespace)

ideally also:
https://cs.chromium.org/chromium/src/ui/accessibility/ax_tree_manager_map.cc?type=cs&sq=package:chromium&g=0&l=17
(static variable in a function)
But I do have a fallback to gdb.lookup_symbol, so that one works too,
though less efficiently. Even with a CU API, this might be difficult
(maybe? depending how easy it is to find a specific function from a
CU)

Christian