+2014-12-17 Doug Evans <xdje42@gmail.com>
+
+ New parameter "debug symbol-lookup".
+ * NEWS: Mention it.
+ * cp-namespace.c (cp_lookup_symbol_imports_or_template): Add debug
+ output.
+ (cp_lookup_symbol_namespace, cp_lookup_symbol_nonlocal): Ditto.
+ (cp_lookup_nested_symbol): Ditto.
+ * language.c (language_lookup_primitive_type_by_name): Add debug
+ output.
+ * minsyms.c (lookup_minimal_symbol): Add debug output.
+ * objfiles.c (objfile_debug_name): Moved here, and renamed ...
+ * symfile-debug.c (debug_objfile_name): ... from here. All callers
+ updated.
+ * objfiles.h (objfile_debug_name): Declare.
+ * symtab.h (symbol_lookup_debug): Declare.
+ * symtab.c (symbol_lookup_debug): New global.
+ (lookup_language_this): Add debug output.
+ (lookup_symbol_aux, lookup_symbol_in_block): Ditto.
+ (lookup_symbol_in_objfile_symtabs, lookup_symbol_via_quick_fns): Ditto.
+ (lookup_symbol_in_static_block, lookup_symbol_in_objfile): Ditto.
+ (_initialize_symtab): Add new parameter "debug symbol-lookup".
+
2014-12-16 Doug Evans <xdje42@gmail.com>
* buildsym.c: Add comments describing how the buildsym machinery
even in non-stop mode. The "auto" mode has been removed, and "off"
is now the default mode.
+* New options
+
+set debug symbol-lookup
+show debug symbol-lookup
+ Control display of debugging info regarding symbol lookup.
+
* MI changes
** The -list-thread-groups command outputs an exit-code field for
const domain_enum domain)
{
struct symbol *function = BLOCK_FUNCTION (block);
+ struct symbol *result;
+
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "cp_lookup_symbol_imports_or_template"
+ " (%s, %s, %s, %s)\n",
+ scope, name, host_address_to_string (block),
+ domain_name (domain));
+ }
if (function != NULL && SYMBOL_LANGUAGE (function) == language_cplus)
{
{
struct template_symbol *templ
= (struct template_symbol *) function;
- struct symbol *result;
result = search_symbol_list (name,
templ->n_template_arguments,
templ->template_arguments);
if (result != NULL)
- return result;
+ {
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "cp_lookup_symbol_imports_or_template"
+ " (...) = %s\n",
+ host_address_to_string (result));
+ }
+ return result;
+ }
}
/* Search the template parameters of the function's defining
while (1)
{
- struct symbol *result;
unsigned int prefix_len = cp_entire_prefix_len (name_copy);
if (prefix_len == 0)
if (result != NULL)
{
do_cleanups (cleanups);
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "cp_lookup_symbol_imports_or_template"
+ " (...) = %s\n",
+ host_address_to_string (result));
+ }
return result;
}
}
}
}
- return cp_lookup_symbol_via_imports (scope, name, block, domain, 1, 1);
+ result = cp_lookup_symbol_via_imports (scope, name, block, domain, 1, 1);
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "cp_lookup_symbol_imports_or_template (...) = %s\n",
+ result != NULL
+ ? host_address_to_string (result) : "NULL");
+ }
+ return result;
}
/* Searches for NAME in the current namespace, and by applying
const domain_enum domain)
{
struct symbol *sym;
-
+
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "cp_lookup_symbol_namespace (%s, %s, %s, %s)\n",
+ scope, name, host_address_to_string (block),
+ domain_name (domain));
+ }
+
/* First, try to find the symbol in the given namespace. */
sym = cp_lookup_symbol_in_namespace (scope, name,
block, domain, 1);
if (sym != NULL)
- return sym;
+ {
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "cp_lookup_symbol_namespace (...) = %s\n",
+ host_address_to_string (sym));
+ }
+ return sym;
+ }
/* Search for name in namespaces imported to this and parent
blocks. */
domain, 0, 1);
if (sym)
- return sym;
+ {
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "cp_lookup_symbol_namespace (...) = %s\n",
+ host_address_to_string (sym));
+ }
+ return sym;
+ }
block = BLOCK_SUPERBLOCK (block);
}
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "cp_lookup_symbol_namespace (...) = NULL\n");
+ }
return NULL;
}
struct symbol *sym;
const char *scope = block_scope (block);
- sym = lookup_namespace_scope (name, block,
- domain, scope, 0);
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "cp_lookup_symbol_non_local"
+ " (%s, %s (scope %s), %s)\n",
+ name, host_address_to_string (block), scope,
+ domain_name (domain));
+ }
+
+ sym = lookup_namespace_scope (name, block, domain, scope, 0);
if (sym != NULL)
- return sym;
+ {
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "cp_lookup_symbol_nonlocal (...) = %s\n",
+ host_address_to_string (sym));
+ }
+ return sym;
+ }
- return cp_lookup_symbol_namespace (scope, name,
- block, domain);
+ sym = cp_lookup_symbol_namespace (scope, name, block, domain);
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "cp_lookup_symbol_nonlocal (...) = %s\n",
+ sym != NULL ? host_address_to_string (sym) : "NULL");
+ }
+ return sym;
}
/* Search through the base classes of PARENT_TYPE for a base class
CHECK_TYPEDEF (parent_type);
+ if (symbol_lookup_debug)
+ {
+ const char *type_name = type_name_no_tag (saved_parent_type);
+
+ fprintf_unfiltered (gdb_stdlog,
+ "cp_lookup_nested_symbol (%s, %s, %s)\n",
+ type_name != NULL ? type_name : "unnamed",
+ nested_name, host_address_to_string (block));
+ }
+
switch (TYPE_CODE (parent_type))
{
case TYPE_CODE_STRUCT:
char *concatenated_name;
if (sym != NULL)
- return sym;
+ {
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "cp_lookup_nested_symbol (...) = %s\n",
+ host_address_to_string (sym));
+ }
+ return sym;
+ }
/* Now search all static file-level symbols. We have to do this
for things like typedefs in the class. We do not try to
parent_name, nested_name);
sym = lookup_static_symbol (concatenated_name, VAR_DOMAIN);
if (sym != NULL)
- return sym;
+ {
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "cp_lookup_nested_symbol (...) = %s\n",
+ host_address_to_string (sym));
+ }
+ return sym;
+ }
/* If no matching symbols were found, try searching any
base classes. */
- return find_symbol_in_baseclass (parent_type, nested_name, block);
+ sym = find_symbol_in_baseclass (parent_type, nested_name, block);
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "cp_lookup_nested_symbol (...) = %s\n",
+ sym != NULL
+ ? host_address_to_string (sym) : "NULL");
+ }
+ return sym;
}
case TYPE_CODE_FUNC:
case TYPE_CODE_METHOD:
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "cp_lookup_nested_symbol (...) = NULL"
+ " (func/method)\n");
+ }
return NULL;
default:
+2014-12-17 Doug Evans <xdje42@gmail.com>
+
+ * gdb.texinfo (Debugging Output): Document "debug symbol-lookup".
+
2014-12-12 Phil Muldoon <pmuldoon@redhat.com>
Jan Kratochvil <jan.kratochvil@redhat.com>
@item show debug solib-frv
Display the current state of FR-V shared-library code debugging
messages.
+@item set debug symbol-lookup
+@cindex symbol lookup
+Turns on or off display of debugging messages related to symbol lookup.
+The default is 0 (off).
+A value of 1 provides basic information.
+A value greater than 1 provides more verbose information.
+@item show debug symbol-lookup
+Show the current state of symbol lookup debugging messages.
@item set debug symfile
@cindex symbol file functions
Turns on or off display of debugging messages related to symbol file functions.
language_gdbarch_data);
struct type *const *p;
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "language_lookup_primitive_type_by_name"
+ " (%s, %s, %s)",
+ la->la_name, host_address_to_string (gdbarch), name);
+ }
+
for (p = ld->arch_info[la->la_language].primitive_type_vector;
(*p) != NULL;
p++)
{
if (strcmp (TYPE_NAME (*p), name) == 0)
- return (*p);
+ {
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog, " = %s\n",
+ host_address_to_string (*p));
+ }
+ return (*p);
+ }
}
+
+ if (symbol_lookup_debug)
+ fprintf_unfiltered (gdb_stdlog, " = NULL\n");
return (NULL);
}
and the second over the demangled hash table. */
int pass;
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "lookup_minimal_symbol (%s, %s, %s)\n",
+ name, sfile != NULL ? sfile : "NULL",
+ objfile_debug_name (objfile));
+ }
+
for (pass = 1; pass <= 2 && found_symbol.minsym == NULL; pass++)
{
/* Select hash list according to pass. */
/* External symbols are best. */
if (found_symbol.minsym != NULL)
- return found_symbol;
+ {
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "lookup_minimal_symbol (...) = %s"
+ " (external)\n",
+ host_address_to_string (found_symbol.minsym));
+ }
+ return found_symbol;
+ }
/* File-local symbols are next best. */
if (found_file_symbol.minsym != NULL)
- return found_file_symbol;
+ {
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "lookup_minimal_symbol (...) = %s"
+ " (file-local)\n",
+ host_address_to_string
+ (found_file_symbol.minsym));
+ }
+ return found_file_symbol;
+ }
/* Symbols for shared library trampolines are next best. */
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "lookup_minimal_symbol (...) = %s%s\n",
+ trampoline_symbol.minsym != NULL
+ ? host_address_to_string (trampoline_symbol.minsym)
+ : "NULL",
+ trampoline_symbol.minsym != NULL
+ ? " (trampoline)" : "");
+ }
return trampoline_symbol;
}
return objfile->original_name;
}
+/* See objfiles.h. */
+
+const char *
+objfile_debug_name (const struct objfile *objfile)
+{
+ return lbasename (objfile->original_name);
+}
+
/* Provide a prototype to silence -Wmissing-prototypes. */
extern initialize_file_ftype _initialize_objfiles;
const char *objfile_name (const struct objfile *objfile);
+/* Return the name to print for OBJFILE in debugging messages. */
+
+extern const char *objfile_debug_name (const struct objfile *objfile);
+
/* Set the objfile's notion of the "main" name and language. */
extern void set_objfile_main_name (struct objfile *objfile,
&& objfile_data (objfile, symfile_debug_objfile_data_key) != NULL);
}
-/* Utility to return the name to print for OBJFILE. */
-
-static const char *
-debug_objfile_name (const struct objfile *objfile)
-{
- return lbasename (objfile->original_name);
-}
-
/* Utility return the name to print for SYMTAB. */
static const char *
retval = debug_data->real_sf->qf->has_symbols (objfile);
fprintf_filtered (gdb_stdlog, "qf->has_symbols (%s) = %d\n",
- debug_objfile_name (objfile), retval);
+ objfile_debug_name (objfile), retval);
return retval;
}
struct symtab *retval;
fprintf_filtered (gdb_stdlog, "qf->find_last_source_symtab (%s)\n",
- debug_objfile_name (objfile));
+ objfile_debug_name (objfile));
retval = debug_data->real_sf->qf->find_last_source_symtab (objfile);
objfile_data (objfile, symfile_debug_objfile_data_key);
fprintf_filtered (gdb_stdlog, "qf->forget_cached_source_info (%s)\n",
- debug_objfile_name (objfile));
+ objfile_debug_name (objfile));
debug_data->real_sf->qf->forget_cached_source_info (objfile);
}
fprintf_filtered (gdb_stdlog,
"qf->map_symtabs_matching_filename (%s, \"%s\", \"%s\", %s, %s)\n",
- debug_objfile_name (objfile), name,
+ objfile_debug_name (objfile), name,
real_path ? real_path : NULL,
host_address_to_string (callback),
host_address_to_string (data));
fprintf_filtered (gdb_stdlog,
"qf->lookup_symbol (%s, %d, \"%s\", %s)\n",
- debug_objfile_name (objfile), kind, name,
+ objfile_debug_name (objfile), kind, name,
domain_name (domain));
retval = debug_data->real_sf->qf->lookup_symbol (objfile, kind, name,
objfile_data (objfile, symfile_debug_objfile_data_key);
fprintf_filtered (gdb_stdlog, "qf->print_stats (%s)\n",
- debug_objfile_name (objfile));
+ objfile_debug_name (objfile));
debug_data->real_sf->qf->print_stats (objfile);
}
objfile_data (objfile, symfile_debug_objfile_data_key);
fprintf_filtered (gdb_stdlog, "qf->dump (%s)\n",
- debug_objfile_name (objfile));
+ objfile_debug_name (objfile));
debug_data->real_sf->qf->dump (objfile);
}
objfile_data (objfile, symfile_debug_objfile_data_key);
fprintf_filtered (gdb_stdlog, "qf->relocate (%s, %s, %s)\n",
- debug_objfile_name (objfile),
+ objfile_debug_name (objfile),
host_address_to_string (new_offsets),
host_address_to_string (delta));
fprintf_filtered (gdb_stdlog,
"qf->expand_symtabs_for_function (%s, \"%s\")\n",
- debug_objfile_name (objfile), func_name);
+ objfile_debug_name (objfile), func_name);
debug_data->real_sf->qf->expand_symtabs_for_function (objfile, func_name);
}
objfile_data (objfile, symfile_debug_objfile_data_key);
fprintf_filtered (gdb_stdlog, "qf->expand_all_symtabs (%s)\n",
- debug_objfile_name (objfile));
+ objfile_debug_name (objfile));
debug_data->real_sf->qf->expand_all_symtabs (objfile);
}
fprintf_filtered (gdb_stdlog,
"qf->expand_symtabs_with_fullname (%s, \"%s\")\n",
- debug_objfile_name (objfile), fullname);
+ objfile_debug_name (objfile), fullname);
debug_data->real_sf->qf->expand_symtabs_with_fullname (objfile, fullname);
}
fprintf_filtered (gdb_stdlog,
"qf->map_matching_symbols (%s, \"%s\", %s, %d, %s, %s, %s, %s)\n",
- debug_objfile_name (objfile), name,
+ objfile_debug_name (objfile), name,
domain_name (namespace), global,
host_address_to_string (callback),
host_address_to_string (data),
fprintf_filtered (gdb_stdlog,
"qf->expand_symtabs_matching (%s, %s, %s, %s, %s)\n",
- debug_objfile_name (objfile),
+ objfile_debug_name (objfile),
host_address_to_string (file_matcher),
host_address_to_string (symbol_matcher),
search_domain_name (kind),
fprintf_filtered (gdb_stdlog,
"qf->find_pc_sect_compunit_symtab (%s, %s, %s, %s, %d)\n",
- debug_objfile_name (objfile),
+ objfile_debug_name (objfile),
host_address_to_string (msymbol.minsym),
hex_string (pc),
host_address_to_string (section),
objfile_data (objfile, symfile_debug_objfile_data_key);
fprintf_filtered (gdb_stdlog,
"qf->map_symbol_filenames (%s, %s, %s, %d)\n",
- debug_objfile_name (objfile),
+ objfile_debug_name (objfile),
host_address_to_string (fun),
host_address_to_string (data),
need_fullname);
fprintf_filtered (gdb_stdlog,
"probes->sym_get_probes (%s) = %s\n",
- debug_objfile_name (objfile),
+ objfile_debug_name (objfile),
host_address_to_string (retval));
return retval;
objfile_data (objfile, symfile_debug_objfile_data_key);
fprintf_filtered (gdb_stdlog, "sf->sym_new_init (%s)\n",
- debug_objfile_name (objfile));
+ objfile_debug_name (objfile));
debug_data->real_sf->sym_new_init (objfile);
}
objfile_data (objfile, symfile_debug_objfile_data_key);
fprintf_filtered (gdb_stdlog, "sf->sym_init (%s)\n",
- debug_objfile_name (objfile));
+ objfile_debug_name (objfile));
debug_data->real_sf->sym_init (objfile);
}
objfile_data (objfile, symfile_debug_objfile_data_key);
fprintf_filtered (gdb_stdlog, "sf->sym_read (%s, 0x%x)\n",
- debug_objfile_name (objfile), symfile_flags);
+ objfile_debug_name (objfile), symfile_flags);
debug_data->real_sf->sym_read (objfile, symfile_flags);
}
objfile_data (objfile, symfile_debug_objfile_data_key);
fprintf_filtered (gdb_stdlog, "sf->sym_read_psymbols (%s)\n",
- debug_objfile_name (objfile));
+ objfile_debug_name (objfile));
debug_data->real_sf->sym_read_psymbols (objfile);
}
objfile_data (objfile, symfile_debug_objfile_data_key);
fprintf_filtered (gdb_stdlog, "sf->sym_finish (%s)\n",
- debug_objfile_name (objfile));
+ objfile_debug_name (objfile));
debug_data->real_sf->sym_finish (objfile);
}
objfile_data (objfile, symfile_debug_objfile_data_key);
fprintf_filtered (gdb_stdlog, "sf->sym_offsets (%s, %s)\n",
- debug_objfile_name (objfile),
+ objfile_debug_name (objfile),
host_address_to_string (info));
debug_data->real_sf->sym_offsets (objfile, info);
objfile_data (objfile, symfile_debug_objfile_data_key);
fprintf_filtered (gdb_stdlog, "sf->sym_read_linetable (%s)\n",
- debug_objfile_name (objfile));
+ objfile_debug_name (objfile));
debug_data->real_sf->sym_read_linetable (objfile);
}
fprintf_filtered (gdb_stdlog,
"sf->sym_relocate (%s, %s, %s) = %s\n",
- debug_objfile_name (objfile),
+ objfile_debug_name (objfile),
host_address_to_string (sectp),
host_address_to_string (buf),
host_address_to_string (retval));
/* When non-zero, print debugging messages related to symtab creation. */
unsigned int symtab_create_debug = 0;
+/* When non-zero, print debugging messages related to symbol lookup. */
+unsigned int symbol_lookup_debug = 0;
+
/* Non-zero if a file may be known by two different basenames.
This is the uncommon case, and significantly slows down gdb.
Default set to "off" to not slow down the common case. */
if (lang->la_name_of_this == NULL || block == NULL)
return NULL;
+ if (symbol_lookup_debug > 1)
+ {
+ struct objfile *objfile = lookup_objfile_from_block (block);
+
+ fprintf_unfiltered (gdb_stdlog,
+ "lookup_language_this (%s, %s (objfile %s))",
+ lang->la_name, host_address_to_string (block),
+ objfile_debug_name (objfile));
+ }
+
while (block)
{
struct symbol *sym;
sym = block_lookup_symbol (block, lang->la_name_of_this, VAR_DOMAIN);
if (sym != NULL)
{
+ if (symbol_lookup_debug > 1)
+ {
+ fprintf_unfiltered (gdb_stdlog, " = %s (%s, block %s)\n",
+ SYMBOL_PRINT_NAME (sym),
+ host_address_to_string (sym),
+ host_address_to_string (block));
+ }
block_found = block;
return sym;
}
block = BLOCK_SUPERBLOCK (block);
}
+ if (symbol_lookup_debug > 1)
+ fprintf_unfiltered (gdb_stdlog, " = NULL\n");
return NULL;
}
struct symbol *sym;
const struct language_defn *langdef;
+ if (symbol_lookup_debug)
+ {
+ struct objfile *objfile = lookup_objfile_from_block (block);
+
+ fprintf_unfiltered (gdb_stdlog,
+ "lookup_symbol_aux (%s, %s (objfile %s), %s, %s)\n",
+ name, host_address_to_string (block),
+ objfile != NULL
+ ? objfile_debug_name (objfile) : "NULL",
+ domain_name (domain), language_str (language));
+ }
+
/* Make sure we do something sensible with is_a_field_of_this, since
the callers that set this parameter to some non-null value will
certainly use it later. If we don't set it, the contents of
sym = lookup_local_symbol (name, block, domain, language);
if (sym != NULL)
- return sym;
+ {
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog, "lookup_symbol_aux (...) = %s\n",
+ host_address_to_string (sym));
+ }
+ return sym;
+ }
/* If requested to do so by the caller and if appropriate for LANGUAGE,
check to see if NAME is a field of `this'. */
langdef->la_name_of_this);
if (check_field (t, name, is_a_field_of_this))
- return NULL;
+ {
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "lookup_symbol_aux (...) = NULL\n");
+ }
+ return NULL;
+ }
}
}
sym = langdef->la_lookup_symbol_nonlocal (name, block, domain);
if (sym != NULL)
- return sym;
+ {
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog, "lookup_symbol_aux (...) = %s\n",
+ host_address_to_string (sym));
+ }
+ return sym;
+ }
/* Now search all static file-level symbols. Not strictly correct,
but more useful than an error. */
- return lookup_static_symbol (name, domain);
+ sym = lookup_static_symbol (name, domain);
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog, "lookup_symbol_aux (...) = %s\n",
+ sym != NULL ? host_address_to_string (sym) : "NULL");
+ }
+ return sym;
}
/* Check to see if the symbol is defined in BLOCK or its superiors.
{
struct symbol *sym;
+ if (symbol_lookup_debug > 1)
+ {
+ struct objfile *objfile = lookup_objfile_from_block (block);
+
+ fprintf_unfiltered (gdb_stdlog,
+ "lookup_symbol_in_block (%s, %s (objfile %s), %s)",
+ name, host_address_to_string (block),
+ objfile_debug_name (objfile),
+ domain_name (domain));
+ }
+
sym = block_lookup_symbol (block, name, domain);
if (sym)
{
+ if (symbol_lookup_debug > 1)
+ {
+ fprintf_unfiltered (gdb_stdlog, " = %s\n",
+ host_address_to_string (sym));
+ }
block_found = block;
return fixup_symbol_section (sym, NULL);
}
+ if (symbol_lookup_debug > 1)
+ fprintf_unfiltered (gdb_stdlog, " = NULL\n");
return NULL;
}
gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK);
+ if (symbol_lookup_debug > 1)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "lookup_symbol_in_objfile_symtabs (%s, %s, %s, %s)",
+ objfile_debug_name (objfile),
+ block_index == GLOBAL_BLOCK
+ ? "GLOBAL_BLOCK" : "STATIC_BLOCK",
+ name, domain_name (domain));
+ }
+
ALL_OBJFILE_COMPUNITS (objfile, cust)
{
const struct blockvector *bv;
sym = block_lookup_symbol_primary (block, name, domain);
if (sym)
{
+ if (symbol_lookup_debug > 1)
+ {
+ fprintf_unfiltered (gdb_stdlog, " = %s (block %s)\n",
+ host_address_to_string (sym),
+ host_address_to_string (block));
+ }
block_found = block;
return fixup_symbol_section (sym, objfile);
}
}
+ if (symbol_lookup_debug > 1)
+ fprintf_unfiltered (gdb_stdlog, " = NULL\n");
return NULL;
}
if (!objfile->sf)
return NULL;
+
+ if (symbol_lookup_debug > 1)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "lookup_symbol_via_quick_fns (%s, %s, %s, %s)\n",
+ objfile_debug_name (objfile),
+ block_index == GLOBAL_BLOCK
+ ? "GLOBAL_BLOCK" : "STATIC_BLOCK",
+ name, domain_name (domain));
+ }
+
cust = objfile->sf->qf->lookup_symbol (objfile, block_index, name, domain);
if (cust == NULL)
- return NULL;
+ {
+ if (symbol_lookup_debug > 1)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "lookup_symbol_via_quick_fns (...) = NULL\n");
+ }
+ return NULL;
+ }
bv = COMPUNIT_BLOCKVECTOR (cust);
block = BLOCKVECTOR_BLOCK (bv, block_index);
sym = block_lookup_symbol (block, name, domain);
if (!sym)
error_in_psymtab_expansion (block_index, name, cust);
+
+ if (symbol_lookup_debug > 1)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "lookup_symbol_via_quick_fns (...) = %s (block %s)\n",
+ host_address_to_string (sym),
+ host_address_to_string (block));
+ }
+
block_found = block;
return fixup_symbol_section (sym, objfile);
}
const domain_enum domain)
{
const struct block *static_block = block_static_block (block);
+ struct symbol *sym;
- if (static_block != NULL)
- return lookup_symbol_in_block (name, static_block, domain);
- else
+ if (static_block == NULL)
return NULL;
+
+ if (symbol_lookup_debug)
+ {
+ struct objfile *objfile = lookup_objfile_from_block (static_block);
+
+ fprintf_unfiltered (gdb_stdlog,
+ "lookup_symbol_in_static_block (%s, %s (objfile %s),"
+ " %s)\n",
+ name,
+ host_address_to_string (block),
+ objfile_debug_name (objfile),
+ domain_name (domain));
+ }
+
+ sym = lookup_symbol_in_block (name, static_block, domain);
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "lookup_symbol_in_static_block (...) = %s\n",
+ sym != NULL ? host_address_to_string (sym) : "NULL");
+ }
+ return sym;
}
/* Perform the standard symbol lookup of NAME in OBJFILE:
{
struct symbol *result;
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "lookup_symbol_in_objfile (%s, %s, %s, %s)\n",
+ objfile_debug_name (objfile),
+ block_index == GLOBAL_BLOCK
+ ? "GLOBAL_BLOCK" : "STATIC_BLOCK",
+ name, domain_name (domain));
+ }
+
result = lookup_symbol_in_objfile_symtabs (objfile, block_index,
name, domain);
- if (result == NULL)
+ if (result != NULL)
{
- result = lookup_symbol_via_quick_fns (objfile, block_index,
- name, domain);
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "lookup_symbol_in_objfile (...) = %s"
+ " (in symtabs)\n",
+ host_address_to_string (result));
+ }
+ return result;
}
+ result = lookup_symbol_via_quick_fns (objfile, block_index,
+ name, domain);
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "lookup_symbol_in_objfile (...) = %s%s\n",
+ result != NULL
+ ? host_address_to_string (result)
+ : "NULL",
+ result != NULL ? " (via quick fns)" : "");
+ }
return result;
}
NULL,
&setdebuglist, &showdebuglist);
+ add_setshow_zuinteger_cmd ("symbol-lookup", no_class, &symbol_lookup_debug,
+ _("\
+Set debugging of symbol lookup."), _("\
+Show debugging of symbol lookup."), _("\
+When enabled (non-zero), symbol lookups are logged."),
+ NULL, NULL,
+ &setdebuglist, &showdebuglist);
+
observer_attach_executable_changed (symtab_observer_executable_changed);
}
extern unsigned int symtab_create_debug;
+extern unsigned int symbol_lookup_debug;
+
extern int basenames_may_differ;
int compare_filenames_for_search (const char *filename,