]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnamesSet.h
Merge ACPICA 20180313.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Plugins / SymbolFile / DWARF / DWARFDebugPubnamesSet.h
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 <map>
15 #include <string>
16 #include <vector>
17 #if __cplusplus >= 201103L || defined(_MSC_VER)
18 #include <unordered_map>
19 #else
20 #include <ext/hash_map>
21 #endif
22
23 #include "lldb/Core/STLUtils.h"
24
25 class DWARFDebugPubnamesSet {
26 public:
27   struct Header {
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
33     Header()
34         : length(10), version(2), die_offset(DW_INVALID_OFFSET), die_length(0) {
35     }
36   };
37
38   struct Descriptor {
39     Descriptor() : offset(), name() {}
40
41     Descriptor(dw_offset_t the_offset, const char *the_name)
42         : offset(the_offset), name(the_name ? the_name : "") {}
43
44     dw_offset_t offset;
45     std::string name;
46   };
47
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];
58     return NULL;
59   }
60   uint32_t NumDescriptors() const { return m_descriptors.size(); }
61   void AddDescriptor(dw_offset_t cu_rel_offset, const char *name);
62   void Clear();
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 &regex,
70             std::vector<dw_offset_t> &die_offsets) const;
71   dw_offset_t GetOffsetOfNextEntry() const;
72
73 protected:
74   typedef std::vector<Descriptor> DescriptorColl;
75   typedef DescriptorColl::iterator DescriptorIter;
76   typedef DescriptorColl::const_iterator DescriptorConstIter;
77
78   dw_offset_t m_offset;
79   Header m_header;
80 #if __cplusplus >= 201103L || defined(_MSC_VER)
81   typedef std::unordered_multimap<const char *, uint32_t,
82                                   std::hash<const char *>,
83                                   CStringEqualBinaryPredicate>
84       cstr_to_index_mmap;
85 #else
86   typedef __gnu_cxx::hash_multimap<const char *, uint32_t,
87                                    __gnu_cxx::hash<const char *>,
88                                    CStringEqualBinaryPredicate>
89       cstr_to_index_mmap;
90 #endif
91   DescriptorColl m_descriptors;
92   mutable cstr_to_index_mmap m_name_to_descriptor_index;
93 };
94
95 #endif // SymbolFileDWARF_DWARFDebugPubnamesSet_h_