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"
17 #if __cplusplus >= 201103L || defined(_MSC_VER)
18 #include <unordered_map>
20 #include <ext/hash_map>
23 #include "lldb/Core/STLUtils.h"
25 class DWARFDebugPubnamesSet {
28 uint32_t length; // length of the set of entries for this compilation unit,
29 // not including the length field itself
30 uint16_t version; // The DWARF version number
31 uint32_t die_offset; // compile unit .debug_info offset
32 uint32_t die_length; // compile unit .debug_info length
34 : length(10), version(2), die_offset(DW_INVALID_OFFSET), die_length(0) {
39 Descriptor() : offset(), name() {}
41 Descriptor(dw_offset_t the_offset, const char *the_name)
42 : offset(the_offset), name(the_name ? the_name : "") {}
48 DWARFDebugPubnamesSet();
49 DWARFDebugPubnamesSet(dw_offset_t debug_aranges_offset,
50 dw_offset_t cu_die_offset, dw_offset_t die_length);
51 dw_offset_t GetOffset() const { return m_offset; }
52 void SetOffset(dw_offset_t offset) { m_offset = offset; }
53 DWARFDebugPubnamesSet::Header &GetHeader() { return m_header; }
54 const DWARFDebugPubnamesSet::Header &GetHeader() const { return m_header; }
55 const DWARFDebugPubnamesSet::Descriptor *GetDescriptor(uint32_t i) const {
56 if (i < m_descriptors.size())
57 return &m_descriptors[i];
60 uint32_t NumDescriptors() const { return m_descriptors.size(); }
61 void AddDescriptor(dw_offset_t cu_rel_offset, const char *name);
63 bool Extract(const lldb_private::DWARFDataExtractor &debug_pubnames_data,
64 lldb::offset_t *offset_ptr);
65 void Dump(lldb_private::Log *s) const;
66 void InitNameIndexes() const;
67 void Find(const char *name, bool ignore_case,
68 std::vector<dw_offset_t> &die_offset_coll) const;
69 void Find(const lldb_private::RegularExpression ®ex,
70 std::vector<dw_offset_t> &die_offsets) const;
71 dw_offset_t GetOffsetOfNextEntry() const;
74 typedef std::vector<Descriptor> DescriptorColl;
75 typedef DescriptorColl::iterator DescriptorIter;
76 typedef DescriptorColl::const_iterator DescriptorConstIter;
80 #if __cplusplus >= 201103L || defined(_MSC_VER)
81 typedef std::unordered_multimap<const char *, uint32_t,
82 std::hash<const char *>,
83 CStringEqualBinaryPredicate>
86 typedef __gnu_cxx::hash_multimap<const char *, uint32_t,
87 __gnu_cxx::hash<const char *>,
88 CStringEqualBinaryPredicate>
91 DescriptorColl m_descriptors;
92 mutable cstr_to_index_mmap m_name_to_descriptor_index;
95 #endif // SymbolFileDWARF_DWARFDebugPubnamesSet_h_