diff options
Diffstat (limited to 'gdb/dwarf2/read.h')
-rw-r--r-- | gdb/dwarf2/read.h | 102 |
1 files changed, 47 insertions, 55 deletions
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index f3e043c..4e3f8d7 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -20,9 +20,12 @@ #ifndef GDB_DWARF2_READ_H #define GDB_DWARF2_READ_H +#if CXX_STD_THREAD +#include <mutex> +#endif #include <queue> #include "dwarf2/abbrev.h" -#include "dwarf2/comp-unit-head.h" +#include "dwarf2/unit-head.h" #include "dwarf2/file-and-dir.h" #include "dwarf2/index-cache.h" #include "dwarf2/mapped-index.h" @@ -44,7 +47,6 @@ struct tu_stats int nr_symtab_sharers = 0; int nr_stmt_less_type_units = 0; int nr_all_type_units_reallocs = 0; - int nr_tus = 0; }; struct abbrev_table_cache; @@ -233,14 +235,14 @@ public: /* Backlink to the owner of this. */ dwarf2_per_bfd *per_bfd; - /* DWARF header of this CU. Note that dwarf2_cu reads its own version of the - header, which may differ from this one, since it may pass rcuh_kind::TYPE - to read_comp_unit_head, whereas for dwarf2_per_cu we always pass - rcuh_kind::COMPILE. + /* DWARF header of this unit. Note that dwarf2_cu reads its own version of + the header, which may differ from this one, since it may pass + rch_kind::TYPE to read_unit_head, whereas for dwarf2_per_cu we always pass + ruh_kind::COMPILE. Don't access this field directly, use the get_header method instead. It should be private, but we can't make it private at the moment. */ - mutable comp_unit_head m_header; + mutable unit_head m_header; /* The file and directory for this CU. This is cached so that we don't need to re-examine the DWO in some situations. This may be @@ -271,7 +273,7 @@ public: std::vector<dwarf2_per_cu *> imported_symtabs; /* Get the header of this per_cu, reading it if necessary. */ - const comp_unit_head *get_header () const; + const unit_head *get_header () const; /* Return the address size given in the compilation unit header for this CU. */ @@ -293,6 +295,10 @@ public: return m_length; } + /* Return true if the length of this CU has been set. */ + bool length_is_set () const + { return m_length != 0; } + void set_length (unsigned int length, bool strict_p = true) { if (m_length == 0) @@ -512,26 +518,12 @@ struct dwarf2_per_bfd const char *filename () const { return bfd_get_filename (this->obfd); } - /* Return the CU given its index. */ - dwarf2_per_cu *get_cu (int index) const + /* Return the unit given its index. */ + dwarf2_per_cu *get_unit (int index) const { return this->all_units[index].get (); } - /* Return the CU given its index in the CU table in the index. */ - dwarf2_per_cu *get_index_cu (int index) const - { - if (this->all_comp_units_index_cus.empty ()) - return get_cu (index); - - return this->all_comp_units_index_cus[index]; - } - - dwarf2_per_cu *get_index_tu (int index) const - { - return this->all_comp_units_index_tus[index]; - } - /* Return the separate '.dwz' debug file. If there is no .gnu_debugaltlink or .debug_sup section in the file, then the result depends on REQUIRE: if REQUIRE is true, error out; if @@ -616,13 +608,9 @@ public: the target compilation unit of a particular reference. */ std::vector<dwarf2_per_cu_up> all_units; - /* The all_units vector contains both CUs and TUs. Provide views on the - vector that are limited to either the CU part or the TU part. */ - gdb::array_view<dwarf2_per_cu_up> all_comp_units; - gdb::array_view<dwarf2_per_cu_up> all_type_units; - - std::vector<dwarf2_per_cu *> all_comp_units_index_cus; - std::vector<dwarf2_per_cu *> all_comp_units_index_tus; + /* Number of compilation and type units in the ALL_UNITS vector. */ + unsigned int num_comp_units = 0; + unsigned int num_type_units = 0; /* Set of signatured_types, used to look up by signature. */ signatured_type_set signatured_types; @@ -634,6 +622,11 @@ public: /* Set of dwo_file objects. */ dwo_file_up_set dwo_files; +#if CXX_STD_THREAD + /* Mutex to synchronize access to DWO_FILES. */ + std::mutex dwo_files_lock; +#endif + /* The DWP file if there is one, or NULL. */ dwp_file_up dwp_file; @@ -702,7 +695,7 @@ public: dwarf2_per_cu *operator* () const { - return m_per_bfd->get_cu (m_index); + return m_per_bfd->get_unit (m_index); } bool operator== (const all_units_iterator &other) const @@ -812,7 +805,7 @@ struct dwarf2_per_objfile BUF is assumed to be in a compilation unit described by CU_HEADER. Return *BYTES_READ_PTR count of bytes read from BUF. */ const char *read_line_string (const gdb_byte *buf, - const struct comp_unit_head *cu_header, + const struct unit_head *unit_header, unsigned int *bytes_read_ptr); /* Return pointer to string at .debug_line_str offset as read from BUF. @@ -934,8 +927,6 @@ public: DISABLE_COPY_AND_ASSIGN (cutu_reader); - cutu_reader (cutu_reader &&) = default; - /* Return true if either: - the unit is empty (just a header without any DIE) @@ -1031,19 +1022,11 @@ private: dwo_file_up open_and_init_dwo_file (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir); - void locate_dwo_sections (struct objfile *objfile, bfd *abfd, asection *sectp, - struct dwo_sections *dwo_sections); - - void create_dwo_cus_hash_table (dwarf2_cu *cu, dwo_file &dwo_file); + void locate_dwo_sections (objfile *objfile, dwo_file &dwo_file); - void create_dwo_debug_types_hash_table - (dwarf2_per_bfd *per_bfd, dwo_file *dwo_file, - gdb::array_view<dwarf2_section_info> type_sections); - - void create_dwo_debug_type_hash_table (dwarf2_per_bfd *per_bfd, - dwo_file *dwo_file, - dwarf2_section_info *section, - rcuh_kind section_kind); + void create_dwo_unit_hash_tables (dwo_file &dwo_file, dwarf2_cu &skeleton_cu, + dwarf2_section_info §ion, + ruh_kind section_kind); dwo_unit *lookup_dwo_cutu (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir, ULONGEST signature, @@ -1234,7 +1217,7 @@ extern void dw_expand_symtabs_matching_file_matcher extern const char *read_indirect_string_at_offset (dwarf2_per_objfile *per_objfile, LONGEST str_offset); -/* Initialize the views on all_units. */ +/* Finalize the all_units vector. */ extern void finalize_all_units (dwarf2_per_bfd *per_bfd); @@ -1279,14 +1262,17 @@ extern pc_bounds_kind dwarf2_get_pc_bounds (die_info *die, dwarf2_cu *cu, addrmap_mutable *map, void *datum); -/* Locate the .debug_info compilation unit from CU's objfile which contains - the DIE at OFFSET. Raises an error on failure. */ +/* Locate the unit in PER_OBJFILE which contains the DIE at TARGET. Raises an + error on failure. */ + +extern dwarf2_per_cu *dwarf2_find_containing_unit + (const section_and_offset &target, dwarf2_per_objfile *per_objfile); -extern dwarf2_per_cu *dwarf2_find_containing_comp_unit (sect_offset sect_off, - unsigned int - offset_in_dwz, - dwarf2_per_bfd - *per_bfd); +/* Locate the unit starting at START in PER_BFD. Return nullptr if not + found. */ + +extern dwarf2_per_cu *dwarf2_find_unit (const section_and_offset &start, + dwarf2_per_bfd *per_bfd); /* Decode simple location descriptions. @@ -1329,4 +1315,10 @@ extern int dwarf2_ranges_read (unsigned offset, unrelocated_addr *low_return, extern file_and_directory &find_file_and_directory (die_info *die, dwarf2_cu *cu); + +/* Return the section that ATTR, an attribute with ref form, references. */ + +extern const dwarf2_section_info &get_section_for_ref + (const attribute &attr, dwarf2_cu *cu); + #endif /* GDB_DWARF2_READ_H */ |