diff options
author | Tom de Vries <tdevries@suse.de> | 2024-01-10 10:06:35 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2024-01-10 10:06:35 +0100 |
commit | 42bd6b5fd4f9e41f99d80a8f2946926503299e5e (patch) | |
tree | 241f0ed8d15be7f43283e18824f40c2fe322b440 /gdb/dwarf2/cooked-index.h | |
parent | 850fce8baf0a19f911e6c891c13447292928e987 (diff) | |
download | gdb-42bd6b5fd4f9e41f99d80a8f2946926503299e5e.zip gdb-42bd6b5fd4f9e41f99d80a8f2946926503299e5e.tar.gz gdb-42bd6b5fd4f9e41f99d80a8f2946926503299e5e.tar.bz2 |
gdb/symtab: Eliminate deferred_entry
Currently cooked_index entry creation is either:
- done immediately if the parent_entry is known, or
- deferred if the parent_entry is not yet known, and done later while
resolving the deferred entries.
Instead, create all cooked_index entries immediately, and keep track of which
entries have a parent_entry that needs resolving later using the new
IS_PARENT_DEFERRED flag.
Tested on x86_64-linux.
Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/dwarf2/cooked-index.h')
-rw-r--r-- | gdb/dwarf2/cooked-index.h | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h index fa0807a..4c3b290 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -48,6 +48,7 @@ struct dwarf2_per_cu_data; struct dwarf2_per_bfd; struct index_cache_store_context; +struct cooked_index_entry; /* Flags that describe an entry in the index. */ enum cooked_index_flag_enum : unsigned char @@ -63,9 +64,30 @@ enum cooked_index_flag_enum : unsigned char /* True if this entry is just for the declaration of a type, not the definition. */ IS_TYPE_DECLARATION = 16, + /* True is parent_entry.deferred has a value rather than parent_entry + .resolved. */ + IS_PARENT_DEFERRED = 32, }; DEF_ENUM_FLAGS_TYPE (enum cooked_index_flag_enum, cooked_index_flag); +/* Type representing either a resolved or deferred cooked_index_entry. */ + +union cooked_index_entry_ref +{ + cooked_index_entry_ref (CORE_ADDR deferred_) + { + deferred = deferred_; + } + + cooked_index_entry_ref (const cooked_index_entry *resolved_) + { + resolved = resolved_; + } + + const cooked_index_entry *resolved; + CORE_ADDR deferred; +}; + /* Return a string representation of FLAGS. */ std::string to_string (cooked_index_flag flags); @@ -88,7 +110,7 @@ struct cooked_index_entry : public allocate_on_obstack { cooked_index_entry (sect_offset die_offset_, enum dwarf_tag tag_, cooked_index_flag flags_, const char *name_, - const cooked_index_entry *parent_entry_, + cooked_index_entry_ref parent_entry_, dwarf2_per_cu_data *per_cu_) : name (name_), tag (tag_), @@ -223,13 +245,30 @@ struct cooked_index_entry : public allocate_on_obstack /* Set parent entry to PARENT. */ void set_parent (const cooked_index_entry *parent) { - m_parent_entry = parent; + gdb_assert ((flags & IS_PARENT_DEFERRED) == 0); + m_parent_entry.resolved = parent; + } + + /* Resolve deferred parent entry to PARENT. */ + void resolve_parent (const cooked_index_entry *parent) + { + gdb_assert ((flags & IS_PARENT_DEFERRED) != 0); + flags = flags & ~IS_PARENT_DEFERRED; + m_parent_entry.resolved = parent; } /* Return parent entry. */ const cooked_index_entry *get_parent () const { - return m_parent_entry; + gdb_assert ((flags & IS_PARENT_DEFERRED) == 0); + return m_parent_entry.resolved; + } + + /* Return deferred parent entry. */ + CORE_ADDR get_deferred_parent () const + { + gdb_assert ((flags & IS_PARENT_DEFERRED) != 0); + return m_parent_entry.deferred; } /* The name as it appears in DWARF. This always points into one of @@ -260,7 +299,7 @@ private: /* The parent entry. This is NULL for top-level entries. Otherwise, it points to the parent entry, such as a namespace or class. */ - const cooked_index_entry *m_parent_entry; + cooked_index_entry_ref m_parent_entry; }; class cooked_index; @@ -283,7 +322,7 @@ public: cooked_index_entry *add (sect_offset die_offset, enum dwarf_tag tag, cooked_index_flag flags, const char *name, - const cooked_index_entry *parent_entry, + cooked_index_entry_ref parent_entry, dwarf2_per_cu_data *per_cu); /* Install a new fixed addrmap from the given mutable addrmap. */ @@ -334,7 +373,7 @@ private: enum dwarf_tag tag, cooked_index_flag flags, const char *name, - const cooked_index_entry *parent_entry, + cooked_index_entry_ref parent_entry, dwarf2_per_cu_data *per_cu) { return new (&m_storage) cooked_index_entry (die_offset, tag, flags, @@ -399,7 +438,7 @@ public: cooked_index_entry *add (sect_offset die_offset, enum dwarf_tag tag, cooked_index_flag flags, const char *name, - const cooked_index_entry *parent_entry, + cooked_index_entry_ref parent_entry, dwarf2_per_cu_data *per_cu) { return m_index->add (die_offset, tag, flags, name, parent_entry, per_cu); |