1 //===-- DWARFDebugPubnamesSet.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_DWARFDebugPubnamesSet_h_
11 #define SymbolFileDWARF_DWARFDebugPubnamesSet_h_
13 #include "SymbolFileDWARF.h"
16 #if __cplusplus >= 201103L || defined(_MSC_VER)
17 #include <unordered_map>
19 #include <ext/hash_map>
22 class DWARFDebugPubnamesSet {
25 uint32_t length; // length of the set of entries for this compilation unit,
26 // not including the length field itself
27 uint16_t version; // The DWARF version number
28 uint32_t die_offset; // compile unit .debug_info offset
29 uint32_t die_length; // compile unit .debug_info length
31 : length(10), version(2), die_offset(DW_INVALID_OFFSET), die_length(0) {
36 Descriptor() : offset(), name() {}
38 Descriptor(dw_offset_t the_offset, const char *the_name)
39 : offset(the_offset), name(the_name ? the_name : "") {}
45 DWARFDebugPubnamesSet();
46 DWARFDebugPubnamesSet(dw_offset_t debug_aranges_offset,
47 dw_offset_t cu_die_offset, dw_offset_t die_length);
48 dw_offset_t GetOffset() const { return m_offset; }
49 void SetOffset(dw_offset_t offset) { m_offset = offset; }
50 DWARFDebugPubnamesSet::Header &GetHeader() { return m_header; }
51 const DWARFDebugPubnamesSet::Header &GetHeader() const { return m_header; }
52 const DWARFDebugPubnamesSet::Descriptor *GetDescriptor(uint32_t i) const {
53 if (i < m_descriptors.size())
54 return &m_descriptors[i];
57 uint32_t NumDescriptors() const { return m_descriptors.size(); }
58 void AddDescriptor(dw_offset_t cu_rel_offset, const char *name);
60 bool Extract(const lldb_private::DWARFDataExtractor &debug_pubnames_data,
61 lldb::offset_t *offset_ptr);
62 void Dump(lldb_private::Log *s) const;
63 void InitNameIndexes() const;
64 void Find(const char *name, bool ignore_case,
65 std::vector<dw_offset_t> &die_offset_coll) const;
66 void Find(const lldb_private::RegularExpression ®ex,
67 std::vector<dw_offset_t> &die_offsets) const;
68 dw_offset_t GetOffsetOfNextEntry() const;
71 typedef std::vector<Descriptor> DescriptorColl;
72 typedef DescriptorColl::iterator DescriptorIter;
73 typedef DescriptorColl::const_iterator DescriptorConstIter;
77 #if __cplusplus >= 201103L || defined(_MSC_VER)
78 typedef std::unordered_multimap<const char *, uint32_t,
79 std::hash<const char *>,
80 CStringEqualBinaryPredicate>
83 typedef __gnu_cxx::hash_multimap<const char *, uint32_t,
84 __gnu_cxx::hash<const char *>,
85 CStringEqualBinaryPredicate>
88 DescriptorColl m_descriptors;
89 mutable cstr_to_index_mmap m_name_to_descriptor_index;
92 #endif // SymbolFileDWARF_DWARFDebugPubnamesSet_h_