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

Simon Marchi simark@simark.ca
Fri Jul 26 22:43:00 GMT 2019


On 2019-07-26 18:04, Christian Biesinger wrote:
> 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)

Agreed, it would be a bit confusing to pass a block to a 'lookup' 
function, and have the search actually done in another 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 agree.

> - I'd be happy to add a patch that adds makes block['foo'] work, in
> addition to the currently-existing iteration

That is a separate issue, but yeah, if blocks can be seen as containers 
of symbols, and symbol names are guaranteed to be unique within a block, 
then it sounds like it would be handy.

> 
> Conversely, lookup_static_symbol without a block does add new 
> functionality.

Yes, and it's always possible to add parameters after if needed since 
it's Python.

> I will send a new patch with this in a moment.

Thanks,

Simon



More information about the Gdb-patches mailing list