From 128a391fe45a234587dc585e03a7726cd6ee0255 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 23 Oct 2019 09:50:58 -0600 Subject: Virtualize "readin" and "compunit_symtab" This patch removes the "readin" and "compunit_symtab" members from partial_symtab, replacing them with methods. Then it introduces a new "standard_psymtab" class, which restores these members; and changes the symbol readers to use this intermediate class as the base class of their partial symtab subclasses. The reason for this is to make it possible for a symbol reader to implement an alternate mapping between partial and full symbol tables. This is important in order to be able to share psymtabs across objfiles -- whether a psymtab has been "readin" is objfile-dependent, as are the pointers to the full symbol tables. gdb/ChangeLog 2020-01-26 Tom Tromey * psymtab.c (partial_map_expand_apply) (psym_find_pc_sect_compunit_symtab, psym_lookup_symbol) (psymtab_to_symtab, psym_find_last_source_symtab, dump_psymtab) (psym_print_stats, psym_expand_symtabs_for_function) (psym_map_symbol_filenames, psym_map_matching_symbols) (psym_expand_symtabs_matching) (partial_symtab::read_dependencies, maintenance_info_psymtabs) (maintenance_check_psymtabs): Use new methods. * psympriv.h (struct partial_symtab) : New methods. : Remove members. (struct standard_psymtab): New. (struct legacy_psymtab): Derive from standard_psymtab. * dwarf2read.h (struct dwarf2_psymtab): Derive from standard_psymtab. * ctfread.c (struct ctf_psymtab): Derive from standard_psymtab. Change-Id: Idb923f196d7e03bf7cb9cfc8134ed06dd3f211ce --- gdb/psympriv.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 9 deletions(-) (limited to 'gdb/psympriv.h') diff --git a/gdb/psympriv.h b/gdb/psympriv.h index e4b2330..1b1f57c 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -137,6 +137,15 @@ struct partial_symtab /* Ensure that all the dependencies are read in. */ void read_dependencies (struct objfile *); + /* Return true if the symtab corresponding to this psymtab has been + readin. */ + virtual bool readin_p () const = 0; + + /* Return a pointer to the compunit allocated for this source file. + Return nullptr if !readin or if there was no symtab. */ + virtual struct compunit_symtab *get_compunit_symtab () const = 0; + + /* Return the raw low text address of this partial_symtab. */ CORE_ADDR raw_text_low () const { @@ -265,12 +274,6 @@ struct partial_symtab int statics_offset = 0; int n_static_syms = 0; - /* True if the symtab corresponding to this psymtab has been readin. - This is located here so that this structure packs better on - 64-bit systems. */ - - bool readin = false; - /* True iff objfile->psymtabs_addrmap is properly populated for this partial_symtab. For discontiguous overlapping psymtabs is the only usable info in PSYMTABS_ADDRMAP. */ @@ -289,6 +292,40 @@ struct partial_symtab unsigned int text_low_valid : 1; unsigned int text_high_valid : 1; +}; + +/* A partial symtab that tracks the "readin" and "compunit_symtab" + information in the ordinary way -- by storing it directly in this + object. */ +struct standard_psymtab : public partial_symtab +{ + standard_psymtab (const char *filename, struct objfile *objfile) + : partial_symtab (filename, objfile) + { + } + + standard_psymtab (const char *filename, struct objfile *objfile, + CORE_ADDR addr) + : partial_symtab (filename, objfile, addr) + { + } + + bool readin_p () const override + { + return readin; + } + + /* Return a pointer to the compunit allocated for this source file. + Return nullptr if !readin or if there was no symtab. */ + struct compunit_symtab *get_compunit_symtab () const override + { + return compunit_symtab; + } + + /* True if the symtab corresponding to this psymtab has been + readin. */ + + bool readin = false; /* 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. */ @@ -300,16 +337,16 @@ struct partial_symtab not be used in new code, but exists to transition the somewhat unmaintained "legacy" debug formats. */ -struct legacy_psymtab : public partial_symtab +struct legacy_psymtab : public standard_psymtab { legacy_psymtab (const char *filename, struct objfile *objfile) - : partial_symtab (filename, objfile) + : standard_psymtab (filename, objfile) { } legacy_psymtab (const char *filename, struct objfile *objfile, CORE_ADDR addr) - : partial_symtab (filename, objfile, addr) + : standard_psymtab (filename, objfile, addr) { } -- cgit v1.1