gdb: convert 'set debug symbol-lookup' to new debug printing scheme

Convert the implementation of 'set debug symbol-lookup' to the new
debug printing scheme.

In a few places I've updated the debug output to remove places where
the printed debug message included the function name, the new debug
scheme already adds that, but I haven't done all the possible updates.
This commit is contained in:
Andrew Burgess 2022-12-02 12:10:10 +00:00
parent 9f50fe0835
commit b1e678d920
6 changed files with 161 additions and 276 deletions

View file

@ -507,14 +507,9 @@ cp_lookup_symbol_imports_or_template (const char *scope,
struct symbol *function = block->function (); struct symbol *function = block->function ();
struct block_symbol result; struct block_symbol result;
if (symbol_lookup_debug) symbol_lookup_debug_printf
{ ("cp_lookup_symbol_imports_or_template (%s, %s, %s, %s)",
gdb_printf (gdb_stdlog, scope, name, host_address_to_string (block), domain_name (domain));
"cp_lookup_symbol_imports_or_template"
" (%s, %s, %s, %s)\n",
scope, name, host_address_to_string (block),
domain_name (domain));
}
if (function != NULL && function->language () == language_cplus) if (function != NULL && function->language () == language_cplus)
{ {
@ -529,13 +524,9 @@ cp_lookup_symbol_imports_or_template (const char *scope,
if (sym != NULL) if (sym != NULL)
{ {
if (symbol_lookup_debug) symbol_lookup_debug_printf
{ ("cp_lookup_symbol_imports_or_template (...) = %s",
gdb_printf (gdb_stdlog,
"cp_lookup_symbol_imports_or_template"
" (...) = %s\n",
host_address_to_string (sym)); host_address_to_string (sym));
}
return (struct block_symbol) {sym, block}; return (struct block_symbol) {sym, block};
} }
} }
@ -574,13 +565,9 @@ cp_lookup_symbol_imports_or_template (const char *scope,
TYPE_TEMPLATE_ARGUMENTS (context)); TYPE_TEMPLATE_ARGUMENTS (context));
if (sym != NULL) if (sym != NULL)
{ {
if (symbol_lookup_debug) symbol_lookup_debug_printf
{ ("cp_lookup_symbol_imports_or_template (...) = %s",
gdb_printf
(gdb_stdlog,
"cp_lookup_symbol_imports_or_template (...) = %s\n",
host_address_to_string (sym)); host_address_to_string (sym));
}
return (struct block_symbol) {sym, parent}; return (struct block_symbol) {sym, parent};
} }
} }
@ -588,13 +575,9 @@ cp_lookup_symbol_imports_or_template (const char *scope,
} }
result = cp_lookup_symbol_via_imports (scope, name, block, domain, 0, 1, 1); result = cp_lookup_symbol_via_imports (scope, name, block, domain, 0, 1, 1);
if (symbol_lookup_debug) symbol_lookup_debug_printf
{ ("cp_lookup_symbol_imports_or_template (...) = %s",
gdb_printf (gdb_stdlog, result.symbol != NULL ? host_address_to_string (result.symbol) : "NULL");
"cp_lookup_symbol_imports_or_template (...) = %s\n",
result.symbol != NULL
? host_address_to_string (result.symbol) : "NULL");
}
return result; return result;
} }
@ -634,13 +617,9 @@ cp_lookup_symbol_namespace (const char *scope,
{ {
struct block_symbol sym; struct block_symbol sym;
if (symbol_lookup_debug) symbol_lookup_debug_printf ("cp_lookup_symbol_namespace (%s, %s, %s, %s)",
{
gdb_printf (gdb_stdlog,
"cp_lookup_symbol_namespace (%s, %s, %s, %s)\n",
scope, name, host_address_to_string (block), scope, name, host_address_to_string (block),
domain_name (domain)); domain_name (domain));
}
/* First, try to find the symbol in the given namespace. */ /* First, try to find the symbol in the given namespace. */
sym = cp_lookup_symbol_in_namespace (scope, name, block, domain, 1); sym = cp_lookup_symbol_in_namespace (scope, name, block, domain, 1);
@ -649,13 +628,9 @@ cp_lookup_symbol_namespace (const char *scope,
if (sym.symbol == NULL) if (sym.symbol == NULL)
sym = cp_lookup_symbol_via_all_imports (scope, name, block, domain); sym = cp_lookup_symbol_via_all_imports (scope, name, block, domain);
if (symbol_lookup_debug) symbol_lookup_debug_printf ("cp_lookup_symbol_namespace (...) = %s",
{
gdb_printf (gdb_stdlog,
"cp_lookup_symbol_namespace (...) = %s\n",
sym.symbol != NULL sym.symbol != NULL
? host_address_to_string (sym.symbol) : "NULL"); ? host_address_to_string (sym.symbol) : "NULL");
}
return sym; return sym;
} }
@ -740,14 +715,9 @@ cp_lookup_symbol_nonlocal (const struct language_defn *langdef,
struct block_symbol sym; struct block_symbol sym;
const char *scope = block_scope (block); const char *scope = block_scope (block);
if (symbol_lookup_debug) symbol_lookup_debug_printf
{ ("cp_lookup_symbol_non_local (%s, %s (scope %s), %s)",
gdb_printf (gdb_stdlog, name, host_address_to_string (block), scope, domain_name (domain));
"cp_lookup_symbol_non_local"
" (%s, %s (scope %s), %s)\n",
name, host_address_to_string (block), scope,
domain_name (domain));
}
/* First, try to find the symbol in the given namespace, and all /* First, try to find the symbol in the given namespace, and all
containing namespaces. */ containing namespaces. */
@ -757,14 +727,10 @@ cp_lookup_symbol_nonlocal (const struct language_defn *langdef,
if (sym.symbol == NULL) if (sym.symbol == NULL)
sym = cp_lookup_symbol_via_all_imports (scope, name, block, domain); sym = cp_lookup_symbol_via_all_imports (scope, name, block, domain);
if (symbol_lookup_debug) symbol_lookup_debug_printf ("cp_lookup_symbol_nonlocal (...) = %s",
{
gdb_printf (gdb_stdlog,
"cp_lookup_symbol_nonlocal (...) = %s\n",
(sym.symbol != NULL (sym.symbol != NULL
? host_address_to_string (sym.symbol) ? host_address_to_string (sym.symbol)
: "NULL")); : "NULL"));
}
return sym; return sym;
} }
@ -921,8 +887,7 @@ cp_lookup_nested_symbol (struct type *parent_type,
{ {
const char *type_name = saved_parent_type->name (); const char *type_name = saved_parent_type->name ();
gdb_printf (gdb_stdlog, symbol_lookup_debug_printf ("cp_lookup_nested_symbol (%s, %s, %s, %s)",
"cp_lookup_nested_symbol (%s, %s, %s, %s)\n",
type_name != NULL ? type_name : "unnamed", type_name != NULL ? type_name : "unnamed",
nested_name, host_address_to_string (block), nested_name, host_address_to_string (block),
domain_name (domain)); domain_name (domain));
@ -955,25 +920,17 @@ cp_lookup_nested_symbol (struct type *parent_type,
concatenated_name, block, domain, concatenated_name, block, domain,
1, is_in_anonymous); 1, is_in_anonymous);
if (symbol_lookup_debug) symbol_lookup_debug_printf ("cp_lookup_nested_symbol (...) = %s",
{
gdb_printf (gdb_stdlog,
"cp_lookup_nested_symbol (...) = %s\n",
(sym.symbol != NULL (sym.symbol != NULL
? host_address_to_string (sym.symbol) ? host_address_to_string (sym.symbol)
: "NULL")); : "NULL"));
}
return sym; return sym;
} }
case TYPE_CODE_FUNC: case TYPE_CODE_FUNC:
case TYPE_CODE_METHOD: case TYPE_CODE_METHOD:
if (symbol_lookup_debug) symbol_lookup_debug_printf
{ ("cp_lookup_nested_symbol (...) = NULL (func/method)");
gdb_printf (gdb_stdlog,
"cp_lookup_nested_symbol (...) = NULL"
" (func/method)\n");
}
return {}; return {};
default: default:

View file

@ -1077,17 +1077,15 @@ language_lookup_primitive_type_as_symbol (const struct language_defn *la,
struct language_gdbarch *ld = get_language_gdbarch (gdbarch); struct language_gdbarch *ld = get_language_gdbarch (gdbarch);
struct language_arch_info *lai = &ld->arch_info[la->la_language]; struct language_arch_info *lai = &ld->arch_info[la->la_language];
if (symbol_lookup_debug) symbol_lookup_debug_printf
gdb_printf (gdb_stdlog, ("language = \"%s\", gdbarch @ %s, type = \"%s\")",
"language_lookup_primitive_type_as_symbol"
" (%s, %s, %s)",
la->name (), host_address_to_string (gdbarch), name); la->name (), host_address_to_string (gdbarch), name);
struct symbol *sym struct symbol *sym
= lai->lookup_primitive_type_as_symbol (name, la->la_language); = lai->lookup_primitive_type_as_symbol (name, la->la_language);
if (symbol_lookup_debug) symbol_lookup_debug_printf ("found symbol @ %s",
gdb_printf (gdb_stdlog, " = %s\n", host_address_to_string (sym)); host_address_to_string (sym));
/* Note: The result of symbol lookup is normally a symbol *and* the block /* Note: The result of symbol lookup is normally a symbol *and* the block
it was found in. Builtin types don't live in blocks. We *could* give it was found in. Builtin types don't live in blocks. We *could* give

View file

@ -385,13 +385,9 @@ lookup_minimal_symbol (const char *name, const char *sfile,
if (objf == NULL || objf == objfile if (objf == NULL || objf == objfile
|| objf == objfile->separate_debug_objfile_backlink) || objf == objfile->separate_debug_objfile_backlink)
{ {
if (symbol_lookup_debug) symbol_lookup_debug_printf ("lookup_minimal_symbol (%s, %s, %s)",
{
gdb_printf (gdb_stdlog,
"lookup_minimal_symbol (%s, %s, %s)\n",
name, sfile != NULL ? sfile : "NULL", name, sfile != NULL ? sfile : "NULL",
objfile_debug_name (objfile)); objfile_debug_name (objfile));
}
/* Do two passes: the first over the ordinary hash table, /* Do two passes: the first over the ordinary hash table,
and the second over the demangled hash table. */ and the second over the demangled hash table. */
@ -438,8 +434,8 @@ lookup_minimal_symbol (const char *name, const char *sfile,
{ {
minimal_symbol *minsym = found.external_symbol.minsym; minimal_symbol *minsym = found.external_symbol.minsym;
gdb_printf (gdb_stdlog, symbol_lookup_debug_printf
"lookup_minimal_symbol (...) = %s (external)\n", ("lookup_minimal_symbol (...) = %s (external)",
host_address_to_string (minsym)); host_address_to_string (minsym));
} }
return found.external_symbol; return found.external_symbol;
@ -452,8 +448,8 @@ lookup_minimal_symbol (const char *name, const char *sfile,
{ {
minimal_symbol *minsym = found.file_symbol.minsym; minimal_symbol *minsym = found.file_symbol.minsym;
gdb_printf (gdb_stdlog, symbol_lookup_debug_printf
"lookup_minimal_symbol (...) = %s (file-local)\n", ("lookup_minimal_symbol (...) = %s (file-local)",
host_address_to_string (minsym)); host_address_to_string (minsym));
} }
return found.file_symbol; return found.file_symbol;
@ -466,8 +462,8 @@ lookup_minimal_symbol (const char *name, const char *sfile,
{ {
minimal_symbol *minsym = found.trampoline_symbol.minsym; minimal_symbol *minsym = found.trampoline_symbol.minsym;
gdb_printf (gdb_stdlog, symbol_lookup_debug_printf
"lookup_minimal_symbol (...) = %s (trampoline)\n", ("lookup_minimal_symbol (...) = %s (trampoline)",
host_address_to_string (minsym)); host_address_to_string (minsym));
} }
@ -475,8 +471,7 @@ lookup_minimal_symbol (const char *name, const char *sfile,
} }
/* Not found. */ /* Not found. */
if (symbol_lookup_debug) symbol_lookup_debug_printf ("lookup_minimal_symbol (...) = NULL");
gdb_printf (gdb_stdlog, "lookup_minimal_symbol (...) = NULL\n");
return {}; return {};
} }

View file

@ -148,14 +148,10 @@ public:
{ {
struct block_symbol result = {}; struct block_symbol result = {};
if (symbol_lookup_debug) symbol_lookup_debug_printf
{ ("rust_lookup_symbol_non_local (%s, %s (scope %s), %s)",
gdb_printf (gdb_stdlog, name, host_address_to_string (block), block_scope (block),
"rust_lookup_symbol_non_local" domain_name (domain));
" (%s, %s (scope %s), %s)\n",
name, host_address_to_string (block),
block_scope (block), domain_name (domain));
}
/* Look up bare names in the block's scope. */ /* Look up bare names in the block's scope. */
std::string scopedname; std::string scopedname;

View file

@ -1424,13 +1424,11 @@ symbol_cache_lookup (struct symbol_cache *cache,
if (eq_symbol_entry (slot, objfile_context, name, domain)) if (eq_symbol_entry (slot, objfile_context, name, domain))
{ {
if (symbol_lookup_debug) symbol_lookup_debug_printf ("%s block symbol cache hit%s for %s, %s",
gdb_printf (gdb_stdlog,
"%s block symbol cache hit%s for %s, %s\n",
block == GLOBAL_BLOCK ? "Global" : "Static", block == GLOBAL_BLOCK ? "Global" : "Static",
slot->state == SYMBOL_SLOT_NOT_FOUND slot->state == SYMBOL_SLOT_NOT_FOUND
? " (not found)" : "", ? " (not found)" : "", name,
name, domain_name (domain)); domain_name (domain));
++bsc->hits; ++bsc->hits;
if (slot->state == SYMBOL_SLOT_NOT_FOUND) if (slot->state == SYMBOL_SLOT_NOT_FOUND)
return SYMBOL_LOOKUP_FAILED; return SYMBOL_LOOKUP_FAILED;
@ -1439,13 +1437,9 @@ symbol_cache_lookup (struct symbol_cache *cache,
/* Symbol is not present in the cache. */ /* Symbol is not present in the cache. */
if (symbol_lookup_debug) symbol_lookup_debug_printf ("%s block symbol cache miss for %s, %s",
{
gdb_printf (gdb_stdlog,
"%s block symbol cache miss for %s, %s\n",
block == GLOBAL_BLOCK ? "Global" : "Static", block == GLOBAL_BLOCK ? "Global" : "Static",
name, domain_name (domain)); name, domain_name (domain));
}
++bsc->misses; ++bsc->misses;
return {}; return {};
} }
@ -1996,15 +1990,9 @@ lookup_language_this (const struct language_defn *lang,
if (lang->name_of_this () == NULL || block == NULL) if (lang->name_of_this () == NULL || block == NULL)
return {}; return {};
if (symbol_lookup_debug > 1) symbol_lookup_debug_printf_v ("lookup_language_this (%s, %s (objfile %s))",
{
struct objfile *objfile = block_objfile (block);
gdb_printf (gdb_stdlog,
"lookup_language_this (%s, %s (objfile %s))",
lang->name (), host_address_to_string (block), lang->name (), host_address_to_string (block),
objfile_debug_name (objfile)); objfile_debug_name (block_objfile (block)));
}
while (block) while (block)
{ {
@ -2015,13 +2003,10 @@ lookup_language_this (const struct language_defn *lang,
VAR_DOMAIN); VAR_DOMAIN);
if (sym != NULL) if (sym != NULL)
{ {
if (symbol_lookup_debug > 1) symbol_lookup_debug_printf_v
{ ("lookup_language_this (...) = %s (%s, block %s)",
gdb_printf (gdb_stdlog, " = %s (%s, block %s)\n", sym->print_name (), host_address_to_string (sym),
sym->print_name (),
host_address_to_string (sym),
host_address_to_string (block)); host_address_to_string (block));
}
return (struct block_symbol) {sym, block}; return (struct block_symbol) {sym, block};
} }
if (block->function ()) if (block->function ())
@ -2029,8 +2014,7 @@ lookup_language_this (const struct language_defn *lang,
block = block->superblock (); block = block->superblock ();
} }
if (symbol_lookup_debug > 1) symbol_lookup_debug_printf_v ("lookup_language_this (...) = NULL");
gdb_printf (gdb_stdlog, " = NULL\n");
return {}; return {};
} }
@ -2096,11 +2080,12 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
struct objfile *objfile = (block == nullptr struct objfile *objfile = (block == nullptr
? nullptr : block_objfile (block)); ? nullptr : block_objfile (block));
gdb_printf (gdb_stdlog, symbol_lookup_debug_printf
"lookup_symbol_aux (%s, %s (objfile %s), %s, %s)\n", ("demangled symbol name = \"%s\", block @ %s (objfile %s)",
name, host_address_to_string (block), name, host_address_to_string (block),
objfile != NULL objfile != NULL ? objfile_debug_name (objfile) : "NULL");
? objfile_debug_name (objfile) : "NULL", symbol_lookup_debug_printf
("domain name = \"%s\", language = \"%s\")",
domain_name (domain), language_str (language)); domain_name (domain), language_str (language));
} }
@ -2117,11 +2102,9 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
result = lookup_local_symbol (name, match_type, block, domain, language); result = lookup_local_symbol (name, match_type, block, domain, language);
if (result.symbol != NULL) if (result.symbol != NULL)
{ {
if (symbol_lookup_debug) symbol_lookup_debug_printf
{ ("found symbol @ %s (using lookup_local_symbol)",
gdb_printf (gdb_stdlog, "lookup_symbol_aux (...) = %s\n",
host_address_to_string (result.symbol)); host_address_to_string (result.symbol));
}
return result; return result;
} }
@ -2154,11 +2137,7 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
if (check_field (t, name, is_a_field_of_this)) if (check_field (t, name, is_a_field_of_this))
{ {
if (symbol_lookup_debug) symbol_lookup_debug_printf ("no symbol found");
{
gdb_printf (gdb_stdlog,
"lookup_symbol_aux (...) = NULL\n");
}
return {}; return {};
} }
} }
@ -2170,11 +2149,9 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
result = langdef->lookup_symbol_nonlocal (name, block, domain); result = langdef->lookup_symbol_nonlocal (name, block, domain);
if (result.symbol != NULL) if (result.symbol != NULL)
{ {
if (symbol_lookup_debug) symbol_lookup_debug_printf
{ ("found symbol @ %s (using language lookup_symbol_nonlocal)",
gdb_printf (gdb_stdlog, "lookup_symbol_aux (...) = %s\n",
host_address_to_string (result.symbol)); host_address_to_string (result.symbol));
}
return result; return result;
} }
@ -2182,13 +2159,9 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
but more useful than an error. */ but more useful than an error. */
result = lookup_static_symbol (name, domain); result = lookup_static_symbol (name, domain);
if (symbol_lookup_debug) symbol_lookup_debug_printf
{ ("found symbol @ %s (using lookup_static_symbol)",
gdb_printf (gdb_stdlog, "lookup_symbol_aux (...) = %s\n", result.symbol != NULL ? host_address_to_string (result.symbol) : "NULL");
result.symbol != NULL
? host_address_to_string (result.symbol)
: "NULL");
}
return result; return result;
} }
@ -2246,31 +2219,27 @@ lookup_symbol_in_block (const char *name, symbol_name_match_type match_type,
{ {
struct symbol *sym; struct symbol *sym;
if (symbol_lookup_debug > 1) if (symbol_lookup_debug)
{ {
struct objfile *objfile = (block == nullptr struct objfile *objfile
? nullptr : block_objfile (block)); = block == nullptr ? nullptr : block_objfile (block);
gdb_printf (gdb_stdlog, symbol_lookup_debug_printf_v
"lookup_symbol_in_block (%s, %s (objfile %s), %s)", ("lookup_symbol_in_block (%s, %s (objfile %s), %s)",
name, host_address_to_string (block), name, host_address_to_string (block),
objfile_debug_name (objfile), objfile != nullptr ? objfile_debug_name (objfile) : "NULL",
domain_name (domain)); domain_name (domain));
} }
sym = block_lookup_symbol (block, name, match_type, domain); sym = block_lookup_symbol (block, name, match_type, domain);
if (sym) if (sym)
{ {
if (symbol_lookup_debug > 1) symbol_lookup_debug_printf_v ("lookup_symbol_in_block (...) = %s",
{
gdb_printf (gdb_stdlog, " = %s\n",
host_address_to_string (sym)); host_address_to_string (sym));
}
return fixup_symbol_section (sym, NULL); return fixup_symbol_section (sym, NULL);
} }
if (symbol_lookup_debug > 1) symbol_lookup_debug_printf_v ("lookup_symbol_in_block (...) = NULL");
gdb_printf (gdb_stdlog, " = NULL\n");
return NULL; return NULL;
} }
@ -2308,15 +2277,11 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
{ {
gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK); gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK);
if (symbol_lookup_debug > 1) symbol_lookup_debug_printf_v
{ ("lookup_symbol_in_objfile_symtabs (%s, %s, %s, %s)",
gdb_printf (gdb_stdlog,
"lookup_symbol_in_objfile_symtabs (%s, %s, %s, %s)",
objfile_debug_name (objfile), objfile_debug_name (objfile),
block_index == GLOBAL_BLOCK block_index == GLOBAL_BLOCK ? "GLOBAL_BLOCK" : "STATIC_BLOCK",
? "GLOBAL_BLOCK" : "STATIC_BLOCK",
name, domain_name (domain)); name, domain_name (domain));
}
struct block_symbol other; struct block_symbol other;
other.symbol = NULL; other.symbol = NULL;
@ -2352,18 +2317,16 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
if (other.symbol != NULL) if (other.symbol != NULL)
{ {
if (symbol_lookup_debug > 1) symbol_lookup_debug_printf_v
{ ("lookup_symbol_in_objfile_symtabs (...) = %s (block %s)",
gdb_printf (gdb_stdlog, " = %s (block %s)\n",
host_address_to_string (other.symbol), host_address_to_string (other.symbol),
host_address_to_string (other.block)); host_address_to_string (other.block));
}
other.symbol = fixup_symbol_section (other.symbol, objfile); other.symbol = fixup_symbol_section (other.symbol, objfile);
return other; return other;
} }
if (symbol_lookup_debug > 1) symbol_lookup_debug_printf_v
gdb_printf (gdb_stdlog, " = NULL\n"); ("lookup_symbol_in_objfile_symtabs (...) = NULL");
return {}; return {};
} }
@ -2438,24 +2401,17 @@ lookup_symbol_via_quick_fns (struct objfile *objfile,
const struct block *block; const struct block *block;
struct block_symbol result; struct block_symbol result;
if (symbol_lookup_debug > 1) symbol_lookup_debug_printf_v
{ ("lookup_symbol_via_quick_fns (%s, %s, %s, %s)",
gdb_printf (gdb_stdlog,
"lookup_symbol_via_quick_fns (%s, %s, %s, %s)\n",
objfile_debug_name (objfile), objfile_debug_name (objfile),
block_index == GLOBAL_BLOCK block_index == GLOBAL_BLOCK ? "GLOBAL_BLOCK" : "STATIC_BLOCK",
? "GLOBAL_BLOCK" : "STATIC_BLOCK",
name, domain_name (domain)); name, domain_name (domain));
}
cust = objfile->lookup_symbol (block_index, name, domain); cust = objfile->lookup_symbol (block_index, name, domain);
if (cust == NULL) if (cust == NULL)
{ {
if (symbol_lookup_debug > 1) symbol_lookup_debug_printf_v
{ ("lookup_symbol_via_quick_fns (...) = NULL");
gdb_printf (gdb_stdlog,
"lookup_symbol_via_quick_fns (...) = NULL\n");
}
return {}; return {};
} }
@ -2466,13 +2422,10 @@ lookup_symbol_via_quick_fns (struct objfile *objfile,
if (result.symbol == NULL) if (result.symbol == NULL)
error_in_psymtab_expansion (block_index, name, cust); error_in_psymtab_expansion (block_index, name, cust);
if (symbol_lookup_debug > 1) symbol_lookup_debug_printf_v
{ ("lookup_symbol_via_quick_fns (...) = %s (block %s)",
gdb_printf (gdb_stdlog,
"lookup_symbol_via_quick_fns (...) = %s (block %s)\n",
host_address_to_string (result.symbol), host_address_to_string (result.symbol),
host_address_to_string (block)); host_address_to_string (block));
}
result.symbol = fixup_symbol_section (result.symbol, objfile); result.symbol = fixup_symbol_section (result.symbol, objfile);
result.block = block; result.block = block;
@ -2538,24 +2491,19 @@ lookup_symbol_in_static_block (const char *name,
struct objfile *objfile = (block == nullptr struct objfile *objfile = (block == nullptr
? nullptr : block_objfile (block)); ? nullptr : block_objfile (block));
gdb_printf (gdb_stdlog, symbol_lookup_debug_printf
"lookup_symbol_in_static_block (%s, %s (objfile %s)," ("lookup_symbol_in_static_block (%s, %s (objfile %s), %s)",
" %s)\n", name, host_address_to_string (block),
name, objfile != nullptr ? objfile_debug_name (objfile) : "NULL",
host_address_to_string (block),
objfile_debug_name (objfile),
domain_name (domain)); domain_name (domain));
} }
sym = lookup_symbol_in_block (name, sym = lookup_symbol_in_block (name,
symbol_name_match_type::FULL, symbol_name_match_type::FULL,
static_block, domain); static_block, domain);
if (symbol_lookup_debug) symbol_lookup_debug_printf ("lookup_symbol_in_static_block (...) = %s",
{ sym != NULL
gdb_printf (gdb_stdlog, ? host_address_to_string (sym) : "NULL");
"lookup_symbol_in_static_block (...) = %s\n",
sym != NULL ? host_address_to_string (sym) : "NULL");
}
return (struct block_symbol) {sym, static_block}; return (struct block_symbol) {sym, static_block};
} }
@ -2572,41 +2520,30 @@ lookup_symbol_in_objfile (struct objfile *objfile, enum block_enum block_index,
gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK); gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK);
if (symbol_lookup_debug) symbol_lookup_debug_printf ("lookup_symbol_in_objfile (%s, %s, %s, %s)",
{
gdb_printf (gdb_stdlog,
"lookup_symbol_in_objfile (%s, %s, %s, %s)\n",
objfile_debug_name (objfile), objfile_debug_name (objfile),
block_index == GLOBAL_BLOCK block_index == GLOBAL_BLOCK
? "GLOBAL_BLOCK" : "STATIC_BLOCK", ? "GLOBAL_BLOCK" : "STATIC_BLOCK",
name, domain_name (domain)); name, domain_name (domain));
}
result = lookup_symbol_in_objfile_symtabs (objfile, block_index, result = lookup_symbol_in_objfile_symtabs (objfile, block_index,
name, domain); name, domain);
if (result.symbol != NULL) if (result.symbol != NULL)
{ {
if (symbol_lookup_debug) symbol_lookup_debug_printf
{ ("lookup_symbol_in_objfile (...) = %s (in symtabs)",
gdb_printf (gdb_stdlog,
"lookup_symbol_in_objfile (...) = %s"
" (in symtabs)\n",
host_address_to_string (result.symbol)); host_address_to_string (result.symbol));
}
return result; return result;
} }
result = lookup_symbol_via_quick_fns (objfile, block_index, result = lookup_symbol_via_quick_fns (objfile, block_index,
name, domain); name, domain);
if (symbol_lookup_debug) symbol_lookup_debug_printf ("lookup_symbol_in_objfile (...) = %s%s",
{
gdb_printf (gdb_stdlog,
"lookup_symbol_in_objfile (...) = %s%s\n",
result.symbol != NULL result.symbol != NULL
? host_address_to_string (result.symbol) ? host_address_to_string (result.symbol)
: "NULL", : "NULL",
result.symbol != NULL ? " (via quick fns)" : ""); result.symbol != NULL ? " (via quick fns)"
} : "");
return result; return result;
} }
@ -4651,12 +4588,8 @@ treg_matches_sym_type_name (const compiled_regex &treg,
struct type *sym_type; struct type *sym_type;
std::string printed_sym_type_name; std::string printed_sym_type_name;
if (symbol_lookup_debug > 1) symbol_lookup_debug_printf_v ("treg_matches_sym_type_name, sym %s",
{
gdb_printf (gdb_stdlog,
"treg_matches_sym_type_name\n sym %s\n",
sym->natural_name ()); sym->natural_name ());
}
sym_type = sym->type (); sym_type = sym->type ();
if (sym_type == NULL) if (sym_type == NULL)
@ -4668,14 +4601,8 @@ treg_matches_sym_type_name (const compiled_regex &treg,
printed_sym_type_name = type_to_string (sym_type); printed_sym_type_name = type_to_string (sym_type);
} }
symbol_lookup_debug_printf_v ("sym_type_name %s",
if (symbol_lookup_debug > 1)
{
gdb_printf (gdb_stdlog,
" sym_type_name %s\n",
printed_sym_type_name.c_str ()); printed_sym_type_name.c_str ());
}
if (printed_sym_type_name.empty ()) if (printed_sym_type_name.empty ())
return false; return false;

View file

@ -2625,6 +2625,18 @@ extern unsigned int symtab_create_debug;
extern unsigned int symbol_lookup_debug; extern unsigned int symbol_lookup_debug;
/* 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__)
/* 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__)
extern bool basenames_may_differ; extern bool basenames_may_differ;
bool compare_filenames_for_search (const char *filename, bool compare_filenames_for_search (const char *filename,