+2014-11-20 Doug Evans <xdje42@gmail.com>
+
+ Split struct symtab into two: struct symtab and compunit_symtab.
+ * amd64-tdep.c (amd64_skip_xmm_prologue): Fetch producer from compunit.
+ * block.c (blockvector_for_pc_sect): Change "struct symtab *" argument
+ to "struct compunit_symtab *". All callers updated.
+ (set_block_compunit_symtab): Renamed from set_block_symtab. Change
+ "struct symtab *" argument to "struct compunit_symtab *".
+ All callers updated.
+ (get_block_compunit_symtab): Renamed from get_block_symtab. Change
+ result to "struct compunit_symtab *". All callers updated.
+ (find_iterator_compunit_symtab): Renamed from find_iterator_symtab.
+ Change result to "struct compunit_symtab *". All callers updated.
+ * block.h (struct global_block) <compunit_symtab>: Renamed from symtab.
+ hange type to "struct compunit_symtab *". All uses updated.
+ (struct block_iterator) <d.compunit_symtab>: Renamed from "d.symtab".
+ Change type to "struct compunit_symtab *". All uses updated.
+ * buildsym.c (struct buildsym_compunit): New struct.
+ (subfiles, buildsym_compdir, buildsym_objfile, main_subfile): Delete.
+ (buildsym_compunit): New static global.
+ (finish_block_internal): Update to fetch objfile from
+ buildsym_compunit.
+ (make_blockvector): Delete objfile argument.
+ (start_subfile): Rewrite to use buildsym_compunit. Don't initialize
+ debugformat, producer.
+ (start_buildsym_compunit): New function.
+ (free_buildsym_compunit): Renamed from free_subfiles_list.
+ All callers updated.
+ (patch_subfile_names): Rewrite to use buildsym_compunit.
+ (get_compunit_symtab): New function.
+ (get_macro_table): Delete argument comp_dir. All callers updated.
+ (start_symtab): Change result to "struct compunit_symtab *".
+ All callers updated. Create the subfile of the main source file.
+ (watch_main_source_file_lossage): Rewrite to use buildsym_compunit.
+ (reset_symtab_globals): Update.
+ (end_symtab_get_static_block): Update to use buildsym_compunit.
+ (end_symtab_without_blockvector): Rewrite.
+ (end_symtab_with_blockvector): Change result to
+ "struct compunit_symtab *". All callers updated.
+ Update to use buildsym_compunit. Don't set symtab->dirname,
+ instead set it in the compunit.
+ Explicitly make sure main symtab is first in its list.
+ Set debugformat, producer, blockvector, block_line_section, and
+ macrotable in the compunit.
+ (end_symtab_from_static_block): Change result to
+ "struct compunit_symtab *". All callers updated.
+ (end_symtab, end_expandable_symtab): Ditto.
+ (set_missing_symtab): Change symtab argument to
+ "struct compunit_symtab *". All callers updated.
+ (augment_type_symtab): Ditto.
+ (record_debugformat): Update to use buildsym_compunit.
+ (record_producer): Update to use buildsym_compunit.
+ * buildsym.h (struct subfile) <dirname>: Delete.
+ <producer, debugformat>: Delete.
+ <buildsym_compunit>: New member.
+ (get_compunit_symtab): Declare.
+ * dwarf2read.c (struct type_unit_group) <compunit_symtab>: Renamed
+ from primary_symtab. Change type to "struct compunit_symtab *".
+ All uses updated.
+ (dwarf2_start_symtab): Change result to "struct compunit_symtab *".
+ All callers updated.
+ (dwarf_decode_macros): Delete comp_dir argument. All callers updated.
+ (struct dwarf2_per_cu_quick_data) <compunit_symtab>: Renamed from
+ symtab. Change type to "struct compunit_symtab *". All uses updated.
+ (dw2_instantiate_symtab): Change result to "struct compunit_symtab *".
+ All callers updated.
+ (dw2_find_last_source_symtab): Ditto.
+ (dw2_lookup_symbol): Ditto.
+ (recursively_find_pc_sect_compunit_symtab): Renamed from
+ recursively_find_pc_sect_symtab. Change result to
+ "struct compunit_symtab *". All callers updated.
+ (dw2_find_pc_sect_compunit_symtab): Renamed from
+ dw2_find_pc_sect_symtab. Change result to
+ "struct compunit_symtab *". All callers updated.
+ (get_compunit_symtab): Renamed from get_symtab. Change result to
+ "struct compunit_symtab *". All callers updated.
+ (recursively_compute_inclusions): Change type of immediate_parent
+ argument to "struct compunit_symtab *". All callers updated.
+ (compute_compunit_symtab_includes): Renamed from
+ compute_symtab_includes. All callers updated. Rewrite to compute
+ includes of compunit_symtabs and not symtabs.
+ (process_full_comp_unit): Update to work with struct compunit_symtab.
+ (process_full_type_unit): Ditto.
+ (dwarf_decode_lines_1): Delete argument comp_dir. All callers updated.
+ (dwarf_decode_lines): Remove special case handling of main subfile.
+ (macro_start_file): Delete argument comp_dir. All callers updated.
+ (dwarf_decode_macro_bytes): Ditto.
+ * guile/scm-block.c (bkscm_print_block_syms_progress_smob): Update to
+ use struct compunit_symtab.
+ * i386-tdep.c (i386_skip_prologue): Fetch producer from compunit.
+ * jit.c (finalize_symtab): Build compunit_symtab.
+ * jv-lang.c (get_java_class_symtab): Change result to
+ "struct compunit_symtab *". All callers updated.
+ * macroscope.c (sal_macro_scope): Fetch macro table from compunit.
+ * macrotab.c (struct macro_table) <compunit_symtab>: Renamed from
+ comp_dir. Change type to "struct compunit_symtab *".
+ All uses updated.
+ (new_macro_table): Change comp_dir argument to cust,
+ "struct compunit_symtab *". All callers updated.
+ * maint.c (struct cmd_stats) <nr_compunit_symtabs>: Renamed from
+ nr_primary_symtabs. All uses updated.
+ (count_symtabs_and_blocks): Update to handle compunits.
+ (report_command_stats): Update output, "primary symtabs" renamed to
+ "compunits".
+ * mdebugread.c (new_symtab): Change result to
+ "struct compunit_symtab *". All callers updated.
+ (parse_procedure): Change type of search_symtab argument to
+ "struct compunit_symtab *". All callers updated.
+ * objfiles.c (objfile_relocate1): Loop over blockvectors in a
+ separate loop.
+ * objfiles.h (struct objfile) <compunit_symtabs>: Renamed from
+ symtabs. Change type to "struct compunit_symtab *". All uses updated.
+ (ALL_OBJFILE_FILETABS): Renamed from ALL_OBJFILE_SYMTABS.
+ All uses updated.
+ (ALL_OBJFILE_COMPUNITS): Renamed from ALL_OBJFILE_PRIMARY_SYMTABS.
+ All uses updated.
+ (ALL_FILETABS): Renamed from ALL_SYMTABS. All uses updated.
+ (ALL_COMPUNITS): Renamed from ALL_PRIMARY_SYMTABS. All uses updated.
+ * psympriv.h (struct partial_symtab) <compunit_symtab>: Renamed from
+ symtab. Change type to "struct compunit_symtab *". All uses updated.
+ * psymtab.c (psymtab_to_symtab): Change result type to
+ "struct compunit_symtab *". All callers updated.
+ (find_pc_sect_compunit_symtab_from_partial): Renamed from
+ find_pc_sect_symtab_from_partial. Change result type to
+ "struct compunit_symtab *". All callers updated.
+ (lookup_symbol_aux_psymtabs): Change result type to
+ "struct compunit_symtab *". All callers updated.
+ (find_last_source_symtab_from_partial): Ditto.
+ * python/py-symtab.c (stpy_get_producer): Fetch producer from compunit.
+ * source.c (forget_cached_source_info_for_objfile): Fetch debugformat
+ and macro_table from compunit.
+ * symfile-debug.c (debug_qf_find_last_source_symtab): Change result
+ type to "struct compunit_symtab *". All callers updated.
+ (debug_qf_lookup_symbol): Ditto.
+ (debug_qf_find_pc_sect_compunit_symtab): Renamed from
+ debug_qf_find_pc_sect_symtab, change result type to
+ "struct compunit_symtab *". All callers updated.
+ * symfile.c (allocate_symtab): Delete objfile argument.
+ New argument cust.
+ (allocate_compunit_symtab): New function.
+ (add_compunit_symtab_to_objfile): New function.
+ * symfile.h (struct quick_symbol_functions) <lookup_symbol>:
+ Change result type to "struct compunit_symtab *". All uses updated.
+ <find_pc_sect_compunit_symtab>: Renamed from find_pc_sect_symtab.
+ Change result type to "struct compunit_symtab *". All uses updated.
+ * symmisc.c (print_objfile_statistics): Compute blockvector count in
+ separate loop.
+ (dump_symtab_1): Update test for primary source symtab.
+ (maintenance_info_symtabs): Update to handle compunit symtabs.
+ (maintenance_check_symtabs): Ditto.
+ * symtab.c (set_primary_symtab): Delete.
+ (compunit_primary_filetab): New function.
+ (compunit_language): New function.
+ (iterate_over_some_symtabs): Change type of arguments "first",
+ "after_last" to "struct compunit_symtab *". All callers updated.
+ Update to loop over symtabs in each compunit.
+ (error_in_psymtab_expansion): Rename symtab argument to cust,
+ and change type to "struct compunit_symtab *". All callers updated.
+ (find_pc_sect_compunit_symtab): Renamed from find_pc_sect_symtab.
+ Change result type to "struct compunit_symtab *". All callers updated.
+ (find_pc_compunit_symtab): Renamed from find_pc_symtab.
+ Change result type to "struct compunit_symtab *". All callers updated.
+ (find_pc_sect_line): Only loop over symtabs within selected compunit
+ instead of all symtabs in the objfile.
+ * symtab.h (struct symtab) <blockvector>: Moved to compunit_symtab.
+ <compunit_symtab> New member.
+ <block_line_section>: Moved to compunit_symtab.
+ <locations_valid>: Ditto.
+ <epilogue_unwind_valid>: Ditto.
+ <macro_table>: Ditto.
+ <dirname>: Ditto.
+ <debugformat>: Ditto.
+ <producer>: Ditto.
+ <objfile>: Ditto.
+ <call_site_htab>: Ditto.
+ <includes>: Ditto.
+ <user>: Ditto.
+ <primary>: Delete
+ (SYMTAB_COMPUNIT): New macro.
+ (SYMTAB_BLOCKVECTOR): Update definition.
+ (SYMTAB_OBJFILE): Update definition.
+ (SYMTAB_DIRNAME): Update definition.
+ (struct compunit_symtab): New type. Common members among all source
+ symtabs within a compilation unit moved here. All uses updated.
+ (COMPUNIT_OBJFILE): New macro.
+ (COMPUNIT_FILETABS): New macro.
+ (COMPUNIT_DEBUGFORMAT): New macro.
+ (COMPUNIT_PRODUCER): New macro.
+ (COMPUNIT_DIRNAME): New macro.
+ (COMPUNIT_BLOCKVECTOR): New macro.
+ (COMPUNIT_BLOCK_LINE_SECTION): New macro.
+ (COMPUNIT_LOCATIONS_VALID): New macro.
+ (COMPUNIT_EPILOGUE_UNWIND_VALID): New macro.
+ (COMPUNIT_CALL_SITE_HTAB): New macro.
+ (COMPUNIT_MACRO_TABLE): New macro.
+ (ALL_COMPUNIT_FILETABS): New macro.
+ (compunit_symtab_ptr): New typedef.
+ (DEF_VEC_P (compunit_symtab_ptr)): New vector type.
+
2014-11-20 Joel Brobecker <brobecker@adacore.com>
* ada-lang.c (ada_is_redundant_range_encoding): Return 0
int encoded_p;
VEC(char_ptr) *completions = VEC_alloc (char_ptr, 128);
struct symbol *sym;
- struct symtab *s;
+ struct compunit_symtab *s;
struct minimal_symbol *msymbol;
struct objfile *objfile;
const struct block *b, *surrounding_static_block = 0;
}
/* Go through the symtabs and check the externs and statics for
- symbols which match.
- Non-primary symtabs share the block vector with their primary symtabs
- so we use ALL_PRIMARY_SYMTABS here instead of ALL_SYMTABS. */
+ symbols which match. */
- ALL_PRIMARY_SYMTABS (objfile, s)
+ ALL_COMPUNITS (objfile, s)
{
QUIT;
- b = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (s), GLOBAL_BLOCK);
+ b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), GLOBAL_BLOCK);
ALL_BLOCK_SYMBOLS (b, iter, sym)
{
symbol_completion_add (&completions, SYMBOL_LINKAGE_NAME (sym),
}
}
- ALL_PRIMARY_SYMTABS (objfile, s)
+ ALL_COMPUNITS (objfile, s)
{
QUIT;
- b = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (s), STATIC_BLOCK);
+ b = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (s), STATIC_BLOCK);
/* Don't do this block twice. */
if (b == surrounding_static_block)
continue;
ada_add_global_exceptions (regex_t *preg, VEC(ada_exc_info) **exceptions)
{
struct objfile *objfile;
- struct symtab *s;
+ struct compunit_symtab *s;
expand_symtabs_matching (NULL, ada_exc_search_name_matches,
VARIABLES_DOMAIN, preg);
- ALL_PRIMARY_SYMTABS (objfile, s)
+ ALL_COMPUNITS (objfile, s)
{
- const struct blockvector *bv = SYMTAB_BLOCKVECTOR (s);
+ const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (s);
int i;
for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
start_pc_sal = find_pc_sect_line (start_pc, NULL, 0);
if (start_pc_sal.symtab == NULL
- || producer_is_gcc_ge_4 (start_pc_sal.symtab->producer) < 6
+ || producer_is_gcc_ge_4 (COMPUNIT_PRODUCER
+ (SYMTAB_COMPUNIT (start_pc_sal.symtab))) < 6
|| start_pc_sal.pc != start_pc || pc >= start_pc_sal.end)
return pc;
{
CORE_ADDR post_prologue_pc
= skip_prologue_using_sal (gdbarch, func_addr);
- struct symtab *s = find_pc_symtab (func_addr);
+ struct compunit_symtab *cust = find_pc_compunit_symtab (func_addr);
/* Clang always emits a line note before the prologue and another
one after. We trust clang to emit usable line notes. */
if (post_prologue_pc
- && (s != NULL
- && s->producer != NULL
- && strncmp (s->producer, "clang ", sizeof ("clang ") - 1) == 0))
+ && (cust != NULL
+ && COMPUNIT_PRODUCER (cust) != NULL
+ && strncmp (COMPUNIT_PRODUCER (cust), "clang ",
+ sizeof ("clang ") - 1) == 0))
return max (start_pc, post_prologue_pc);
}
amd64_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
gdb_byte insn;
- struct symtab *symtab;
+ struct compunit_symtab *cust;
- symtab = find_pc_symtab (pc);
- if (symtab && symtab->epilogue_unwind_valid)
+ cust = find_pc_compunit_symtab (pc);
+ if (cust != NULL && COMPUNIT_EPILOGUE_UNWIND_VALID (cust))
return 0;
if (target_read_memory (pc, &insn, 1))
{
CORE_ADDR post_prologue_pc
= skip_prologue_using_sal (gdbarch, func_addr);
- struct symtab *s = find_pc_symtab (func_addr);
+ struct compunit_symtab *cust = find_pc_compunit_symtab (func_addr);
if (post_prologue_pc)
post_prologue_pc
will have producer information for most binaries; if it is
missing (e.g. for -gstabs), assuming the GNU tools. */
if (post_prologue_pc
- && (s == NULL
- || s->producer == NULL
- || strncmp (s->producer, "GNU ", sizeof ("GNU ") - 1) == 0
- || strncmp (s->producer, "clang ", sizeof ("clang ") - 1) == 0))
+ && (cust == NULL
+ || COMPUNIT_PRODUCER (cust) == NULL
+ || strncmp (COMPUNIT_PRODUCER (cust), "GNU ",
+ sizeof ("GNU ") - 1) == 0
+ || strncmp (COMPUNIT_PRODUCER (cust), "clang ",
+ sizeof ("clang ") - 1) == 0))
return post_prologue_pc;
if (post_prologue_pc != 0)
const struct blockvector *
blockvector_for_pc_sect (CORE_ADDR pc, struct obj_section *section,
- const struct block **pblock, struct symtab *symtab)
+ const struct block **pblock,
+ struct compunit_symtab *cust)
{
const struct blockvector *bl;
struct block *b;
- if (symtab == 0) /* if no symtab specified by caller */
+ if (cust == NULL)
{
/* First search all symtabs for one whose file contains our pc */
- symtab = find_pc_sect_symtab (pc, section);
- if (symtab == 0)
+ cust = find_pc_sect_compunit_symtab (pc, section);
+ if (cust == NULL)
return 0;
}
- bl = SYMTAB_BLOCKVECTOR (symtab);
+ bl = COMPUNIT_BLOCKVECTOR (cust);
/* Then search that symtab for the smallest block that wins. */
b = find_block_in_blockvector (bl, pc);
struct call_site *
call_site_for_pc (struct gdbarch *gdbarch, CORE_ADDR pc)
{
- struct symtab *symtab;
+ struct compunit_symtab *cust;
void **slot = NULL;
/* -1 as tail call PC can be already after the compilation unit range. */
- symtab = find_pc_symtab (pc - 1);
+ cust = find_pc_compunit_symtab (pc - 1);
- if (symtab != NULL && symtab->call_site_htab != NULL)
- slot = htab_find_slot (symtab->call_site_htab, &pc, NO_INSERT);
+ if (cust != NULL && COMPUNIT_CALL_SITE_HTAB (cust) != NULL)
+ slot = htab_find_slot (COMPUNIT_CALL_SITE_HTAB (cust), &pc, NO_INSERT);
if (slot == NULL)
{
return &bl->block;
}
-/* Set the symtab of the global block. */
+/* Set the compunit of the global block. */
void
-set_block_symtab (struct block *block, struct symtab *symtab)
+set_block_compunit_symtab (struct block *block, struct compunit_symtab *cu)
{
struct global_block *gb;
gdb_assert (BLOCK_SUPERBLOCK (block) == NULL);
gb = (struct global_block *) block;
- gdb_assert (gb->symtab == NULL);
- gb->symtab = symtab;
+ gdb_assert (gb->compunit_symtab == NULL);
+ gb->compunit_symtab = cu;
}
-/* Return the symtab of the global block. */
+/* Return the compunit of the global block. */
-static struct symtab *
-get_block_symtab (const struct block *block)
+static struct compunit_symtab *
+get_block_compunit_symtab (const struct block *block)
{
struct global_block *gb;
gdb_assert (BLOCK_SUPERBLOCK (block) == NULL);
gb = (struct global_block *) block;
- gdb_assert (gb->symtab != NULL);
- return gb->symtab;
+ gdb_assert (gb->compunit_symtab != NULL);
+ return gb->compunit_symtab;
}
\f
struct block_iterator *iter)
{
enum block_enum which;
- struct symtab *symtab;
+ struct compunit_symtab *cu;
iter->idx = -1;
if (BLOCK_SUPERBLOCK (block) == NULL)
{
which = GLOBAL_BLOCK;
- symtab = get_block_symtab (block);
+ cu = get_block_compunit_symtab (block);
}
else if (BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL)
{
which = STATIC_BLOCK;
- symtab = get_block_symtab (BLOCK_SUPERBLOCK (block));
+ cu = get_block_compunit_symtab (BLOCK_SUPERBLOCK (block));
}
else
{
/* If this is an included symtab, find the canonical includer and
use it instead. */
- while (symtab->user != NULL)
- symtab = symtab->user;
+ while (cu->user != NULL)
+ cu = cu->user;
/* Putting this check here simplifies the logic of the iterator
functions. If there are no included symtabs, we only need to
search a single block, so we might as well just do that
directly. */
- if (symtab->includes == NULL)
+ if (cu->includes == NULL)
{
iter->d.block = block;
/* A signal value meaning that we're iterating over a single
}
else
{
- iter->d.symtab = symtab;
+ iter->d.compunit_symtab = cu;
iter->which = which;
}
}
-/* A helper function that finds the current symtab over whose static
+/* A helper function that finds the current compunit over whose static
or global block we should iterate. */
-static struct symtab *
-find_iterator_symtab (struct block_iterator *iterator)
+static struct compunit_symtab *
+find_iterator_compunit_symtab (struct block_iterator *iterator)
{
if (iterator->idx == -1)
- return iterator->d.symtab;
- return iterator->d.symtab->includes[iterator->idx];
+ return iterator->d.compunit_symtab;
+ return iterator->d.compunit_symtab->includes[iterator->idx];
}
/* Perform a single step for a plain block iterator, iterating across
{
if (first)
{
- struct symtab *symtab = find_iterator_symtab (iterator);
+ struct compunit_symtab *cust
+ = find_iterator_compunit_symtab (iterator);
const struct block *block;
/* Iteration is complete. */
- if (symtab == NULL)
+ if (cust == NULL)
return NULL;
- block = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symtab),
+ block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
iterator->which);
sym = dict_iterator_first (BLOCK_DICT (block), &iterator->dict_iter);
}
{
if (first)
{
- struct symtab *symtab = find_iterator_symtab (iterator);
+ struct compunit_symtab *cust
+ = find_iterator_compunit_symtab (iterator);
const struct block *block;
/* Iteration is complete. */
- if (symtab == NULL)
+ if (cust == NULL)
return NULL;
- block = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symtab),
+ block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
iterator->which);
sym = dict_iter_name_first (BLOCK_DICT (block), name,
&iterator->dict_iter);
{
if (first)
{
- struct symtab *symtab = find_iterator_symtab (iterator);
+ struct compunit_symtab *cust
+ = find_iterator_compunit_symtab (iterator);
const struct block *block;
/* Iteration is complete. */
- if (symtab == NULL)
+ if (cust == NULL)
return NULL;
- block = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symtab),
+ block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
iterator->which);
sym = dict_iter_match_first (BLOCK_DICT (block), name,
compare, &iterator->dict_iter);
/* Opaque declarations. */
struct symbol;
-struct symtab;
+struct compunit_symtab;
struct block_namespace_info;
struct using_direct;
struct obstack;
};
/* The global block is singled out so that we can provide a back-link
- to the primary symtab. */
+ to the compunit symtab. */
struct global_block
{
struct block block;
- /* This holds a pointer to the primary symtab holding this
- block. */
+ /* This holds a pointer to the compunit symtab holding this block. */
- struct symtab *symtab;
+ struct compunit_symtab *compunit_symtab;
};
#define BLOCK_START(bl) (bl)->startaddr
extern const struct blockvector *blockvector_for_pc (CORE_ADDR,
const struct block **);
-extern const struct blockvector *blockvector_for_pc_sect (CORE_ADDR,
- struct obj_section *,
- const struct block **,
- struct symtab *);
+extern const struct blockvector *
+ blockvector_for_pc_sect (CORE_ADDR, struct obj_section *,
+ const struct block **, struct compunit_symtab *);
extern int blockvector_contains_pc (const struct blockvector *bv, CORE_ADDR pc);
extern struct block *allocate_global_block (struct obstack *obstack);
-extern void set_block_symtab (struct block *, struct symtab *);
+extern void set_block_compunit_symtab (struct block *,
+ struct compunit_symtab *);
/* A block iterator. This structure should be treated as though it
were opaque; it is only defined here because we want to support
struct block_iterator
{
/* If we're iterating over a single block, this holds the block.
- Otherwise, it holds the canonical symtab. */
+ Otherwise, it holds the canonical compunit. */
union
{
- struct symtab *symtab;
+ struct compunit_symtab *compunit_symtab;
const struct block *block;
} d;
struct obj_section *section;
struct symbol *f;
struct bound_minimal_symbol msymbol;
- struct symtab *symtab = NULL;
+ struct compunit_symtab *compunit_symtab = NULL;
struct objfile *objfile;
int i;
CORE_ADDR mapped_pc;
ALL_OBJFILES (objfile)
{
if (objfile->sf)
- symtab = objfile->sf->qf->find_pc_sect_symtab (objfile, msymbol,
- mapped_pc, section, 0);
- if (symtab)
+ {
+ compunit_symtab
+ = objfile->sf->qf->find_pc_sect_compunit_symtab (objfile, msymbol,
+ mapped_pc, section,
+ 0);
+ }
+ if (compunit_symtab != NULL)
break;
}
- if (symtab)
+ if (compunit_symtab != NULL)
{
/* Checking whether the msymbol has a larger value is for the
"pathological" case mentioned in print_frame_info. */
const struct block *b;
struct symbol *sym;
- bv = blockvector_for_pc_sect (sal->pc, 0, &b, sal->symtab);
+ bv = blockvector_for_pc_sect (sal->pc, 0, &b,
+ SYMTAB_COMPUNIT (sal->symtab));
if (bv != NULL)
{
sym = block_linkage_function (b);
#include "stabsread.h"
-/* The objfile we are currently reading debug info from. */
+/* Buildsym's counterpart to struct compunit_symtab.
+ TODO(dje): Move all related global state into here. */
-static struct objfile *buildsym_objfile;
+struct buildsym_compunit
+{
+ /* The objfile we're reading debug info from. */
+ struct objfile *objfile;
+
+ /* List of subfiles (source files).
+ Files are added to the front of the list.
+ This is important mostly for the language determination hacks we use,
+ which iterate over previously added files. */
+ struct subfile *subfiles;
+
+ /* The subfile of the main source file. */
+ struct subfile *main_subfile;
-/* The compilation directory. */
+ /* E.g., DW_AT_comp_dir if DWARF. Space for this is malloc'd. */
+ char *comp_dir;
-static char *buildsym_comp_dir;
+ /* Space for this is not malloc'd, and is assumed to have at least
+ the same lifetime as objfile. */
+ const char *producer;
-/* List of subfiles. */
+ /* Space for this is not malloc'd, and is assumed to have at least
+ the same lifetime as objfile. */
+ const char *debugformat;
-static struct subfile *subfiles;
+ /* The compunit we are building. */
+ struct compunit_symtab *compunit_symtab;
+};
-/* The "main" subfile.
- In C this is the ".c" file (and similarly for other languages).
- This becomes the "primary" symtab of the compilation unit. */
+/* The work-in-progress of the compunit we are building.
+ This is created first, before any subfiles by start_symtab. */
-static struct subfile *main_subfile;
+static struct buildsym_compunit *buildsym_compunit;
/* List of free `struct pending' structures for reuse. */
static struct subfile_stack *subfile_stack;
/* The macro table for the compilation unit whose symbols we're
- currently reading. All the symtabs for the CU will point to this. */
+ currently reading. */
static struct macro_table *pending_macros;
static int compare_line_numbers (const void *ln1p, const void *ln2p);
CORE_ADDR start, CORE_ADDR end,
int is_global, int expandable)
{
- struct objfile *objfile = buildsym_objfile;
+ struct objfile *objfile = buildsym_compunit->objfile;
struct gdbarch *gdbarch = get_objfile_arch (objfile);
struct pending *next, *next1;
struct block *block;
addrmap_set_empty (pending_addrmap, start, end_inclusive, block);
}
-
static struct blockvector *
-make_blockvector (struct objfile *objfile)
+make_blockvector (void)
{
+ struct objfile *objfile = buildsym_compunit->objfile;
struct pending_block *next;
struct blockvector *blockvector;
int i;
void
start_subfile (const char *name)
{
+ const char *subfile_dirname;
struct subfile *subfile;
- /* See if this subfile is already known as a subfile of the current
- main source file. */
+ gdb_assert (buildsym_compunit != NULL);
+
+ subfile_dirname = buildsym_compunit->comp_dir;
+
+ /* See if this subfile is already registered. */
- for (subfile = subfiles; subfile; subfile = subfile->next)
+ for (subfile = buildsym_compunit->subfiles; subfile; subfile = subfile->next)
{
char *subfile_name;
attempt to create an absolute path to compare. */
if (IS_ABSOLUTE_PATH (name)
&& !IS_ABSOLUTE_PATH (subfile->name)
- && subfile->dirname != NULL)
- subfile_name = concat (subfile->dirname, SLASH_STRING,
+ && subfile_dirname != NULL)
+ subfile_name = concat (subfile_dirname, SLASH_STRING,
subfile->name, (char *) NULL);
else
subfile_name = subfile->name;
xfree (subfile_name);
}
- /* This subfile is not known. Add an entry for it. Make an entry
- for this subfile in the list of all subfiles of the current main
- source file. */
+ /* This subfile is not known. Add an entry for it. */
subfile = (struct subfile *) xmalloc (sizeof (struct subfile));
- memset ((char *) subfile, 0, sizeof (struct subfile));
- subfile->next = subfiles;
- subfiles = subfile;
+ memset (subfile, 0, sizeof (struct subfile));
+ subfile->buildsym_compunit = buildsym_compunit;
+
+ subfile->next = buildsym_compunit->subfiles;
+ buildsym_compunit->subfiles = subfile;
+
current_subfile = subfile;
- /* Save its name and compilation directory name. */
subfile->name = xstrdup (name);
- subfile->dirname
- = (buildsym_comp_dir == NULL) ? NULL : xstrdup (buildsym_comp_dir);
/* Initialize line-number recording for this subfile. */
subfile->line_vector = NULL;
subfile->language = subfile->next->language;
}
- /* Initialize the debug format string to NULL. We may supply it
- later via a call to record_debugformat. */
- subfile->debugformat = NULL;
-
- /* Similarly for the producer. */
- subfile->producer = NULL;
-
/* If the filename of this subfile ends in .C, then change the
language of any pending subfiles from C to C++. We also accept
any other C++ suffixes accepted by deduce_language_from_filename. */
enum language sublang = deduce_language_from_filename (subfile->name);
if (sublang == language_cplus || sublang == language_fortran)
- for (s = subfiles; s != NULL; s = s->next)
+ for (s = buildsym_compunit->subfiles; s != NULL; s = s->next)
if (s->language == language_c)
s->language = sublang;
}
}
}
-/* Delete the subfiles list. */
+/* Start recording information about a primary source file (IOW, not an
+ included source file).
+ COMP_DIR is the directory in which the compilation unit was compiled
+ (or NULL if not known). */
+
+static struct buildsym_compunit *
+start_buildsym_compunit (struct objfile *objfile, const char *comp_dir)
+{
+ struct buildsym_compunit *bscu;
+
+ bscu = (struct buildsym_compunit *)
+ xmalloc (sizeof (struct buildsym_compunit));
+ memset (bscu, 0, sizeof (struct buildsym_compunit));
+
+ bscu->objfile = objfile;
+ bscu->comp_dir = (comp_dir == NULL) ? NULL : xstrdup (comp_dir);
+
+ /* Initialize the debug format string to NULL. We may supply it
+ later via a call to record_debugformat. */
+ bscu->debugformat = NULL;
+
+ /* Similarly for the producer. */
+ bscu->producer = NULL;
+
+ return bscu;
+}
+
+/* Delete the buildsym compunit. */
static void
-free_subfiles_list (void)
+free_buildsym_compunit (void)
{
struct subfile *subfile, *nextsub;
- for (subfile = subfiles; subfile != NULL; subfile = nextsub)
+ if (buildsym_compunit == NULL)
+ return;
+ for (subfile = buildsym_compunit->subfiles;
+ subfile != NULL;
+ subfile = nextsub)
{
nextsub = subfile->next;
xfree (subfile->name);
- xfree (subfile->dirname);
xfree (subfile->line_vector);
xfree (subfile);
}
- subfiles = NULL;
- current_subfile = NULL;
- main_subfile = NULL;
+ xfree (buildsym_compunit->comp_dir);
+ xfree (buildsym_compunit);
+ buildsym_compunit = NULL;
}
/* For stabs readers, the first N_SO symbol is assumed to be the
void
patch_subfile_names (struct subfile *subfile, char *name)
{
- if (subfile != NULL && subfile->dirname == NULL && subfile->name != NULL
+ if (subfile != NULL
+ && buildsym_compunit->comp_dir == NULL
+ && subfile->name != NULL
&& IS_DIR_SEPARATOR (subfile->name[strlen (subfile->name) - 1]))
{
- /* With correct debug info, buildsym_comp_dir should be NULL since
- subfile->dirname is NULL. However, don't assume this. */
- xfree (buildsym_comp_dir);
- buildsym_comp_dir = xstrdup (subfile->name);
-
- subfile->dirname = subfile->name;
+ buildsym_compunit->comp_dir = subfile->name;
subfile->name = xstrdup (name);
set_last_source_file (name);
return ln1->line - ln2->line;
}
\f
-/* Return the macro table.
- Initialize it if this is the first use.
- It is only valid to call this between calls to start_symtab and the
- end_symtab* functions. */
+/* See buildsym.h. */
+
+struct compunit_symtab *
+buildsym_compunit_symtab (void)
+{
+ gdb_assert (buildsym_compunit != NULL);
+
+ return buildsym_compunit->compunit_symtab;
+}
+
+/* See buildsym.h. */
struct macro_table *
-get_macro_table (const char *comp_dir)
+get_macro_table (void)
{
- struct objfile *objfile = buildsym_objfile;
+ struct objfile *objfile;
+
+ gdb_assert (buildsym_compunit != NULL);
+
+ objfile = buildsym_compunit->objfile;
if (! pending_macros)
- pending_macros = new_macro_table (&objfile->per_bfd->storage_obstack,
- objfile->per_bfd->macro_cache,
- comp_dir);
+ {
+ pending_macros = new_macro_table (&objfile->per_bfd->storage_obstack,
+ objfile->per_bfd->macro_cache,
+ buildsym_compunit->compunit_symtab);
+ }
+
return pending_macros;
}
\f
which the file was compiled (or NULL if not known). START_ADDR is the
lowest address of objects in the file (or 0 if not known). */
-void
+struct compunit_symtab *
start_symtab (struct objfile *objfile, const char *name, const char *comp_dir,
CORE_ADDR start_addr)
{
- buildsym_objfile = objfile;
- buildsym_comp_dir = comp_dir != NULL ? xstrdup (comp_dir) : NULL;
restart_symtab (start_addr);
- set_last_source_file (name);
+
+ buildsym_compunit = start_buildsym_compunit (objfile, comp_dir);
+
+ /* Allocate the primary symtab now. The caller needs it to allocate
+ non-primary symtabs. It is also needed by get_macro_table. */
+ buildsym_compunit->compunit_symtab = allocate_compunit_symtab (objfile,
+ name);
+
+ /* Build the subfile for NAME (the main source file) so that we can record
+ a pointer to it for later.
+ IMPORTANT: Do not allocate a struct symtab for NAME here.
+ It can happen that the debug info provides a different path to NAME than
+ DIRNAME,NAME. We cope with this in watch_main_source_file_lossage but
+ that only works if the main_subfile doesn't have a symtab yet. */
start_subfile (name);
/* Save this so that we don't have to go looking for it at the end
of the subfiles list. */
- main_subfile = current_subfile;
+ buildsym_compunit->main_subfile = current_subfile;
+
+ set_last_source_file (name);
+
+ return buildsym_compunit->compunit_symtab;
}
/* Restart compilation for a symtab.
/* Reset the sub source files list. The list should already be empty,
but free it anyway in case some code didn't finish cleaning up after
an error. */
- free_subfiles_list ();
+ free_buildsym_compunit ();
}
/* Subroutine of end_symtab to simplify it. Look for a subfile that
main source file's subfile and discard the other subfile. This can
happen because of a compiler bug or from the user playing games
with #line or from things like a distributed build system that
- manipulates the debug info. */
+ manipulates the debug info. This can also happen from an innocent
+ symlink in the paths, we don't canonicalize paths here. */
static void
watch_main_source_file_lossage (void)
{
- struct subfile *subfile;
+ struct subfile *mainsub, *subfile;
- /* We have to watch for mainsub == NULL here. It's a quirk of
+ /* We have to watch for buildsym_compunit == NULL here. It's a quirk of
end_symtab, it can return NULL so there may not be a main subfile. */
- if (main_subfile == NULL)
+ if (buildsym_compunit == NULL)
return;
+ /* Get the main source file. */
+ mainsub = buildsym_compunit->main_subfile;
+
/* If the main source file doesn't have any line number or symbol
info, look for an alias in another subfile. */
- if (main_subfile->line_vector == NULL
- && main_subfile->symtab == NULL)
+ if (mainsub->line_vector == NULL
+ && mainsub->symtab == NULL)
{
- const char *mainbase = lbasename (main_subfile->name);
+ const char *mainbase = lbasename (mainsub->name);
int nr_matches = 0;
struct subfile *prevsub;
struct subfile *mainsub_alias = NULL;
struct subfile *prev_mainsub_alias = NULL;
prevsub = NULL;
- for (subfile = subfiles;
- /* Stop before we get to the last one. */
- subfile->next;
+ for (subfile = buildsym_compunit->subfiles;
+ subfile != NULL;
subfile = subfile->next)
{
+ if (subfile == mainsub)
+ continue;
if (filename_cmp (lbasename (subfile->name), mainbase) == 0)
{
++nr_matches;
if (nr_matches == 1)
{
- gdb_assert (mainsub_alias != NULL && mainsub_alias != main_subfile);
+ gdb_assert (mainsub_alias != NULL && mainsub_alias != mainsub);
/* Found a match for the main source file.
Copy its line_vector and symtab to the main subfile
and then discard it. */
- main_subfile->line_vector = mainsub_alias->line_vector;
- main_subfile->line_vector_length = mainsub_alias->line_vector_length;
- main_subfile->symtab = mainsub_alias->symtab;
+ mainsub->line_vector = mainsub_alias->line_vector;
+ mainsub->line_vector_length = mainsub_alias->line_vector_length;
+ mainsub->symtab = mainsub_alias->symtab;
if (prev_mainsub_alias == NULL)
- subfiles = mainsub_alias->next;
+ buildsym_compunit->subfiles = mainsub_alias->next;
else
prev_mainsub_alias->next = mainsub_alias->next;
xfree (mainsub_alias->name);
- xfree (mainsub_alias->dirname);
xfree (mainsub_alias);
}
}
static void
reset_symtab_globals (void)
{
- buildsym_objfile = NULL;
- xfree (buildsym_comp_dir);
- buildsym_comp_dir = NULL;
set_last_source_file (NULL);
- free_subfiles_list ();
+ free_buildsym_compunit ();
pending_macros = NULL;
if (pending_addrmap)
{
struct block *
end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
{
- struct objfile *objfile = buildsym_objfile;
+ struct objfile *objfile = buildsym_compunit->objfile;
/* Finish the lexical context of the last function in the file; pop
the context stack. */
static void
end_symtab_without_blockvector (void)
{
- struct objfile *objfile = buildsym_objfile;
- struct subfile *subfile;
-
- /* Since we are ignoring these subfiles, we also need
- to unlink the associated empty symtab that we created.
- Otherwise, we can run into trouble because various parts
- such as the block-vector are uninitialized whereas
- the rest of the code assumes that they are.
-
- We can only unlink the symtab. We can't free it because
- it was allocated on the objfile obstack. */
-
- for (subfile = subfiles; subfile != NULL; subfile = subfile->next)
- {
- if (subfile->symtab)
- {
- struct symtab *s;
-
- if (objfile->symtabs == subfile->symtab)
- objfile->symtabs = objfile->symtabs->next;
- else
- ALL_OBJFILE_SYMTABS (objfile, s)
- if (s->next == subfile->symtab)
- {
- s->next = s->next->next;
- break;
- }
- subfile->symtab = NULL;
- }
- }
+ /* Free up all the subfiles.
+ We won't be adding a compunit to the objfile's list of compunits,
+ so there's nothing to unchain. However, since each symtab
+ is added to the objfile's obstack we can't free that space.
+ We could do better, but this is believed to be a sufficiently rare
+ event. */
+ free_buildsym_compunit ();
}
/* Subroutine of end_symtab_from_static_block to simplify it.
Handle the "have blockvector" case.
See end_symtab_from_static_block for a description of the arguments. */
-static struct symtab *
+static struct compunit_symtab *
end_symtab_with_blockvector (struct block *static_block,
int section, int expandable)
{
- struct objfile *objfile = buildsym_objfile;
+ struct objfile *objfile = buildsym_compunit->objfile;
+ struct compunit_symtab *cu = buildsym_compunit->compunit_symtab;
struct symtab *symtab;
struct blockvector *blockvector;
struct subfile *subfile;
CORE_ADDR end_addr;
gdb_assert (static_block != NULL);
- gdb_assert (subfiles != NULL);
+ gdb_assert (buildsym_compunit != NULL);
+ gdb_assert (buildsym_compunit->subfiles != NULL);
end_addr = BLOCK_END (static_block);
finish_block_internal (NULL, &global_symbols, NULL,
last_source_start_addr, end_addr,
1, expandable);
- blockvector = make_blockvector (objfile);
+ blockvector = make_blockvector ();
/* Read the line table if it has to be read separately.
This is only used by xcoffread.c. */
line number information. */
watch_main_source_file_lossage ();
- /* Now create the symtab objects proper, one for each subfile. */
+ /* Now create the symtab objects proper, if not already done,
+ one for each subfile. */
- for (subfile = subfiles; subfile != NULL; subfile = subfile->next)
+ for (subfile = buildsym_compunit->subfiles;
+ subfile != NULL;
+ subfile = subfile->next)
{
int linetablesize = 0;
/* Allocate a symbol table if necessary. */
if (subfile->symtab == NULL)
- subfile->symtab = allocate_symtab (subfile->name, objfile);
+ subfile->symtab = allocate_symtab (cu, subfile->name);
symtab = subfile->symtab;
/* Fill in its components. */
- symtab->blockvector = blockvector;
- symtab->macro_table = pending_macros;
+
if (subfile->line_vector)
{
/* Reallocate the line table on the symbol obstack. */
{
SYMTAB_LINETABLE (symtab) = NULL;
}
- symtab->block_line_section = section;
- if (subfile->dirname)
- {
- /* Reallocate the dirname on the symbol obstack. */
- SYMTAB_DIRNAME (symtab) =
- obstack_copy0 (&objfile->objfile_obstack,
- subfile->dirname,
- strlen (subfile->dirname));
- }
- else
- {
- SYMTAB_DIRNAME (symtab) = NULL;
- }
/* Use whatever language we have been using for this
subfile, not the one that was deduced in allocate_symtab
opinion of what language it is from things we found in
the symbols. */
symtab->language = subfile->language;
+ }
- /* Save the debug format string (if any) in the symtab. */
- symtab->debugformat = subfile->debugformat;
+ /* Make sure the symtab of main_subfile is the first in its list. */
+ {
+ struct symtab *main_symtab, *prev_symtab;
+
+ main_symtab = buildsym_compunit->main_subfile->symtab;
+ prev_symtab = NULL;
+ ALL_COMPUNIT_FILETABS (cu, symtab)
+ {
+ if (symtab == main_symtab)
+ {
+ if (prev_symtab != NULL)
+ {
+ prev_symtab->next = main_symtab->next;
+ main_symtab->next = COMPUNIT_FILETABS (cu);
+ COMPUNIT_FILETABS (cu) = main_symtab;
+ }
+ break;
+ }
+ prev_symtab = symtab;
+ }
+ gdb_assert (main_symtab == COMPUNIT_FILETABS (cu));
+ }
- /* Similarly for the producer. */
- symtab->producer = subfile->producer;
+ /* Fill out the primary symtab. */
- /* All symtabs for the main file and the subfiles share a
- blockvector, so we need to clear primary for everything
- but the main file. */
- set_symtab_primary (symtab, 0);
+ if (buildsym_compunit->comp_dir != NULL)
+ {
+ /* Reallocate the dirname on the symbol obstack. */
+ COMPUNIT_DIRNAME (cu)
+ = obstack_copy0 (&objfile->objfile_obstack,
+ buildsym_compunit->comp_dir,
+ strlen (buildsym_compunit->comp_dir));
}
- /* The main source file is the primary symtab. */
- gdb_assert (main_subfile->symtab != NULL);
- symtab = main_subfile->symtab;
- set_symtab_primary (symtab, 1);
+ /* Save the debug format string (if any) in the symtab. */
+ COMPUNIT_DEBUGFORMAT (cu) = buildsym_compunit->debugformat;
+
+ /* Similarly for the producer. */
+ COMPUNIT_PRODUCER (cu) = buildsym_compunit->producer;
+
+ COMPUNIT_BLOCKVECTOR (cu) = blockvector;
{
- struct block *b = BLOCKVECTOR_BLOCK (symtab->blockvector, GLOBAL_BLOCK);
+ struct block *b = BLOCKVECTOR_BLOCK (blockvector, GLOBAL_BLOCK);
- set_block_symtab (b, symtab);
+ set_block_compunit_symtab (b, cu);
}
+ COMPUNIT_BLOCK_LINE_SECTION (cu) = section;
+
+ COMPUNIT_MACRO_TABLE (cu) = pending_macros;
+
/* Default any symbols without a specified symtab to the primary symtab. */
{
int block_i;
+ /* The main source file's symtab. */
+ symtab = COMPUNIT_FILETABS (cu);
+
for (block_i = 0; block_i < BLOCKVECTOR_NBLOCKS (blockvector); block_i++)
{
struct block *block = BLOCKVECTOR_BLOCK (blockvector, block_i);
}
}
- return symtab;
+ add_compunit_symtab_to_objfile (cu);
+ free_buildsym_compunit ();
+
+ return cu;
}
/* Implementation of the second part of end_symtab. Pass STATIC_BLOCK
If EXPANDABLE is non-zero the GLOBAL_BLOCK dictionary is made
expandable. */
-struct symtab *
+struct compunit_symtab *
end_symtab_from_static_block (struct block *static_block,
int section, int expandable)
{
- struct symtab *s;
+ struct compunit_symtab *cu;
if (static_block == NULL)
{
end_symtab_without_blockvector ();
- s = NULL;
+ cu = NULL;
}
else
- s = end_symtab_with_blockvector (static_block, section, expandable);
+ cu = end_symtab_with_blockvector (static_block, section, expandable);
reset_symtab_globals ();
- return s;
+ return cu;
}
/* Finish the symbol definitions for one main source file, close off
call end_symtab_get_static_block and end_symtab_from_static_block
yourself. */
-struct symtab *
+struct compunit_symtab *
end_symtab (CORE_ADDR end_addr, int section)
{
struct block *static_block;
/* Same as end_symtab except create a symtab that can be later added to. */
-struct symtab *
+struct compunit_symtab *
end_expandable_symtab (CORE_ADDR end_addr, int section)
{
struct block *static_block;
}
/* Subroutine of augment_type_symtab to simplify it.
- Attach SYMTAB to all symbols in PENDING_LIST that don't have one. */
+ Attach the main source file's symtab to all symbols in PENDING_LIST that
+ don't have one. */
static void
-set_missing_symtab (struct pending *pending_list, struct symtab *symtab)
+set_missing_symtab (struct pending *pending_list,
+ struct compunit_symtab *cu)
{
struct pending *pending;
int i;
for (i = 0; i < pending->nsyms; ++i)
{
if (SYMBOL_SYMTAB (pending->symbol[i]) == NULL)
- SYMBOL_SYMTAB (pending->symbol[i]) = symtab;
+ SYMBOL_SYMTAB (pending->symbol[i]) = COMPUNIT_FILETABS (cu);
}
}
}
This is the case for DWARF4 Type Units. */
void
-augment_type_symtab (struct symtab *primary_symtab)
+augment_type_symtab (struct compunit_symtab *cust)
{
- const struct blockvector *blockvector = primary_symtab->blockvector;
+ const struct blockvector *blockvector = COMPUNIT_BLOCKVECTOR (cust);
if (context_stack_depth > 0)
{
/* First mark any symbols without a specified symtab as belonging
to the primary symtab. */
- set_missing_symtab (file_symbols, primary_symtab);
+ set_missing_symtab (file_symbols, cust);
dict_add_pending (BLOCK_DICT (block), file_symbols);
}
/* First mark any symbols without a specified symtab as belonging
to the primary symtab. */
- set_missing_symtab (global_symbols, primary_symtab);
+ set_missing_symtab (global_symbols, cust);
dict_add_pending (BLOCK_DICT (block), global_symbols);
}
void
record_debugformat (const char *format)
{
- current_subfile->debugformat = format;
+ buildsym_compunit->debugformat = format;
}
void
record_producer (const char *producer)
{
- current_subfile->producer = producer;
+ buildsym_compunit->producer = producer;
}
/* Merge the first symbol list SRCLIST into the second symbol list
struct objfile;
struct symbol;
struct addrmap;
+struct compunit_symtab;
/* This module provides definitions used for creating and adding to
the symbol table. These routines are called from various symbol-
and associated info, but they all share one blockvector. */
struct subfile
- {
- struct subfile *next;
- char *name;
- char *dirname;
- struct linetable *line_vector;
- int line_vector_length;
- enum language language;
- const char *producer;
- const char *debugformat;
- struct symtab *symtab;
- };
+{
+ struct subfile *next;
+ /* Space for this is malloc'd. */
+ char *name;
+ /* Space for this is malloc'd. */
+ struct linetable *line_vector;
+ int line_vector_length;
+ /* The "containing" compunit. */
+ struct buildsym_compunit *buildsym_compunit;
+ enum language language;
+ struct symtab *symtab;
+};
EXTERN struct subfile *current_subfile;
int expandable,
int required);
-extern struct symtab *end_symtab_from_static_block (struct block *static_block,
- int section,
- int expandable);
+extern struct compunit_symtab *
+ end_symtab_from_static_block (struct block *static_block,
+ int section, int expandable);
-extern struct symtab *end_symtab (CORE_ADDR end_addr, int section);
+extern struct compunit_symtab *end_symtab (CORE_ADDR end_addr, int section);
-extern struct symtab *end_expandable_symtab (CORE_ADDR end_addr,
- int section);
+extern struct compunit_symtab *end_expandable_symtab (CORE_ADDR end_addr,
+ int section);
-extern void augment_type_symtab (struct symtab *primary_symtab);
+extern void augment_type_symtab (struct compunit_symtab *cust);
/* Defined in stabsread.c. */
extern record_line_ftype record_line;
-extern void start_symtab (struct objfile *objfile,
- const char *name, const char *dirname,
- CORE_ADDR start_addr);
+extern struct compunit_symtab *start_symtab (struct objfile *objfile,
+ const char *name,
+ const char *comp_dir,
+ CORE_ADDR start_addr);
extern void restart_symtab (CORE_ADDR start_addr);
extern const char *get_last_source_file (void);
-/* Return the macro table. */
+/* Return the compunit symtab object.
+ It is only valid to call this between calls to start_symtab and the
+ end_symtab* functions. */
+
+extern struct compunit_symtab *buildsym_compunit_symtab (void);
+
+/* Return the macro table.
+ Initialize it if this is the first use.
+ It is only valid to call this between calls to start_symtab and the
+ end_symtab* functions. */
-extern struct macro_table *get_macro_table (const char *comp_dir);
+extern struct macro_table *get_macro_table (void);
#undef EXTERN
struct coff_symbol fcn_cs_saved;
static struct internal_syment fcn_sym_saved;
static union internal_auxent fcn_aux_saved;
- struct symtab *s;
/* A .file is open. */
int in_source_file = 0;
int next_file_symnum = -1;
/* Patch up any opaque types (references to types that are not defined
in the file where they are referenced, e.g. "struct foo *bar"). */
- ALL_OBJFILE_SYMTABS (objfile, s)
- patch_opaque_types (s);
+ {
+ struct compunit_symtab *cu;
+ struct symtab *s;
+
+ ALL_OBJFILE_FILETABS (objfile, cu, s)
+ patch_opaque_types (s);
+ }
coffread_objfile = NULL;
}
static void
make_symbol_overload_list_qualified (const char *func_name)
{
- struct symtab *s;
+ struct compunit_symtab *cust;
struct objfile *objfile;
const struct block *b, *surrounding_static_block = 0;
/* 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);
make_symbol_overload_list_block (func_name, b);
}
- 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);
/* Don't do this block twice. */
if (b == surrounding_static_block)
continue;
subpst->n_static_syms = 0;
subpst->readin = 0;
- subpst->symtab = 0;
+ subpst->compunit_symtab = 0;
subpst->read_symtab = pst->read_symtab;
}
if (last_source_start_addr > text_offset)
last_source_start_addr = text_offset;
- pst->symtab = end_symtab (text_offset + text_size,
- SECT_OFF_TEXT (objfile));
+ pst->compunit_symtab = end_symtab (text_offset + text_size,
+ SECT_OFF_TEXT (objfile));
end_stabs ();
dwarf2_frame_find_quirks (struct dwarf2_frame_state *fs,
struct dwarf2_fde *fde)
{
- struct symtab *s;
+ struct compunit_symtab *cust;
- s = find_pc_symtab (fs->pc);
- if (s == NULL)
+ cust = find_pc_compunit_symtab (fs->pc);
+ if (cust == NULL)
return;
- if (producer_is_realview (s->producer))
+ if (producer_is_realview (COMPUNIT_PRODUCER (cust)))
{
if (fde->cie->version == 1)
fs->armcc_cfa_offsets_sf = 1;
and is deleted afterwards and not used again. */
VEC (sig_type_ptr) *tus;
- /* The primary symtab.
+ /* The compunit symtab.
Type units in a group needn't all be defined in the same source file,
- so we create an essentially anonymous symtab as the primary symtab. */
- struct symtab *primary_symtab;
+ so we create an essentially anonymous symtab as the compunit symtab. */
+ struct compunit_symtab *compunit_symtab;
/* The data used to construct the hash key. */
struct stmt_list_hash hash;
static void dwarf2_start_subfile (const char *, const char *);
-static void dwarf2_start_symtab (struct dwarf2_cu *,
- const char *, const char *, CORE_ADDR);
+static struct compunit_symtab *dwarf2_start_symtab (struct dwarf2_cu *,
+ const char *, const char *,
+ CORE_ADDR);
static struct symbol *new_symbol (struct die_info *, struct type *,
struct dwarf2_cu *);
static struct die_info *dwarf_alloc_die (struct dwarf2_cu *, int);
-static void dwarf_decode_macros (struct dwarf2_cu *, unsigned int,
- const char *, int);
+static void dwarf_decode_macros (struct dwarf2_cu *, unsigned int, int);
static int attr_form_is_block (const struct attribute *);
/* The corresponding symbol table. This is NULL if symbols for this
CU have not yet been read. */
- struct symtab *symtab;
+ struct compunit_symtab *compunit_symtab;
/* A temporary mark bit used when iterating over all CUs in
expand_symtabs_matching. */
back_to = make_cleanup (dwarf2_release_queue, NULL);
if (dwarf2_per_objfile->using_index
- ? per_cu->v.quick->symtab == NULL
+ ? per_cu->v.quick->compunit_symtab == NULL
: (per_cu->v.psymtab == NULL || !per_cu->v.psymtab->readin))
{
queue_comp_unit (per_cu, language_minimal);
the objfile from which this CU came. Returns the resulting symbol
table. */
-static struct symtab *
+static struct compunit_symtab *
dw2_instantiate_symtab (struct dwarf2_per_cu_data *per_cu)
{
gdb_assert (dwarf2_per_objfile->using_index);
- if (!per_cu->v.quick->symtab)
+ if (!per_cu->v.quick->compunit_symtab)
{
struct cleanup *back_to = make_cleanup (free_cached_comp_units, NULL);
increment_reading_symtab ();
do_cleanups (back_to);
}
- /* The result of symtab expansion is always the primary symtab. */
- gdb_assert (per_cu->v.quick->symtab->primary);
-
- return per_cu->v.quick->symtab;
+ return per_cu->v.quick->compunit_symtab;
}
/* Return the CU/TU given its index.
static struct symtab *
dw2_find_last_source_symtab (struct objfile *objfile)
{
+ struct compunit_symtab *cust;
int index;
dw2_setup (objfile);
index = dwarf2_per_objfile->n_comp_units - 1;
- return dw2_instantiate_symtab (dw2_get_cutu (index));
+ cust = dw2_instantiate_symtab (dw2_get_cutu (index));
+ if (cust == NULL)
+ return NULL;
+ return compunit_primary_filetab (cust);
}
/* Traversal function for dw2_forget_cached_source_info. */
int (*callback) (struct symtab *, void *),
void *data)
{
- struct symtab *last_made = objfile->symtabs;
+ struct compunit_symtab *last_made = objfile->compunit_symtabs;
/* Don't visit already-expanded CUs. */
- if (per_cu->v.quick->symtab)
+ if (per_cu->v.quick->compunit_symtab)
return 0;
/* This may expand more than one symtab, and we want to iterate over
dw2_instantiate_symtab (per_cu);
return iterate_over_some_symtabs (name, real_path, callback, data,
- objfile->symtabs, last_made);
+ objfile->compunit_symtabs, last_made);
}
/* Implementation of the map_symtabs_matching_filename method. */
struct quick_file_names *file_data;
/* We only need to look at symtabs not already expanded. */
- if (per_cu->v.quick->symtab)
+ if (per_cu->v.quick->compunit_symtab)
continue;
file_data = dw2_get_file_names (per_cu);
per_cu = dw2_get_cutu (cu_index);
/* Skip if already read in. */
- if (per_cu->v.quick->symtab)
+ if (per_cu->v.quick->compunit_symtab)
continue;
/* Check static vs global. */
return NULL;
}
-static struct symtab *
+static struct compunit_symtab *
dw2_lookup_symbol (struct objfile *objfile, int block_index,
const char *name, domain_enum domain)
{
- struct symtab *stab_best = NULL;
+ struct compunit_symtab *stab_best = NULL;
struct mapped_index *index;
dw2_setup (objfile);
while ((per_cu = dw2_symtab_iter_next (&iter)) != NULL)
{
struct symbol *sym = NULL;
- struct symtab *stab = dw2_instantiate_symtab (per_cu);
- const struct blockvector *bv = SYMTAB_BLOCKVECTOR (stab);
+ struct compunit_symtab *stab = dw2_instantiate_symtab (per_cu);
+ const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (stab);
struct block *block = BLOCKVECTOR_BLOCK (bv, block_index);
/* Some caution must be observed with overloaded functions
{
struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i);
- if (!per_cu->v.quick->symtab)
+ if (!per_cu->v.quick->compunit_symtab)
++count;
}
printf_filtered (_(" Number of read CUs: %d\n"), total - count);
struct quick_file_names *file_data;
/* We only need to look at symtabs not already expanded. */
- if (per_cu->v.quick->symtab)
+ if (per_cu->v.quick->compunit_symtab)
continue;
file_data = dw2_get_file_names (per_cu);
per_cu->v.quick->mark = 0;
/* We only need to look at symtabs not already expanded. */
- if (per_cu->v.quick->symtab)
+ if (per_cu->v.quick->compunit_symtab)
continue;
file_data = dw2_get_file_names (per_cu);
}
}
-/* A helper for dw2_find_pc_sect_symtab which finds the most specific
+/* A helper for dw2_find_pc_sect_compunit_symtab which finds the most specific
symtab. */
-static struct symtab *
-recursively_find_pc_sect_symtab (struct symtab *symtab, CORE_ADDR pc)
+static struct compunit_symtab *
+recursively_find_pc_sect_compunit_symtab (struct compunit_symtab *cust,
+ CORE_ADDR pc)
{
int i;
- if (SYMTAB_BLOCKVECTOR (symtab) != NULL
- && blockvector_contains_pc (SYMTAB_BLOCKVECTOR (symtab), pc))
- return symtab;
+ if (COMPUNIT_BLOCKVECTOR (cust) != NULL
+ && blockvector_contains_pc (COMPUNIT_BLOCKVECTOR (cust), pc))
+ return cust;
- if (symtab->includes == NULL)
+ if (cust->includes == NULL)
return NULL;
- for (i = 0; symtab->includes[i]; ++i)
+ for (i = 0; cust->includes[i]; ++i)
{
- struct symtab *s = symtab->includes[i];
+ struct compunit_symtab *s = cust->includes[i];
- s = recursively_find_pc_sect_symtab (s, pc);
+ s = recursively_find_pc_sect_compunit_symtab (s, pc);
if (s != NULL)
return s;
}
return NULL;
}
-static struct symtab *
-dw2_find_pc_sect_symtab (struct objfile *objfile,
- struct bound_minimal_symbol msymbol,
- CORE_ADDR pc,
- struct obj_section *section,
- int warn_if_readin)
+static struct compunit_symtab *
+dw2_find_pc_sect_compunit_symtab (struct objfile *objfile,
+ struct bound_minimal_symbol msymbol,
+ CORE_ADDR pc,
+ struct obj_section *section,
+ int warn_if_readin)
{
struct dwarf2_per_cu_data *data;
- struct symtab *result;
+ struct compunit_symtab *result;
dw2_setup (objfile);
if (!data)
return NULL;
- if (warn_if_readin && data->v.quick->symtab)
+ if (warn_if_readin && data->v.quick->compunit_symtab)
warning (_("(Internal error: pc %s in read in CU, but not in symtab.)"),
paddress (get_objfile_arch (objfile), pc));
- result = recursively_find_pc_sect_symtab (dw2_instantiate_symtab (data), pc);
+ result
+ = recursively_find_pc_sect_compunit_symtab (dw2_instantiate_symtab (data),
+ pc);
gdb_assert (result != NULL);
return result;
}
{
struct dwarf2_per_cu_data *per_cu = dw2_get_cutu (i);
- if (per_cu->v.quick->symtab)
+ if (per_cu->v.quick->compunit_symtab)
{
void **slot = htab_find_slot (visited, per_cu->v.quick->file_names,
INSERT);
void **slot;
/* We only need to look at symtabs not already expanded. */
- if (per_cu->v.quick->symtab)
+ if (per_cu->v.quick->compunit_symtab)
continue;
file_data = dw2_get_file_names (per_cu);
dw2_expand_symtabs_with_fullname,
dw2_map_matching_symbols,
dw2_expand_symtabs_matching,
- dw2_find_pc_sect_symtab,
+ dw2_find_pc_sect_compunit_symtab,
dw2_map_symbol_filenames
};
subpst->n_global_syms = 0;
subpst->statics_offset = 0;
subpst->n_static_syms = 0;
- subpst->symtab = NULL;
+ subpst->compunit_symtab = NULL;
subpst->read_symtab = pst->read_symtab;
subpst->readin = 0;
if (dwarf2_per_objfile->using_index)
{
gdb_assert (sig_entry->per_cu.v.quick != NULL);
- gdb_assert (sig_entry->per_cu.v.quick->symtab == NULL);
+ gdb_assert (sig_entry->per_cu.v.quick->compunit_symtab == NULL);
}
else
gdb_assert (sig_entry->per_cu.v.psymtab == NULL);
for (item = dwarf2_queue; item != NULL; dwarf2_queue = item = next_item)
{
if (dwarf2_per_objfile->using_index
- ? !item->per_cu->v.quick->symtab
+ ? !item->per_cu->v.quick->compunit_symtab
: (item->per_cu->v.psymtab && !item->per_cu->v.psymtab->readin))
{
struct dwarf2_per_cu_data *per_cu = item->per_cu;
/* Return the symtab for PER_CU. This works properly regardless of
whether we're using the index or psymtabs. */
-static struct symtab *
-get_symtab (struct dwarf2_per_cu_data *per_cu)
+static struct compunit_symtab *
+get_compunit_symtab (struct dwarf2_per_cu_data *per_cu)
{
return (dwarf2_per_objfile->using_index
- ? per_cu->v.quick->symtab
- : per_cu->v.psymtab->symtab);
+ ? per_cu->v.quick->compunit_symtab
+ : per_cu->v.psymtab->compunit_symtab);
}
/* A helper function for computing the list of all symbol tables
included by PER_CU. */
static void
-recursively_compute_inclusions (VEC (symtab_ptr) **result,
+recursively_compute_inclusions (VEC (compunit_symtab_ptr) **result,
htab_t all_children, htab_t all_type_symtabs,
struct dwarf2_per_cu_data *per_cu,
- struct symtab *immediate_parent)
+ struct compunit_symtab *immediate_parent)
{
void **slot;
int ix;
- struct symtab *symtab;
+ struct compunit_symtab *cust;
struct dwarf2_per_cu_data *iter;
slot = htab_find_slot (all_children, per_cu, INSERT);
*slot = per_cu;
/* Only add a CU if it has a symbol table. */
- symtab = get_symtab (per_cu);
- if (symtab != NULL)
+ cust = get_compunit_symtab (per_cu);
+ if (cust != NULL)
{
/* If this is a type unit only add its symbol table if we haven't
seen it yet (type unit per_cu's can share symtabs). */
if (per_cu->is_debug_types)
{
- slot = htab_find_slot (all_type_symtabs, symtab, INSERT);
+ slot = htab_find_slot (all_type_symtabs, cust, INSERT);
if (*slot == NULL)
{
- *slot = symtab;
- VEC_safe_push (symtab_ptr, *result, symtab);
- if (symtab->user == NULL)
- symtab->user = immediate_parent;
+ *slot = cust;
+ VEC_safe_push (compunit_symtab_ptr, *result, cust);
+ if (cust->user == NULL)
+ cust->user = immediate_parent;
}
}
else
{
- VEC_safe_push (symtab_ptr, *result, symtab);
- if (symtab->user == NULL)
- symtab->user = immediate_parent;
+ VEC_safe_push (compunit_symtab_ptr, *result, cust);
+ if (cust->user == NULL)
+ cust->user = immediate_parent;
}
}
++ix)
{
recursively_compute_inclusions (result, all_children,
- all_type_symtabs, iter, symtab);
+ all_type_symtabs, iter, cust);
}
}
-/* Compute the symtab 'includes' fields for the symtab related to
+/* Compute the compunit_symtab 'includes' fields for the compunit_symtab of
PER_CU. */
static void
-compute_symtab_includes (struct dwarf2_per_cu_data *per_cu)
+compute_compunit_symtab_includes (struct dwarf2_per_cu_data *per_cu)
{
gdb_assert (! per_cu->is_debug_types);
{
int ix, len;
struct dwarf2_per_cu_data *per_cu_iter;
- struct symtab *symtab_iter;
- VEC (symtab_ptr) *result_symtabs = NULL;
+ struct compunit_symtab *compunit_symtab_iter;
+ VEC (compunit_symtab_ptr) *result_symtabs = NULL;
htab_t all_children, all_type_symtabs;
- struct symtab *symtab = get_symtab (per_cu);
+ struct compunit_symtab *cust = get_compunit_symtab (per_cu);
/* If we don't have a symtab, we can just skip this case. */
- if (symtab == NULL)
+ if (cust == NULL)
return;
all_children = htab_create_alloc (1, htab_hash_pointer, htab_eq_pointer,
{
recursively_compute_inclusions (&result_symtabs, all_children,
all_type_symtabs, per_cu_iter,
- symtab);
+ cust);
}
/* Now we have a transitive closure of all the included symtabs. */
- len = VEC_length (symtab_ptr, result_symtabs);
- symtab->includes
+ len = VEC_length (compunit_symtab_ptr, result_symtabs);
+ cust->includes
= obstack_alloc (&dwarf2_per_objfile->objfile->objfile_obstack,
(len + 1) * sizeof (struct symtab *));
for (ix = 0;
- VEC_iterate (symtab_ptr, result_symtabs, ix, symtab_iter);
+ VEC_iterate (compunit_symtab_ptr, result_symtabs, ix,
+ compunit_symtab_iter);
++ix)
- symtab->includes[ix] = symtab_iter;
- symtab->includes[len] = NULL;
+ cust->includes[ix] = compunit_symtab_iter;
+ cust->includes[len] = NULL;
- VEC_free (symtab_ptr, result_symtabs);
+ VEC_free (compunit_symtab_ptr, result_symtabs);
htab_delete (all_children);
htab_delete (all_type_symtabs);
}
++ix)
{
if (! iter->is_debug_types)
- compute_symtab_includes (iter);
+ compute_compunit_symtab_includes (iter);
}
VEC_free (dwarf2_per_cu_ptr, dwarf2_per_objfile->just_read_cus);
struct dwarf2_cu *cu = per_cu->cu;
struct objfile *objfile = per_cu->objfile;
CORE_ADDR lowpc, highpc;
- struct symtab *symtab;
+ struct compunit_symtab *cust;
struct cleanup *back_to, *delayed_list_cleanup;
CORE_ADDR baseaddr;
struct block *static_block;
this comp unit. */
dwarf2_record_block_ranges (cu->dies, static_block, baseaddr, cu);
- symtab = end_symtab_from_static_block (static_block,
- SECT_OFF_TEXT (objfile), 0);
+ cust = end_symtab_from_static_block (static_block,
+ SECT_OFF_TEXT (objfile), 0);
- if (symtab != NULL)
+ if (cust != NULL)
{
int gcc_4_minor = producer_is_gcc_ge_4 (cu->producer);
/* Set symtab language to language from DW_AT_language. If the
compilation is from a C file generated by language preprocessors, do
not set the language if it was already deduced by start_subfile. */
- if (!(cu->language == language_c && symtab->language != language_c))
- symtab->language = cu->language;
+ if (!(cu->language == language_c
+ && COMPUNIT_FILETABS (cust)->language != language_c))
+ COMPUNIT_FILETABS (cust)->language = cu->language;
/* GCC-4.0 has started to support -fvar-tracking. GCC-3.x still can
produce DW_AT_location with location lists but it can be possibly
options - this waits on GCC PR other/32998 (-frecord-gcc-switches).
*/
if (cu->has_loclist && gcc_4_minor >= 5)
- symtab->locations_valid = 1;
+ cust->locations_valid = 1;
if (gcc_4_minor >= 5)
- symtab->epilogue_unwind_valid = 1;
+ cust->epilogue_unwind_valid = 1;
- symtab->call_site_htab = cu->call_site_htab;
+ cust->call_site_htab = cu->call_site_htab;
}
if (dwarf2_per_objfile->using_index)
- per_cu->v.quick->symtab = symtab;
+ per_cu->v.quick->compunit_symtab = cust;
else
{
struct partial_symtab *pst = per_cu->v.psymtab;
- pst->symtab = symtab;
+ pst->compunit_symtab = cust;
pst->readin = 1;
}
{
struct dwarf2_cu *cu = per_cu->cu;
struct objfile *objfile = per_cu->objfile;
- struct symtab *symtab;
+ struct compunit_symtab *cust;
struct cleanup *back_to, *delayed_list_cleanup;
struct signatured_type *sig_type;
If this is the first TU to use this symtab, complete the construction
of it with end_expandable_symtab. Otherwise, complete the addition of
this TU's symbols to the existing symtab. */
- if (sig_type->type_unit_group->primary_symtab == NULL)
+ if (sig_type->type_unit_group->compunit_symtab == NULL)
{
- symtab = end_expandable_symtab (0, SECT_OFF_TEXT (objfile));
- sig_type->type_unit_group->primary_symtab = symtab;
+ cust = end_expandable_symtab (0, SECT_OFF_TEXT (objfile));
+ sig_type->type_unit_group->compunit_symtab = cust;
- if (symtab != NULL)
+ if (cust != NULL)
{
/* Set symtab language to language from DW_AT_language. If the
compilation is from a C file generated by language preprocessors,
do not set the language if it was already deduced by
start_subfile. */
- if (!(cu->language == language_c && symtab->language != language_c))
- symtab->language = cu->language;
+ if (!(cu->language == language_c
+ && COMPUNIT_FILETABS (cust)->language != language_c))
+ COMPUNIT_FILETABS (cust)->language = cu->language;
}
}
else
{
- augment_type_symtab (sig_type->type_unit_group->primary_symtab);
- symtab = sig_type->type_unit_group->primary_symtab;
+ augment_type_symtab (sig_type->type_unit_group->compunit_symtab);
+ cust = sig_type->type_unit_group->compunit_symtab;
}
if (dwarf2_per_objfile->using_index)
- per_cu->v.quick->symtab = symtab;
+ per_cu->v.quick->compunit_symtab = cust;
else
{
struct partial_symtab *pst = per_cu->v.psymtab;
- pst->symtab = symtab;
+ pst->compunit_symtab = cust;
pst->readin = 1;
}
complaint (&symfile_complaints,
_("CU refers to both DW_AT_GNU_macros and DW_AT_macro_info"));
- dwarf_decode_macros (cu, DW_UNSND (attr), comp_dir, 1);
+ dwarf_decode_macros (cu, DW_UNSND (attr), 1);
}
else
{
{
unsigned int macro_offset = DW_UNSND (attr);
- dwarf_decode_macros (cu, macro_offset, comp_dir, 0);
+ dwarf_decode_macros (cu, macro_offset, 0);
}
}
do it again, we could fake it and just recreate the part we need
(file name,index -> symtab mapping). If data shows this optimization
is useful we can do it then. */
- first_time = tu_group->primary_symtab == NULL;
+ first_time = tu_group->compunit_symtab == NULL;
/* We have to handle the case of both a missing DW_AT_stmt_list or bad
debug info. */
gdb_assert (tu_group->symtabs == NULL);
restart_symtab (0);
}
- /* Note: The primary symtab will get allocated at the end. */
+ /* Note: The compunit symtab will get allocated at the end. */
return;
}
if (first_time)
{
- dwarf2_start_symtab (cu, "", NULL, 0);
+ struct compunit_symtab *cust = dwarf2_start_symtab (cu, "", NULL, 0);
tu_group->num_symtabs = lh->num_file_names;
tu_group->symtabs = XNEWVEC (struct symtab *, lh->num_file_names);
dir = lh->include_dirs[fe->dir_index - 1];
dwarf2_start_subfile (fe->name, dir);
- /* Note: We don't have to watch for the main subfile here, type units
- don't have DW_AT_name. */
-
if (current_subfile->symtab == NULL)
{
/* NOTE: start_subfile will recognize when it's been passed
a file it has already seen. So we can't assume there's a
- simple mapping from lh->file_names to subfiles,
+ simple mapping from lh->file_names to subfiles, plus
lh->file_names may contain dups. */
- current_subfile->symtab = allocate_symtab (current_subfile->name,
- objfile);
+ current_subfile->symtab
+ = allocate_symtab (cust, current_subfile->name);
}
fe->symtab = current_subfile->symtab;
Process the line number information in LH. */
static void
-dwarf_decode_lines_1 (struct line_header *lh, const char *comp_dir,
- struct dwarf2_cu *cu, const int decode_for_pst_p,
- CORE_ADDR lowpc)
+dwarf_decode_lines_1 (struct line_header *lh, struct dwarf2_cu *cu,
+ const int decode_for_pst_p, CORE_ADDR lowpc)
{
const gdb_byte *line_ptr, *extended_end;
const gdb_byte *line_end;
{
struct objfile *objfile = cu->objfile;
const int decode_for_pst_p = (pst != NULL);
- struct subfile *first_subfile = current_subfile;
- dwarf_decode_lines_1 (lh, comp_dir, cu, decode_for_pst_p, lowpc);
+ dwarf_decode_lines_1 (lh, cu, decode_for_pst_p, lowpc);
if (decode_for_pst_p)
{
/* Make sure a symtab is created for every file, even files
which contain only variables (i.e. no code with associated
line numbers). */
+ struct compunit_symtab *cust = buildsym_compunit_symtab ();
int i;
for (i = 0; i < lh->num_file_names; i++)
dir = lh->include_dirs[fe->dir_index - 1];
dwarf2_start_subfile (fe->name, dir);
- /* Skip the main file; we don't need it, and it must be
- allocated last, so that it will show up before the
- non-primary symtabs in the objfile's symtab list. */
- if (current_subfile == first_subfile)
- continue;
-
if (current_subfile->symtab == NULL)
- current_subfile->symtab = allocate_symtab (current_subfile->name,
- objfile);
+ {
+ current_subfile->symtab
+ = allocate_symtab (cust, current_subfile->name);
+ }
fe->symtab = current_subfile->symtab;
}
}
/* Start a symtab for DWARF.
NAME, COMP_DIR, LOW_PC are passed to start_symtab. */
-static void
+static struct compunit_symtab *
dwarf2_start_symtab (struct dwarf2_cu *cu,
const char *name, const char *comp_dir, CORE_ADDR low_pc)
{
- start_symtab (dwarf2_per_objfile->objfile, name, comp_dir, low_pc);
+ struct compunit_symtab *cust
+ = start_symtab (cu->objfile, name, comp_dir, low_pc);
+
record_debugformat ("DWARF 2");
record_producer (cu->producer);
processing_gcc_compilation = 2;
cu->processing_has_namespace_info = 0;
+
+ return cust;
}
static void
static struct macro_source_file *
macro_start_file (int file, int line,
struct macro_source_file *current_file,
- const char *comp_dir,
- struct line_header *lh)
+ struct line_header *lh)
{
/* File name relative to the compilation directory of this source file. */
char *file_name = file_file_name (file, lh);
{
/* Note: We don't create a macro table for this compilation unit
at all until we actually get a filename. */
- struct macro_table *macro_table = get_macro_table (comp_dir);
+ struct macro_table *macro_table = get_macro_table ();
/* If we have no current file, then this must be the start_file
directive for the compilation unit's main source file. */
dwarf_decode_macro_bytes (bfd *abfd,
const gdb_byte *mac_ptr, const gdb_byte *mac_end,
struct macro_source_file *current_file,
- struct line_header *lh, const char *comp_dir,
+ struct line_header *lh,
struct dwarf2_section_info *section,
int section_is_gnu, int section_is_dwz,
unsigned int offset_size,
at_commandline = 0;
}
else
- current_file = macro_start_file (file, line, current_file,
- comp_dir, lh);
+ current_file = macro_start_file (file, line, current_file, lh);
}
break;
*slot = (void *) new_mac_ptr;
dwarf_decode_macro_bytes (include_bfd, new_mac_ptr,
- include_mac_end, current_file,
- lh, comp_dir,
+ include_mac_end, current_file, lh,
section, section_is_gnu, is_dwz,
offset_size, include_hash);
static void
dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
- const char *comp_dir, int section_is_gnu)
+ int section_is_gnu)
{
struct objfile *objfile = dwarf2_per_objfile->objfile;
struct line_header *lh = cu->line_header;
file = read_unsigned_leb128 (abfd, mac_ptr, &bytes_read);
mac_ptr += bytes_read;
- current_file = macro_start_file (file, line, current_file,
- comp_dir, lh);
+ current_file = macro_start_file (file, line, current_file, lh);
}
break;
slot = htab_find_slot (include_hash, mac_ptr, INSERT);
*slot = (void *) mac_ptr;
dwarf_decode_macro_bytes (abfd, mac_ptr, mac_end,
- current_file, lh, comp_dir, section,
+ current_file, lh, section,
section_is_gnu, 0, offset_size, include_hash);
do_cleanups (cleanup);
}
block. */
if (get_frame_address_in_block_if_available (fi, &pc))
{
- struct symtab *s = find_pc_symtab (pc);
+ struct compunit_symtab *cust = find_pc_compunit_symtab (pc);
- if (s
- && s->language != current_language->la_language
- && s->language != language_unknown
+ if (cust != NULL
+ && compunit_language (cust) != current_language->la_language
+ && compunit_language (cust) != language_unknown
&& language_mode == language_mode_auto)
- set_language (s->language);
+ set_language (compunit_language (cust));
}
}
}
case GLOBAL_BLOCK:
case STATIC_BLOCK:
{
- struct symtab *s;
+ struct compunit_symtab *cust;
gdbscm_printf (port, " %s",
i_smob->iter.which == GLOBAL_BLOCK
? "global" : "static");
if (i_smob->iter.idx != -1)
gdbscm_printf (port, " @%d", i_smob->iter.idx);
- s = (i_smob->iter.idx == -1
- ? i_smob->iter.d.symtab
- : i_smob->iter.d.symtab->includes[i_smob->iter.idx]);
- gdbscm_printf (port, " %s", symtab_to_filename_for_display (s));
+ cust = (i_smob->iter.idx == -1
+ ? i_smob->iter.d.compunit_symtab
+ : i_smob->iter.d.compunit_symtab->includes[i_smob->iter.idx]);
+ gdbscm_printf (port, " %s",
+ symtab_to_filename_for_display
+ (compunit_primary_filetab (cust)));
break;
}
case FIRST_LOCAL_BLOCK:
{
CORE_ADDR pc;
const struct block *block = NULL;
- struct obj_section *section = NULL;
- struct symtab *symtab = NULL;
+ struct compunit_symtab *cust = NULL;
volatile struct gdb_exception except;
gdbscm_parse_function_args (FUNC_NAME, SCM_ARG1, NULL, "U", pc_scm, &pc);
TRY_CATCH (except, RETURN_MASK_ALL)
{
- section = find_pc_mapped_section (pc);
- symtab = find_pc_sect_symtab (pc, section);
+ cust = find_pc_compunit_symtab (pc);
- if (symtab != NULL && SYMTAB_OBJFILE (symtab) != NULL)
+ if (cust != NULL && COMPUNIT_OBJFILE (cust) != NULL)
block = block_for_pc (pc);
}
GDBSCM_HANDLE_GDB_EXCEPTION (except);
- if (symtab == NULL || SYMTAB_OBJFILE (symtab) == NULL)
+ if (cust == NULL || COMPUNIT_OBJFILE (cust) == NULL)
{
gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG1, pc_scm,
_("cannot locate object file for block"));
}
if (block != NULL)
- return bkscm_scm_from_block (block, SYMTAB_OBJFILE (symtab));
+ return bkscm_scm_from_block (block, COMPUNIT_OBJFILE (cust));
return SCM_BOOL_F;
}
\f
{
CORE_ADDR post_prologue_pc
= skip_prologue_using_sal (gdbarch, func_addr);
- struct symtab *s = find_pc_symtab (func_addr);
+ struct compunit_symtab *cust = find_pc_compunit_symtab (func_addr);
/* Clang always emits a line note before the prologue and another
one after. We trust clang to emit usable line notes. */
if (post_prologue_pc
- && (s != NULL
- && s->producer != NULL
- && strncmp (s->producer, "clang ", sizeof ("clang ") - 1) == 0))
+ && (cust != NULL
+ && COMPUNIT_PRODUCER (cust) != NULL
+ && strncmp (COMPUNIT_PRODUCER (cust), "clang ",
+ sizeof ("clang ") - 1) == 0))
return max (start_pc, post_prologue_pc);
}
i386_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
gdb_byte insn;
- struct symtab *symtab;
+ struct compunit_symtab *cust;
- symtab = find_pc_symtab (pc);
- if (symtab && symtab->epilogue_unwind_valid)
+ cust = find_pc_compunit_symtab (pc);
+ if (cust != NULL && COMPUNIT_EPILOGUE_UNWIND_VALID (cust))
return 0;
if (target_read_memory (pc, &insn, 1))
handle_step_into_function (struct gdbarch *gdbarch,
struct execution_control_state *ecs)
{
- struct symtab *s;
+ struct compunit_symtab *cust;
struct symtab_and_line stop_func_sal, sr_sal;
fill_in_stop_func (gdbarch, ecs);
- s = find_pc_symtab (stop_pc);
- if (s && s->language != language_asm)
+ cust = find_pc_compunit_symtab (stop_pc);
+ if (cust != NULL && compunit_language (cust) != language_asm)
ecs->stop_func_start = gdbarch_skip_prologue (gdbarch,
ecs->stop_func_start);
handle_step_into_function_backward (struct gdbarch *gdbarch,
struct execution_control_state *ecs)
{
- struct symtab *s;
+ struct compunit_symtab *cust;
struct symtab_and_line stop_func_sal;
fill_in_stop_func (gdbarch, ecs);
- s = find_pc_symtab (stop_pc);
- if (s && s->language != language_asm)
+ cust = find_pc_compunit_symtab (stop_pc);
+ if (cust != NULL && compunit_language (cust) != language_asm)
ecs->stop_func_start = gdbarch_skip_prologue (gdbarch,
ecs->stop_func_start);
static void
finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
{
- struct symtab *symtab;
+ struct compunit_symtab *cust;
struct gdb_block *gdb_block_iter, *gdb_block_iter_tmp;
struct block *block_iter;
int actual_nblocks, i;
actual_nblocks = FIRST_LOCAL_BLOCK + stab->nblocks;
- symtab = allocate_symtab (stab->file_name, objfile);
+ cust = allocate_compunit_symtab (objfile, stab->file_name);
+ allocate_symtab (cust, stab->file_name);
+ add_compunit_symtab_to_objfile (cust);
+
/* JIT compilers compile in memory. */
- SYMTAB_DIRNAME (symtab) = NULL;
+ COMPUNIT_DIRNAME (cust) = NULL;
/* Copy over the linetable entry if one was provided. */
if (stab->linetable)
size_t size = ((stab->linetable->nitems - 1)
* sizeof (struct linetable_entry)
+ sizeof (struct linetable));
- SYMTAB_LINETABLE (symtab) = obstack_alloc (&objfile->objfile_obstack,
- size);
- memcpy (SYMTAB_LINETABLE (symtab), stab->linetable, size);
- }
- else
- {
- SYMTAB_LINETABLE (symtab) = NULL;
+ SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust))
+ = obstack_alloc (&objfile->objfile_obstack, size);
+ memcpy (SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust)), stab->linetable,
+ size);
}
blockvector_size = (sizeof (struct blockvector)
+ (actual_nblocks - 1) * sizeof (struct block *));
bv = obstack_alloc (&objfile->objfile_obstack, blockvector_size);
- symtab->blockvector = bv;
+ COMPUNIT_BLOCKVECTOR (cust) = bv;
/* (begin, end) will contain the PC range this entire blockvector
spans. */
- set_symtab_primary (symtab, 1);
BLOCKVECTOR_MAP (bv) = NULL;
begin = stab->blocks->begin;
end = stab->blocks->end;
/* The name. */
SYMBOL_DOMAIN (block_name) = VAR_DOMAIN;
SYMBOL_ACLASS_INDEX (block_name) = LOC_BLOCK;
- SYMBOL_SYMTAB (block_name) = symtab;
+ SYMBOL_SYMTAB (block_name) = COMPUNIT_FILETABS (cust);
SYMBOL_TYPE (block_name) = lookup_function_type (block_type);
SYMBOL_BLOCK_VALUE (block_name) = new_block;
BLOCKVECTOR_BLOCK (bv, i) = new_block;
if (i == GLOBAL_BLOCK)
- set_block_symtab (new_block, symtab);
+ set_block_compunit_symtab (new_block, cust);
}
/* Fill up the superblock fields for the real blocks, using the
static int java_demangled_signature_length (const char *);
static void java_demangled_signature_copy (char *, const char *);
-static struct symtab *get_java_class_symtab (struct gdbarch *gdbarch);
+static struct compunit_symtab *get_java_class_symtab (struct gdbarch *gdbarch);
static char *get_java_utf8_name (struct obstack *obstack, struct value *name);
static int java_class_is_primitive (struct value *clas);
static struct value *java_value_string (char *ptr, int len);
return dynamics_objfile;
}
-static struct symtab *
+static struct compunit_symtab *
get_java_class_symtab (struct gdbarch *gdbarch)
{
struct objfile *objfile = get_dynamics_objfile (gdbarch);
- struct symtab *class_symtab = objfile->symtabs;
+ struct compunit_symtab *class_symtab = objfile->compunit_symtabs;
if (class_symtab == NULL)
{
struct block *bl;
struct jv_per_objfile_data *jv_data;
- class_symtab = allocate_symtab ("<java-classes>", objfile);
- class_symtab->language = language_java;
+ class_symtab = allocate_compunit_symtab (objfile, "<java-classes>");
+ add_compunit_symtab_to_objfile (class_symtab);
+ allocate_symtab (class_symtab, "<java-classes>");
+
+ COMPUNIT_FILETABS (class_symtab)->language = language_java;
bv = (struct blockvector *)
obstack_alloc (&objfile->objfile_obstack,
sizeof (struct blockvector) + sizeof (struct block *));
BLOCKVECTOR_NBLOCKS (bv) = 1;
- SYMTAB_BLOCKVECTOR (class_symtab) = bv;
+ COMPUNIT_BLOCKVECTOR (class_symtab) = bv;
/* Allocate dummy STATIC_BLOCK. */
bl = allocate_block (&objfile->objfile_obstack);
/* Allocate GLOBAL_BLOCK. */
bl = allocate_global_block (&objfile->objfile_obstack);
BLOCK_DICT (bl) = dict_create_hashed_expandable ();
- set_block_symtab (bl, class_symtab);
+ set_block_compunit_symtab (bl, class_symtab);
BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = bl;
/* Arrange to free the dict. */
static void
add_class_symtab_symbol (struct symbol *sym)
{
- struct symtab *symtab
+ struct compunit_symtab *cust
= get_java_class_symtab (get_objfile_arch (SYMBOL_OBJFILE (sym)));
- const struct blockvector *bv = SYMTAB_BLOCKVECTOR (symtab);
+ const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
dict_add_symbol (BLOCK_DICT (BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK)), sym);
}
ALL_OBJFILES (objfile)
{
- struct symtab *symtab;
+ struct compunit_symtab *cu;
if (objfile->sf)
objfile->sf->qf->expand_symtabs_matching (objfile, NULL,
ALL_DOMAIN,
&matcher_data);
- ALL_OBJFILE_PRIMARY_SYMTABS (objfile, symtab)
+ ALL_OBJFILE_COMPUNITS (objfile, cu)
{
+ struct symtab *symtab = COMPUNIT_FILETABS (cu);
+
iterate_over_file_blocks (symtab, name, domain, callback, data);
if (include_inline)
{
struct macro_source_file *main_file, *inclusion;
struct macro_scope *ms;
+ struct compunit_symtab *cust;
- if (! sal.symtab
- || ! sal.symtab->macro_table)
- return 0;
+ if (sal.symtab == NULL)
+ return NULL;
+ cust = SYMTAB_COMPUNIT (sal.symtab);
+ if (COMPUNIT_MACRO_TABLE (cust) == NULL)
+ return NULL;
ms = (struct macro_scope *) xmalloc (sizeof (*ms));
- main_file = macro_main (sal.symtab->macro_table);
+ main_file = macro_main (COMPUNIT_MACRO_TABLE (cust));
inclusion = macro_lookup_inclusion (main_file, sal.symtab->filename);
if (inclusion)
#inclusion tree; everything else is #included from here. */
struct macro_source_file *main_source;
- /* Compilation directory for all files of this macro table. It is allocated
- on objfile's obstack. */
- const char *comp_dir;
+ /* Backlink to containing compilation unit, or NULL if there isn't one. */
+ struct compunit_symtab *compunit_symtab;
/* True if macros in this table can be redefined without issuing an
error. */
struct macro_table *
new_macro_table (struct obstack *obstack, struct bcache *b,
- const char *comp_dir)
+ struct compunit_symtab *cust)
{
struct macro_table *t;
t->obstack = obstack;
t->bcache = b;
t->main_source = NULL;
- t->comp_dir = comp_dir;
+ t->compunit_symtab = cust;
t->redef_ok = 0;
t->definitions = (splay_tree_new_with_allocator
(macro_tree_compare,
char *
macro_source_fullname (struct macro_source_file *file)
{
- if (file->table->comp_dir == NULL || IS_ABSOLUTE_PATH (file->filename))
+ const char *comp_dir = NULL;
+
+ if (file->table->compunit_symtab != NULL)
+ comp_dir = COMPUNIT_DIRNAME (file->table->compunit_symtab);
+
+ if (comp_dir == NULL || IS_ABSOLUTE_PATH (file->filename))
return xstrdup (file->filename);
- return concat (file->table->comp_dir, SLASH_STRING, file->filename, NULL);
+ return concat (comp_dir, SLASH_STRING, file->filename, NULL);
}
struct obstack;
struct bcache;
+struct compunit_symtab;
/* How do we represent a source location? I mean, how should we
represent them within GDB; the user wants to use all sorts of
xmalloc if OBSTACK is zero. Use BCACHE to store all macro names,
arguments, definitions, and anything else that might be the same
amongst compilation units in an executable file; if BCACHE is zero,
- don't cache these things. COMP_DIR optionally contains the compilation
- directory of all files for this macro table.
+ don't cache these things. CUST is a pointer to the containing
+ compilation unit, or NULL if there isn't one.
Note that, if either OBSTACK or BCACHE are non-zero, then removing
information from the table may leak memory. Neither obstacks nor
do that in GCC 4.1.2.). */
struct macro_table *new_macro_table (struct obstack *obstack,
struct bcache *bcache,
- const char *comp_dir);
+ struct compunit_symtab *cust);
/* Free TABLE, and any macro definitions, source file structures,
long start_space;
/* Total number of symtabs (over all objfiles). */
int start_nr_symtabs;
- /* Of those, a count of just the primary ones. */
- int start_nr_primary_symtabs;
+ /* A count of the compunits. */
+ int start_nr_compunit_symtabs;
/* Total number of blocks. */
int start_nr_blocks;
};
/* Count the number of symtabs and blocks. */
static void
-count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_primary_symtabs_ptr,
+count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr,
int *nr_blocks_ptr)
{
struct objfile *o;
+ struct compunit_symtab *cu;
struct symtab *s;
int nr_symtabs = 0;
- int nr_primary_symtabs = 0;
+ int nr_compunit_symtabs = 0;
int nr_blocks = 0;
/* When collecting statistics during startup, this is called before
current_program_space may be NULL. */
if (current_program_space != NULL)
{
- ALL_SYMTABS (o, s)
+ ALL_COMPUNITS (o, cu)
{
- ++nr_symtabs;
- if (s->primary)
- {
- ++nr_primary_symtabs;
- nr_blocks += BLOCKVECTOR_NBLOCKS (SYMTAB_BLOCKVECTOR (s));
- }
+ ++nr_compunit_symtabs;
+ nr_blocks += BLOCKVECTOR_NBLOCKS (COMPUNIT_BLOCKVECTOR (cu));
+ ALL_COMPUNIT_FILETABS (cu, s)
+ ++nr_symtabs;
}
}
*nr_symtabs_ptr = nr_symtabs;
- *nr_primary_symtabs_ptr = nr_primary_symtabs;
+ *nr_compunit_symtabs_ptr = nr_compunit_symtabs;
*nr_blocks_ptr = nr_blocks;
}
if (start_stats->symtab_enabled && per_command_symtab)
{
- int nr_symtabs, nr_primary_symtabs, nr_blocks;
+ int nr_symtabs, nr_compunit_symtabs, nr_blocks;
- count_symtabs_and_blocks (&nr_symtabs, &nr_primary_symtabs, &nr_blocks);
+ count_symtabs_and_blocks (&nr_symtabs, &nr_compunit_symtabs, &nr_blocks);
printf_unfiltered (_("#symtabs: %d (+%d),"
- " #primary symtabs: %d (+%d),"
+ " #compunits: %d (+%d),"
" #blocks: %d (+%d)\n"),
nr_symtabs,
nr_symtabs - start_stats->start_nr_symtabs,
- nr_primary_symtabs,
- nr_primary_symtabs - start_stats->start_nr_primary_symtabs,
+ nr_compunit_symtabs,
+ (nr_compunit_symtabs
+ - start_stats->start_nr_compunit_symtabs),
nr_blocks,
nr_blocks - start_stats->start_nr_blocks);
}
if (msg_type == 0 || per_command_symtab)
{
- int nr_symtabs, nr_primary_symtabs, nr_blocks;
+ int nr_symtabs, nr_compunit_symtabs, nr_blocks;
- count_symtabs_and_blocks (&nr_symtabs, &nr_primary_symtabs, &nr_blocks);
+ count_symtabs_and_blocks (&nr_symtabs, &nr_compunit_symtabs, &nr_blocks);
new_stat->start_nr_symtabs = nr_symtabs;
- new_stat->start_nr_primary_symtabs = nr_primary_symtabs;
+ new_stat->start_nr_compunit_symtabs = nr_compunit_symtabs;
new_stat->start_nr_blocks = nr_blocks;
new_stat->symtab_enabled = 1;
}
static struct block *new_block (enum block_type);
-static struct symtab *new_symtab (const char *, int, struct objfile *);
+static struct compunit_symtab *new_symtab (const char *, int, struct objfile *);
static struct linetable *new_linetable (int);
in question, or NULL to use top_stack->cur_block. */
static void
-parse_procedure (PDR *pr, struct symtab *search_symtab,
+parse_procedure (PDR *pr, struct compunit_symtab *search_symtab,
struct partial_symtab *pst)
{
struct symbol *s, *i;
#else
s = mylookup_symbol
(sh_name,
- BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (search_symtab), STATIC_BLOCK),
+ BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (search_symtab),
+ STATIC_BLOCK),
VAR_DOMAIN,
LOC_BLOCK);
#endif
void (*swap_sym_in) (bfd *, void *, SYMR *);
void (*swap_pdr_in) (bfd *, void *, PDR *);
int i;
- struct symtab *st = NULL;
+ struct compunit_symtab *cust = NULL;
FDR *fh;
struct linetable *lines;
CORE_ADDR lowest_pdr_addr = 0;
valu += ANOFFSET (pst->section_offsets,
SECT_OFF_TEXT (objfile));
previous_stab_code = N_SO;
- st = end_symtab (valu, SECT_OFF_TEXT (objfile));
+ cust = end_symtab (valu, SECT_OFF_TEXT (objfile));
end_stabs ();
last_symtab_ended = 1;
}
if (! last_symtab_ended)
{
- st = end_symtab (pst->texthigh, SECT_OFF_TEXT (objfile));
+ cust = end_symtab (pst->texthigh, SECT_OFF_TEXT (objfile));
end_stabs ();
}
pdr_in = pr_block;
pdr_in_end = pdr_in + fh->cpd;
for (; pdr_in < pdr_in_end; pdr_in++)
- parse_procedure (pdr_in, st, pst);
+ parse_procedure (pdr_in, cust, pst);
do_cleanups (old_chain);
}
if (fh == 0)
{
maxlines = 0;
- st = new_symtab ("unknown", 0, objfile);
+ cust = new_symtab ("unknown", 0, objfile);
}
else
{
maxlines = 2 * fh->cline;
- st = new_symtab (pst->filename, maxlines, objfile);
+ cust = new_symtab (pst->filename, maxlines, objfile);
/* The proper language was already determined when building
the psymtab, use it. */
- st->language = PST_PRIVATE (pst)->pst_language;
+ COMPUNIT_FILETABS (cust)->language = PST_PRIVATE (pst)->pst_language;
}
- psymtab_language = st->language;
+ psymtab_language = COMPUNIT_FILETABS (cust)->language;
- lines = SYMTAB_LINETABLE (st);
+ lines = SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust));
/* Get a new lexical context. */
push_parse_stack ();
- top_stack->cur_st = st;
- top_stack->cur_block = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (st),
- STATIC_BLOCK);
+ top_stack->cur_st = COMPUNIT_FILETABS (cust);
+ top_stack->cur_block
+ = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), STATIC_BLOCK);
BLOCK_START (top_stack->cur_block) = pst->textlow;
BLOCK_END (top_stack->cur_block) = 0;
top_stack->blocktype = stFile;
pdr_in = pr_block;
pdr_in_end = pdr_in + fh->cpd;
for (; pdr_in < pdr_in_end; pdr_in++)
- parse_procedure (pdr_in, 0, pst);
+ parse_procedure (pdr_in, NULL, pst);
do_cleanups (old_chain);
}
size = lines->nitems;
if (size > 1)
--size;
- SYMTAB_LINETABLE (st)
+ SYMTAB_LINETABLE (COMPUNIT_FILETABS (cust))
= obstack_copy (&mdebugread_objfile->objfile_obstack,
lines,
(sizeof (struct linetable)
/* .. and our share of externals.
XXX use the global list to speed up things here. How?
FIXME, Maybe quit once we have found the right number of ext's? */
- top_stack->cur_st = st;
+ top_stack->cur_st = COMPUNIT_FILETABS (cust);
top_stack->cur_block
= BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (top_stack->cur_st),
GLOBAL_BLOCK);
if (info_verbose && n_undef_symbols)
{
printf_filtered (_("File %s contains %d unresolved references:"),
- symtab_to_filename_for_display (st),
+ symtab_to_filename_for_display
+ (COMPUNIT_FILETABS (cust)),
n_undef_symbols);
printf_filtered ("\n\t%4d variables\n\t%4d "
"procedures\n\t%4d labels\n",
}
pop_parse_stack ();
- set_symtab_primary (st, 1);
-
- sort_blocks (st);
+ sort_blocks (COMPUNIT_FILETABS (cust));
}
/* Now link the psymtab and the symtab. */
- pst->symtab = st;
+ pst->compunit_symtab = cust;
mdebugread_objfile = NULL;
}
/* Allocate a new symtab for NAME. Needs an estimate of how many
linenumbers MAXLINES we'll put in it. */
-static struct symtab *
+static struct compunit_symtab *
new_symtab (const char *name, int maxlines, struct objfile *objfile)
{
- struct symtab *s = allocate_symtab (name, objfile);
+ struct compunit_symtab *cust = allocate_compunit_symtab (objfile, name);
+ struct symtab *symtab;
struct blockvector *bv;
- SYMTAB_LINETABLE (s) = new_linetable (maxlines);
+ add_compunit_symtab_to_objfile (cust);
+ symtab = allocate_symtab (cust, name);
+
+ SYMTAB_LINETABLE (symtab) = new_linetable (maxlines);
/* All symtabs must have at least two blocks. */
bv = new_bvect (2);
BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = new_block (NON_FUNCTION_BLOCK);
BLOCK_SUPERBLOCK (BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK)) =
BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- SYMTAB_BLOCKVECTOR (s) = bv;
+ COMPUNIT_BLOCKVECTOR (cust) = bv;
- s->debugformat = "ECOFF";
- return (s);
+ COMPUNIT_DEBUGFORMAT (cust) = "ECOFF";
+ return cust;
}
/* Allocate a new partial_symtab NAME. */
ui_out_field_string (uiout, "fullname", symtab_to_fullname (st.symtab));
- ui_out_field_int (uiout, "macro-info", st.symtab->macro_table ? 1 : 0);
+ ui_out_field_int (uiout, "macro-info",
+ COMPUNIT_MACRO_TABLE
+ (SYMTAB_COMPUNIT (st.symtab)) != NULL);
}
/* A callback for map_partial_symbol_filenames. */
mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc)
{
struct ui_out *uiout = current_uiout;
+ struct compunit_symtab *cu;
struct symtab *s;
struct objfile *objfile;
/* Print the table header. */
ui_out_begin (uiout, ui_out_type_list, "files");
- /* Look at all of the symtabs. */
- ALL_SYMTABS (objfile, s)
+ /* Look at all of the file symtabs. */
+ ALL_FILETABS (objfile, cu, s)
{
ui_out_begin (uiout, ui_out_type_tuple, NULL);
/* OK, get all the symtabs. */
{
+ struct compunit_symtab *cust;
struct symtab *s;
- ALL_OBJFILE_SYMTABS (objfile, s)
+ ALL_OBJFILE_FILETABS (objfile, cust, s)
{
struct linetable *l;
- const struct blockvector *bv;
int i;
/* First the line table. */
if (l)
{
for (i = 0; i < l->nitems; ++i)
- l->item[i].pc += ANOFFSET (delta, s->block_line_section);
+ l->item[i].pc += ANOFFSET (delta,
+ COMPUNIT_BLOCK_LINE_SECTION
+ (cust));
}
+ }
- /* Don't relocate a shared blockvector more than once. */
- if (!s->primary)
- continue;
+ ALL_OBJFILE_COMPUNITS (objfile, cust)
+ {
+ const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
+ int block_line_section = COMPUNIT_BLOCK_LINE_SECTION (cust);
- bv = SYMTAB_BLOCKVECTOR (s);
if (BLOCKVECTOR_MAP (bv))
addrmap_relocate (BLOCKVECTOR_MAP (bv),
- ANOFFSET (delta, s->block_line_section));
+ ANOFFSET (delta, block_line_section));
for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); ++i)
{
struct dict_iterator iter;
b = BLOCKVECTOR_BLOCK (bv, i);
- BLOCK_START (b) += ANOFFSET (delta, s->block_line_section);
- BLOCK_END (b) += ANOFFSET (delta, s->block_line_section);
+ BLOCK_START (b) += ANOFFSET (delta, block_line_section);
+ BLOCK_END (b) += ANOFFSET (delta, block_line_section);
/* We only want to iterate over the local symbols, not any
symbols in included symtabs. */
int
objfile_has_full_symbols (struct objfile *objfile)
{
- return objfile->symtabs != NULL;
+ return objfile->compunit_symtabs != NULL;
}
/* Return non-zero if OBJFILE has full or partial symbols, either directly
struct bcache;
struct htab;
-struct symtab;
struct objfile_data;
/* This structure maintains information on a per-objfile basis about the
struct program_space *pspace;
- /* Each objfile points to a linked list of symtabs derived from this file,
- one symtab structure for each compilation unit (source file). Each link
- in the symtab list contains a backpointer to this objfile. */
+ /* List of compunits.
+ These are used to do symbol lookups and file/line-number lookups. */
- struct symtab *symtabs;
+ struct compunit_symtab *compunit_symtabs;
/* Each objfile points to a linked list of partial symtabs derived from
this file, one partial symtab structure for each compilation unit
/* Traverse all symtabs in one objfile. */
-#define ALL_OBJFILE_SYMTABS(objfile, s) \
- for ((s) = (objfile) -> symtabs; (s) != NULL; (s) = (s) -> next)
+#define ALL_OBJFILE_FILETABS(objfile, cu, s) \
+ ALL_OBJFILE_COMPUNITS (objfile, cu) \
+ ALL_COMPUNIT_FILETABS (cu, s)
-/* Traverse all primary symtabs in one objfile. */
+/* Traverse all compunits in one objfile. */
-#define ALL_OBJFILE_PRIMARY_SYMTABS(objfile, s) \
- ALL_OBJFILE_SYMTABS ((objfile), (s)) \
- if ((s)->primary)
+#define ALL_OBJFILE_COMPUNITS(objfile, cu) \
+ for ((cu) = (objfile) -> compunit_symtabs; (cu) != NULL; (cu) = (cu) -> next)
/* Traverse all minimal symbols in one objfile. */
/* Traverse all symtabs in all objfiles in the current symbol
space. */
-#define ALL_SYMTABS(objfile, s) \
- ALL_OBJFILES (objfile) \
- ALL_OBJFILE_SYMTABS (objfile, s)
+#define ALL_FILETABS(objfile, ps, s) \
+ ALL_OBJFILES (objfile) \
+ ALL_OBJFILE_FILETABS (objfile, ps, s)
-/* Traverse all symtabs in all objfiles in the current program space,
- skipping included files (which share a blockvector with their
- primary symtab). */
+/* Traverse all compunits in all objfiles in the current program space. */
-#define ALL_PRIMARY_SYMTABS(objfile, s) \
+#define ALL_COMPUNITS(objfile, cu) \
ALL_OBJFILES (objfile) \
- ALL_OBJFILE_PRIMARY_SYMTABS (objfile, s)
+ ALL_OBJFILE_COMPUNITS (objfile, cu)
/* Traverse all minimal symbols in all objfiles in the current symbol
space. */
ENUM_BITFIELD (psymtab_search_status) searched_flag : 2;
- /* Pointer to symtab eventually allocated for this source file, 0 if
+ /* Pointer to compunit eventually allocated for this source file, 0 if
!readin or if we haven't looked for the symtab after it was readin. */
- struct symtab *symtab;
+ struct compunit_symtab *compunit_symtab;
/* Pointer to function which will read in the symtab corresponding to
this psymtab. */
static void fixup_psymbol_section (struct partial_symbol *psym,
struct objfile *objfile);
-static struct symtab *psymtab_to_symtab (struct objfile *objfile,
- struct partial_symtab *pst);
+static struct compunit_symtab *psymtab_to_symtab (struct objfile *objfile,
+ struct partial_symtab *pst);
/* Ensure that the partial symbols for OBJFILE have been loaded. This
function always returns its argument, as a convenience. */
int (*callback) (struct symtab *, void *),
void *data)
{
- struct symtab *last_made = objfile->symtabs;
+ struct compunit_symtab *last_made = objfile->compunit_symtabs;
/* Shared psymtabs should never be seen here. Instead they should
be handled properly by the caller. */
psymtab_to_symtab (objfile, pst);
return iterate_over_some_symtabs (name, real_path, callback, data,
- objfile->symtabs, last_made);
+ objfile->compunit_symtabs, last_made);
}
/* Implementation of the map_symtabs_matching_filename method. */
return NULL;
}
-static struct symtab *
-find_pc_sect_symtab_from_partial (struct objfile *objfile,
- struct bound_minimal_symbol msymbol,
- CORE_ADDR pc, struct obj_section *section,
- int warn_if_readin)
+static struct compunit_symtab *
+find_pc_sect_compunit_symtab_from_partial (struct objfile *objfile,
+ struct bound_minimal_symbol msymbol,
+ CORE_ADDR pc,
+ struct obj_section *section,
+ int warn_if_readin)
{
struct partial_symtab *ps = find_pc_sect_psymtab (objfile, pc, section,
msymbol);
(Internal error: pc %s in read in psymtab, but not in symtab.)\n"),
paddress (get_objfile_arch (objfile), pc));
psymtab_to_symtab (objfile, ps);
- return ps->symtab;
+ return ps->compunit_symtab;
}
return NULL;
}
fixup_section (&psym->ginfo, addr, objfile);
}
-static struct symtab *
+static struct compunit_symtab *
lookup_symbol_aux_psymtabs (struct objfile *objfile,
int block_index, const char *name,
const domain_enum domain)
{
struct partial_symtab *ps;
const int psymtab_index = (block_index == GLOBAL_BLOCK ? 1 : 0);
- struct symtab *stab_best = NULL;
+ struct compunit_symtab *stab_best = NULL;
ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps)
{
psymtab_index, domain))
{
struct symbol *sym = NULL;
- struct symtab *stab = psymtab_to_symtab (objfile, ps);
+ struct compunit_symtab *stab = psymtab_to_symtab (objfile, ps);
/* Note: While psymtab_to_symtab can return NULL if the partial symtab
is empty, we can assume it won't here because lookup_partial_symbol
succeeded. */
- const struct blockvector *bv = SYMTAB_BLOCKVECTOR (stab);
+ const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (stab);
struct block *block = BLOCKVECTOR_BLOCK (bv, block_index);
/* Some caution must be observed with overloaded functions
which can happen. Otherwise the result is the primary symtab
that contains PST. */
-static struct symtab *
+static struct compunit_symtab *
psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
{
/* If it is a shared psymtab, find an unshared psymtab that includes
pst = pst->user;
/* If it's been looked up before, return it. */
- if (pst->symtab)
- return pst->symtab;
+ if (pst->compunit_symtab)
+ return pst->compunit_symtab;
/* If it has not yet been read in, read it. */
if (!pst->readin)
do_cleanups (back_to);
}
- if (pst->symtab != NULL)
- gdb_assert (pst->symtab->primary);
-
- return pst->symtab;
+ return pst->compunit_symtab;
}
static void
"readin pst found and no symtabs."));
}
else
- return psymtab_to_symtab (ofp, cs_pst);
+ {
+ struct compunit_symtab *cust = psymtab_to_symtab (ofp, cs_pst);
+
+ if (cust == NULL)
+ return NULL;
+ return compunit_primary_filetab (cust);
+ }
}
return NULL;
}
{
fprintf_filtered (outfile,
" Full symtab was read (at ");
- gdb_print_host_address (psymtab->symtab, outfile);
+ gdb_print_host_address (psymtab->compunit_symtab, outfile);
fprintf_filtered (outfile, " by function at ");
gdb_print_host_address (psymtab->read_symtab, outfile);
fprintf_filtered (outfile, ")\n");
|| match_partial_symbol (objfile, ps, global, name, namespace, match,
ordered_compare))
{
- struct symtab *s = psymtab_to_symtab (objfile, ps);
+ struct compunit_symtab *cust = psymtab_to_symtab (objfile, ps);
struct block *block;
- if (s == NULL)
+ if (cust == NULL)
continue;
- block = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (s), block_kind);
+ block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), block_kind);
if (map_block (name, namespace, objfile, block,
callback, data, match))
return;
read_psymtabs_with_fullname,
map_matching_symbols_psymtab,
expand_symtabs_matching_via_partial,
- find_pc_sect_symtab_from_partial,
+ find_pc_sect_compunit_symtab_from_partial,
map_symbol_filenames_psymtab
};
memset (psymtab, 0, sizeof (struct partial_symtab));
psymtab->filename = bcache (filename, strlen (filename) + 1,
objfile->per_bfd->filename_cache);
- psymtab->symtab = NULL;
+ psymtab->compunit_symtab = NULL;
/* Prepend it to the psymtab list for the objfile it belongs to.
Psymtabs are searched in most recent inserted -> least recent
{
struct symbol *sym;
struct partial_symbol **psym;
- struct symtab *s = NULL;
+ struct compunit_symtab *cust = NULL;
struct partial_symtab *ps;
const struct blockvector *bv;
struct objfile *objfile;
/* We don't call psymtab_to_symtab here because that may cause symtab
expansion. When debugging a problem it helps if checkers leave
things unchanged. */
- s = ps->symtab;
+ cust = ps->compunit_symtab;
/* First do some checks that don't require the associated symtab. */
if (ps->texthigh < ps->textlow)
}
/* Now do checks requiring the associated symtab. */
- if (s == NULL)
+ if (cust == NULL)
continue;
- bv = SYMTAB_BLOCKVECTOR (s);
+ bv = COMPUNIT_BLOCKVECTOR (cust);
b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
psym = objfile->static_psymbols.list + ps->statics_offset;
length = ps->n_static_syms;
{
gdb_py_ulongest pc;
const struct block *block = NULL;
- struct obj_section *section = NULL;
- struct symtab *symtab = NULL;
+ struct compunit_symtab *cust = NULL;
volatile struct gdb_exception except;
if (!PyArg_ParseTuple (args, GDB_PY_LLU_ARG, &pc))
TRY_CATCH (except, RETURN_MASK_ALL)
{
- section = find_pc_mapped_section (pc);
- symtab = find_pc_sect_symtab (pc, section);
+ cust = find_pc_compunit_symtab (pc);
- if (symtab != NULL && SYMTAB_OBJFILE (symtab) != NULL)
+ if (cust != NULL && COMPUNIT_OBJFILE (cust) != NULL)
block = block_for_pc (pc);
}
GDB_PY_HANDLE_EXCEPTION (except);
- if (!symtab || SYMTAB_OBJFILE (symtab) == NULL)
+ if (cust == NULL || COMPUNIT_OBJFILE (cust) == NULL)
{
PyErr_SetString (PyExc_RuntimeError,
_("Cannot locate object file for block."));
}
if (block)
- return block_to_block_object (block, SYMTAB_OBJFILE (symtab));
+ return block_to_block_object (block, COMPUNIT_OBJFILE (cust));
Py_RETURN_NONE;
}
stpy_get_producer (PyObject *self, void *closure)
{
struct symtab *symtab = NULL;
+ struct compunit_symtab *cust;
STPY_REQUIRE_VALID (self, symtab);
- if (symtab->producer != NULL)
+ cust = SYMTAB_COMPUNIT (symtab);
+ if (COMPUNIT_PRODUCER (cust) != NULL)
{
- const char *producer = symtab->producer;
+ const char *producer = COMPUNIT_PRODUCER (cust);
return PyString_Decode (producer, strlen (producer),
host_charset (), NULL);
struct symtabs_and_lines sals;
struct symtab_and_line sal;
struct objfile *ofp;
+ struct compunit_symtab *cu;
if (s)
{
current_source_line = 1;
- ALL_SYMTABS (ofp, s)
+ ALL_FILETABS (ofp, cu, s)
{
const char *name = s->filename;
int len = strlen (name);
void
forget_cached_source_info_for_objfile (struct objfile *objfile)
{
+ struct compunit_symtab *cu;
struct symtab *s;
- ALL_OBJFILE_SYMTABS (objfile, s)
+ ALL_OBJFILE_FILETABS (objfile, cu, s)
{
if (s->line_charpos != NULL)
{
s->nlines == 1 ? "" : "s");
printf_filtered (_("Source language is %s.\n"), language_str (s->language));
- printf_filtered (_("Compiled with %s debugging format.\n"), s->debugformat);
+ printf_filtered (_("Compiled with %s debugging format.\n"),
+ COMPUNIT_DEBUGFORMAT (SYMTAB_COMPUNIT (s)));
printf_filtered (_("%s preprocessor macro info.\n"),
- s->macro_table ? "Includes" : "Does not include");
+ COMPUNIT_MACRO_TABLE (SYMTAB_COMPUNIT (s)) != NULL
+ ? "Includes" : "Does not include");
}
\f
spu_catch_start (struct objfile *objfile)
{
struct bound_minimal_symbol minsym;
- struct symtab *symtab;
+ struct compunit_symtab *cust;
CORE_ADDR pc;
char buf[32];
/* If we have debugging information, try to use it -- this
will allow us to properly skip the prologue. */
pc = BMSYMBOL_VALUE_ADDRESS (minsym);
- symtab = find_pc_sect_symtab (pc, MSYMBOL_OBJ_SECTION (minsym.objfile,
- minsym.minsym));
- if (symtab != NULL)
+ cust
+ = find_pc_sect_compunit_symtab (pc, MSYMBOL_OBJ_SECTION (minsym.objfile,
+ minsym.minsym));
+ if (cust != NULL)
{
- const struct blockvector *bv = SYMTAB_BLOCKVECTOR (symtab);
+ const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
struct block *block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
struct symbol *sym;
struct symtab_and_line sal;
{
volatile struct gdb_exception ex;
CORE_ADDR pc = 0;
- struct symtab *s;
/* We determine the current frame language by looking up its
associated symtab. To retrieve this symtab, we use the frame
}
else
{
- s = find_pc_symtab (pc);
- if (s != NULL)
- return s->language;
+ struct compunit_symtab *cust = find_pc_compunit_symtab (pc);
+
+ if (cust != NULL)
+ return compunit_language (cust);
}
}
return retval;
}
-static struct symtab *
+static struct compunit_symtab *
debug_qf_lookup_symbol (struct objfile *objfile, int kind, const char *name,
domain_enum domain)
{
const struct debug_sym_fns_data *debug_data =
objfile_data (objfile, symfile_debug_objfile_data_key);
- struct symtab *retval;
+ struct compunit_symtab *retval;
fprintf_filtered (gdb_stdlog,
"qf->lookup_symbol (%s, %d, \"%s\", %s)\n",
domain);
fprintf_filtered (gdb_stdlog, "qf->lookup_symbol (...) = %s\n",
- retval ? debug_symtab_name (retval) : "NULL");
+ retval
+ ? debug_symtab_name (compunit_primary_filetab (retval))
+ : "NULL");
return retval;
}
kind, data);
}
-static struct symtab *
-debug_qf_find_pc_sect_symtab (struct objfile *objfile,
- struct bound_minimal_symbol msymbol,
- CORE_ADDR pc,
- struct obj_section *section,
- int warn_if_readin)
+static struct compunit_symtab *
+debug_qf_find_pc_sect_compunit_symtab (struct objfile *objfile,
+ struct bound_minimal_symbol msymbol,
+ CORE_ADDR pc,
+ struct obj_section *section,
+ int warn_if_readin)
{
const struct debug_sym_fns_data *debug_data =
objfile_data (objfile, symfile_debug_objfile_data_key);
- struct symtab *retval;
+ struct compunit_symtab *retval;
fprintf_filtered (gdb_stdlog,
- "qf->find_pc_sect_symtab (%s, %s, %s, %s, %d)\n",
+ "qf->find_pc_sect_compunit_symtab (%s, %s, %s, %s, %d)\n",
debug_objfile_name (objfile),
host_address_to_string (msymbol.minsym),
hex_string (pc),
host_address_to_string (section),
warn_if_readin);
- retval = debug_data->real_sf->qf->find_pc_sect_symtab (objfile, msymbol,
- pc, section,
- warn_if_readin);
+ retval
+ = debug_data->real_sf->qf->find_pc_sect_compunit_symtab (objfile, msymbol,
+ pc, section,
+ warn_if_readin);
- fprintf_filtered (gdb_stdlog, "qf->find_pc_sect_symtab (...) = %s\n",
- retval ? debug_symtab_name (retval) : "NULL");
+ fprintf_filtered (gdb_stdlog,
+ "qf->find_pc_sect_compunit_symtab (...) = %s\n",
+ retval
+ ? debug_symtab_name (compunit_primary_filetab (retval))
+ : "NULL");
return retval;
}
debug_qf_expand_symtabs_with_fullname,
debug_qf_map_matching_symbols,
debug_qf_expand_symtabs_matching,
- debug_qf_find_pc_sect_symtab,
+ debug_qf_find_pc_sect_compunit_symtab,
debug_qf_map_symbol_filenames
};
\f
objfile->psymbol_cache = psymbol_bcache_init ();
obstack_free (&objfile->objfile_obstack, 0);
objfile->sections = NULL;
- objfile->symtabs = NULL;
+ objfile->compunit_symtabs = NULL;
objfile->psymtabs = NULL;
objfile->psymtabs_addrmap = NULL;
objfile->free_psymtabs = NULL;
return language_unknown;
}
\f
-/* allocate_symtab:
-
- Allocate and partly initialize a new symbol table. Return a pointer
- to it. error() if no space.
-
- Caller must set these fields:
- LINETABLE(symtab)
- symtab->blockvector
- symtab->dirname
- symtab->free_code
- symtab->free_ptr
- */
+/* Allocate and initialize a new symbol table.
+ CUST is from the result of allocate_compunit_symtab. */
struct symtab *
-allocate_symtab (const char *filename, struct objfile *objfile)
+allocate_symtab (struct compunit_symtab *cust, const char *filename)
{
- struct symtab *symtab;
+ struct objfile *objfile = cust->objfile;
+ struct symtab *symtab
+ = OBSTACK_ZALLOC (&objfile->objfile_obstack, struct symtab);
- symtab = (struct symtab *)
- obstack_alloc (&objfile->objfile_obstack, sizeof (struct symtab));
- memset (symtab, 0, sizeof (*symtab));
symtab->filename = bcache (filename, strlen (filename) + 1,
objfile->per_bfd->filename_cache);
symtab->fullname = NULL;
symtab->language = deduce_language_from_filename (filename);
- symtab->debugformat = "unknown";
-
- /* Hook it to the objfile it comes from. */
-
- SYMTAB_OBJFILE (symtab) = objfile;
- symtab->next = objfile->symtabs;
- objfile->symtabs = symtab;
/* This can be very verbose with lots of headers.
Only print at higher debug levels. */
host_address_to_string (symtab), filename);
}
- return (symtab);
+ /* Add it to CUST's list of symtabs. */
+ if (cust->filetabs == NULL)
+ {
+ cust->filetabs = symtab;
+ cust->last_filetab = symtab;
+ }
+ else
+ {
+ cust->last_filetab->next = symtab;
+ cust->last_filetab = symtab;
+ }
+
+ /* Backlink to the containing compunit symtab. */
+ symtab->compunit_symtab = cust;
+
+ return symtab;
+}
+
+/* Allocate and initialize a new compunit.
+ NAME is the name of the main source file, if there is one, or some
+ descriptive text if there are no source files. */
+
+struct compunit_symtab *
+allocate_compunit_symtab (struct objfile *objfile, const char *name)
+{
+ struct compunit_symtab *cu = OBSTACK_ZALLOC (&objfile->objfile_obstack,
+ struct compunit_symtab);
+ const char *saved_name;
+
+ cu->objfile = objfile;
+
+ /* The name we record here is only for display/debugging purposes.
+ Just save the basename to avoid path issues (too long for display,
+ relative vs absolute, etc.). */
+ saved_name = lbasename (name);
+ cu->name = obstack_copy0 (&objfile->objfile_obstack, saved_name,
+ strlen (saved_name));
+
+ COMPUNIT_DEBUGFORMAT (cu) = "unknown";
+
+ if (symtab_create_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "Created compunit symtab %s for %s.\n",
+ host_address_to_string (cu),
+ cu->name);
+ }
+
+ return cu;
+}
+
+/* Hook CU to the objfile it comes from. */
+
+void
+add_compunit_symtab_to_objfile (struct compunit_symtab *cu)
+{
+ cu->next = cu->objfile->compunit_symtabs;
+ cu->objfile->compunit_symtabs = cu;
}
\f
symbols. NAME is the name of the symbol to look for. DOMAIN
indicates what sort of symbol to search for.
- Returns the newly-expanded symbol table in which the symbol is
+ Returns the newly-expanded compunit in which the symbol is
defined, or NULL if no such symbol table exists. If OBJFILE
- contains !TYPE_OPAQUE symbol prefer its symtab. If it contains
- only TYPE_OPAQUE symbol(s), return at least that symtab. */
- struct symtab *(*lookup_symbol) (struct objfile *objfile,
- int block_index, const char *name,
- domain_enum domain);
+ contains !TYPE_OPAQUE symbol prefer its compunit. If it contains
+ only TYPE_OPAQUE symbol(s), return at least that compunit. */
+ struct compunit_symtab *(*lookup_symbol) (struct objfile *objfile,
+ int block_index, const char *name,
+ domain_enum domain);
/* Print statistics about any indices loaded for OBJFILE. The
statistics should be printed to gdb_stdout. This is used for
enum search_domain kind,
void *data);
- /* Return the symbol table from OBJFILE that contains PC and
- SECTION. Return NULL if there is no such symbol table. This
- should return the symbol table that contains a symbol whose
+ /* Return the comp unit from OBJFILE that contains PC and
+ SECTION. Return NULL if there is no such compunit. This
+ should return the compunit that contains a symbol whose
address exactly matches PC, or, if there is no exact match, the
- symbol table that contains a symbol whose address is closest to
+ compunit that contains a symbol whose address is closest to
PC. */
- struct symtab *(*find_pc_sect_symtab) (struct objfile *objfile,
- struct bound_minimal_symbol msymbol,
- CORE_ADDR pc,
- struct obj_section *section,
- int warn_if_readin);
+ struct compunit_symtab *(*find_pc_sect_compunit_symtab)
+ (struct objfile *objfile, struct bound_minimal_symbol msymbol,
+ CORE_ADDR pc, struct obj_section *section, int warn_if_readin);
/* Call a callback for every file defined in OBJFILE whose symtab is
not already read in. FUN is the callback. It is passed the file's
extern bfd_byte *default_symfile_relocate (struct objfile *objfile,
asection *sectp, bfd_byte *buf);
-extern struct symtab *allocate_symtab (const char *, struct objfile *)
+extern struct symtab *allocate_symtab (struct compunit_symtab *, const char *)
ATTRIBUTE_NONNULL (1);
+extern struct compunit_symtab *allocate_compunit_symtab (struct objfile *,
+ const char *)
+ ATTRIBUTE_NONNULL (1);
+
+extern void add_compunit_symtab_to_objfile (struct compunit_symtab *cu);
+
extern void add_symtab_fns (enum bfd_flavour flavour, const struct sym_fns *);
/* This enum encodes bit-flags passed as ADD_FLAGS parameter to
{
struct program_space *pspace;
struct objfile *objfile;
+ struct compunit_symtab *cu;
struct symtab *s;
int i, linetables, blockvectors;
if (objfile->sf)
objfile->sf->qf->print_stats (objfile);
i = linetables = blockvectors = 0;
- ALL_OBJFILE_SYMTABS (objfile, s)
+ ALL_OBJFILE_FILETABS (objfile, cu, s)
{
i++;
if (SYMTAB_LINETABLE (s) != NULL)
linetables++;
- if (s->primary == 1)
- blockvectors++;
}
+ ALL_OBJFILE_COMPUNITS (objfile, cu)
+ blockvectors++;
printf_filtered (_(" Number of symbol tables: %d\n"), i);
printf_filtered (_(" Number of symbol tables with line tables: %d\n"),
linetables);
static void
dump_objfile (struct objfile *objfile)
{
+ struct compunit_symtab *cust;
struct symtab *symtab;
printf_filtered ("\nObject file %s: ", objfile_name (objfile));
if (objfile->sf)
objfile->sf->qf->dump (objfile);
- if (objfile->symtabs)
+ if (objfile->compunit_symtabs != NULL)
{
printf_filtered ("Symtabs:\n");
- for (symtab = objfile->symtabs;
- symtab != NULL;
- symtab = symtab->next)
+ ALL_OBJFILE_FILETABS (objfile, cust, symtab)
{
printf_filtered ("%s at ", symtab_to_filename_for_display (symtab));
gdb_print_host_address (symtab, gdb_stdout);
fprintf_filtered (outfile, "\n");
}
}
- /* Now print the block info, but only for primary symtabs since we will
+ /* Now print the block info, but only for compunit symtabs since we will
print lots of duplicate info otherwise. */
- if (symtab->primary)
+ if (symtab == COMPUNIT_FILETABS (SYMTAB_COMPUNIT (symtab)))
{
fprintf_filtered (outfile, "\nBlockvector:\n\n");
bv = SYMTAB_BLOCKVECTOR (symtab);
char *symname = NULL;
char *filename = DEV_TTY;
struct objfile *objfile;
+ struct compunit_symtab *cu;
struct symtab *s;
dont_repeat ();
perror_with_name (filename);
make_cleanup_ui_file_delete (outfile);
- ALL_SYMTABS (objfile, s)
+ ALL_FILETABS (objfile, cu, s)
{
QUIT;
if (symname == NULL
ALL_PSPACES (pspace)
ALL_PSPACE_OBJFILES (pspace, objfile)
{
+ struct compunit_symtab *cust;
struct symtab *symtab;
/* We don't want to print anything for this objfile until we
actually find a symtab whose name matches. */
int printed_objfile_start = 0;
- ALL_OBJFILE_SYMTABS (objfile, symtab)
+ ALL_OBJFILE_COMPUNITS (objfile, cust)
{
- QUIT;
+ int printed_compunit_symtab_start = 0;
- if (! regexp
- || re_exec (symtab_to_filename_for_display (symtab)))
+ ALL_COMPUNIT_FILETABS (cust, symtab)
{
- if (! printed_objfile_start)
+ QUIT;
+
+ if (! regexp
+ || re_exec (symtab_to_filename_for_display (symtab)))
{
- printf_filtered ("{ objfile %s ", objfile_name (objfile));
- wrap_here (" ");
- printf_filtered ("((struct objfile *) %s)\n",
- host_address_to_string (objfile));
- printed_objfile_start = 1;
+ if (! printed_objfile_start)
+ {
+ printf_filtered ("{ objfile %s ", objfile_name (objfile));
+ wrap_here (" ");
+ printf_filtered ("((struct objfile *) %s)\n",
+ host_address_to_string (objfile));
+ printed_objfile_start = 1;
+ }
+ if (! printed_compunit_symtab_start)
+ {
+ printf_filtered (" { ((struct compunit_symtab *) %s)\n",
+ host_address_to_string (cust));
+ printf_filtered (" debugformat %s\n",
+ COMPUNIT_DEBUGFORMAT (cust));
+ printf_filtered (" producer %s\n",
+ COMPUNIT_PRODUCER (cust) != NULL
+ ? COMPUNIT_PRODUCER (cust)
+ : "(null)");
+ printf_filtered (" dirname %s\n",
+ COMPUNIT_DIRNAME (cust) != NULL
+ ? COMPUNIT_DIRNAME (cust)
+ : "(null)");
+ printf_filtered (" blockvector"
+ " ((struct blockvector *) %s)\n",
+ host_address_to_string
+ (COMPUNIT_BLOCKVECTOR (cust)));
+ printed_compunit_symtab_start = 1;
+ }
+
+ printf_filtered ("\t{ symtab %s ",
+ symtab_to_filename_for_display (symtab));
+ wrap_here (" ");
+ printf_filtered ("((struct symtab *) %s)\n",
+ host_address_to_string (symtab));
+ printf_filtered ("\t fullname %s\n",
+ symtab->fullname != NULL
+ ? symtab->fullname
+ : "(null)");
+ printf_filtered ("\t "
+ "linetable ((struct linetable *) %s)\n",
+ host_address_to_string (symtab->linetable));
+ printf_filtered ("\t}\n");
}
-
- printf_filtered (" { symtab %s ",
- symtab_to_filename_for_display (symtab));
- wrap_here (" ");
- printf_filtered ("((struct symtab *) %s)\n",
- host_address_to_string (symtab));
- printf_filtered (" dirname %s\n",
- SYMTAB_DIRNAME (symtab) != NULL
- ? SYMTAB_DIRNAME (symtab) : "(null)");
- printf_filtered (" fullname %s\n",
- symtab->fullname ? symtab->fullname : "(null)");
- printf_filtered (" "
- "blockvector ((struct blockvector *) %s)%s\n",
- host_address_to_string (symtab->blockvector),
- symtab->primary ? " (primary)" : "");
- printf_filtered (" "
- "linetable ((struct linetable *) %s)\n",
- host_address_to_string
- (SYMTAB_LINETABLE (symtab)));
- printf_filtered (" debugformat %s\n",
- symtab->debugformat);
- printf_filtered (" }\n");
}
+
+ if (printed_compunit_symtab_start)
+ printf_filtered (" }\n");
}
if (printed_objfile_start)
ALL_PSPACES (pspace)
ALL_PSPACE_OBJFILES (pspace, objfile)
{
- struct symtab *symtab;
+ struct compunit_symtab *cust;
/* We don't want to print anything for this objfile until we
actually find something worth printing. */
int printed_objfile_start = 0;
- ALL_OBJFILE_SYMTABS (objfile, symtab)
+ ALL_OBJFILE_COMPUNITS (objfile, cust)
{
int found_something = 0;
+ struct symtab *symtab = compunit_primary_filetab (cust);
QUIT;
- if (symtab->blockvector == NULL)
+ if (COMPUNIT_BLOCKVECTOR (cust) == NULL)
found_something = 1;
/* Add more checks here. */
}
printf_filtered (" { symtab %s\n",
symtab_to_filename_for_display (symtab));
- if (symtab->blockvector == NULL)
+ if (COMPUNIT_BLOCKVECTOR (cust) == NULL)
printf_filtered (" NULL blockvector\n");
printf_filtered (" }\n");
}
}
}
-/* 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))
+ ALL_COMPUNIT_FILETABS (cust, s)
{
- 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))
- {
- 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;
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)
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);
/* 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;
+ sizeof (((struct section_offsets *) 0)->offsets) * ((n)-1))
/* Each source file or header is represented by a struct symtab.
+ The name "symtab" is historical, another name for it is "filetab".
These objects are chained through the `next' field. */
struct symtab
struct symtab *next;
- /* List of all symbol scope blocks for this symtab. May be shared
- between different symtabs (and normally is for all the symtabs
- in a given compilation unit). */
+ /* Backlink to containing compunit symtab. */
- const struct blockvector *blockvector;
+ struct compunit_symtab *compunit_symtab;
/* Table mapping core addresses to line numbers for this file.
Can be NULL if none. Never shared between different symtabs. */
struct linetable *linetable;
- /* Section in objfile->section_offsets for the blockvector and
- the linetable. Probably always SECT_OFF_TEXT. */
-
- int block_line_section;
-
- /* If several symtabs share a blockvector, exactly one of them
- should be designated the primary, so that the blockvector
- is relocated exactly once by objfile_relocate. */
-
- unsigned int primary : 1;
-
- /* Symtab has been compiled with both optimizations and debug info so that
- GDB may stop skipping prologues as variables locations are valid already
- at function entry points. */
-
- unsigned int locations_valid : 1;
-
- /* DWARF unwinder for this CU is valid even for epilogues (PC at the return
- instruction). This is supported by GCC since 4.5.0. */
-
- unsigned int epilogue_unwind_valid : 1;
-
- /* The macro table for this symtab. Like the blockvector, this
- may be shared between different symtabs --- and normally is for
- all the symtabs in a given compilation unit. */
- struct macro_table *macro_table;
-
/* Name of this source file. This pointer is never NULL. */
const char *filename;
- /* Directory in which it was compiled, or NULL if we don't know. */
-
- const char *dirname;
-
/* Total number of lines found in source file. */
int nlines;
enum language language;
- /* String that identifies the format of the debugging information, such
- as "stabs", "dwarf 1", "dwarf 2", "coff", etc. This is mostly useful
+ /* Full name of file as found by searching the source path.
+ NULL if not yet known. */
+
+ char *fullname;
+};
+
+#define SYMTAB_COMPUNIT(symtab) ((symtab)->compunit_symtab)
+#define SYMTAB_LINETABLE(symtab) ((symtab)->linetable)
+#define SYMTAB_LANGUAGE(symtab) ((symtab)->language)
+#define SYMTAB_BLOCKVECTOR(symtab) \
+ COMPUNIT_BLOCKVECTOR (SYMTAB_COMPUNIT (symtab))
+#define SYMTAB_OBJFILE(symtab) \
+ COMPUNIT_OBJFILE (SYMTAB_COMPUNIT (symtab))
+#define SYMTAB_PSPACE(symtab) (SYMTAB_OBJFILE (symtab)->pspace)
+#define SYMTAB_DIRNAME(symtab) \
+ COMPUNIT_DIRNAME (SYMTAB_COMPUNIT (symtab))
+
+typedef struct symtab *symtab_ptr;
+DEF_VEC_P (symtab_ptr);
+
+/* Compunit symtabs contain the actual "symbol table", aka blockvector, as well
+ as the list of all source files (what gdb has historically associated with
+ the term "symtab").
+ Additional information is recorded here that is common to all symtabs in a
+ compilation unit (DWARF or otherwise).
+
+ Example:
+ For the case of a program built out of these files:
+
+ foo.c
+ foo1.h
+ foo2.h
+ bar.c
+ foo1.h
+ bar.h
+
+ This is recorded as:
+
+ objfile -> foo.c(cu) -> bar.c(cu) -> NULL
+ | |
+ v v
+ foo.c bar.c
+ | |
+ v v
+ foo1.h foo1.h
+ | |
+ v v
+ foo2.h bar.h
+ | |
+ v v
+ NULL NULL
+
+ where "foo.c(cu)" and "bar.c(cu)" are struct compunit_symtab objects,
+ and the files foo.c, etc. are struct symtab objects. */
+
+struct compunit_symtab
+{
+ /* Unordered chain of all compunit symtabs of this objfile. */
+ struct compunit_symtab *next;
+
+ /* Object file from which this symtab information was read. */
+ struct objfile *objfile;
+
+ /* Name of the symtab.
+ This is *not* intended to be a usable filename, and is
+ for debugging purposes only. */
+ const char *name;
+
+ /* Unordered list of file symtabs, except that by convention the "main"
+ source file (e.g., .c, .cc) is guaranteed to be first.
+ Each symtab is a file, either the "main" source file (e.g., .c, .cc)
+ or header (e.g., .h). */
+ struct symtab *filetabs;
+
+ /* Last entry in FILETABS list.
+ Subfiles are added to the end of the list so they accumulate in order,
+ with the main source subfile living at the front.
+ The main reason is so that the main source file symtab is at the head
+ of the list, and the rest appear in order for debugging convenience. */
+ struct symtab *last_filetab;
+
+ /* Non-NULL string that identifies the format of the debugging information,
+ such as "stabs", "dwarf 1", "dwarf 2", "coff", etc. This is mostly useful
for automated testing of gdb but may also be information that is
useful to the user. */
-
const char *debugformat;
- /* String of producer version information. May be zero. */
-
+ /* String of producer version information, or NULL if we don't know. */
const char *producer;
- /* Full name of file as found by searching the source path.
- NULL if not yet known. */
+ /* Directory in which it was compiled, or NULL if we don't know. */
+ const char *dirname;
- char *fullname;
+ /* List of all symbol scope blocks for this symtab. It is shared among
+ all symtabs in a given compilation unit. */
+ const struct blockvector *blockvector;
- /* Object file from which this symbol information was read. */
+ /* Section in objfile->section_offsets for the blockvector and
+ the linetable. Probably always SECT_OFF_TEXT. */
+ int block_line_section;
- struct objfile *objfile;
+ /* Symtab has been compiled with both optimizations and debug info so that
+ GDB may stop skipping prologues as variables locations are valid already
+ at function entry points. */
+ unsigned int locations_valid : 1;
- /* struct call_site entries for this compilation unit or NULL. */
+ /* DWARF unwinder for this CU is valid even for epilogues (PC at the return
+ instruction). This is supported by GCC since 4.5.0. */
+ unsigned int epilogue_unwind_valid : 1;
+ /* struct call_site entries for this compilation unit or NULL. */
htab_t call_site_htab;
+ /* The macro table for this symtab. Like the blockvector, this
+ is shared between different symtabs in a given compilation unit.
+ It's debatable whether it *should* be shared among all the symtabs in
+ the given compilation unit, but it currently is. */
+ struct macro_table *macro_table;
+
/* If non-NULL, then this points to a NULL-terminated vector of
- included symbol tables. When searching the static or global
- block of this symbol table, the corresponding block of all
- included symbol tables will also be searched. Note that this
+ included compunits. When searching the static or global
+ block of this compunit, the corresponding block of all
+ included compunits will also be searched. Note that this
list must be flattened -- the symbol reader is responsible for
ensuring that this vector contains the transitive closure of all
- included symbol tables. */
-
- struct symtab **includes;
+ included compunits. */
+ struct compunit_symtab **includes;
- /* If this is an included symbol table, this points to one includer
- of the table. This user is considered the canonical symbol table
- containing this one. An included symbol table may itself be
+ /* If this is an included compunit, this points to one includer
+ of the table. This user is considered the canonical compunit
+ containing this one. An included compunit may itself be
included by another. */
-
- struct symtab *user;
+ struct compunit_symtab *user;
};
-#define SYMTAB_BLOCKVECTOR(symtab) ((symtab)->blockvector)
-#define SYMTAB_LINETABLE(symtab) ((symtab)->linetable)
-#define SYMTAB_OBJFILE(symtab) ((symtab)->objfile)
-#define SYMTAB_PSPACE(symtab) (SYMTAB_OBJFILE (symtab)->pspace)
-#define SYMTAB_DIRNAME(symtab) ((symtab)->dirname)
+#define COMPUNIT_OBJFILE(cust) ((cust)->objfile)
+#define COMPUNIT_FILETABS(cust) ((cust)->filetabs)
+#define COMPUNIT_DEBUGFORMAT(cust) ((cust)->debugformat)
+#define COMPUNIT_PRODUCER(cust) ((cust)->producer)
+#define COMPUNIT_DIRNAME(cust) ((cust)->dirname)
+#define COMPUNIT_BLOCKVECTOR(cust) ((cust)->blockvector)
+#define COMPUNIT_BLOCK_LINE_SECTION(cust) ((cust)->block_line_section)
+#define COMPUNIT_LOCATIONS_VALID(cust) ((cust)->locations_valid)
+#define COMPUNIT_EPILOGUE_UNWIND_VALID(cust) ((cust)->epilogue_unwind_valid)
+#define COMPUNIT_CALL_SITE_HTAB(cust) ((cust)->call_site_htab)
+#define COMPUNIT_MACRO_TABLE(cust) ((cust)->macro_table)
-/* Call this to set the "primary" field in struct symtab. */
-extern void set_symtab_primary (struct symtab *, int primary);
+/* Iterate over all file tables (struct symtab) within a compunit. */
-typedef struct symtab *symtab_ptr;
-DEF_VEC_P (symtab_ptr);
+#define ALL_COMPUNIT_FILETABS(cu, s) \
+ for ((s) = (cu) -> filetabs; (s) != NULL; (s) = (s) -> next)
+
+/* Return the primary symtab of CUST. */
+
+extern struct symtab *
+ compunit_primary_filetab (const struct compunit_symtab *cust);
+
+/* Return the language of CUST. */
+
+extern enum language compunit_language (const struct compunit_symtab *cust);
+
+typedef struct compunit_symtab *compunit_symtab_ptr;
+DEF_VEC_P (compunit_symtab_ptr);
\f
/* lookup full symbol table by address. */
-extern struct symtab *find_pc_symtab (CORE_ADDR);
+extern struct compunit_symtab *find_pc_compunit_symtab (CORE_ADDR);
/* lookup full symbol table by address and section. */
-extern struct symtab *find_pc_sect_symtab (CORE_ADDR, struct obj_section *);
+extern struct compunit_symtab *
+ find_pc_sect_compunit_symtab (CORE_ADDR, struct obj_section *);
extern int find_pc_line_pc_range (CORE_ADDR, CORE_ADDR *, CORE_ADDR *);
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);
void iterate_over_symtabs (const char *name,
int (*callback) (struct symtab *symtab,
+2014-11-20 Doug Evans <xdje42@gmail.com>
+
+ * gdb.base/maint.exp: Update expected output.
+
2014-11-19 Andreas Arnez <arnez@linux.vnet.ibm.com>
* gdb.base/bp-permanent.c (NOP): Define as 2-byte instead of
gdb_test_no_output "mt set per on" "mt set per on for expand-symtabs"
gdb_test_multiple "mt expand-symtabs $subdir/break\[.\]c$" \
"mt expand-symtabs" {
- -re "#primary symtabs: (1|2) \\(\[+\](0|1|2)\\),.*$gdb_prompt $" {
+ -re "#compunits: (1|2) \\(\[+\](0|1|2)\\),.*$gdb_prompt $" {
# This should expand at most two primary symtabs.
# "Normally" it will not expand any, because the symtab
# holding "main" will already have been expanded, but if the
# Test per-command stats.
gdb_test_no_output "maint set per-command on"
gdb_test "pwd" \
- "Command execution time: \[0-9.\]+ \\(cpu\\), \[0-9.\]+ \\(wall\\)\[\r\n\]+Space used: $decimal \\(\\+$decimal for this command\\)\[\r\n\]+#symtabs: $decimal \\(\\+$decimal\\), #primary symtabs: $decimal \\(\\+$decimal\\), #blocks: $decimal \\(\\+$decimal\\)"
+ "Command execution time: \[0-9.\]+ \\(cpu\\), \[0-9.\]+ \\(wall\\)\[\r\n\]+Space used: $decimal \\(\\+$decimal for this command\\)\[\r\n\]+#symtabs: $decimal \\(\\+$decimal\\), #compunits: $decimal \\(\\+$decimal\\), #blocks: $decimal \\(\\+$decimal\\)"
gdb_test_no_output "maint set per-command off"
gdb_test "maint demangle" \
{
if (get_last_source_file ())
{
- pst->symtab = end_symtab (cur_src_end_addr,
- SECT_OFF_TEXT (objfile));
+ pst->compunit_symtab = end_symtab (cur_src_end_addr,
+ SECT_OFF_TEXT (objfile));
end_stabs ();
}
{
complete_symtab (filestring, file_start_addr);
cur_src_end_addr = file_end_addr;
- end_symtab (file_end_addr,
- SECT_OFF_TEXT (objfile));
+ end_symtab (file_end_addr, SECT_OFF_TEXT (objfile));
end_stabs ();
start_stabs ();
/* Give all csects for this source file the same
if (get_last_source_file ())
{
- struct symtab *s;
+ struct compunit_symtab *cust;
complete_symtab (filestring, file_start_addr);
cur_src_end_addr = file_end_addr;
- s = end_symtab (file_end_addr, SECT_OFF_TEXT (objfile));
+ cust = end_symtab (file_end_addr, SECT_OFF_TEXT (objfile));
/* When reading symbols for the last C_FILE of the objfile, try
- to make sure that we set pst->symtab to the symtab for the
+ to make sure that we set pst->compunit_symtab to the symtab for the
file, not to the _globals_ symtab. I'm not sure whether this
actually works right or when/if it comes up. */
- if (pst->symtab == NULL)
- pst->symtab = s;
+ if (pst->compunit_symtab == NULL)
+ pst->compunit_symtab = cust;
end_stabs ();
}
}
subpst->n_static_syms = 0;
subpst->readin = 0;
- subpst->symtab = 0;
+ subpst->compunit_symtab = NULL;
subpst->read_symtab = pst->read_symtab;
}