LLDB mainline
DWARFDebugAranges.cpp
Go to the documentation of this file.
1//===-- DWARFDebugAranges.cpp ---------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "DWARFDebugAranges.h"
10#include "DWARFUnit.h"
11#include "LogChannelDWARF.h"
12#include "lldb/Utility/Log.h"
13#include "lldb/Utility/Timer.h"
14#include "llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h"
15
16using namespace lldb;
17using namespace lldb_private;
18using namespace lldb_private::plugin::dwarf;
19using llvm::DWARFDebugArangeSet;
20
21// Constructor
23
24// Extract
25void DWARFDebugAranges::extract(const DWARFDataExtractor &debug_aranges_data) {
26 llvm::DWARFDataExtractor dwarf_data = debug_aranges_data.GetAsLLVMDWARF();
27 lldb::offset_t offset = 0;
28
29 DWARFDebugArangeSet set;
30 Range range;
31 while (dwarf_data.isValidOffset(offset)) {
32 const lldb::offset_t set_offset = offset;
33 if (llvm::Error error = set.extract(dwarf_data, &offset)) {
35 LLDB_LOG_ERROR(log, std::move(error),
36 "DWARFDebugAranges::extract failed to extract "
37 ".debug_aranges set at offset {1:x}: {0}",
38 set_offset);
39 set.clear();
40 return;
41 }
42 const uint64_t cu_offset = set.getCompileUnitDIEOffset();
43 for (const auto &desc : set.descriptors()) {
44 if (desc.Length != 0)
46 RangeToDIE::Entry(desc.Address, desc.Length, cu_offset));
47 }
48 }
49}
50
51void DWARFDebugAranges::Dump(Log *log) const {
52 if (log == nullptr)
53 return;
54
55 const size_t num_entries = m_aranges.GetSize();
56 for (size_t i = 0; i < num_entries; ++i) {
58 if (entry)
59 LLDB_LOG(log, "{0:x8}: [{1:x16} - {2:x16})", entry->data,
60 entry->GetRangeBase(), entry->GetRangeEnd());
61 }
62}
63
65 dw_addr_t high_pc) {
66 if (high_pc > low_pc)
67 m_aranges.Append(RangeToDIE::Entry(low_pc, high_pc - low_pc, offset));
68}
69
70void DWARFDebugAranges::Sort(bool minimize) {
72
75}
76
77// FindAddress
80 if (entry)
81 return entry->data;
82 return DW_INVALID_OFFSET;
83}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition: Log.h:369
#define LLDB_LOG_ERROR(log, error,...)
Definition: Log.h:392
#define LLDB_SCOPED_TIMER()
Definition: Timer.h:83
llvm::DWARFDataExtractor GetAsLLVMDWARF() const
void CombineConsecutiveEntriesWithEqualData()
Definition: RangeMap.h:492
const Entry * GetEntryAtIndex(size_t i) const
Definition: RangeMap.h:534
void Append(const Entry &entry)
Definition: RangeMap.h:451
Entry * FindEntryThatContains(B addr)
Definition: RangeMap.h:569
void extract(const DWARFDataExtractor &debug_aranges_data)
dw_offset_t FindAddress(dw_addr_t address) const
void AppendRange(dw_offset_t cu_offset, dw_addr_t low_pc, dw_addr_t high_pc)
uint64_t dw_offset_t
Definition: dwarf.h:30
#define DW_INVALID_OFFSET
Definition: dwarf.h:35
uint64_t dw_addr_t
Definition: dwarf.h:26
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:332
Definition: SBAddress.h:15
uint64_t offset_t
Definition: lldb-types.h:85
BaseType GetRangeBase() const
Definition: RangeMap.h:45
BaseType GetRangeEnd() const
Definition: RangeMap.h:78