LLDB mainline
DWARFDebugInfoEntry.cpp
Go to the documentation of this file.
1//===-- DWARFDebugInfoEntry.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
10
11#include <cassert>
12
13#include <algorithm>
14#include <limits>
15#include <optional>
16
17#include "LogChannelDWARF.h"
18#include "lldb/Core/Module.h"
21#include "llvm/ADT/STLExtras.h"
22#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
23#include "llvm/Support/Error.h"
24#include "llvm/Support/FormatAdapters.h"
25#include "llvm/Support/LEB128.h"
26
27#include "DWARFCompileUnit.h"
28#include "DWARFDebugAranges.h"
29#include "DWARFDebugInfo.h"
30#include "DWARFDeclContext.h"
31#include "DWARFFormValue.h"
32#include "DWARFUnit.h"
33#include "SymbolFileDWARF.h"
34#include "SymbolFileDWARFDwo.h"
35
36using namespace lldb_private;
37using namespace lldb_private::plugin::dwarf;
38using namespace llvm::dwarf;
39extern int g_verbose;
40
41// Extract a debug info entry for a given DWARFUnit from the data
42// starting at the offset in offset_ptr
44 const DWARFUnit &unit,
45 lldb::offset_t *offset_ptr) {
46 m_offset = *offset_ptr;
47 auto report_error = [&](const char *fmt, const auto &...vals) {
48 unit.GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
49 "[{0:x16}]: {1}, please file a bug and "
50 "attach the file at the start of this error message",
51 static_cast<uint64_t>(m_offset), llvm::formatv(fmt, vals...));
52 *offset_ptr = std::numeric_limits<lldb::offset_t>::max();
53 return false;
54 };
55
56 m_parent_idx = 0;
57 m_sibling_idx = 0;
58 const uint64_t abbr_idx = data.GetULEB128(offset_ptr);
59 if (abbr_idx > std::numeric_limits<uint16_t>::max())
60 return report_error("abbreviation code {0} too big", abbr_idx);
61 m_abbr_idx = abbr_idx;
62
63 if (m_abbr_idx == 0) {
64 m_tag = llvm::dwarf::DW_TAG_null;
65 m_has_children = false;
66 return true; // NULL debug tag entry
67 }
68
69 const auto *abbrevDecl = GetAbbreviationDeclarationPtr(&unit);
70 if (abbrevDecl == nullptr)
71 return report_error("invalid abbreviation code {0}", abbr_idx);
72
73 m_tag = abbrevDecl->getTag();
74 m_has_children = abbrevDecl->hasChildren();
75 // Skip all data in the .debug_info or .debug_types for the attributes
76 for (const auto &attribute : abbrevDecl->attributes()) {
77 if (DWARFFormValue::SkipValue(attribute.Form, data, offset_ptr, &unit))
78 continue;
79
80 return report_error("Unsupported DW_FORM_{1:x}", attribute.Form);
81 }
82 return true;
83}
84
85static llvm::Expected<llvm::DWARFAddressRangesVector>
86GetRanges(DWARFUnit &unit, const DWARFFormValue &value) {
87 return (value.Form() == DW_FORM_rnglistx)
88 ? unit.FindRnglistFromIndex(value.Unsigned())
89 : unit.FindRnglistFromOffset(value.Unsigned());
90}
91
93 const llvm::DWARFAbbreviationDeclaration::AttributeSpec &attr_spec,
94 dw_attr_t &attr, DWARFFormValue &form_value) {
95 attr = attr_spec.Attr;
96 form_value.FormRef() = attr_spec.Form;
97 if (attr_spec.isImplicitConst())
98 form_value.SetSigned(attr_spec.getImplicitConstValue());
99}
100
101// GetDIENamesAndRanges
102//
103// Gets the valid address ranges for a given DIE by looking for a
104// DW_AT_low_pc/DW_AT_high_pc pair, DW_AT_entry_pc, or DW_AT_ranges attributes.
106 DWARFUnit *cu, const char *&name, const char *&mangled,
107 llvm::DWARFAddressRangesVector &ranges, std::optional<int> &decl_file,
108 std::optional<int> &decl_line, std::optional<int> &decl_column,
109 std::optional<int> &call_file, std::optional<int> &call_line,
110 std::optional<int> &call_column, DWARFExpressionList *frame_base) const {
113 std::vector<DWARFDIE> dies;
114 bool set_frame_base_loclist_addr = false;
115
117 lldb::ModuleSP module = dwarf.GetObjectFile()->GetModule();
118
119 if (const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu)) {
120 const DWARFDataExtractor &data = cu->GetData();
122
123 if (!data.ValidOffset(offset))
124 return false;
125
126 bool do_offset = false;
127
128 for (const auto &attribute : abbrevDecl->attributes()) {
129 DWARFFormValue form_value(cu);
130 dw_attr_t attr;
131 ExtractAttrAndFormValue(attribute, attr, form_value);
132
133 if (form_value.ExtractValue(data, &offset)) {
134 switch (attr) {
135 case DW_AT_low_pc:
136 lo_pc = form_value.Address();
137
138 if (do_offset)
139 hi_pc += lo_pc;
140 do_offset = false;
141 break;
142
143 case DW_AT_entry_pc:
144 lo_pc = form_value.Address();
145 break;
146
147 case DW_AT_high_pc:
148 if (form_value.Form() == DW_FORM_addr ||
149 form_value.Form() == DW_FORM_addrx ||
150 form_value.Form() == DW_FORM_GNU_addr_index) {
151 hi_pc = form_value.Address();
152 } else {
153 hi_pc = form_value.Unsigned();
154 if (lo_pc == LLDB_INVALID_ADDRESS)
155 do_offset = hi_pc != LLDB_INVALID_ADDRESS;
156 else
157 hi_pc += lo_pc; // DWARF 4 introduces <offset-from-lo-pc> to save
158 // on relocations
159 }
160 break;
161
162 case DW_AT_ranges:
163 if (llvm::Expected<llvm::DWARFAddressRangesVector> r =
164 GetRanges(*cu, form_value)) {
165 ranges = std::move(*r);
166 } else {
167 module->ReportError(
168 "[{0:x16}]: DIE has DW_AT_ranges({1} {2:x16}) attribute, but "
169 "range extraction failed ({3}), please file a bug "
170 "and attach the file at the start of this error message",
171 GetOffset(), llvm::dwarf::FormEncodingString(form_value.Form()),
172 form_value.Unsigned(), fmt_consume(r.takeError()));
173 }
174 break;
175
176 case DW_AT_name:
177 if (name == nullptr)
178 name = form_value.AsCString();
179 break;
180
181 case DW_AT_MIPS_linkage_name:
182 case DW_AT_linkage_name:
183 if (mangled == nullptr)
184 mangled = form_value.AsCString();
185 break;
186
187 case DW_AT_abstract_origin:
188 dies.push_back(form_value.Reference());
189 break;
190
191 case DW_AT_specification:
192 dies.push_back(form_value.Reference());
193 break;
194
195 case DW_AT_decl_file:
196 if (!decl_file)
197 decl_file = form_value.Unsigned();
198 break;
199
200 case DW_AT_decl_line:
201 if (!decl_line)
202 decl_line = form_value.Unsigned();
203 break;
204
205 case DW_AT_decl_column:
206 if (!decl_column)
207 decl_column = form_value.Unsigned();
208 break;
209
210 case DW_AT_call_file:
211 if (!call_file)
212 call_file = form_value.Unsigned();
213 break;
214
215 case DW_AT_call_line:
216 if (!call_line)
217 call_line = form_value.Unsigned();
218 break;
219
220 case DW_AT_call_column:
221 if (!call_column)
222 call_column = form_value.Unsigned();
223 break;
224
225 case DW_AT_frame_base:
226 if (frame_base) {
227 if (form_value.BlockData()) {
228 uint64_t block_offset =
229 form_value.BlockData() - data.GetDataStart();
230 uint64_t block_length = form_value.Unsigned();
231 *frame_base =
232 DWARFExpressionList(module,
234 data, block_offset, block_length)),
235 cu);
236 } else {
237 DataExtractor data = cu->GetLocationData();
238 const dw_offset_t offset = form_value.Unsigned();
239 if (data.ValidOffset(offset)) {
240 data = DataExtractor(data, offset, data.GetByteSize() - offset);
241 if (lo_pc != LLDB_INVALID_ADDRESS) {
242 assert(lo_pc >= cu->GetBaseAddress());
243 cu->ParseDWARFLocationList(data, *frame_base);
244 frame_base->SetFuncFileAddress(lo_pc);
245 } else
246 set_frame_base_loclist_addr = true;
247 }
248 }
249 }
250 break;
251
252 default:
253 break;
254 }
255 }
256 }
257 }
258
259 if (ranges.empty() && lo_pc != LLDB_INVALID_ADDRESS) {
260 lldb::addr_t range_hi_pc =
261 (hi_pc != LLDB_INVALID_ADDRESS && hi_pc > lo_pc) ? hi_pc : lo_pc;
262 ranges.emplace_back(lo_pc, range_hi_pc);
263 }
264
265 if (set_frame_base_loclist_addr && !ranges.empty()) {
266 dw_addr_t file_addr = ranges.begin()->LowPC;
267 assert(file_addr >= cu->GetBaseAddress());
268 frame_base->SetFuncFileAddress(file_addr);
269 }
270
271 if (ranges.empty() || name == nullptr || mangled == nullptr) {
272 for (const DWARFDIE &die : dies) {
273 if (die) {
274 die.GetDIE()->GetDIENamesAndRanges(die.GetCU(), name, mangled, ranges,
275 decl_file, decl_line, decl_column,
276 call_file, call_line, call_column);
277 }
278 }
279 }
280 return !ranges.empty();
281}
282
283/// Helper for the public \ref DWARFDebugInfoEntry::GetAttributes API.
284/// Adds all attributes of the DIE at the top of the \c worklist to the
285/// \c attributes list. Specifcations and abstract origins are added
286/// to the \c worklist if the referenced DIE has not been seen before.
287static bool
289 llvm::SmallPtrSet<DWARFDebugInfoEntry const *, 3> &seen,
290 DWARFAttributes &attributes) {
291 assert(!worklist.empty() && "Need at least one DIE to visit.");
292 assert(seen.size() >= 1 &&
293 "Need to have seen at least the currently visited entry.");
294
295 DWARFDIE current = worklist.pop_back_val();
296
297 const auto *cu = current.GetCU();
298 assert(cu);
299
300 const auto *entry = current.GetDIE();
301 assert(entry);
302
303 const auto *abbrevDecl =
304 entry->GetAbbreviationDeclarationPtr(current.GetCU());
305 if (!abbrevDecl)
306 return false;
307
308 const DWARFDataExtractor &data = cu->GetData();
309 lldb::offset_t offset = current.GetDIE()->GetFirstAttributeOffset();
310
311 const bool is_first_die = seen.size() == 1;
312
313 for (const auto &attribute : abbrevDecl->attributes()) {
314 DWARFFormValue form_value(cu);
315 dw_attr_t attr;
316 ExtractAttrAndFormValue(attribute, attr, form_value);
317
318 // If we are tracking down DW_AT_specification or DW_AT_abstract_origin
319 // attributes, the depth will be non-zero. We need to omit certain
320 // attributes that don't make sense.
321 switch (attr) {
322 case DW_AT_sibling:
323 case DW_AT_declaration:
324 if (!is_first_die) {
325 // This attribute doesn't make sense when combined with the DIE that
326 // references this DIE. We know a DIE is referencing this DIE because
327 // we've visited more than one DIE already.
328 break;
329 }
330 [[fallthrough]];
331 default:
332 attributes.Append(form_value, offset, attr);
333 break;
334 }
335
336 if (attr == DW_AT_specification || attr == DW_AT_abstract_origin) {
337 if (form_value.ExtractValue(data, &offset)) {
338 if (DWARFDIE spec_die = form_value.Reference()) {
339 if (seen.insert(spec_die.GetDIE()).second)
340 worklist.push_back(spec_die);
341 }
342 }
343 } else {
344 const dw_form_t form = form_value.Form();
345 std::optional<uint8_t> fixed_skip_size =
347 if (fixed_skip_size)
348 offset += *fixed_skip_size;
349 else
350 DWARFFormValue::SkipValue(form, data, &offset, cu);
351 }
352 }
353
354 return true;
355}
356
358 Recurse recurse) const {
359 // FIXME: use ElaboratingDIEIterator to follow specifications/abstract origins
360 // instead of maintaining our own worklist/seen list.
361
362 DWARFAttributes attributes;
363
364 llvm::SmallVector<DWARFDIE, 3> worklist;
365 worklist.emplace_back(cu, this);
366
367 // Keep track if DIEs already seen to prevent infinite recursion.
368 // Value of '3' was picked for the same reason that
369 // DWARFDie::findRecursively does.
370 llvm::SmallPtrSet<DWARFDebugInfoEntry const *, 3> seen;
371 seen.insert(this);
372
373 do {
374 if (!::GetAttributes(worklist, seen, attributes)) {
375 attributes.Clear();
376 break;
377 }
378 } while (!worklist.empty() && recurse == Recurse::yes);
379
380 return attributes;
381}
382
383// GetAttributeValue
384//
385// Get the value of an attribute and return the .debug_info or .debug_types
386// offset of the attribute if it was properly extracted into form_value,
387// or zero if we fail since an offset of zero is invalid for an attribute (it
388// would be a compile unit header).
390 const DWARFUnit *cu, const dw_attr_t attr, DWARFFormValue &form_value,
391 dw_offset_t *end_attr_offset_ptr, bool check_elaborating_dies) const {
392 if (const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu)) {
393 std::optional<uint32_t> attr_idx = abbrevDecl->findAttributeIndex(attr);
394
395 if (attr_idx) {
396 const DWARFDataExtractor &data = cu->GetData();
398
399 uint32_t idx = 0;
400 while (idx < *attr_idx)
401 DWARFFormValue::SkipValue(abbrevDecl->getFormByIndex(idx++), data,
402 &offset, cu);
403
404 const dw_offset_t attr_offset = offset;
405 form_value.SetUnit(cu);
406 form_value.SetForm(abbrevDecl->getFormByIndex(idx));
407 if (abbrevDecl->getAttrIsImplicitConstByIndex(idx))
408 form_value.SetValue(abbrevDecl->getAttrImplicitConstValueByIndex(idx));
409
410 if (form_value.ExtractValue(data, &offset)) {
411 if (end_attr_offset_ptr)
412 *end_attr_offset_ptr = offset;
413 return attr_offset;
414 }
415 }
416 }
417
418 if (check_elaborating_dies) {
419 for (dw_attr_t elaborating_attr :
420 {DW_AT_specification, DW_AT_abstract_origin, DW_AT_signature}) {
421 if (!GetAttributeValue(cu, elaborating_attr, form_value))
422 continue;
423 DWARFDIE die = form_value.Reference();
424 if (!die)
425 continue;
426 dw_offset_t die_offset = die.GetDIE()->GetAttributeValue(
427 die.GetCU(), attr, form_value, end_attr_offset_ptr, false);
428 if (die_offset)
429 return die_offset;
430 }
431 }
432 return 0;
433}
434
435// GetAttributeValueAsString
436//
437// Get the value of an attribute as a string return it. The resulting pointer
438// to the string data exists within the supplied SymbolFileDWARF and will only
439// be available as long as the SymbolFileDWARF is still around and it's content
440// doesn't change.
442 const DWARFUnit *cu, const dw_attr_t attr, const char *fail_value,
443 bool check_elaborating_dies) const {
444 DWARFFormValue form_value;
445 if (GetAttributeValue(cu, attr, form_value, nullptr, check_elaborating_dies))
446 return form_value.AsCString();
447 return fail_value;
448}
449
450// GetAttributeValueAsUnsigned
451//
452// Get the value of an attribute as unsigned and return it.
454 const DWARFUnit *cu, const dw_attr_t attr, uint64_t fail_value,
455 bool check_elaborating_dies) const {
456 DWARFFormValue form_value;
457 if (GetAttributeValue(cu, attr, form_value, nullptr, check_elaborating_dies))
458 return form_value.Unsigned();
459 return fail_value;
460}
461
462std::optional<uint64_t>
464 const DWARFUnit *cu, const dw_attr_t attr,
465 bool check_elaborating_dies) const {
466 DWARFFormValue form_value;
467 if (GetAttributeValue(cu, attr, form_value, nullptr, check_elaborating_dies))
468 return form_value.Unsigned();
469 return std::nullopt;
470}
471
472// GetAttributeValueAsReference
473//
474// Get the value of an attribute as reference and fix up and compile unit
475// relative offsets as needed.
477 const DWARFUnit *cu, const dw_attr_t attr,
478 bool check_elaborating_dies) const {
479 DWARFFormValue form_value;
480 if (GetAttributeValue(cu, attr, form_value, nullptr, check_elaborating_dies))
481 return form_value.Reference();
482 return {};
483}
484
486 const DWARFUnit *cu, const dw_attr_t attr, uint64_t fail_value,
487 bool check_elaborating_dies) const {
488 DWARFFormValue form_value;
489 if (GetAttributeValue(cu, attr, form_value, nullptr, check_elaborating_dies))
490 return form_value.Address();
491 return fail_value;
492}
493
494// GetAttributeHighPC
495//
496// Get the hi_pc, adding hi_pc to lo_pc when specified as an <offset-from-low-
497// pc>.
498//
499// Returns the hi_pc or fail_value.
502 uint64_t fail_value,
503 bool check_elaborating_dies) const {
504 DWARFFormValue form_value;
505 if (GetAttributeValue(cu, DW_AT_high_pc, form_value, nullptr,
506 check_elaborating_dies)) {
507 dw_form_t form = form_value.Form();
508 if (form == DW_FORM_addr || form == DW_FORM_addrx ||
509 form == DW_FORM_GNU_addr_index)
510 return form_value.Address();
511
512 // DWARF4 can specify the hi_pc as an <offset-from-lowpc>
513 return lo_pc + form_value.Unsigned();
514 }
515 return fail_value;
516}
517
518// GetAttributeAddressRange
519//
520// Get the lo_pc and hi_pc, adding hi_pc to lo_pc when specified as an <offset-
521// from-low-pc>.
522//
523// Returns true or sets lo_pc and hi_pc to fail_value.
525 const DWARFUnit *cu, dw_addr_t &lo_pc, dw_addr_t &hi_pc,
526 uint64_t fail_value, bool check_elaborating_dies) const {
527 lo_pc = GetAttributeValueAsAddress(cu, DW_AT_low_pc, fail_value,
528 check_elaborating_dies);
529 if (lo_pc != fail_value) {
530 hi_pc = GetAttributeHighPC(cu, lo_pc, fail_value, check_elaborating_dies);
531 if (hi_pc != fail_value)
532 return true;
533 }
534 lo_pc = fail_value;
535 hi_pc = fail_value;
536 return false;
537}
538
539llvm::Expected<llvm::DWARFAddressRangesVector>
541 DWARFUnit *cu, bool check_hi_lo_pc, bool check_elaborating_dies) const {
542
543 DWARFFormValue form_value;
544 if (GetAttributeValue(cu, DW_AT_ranges, form_value))
545 return GetRanges(*cu, form_value);
546
547 if (check_hi_lo_pc) {
551 check_elaborating_dies) &&
552 lo_pc < hi_pc)
553 return llvm::DWARFAddressRangesVector{{lo_pc, hi_pc}};
554 }
555 return llvm::createStringError("DIE has no address range information");
556}
557
558// GetName
559//
560// Get value of the DW_AT_name attribute and return it if one exists, else
561// return NULL.
562const char *DWARFDebugInfoEntry::GetName(const DWARFUnit *cu) const {
563 return GetAttributeValueAsString(cu, DW_AT_name, nullptr, true);
564}
565
566// GetMangledName
567//
568// Get value of the DW_AT_MIPS_linkage_name attribute and return it if one
569// exists, else return the value of the DW_AT_name attribute
570const char *
572 bool substitute_name_allowed) const {
573 const char *name = nullptr;
574
575 name = GetAttributeValueAsString(cu, DW_AT_MIPS_linkage_name, nullptr, true);
576 if (name)
577 return name;
578
579 name = GetAttributeValueAsString(cu, DW_AT_linkage_name, nullptr, true);
580 if (name)
581 return name;
582
583 if (!substitute_name_allowed)
584 return nullptr;
585
586 name = GetAttributeValueAsString(cu, DW_AT_name, nullptr, true);
587 return name;
588}
589
590// GetPubname
591//
592// Get value the name for a DIE as it should appear for a .debug_pubnames or
593// .debug_pubtypes section.
594const char *DWARFDebugInfoEntry::GetPubname(const DWARFUnit *cu) const {
595 const char *name = nullptr;
596 if (!cu)
597 return name;
598
599 name = GetAttributeValueAsString(cu, DW_AT_MIPS_linkage_name, nullptr, true);
600 if (name)
601 return name;
602
603 name = GetAttributeValueAsString(cu, DW_AT_linkage_name, nullptr, true);
604 if (name)
605 return name;
606
607 name = GetAttributeValueAsString(cu, DW_AT_name, nullptr, true);
608 return name;
609}
610
611/// This function is builds a table very similar to the standard .debug_aranges
612/// table, except that the actual DIE offset for the function is placed in the
613/// table instead of the compile unit offset.
615 DWARFUnit *cu, DWARFDebugAranges *debug_aranges) const {
617 if (m_tag) {
618 // Subprogram forward declarations don't have
619 // DW_AT_ranges/DW_AT_low_pc/DW_AT_high_pc attributes, so don't even try
620 // getting address range information for them.
621 if (m_tag == DW_TAG_subprogram &&
622 !GetAttributeValueAsOptionalUnsigned(cu, DW_AT_declaration)) {
623 if (llvm::Expected<llvm::DWARFAddressRangesVector> ranges =
624 GetAttributeAddressRanges(cu, /*check_hi_lo_pc=*/true)) {
625 for (const auto &r : *ranges)
626 debug_aranges->AppendRange(GetOffset(), r.LowPC, r.HighPC);
627 } else {
628 LLDB_LOG_ERROR(log, ranges.takeError(), "DIE({1:x}): {0}", GetOffset());
629 }
630 }
631
632 const DWARFDebugInfoEntry *child = GetFirstChild();
633 while (child) {
634 child->BuildFunctionAddressRangeTable(cu, debug_aranges);
635 child = child->GetSibling();
636 }
637 }
638}
639
641 return GetOffset() + llvm::getULEB128Size(m_abbr_idx);
642}
643
644const llvm::DWARFAbbreviationDeclaration *
646 if (!cu)
647 return nullptr;
648
649 const llvm::DWARFAbbreviationDeclarationSet *abbrev_set =
650 cu->GetAbbreviations();
651 if (!abbrev_set)
652 return nullptr;
653
654 return abbrev_set->getAbbreviationDeclaration(m_abbr_idx);
655}
656
658 if (Tag() != DW_TAG_variable && Tag() != DW_TAG_member)
659 return false;
660 const DWARFDebugInfoEntry *parent_die = GetParent();
661 while (parent_die != nullptr) {
662 switch (parent_die->Tag()) {
663 case DW_TAG_subprogram:
664 case DW_TAG_lexical_block:
665 case DW_TAG_inlined_subroutine:
666 return false;
667
668 case DW_TAG_compile_unit:
669 case DW_TAG_partial_unit:
670 return true;
671
672 default:
673 break;
674 }
675 parent_die = parent_die->GetParent();
676 }
677 return false;
678}
679
681 return m_offset == rhs.m_offset && m_parent_idx == rhs.m_parent_idx &&
684 m_tag == rhs.m_tag;
685}
686
688 return !(*this == rhs);
689}
static void ExtractAttrAndFormValue(const llvm::DWARFAbbreviationDeclaration::AttributeSpec &attr_spec, dw_attr_t &attr, DWARFFormValue &form_value)
static bool GetAttributes(llvm::SmallVectorImpl< DWARFDIE > &worklist, llvm::SmallPtrSet< DWARFDebugInfoEntry const *, 3 > &seen, DWARFAttributes &attributes)
Helper for the public DWARFDebugInfoEntry::GetAttributes API.
static llvm::Expected< llvm::DWARFAddressRangesVector > GetRanges(DWARFUnit &unit, const DWARFFormValue &value)
int g_verbose
#define LLDB_LOG_ERROR(log, error,...)
Definition Log.h:392
"lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file address range to a single ...
void SetFuncFileAddress(lldb::addr_t func_file_addr)
"lldb/Expression/DWARFExpression.h" Encapsulates a DWARF location expression and interprets it.
An data extractor class.
uint64_t GetULEB128(lldb::offset_t *offset_ptr) const
Extract a unsigned LEB128 value from *offset_ptr.
const void * GetData(lldb::offset_t *offset_ptr, lldb::offset_t length) const
Extract length bytes from *offset_ptr.
uint64_t GetByteSize() const
Get the number of bytes contained in this object.
const uint8_t * GetDataStart() const
Get the data start pointer.
bool ValidOffset(lldb::offset_t offset) const
Test the validity of offset.
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
ObjectFile * GetObjectFile() override
Definition SymbolFile.h:566
void Append(const DWARFFormValue &form_value, dw_offset_t attr_die_offset, dw_attr_t attr)
DWARFDIE GetDIE(dw_offset_t die_offset) const
Definition DWARFDIE.cpp:126
void AppendRange(dw_offset_t cu_offset, dw_addr_t low_pc, dw_addr_t high_pc)
bool operator==(const DWARFDebugInfoEntry &rhs) const
dw_tag_t m_tag
A copy of the DW_TAG value so we don't have to go through the compile unit abbrev table.
bool GetAttributeAddressRange(const DWARFUnit *cu, dw_addr_t &lo_pc, dw_addr_t &hi_pc, uint64_t fail_value, bool check_elaborating_dies=false) const
dw_addr_t GetAttributeHighPC(const DWARFUnit *cu, dw_addr_t lo_pc, uint64_t fail_value, bool check_elaborating_dies=false) const
bool operator!=(const DWARFDebugInfoEntry &rhs) const
llvm::Expected< llvm::DWARFAddressRangesVector > GetAttributeAddressRanges(DWARFUnit *cu, bool check_hi_lo_pc, bool check_elaborating_dies=false) const
DWARFAttributes GetAttributes(const DWARFUnit *cu, Recurse recurse=Recurse::yes) const
Get all attribute values for a given DIE, optionally following any specifications and abstract origin...
const char * GetMangledName(const DWARFUnit *cu, bool substitute_name_allowed=true) const
std::optional< uint64_t > GetAttributeValueAsOptionalUnsigned(const DWARFUnit *cu, const dw_attr_t attr, bool check_elaborating_dies=false) const
const llvm::DWARFAbbreviationDeclaration * GetAbbreviationDeclarationPtr(const DWARFUnit *cu) const
void BuildFunctionAddressRangeTable(DWARFUnit *cu, DWARFDebugAranges *debug_aranges) const
This function is builds a table very similar to the standard .debug_aranges table,...
DWARFDIE GetAttributeValueAsReference(const DWARFUnit *cu, const dw_attr_t attr, bool check_elaborating_dies=false) const
const char * GetAttributeValueAsString(const DWARFUnit *cu, const dw_attr_t attr, const char *fail_value, bool check_elaborating_dies=false) const
bool GetDIENamesAndRanges(DWARFUnit *cu, const char *&name, const char *&mangled, llvm::DWARFAddressRangesVector &rangeList, std::optional< int > &decl_file, std::optional< int > &decl_line, std::optional< int > &decl_column, std::optional< int > &call_file, std::optional< int > &call_line, std::optional< int > &call_column, DWARFExpressionList *frame_base=nullptr) const
uint64_t GetAttributeValueAsAddress(const DWARFUnit *cu, const dw_attr_t attr, uint64_t fail_value, bool check_elaborating_dies=false) const
uint64_t GetAttributeValueAsUnsigned(const DWARFUnit *cu, const dw_attr_t attr, uint64_t fail_value, bool check_elaborating_dies=false) const
const char * GetPubname(const DWARFUnit *cu) const
bool Extract(const DWARFDataExtractor &data, const DWARFUnit &cu, lldb::offset_t *offset_ptr)
dw_offset_t GetAttributeValue(const DWARFUnit *cu, const dw_attr_t attr, DWARFFormValue &formValue, dw_offset_t *end_attr_offset_ptr=nullptr, bool check_elaborating_dies=false) const
const char * GetName(const DWARFUnit *cu) const
bool ExtractValue(const DWARFDataExtractor &data, lldb::offset_t *offset_ptr)
std::optional< uint8_t > GetFixedSize() const
bool SkipValue(const DWARFDataExtractor &debug_info_data, lldb::offset_t *offset_ptr) const
llvm::Expected< llvm::DWARFAddressRangesVector > FindRnglistFromOffset(dw_offset_t offset)
Return a list of address ranges resulting from a (possibly encoded) range list starting at a given of...
SymbolFileDWARF & GetSymbolFileDWARF() const
Definition DWARFUnit.h:200
dw_addr_t GetBaseAddress() const override
Definition DWARFUnit.h:131
const DWARFDataExtractor & GetData() const
Get the data that contains the DIE information for this unit.
DWARFDataExtractor GetLocationData() const
bool ParseDWARFLocationList(const DataExtractor &data, DWARFExpressionList &loc_list) const
llvm::Expected< llvm::DWARFAddressRangesVector > FindRnglistFromIndex(uint32_t index)
Return a list of address ranges retrieved from an encoded range list whose offset is found via a tabl...
const llvm::DWARFAbbreviationDeclarationSet * GetAbbreviations() const
uint64_t dw_offset_t
Definition dwarf.h:24
llvm::dwarf::Attribute dw_attr_t
Definition dwarf.h:17
uint64_t dw_addr_t
Definition dwarf.h:20
llvm::dwarf::Form dw_form_t
Definition dwarf.h:18
#define LLDB_INVALID_ADDRESS
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
uint64_t offset_t
Definition lldb-types.h:85
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::Module > ModuleSP