This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][PR/24474] Make gdb.lookup_static_symbol also check the STATIC_SCOPE


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]