aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2022-12-06 12:49:55 +0000
committerAndrew Burgess <aburgess@redhat.com>2022-12-14 10:56:47 +0000
commit2698da268bdd0b4a6815a15b41a42bac5f928ca7 (patch)
treeec64c7c492dff05d06e21431688b0a11a6c1b2d2 /gdb
parentb1e678d920e4468cfd69a40560ee24834f6bdce4 (diff)
downloadgdb-2698da268bdd0b4a6815a15b41a42bac5f928ca7.zip
gdb-2698da268bdd0b4a6815a15b41a42bac5f928ca7.tar.gz
gdb-2698da268bdd0b4a6815a15b41a42bac5f928ca7.tar.bz2
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.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/symtab.c4
-rw-r--r--gdb/symtab.h29
2 files changed, 29 insertions, 4 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 14d81f5..a7a5415 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1950,6 +1950,8 @@ lookup_symbol_in_language (const char *name, const struct block *block,
const domain_enum domain, enum language lang,
struct field_of_this_result *is_a_field_of_this)
{
+ SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT;
+
demangle_result_storage storage;
const char *modified_name = demangle_for_lookup (name, lang, storage);
@@ -2072,6 +2074,8 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
const domain_enum domain, enum language language,
struct field_of_this_result *is_a_field_of_this)
{
+ SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT;
+
struct block_symbol result;
const struct language_defn *langdef;
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 6eca61a..d0fa3b1 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -2625,17 +2625,38 @@ extern unsigned int symtab_create_debug;
extern unsigned int symbol_lookup_debug;
+/* Return true if symbol-lookup debug is turned on at all. */
+
+static inline bool
+symbol_lookup_debug_enabled ()
+{
+ return symbol_lookup_debug > 0;
+}
+
+/* Return true if symbol-lookup debug is turned to verbose mode. */
+
+static inline bool
+symbol_lookup_debug_enabled_v ()
+{
+ return symbol_lookup_debug > 1;
+}
+
/* Print a "symbol-lookup" debug statement if symbol_lookup_debug is >= 1. */
#define symbol_lookup_debug_printf(fmt, ...) \
- debug_prefixed_printf_cond (symbol_lookup_debug >= 1, "symbol-lookup", fmt, \
- ##__VA_ARGS__)
+ debug_prefixed_printf_cond (symbol_lookup_debug_enabled (), \
+ "symbol-lookup", fmt, ##__VA_ARGS__)
/* Print a "symbol-lookup" debug statement if symbol_lookup_debug is >= 2. */
#define symbol_lookup_debug_printf_v(fmt, ...) \
- debug_prefixed_printf_cond (symbol_lookup_debug >= 2, "symbol-lookup", fmt, \
- ##__VA_ARGS__)
+ debug_prefixed_printf_cond (symbol_lookup_debug_enabled_v (), \
+ "symbol-lookup", fmt, ##__VA_ARGS__)
+
+/* Print "symbol-lookup" enter/exit debug statements. */
+
+#define SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT \
+ scoped_debug_enter_exit (symbol_lookup_debug_enabled, "symbol-lookup")
extern bool basenames_may_differ;