This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH][PR/24474] Make gdb.lookup_static_symbol also check the STATIC_SCOPE
- From: "Christian Biesinger via gdb-patches" <gdb-patches at sourceware dot org>
- To: Simon Marchi <simark at simark dot ca>
- Cc: Christian Biesinger via gdb-patches <gdb-patches at sourceware dot org>
- Date: Fri, 26 Jul 2019 15:04:51 -0700
- Subject: Re: [PATCH][PR/24474] Make gdb.lookup_static_symbol also check the STATIC_SCOPE
- References: <20190605012421.252953-1-cbiesinger@google.com> <8f4bcc74-18a0-c8f6-b97d-aef05021a656@simark.ca>
- Reply-to: Christian Biesinger <cbiesinger at google dot com>
On Mon, Jul 15, 2019 at 8:28 PM Simon Marchi <simark@simark.ca> wrote:
> Would it be an option to add a gdb.lookup_static_symbol function, that would only look through
> the static blocks? Its behavior could be that if you don't pass a block, it searches through
> all the static blocks until it finds a matching symbol (just like your patch does with
> gdb.lookup_global_symbol if no symbol is found). And if you pass a block, it restricts the
> search to the static block linked to that block, ensuring you find the static symbol you want.
Thanks for your response! I have started implementing this and
concluded that I would prefer not to add a block argument with this
behavior to lookup_static_symbol:
- If I add it with the behavior you suggest, this will be very
confusing to use because it won't find function-local static variables
(they are not part of the static block)
- It does not add new functionality. You can already access static
symbols if you have a block: [sym for sym in block if sym.addr_class
== gdb.SYMBOL_LOC_STATIC]. And you can already do that in a function's
static block too, using block.static_block.
- I'd be happy to add a patch that adds makes block['foo'] work, in
addition to the currently-existing iteration
Conversely, lookup_static_symbol without a block does add new functionality.
I will send a new patch with this in a moment.
Christian