]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gdb/symtab.c
gdb: add SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT
authorAndrew Burgess <aburgess@redhat.com>
Tue, 6 Dec 2022 12:49:55 +0000 (12:49 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Wed, 14 Dec 2022 10:56:47 +0000 (10:56 +0000)
commit2698da268bdd0b4a6815a15b41a42bac5f928ca7
treeec64c7c492dff05d06e21431688b0a11a6c1b2d2
parentb1e678d920e4468cfd69a40560ee24834f6bdce4
gdb: add SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT

After the previous commit converted symbol-lookup debug to use the new
debug scheme, this commit adds SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT.

The previous commit didn't add SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT
because symbol-lookup debug is controlled by an 'unsigned int' rather
than a 'bool' control variable, we use the numeric value to offer
different levels of verbosity for symbol-lookup debug.

The *_SCOPED_DEBUG_ENTER_EXIT mechanism currently relies on capturing
a reference to the bool control variable, and evaluating the variable
both on entry, and at exit, this is done in the scoped_debug_start_end
class (see gdbsupport/common-debug.h).

This commit templates scoped_debug_start_end so that the class can
accept either a 'bool &' or an invokable object, e.g. a lambda
function, or a function pointer.

The existing scoped_debug_start_end and scoped_debug_enter_exit macros
in common-debug.h are updated to support scoped_debug_enter_exit being
templated, however, nothing outside of common-debug.h needs to change.

I've then added SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT in symtab.h, and
added a couple of token uses in symtab.c.  I didn't want to add too
much in this first commit, this is really about updating
common-debug.h to support this new functionality.

Within symtab.h I created a couple of global functions that can be
used to query the status of the symbol_lookup_debug control variable,
these functions are then used within the two existing macros:

  symbol_lookup_debug_printf
  symbol_lookup_debug_printf_v

and also in the new SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT macro.
gdb/symtab.c
gdb/symtab.h
gdbsupport/common-debug.h