}
}
-/* Set the primary field in SYMTAB. */
+/* See symtab.h. */
-void
-set_symtab_primary (struct symtab *symtab, int primary)
+struct symtab *
+compunit_primary_filetab (const struct compunit_symtab *cust)
{
- symtab->primary = primary;
+ gdb_assert (COMPUNIT_FILETABS (cust) != NULL);
- if (symtab_create_debug && primary)
- {
- fprintf_unfiltered (gdb_stdlog,
- "Created primary symtab %s for %s.\n",
- host_address_to_string (symtab),
- symtab_to_filename_for_display (symtab));
- }
+ /* The primary file symtab is the first one in the list. */
+ return COMPUNIT_FILETABS (cust);
+}
+
+/* See symtab.h. */
+
+enum language
+compunit_language (const struct compunit_symtab *cust)
+{
+ struct symtab *symtab = compunit_primary_filetab (cust);
+
+/* The language of the compunit symtab is the language of its primary
+ source file. */
+ return SYMTAB_LANGUAGE (symtab);
}
/* See whether FILENAME matches SEARCH_NAME using the rule that we
are identical to the `map_symtabs_matching_filename' method of
quick_symbol_functions.
- FIRST and AFTER_LAST indicate the range of symtabs to search.
- AFTER_LAST is one past the last symtab to search; NULL means to
+ FIRST and AFTER_LAST indicate the range of compunit symtabs to search.
+ Each symtab within the specified compunit symtab is also searched.
+ AFTER_LAST is one past the last compunit symtab to search; NULL means to
search until the end of the list. */
int
int (*callback) (struct symtab *symtab,
void *data),
void *data,
- struct symtab *first,
- struct symtab *after_last)
+ struct compunit_symtab *first,
+ struct compunit_symtab *after_last)
{
- struct symtab *s = NULL;
+ struct compunit_symtab *cust;
+ struct symtab *s;
const char* base_name = lbasename (name);
- for (s = first; s != NULL && s != after_last; s = s->next)
+ for (cust = first; cust != NULL && cust != after_last; cust = cust->next)
{
- if (compare_filenames_for_search (s->filename, name))
- {
- if (callback (s, data))
- return 1;
- continue;
- }
-
- /* Before we invoke realpath, which can get expensive when many
- files are involved, do a quick comparison of the basenames. */
- if (! basenames_may_differ
- && FILENAME_CMP (base_name, lbasename (s->filename)) != 0)
- continue;
-
- if (compare_filenames_for_search (symtab_to_fullname (s), name))
+ ALL_COMPUNIT_FILETABS (cust, s)
{
- if (callback (s, data))
- return 1;
- continue;
- }
+ if (compare_filenames_for_search (s->filename, name))
+ {
+ if (callback (s, data))
+ return 1;
+ continue;
+ }
- /* If the user gave us an absolute path, try to find the file in
- this symtab and use its absolute path. */
- if (real_path != NULL)
- {
- const char *fullname = symtab_to_fullname (s);
+ /* Before we invoke realpath, which can get expensive when many
+ files are involved, do a quick comparison of the basenames. */
+ if (! basenames_may_differ
+ && FILENAME_CMP (base_name, lbasename (s->filename)) != 0)
+ continue;
- gdb_assert (IS_ABSOLUTE_PATH (real_path));
- gdb_assert (IS_ABSOLUTE_PATH (name));
- if (FILENAME_CMP (real_path, fullname) == 0)
+ if (compare_filenames_for_search (symtab_to_fullname (s), name))
{
if (callback (s, data))
return 1;
continue;
}
+
+ /* If the user gave us an absolute path, try to find the file in
+ this symtab and use its absolute path. */
+ if (real_path != NULL)
+ {
+ const char *fullname = symtab_to_fullname (s);
+
+ gdb_assert (IS_ABSOLUTE_PATH (real_path));
+ gdb_assert (IS_ABSOLUTE_PATH (name));
+ if (FILENAME_CMP (real_path, fullname) == 0)
+ {
+ if (callback (s, data))
+ return 1;
+ continue;
+ }
+ }
}
}
ALL_OBJFILES (objfile)
{
if (iterate_over_some_symtabs (name, real_path, callback, data,
- objfile->symtabs, NULL))
+ objfile->compunit_symtabs, NULL))
{
do_cleanups (cleanups);
return;
return (mangled_name);
}
-/* Initialize the cplus_specific structure. 'cplus_specific' should
- only be allocated for use with cplus symbols. */
-
-static void
-symbol_init_cplus_specific (struct general_symbol_info *gsymbol,
- struct obstack *obstack)
-{
- /* A language_specific structure should not have been previously
- initialized. */
- gdb_assert (gsymbol->language_specific.cplus_specific == NULL);
- gdb_assert (obstack != NULL);
-
- gsymbol->language_specific.cplus_specific =
- OBSTACK_ZALLOC (obstack, struct cplus_specific);
-}
-
/* Set the demangled name of GSYMBOL to NAME. NAME must be already
- correctly allocated. For C++ symbols a cplus_specific struct is
- allocated so OBJFILE must not be NULL. If this is a non C++ symbol
- OBJFILE can be NULL. */
+ correctly allocated. */
void
symbol_set_demangled_name (struct general_symbol_info *gsymbol,
const char *name,
struct obstack *obstack)
{
- if (gsymbol->language == language_cplus)
- {
- if (gsymbol->language_specific.cplus_specific == NULL)
- symbol_init_cplus_specific (gsymbol, obstack);
-
- gsymbol->language_specific.cplus_specific->demangled_name = name;
- }
- else if (gsymbol->language == language_ada)
+ if (gsymbol->language == language_ada)
{
if (name == NULL)
{
const char *
symbol_get_demangled_name (const struct general_symbol_info *gsymbol)
{
- if (gsymbol->language == language_cplus)
- {
- if (gsymbol->language_specific.cplus_specific != NULL)
- return gsymbol->language_specific.cplus_specific->demangled_name;
- else
- return NULL;
- }
- else if (gsymbol->language == language_ada)
+ if (gsymbol->language == language_ada)
{
if (!gsymbol->ada_mangled)
return NULL;
struct obstack *obstack)
{
gsymbol->language = language;
- if (gsymbol->language == language_d
+ if (gsymbol->language == language_cplus
+ || gsymbol->language == language_d
|| gsymbol->language == language_go
|| gsymbol->language == language_java
|| gsymbol->language == language_objc
gdb_assert (gsymbol->ada_mangled == 0);
gsymbol->language_specific.obstack = obstack;
}
- else if (gsymbol->language == language_cplus)
- gsymbol->language_specific.cplus_specific = NULL;
else
{
memset (&gsymbol->language_specific, 0,
ALL_OBJFILES (objfile)
{
- struct symtab *s = NULL;
+ struct compunit_symtab *cust = NULL;
if (objfile->sf)
- s = objfile->sf->qf->find_pc_sect_symtab (objfile, msymbol,
- pc, section, 0);
- if (s != NULL)
+ cust = objfile->sf->qf->find_pc_sect_compunit_symtab (objfile, msymbol,
+ pc, section, 0);
+ if (cust)
return;
}
}
lookup_objfile_from_block (const struct block *block)
{
struct objfile *obj;
- struct symtab *s;
+ struct compunit_symtab *cust;
if (block == NULL)
return NULL;
block = block_global_block (block);
- /* Go through SYMTABS.
- Non-primary symtabs share the block vector with their primary symtabs
- so we use ALL_PRIMARY_SYMTABS here instead of ALL_SYMTABS. */
- ALL_PRIMARY_SYMTABS (obj, s)
- if (block == BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (s), GLOBAL_BLOCK))
+ /* Look through all blockvectors. */
+ ALL_COMPUNITS (obj, cust)
+ if (block == BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
+ GLOBAL_BLOCK))
{
if (obj->separate_debug_objfile_backlink)
obj = obj->separate_debug_objfile_backlink;
const domain_enum domain)
{
const struct objfile *objfile;
- struct symbol *sym;
- const struct blockvector *bv;
- const struct block *block;
- struct symtab *s;
for (objfile = main_objfile;
objfile;
objfile = objfile_separate_debug_iterate (main_objfile, objfile))
{
+ struct compunit_symtab *cust;
+ struct symbol *sym;
+
/* Go through symtabs. */
- ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
+ ALL_OBJFILE_COMPUNITS (objfile, cust)
{
- bv = SYMTAB_BLOCKVECTOR (s);
+ const struct blockvector *bv;
+ const struct block *block;
+
+ bv = COMPUNIT_BLOCKVECTOR (cust);
block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
sym = block_lookup_symbol (block, name, domain);
if (sym)
lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index,
const char *name, const domain_enum domain)
{
- struct symbol *sym = NULL;
- const struct blockvector *bv;
- const struct block *block;
- struct symtab *s;
+ struct compunit_symtab *cust;
- ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
+ ALL_OBJFILE_COMPUNITS (objfile, cust)
{
- bv = SYMTAB_BLOCKVECTOR (s);
+ const struct blockvector *bv;
+ const struct block *block;
+ struct symbol *sym;
+
+ bv = COMPUNIT_BLOCKVECTOR (cust);
block = BLOCKVECTOR_BLOCK (bv, block_index);
sym = block_lookup_symbol (block, name, domain);
if (sym)
/* Wrapper around lookup_symbol_in_objfile_symtabs for search_symbols.
Look up LINKAGE_NAME in DOMAIN in the global and static blocks of OBJFILE
- and all related objfiles. */
+ and all associated separate debug objfiles.
+
+ Normally we only look in OBJFILE, and not any separate debug objfiles
+ because the outer loop will cause them to be searched too. This case is
+ different. Here we're called from search_symbols where it will only
+ call us for the the objfile that contains a matching minsym. */
static struct symbol *
lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile,
static void ATTRIBUTE_NORETURN
error_in_psymtab_expansion (int block_index, const char *name,
- struct symtab *symtab)
+ struct compunit_symtab *cust)
{
error (_("\
Internal: %s symbol `%s' found in %s psymtab but not in symtab.\n\
%s may be an inlined function, or may be a template function\n \
(if a template, try specifying an instantiation: %s<type>)."),
block_index == GLOBAL_BLOCK ? "global" : "static",
- name, symtab_to_filename_for_display (symtab), name, name);
+ name,
+ symtab_to_filename_for_display (compunit_primary_filetab (cust)),
+ name, name);
}
/* A helper function for various lookup routines that interfaces with
lookup_symbol_via_quick_fns (struct objfile *objfile, int block_index,
const char *name, const domain_enum domain)
{
- struct symtab *symtab;
+ struct compunit_symtab *cust;
const struct blockvector *bv;
const struct block *block;
struct symbol *sym;
if (!objfile->sf)
return NULL;
- symtab = objfile->sf->qf->lookup_symbol (objfile, block_index, name, domain);
- if (!symtab)
+ cust = objfile->sf->qf->lookup_symbol (objfile, block_index, name, domain);
+ if (cust == NULL)
return NULL;
- bv = SYMTAB_BLOCKVECTOR (symtab);
+ 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, symtab);
+ error_in_psymtab_expansion (block_index, name, cust);
block_found = block;
return fixup_symbol_section (sym, objfile);
}
basic_lookup_transparent_type_quick (struct objfile *objfile, int block_index,
const char *name)
{
- struct symtab *symtab;
+ struct compunit_symtab *cust;
const struct blockvector *bv;
struct block *block;
struct symbol *sym;
if (!objfile->sf)
return NULL;
- symtab = objfile->sf->qf->lookup_symbol (objfile, block_index, name,
- STRUCT_DOMAIN);
- if (!symtab)
+ cust = objfile->sf->qf->lookup_symbol (objfile, block_index, name,
+ STRUCT_DOMAIN);
+ if (cust == NULL)
return NULL;
- bv = SYMTAB_BLOCKVECTOR (symtab);
+ bv = COMPUNIT_BLOCKVECTOR (cust);
block = BLOCKVECTOR_BLOCK (bv, block_index);
sym = block_lookup_symbol (block, name, STRUCT_DOMAIN);
if (!sym)
- error_in_psymtab_expansion (block_index, name, symtab);
+ error_in_psymtab_expansion (block_index, name, cust);
if (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
return SYMBOL_TYPE (sym);
basic_lookup_transparent_type (const char *name)
{
struct symbol *sym;
- struct symtab *s = NULL;
+ struct compunit_symtab *cust;
const struct blockvector *bv;
struct objfile *objfile;
struct block *block;
ALL_OBJFILES (objfile)
{
- ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
+ ALL_OBJFILE_COMPUNITS (objfile, cust)
{
- bv = SYMTAB_BLOCKVECTOR (s);
+ bv = COMPUNIT_BLOCKVECTOR (cust);
block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
sym = block_lookup_symbol (block, name, STRUCT_DOMAIN);
if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
ALL_OBJFILES (objfile)
{
- ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
+ ALL_OBJFILE_COMPUNITS (objfile, cust)
{
- bv = SYMTAB_BLOCKVECTOR (s);
+ bv = COMPUNIT_BLOCKVECTOR (cust);
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
sym = block_lookup_symbol (block, name, STRUCT_DOMAIN);
if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
}
}
-/* Find the symtab associated with PC and SECTION. Look through the
- psymtabs and read in another symtab if necessary. */
+/* Find the compunit symtab associated with PC and SECTION.
+ This will read in debug info as necessary. */
-struct symtab *
-find_pc_sect_symtab (CORE_ADDR pc, struct obj_section *section)
+struct compunit_symtab *
+find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section)
{
- struct block *b;
- const struct blockvector *bv;
- struct symtab *s = NULL;
- struct symtab *best_s = NULL;
+ struct compunit_symtab *cust;
+ struct compunit_symtab *best_cust = NULL;
struct objfile *objfile;
CORE_ADDR distance = 0;
struct bound_minimal_symbol msymbol;
It also happens for objfiles that have their functions reordered.
For these, the symtab we are looking for is not necessarily read in. */
- ALL_PRIMARY_SYMTABS (objfile, s)
+ ALL_COMPUNITS (objfile, cust)
{
- bv = SYMTAB_BLOCKVECTOR (s);
+ struct block *b;
+ const struct blockvector *bv;
+
+ bv = COMPUNIT_BLOCKVECTOR (cust);
b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
if (BLOCK_START (b) <= pc
can't be found. */
if ((objfile->flags & OBJF_REORDERED) && objfile->sf)
{
- struct symtab *result;
+ struct compunit_symtab *result;
result
- = objfile->sf->qf->find_pc_sect_symtab (objfile,
- msymbol,
- pc, section,
- 0);
- if (result)
+ = objfile->sf->qf->find_pc_sect_compunit_symtab (objfile,
+ msymbol,
+ pc, section,
+ 0);
+ if (result != NULL)
return result;
}
if (section != 0)
section. */
}
distance = BLOCK_END (b) - BLOCK_START (b);
- best_s = s;
+ best_cust = cust;
}
}
- if (best_s != NULL)
- return (best_s);
+ if (best_cust != NULL)
+ return best_cust;
/* Not found in symtabs, search the "quick" symtabs (e.g. psymtabs). */
ALL_OBJFILES (objfile)
{
- struct symtab *result;
+ struct compunit_symtab *result;
if (!objfile->sf)
continue;
- result = objfile->sf->qf->find_pc_sect_symtab (objfile,
- msymbol,
- pc, section,
- 1);
- if (result)
+ result = objfile->sf->qf->find_pc_sect_compunit_symtab (objfile,
+ msymbol,
+ pc, section,
+ 1);
+ if (result != NULL)
return result;
}
return NULL;
}
-/* Find the symtab associated with PC. Look through the psymtabs and read
- in another symtab if necessary. Backward compatibility, no section. */
+/* Find the compunit symtab associated with PC.
+ This will read in debug info as necessary.
+ Backward compatibility, no section. */
-struct symtab *
-find_pc_symtab (CORE_ADDR pc)
+struct compunit_symtab *
+find_pc_compunit_symtab (CORE_ADDR pc)
{
- return find_pc_sect_symtab (pc, find_pc_mapped_section (pc));
+ return find_pc_sect_compunit_symtab (pc, find_pc_mapped_section (pc));
}
\f
struct symtab_and_line
find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
{
- struct symtab *s;
+ struct compunit_symtab *cust;
+ struct symtab *iter_s;
struct linetable *l;
int len;
int i;
struct symtab_and_line val;
const struct blockvector *bv;
struct bound_minimal_symbol msymbol;
- struct objfile *objfile;
/* Info on best line seen so far, and where it starts, and its file. */
}
- s = find_pc_sect_symtab (pc, section);
- if (!s)
+ cust = find_pc_sect_compunit_symtab (pc, section);
+ if (cust == NULL)
{
/* If no symbol information, return previous pc. */
if (notcurrent)
return val;
}
- bv = SYMTAB_BLOCKVECTOR (s);
- objfile = SYMTAB_OBJFILE (s);
+ bv = COMPUNIT_BLOCKVECTOR (cust);
/* Look at all the symtabs that share this blockvector.
They all have the same apriori range, that we found was right;
but they have different line tables. */
- ALL_OBJFILE_SYMTABS (objfile, s)
+ ALL_COMPUNIT_FILETABS (cust, iter_s)
{
- if (SYMTAB_BLOCKVECTOR (s) != bv)
- continue;
-
/* Find the best line in this symtab. */
- l = SYMTAB_LINETABLE (s);
+ l = SYMTAB_LINETABLE (iter_s);
if (!l)
continue;
len = l->nitems;
if (prev && prev->line && (!best || prev->pc > best->pc))
{
best = prev;
- best_symtab = s;
+ best_symtab = iter_s;
/* Discard BEST_END if it's before the PC of the current BEST. */
if (best_end <= best->pc)
int best;
struct objfile *objfile;
+ struct compunit_symtab *cu;
struct symtab *s;
if (best_index >= 0)
symtab_to_fullname (symtab));
}
- ALL_SYMTABS (objfile, s)
+ ALL_FILETABS (objfile, cu, s)
{
struct linetable *l;
int ind;
/* Be conservative - allow direct PC (without skipping prologue) only if we
have proven the CU (Compilation Unit) supports it. sal->SYMTAB does not
have to be set by the caller so we use SYM instead. */
- if (sym && SYMBOL_SYMTAB (sym)->locations_valid)
+ if (sym && COMPUNIT_LOCATIONS_VALID (SYMTAB_COMPUNIT (SYMBOL_SYMTAB (sym))))
force_skip = 0;
saved_pc = pc;
static void
sources_info (char *ignore, int from_tty)
{
+ struct compunit_symtab *cu;
struct symtab *s;
struct objfile *objfile;
struct output_source_filename_data data;
printf_filtered ("Source files for which symbols have been read in:\n\n");
data.first = 1;
- ALL_SYMTABS (objfile, s)
+ ALL_FILETABS (objfile, cu, s)
{
const char *fullname = symtab_to_fullname (s);
int nfiles, const char *files[],
struct symbol_search **matches)
{
- struct symtab *s;
+ struct compunit_symtab *cust;
const struct blockvector *bv;
struct block *b;
int i = 0;
{
/* Note: An important side-effect of these lookup functions
is to expand the symbol table if msymbol is found, for the
- benefit of the next loop on ALL_PRIMARY_SYMTABS. */
+ benefit of the next loop on ALL_COMPUNITS. */
if (kind == FUNCTIONS_DOMAIN
- ? find_pc_symtab (MSYMBOL_VALUE_ADDRESS (objfile,
- msymbol)) == NULL
+ ? (find_pc_compunit_symtab
+ (MSYMBOL_VALUE_ADDRESS (objfile, msymbol)) == NULL)
: (lookup_symbol_in_objfile_from_linkage_name
(objfile, MSYMBOL_LINKAGE_NAME (msymbol), VAR_DOMAIN)
== NULL))
nfound = 0;
retval_chain = make_cleanup_free_search_symbols (&found);
- ALL_PRIMARY_SYMTABS (objfile, s)
+ ALL_COMPUNITS (objfile, cust)
{
- bv = SYMTAB_BLOCKVECTOR (s);
+ bv = COMPUNIT_BLOCKVECTOR (cust);
for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
{
b = BLOCKVECTOR_BLOCK (bv, i);
e.g., c++ static const members.
We only want to skip enums here. */
&& !(SYMBOL_CLASS (sym) == LOC_CONST
- && TYPE_CODE (SYMBOL_TYPE (sym))
- == TYPE_CODE_ENUM))
+ && (TYPE_CODE (SYMBOL_TYPE (sym))
+ == TYPE_CODE_ENUM)))
|| (kind == FUNCTIONS_DOMAIN
&& SYMBOL_CLASS (sym) == LOC_BLOCK)
|| (kind == TYPES_DOMAIN
}
/* If there are no eyes, avoid all contact. I mean, if there are
- no debug symbols, then print directly from the msymbol_vector. */
+ no debug symbols, then add matching minsyms. */
if (found_misc || (nfiles == 0 && kind != FUNCTIONS_DOMAIN))
{
/* For functions we can do a quick check of whether the
symbol might be found via find_pc_symtab. */
if (kind != FUNCTIONS_DOMAIN
- || find_pc_symtab (MSYMBOL_VALUE_ADDRESS (objfile,
- msymbol)) == NULL)
+ || (find_pc_compunit_symtab
+ (MSYMBOL_VALUE_ADDRESS (objfile, msymbol)) == NULL))
{
if (lookup_symbol_in_objfile_from_linkage_name
(objfile, MSYMBOL_LINKAGE_NAME (msymbol), VAR_DOMAIN)
won't be that many. */
struct symbol *sym;
- struct symtab *s;
+ struct compunit_symtab *cust;
struct minimal_symbol *msymbol;
struct objfile *objfile;
const struct block *b;
/* Go through the symtabs and check the externs and statics for
symbols which match. */
- ALL_PRIMARY_SYMTABS (objfile, s)
+ ALL_COMPUNITS (objfile, cust)
{
QUIT;
- b = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (s), GLOBAL_BLOCK);
+ b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), GLOBAL_BLOCK);
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
if (code == TYPE_CODE_UNDEF
}
}
- ALL_PRIMARY_SYMTABS (objfile, s)
+ ALL_COMPUNITS (objfile, cust)
{
QUIT;
- b = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (s), STATIC_BLOCK);
+ b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK);
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
if (code == TYPE_CODE_UNDEF
VEC (char_ptr) *
make_source_files_completion_list (const char *text, const char *word)
{
+ struct compunit_symtab *cu;
struct symtab *s;
struct objfile *objfile;
size_t text_len = strlen (text);
cache_cleanup = make_cleanup (delete_filename_seen_cache,
filename_seen_cache);
- ALL_SYMTABS (objfile, s)
+ ALL_FILETABS (objfile, cu, s)
{
if (not_interesting_fname (s->filename))
continue;