1 //===-- DWARFDebugPubnamesSet.h ---------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef SymbolFileDWARF_DWARFDebugPubnamesSet_h_ 11 #define SymbolFileDWARF_DWARFDebugPubnamesSet_h_ 12 13 #include "SymbolFileDWARF.h" 14 #include <string> 15 #include <vector> 16 #if __cplusplus >= 201103L 17 #include <unordered_map> 18 #else 19 #include <ext/hash_map> 20 #endif 21 22 class DWARFDebugPubnamesSet 23 { 24 public: 25 struct Header 26 { 27 uint32_t length; // length of the set of entries for this compilation unit, not including the length field itself 28 uint16_t version; // The DWARF version number 29 uint32_t die_offset; // compile unit .debug_info offset 30 uint32_t die_length; // compile unit .debug_info length 31 Header() : 32 length(10), 33 version(2), 34 die_offset(DW_INVALID_OFFSET), 35 die_length(0) 36 { 37 } 38 }; 39 40 struct Descriptor 41 { 42 Descriptor() : 43 offset(), 44 name() 45 { 46 } 47 48 Descriptor(dw_offset_t the_offset, const char *the_name) : 49 offset(the_offset), 50 name(the_name ? the_name : "") 51 { 52 } 53 54 dw_offset_t offset; 55 std::string name; 56 }; 57 58 DWARFDebugPubnamesSet(); 59 DWARFDebugPubnamesSet(dw_offset_t debug_aranges_offset, dw_offset_t cu_die_offset, dw_offset_t die_length); 60 dw_offset_t GetOffset() const { return m_offset; } 61 void SetOffset(dw_offset_t offset) { m_offset = offset; } 62 DWARFDebugPubnamesSet::Header& GetHeader() { return m_header; } 63 const DWARFDebugPubnamesSet::Header& GetHeader() const { return m_header; } 64 const DWARFDebugPubnamesSet::Descriptor* GetDescriptor(uint32_t i) const 65 { 66 if (i < m_descriptors.size()) 67 return &m_descriptors[i]; 68 return NULL; 69 } 70 uint32_t NumDescriptors() const { return m_descriptors.size(); } 71 void AddDescriptor(dw_offset_t cu_rel_offset, const char* name); 72 void Clear(); 73 bool Extract(const lldb_private::DataExtractor& debug_pubnames_data, lldb::offset_t *offset_ptr); 74 void Dump(lldb_private::Log *s) const; 75 void InitNameIndexes() const; 76 void Find(const char* name, bool ignore_case, std::vector<dw_offset_t>& die_offset_coll) const; 77 void Find(const lldb_private::RegularExpression& regex, std::vector<dw_offset_t>& die_offsets) const; 78 dw_offset_t GetOffsetOfNextEntry() const; 79 80 81 82 protected: 83 typedef std::vector<Descriptor> DescriptorColl; 84 typedef DescriptorColl::iterator DescriptorIter; 85 typedef DescriptorColl::const_iterator DescriptorConstIter; 86 87 88 dw_offset_t m_offset; 89 Header m_header; 90 #if __cplusplus >= 201103L 91 typedef std::unordered_multimap<const char*, uint32_t, std::hash<const char*>, CStringEqualBinaryPredicate> cstr_to_index_mmap; 92 #else 93 typedef __gnu_cxx::hash_multimap<const char*, uint32_t, __gnu_cxx::hash<const char*>, CStringEqualBinaryPredicate> cstr_to_index_mmap; 94 #endif 95 DescriptorColl m_descriptors; 96 mutable cstr_to_index_mmap m_name_to_descriptor_index; 97 }; 98 99 #endif // SymbolFileDWARF_DWARFDebugPubnamesSet_h_ 100