static int debug_qf_map_symtabs_matching_filename (struct objfile *objfile, const char *name, const char *real_path, int (*callback) (struct symtab *, void *), void *data) { const struct debug_sym_fns_data *debug_data = objfile_data (objfile, symfile_debug_objfile_data_key); int retval; fprintf_filtered (gdb_stdlog, "qf->map_symtabs_matching_filename (%s, \"%s\", \"%s\", %s, %s)\n", objfile_debug_name (objfile), name, real_path ? real_path : NULL, host_address_to_string (callback), host_address_to_string (data)); retval = debug_data->real_sf->qf->map_symtabs_matching_filename (objfile, name, real_path, callback, data); fprintf_filtered (gdb_stdlog, "qf->map_symtabs_matching_filename (...) = %d\n", retval); return retval; }
static void debug_qf_relocate (struct objfile *objfile, const struct section_offsets *new_offsets, const struct section_offsets *delta) { const struct debug_sym_fns_data *debug_data = objfile_data (objfile, symfile_debug_objfile_data_key); fprintf_filtered (gdb_stdlog, "qf->relocate (%s, %s, %s)\n", objfile_debug_name (objfile), host_address_to_string (new_offsets), host_address_to_string (delta)); debug_data->real_sf->qf->relocate (objfile, new_offsets, delta); }
/* Try to select a global architecture that matches "info". Return non-zero if the attempt succeeds. */ int gdbarch_update_p (struct gdbarch_info info) { struct gdbarch *new_gdbarch; /* Check for the current file. */ if (info.abfd == NULL) info.abfd = exec_bfd; if (info.abfd == NULL) info.abfd = core_bfd; /* Check for the current target description. */ if (info.target_desc == NULL) info.target_desc = target_current_description (); new_gdbarch = gdbarch_find_by_info (info); /* If there no architecture by that name, reject the request. */ if (new_gdbarch == NULL) { if (gdbarch_debug) fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: " "Architecture not found\n"); return 0; } /* If it is the same old architecture, accept the request (but don't swap anything). */ if (new_gdbarch == target_gdbarch ()) { if (gdbarch_debug) fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: " "Architecture %s (%s) unchanged\n", host_address_to_string (new_gdbarch), gdbarch_bfd_arch_info (new_gdbarch)->printable_name); return 1; } /* It's a new architecture, swap it in. */ if (gdbarch_debug) fprintf_unfiltered (gdb_stdlog, "gdbarch_update_p: " "New architecture %s (%s) selected\n", host_address_to_string (new_gdbarch), gdbarch_bfd_arch_info (new_gdbarch)->printable_name); set_target_gdbarch (new_gdbarch); return 1; }
void compile_cplus_instance::enter_scope (compile_scope &&new_scope) { bool must_push = m_scopes.empty () || m_scopes.back () != new_scope; new_scope.m_pushed = must_push; /* Save the new scope. */ m_scopes.push_back (std::move (new_scope)); if (must_push) { if (debug_compile_cplus_scopes) { fprintf_unfiltered (gdb_stdlog, "entering new scope %s\n", host_address_to_string (&m_scopes.back ())); } /* Push the global namespace. */ plugin ().push_namespace (""); /* Push all other namespaces. Note that we do not push the last scope_component -- that's the actual type we are converting. */ std::for_each (m_scopes.back ().begin (), m_scopes.back ().end () - 1, [this] (const scope_component &comp) { gdb_assert (TYPE_CODE (SYMBOL_TYPE (comp.bsymbol.symbol)) == TYPE_CODE_NAMESPACE); const char *ns = (comp.name == CP_ANONYMOUS_NAMESPACE_STR ? nullptr : comp.name.c_str ()); this->plugin ().push_namespace (ns); }); } else { if (debug_compile_cplus_scopes) { fprintf_unfiltered (gdb_stdlog, "staying in current scope -- " "scopes are identical\n"); } } }
void compile_cplus_instance::leave_scope () { /* Get the current scope and remove it from the internal list of scopes. */ compile_scope current = m_scopes.back (); m_scopes.pop_back (); if (current.m_pushed) { if (debug_compile_cplus_scopes) { fprintf_unfiltered (gdb_stdlog, "leaving scope %s\n", host_address_to_string (¤t)); } /* Pop namespaces. */ std::for_each (current.begin (),current.end () - 1, [this] (const scope_component &comp) { gdb_assert (TYPE_CODE (SYMBOL_TYPE (comp.bsymbol.symbol)) == TYPE_CODE_NAMESPACE); this->plugin ().pop_binding_level (comp.name.c_str ()); }); /* Pop global namespace. */ plugin ().pop_binding_level (""); } else { if (debug_compile_cplus_scopes) fprintf_unfiltered (gdb_stdlog, "identical scopes -- not leaving scope\n"); } }
struct bound_minimal_symbol lookup_minimal_symbol (const char *name, const char *sfile, struct objfile *objf) { struct objfile *objfile; found_minimal_symbols found; unsigned int mangled_hash = msymbol_hash (name) % MINIMAL_SYMBOL_HASH_SIZE; auto *mangled_cmp = (case_sensitivity == case_sensitive_on ? strcmp : strcasecmp); if (sfile != NULL) sfile = lbasename (sfile); lookup_name_info lookup_name (name, symbol_name_match_type::FULL); for (objfile = object_files; objfile != NULL && found.external_symbol.minsym == NULL; objfile = objfile->next) { if (objf == NULL || objf == objfile || objf == objfile->separate_debug_objfile_backlink) { if (symbol_lookup_debug) { fprintf_unfiltered (gdb_stdlog, "lookup_minimal_symbol (%s, %s, %s)\n", name, sfile != NULL ? sfile : "NULL", objfile_debug_name (objfile)); } /* Do two passes: the first over the ordinary hash table, and the second over the demangled hash table. */ lookup_minimal_symbol_mangled (name, sfile, objfile, objfile->per_bfd->msymbol_hash, mangled_hash, mangled_cmp, found); /* If not found, try the demangled hash table. */ if (found.external_symbol.minsym == NULL) { /* Once for each language in the demangled hash names table (usually just zero or one languages). */ for (auto lang : objfile->per_bfd->demangled_hash_languages) { unsigned int hash = (lookup_name.search_name_hash (lang) % MINIMAL_SYMBOL_HASH_SIZE); symbol_name_matcher_ftype *match = get_symbol_name_matcher (language_def (lang), lookup_name); struct minimal_symbol **msymbol_demangled_hash = objfile->per_bfd->msymbol_demangled_hash; lookup_minimal_symbol_demangled (lookup_name, sfile, objfile, msymbol_demangled_hash, hash, match, found); if (found.external_symbol.minsym != NULL) break; } } } } /* External symbols are best. */ if (found.external_symbol.minsym != NULL) { if (symbol_lookup_debug) { minimal_symbol *minsym = found.external_symbol.minsym; fprintf_unfiltered (gdb_stdlog, "lookup_minimal_symbol (...) = %s (external)\n", host_address_to_string (minsym)); } return found.external_symbol; } /* File-local symbols are next best. */ if (found.file_symbol.minsym != NULL) { if (symbol_lookup_debug) { minimal_symbol *minsym = found.file_symbol.minsym; fprintf_unfiltered (gdb_stdlog, "lookup_minimal_symbol (...) = %s (file-local)\n", host_address_to_string (minsym)); } return found.file_symbol; } /* Symbols for shared library trampolines are next best. */ if (found.trampoline_symbol.minsym != NULL) { if (symbol_lookup_debug) { minimal_symbol *minsym = found.trampoline_symbol.minsym; fprintf_unfiltered (gdb_stdlog, "lookup_minimal_symbol (...) = %s (trampoline)\n", host_address_to_string (minsym)); } return found.trampoline_symbol; } /* Not found. */ if (symbol_lookup_debug) fprintf_unfiltered (gdb_stdlog, "lookup_minimal_symbol (...) = NULL\n"); return {}; }
struct block_symbol cp_lookup_symbol_imports_or_template (const char *scope, const char *name, const struct block *block, const domain_enum domain) { struct symbol *function = BLOCK_FUNCTION (block); struct block_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) { /* Search the function's template parameters. */ if (SYMBOL_IS_CPLUS_TEMPLATE_FUNCTION (function)) { struct template_symbol *templ = (struct template_symbol *) function; struct symbol *sym = search_symbol_list (name, templ->n_template_arguments, templ->template_arguments); if (sym != NULL) { if (symbol_lookup_debug) { fprintf_unfiltered (gdb_stdlog, "cp_lookup_symbol_imports_or_template" " (...) = %s\n", host_address_to_string (sym)); } return (struct block_symbol) {sym, block}; } } /* Search the template parameters of the function's defining context. */ if (SYMBOL_NATURAL_NAME (function)) { struct type *context; char *name_copy = xstrdup (SYMBOL_NATURAL_NAME (function)); struct cleanup *cleanups = make_cleanup (xfree, name_copy); const struct language_defn *lang = language_def (language_cplus); struct gdbarch *arch = symbol_arch (function); const struct block *parent = BLOCK_SUPERBLOCK (block); struct symbol *sym; while (1) { unsigned int prefix_len = cp_entire_prefix_len (name_copy); if (prefix_len == 0) context = NULL; else { name_copy[prefix_len] = '\0'; context = lookup_typename (lang, arch, name_copy, parent, 1); } if (context == NULL) break; sym = search_symbol_list (name, TYPE_N_TEMPLATE_ARGUMENTS (context), TYPE_TEMPLATE_ARGUMENTS (context)); if (sym != NULL) { do_cleanups (cleanups); if (symbol_lookup_debug) { fprintf_unfiltered (gdb_stdlog, "cp_lookup_symbol_imports_or_template (...) = %s\n", host_address_to_string (sym)); } return (struct block_symbol) {sym, parent}; } } do_cleanups (cleanups); } }
char * c_get_range_decl_name (const struct dynamic_prop *prop) { return xstrprintf ("__gdb_prop_%s", host_address_to_string (prop)); }