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