1 //===-- HashedNameToDIE.h ---------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef SymbolFileDWARF_HashedNameToDIE_h_
11 #define SymbolFileDWARF_HashedNameToDIE_h_
15 #include "lldb/lldb-defines.h"
16 #include "lldb/Core/dwarf.h"
17 #include "lldb/Core/RegularExpression.h"
18 #include "lldb/Core/MappedHash.h"
20 #include "DWARFDefines.h"
21 #include "DWARFFormValue.h"
22 #include "NameToDIE.h"
24 class SymbolFileDWARF;
25 class DWARFCompileUnit;
26 class DWARFDebugInfoEntry;
31 enum AtomType : uint16_t
34 eAtomTypeDIEOffset = 1u, // DIE offset, check form for encoding
35 eAtomTypeCUOffset = 2u, // DIE offset of the compiler unit header that contains the item in question
36 eAtomTypeTag = 3u, // DW_TAG_xxx value, should be encoded as DW_FORM_data1 (if no tags exceed 255) or DW_FORM_data2
37 eAtomTypeNameFlags = 4u, // Flags from enum NameFlags
38 eAtomTypeTypeFlags = 5u, // Flags from enum TypeFlags,
39 eAtomTypeQualNameHash = 6u // A 32 bit hash of the full qualified name (since all hash entries are basename only)
40 // For example a type like "std::vector<int>::iterator" would have a name of "iterator"
41 // and a 32 bit hash for "std::vector<int>::iterator" to allow us to not have to pull
42 // in debug info for a type when we know the fully qualified name.
45 // Bit definitions for the eAtomTypeTypeFlags flags
48 // Always set for C++, only set for ObjC if this is the
49 // @implementation for class
50 eTypeFlagClassIsImplementation = ( 1u << 1 )
55 dw_offset_t cu_offset;
56 dw_offset_t offset; // The DIE offset
58 uint32_t type_flags; // Any flags for this DIEInfo
59 uint32_t qualified_name_hash; // A 32 bit hash of the fully qualified name
62 DIEInfo (dw_offset_t c, dw_offset_t o, dw_tag_t t, uint32_t f, uint32_t h);
71 typedef std::vector<DIEInfo> DIEInfoArray;
72 typedef std::vector<Atom> AtomArray;
77 Prologue (dw_offset_t _die_base_offset = 0);
83 ContainsAtom (AtomType atom_type) const;
89 AppendAtom (AtomType type, dw_form_t form);
92 Read (const lldb_private::DataExtractor &data, lldb::offset_t offset);
98 GetMinimumHashDataByteSize () const;
101 HashDataHasFixedByteSize() const;
103 // DIE offset base so die offsets in hash_data can be CU relative
104 dw_offset_t die_base_offset;
107 size_t min_hash_data_byte_size;
108 bool hash_data_has_fixed_byte_size;
111 class Header : public MappedHash::Header<Prologue>
115 GetByteSize (const HeaderData &header_data) override;
118 Read (lldb_private::DataExtractor &data, lldb::offset_t offset) override;
121 Read (const lldb_private::DWARFDataExtractor &data,
122 lldb::offset_t *offset_ptr,
123 DIEInfo &hash_data) const;
126 Dump (lldb_private::Stream& strm, const DIEInfo &hash_data) const;
129 // A class for reading and using a saved hash table from a block of data
131 class MemoryTable : public MappedHash::MemoryTable<uint32_t, DWARFMappedHash::Header, DIEInfoArray>
134 MemoryTable (lldb_private::DWARFDataExtractor &table_data,
135 const lldb_private::DWARFDataExtractor &string_table,
139 GetStringForKeyType (KeyType key) const override;
142 ReadHashData (uint32_t hash_data_offset, HashData &hash_data) const override;
145 AppendAllDIEsThatMatchingRegex (const lldb_private::RegularExpression& regex,
146 DIEInfoArray &die_info_array) const;
149 AppendAllDIEsInRange (const uint32_t die_offset_start,
150 const uint32_t die_offset_end,
151 DIEInfoArray &die_info_array) const;
154 FindByName (const char *name, DIEArray &die_offsets);
157 FindByNameAndTag (const char *name, const dw_tag_t tag, DIEArray &die_offsets);
160 FindByNameAndTagAndQualifiedNameHash (const char *name,
162 const uint32_t qualified_name_hash,
163 DIEArray &die_offsets);
166 FindCompleteObjCClassByName (const char *name,
167 DIEArray &die_offsets,
168 bool must_be_implementation);
172 AppendHashDataForRegularExpression (const lldb_private::RegularExpression& regex,
173 lldb::offset_t* hash_data_offset_ptr,
177 FindByName (const char *name, DIEInfoArray &die_info_array);
180 GetHashDataForName (const char *name,
181 lldb::offset_t* hash_data_offset_ptr,
182 Pair &pair) const override;
184 const lldb_private::DWARFDataExtractor &m_data;
185 const lldb_private::DWARFDataExtractor &m_string_table;
190 ExtractDIEArray (const DIEInfoArray &die_info_array, DIEArray &die_offsets);
194 ExtractDIEArray (const DIEInfoArray &die_info_array,
196 DIEArray &die_offsets);
199 ExtractDIEArray (const DIEInfoArray &die_info_array,
201 const uint32_t qualified_name_hash,
202 DIEArray &die_offsets);
205 ExtractClassOrStructDIEArray (const DIEInfoArray &die_info_array,
206 bool return_implementation_only_if_available,
207 DIEArray &die_offsets);
210 ExtractTypesFromDIEArray (const DIEInfoArray &die_info_array,
211 uint32_t type_flag_mask,
212 uint32_t type_flag_value,
213 DIEArray &die_offsets);
216 GetAtomTypeName (uint16_t atom);
219 #endif // SymbolFileDWARF_HashedNameToDIE_h_