1999-04-16 09:35:26 +08:00
|
|
|
|
/* Build symbol tables in GDB's internal format.
|
2019-01-01 14:01:51 +08:00
|
|
|
|
Copyright (C) 1986-2019 Free Software Foundation, Inc.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-24 02:08:50 +08:00
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
1999-07-08 04:19:36 +08:00
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-24 02:08:50 +08:00
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
|
|
#if !defined (BUILDSYM_H)
|
|
|
|
|
#define BUILDSYM_H 1
|
|
|
|
|
|
2003-04-12 Andrew Cagney <cagney@redhat.com>
* gdbarch.sh: Add missing opaque declarations.
* gdbarch.h: Regnerate.
* symtab.h: Add missing opaque declarations.
* value.h, target.h, symfile.h, stabsread.h: Ditto.
* x86-64-tdep.h, xmodem.h, monitor.h, typeprint.h: Ditto.
* srec.h, solib-svr4.h, source.h, inferior.h: Ditto.
* ser-unix.h, serial.h, remote-utils.h, gdbcore.h: Ditto.
* ppc-tdep.h, ocd.h, mips-tdep.h, gdbtypes.h: Ditto.
* buildsym.h, builtin-regs.h, linespec.h, language.h: Ditto.
* i387-tdep.h, gdbthread.h, event-top.h, gdb.h: Ditto.
* dwarf2cfi.h, doublest.h, disasm.h, cp-abi.h: Ditto.
* cli-out.h, c-lang.h, ax-gdb.h, arch-utils.h: Ditto.
* ada-lang.h, config/nm-lynx.h, config/nm-linux.h: Ditto.
* config/sparc/tm-sp64.h, config/rs6000/tm-rs6000.h: Ditto.
* config/pa/tm-hppah.h, config/m68k/tm-delta68.h: Ditto.
* cli/cli-setshow.h, cli/cli-script.h: Ditto.
2003-04-13 01:41:26 +08:00
|
|
|
|
struct objfile;
|
|
|
|
|
struct symbol;
|
Support lexical blocks and function bodies that occupy
non-contiguous address ranges.
* addrmap.c, addrmap.h: New files.
* block.h (struct addrmap): New forward declaration.
(struct blockvector): New member, 'map'.
(BLOCKVECTOR_MAP): New accessor macro.
* block.c: #include "addrmap.h"
(blockvector_for_pc_sect): If the blockvector we've found has
an address map, use it instead of searching the blocks.
* buildsym.c: #include "addrmap.h"
(pending_addrmap_obstack, pending_addrmap_interesting): New static
variables.
(really_free_pendings): If we have a pending addrmap, free it too.
(record_block_range): New function.
(make_blockvector): If we have an interesting pending addrmap,
record it in the new blockvector.
(start_symtab, buildsym_init): Assert that there is no pending
addrmap now; we should have cleaned up any addrmaps we'd built
previously.
(end_symtab): If there is a pending addrmap left over that didn't
get included in the blockvector, free it.
* buildsym.h (struct addrmap): New forward declaration.
(record_block_range): New prototype.
* objfiles.c: #include "addrmap.h".
(objfile_relocate): Relocate the blockvector's address map, if
present.
* dwarf2read.c (dwarf2_record_block_ranges): New function.
(read_func_scope, read_lexical_block_scope): Call it.
* Makefile.in (SFILES): Add addrmap.c.
(addrmap_h): New header dependency variable.
(COMMON_OBS): Add addrmap.o.
(addrmap.o): New rule.l
(block.o, objfiles.o, buildsym.o): Depend on $(addrmap_h).
* block.c (blockvector_for_pc, blockvector_for_pc_sect): Return a
pointer to the block, not its index in the blockvector.
(block_for_pc_sect): Use the returned block, instead of looking it
up ourselves.
* block.h (blockvector_for_pc, blockvector_for_pc_sect): Update
declarations.
* breakpoint.c (resolve_sal_pc): Use returned block, instead of
looking it up ourselves.
* stack.c (print_frame_label_vars): Disable function, which
depends on the block's index.
* buildsym.c (finish_block): Return the block we've built.
* buildsym.h (finish_block): Update prototype.
* defs.h (CORE_ADDR_MAX): New constant.
2007-12-05 07:43:57 +08:00
|
|
|
|
struct addrmap;
|
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.
2014-11-20 23:42:48 +08:00
|
|
|
|
struct compunit_symtab;
|
Per-language symbol name hashing algorithm
Currently, we have a mess of symbol name hashing/comparison routines.
There's msymbol_hash for mangled names, and dict_hash and
msymbol_hash_iw for demangled names. Then there's strcmp_iw,
strcmp_iw_ordered and Ada's full_match/wild_match, which all have to
agree with the hashing routines. That's why dict_hash is really about
Ada names. From the inconsistency department, minimal symbol hashing
doesn't go via dict_hash, so Ada's wild matching can't ever work with
minimal symbols.
This patch starts fixing this, by doing two things:
#1 - adds a language vector method to let each language decide how to
compute a symbol name hash.
#2 - makes dictionaries know the language of the symbols they hold,
and then use the dictionaries language to decide which hashing
method to use.
For now, this is just scaffolding, since all languages install the
default method. The series will make C++ install its own hashing
method later on, and will add per-language symbol name comparison
routines too.
This patch was originally based on a patch that Keith wrote for the
libcc1/C++ WIP support.
gdb/ChangeLog:
2017-11-08 Keith Seitz <keiths@redhat.com>
Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_language_defn): Install
default_search_name_hash.
* buildsym.c (struct buildsym_compunit): <language>: New field.
(finish_block_internal): Pass language when creating dictionaries.
(start_buildsym_compunit, start_symtab): New language parameters.
Use them.
(restart_symtab): Pass down compilation unit's language.
* buildsym.h (enum language): Forward declare.
(start_symtab): New 'language' parameter.
* c-lang.c (c_language_defn, cplus_language_defn)
(asm_language_defn, minimal_language_defn): Install
default_search_name_hash.
* coffread.c (coff_start_symtab): Adjust.
* d-lang.c (d_language_defn): Install default_search_name_hash.
* dbxread.c (struct symloc): Add 'pst_language' field.
(PST_LANGUAGE): Define.
(start_psymtab, read_ofile_symtab): Use it.
(process_one_symbol): New 'language' parameter. Pass it down.
* dictionary.c (struct dictionary) <language>: New field.
(DICT_LANGUAGE): Define.
(dict_create_hashed, dict_create_hashed_expandable)
(dict_create_linear, dict_create_linear_expandable): New parameter
'language'. Set the dictionary's language.
(iter_match_first_hashed): Adjust to rename.
(insert_symbol_hashed): Assert we don't see mismatching
languages. Adjust to rename.
(dict_hash): Rename to ...
(default_search_name_hash): ... this and make extern.
* dictionary.h (struct language_defn): Forward declare.
(dict_create_hashed): New parameter 'language'.
* dwarf2read.c (dwarf2_start_symtab): Pass down language.
* f-lang.c (f_language_defn): Install default_search_name_hash.
* go-lang.c (go_language_defn): Install default_search_name_hash.
* jit.c (finalize_symtab): Pass compunit's language to dictionary
creation.
* language.c (unknown_language_defn, auto_language_defn):
* language.h (language_defn::la_search_name_hash): New field.
(default_search_name_hash): Declare.
* m2-lang.c (m2_language_defn): Install default_search_name_hash.
* mdebugread.c (new_block): New parameter 'language'.
* mdebugread.c (parse_symbol): Pass symbol language to block
allocation.
(psymtab_to_symtab_1): Pass down language.
(new_symtab): Pass compunit's language to block allocation.
* objc-lang.c (objc_language_defn): Install
default_search_name_hash.
* opencl-lang.c (opencl_language_defn):
* p-lang.c (pascal_language_defn): Install
default_search_name_hash.
* rust-lang.c (rust_language_defn): Install
default_search_name_hash.
* stabsread.h (enum language): Forward declare.
(process_one_symbol): Add 'language' parameter.
* symtab.c (search_name_hash): New function.
* symtab.h (search_name_hash): Declare.
* xcoffread.c (read_xcoff_symtab): Pass language to start_symtab.
2017-11-08 23:07:56 +08:00
|
|
|
|
enum language;
|
2003-04-12 Andrew Cagney <cagney@redhat.com>
* gdbarch.sh: Add missing opaque declarations.
* gdbarch.h: Regnerate.
* symtab.h: Add missing opaque declarations.
* value.h, target.h, symfile.h, stabsread.h: Ditto.
* x86-64-tdep.h, xmodem.h, monitor.h, typeprint.h: Ditto.
* srec.h, solib-svr4.h, source.h, inferior.h: Ditto.
* ser-unix.h, serial.h, remote-utils.h, gdbcore.h: Ditto.
* ppc-tdep.h, ocd.h, mips-tdep.h, gdbtypes.h: Ditto.
* buildsym.h, builtin-regs.h, linespec.h, language.h: Ditto.
* i387-tdep.h, gdbthread.h, event-top.h, gdb.h: Ditto.
* dwarf2cfi.h, doublest.h, disasm.h, cp-abi.h: Ditto.
* cli-out.h, c-lang.h, ax-gdb.h, arch-utils.h: Ditto.
* ada-lang.h, config/nm-lynx.h, config/nm-linux.h: Ditto.
* config/sparc/tm-sp64.h, config/rs6000/tm-rs6000.h: Ditto.
* config/pa/tm-hppah.h, config/m68k/tm-delta68.h: Ditto.
* cli/cli-setshow.h, cli/cli-script.h: Ditto.
2003-04-13 01:41:26 +08:00
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
|
/* This module provides definitions used for creating and adding to
|
|
|
|
|
the symbol table. These routines are called from various symbol-
|
|
|
|
|
file-reading routines.
|
|
|
|
|
|
|
|
|
|
They originated in dbxread.c of gdb-4.2, and were split out to
|
2018-05-21 23:21:18 +08:00
|
|
|
|
make xcoffread.c more maintainable by sharing code. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
2003-02-19 David Carlton <carlton@math.stanford.edu>
* Makefile.in (SFILES): Add block.c.
(block_h): New.
(COMMON_OBS): Add block.o.
(block.o): New.
(x86-64-tdep.o): Add $(block_h).
(values.o, valops.o, tracepoint.o, symtab.o, symmisc.o, symfile.o)
(stack.o, printcmd.o, p-exp.tab.o, parse.o, objfiles.o)
(objc-exp.tab.o, objc-lang.o, nlmread.o, mips-tdep.o, mdebugread.o)
(m2-exp.tab.o, linespec.o, jv-lang.o, jv-exp.tab.o, infcmd.o)
(f-valprint.o, findvar.o, f-exp.tab.o, expprint.o, coffread.o)
(c-exp.tab.o, buildsym.o, breakpoint.o, blockframe.o, ax-gdb.o)
(alpha-tdep.o, ada-lang.o, ada-exp.tab.o, mi-cmd-stack.o): Ditto.
* value.h: Add opaque declaration for struct block.
* parser-defs.h, objc-lang.h, buildsym.h, breakpoint.h: Ditto.
* ada-lang.h: Ditto.
* x86-64-tdep.c: #include "block.h"
* values.c, valops.c, tracepoint.c, symtab.c, symmisc.c: Ditto.
* symfile.c, stack.c, printcmd.c, p-exp.y, parse.c: Ditto.
* objfiles.c, objc-exp.y, objc-lang.c, nlmread.c: Ditto.
* mips-tdep.c, mdebugread.c, m2-exp.y, linespec.c: Ditto.
* jv-lang.c, jv-exp.y, infcmd.c, f-valprint.c: Ditto.
* findvar.c, f-exp.y, expprint.c, coffread.c, c-exp.y: Ditto.
* buildsym.c, breakpoint.c, blockframe.c, ax-gdb.c: Ditto.
* alpha-tdep.c, ada-lang.c, ada-exp.y: Ditto.
* blockframe.c (blockvector_for_pc_sect): Move to "block.c".
(blockvector_for_pc, block_for_pc_sect, block_for_pc): Ditto.
* symtab.c (block_function): Ditto.
(contained_in): Ditto.
* frame.h: Move block_for_pc and block_for_pc_sect declarations to
block.h. Add opaque declaration for struct block.
* symtab.h: Move block_function and contained_in declarations to
block.h. Add opaque declarations for struct block, struct
blockvector.
(struct block): Move to block.h.
(struct blockvector): Ditto.
(BLOCK_START, BLOCK_END, BLOCK_FUNCTION, BLOCK_SUPERBLOCK)
(BLOCK_GCC_COMPILED, BLOCK_HASHTABLE, BLOCK_NSYMS, BLOCK_SYM)
(BLOCK_BUCKETS, BLOCK_BUCKET, BLOCK_HASHTABLE_SIZE)
(ALL_BLOCK_SYMBOLS, BLOCK_SHOULD_SORT, BLOCKVECTOR_NBLOCKS)
(BLOCKVECTOR_BLOCK, GLOBAL_BLOCK, STATIC_BLOCK, FIRST_LOCAL_BLOCK):
Ditto.
* block.c: New file.
* block.h: New file.
2003-02-19 David Carlton <carlton@math.stanford.edu>
* mi-cmd-stack.c: #include "block.h"
2003-02-20 08:01:07 +08:00
|
|
|
|
struct block;
|
2012-12-11 01:09:29 +08:00
|
|
|
|
struct pending_block;
|
2003-02-19 David Carlton <carlton@math.stanford.edu>
* Makefile.in (SFILES): Add block.c.
(block_h): New.
(COMMON_OBS): Add block.o.
(block.o): New.
(x86-64-tdep.o): Add $(block_h).
(values.o, valops.o, tracepoint.o, symtab.o, symmisc.o, symfile.o)
(stack.o, printcmd.o, p-exp.tab.o, parse.o, objfiles.o)
(objc-exp.tab.o, objc-lang.o, nlmread.o, mips-tdep.o, mdebugread.o)
(m2-exp.tab.o, linespec.o, jv-lang.o, jv-exp.tab.o, infcmd.o)
(f-valprint.o, findvar.o, f-exp.tab.o, expprint.o, coffread.o)
(c-exp.tab.o, buildsym.o, breakpoint.o, blockframe.o, ax-gdb.o)
(alpha-tdep.o, ada-lang.o, ada-exp.tab.o, mi-cmd-stack.o): Ditto.
* value.h: Add opaque declaration for struct block.
* parser-defs.h, objc-lang.h, buildsym.h, breakpoint.h: Ditto.
* ada-lang.h: Ditto.
* x86-64-tdep.c: #include "block.h"
* values.c, valops.c, tracepoint.c, symtab.c, symmisc.c: Ditto.
* symfile.c, stack.c, printcmd.c, p-exp.y, parse.c: Ditto.
* objfiles.c, objc-exp.y, objc-lang.c, nlmread.c: Ditto.
* mips-tdep.c, mdebugread.c, m2-exp.y, linespec.c: Ditto.
* jv-lang.c, jv-exp.y, infcmd.c, f-valprint.c: Ditto.
* findvar.c, f-exp.y, expprint.c, coffread.c, c-exp.y: Ditto.
* buildsym.c, breakpoint.c, blockframe.c, ax-gdb.c: Ditto.
* alpha-tdep.c, ada-lang.c, ada-exp.y: Ditto.
* blockframe.c (blockvector_for_pc_sect): Move to "block.c".
(blockvector_for_pc, block_for_pc_sect, block_for_pc): Ditto.
* symtab.c (block_function): Ditto.
(contained_in): Ditto.
* frame.h: Move block_for_pc and block_for_pc_sect declarations to
block.h. Add opaque declaration for struct block.
* symtab.h: Move block_function and contained_in declarations to
block.h. Add opaque declarations for struct block, struct
blockvector.
(struct block): Move to block.h.
(struct blockvector): Ditto.
(BLOCK_START, BLOCK_END, BLOCK_FUNCTION, BLOCK_SUPERBLOCK)
(BLOCK_GCC_COMPILED, BLOCK_HASHTABLE, BLOCK_NSYMS, BLOCK_SYM)
(BLOCK_BUCKETS, BLOCK_BUCKET, BLOCK_HASHTABLE_SIZE)
(ALL_BLOCK_SYMBOLS, BLOCK_SHOULD_SORT, BLOCKVECTOR_NBLOCKS)
(BLOCKVECTOR_BLOCK, GLOBAL_BLOCK, STATIC_BLOCK, FIRST_LOCAL_BLOCK):
Ditto.
* block.c: New file.
* block.h: New file.
2003-02-19 David Carlton <carlton@math.stanford.edu>
* mi-cmd-stack.c: #include "block.h"
2003-02-20 08:01:07 +08:00
|
|
|
|
|
2015-02-06 00:00:06 +08:00
|
|
|
|
struct dynamic_prop;
|
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
|
/* The list of sub-source-files within the current individual
|
|
|
|
|
compilation. Each file gets its own symtab with its own linetable
|
|
|
|
|
and associated info, but they all share one blockvector. */
|
|
|
|
|
|
|
|
|
|
struct subfile
|
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.
2014-11-20 23:42:48 +08:00
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
};
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
|
|
/* Record the symbols defined for each context in a list. We don't
|
|
|
|
|
create a struct block for the context until we know how long to
|
|
|
|
|
make it. */
|
|
|
|
|
|
|
|
|
|
#define PENDINGSIZE 100
|
|
|
|
|
|
|
|
|
|
struct pending
|
|
|
|
|
{
|
|
|
|
|
struct pending *next;
|
|
|
|
|
int nsyms;
|
|
|
|
|
struct symbol *symbol[PENDINGSIZE];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Stack representing unclosed lexical contexts (that will become
|
|
|
|
|
blocks, eventually). */
|
|
|
|
|
|
|
|
|
|
struct context_stack
|
|
|
|
|
{
|
|
|
|
|
/* Outer locals at the time we entered */
|
|
|
|
|
|
|
|
|
|
struct pending *locals;
|
|
|
|
|
|
2009-06-24 01:46:52 +08:00
|
|
|
|
/* Pending using directives at the time we entered. */
|
|
|
|
|
|
2015-07-22 21:30:57 +08:00
|
|
|
|
struct using_direct *local_using_directives;
|
2009-06-24 01:46:52 +08:00
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
|
/* Pointer into blocklist as of entry */
|
|
|
|
|
|
|
|
|
|
struct pending_block *old_blocks;
|
|
|
|
|
|
|
|
|
|
/* Name of function, if any, defining context */
|
|
|
|
|
|
|
|
|
|
struct symbol *name;
|
|
|
|
|
|
2015-02-06 00:00:06 +08:00
|
|
|
|
/* Expression that computes the frame base of the lexically enclosing
|
|
|
|
|
function, if any. NULL otherwise. */
|
|
|
|
|
|
|
|
|
|
struct dynamic_prop *static_link;
|
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
|
/* PC where this context starts */
|
|
|
|
|
|
|
|
|
|
CORE_ADDR start_addr;
|
|
|
|
|
|
2011-01-01 03:16:37 +08:00
|
|
|
|
/* Temp slot for exception handling. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
|
|
CORE_ADDR end_addr;
|
|
|
|
|
|
|
|
|
|
/* For error-checking matching push/pop */
|
|
|
|
|
|
|
|
|
|
int depth;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2018-05-23 04:27:43 +08:00
|
|
|
|
/* Buildsym's counterpart to struct compunit_symtab. */
|
|
|
|
|
|
|
|
|
|
struct buildsym_compunit
|
|
|
|
|
{
|
|
|
|
|
/* 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). */
|
|
|
|
|
|
|
|
|
|
buildsym_compunit (struct objfile *objfile_, const char *name,
|
|
|
|
|
const char *comp_dir_, enum language language_,
|
|
|
|
|
CORE_ADDR last_addr);
|
|
|
|
|
|
|
|
|
|
/* Reopen an existing compunit_symtab so that additional symbols can
|
|
|
|
|
be added to it. Arguments are as for the main constructor. CUST
|
|
|
|
|
is the expandable compunit_symtab to be reopened. */
|
|
|
|
|
|
|
|
|
|
buildsym_compunit (struct objfile *objfile_, const char *name,
|
|
|
|
|
const char *comp_dir_, enum language language_,
|
|
|
|
|
CORE_ADDR last_addr, struct compunit_symtab *cust)
|
2018-07-09 00:19:10 +08:00
|
|
|
|
: m_objfile (objfile_),
|
2018-05-23 04:27:43 +08:00
|
|
|
|
m_last_source_file (name == nullptr ? nullptr : xstrdup (name)),
|
2018-07-09 00:19:10 +08:00
|
|
|
|
m_comp_dir (comp_dir_ == nullptr ? nullptr : xstrdup (comp_dir_)),
|
|
|
|
|
m_compunit_symtab (cust),
|
|
|
|
|
m_language (language_),
|
2018-05-23 04:27:43 +08:00
|
|
|
|
m_last_source_start_addr (last_addr)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~buildsym_compunit ();
|
|
|
|
|
|
|
|
|
|
DISABLE_COPY_AND_ASSIGN (buildsym_compunit);
|
|
|
|
|
|
|
|
|
|
void set_last_source_file (const char *name)
|
|
|
|
|
{
|
|
|
|
|
char *new_name = name == NULL ? NULL : xstrdup (name);
|
|
|
|
|
m_last_source_file.reset (new_name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *get_last_source_file ()
|
|
|
|
|
{
|
|
|
|
|
return m_last_source_file.get ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct macro_table *get_macro_table ();
|
|
|
|
|
|
|
|
|
|
struct macro_table *release_macros ()
|
|
|
|
|
{
|
|
|
|
|
struct macro_table *result = m_pending_macros;
|
|
|
|
|
m_pending_macros = nullptr;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* This function is called to discard any pending blocks. */
|
|
|
|
|
|
|
|
|
|
void free_pending_blocks ()
|
|
|
|
|
{
|
|
|
|
|
m_pending_block_obstack.clear ();
|
|
|
|
|
m_pending_blocks = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct block *finish_block (struct symbol *symbol,
|
|
|
|
|
struct pending_block *old_blocks,
|
|
|
|
|
const struct dynamic_prop *static_link,
|
|
|
|
|
CORE_ADDR start, CORE_ADDR end);
|
|
|
|
|
|
|
|
|
|
void record_block_range (struct block *block,
|
|
|
|
|
CORE_ADDR start, CORE_ADDR end_inclusive);
|
|
|
|
|
|
|
|
|
|
void start_subfile (const char *name);
|
|
|
|
|
|
|
|
|
|
void patch_subfile_names (struct subfile *subfile, const char *name);
|
|
|
|
|
|
|
|
|
|
void push_subfile ();
|
|
|
|
|
|
|
|
|
|
const char *pop_subfile ();
|
|
|
|
|
|
|
|
|
|
void record_line (struct subfile *subfile, int line, CORE_ADDR pc);
|
|
|
|
|
|
|
|
|
|
struct compunit_symtab *get_compunit_symtab ()
|
|
|
|
|
{
|
2018-07-09 00:19:10 +08:00
|
|
|
|
return m_compunit_symtab;
|
2018-05-23 04:27:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void set_last_source_start_addr (CORE_ADDR addr)
|
|
|
|
|
{
|
|
|
|
|
m_last_source_start_addr = addr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CORE_ADDR get_last_source_start_addr ()
|
|
|
|
|
{
|
|
|
|
|
return m_last_source_start_addr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct using_direct **get_local_using_directives ()
|
|
|
|
|
{
|
|
|
|
|
return &m_local_using_directives;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void set_local_using_directives (struct using_direct *new_local)
|
|
|
|
|
{
|
|
|
|
|
m_local_using_directives = new_local;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct using_direct **get_global_using_directives ()
|
|
|
|
|
{
|
|
|
|
|
return &m_global_using_directives;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool outermost_context_p () const
|
|
|
|
|
{
|
|
|
|
|
return m_context_stack.empty ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct context_stack *get_current_context_stack ()
|
|
|
|
|
{
|
|
|
|
|
if (m_context_stack.empty ())
|
|
|
|
|
return nullptr;
|
|
|
|
|
return &m_context_stack.back ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int get_context_stack_depth () const
|
|
|
|
|
{
|
|
|
|
|
return m_context_stack.size ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct subfile *get_current_subfile ()
|
|
|
|
|
{
|
|
|
|
|
return m_current_subfile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct pending **get_local_symbols ()
|
|
|
|
|
{
|
|
|
|
|
return &m_local_symbols;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct pending **get_file_symbols ()
|
|
|
|
|
{
|
|
|
|
|
return &m_file_symbols;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct pending **get_global_symbols ()
|
|
|
|
|
{
|
|
|
|
|
return &m_global_symbols;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void record_debugformat (const char *format)
|
|
|
|
|
{
|
2018-07-09 00:19:10 +08:00
|
|
|
|
m_debugformat = format;
|
2018-05-23 04:27:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void record_producer (const char *producer)
|
|
|
|
|
{
|
2018-07-09 00:19:10 +08:00
|
|
|
|
m_producer = producer;
|
2018-05-23 04:27:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct context_stack *push_context (int desc, CORE_ADDR valu);
|
|
|
|
|
|
|
|
|
|
struct context_stack pop_context ();
|
|
|
|
|
|
|
|
|
|
struct block *end_symtab_get_static_block (CORE_ADDR end_addr,
|
|
|
|
|
int expandable, int required);
|
|
|
|
|
|
|
|
|
|
struct compunit_symtab *end_symtab_from_static_block
|
|
|
|
|
(struct block *static_block, int section, int expandable);
|
|
|
|
|
|
|
|
|
|
struct compunit_symtab *end_symtab (CORE_ADDR end_addr, int section);
|
|
|
|
|
|
|
|
|
|
struct compunit_symtab *end_expandable_symtab (CORE_ADDR end_addr,
|
|
|
|
|
int section);
|
|
|
|
|
|
|
|
|
|
void augment_type_symtab ();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
void record_pending_block (struct block *block, struct pending_block *opblock);
|
|
|
|
|
|
|
|
|
|
struct block *finish_block_internal (struct symbol *symbol,
|
|
|
|
|
struct pending **listhead,
|
|
|
|
|
struct pending_block *old_blocks,
|
|
|
|
|
const struct dynamic_prop *static_link,
|
|
|
|
|
CORE_ADDR start, CORE_ADDR end,
|
|
|
|
|
int is_global, int expandable);
|
|
|
|
|
|
|
|
|
|
struct blockvector *make_blockvector ();
|
|
|
|
|
|
|
|
|
|
void watch_main_source_file_lossage ();
|
|
|
|
|
|
|
|
|
|
struct compunit_symtab *end_symtab_with_blockvector
|
|
|
|
|
(struct block *static_block, int section, int expandable);
|
|
|
|
|
|
|
|
|
|
/* The objfile we're reading debug info from. */
|
2018-07-09 00:19:10 +08:00
|
|
|
|
struct objfile *m_objfile;
|
2018-05-23 04:27:43 +08:00
|
|
|
|
|
|
|
|
|
/* 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. */
|
2018-07-09 00:19:10 +08:00
|
|
|
|
struct subfile *m_subfiles = nullptr;
|
2018-05-23 04:27:43 +08:00
|
|
|
|
|
|
|
|
|
/* The subfile of the main source file. */
|
2018-07-09 00:19:10 +08:00
|
|
|
|
struct subfile *m_main_subfile = nullptr;
|
2018-05-23 04:27:43 +08:00
|
|
|
|
|
|
|
|
|
/* Name of source file whose symbol data we are now processing. This
|
|
|
|
|
comes from a symbol of type N_SO for stabs. For DWARF it comes
|
|
|
|
|
from the DW_AT_name attribute of a DW_TAG_compile_unit DIE. */
|
|
|
|
|
gdb::unique_xmalloc_ptr<char> m_last_source_file;
|
|
|
|
|
|
|
|
|
|
/* E.g., DW_AT_comp_dir if DWARF. Space for this is malloc'd. */
|
2018-07-09 00:19:10 +08:00
|
|
|
|
gdb::unique_xmalloc_ptr<char> m_comp_dir;
|
2018-05-23 04:27:43 +08:00
|
|
|
|
|
|
|
|
|
/* Space for this is not malloc'd, and is assumed to have at least
|
|
|
|
|
the same lifetime as objfile. */
|
2018-07-09 00:19:10 +08:00
|
|
|
|
const char *m_producer = nullptr;
|
2018-05-23 04:27:43 +08:00
|
|
|
|
|
|
|
|
|
/* Space for this is not malloc'd, and is assumed to have at least
|
|
|
|
|
the same lifetime as objfile. */
|
2018-07-09 00:19:10 +08:00
|
|
|
|
const char *m_debugformat = nullptr;
|
2018-05-23 04:27:43 +08:00
|
|
|
|
|
|
|
|
|
/* The compunit we are building. */
|
2018-07-09 00:19:10 +08:00
|
|
|
|
struct compunit_symtab *m_compunit_symtab = nullptr;
|
2018-05-23 04:27:43 +08:00
|
|
|
|
|
|
|
|
|
/* Language of this compunit_symtab. */
|
2018-07-09 00:19:10 +08:00
|
|
|
|
enum language m_language;
|
2018-05-23 04:27:43 +08:00
|
|
|
|
|
|
|
|
|
/* The macro table for the compilation unit whose symbols we're
|
|
|
|
|
currently reading. */
|
|
|
|
|
struct macro_table *m_pending_macros = nullptr;
|
|
|
|
|
|
|
|
|
|
/* True if symtab has line number info. This prevents an otherwise
|
|
|
|
|
empty symtab from being tossed. */
|
|
|
|
|
bool m_have_line_numbers = false;
|
|
|
|
|
|
|
|
|
|
/* Core address of start of text of current source file. This too
|
|
|
|
|
comes from the N_SO symbol. For Dwarf it typically comes from the
|
|
|
|
|
DW_AT_low_pc attribute of a DW_TAG_compile_unit DIE. */
|
|
|
|
|
CORE_ADDR m_last_source_start_addr;
|
|
|
|
|
|
|
|
|
|
/* Stack of subfile names. */
|
|
|
|
|
std::vector<const char *> m_subfile_stack;
|
|
|
|
|
|
|
|
|
|
/* The "using" directives local to lexical context. */
|
|
|
|
|
struct using_direct *m_local_using_directives = nullptr;
|
|
|
|
|
|
|
|
|
|
/* Global "using" directives. */
|
|
|
|
|
struct using_direct *m_global_using_directives = nullptr;
|
|
|
|
|
|
|
|
|
|
/* The stack of contexts that are pushed by push_context and popped
|
|
|
|
|
by pop_context. */
|
|
|
|
|
std::vector<struct context_stack> m_context_stack;
|
|
|
|
|
|
|
|
|
|
struct subfile *m_current_subfile = nullptr;
|
|
|
|
|
|
|
|
|
|
/* The mutable address map for the compilation unit whose symbols
|
|
|
|
|
we're currently reading. The symtabs' shared blockvector will
|
|
|
|
|
point to a fixed copy of this. */
|
|
|
|
|
struct addrmap *m_pending_addrmap = nullptr;
|
|
|
|
|
|
|
|
|
|
/* The obstack on which we allocate pending_addrmap.
|
|
|
|
|
If pending_addrmap is NULL, this is uninitialized; otherwise, it is
|
|
|
|
|
initialized (and holds pending_addrmap). */
|
|
|
|
|
auto_obstack m_pending_addrmap_obstack;
|
|
|
|
|
|
|
|
|
|
/* True if we recorded any ranges in the addrmap that are different
|
|
|
|
|
from those in the blockvector already. We set this to false when
|
|
|
|
|
we start processing a symfile, and if it's still false at the
|
|
|
|
|
end, then we just toss the addrmap. */
|
|
|
|
|
bool m_pending_addrmap_interesting = false;
|
|
|
|
|
|
|
|
|
|
/* An obstack used for allocating pending blocks. */
|
|
|
|
|
auto_obstack m_pending_block_obstack;
|
|
|
|
|
|
|
|
|
|
/* Pointer to the head of a linked list of symbol blocks which have
|
|
|
|
|
already been finalized (lexical contexts already closed) and which
|
|
|
|
|
are just waiting to be built into a blockvector when finalizing the
|
|
|
|
|
associated symtab. */
|
|
|
|
|
struct pending_block *m_pending_blocks = nullptr;
|
|
|
|
|
|
|
|
|
|
/* Pending static symbols and types at the top level. */
|
|
|
|
|
struct pending *m_file_symbols = nullptr;
|
|
|
|
|
|
|
|
|
|
/* Pending global functions and variables. */
|
|
|
|
|
struct pending *m_global_symbols = nullptr;
|
|
|
|
|
|
|
|
|
|
/* Pending symbols that are local to the lexical context. */
|
|
|
|
|
struct pending *m_local_symbols = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern void add_symbol_to_list (struct symbol *symbol,
|
|
|
|
|
struct pending **listhead);
|
|
|
|
|
|
|
|
|
|
extern struct symbol *find_symbol_in_list (struct pending *list,
|
|
|
|
|
char *name, int length);
|
|
|
|
|
|
|
|
|
|
#endif /* defined (BUILDSYM_H) */
|