Split struct symtab into two: struct symtab and compunit_symtab.

Currently "symtabs" in gdb are stored as a single linked list of
struct symtab that contains both symbol symtabs (the blockvectors)
and file symtabs (the linetables).

This has led to confusion, bugs, and performance issues.

This patch is conceptually very simple: split struct symtab into
two pieces: one part containing things common across the entire
compilation unit, and one part containing things specific to each
source file.

Example.
For the case of a program built out of these files:

foo.c
  foo1.h
  foo2.h
bar.c
  foo1.h
  bar.h

Today we have a single list of struct symtabs:

objfile -> foo.c -> foo1.h -> foo2.h -> bar.c -> foo1.h -> bar.h -> NULL

where "->" means the "next" pointer in struct symtab.

With this patch, that turns into:

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.

So now, for example, when we want to iterate over all blockvectors
we can now just iterate over the compunit_symtab list.

Plus a lot of the data that was either unused or replicated for each
symtab in a compilation unit now lives in struct compunit_symtab.
E.g., the objfile pointer, the producer string, etc.
I thought of moving "language" out of struct symtab but there is
logic to try to compute the language based on previously seen files,
and I think that's best left as is for now.
With my standard monster benchmark with -readnow (which I can't actually
do, but based on my calculations), whereas today the list requires
77MB to store all the struct symtabs, it now only requires 37MB.
A modest space savings given the gigabytes needed for all the debug info,
etc.  Still, it's nice.  Plus, whereas today we create a copy of dirname
for each source file symtab in a compilation unit, we now only create one
for the compunit.

So this patch is basically just a data structure reorg,
I don't expect significant performance improvements from it.

Notes:

1) A followup patch can do a similar split for struct partial_symtab.
I have left that until after I get the changes I want in to
better utilize .gdb_index (it may affect how we do partial syms).

2) Another followup patch *could* rename struct symtab.
The term "symtab" is ambiguous and has been a source of confusion.
In this patch I'm leaving it alone, calling it the "historical" name
of "filetabs", which is what they are now: just the file-name + line-table.

gdb/ChangeLog:

	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.

gdb/testsuite/ChangeLog:

	* gdb.base/maint.exp: Update expected output.
This commit is contained in:
Doug Evans 2014-11-20 07:42:48 -08:00
parent 5c47e52589
commit 43f3e411c4
46 changed files with 1488 additions and 988 deletions

View File

@ -1,3 +1,202 @@
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

View File

@ -6153,7 +6153,7 @@ ada_make_symbol_completion_list (const char *text0, const char *word,
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;
@ -6232,14 +6232,12 @@ ada_make_symbol_completion_list (const char *text0, const char *word,
}
/* 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),
@ -6248,10 +6246,10 @@ ada_make_symbol_completion_list (const char *text0, const char *word,
}
}
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;
@ -12943,14 +12941,14 @@ static void
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++)

View File

@ -2301,7 +2301,8 @@ amd64_skip_xmm_prologue (CORE_ADDR pc, CORE_ADDR start_pc)
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;
@ -2364,14 +2365,15 @@ amd64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_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);
}
@ -2713,10 +2715,10 @@ static int
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))

View File

@ -1398,7 +1398,7 @@ arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR 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);
if (post_prologue_pc)
post_prologue_pc
@ -1412,10 +1412,12 @@ arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR 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)

View File

@ -156,20 +156,21 @@ find_block_in_blockvector (const struct blockvector *bl, CORE_ADDR pc)
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);
@ -196,14 +197,14 @@ blockvector_contains_pc (const struct blockvector *bv, CORE_ADDR 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)
{
@ -388,30 +389,30 @@ allocate_global_block (struct obstack *obstack)
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;
}
@ -425,19 +426,19 @@ initialize_block_iterator (const struct block *block,
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
{
@ -450,14 +451,14 @@ initialize_block_iterator (const struct block *block,
/* 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
@ -466,20 +467,20 @@ initialize_block_iterator (const struct block *block,
}
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
@ -497,14 +498,15 @@ block_iterator_step (struct block_iterator *iterator, int first)
{
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);
}
@ -563,14 +565,15 @@ block_iter_name_step (struct block_iterator *iterator, const char *name,
{
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);
@ -633,14 +636,15 @@ block_iter_match_step (struct block_iterator *iterator,
{
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);

View File

@ -25,7 +25,7 @@
/* Opaque declarations. */
struct symbol;
struct symtab;
struct compunit_symtab;
struct block_namespace_info;
struct using_direct;
struct obstack;
@ -100,7 +100,7 @@ struct block
};
/* 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
{
@ -108,10 +108,9 @@ 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
@ -148,10 +147,9 @@ extern int contained_in (const struct block *, const struct block *);
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);
@ -181,7 +179,8 @@ extern struct block *allocate_block (struct obstack *obstack);
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
@ -190,11 +189,11 @@ extern void set_block_symtab (struct block *, struct symtab *);
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;

View File

@ -195,7 +195,7 @@ find_pc_partial_function_gnu_ifunc (CORE_ADDR pc, const char **name,
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;
@ -220,13 +220,17 @@ find_pc_partial_function_gnu_ifunc (CORE_ADDR pc, const char **name,
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. */

View File

@ -10204,7 +10204,8 @@ resolve_sal_pc (struct symtab_and_line *sal)
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);

View File

@ -52,23 +52,42 @@
#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;
/* The compilation directory. */
/* 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;
static char *buildsym_comp_dir;
/* The subfile of the main source file. */
struct subfile *main_subfile;
/* List of subfiles. */
/* E.g., DW_AT_comp_dir if DWARF. Space for this is malloc'd. */
char *comp_dir;
static struct subfile *subfiles;
/* Space for this is not malloc'd, and is assumed to have at least
the same lifetime as objfile. */
const char *producer;
/* The "main" subfile.
In C this is the ".c" file (and similarly for other languages).
This becomes the "primary" symtab of the compilation unit. */
/* 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 *main_subfile;
/* The compunit we are building. */
struct compunit_symtab *compunit_symtab;
};
/* The work-in-progress of the compunit we are building.
This is created first, before any subfiles by start_symtab. */
static struct buildsym_compunit *buildsym_compunit;
/* List of free `struct pending' structures for reuse. */
@ -124,7 +143,7 @@ struct subfile_stack
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);
@ -264,7 +283,7 @@ finish_block_internal (struct symbol *symbol, struct pending **listhead,
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;
@ -510,10 +529,10 @@ record_block_range (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;
@ -583,12 +602,16 @@ make_blockvector (struct objfile *objfile)
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);
for (subfile = subfiles; subfile; subfile = subfile->next)
subfile_dirname = buildsym_compunit->comp_dir;
/* See if this subfile is already registered. */
for (subfile = buildsym_compunit->subfiles; subfile; subfile = subfile->next)
{
char *subfile_name;
@ -596,8 +619,8 @@ start_subfile (const char *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;
@ -613,20 +636,18 @@ start_subfile (const char *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;
@ -649,13 +670,6 @@ start_subfile (const char *name)
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. */
@ -667,7 +681,7 @@ start_subfile (const char *name)
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;
}
@ -682,24 +696,54 @@ start_subfile (const char *name)
}
}
/* 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
@ -717,15 +761,12 @@ free_subfiles_list (void)
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);
@ -871,20 +912,34 @@ compare_line_numbers (const void *ln1p, const void *ln2p)
return ln1->line - ln2->line;
}
/* 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;
}
@ -897,18 +952,33 @@ get_macro_table (const char *comp_dir)
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.
@ -942,7 +1012,7 @@ restart_symtab (CORE_ADDR start_addr)
/* 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
@ -952,36 +1022,41 @@ restart_symtab (CORE_ADDR start_addr)
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;
@ -993,22 +1068,21 @@ watch_main_source_file_lossage (void)
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);
}
}
@ -1032,11 +1106,8 @@ block_compar (const void *ap, const void *bp)
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)
{
@ -1062,7 +1133,7 @@ reset_symtab_globals (void)
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. */
@ -1157,54 +1228,33 @@ end_symtab_get_static_block (CORE_ADDR end_addr, int expandable, int required)
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);
@ -1212,7 +1262,7 @@ end_symtab_with_blockvector (struct block *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. */
@ -1224,9 +1274,12 @@ end_symtab_with_blockvector (struct block *static_block,
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;
@ -1246,12 +1299,11 @@ end_symtab_with_blockvector (struct block *static_block,
/* 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. */
@ -1264,19 +1316,6 @@ end_symtab_with_blockvector (struct block *static_block,
{
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
@ -1285,33 +1324,66 @@ end_symtab_with_blockvector (struct block *static_block,
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;
/* Similarly for the producer. */
symtab->producer = subfile->producer;
/* 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);
}
/* The main source file is the primary symtab. */
gdb_assert (main_subfile->symtab != NULL);
symtab = main_subfile->symtab;
set_symtab_primary (symtab, 1);
/* Make sure the symtab of main_subfile is the first in its list. */
{
struct block *b = BLOCKVECTOR_BLOCK (symtab->blockvector, GLOBAL_BLOCK);
struct symtab *main_symtab, *prev_symtab;
set_block_symtab (b, 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));
}
/* Fill out the primary symtab. */
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));
}
/* 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 (blockvector, GLOBAL_BLOCK);
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);
@ -1333,7 +1405,10 @@ end_symtab_with_blockvector (struct block *static_block,
}
}
return symtab;
add_compunit_symtab_to_objfile (cu);
free_buildsym_compunit ();
return cu;
}
/* Implementation of the second part of end_symtab. Pass STATIC_BLOCK
@ -1345,23 +1420,23 @@ end_symtab_with_blockvector (struct block *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
@ -1385,7 +1460,7 @@ end_symtab_from_static_block (struct block *static_block,
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;
@ -1396,7 +1471,7 @@ end_symtab (CORE_ADDR end_addr, int section)
/* 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;
@ -1406,10 +1481,12 @@ end_expandable_symtab (CORE_ADDR end_addr, int section)
}
/* 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;
@ -1419,7 +1496,7 @@ set_missing_symtab (struct pending *pending_list, struct symtab *symtab)
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);
}
}
}
@ -1429,9 +1506,9 @@ set_missing_symtab (struct pending *pending_list, struct symtab *symtab)
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)
{
@ -1453,7 +1530,7 @@ augment_type_symtab (struct symtab *primary_symtab)
/* 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);
}
@ -1464,7 +1541,7 @@ augment_type_symtab (struct symtab *primary_symtab)
/* 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);
}
@ -1527,13 +1604,13 @@ hashname (const char *name)
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

View File

@ -22,6 +22,7 @@
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-
@ -56,17 +57,18 @@ EXTERN CORE_ADDR last_source_start_addr;
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;
@ -211,16 +213,16 @@ extern struct block *end_symtab_get_static_block (CORE_ADDR end_addr,
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. */
@ -236,9 +238,10 @@ extern struct context_stack *pop_context (void);
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);
@ -270,9 +273,18 @@ extern void set_last_source_file (const char *name);
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 macro_table *get_macro_table (const char *comp_dir);
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 (void);
#undef EXTERN

View File

@ -781,7 +781,6 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
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;
@ -1200,8 +1199,13 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
/* 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;
}

View File

@ -1393,7 +1393,7 @@ make_symbol_overload_list_using (const char *func_name,
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;
@ -1417,17 +1417,17 @@ make_symbol_overload_list_qualified (const char *func_name)
/* 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;

View File

@ -2344,7 +2344,7 @@ end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
subpst->n_static_syms = 0;
subpst->readin = 0;
subpst->symtab = 0;
subpst->compunit_symtab = 0;
subpst->read_symtab = pst->read_symtab;
}
@ -2644,8 +2644,8 @@ read_ofile_symtab (struct objfile *objfile, struct partial_symtab *pst)
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 ();

View File

@ -852,13 +852,13 @@ static void
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;

View File

@ -715,10 +715,10 @@ struct type_unit_group
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;
@ -1516,8 +1516,9 @@ static void dwarf_decode_lines (struct line_header *, const char *,
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 *);
@ -1716,8 +1717,7 @@ static struct dwarf_block *dwarf_alloc_block (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 *);
@ -2496,7 +2496,7 @@ struct dwarf2_per_cu_quick_data
/* 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. */
@ -2617,7 +2617,7 @@ dw2_do_instantiate_symtab (struct dwarf2_per_cu_data *per_cu)
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);
@ -2648,11 +2648,11 @@ dw2_do_instantiate_symtab (struct dwarf2_per_cu_data *per_cu)
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 ();
@ -2661,10 +2661,7 @@ dw2_instantiate_symtab (struct dwarf2_per_cu_data *per_cu)
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.
@ -3313,11 +3310,15 @@ dw2_get_real_path (struct objfile *objfile,
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. */
@ -3360,10 +3361,10 @@ dw2_map_expand_apply (struct objfile *objfile,
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
@ -3371,7 +3372,7 @@ dw2_map_expand_apply (struct objfile *objfile,
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. */
@ -3397,7 +3398,7 @@ dw2_map_symtabs_matching_filename (struct objfile *objfile, const char *name,
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);
@ -3544,7 +3545,7 @@ dw2_symtab_iter_next (struct dw2_symtab_iterator *iter)
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. */
@ -3592,11 +3593,11 @@ dw2_symtab_iter_next (struct dw2_symtab_iterator *iter)
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);
@ -3614,8 +3615,8 @@ dw2_lookup_symbol (struct objfile *objfile, int block_index,
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
@ -3650,7 +3651,7 @@ dw2_print_stats (struct objfile *objfile)
{
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);
@ -3747,7 +3748,7 @@ dw2_expand_symtabs_with_fullname (struct objfile *objfile,
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);
@ -3827,7 +3828,7 @@ dw2_expand_symtabs_matching
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);
@ -3962,26 +3963,27 @@ dw2_expand_symtabs_matching
}
}
/* 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;
}
@ -3989,15 +3991,15 @@ recursively_find_pc_sect_symtab (struct symtab *symtab, CORE_ADDR pc)
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);
@ -4008,11 +4010,13 @@ dw2_find_pc_sect_symtab (struct objfile *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;
}
@ -4037,7 +4041,7 @@ dw2_map_symbol_filenames (struct objfile *objfile, symbol_filename_ftype *fun,
{
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);
@ -4054,7 +4058,7 @@ dw2_map_symbol_filenames (struct objfile *objfile, symbol_filename_ftype *fun,
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);
@ -4105,7 +4109,7 @@ const struct quick_symbol_functions dwarf2_gdb_index_functions =
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
};
@ -4423,7 +4427,7 @@ dwarf2_create_include_psymtab (const char *name, struct partial_symtab *pst,
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;
@ -4761,7 +4765,7 @@ fill_in_sig_entry_from_dwo_entry (struct objfile *objfile,
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);
@ -7450,7 +7454,7 @@ process_queue (void)
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;
@ -7777,26 +7781,26 @@ fixup_go_packaging (struct dwarf2_cu *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);
@ -7808,27 +7812,27 @@ recursively_compute_inclusions (VEC (symtab_ptr) **result,
*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;
}
}
@ -7837,15 +7841,15 @@ recursively_compute_inclusions (VEC (symtab_ptr) **result,
++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);
@ -7853,13 +7857,13 @@ compute_symtab_includes (struct dwarf2_per_cu_data *per_cu)
{
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,
@ -7874,21 +7878,22 @@ compute_symtab_includes (struct dwarf2_per_cu_data *per_cu)
{
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);
}
@ -7909,7 +7914,7 @@ process_cu_includes (void)
++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);
@ -7925,7 +7930,7 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
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;
@ -7969,18 +7974,19 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
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
@ -7995,20 +8001,20 @@ process_full_comp_unit (struct dwarf2_per_cu_data *per_cu,
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;
}
@ -8027,7 +8033,7 @@ process_full_type_unit (struct dwarf2_per_cu_data *per_cu,
{
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;
@ -8060,33 +8066,34 @@ process_full_type_unit (struct dwarf2_per_cu_data *per_cu,
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;
}
@ -9067,7 +9074,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
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
{
@ -9076,7 +9083,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu)
{
unsigned int macro_offset = DW_UNSND (attr);
dwarf_decode_macros (cu, macro_offset, comp_dir, 0);
dwarf_decode_macros (cu, macro_offset, 0);
}
}
@ -9116,7 +9123,7 @@ setup_type_unit_groups (struct die_info *die, struct dwarf2_cu *cu)
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. */
@ -9135,7 +9142,7 @@ setup_type_unit_groups (struct die_info *die, struct dwarf2_cu *cu)
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;
}
@ -9144,7 +9151,7 @@ setup_type_unit_groups (struct die_info *die, struct dwarf2_cu *cu)
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);
@ -9158,17 +9165,14 @@ setup_type_unit_groups (struct die_info *die, struct dwarf2_cu *cu)
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;
@ -17258,9 +17262,8 @@ dwarf_finish_line (struct gdbarch *gdbarch, struct subfile *subfile,
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;
@ -17619,9 +17622,8 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir,
{
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)
{
@ -17643,6 +17645,7 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir,
/* 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++)
@ -17655,15 +17658,11 @@ dwarf_decode_lines (struct line_header *lh, const char *comp_dir,
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;
}
}
@ -17719,11 +17718,13 @@ dwarf2_start_subfile (const char *filename, const char *dirname)
/* 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);
@ -17731,6 +17732,8 @@ dwarf2_start_symtab (struct dwarf2_cu *cu,
processing_gcc_compilation = 2;
cu->processing_has_namespace_info = 0;
return cust;
}
static void
@ -20365,8 +20368,7 @@ file_full_name (int file, struct line_header *lh, const char *comp_dir)
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);
@ -20375,7 +20377,7 @@ macro_start_file (int file, int line,
{
/* 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. */
@ -20753,7 +20755,7 @@ static void
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,
@ -20900,8 +20902,7 @@ dwarf_decode_macro_bytes (bfd *abfd,
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;
@ -20985,8 +20986,7 @@ dwarf_decode_macro_bytes (bfd *abfd,
*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);
@ -21024,7 +21024,7 @@ dwarf_decode_macro_bytes (bfd *abfd,
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;
@ -21143,8 +21143,7 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
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;
@ -21209,7 +21208,7 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
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);
}

View File

@ -1600,13 +1600,13 @@ select_frame (struct frame_info *fi)
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));
}
}
}

View File

@ -542,17 +542,19 @@ bkscm_print_block_syms_progress_smob (SCM self, SCM port,
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:
@ -675,30 +677,28 @@ gdbscm_lookup_block (SCM pc_scm)
{
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;
}

View File

@ -1817,14 +1817,15 @@ i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_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);
}
@ -2183,10 +2184,10 @@ static int
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))

View File

@ -5692,13 +5692,13 @@ static void
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);
@ -5771,13 +5771,13 @@ static void
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);

View File

@ -633,7 +633,7 @@ jit_symtab_close_impl (struct gdb_symbol_callbacks *cb,
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;
@ -643,9 +643,12 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
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)
@ -653,23 +656,19 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
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;
@ -698,7 +697,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
/* 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;
@ -737,7 +736,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
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

View File

@ -45,7 +45,7 @@ extern void _initialize_java_language (void);
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);
@ -129,11 +129,11 @@ get_dynamics_objfile (struct gdbarch *gdbarch)
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)
{
@ -141,13 +141,16 @@ get_java_class_symtab (struct gdbarch *gdbarch)
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);
@ -158,7 +161,7 @@ get_java_class_symtab (struct gdbarch *gdbarch)
/* 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. */
@ -171,9 +174,9 @@ get_java_class_symtab (struct gdbarch *gdbarch)
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);
}

View File

@ -1023,7 +1023,7 @@ iterate_over_all_matching_symtabs (struct linespec_state *state,
ALL_OBJFILES (objfile)
{
struct symtab *symtab;
struct compunit_symtab *cu;
if (objfile->sf)
objfile->sf->qf->expand_symtabs_matching (objfile, NULL,
@ -1031,8 +1031,10 @@ iterate_over_all_matching_symtabs (struct linespec_state *state,
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)

View File

@ -40,14 +40,17 @@ sal_macro_scope (struct symtab_and_line sal)
{
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)

View File

@ -47,9 +47,8 @@ struct macro_table
#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. */
@ -1049,7 +1048,7 @@ macro_for_each_in_scope (struct macro_source_file *file, int line,
struct macro_table *
new_macro_table (struct obstack *obstack, struct bcache *b,
const char *comp_dir)
struct compunit_symtab *cust)
{
struct macro_table *t;
@ -1063,7 +1062,7 @@ new_macro_table (struct obstack *obstack, struct bcache *b,
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,
@ -1092,8 +1091,13 @@ free_macro_table (struct macro_table *table)
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);
}

View File

@ -22,6 +22,7 @@
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
@ -154,8 +155,8 @@ struct macro_source_file
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
@ -168,7 +169,7 @@ struct macro_source_file
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,

View File

@ -794,8 +794,8 @@ struct cmd_stats
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;
};
@ -821,13 +821,14 @@ set_per_command_space (int new_value)
/* 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
@ -835,19 +836,17 @@ count_symtabs_and_blocks (int *nr_symtabs_ptr, int *nr_primary_symtabs_ptr,
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;
}
@ -902,16 +901,17 @@ report_command_stats (void *arg)
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);
}
@ -960,11 +960,11 @@ make_command_stats_cleanup (int msg_type)
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;
}

View File

@ -237,7 +237,7 @@ enum block_type { FUNCTION_BLOCK, NON_FUNCTION_BLOCK };
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);
@ -1922,7 +1922,7 @@ upgrade_type (int fd, struct type **tpp, int tq, union aux_ext *ax, int bigend,
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;
@ -1984,7 +1984,8 @@ parse_procedure (PDR *pr, struct symtab *search_symtab,
#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
@ -3929,7 +3930,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
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;
@ -4053,7 +4054,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
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;
}
@ -4117,7 +4118,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
if (! last_symtab_ended)
{
st = end_symtab (pst->texthigh, SECT_OFF_TEXT (objfile));
cust = end_symtab (pst->texthigh, SECT_OFF_TEXT (objfile));
end_stabs ();
}
@ -4161,7 +4162,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
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);
}
@ -4176,28 +4177,28 @@ psymtab_to_symtab_1 (struct objfile *objfile,
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;
@ -4271,7 +4272,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
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);
}
@ -4280,7 +4281,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
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)
@ -4290,7 +4291,7 @@ psymtab_to_symtab_1 (struct objfile *objfile,
/* .. 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);
@ -4307,7 +4308,8 @@ psymtab_to_symtab_1 (struct objfile *objfile,
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",
@ -4317,13 +4319,11 @@ psymtab_to_symtab_1 (struct objfile *objfile,
}
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;
}
@ -4726,13 +4726,17 @@ sort_blocks (struct symtab *s)
/* 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);
@ -4740,10 +4744,10 @@ new_symtab (const char *name, int maxlines, struct objfile *objfile)
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. */

View File

@ -55,7 +55,9 @@ mi_cmd_file_list_exec_source_file (char *command, char **argv, int argc)
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. */
@ -80,6 +82,7 @@ void
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;
@ -89,8 +92,8 @@ mi_cmd_file_list_exec_source_files (char *command, char **argv, int argc)
/* 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);

View File

@ -740,12 +740,12 @@ objfile_relocate1 (struct objfile *objfile,
/* 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. */
@ -753,17 +753,20 @@ objfile_relocate1 (struct objfile *objfile,
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)
{
@ -772,8 +775,8 @@ objfile_relocate1 (struct objfile *objfile,
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. */
@ -939,7 +942,7 @@ objfile_has_partial_symbols (struct objfile *objfile)
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

View File

@ -28,7 +28,6 @@
struct bcache;
struct htab;
struct symtab;
struct objfile_data;
/* This structure maintains information on a per-objfile basis about the
@ -286,11 +285,10 @@ struct objfile
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
@ -590,14 +588,14 @@ extern void default_iterate_over_objfiles_in_search_order
/* 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. */
@ -609,17 +607,15 @@ extern void default_iterate_over_objfiles_in_search_order
/* 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. */

View File

@ -192,10 +192,10 @@ struct partial_symtab
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. */

View File

@ -67,8 +67,8 @@ static struct partial_symbol *find_pc_sect_psymbol (struct objfile *,
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. */
@ -135,7 +135,7 @@ partial_map_expand_apply (struct objfile *objfile,
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. */
@ -150,7 +150,7 @@ partial_map_expand_apply (struct objfile *objfile,
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. */
@ -370,11 +370,12 @@ find_pc_sect_psymtab (struct objfile *objfile, CORE_ADDR pc,
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);
@ -388,7 +389,7 @@ find_pc_sect_symtab_from_partial (struct objfile *objfile,
(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;
}
@ -494,14 +495,14 @@ fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile)
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)
{
@ -509,11 +510,11 @@ lookup_symbol_aux_psymtabs (struct objfile *objfile,
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
@ -760,7 +761,7 @@ lookup_partial_symbol (struct objfile *objfile,
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
@ -769,8 +770,8 @@ psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
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)
@ -781,10 +782,7 @@ psymtab_to_symtab (struct objfile *objfile, struct partial_symtab *pst)
do_cleanups (back_to);
}
if (pst->symtab != NULL)
gdb_assert (pst->symtab->primary);
return pst->symtab;
return pst->compunit_symtab;
}
static void
@ -846,7 +844,13 @@ find_last_source_symtab_from_partial (struct objfile *ofp)
"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;
}
@ -986,7 +990,7 @@ dump_psymtab (struct objfile *objfile, struct partial_symtab *psymtab,
{
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");
@ -1261,12 +1265,12 @@ map_matching_symbols_psymtab (struct objfile *objfile,
|| 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;
@ -1436,7 +1440,7 @@ const struct quick_symbol_functions psym_functions =
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
};
@ -1748,7 +1752,7 @@ allocate_psymtab (const char *filename, struct objfile *objfile)
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
@ -2005,7 +2009,7 @@ maintenance_check_psymtabs (char *ignore, int from_tty)
{
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;
@ -2019,7 +2023,7 @@ maintenance_check_psymtabs (char *ignore, int from_tty)
/* 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)
@ -2035,9 +2039,9 @@ maintenance_check_psymtabs (char *ignore, int from_tty)
}
/* 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;

View File

@ -372,8 +372,7 @@ gdbpy_block_for_pc (PyObject *self, PyObject *args)
{
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))
@ -381,15 +380,14 @@ gdbpy_block_for_pc (PyObject *self, PyObject *args)
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."));
@ -397,7 +395,7 @@ gdbpy_block_for_pc (PyObject *self, PyObject *args)
}
if (block)
return block_to_block_object (block, SYMTAB_OBJFILE (symtab));
return block_to_block_object (block, COMPUNIT_OBJFILE (cust));
Py_RETURN_NONE;
}

View File

@ -132,11 +132,13 @@ static PyObject *
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);

View File

@ -259,6 +259,7 @@ select_source_symtab (struct symtab *s)
struct symtabs_and_lines sals;
struct symtab_and_line sal;
struct objfile *ofp;
struct compunit_symtab *cu;
if (s)
{
@ -291,7 +292,7 @@ select_source_symtab (struct symtab *s)
current_source_line = 1;
ALL_SYMTABS (ofp, s)
ALL_FILETABS (ofp, cu, s)
{
const char *name = s->filename;
int len = strlen (name);
@ -369,9 +370,10 @@ show_directories_command (struct ui_file *file, int from_tty,
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)
{
@ -668,9 +670,11 @@ source_info (char *ignore, int from_tty)
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");
}

View File

@ -1953,7 +1953,7 @@ static void
spu_catch_start (struct objfile *objfile)
{
struct bound_minimal_symbol minsym;
struct symtab *symtab;
struct compunit_symtab *cust;
CORE_ADDR pc;
char buf[32];
@ -1978,11 +1978,12 @@ spu_catch_start (struct objfile *objfile)
/* 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;

View File

@ -2569,7 +2569,6 @@ get_frame_language (void)
{
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
@ -2591,9 +2590,10 @@ get_frame_language (void)
}
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);
}
}

View File

@ -151,13 +151,13 @@ debug_qf_map_symtabs_matching_filename (struct objfile *objfile,
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",
@ -168,7 +168,9 @@ debug_qf_lookup_symbol (struct objfile *objfile, int kind, const char *name,
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;
}
@ -306,31 +308,35 @@ debug_qf_expand_symtabs_matching
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;
}
@ -368,7 +374,7 @@ static const struct quick_symbol_functions debug_sym_quick_functions =
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
};

View File

@ -2641,7 +2641,7 @@ reread_symbols (void)
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;
@ -2918,38 +2918,20 @@ deduce_language_from_filename (const char *filename)
return language_unknown;
}
/* 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. */
@ -2973,7 +2955,64 @@ allocate_symtab (const char *filename, struct objfile *objfile)
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;
}

View File

@ -193,13 +193,13 @@ struct quick_symbol_functions
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
@ -285,17 +285,15 @@ struct quick_symbol_functions
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
@ -418,9 +416,15 @@ extern struct symfile_segment_data *default_symfile_segments (bfd *abfd);
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

View File

@ -97,6 +97,7 @@ print_objfile_statistics (void)
{
struct program_space *pspace;
struct objfile *objfile;
struct compunit_symtab *cu;
struct symtab *s;
int i, linetables, blockvectors;
@ -123,14 +124,14 @@ print_objfile_statistics (void)
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);
@ -159,6 +160,7 @@ print_objfile_statistics (void)
static void
dump_objfile (struct objfile *objfile)
{
struct compunit_symtab *cust;
struct symtab *symtab;
printf_filtered ("\nObject file %s: ", objfile_name (objfile));
@ -172,12 +174,10 @@ dump_objfile (struct objfile *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);
@ -320,9 +320,9 @@ dump_symtab_1 (struct objfile *objfile, struct symtab *symtab,
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);
@ -413,6 +413,7 @@ maintenance_print_symbols (char *args, int from_tty)
char *symname = NULL;
char *filename = DEV_TTY;
struct objfile *objfile;
struct compunit_symtab *cu;
struct symtab *s;
dont_repeat ();
@ -443,7 +444,7 @@ maintenance_print_symbols (char *args, int from_tty)
perror_with_name (filename);
make_cleanup_ui_file_delete (outfile);
ALL_SYMTABS (objfile, s)
ALL_FILETABS (objfile, cu, s)
{
QUIT;
if (symname == NULL
@ -725,50 +726,71 @@ maintenance_info_symtabs (char *regexp, int from_tty)
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)
{
printf_filtered ("{ objfile %s ", objfile_name (objfile));
wrap_here (" ");
printf_filtered ("((struct objfile *) %s)\n",
host_address_to_string (objfile));
printed_objfile_start = 1;
}
QUIT;
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 (! regexp
|| re_exec (symtab_to_filename_for_display (symtab)))
{
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");
}
}
if (printed_compunit_symtab_start)
printf_filtered (" }\n");
}
if (printed_objfile_start)
@ -793,19 +815,20 @@ maintenance_check_symtabs (char *ignore, int from_tty)
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. */
@ -821,7 +844,7 @@ maintenance_check_symtabs (char *ignore, int from_tty)
}
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");
}

View File

@ -173,20 +173,27 @@ search_domain_name (enum search_domain e)
}
}
/* 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
@ -237,8 +244,9 @@ compare_filenames_for_search (const char *filename, const char *search_name)
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
@ -247,48 +255,52 @@ iterate_over_some_symtabs (const char *name,
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 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 (compare_filenames_for_search (s->filename, name))
{
if (callback (s, data))
return 1;
continue;
}
/* Before we invoke realpath, which can get expensive when many
files are involved, do a quick comparison of the basenames. */
if (! basenames_may_differ
&& FILENAME_CMP (base_name, lbasename (s->filename)) != 0)
continue;
if (compare_filenames_for_search (symtab_to_fullname (s), name))
{
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;
}
}
}
}
@ -324,7 +336,7 @@ iterate_over_symtabs (const char *name,
ALL_OBJFILES (objfile)
{
if (iterate_over_some_symtabs (name, real_path, callback, data,
objfile->symtabs, NULL))
objfile->compunit_symtabs, NULL))
{
do_cleanups (cleanups);
return;
@ -1067,12 +1079,12 @@ expand_symtab_containing_pc (CORE_ADDR pc, struct obj_section *section)
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;
}
}
@ -1516,17 +1528,16 @@ struct objfile *
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;
@ -1563,19 +1574,21 @@ lookup_global_symbol_from_objfile (const struct objfile *main_objfile,
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)
@ -1603,14 +1616,15 @@ static struct symbol *
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)
@ -1670,14 +1684,16 @@ lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile,
static void ATTRIBUTE_NORETURN
error_in_psymtab_expansion (int block_index, const char *name,
struct symtab *symtab)
struct compunit_symtab *cust)
{
error (_("\
Internal: %s symbol `%s' found in %s psymtab but not in symtab.\n\
%s may be an inlined function, or may be a template function\n \
(if a template, try specifying an instantiation: %s<type>)."),
block_index == GLOBAL_BLOCK ? "global" : "static",
name, symtab_to_filename_for_display (symtab), name, name);
name,
symtab_to_filename_for_display (compunit_primary_filetab (cust)),
name, name);
}
/* A helper function for various lookup routines that interfaces with
@ -1687,22 +1703,22 @@ static struct symbol *
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);
}
@ -1911,23 +1927,23 @@ static struct type *
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);
@ -1945,7 +1961,7 @@ struct type *
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;
@ -1958,9 +1974,9 @@ basic_lookup_transparent_type (const char *name)
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)))
@ -1986,9 +2002,9 @@ basic_lookup_transparent_type (const char *name)
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)))
@ -2036,16 +2052,14 @@ iterate_over_symbols (const struct block *block, const char *name,
}
}
/* 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;
@ -2079,9 +2093,12 @@ find_pc_sect_symtab (CORE_ADDR pc, struct obj_section *section)
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
@ -2097,14 +2114,14 @@ find_pc_sect_symtab (CORE_ADDR pc, struct obj_section *section)
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)
@ -2124,39 +2141,40 @@ find_pc_sect_symtab (CORE_ADDR pc, struct obj_section *section)
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));
}
@ -2180,7 +2198,8 @@ find_pc_symtab (CORE_ADDR pc)
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;
@ -2188,7 +2207,6 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
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. */
@ -2306,8 +2324,8 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
}
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)
@ -2316,20 +2334,16 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int 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;
@ -2373,7 +2387,7 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
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)
@ -2487,6 +2501,7 @@ find_line_symtab (struct symtab *symtab, int line,
int best;
struct objfile *objfile;
struct compunit_symtab *cu;
struct symtab *s;
if (best_index >= 0)
@ -2501,7 +2516,7 @@ find_line_symtab (struct symtab *symtab, int line,
symtab_to_fullname (symtab));
}
ALL_SYMTABS (objfile, s)
ALL_FILETABS (objfile, cu, s)
{
struct linetable *l;
int ind;
@ -2849,7 +2864,7 @@ skip_prologue_sal (struct symtab_and_line *sal)
/* 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;
@ -3336,6 +3351,7 @@ output_partial_symbol_filename (const char *filename, const char *fullname,
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;
@ -3353,7 +3369,7 @@ sources_info (char *ignore, int from_tty)
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);
@ -3551,7 +3567,7 @@ search_symbols (const char *regexp, enum search_domain kind,
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;
@ -3691,10 +3707,10 @@ search_symbols (const char *regexp, enum search_domain kind,
{
/* 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))
@ -3709,9 +3725,9 @@ search_symbols (const char *regexp, enum search_domain kind,
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);
@ -3796,8 +3812,8 @@ search_symbols (const char *regexp, enum search_domain kind,
/* 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)
@ -4349,7 +4365,7 @@ default_make_symbol_completion_list_break_on (const char *text,
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;
@ -4515,10 +4531,10 @@ default_make_symbol_completion_list_break_on (const char *text,
/* 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
@ -4528,10 +4544,10 @@ default_make_symbol_completion_list_break_on (const char *text,
}
}
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
@ -4808,6 +4824,7 @@ maybe_add_partial_symtab_filename (const char *filename, const char *fullname,
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);
@ -4826,7 +4843,7 @@ make_source_files_completion_list (const char *text, const char *word)
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;

View File

@ -870,6 +870,7 @@ struct section_offsets
+ 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
@ -878,52 +879,19 @@ 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;
@ -938,60 +906,170 @@ struct symtab
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
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. */
const char *producer;
/* Full name of file as found by searching the source path.
NULL if not yet known. */
char *fullname;
/* Object file from which this symbol information was read. */
struct objfile *objfile;
/* struct call_site entries for this compilation unit or NULL. */
htab_t call_site_htab;
/* 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
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;
/* 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
included by another. */
struct symtab *user;
};
#define SYMTAB_BLOCKVECTOR(symtab) ((symtab)->blockvector)
#define SYMTAB_COMPUNIT(symtab) ((symtab)->compunit_symtab)
#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)
/* Call this to set the "primary" field in struct symtab. */
extern void set_symtab_primary (struct symtab *, int primary);
#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, or NULL if we don't know. */
const char *producer;
/* Directory in which it was compiled, or NULL if we don't know. */
const char *dirname;
/* List of all symbol scope blocks for this symtab. It is shared among
all symtabs in a given compilation unit. */
const struct blockvector *blockvector;
/* Section in objfile->section_offsets for the blockvector and
the linetable. Probably always SECT_OFF_TEXT. */
int block_line_section;
/* 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;
/* 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 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 compunits. */
struct compunit_symtab **includes;
/* 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 compunit_symtab *user;
};
#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)
/* Iterate over all file tables (struct symtab) within a compunit. */
#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);
/* The virtual function table is now an array of structures which have the
@ -1171,11 +1249,12 @@ extern void expand_symtab_containing_pc (CORE_ADDR, struct obj_section *);
/* 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 *);
@ -1432,8 +1511,8 @@ int iterate_over_some_symtabs (const char *name,
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,

View File

@ -1,3 +1,7 @@
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

View File

@ -72,7 +72,7 @@ gdb_test "maint print registers" "Name.*Nr.*Rel.*Offset.*Size.*Type.*"
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
@ -133,7 +133,7 @@ gdb_test_no_output "maint check-symtabs"
# 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" \

View File

@ -1136,8 +1136,8 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
{
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 ();
}
@ -1194,8 +1194,7 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
{
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
@ -1504,17 +1503,17 @@ read_xcoff_symtab (struct objfile *objfile, struct partial_symtab *pst)
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 ();
}
}
@ -2107,7 +2106,7 @@ xcoff_end_psymtab (struct objfile *objfile, struct partial_symtab *pst,
subpst->n_static_syms = 0;
subpst->readin = 0;
subpst->symtab = 0;
subpst->compunit_symtab = NULL;
subpst->read_symtab = pst->read_symtab;
}