blob: 0597e368e1ff7554b83e1b0b825ba9d3046b85f3 [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- 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 liblldb_DWARFDebugPubnamesSet_h_
11#define SymbolFileDWARF_DWARFDebugPubnamesSet_h_
12
13#include "SymbolFileDWARF.h"
14#include <string>
15#include <vector>
16#include <ext/hash_map>
17
18class DWARFDebugPubnamesSet
19{
20public:
21 struct Header
22 {
23 uint32_t length; // length of the set of entries for this compilation unit, not including the length field itself
24 uint16_t version; // The DWARF version number
25 uint32_t die_offset; // compile unit .debug_info offset
26 uint32_t die_length; // compile unit .debug_info length
27 Header() :
28 length(10),
29 version(2),
30 die_offset(DW_INVALID_OFFSET),
31 die_length(0)
32 {
33 }
34 };
35
36 struct Descriptor
37 {
38 Descriptor() :
39 offset(),
40 name()
41 {
42 }
43
44 Descriptor(dw_offset_t the_offset, const char *the_name) :
45 offset(the_offset),
46 name(the_name ? the_name : "")
47 {
48 }
49
50 dw_offset_t offset;
51 std::string name;
52 };
53
54 DWARFDebugPubnamesSet();
55 DWARFDebugPubnamesSet(dw_offset_t debug_aranges_offset, dw_offset_t cu_die_offset, dw_offset_t die_length);
56 dw_offset_t GetOffset() const { return m_offset; }
57 void SetOffset(dw_offset_t offset) { m_offset = offset; }
58 DWARFDebugPubnamesSet::Header& GetHeader() { return m_header; }
59 const DWARFDebugPubnamesSet::Header& GetHeader() const { return m_header; }
60 const DWARFDebugPubnamesSet::Descriptor* GetDescriptor(uint32_t i) const
61 {
62 if (i < m_descriptors.size())
63 return &m_descriptors[i];
64 return NULL;
65 }
66 uint32_t NumDescriptors() const { return m_descriptors.size(); }
67 void AddDescriptor(dw_offset_t cu_rel_offset, const char* name);
68 void Clear();
69 bool Extract(const lldb_private::DataExtractor& debug_pubnames_data, uint32_t* offset_ptr);
70 void Dump(lldb_private::Log *s) const;
71 void InitNameIndexes() const;
72 void Find(const char* name, bool ignore_case, std::vector<dw_offset_t>& die_offset_coll) const;
73 void Find(const lldb_private::RegularExpression& regex, std::vector<dw_offset_t>& die_offsets) const;
74 dw_offset_t GetOffsetOfNextEntry() const;
75
76
77
78protected:
79 typedef std::vector<Descriptor> DescriptorColl;
80 typedef DescriptorColl::iterator DescriptorIter;
81 typedef DescriptorColl::const_iterator DescriptorConstIter;
82
83
84 dw_offset_t m_offset;
85 Header m_header;
86 typedef __gnu_cxx::hash_multimap<const char*, uint32_t, __gnu_cxx::hash<const char*>, CStringEqualBinaryPredicate> cstr_to_index_mmap;
87 DescriptorColl m_descriptors;
88 mutable cstr_to_index_mmap m_name_to_descriptor_index;
89};
90
91#endif // SymbolFileDWARF_DWARFDebugPubnamesSet_h_