1 //===-- DWARFDebugAranges.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_DWARFDebugAranges_h_
11 #define SymbolFileDWARF_DWARFDebugAranges_h_
12 
13 #include "DWARFDebugArangeSet.h"
14 #include <list>
15 
16 #include "lldb/Core/RangeMap.h"
17 
18 class SymbolFileDWARF;
19 
20 class DWARFDebugAranges
21 {
22 protected:
23     typedef lldb_private::RangeDataArray<dw_addr_t, uint32_t, dw_offset_t, 1> RangeToDIE;
24 
25 public:
26     typedef RangeToDIE::Entry Range;
27     typedef std::vector<RangeToDIE::Entry> RangeColl;
28 
29     DWARFDebugAranges();
30 
31     void
Clear()32     Clear()
33     {
34         m_aranges.Clear();
35     }
36 
37     bool
38     Extract(const lldb_private::DataExtractor &debug_aranges_data);
39 
40     bool
41     Generate(SymbolFileDWARF* dwarf2Data);
42 
43                 // Use append range multiple times and then call sort
44     void
45     AppendRange (dw_offset_t cu_offset,
46                  dw_addr_t low_pc,
47                  dw_addr_t high_pc);
48 
49     void
50     Sort (bool minimize);
51 
52     const Range*
RangeAtIndex(uint32_t idx)53     RangeAtIndex(uint32_t idx) const
54     {
55         return m_aranges.GetEntryAtIndex (idx);
56     }
57 
58     void
59     Dump (lldb_private::Log *log) const;
60 
61     dw_offset_t
62     FindAddress(dw_addr_t address) const;
63 
64     bool
IsEmpty()65     IsEmpty() const
66     {
67         return m_aranges.IsEmpty();
68     }
69     size_t
GetNumRanges()70     GetNumRanges() const
71     {
72         return m_aranges.GetSize();
73     }
74 
75     dw_offset_t
OffsetAtIndex(uint32_t idx)76     OffsetAtIndex(uint32_t idx) const
77     {
78         const Range *range = m_aranges.GetEntryAtIndex (idx);
79         if (range)
80             return range->data;
81         return DW_INVALID_OFFSET;
82     }
83 
84     static void
85     Dump(SymbolFileDWARF* dwarf2Data, lldb_private::Stream *s);
86 
87 protected:
88 
89 
90     RangeToDIE m_aranges;
91 };
92 
93 
94 #endif  // SymbolFileDWARF_DWARFDebugAranges_h_
95