LLDB mainline
DWARFUnit.cpp
Go to the documentation of this file.
1//===-- DWARFUnit.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 "DWARFUnit.h"
10
11#include "lldb/Core/Module.h"
15#include "lldb/Utility/Timer.h"
16#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
17#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
18#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
19#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
20#include "llvm/Object/Error.h"
21
22#include "DWARFCompileUnit.h"
23#include "DWARFDebugAranges.h"
24#include "DWARFDebugInfo.h"
25#include "DWARFTypeUnit.h"
26#include "LogChannelDWARF.h"
27#include "SymbolFileDWARFDwo.h"
28#include <optional>
29
30using namespace lldb;
31using namespace lldb_private;
32using namespace lldb_private::plugin::dwarf;
33using namespace llvm::dwarf;
34
35extern int g_verbose;
36
38 const llvm::DWARFUnitHeader &header,
39 const llvm::DWARFAbbreviationDeclarationSet &abbrevs,
40 DIERef::Section section, bool is_dwo)
41 : UserID(uid), m_dwarf(dwarf), m_header(header), m_abbrevs(&abbrevs),
42 m_cancel_scopes(false), m_section(section), m_is_dwo(is_dwo),
43 m_has_parsed_non_skeleton_unit(false), m_dwo_id(header.getDWOId()) {}
44
45DWARFUnit::~DWARFUnit() = default;
46
47// Parses first DIE of a compile unit, excluding DWO.
49 {
50 llvm::sys::ScopedReader lock(m_first_die_mutex);
51 if (m_first_die)
52 return; // Already parsed
53 }
54 llvm::sys::ScopedWriter lock(m_first_die_mutex);
55 if (m_first_die)
56 return; // Already parsed
57
58 ElapsedTime elapsed(m_dwarf.GetDebugInfoParseTimeRef());
59
60 // Set the offset to that of the first DIE and calculate the start of the
61 // next compilation unit header.
63
64 // We are in our compile unit, parse starting at the offset we were told to
65 // parse
66 const DWARFDataExtractor &data = GetData();
67 if (offset < GetNextUnitOffset() &&
68 m_first_die.Extract(data, *this, &offset)) {
70 return;
71 }
72}
73
74// Parses first DIE of a compile unit including DWO.
77
79 return;
80
82 m_dwo_error.Clear();
83
84 if (!m_dwo_id)
85 return; // No DWO file.
86
87 std::shared_ptr<SymbolFileDWARFDwo> dwo_symbol_file =
88 m_dwarf.GetDwoSymbolFileForCompileUnit(*this, m_first_die);
89 if (!dwo_symbol_file)
90 return;
91
92 DWARFUnit *dwo_cu = dwo_symbol_file->GetDWOCompileUnitForHash(*m_dwo_id);
93
94 if (!dwo_cu) {
96 "unable to load .dwo file from \"{0}\" due to ID ({1:x16}) mismatch "
97 "for skeleton DIE at {2:x8}",
98 dwo_symbol_file->GetObjectFile()->GetFileSpec().GetPath(), *m_dwo_id,
99 m_first_die.GetOffset()));
100 return; // Can't fetch the compile unit from the dwo file.
101 }
102
103 // Link the DWO unit to this object, if it hasn't been linked already (this
104 // can happen when we have an index, and the DWO unit is parsed first).
105 if (!dwo_cu->LinkToSkeletonUnit(*this)) {
107 "multiple compile units with Dwo ID {0:x16}", *m_dwo_id));
108 return;
109 }
110
111 DWARFBaseDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
112 if (!dwo_cu_die.IsValid()) {
113 // Can't fetch the compile unit DIE from the dwo file.
115 "unable to extract compile unit DIE from .dwo file for skeleton "
116 "DIE at {0:x16}",
117 m_first_die.GetOffset()));
118 return;
119 }
120
121 // Here for DWO CU we want to use the address base set in the skeleton unit
122 // (DW_AT_addr_base) if it is available and use the DW_AT_GNU_addr_base
123 // otherwise. We do that because pre-DWARF v5 could use the DW_AT_GNU_*
124 // attributes which were applicable to the DWO units. The corresponding
125 // DW_AT_* attributes standardized in DWARF v5 are also applicable to the
126 // main unit in contrast.
127 if (m_addr_base)
128 dwo_cu->SetAddrBase(*m_addr_base);
129 else if (m_gnu_addr_base)
131
132 if (GetVersion() <= 4 && m_gnu_ranges_base)
134 else if (dwo_symbol_file->GetDWARFContext()
135 .getOrLoadRngListsData()
136 .GetByteSize() > 0)
137 dwo_cu->SetRangesBase(
138 llvm::DWARFListTableHeader::getHeaderSize(GetFormParams().Format));
139
140 if (GetVersion() >= 5 &&
141 dwo_symbol_file->GetDWARFContext().getOrLoadLocListsData().GetByteSize() >
142 0)
143 dwo_cu->SetLoclistsBase(
144 llvm::DWARFListTableHeader::getHeaderSize(GetFormParams().Format));
145
147
148 m_dwo = std::shared_ptr<DWARFUnit>(std::move(dwo_symbol_file), dwo_cu);
149}
150
151// Parses a compile unit and indexes its DIEs if it hasn't already been done.
152// It will leave this compile unit extracted forever.
154 m_cancel_scopes = true;
155
156 {
157 llvm::sys::ScopedReader lock(m_die_array_mutex);
158 if (!m_die_array.empty())
159 return; // Already parsed
160 }
161 llvm::sys::ScopedWriter lock(m_die_array_mutex);
162 if (!m_die_array.empty())
163 return; // Already parsed
164
166}
167
168// Parses a compile unit and indexes its DIEs if it hasn't already been done.
169// It will clear this compile unit after returned instance gets out of scope,
170// no other ScopedExtractDIEs instance is running for this compile unit
171// and no ExtractDIEsIfNeeded() has been executed during this ScopedExtractDIEs
172// lifetime.
174 ScopedExtractDIEs scoped(*this);
175
176 {
177 llvm::sys::ScopedReader lock(m_die_array_mutex);
178 if (!m_die_array.empty())
179 return scoped; // Already parsed
180 }
181 llvm::sys::ScopedWriter lock(m_die_array_mutex);
182 if (!m_die_array.empty())
183 return scoped; // Already parsed
184
185 // Otherwise m_die_array would be already populated.
187
189 scoped.m_clear_dies = true;
190 return scoped;
191}
192
194 llvm::sys::ScopedLock lock(m_cu->m_die_array_scoped_mutex);
195 ++m_cu->m_die_array_scoped_count;
196}
197
199 if (!m_cu)
200 return;
201 llvm::sys::ScopedLock lock(m_cu->m_die_array_scoped_mutex);
202 --m_cu->m_die_array_scoped_count;
203 if (m_cu->m_die_array_scoped_count == 0 && m_clear_dies &&
204 !m_cu->m_cancel_scopes) {
205 llvm::sys::ScopedWriter lock(m_cu->m_die_array_mutex);
206 m_cu->ClearDIEsRWLocked();
207 }
208}
209
214
217 m_cu = rhs.m_cu;
218 rhs.m_cu = nullptr;
219 m_clear_dies = rhs.m_clear_dies;
220 return *this;
221}
222
223// Parses a compile unit and indexes its DIEs, m_die_array_mutex must be
224// held R/W and m_die_array must be empty.
226 llvm::sys::ScopedWriter first_die_lock(m_first_die_mutex);
227
228 ElapsedTime elapsed(m_dwarf.GetDebugInfoParseTimeRef());
230 "%s",
231 llvm::formatv("{0:x16}: DWARFUnit::ExtractDIEsIfNeeded()", GetOffset())
232 .str()
233 .c_str());
234
235 // Set the offset to that of the first DIE and calculate the start of the
236 // next compilation unit header.
238 lldb::offset_t next_cu_offset = GetNextUnitOffset();
239
241
242 uint32_t depth = 0;
243 // We are in our compile unit, parse starting at the offset we were told to
244 // parse
245 const DWARFDataExtractor &data = GetData();
246 std::vector<uint32_t> die_index_stack;
247 die_index_stack.reserve(32);
248 die_index_stack.push_back(0);
249 bool prev_die_had_children = false;
250 while (offset < next_cu_offset && die.Extract(data, *this, &offset)) {
251 const bool null_die = die.IsNULL();
252 if (depth == 0) {
253 assert(m_die_array.empty() && "Compile unit DIE already added");
254
255 // The average bytes per DIE entry has been seen to be around 14-20 so
256 // lets pre-reserve half of that since we are now stripping the NULL
257 // tags.
258
259 // Only reserve the memory if we are adding children of the main
260 // compile unit DIE. The compile unit DIE is always the first entry, so
261 // if our size is 1, then we are adding the first compile unit child
262 // DIE and should reserve the memory.
263 m_die_array.reserve(GetDebugInfoSize() / 24);
264 m_die_array.push_back(die);
265
266 if (!m_first_die)
267 AddUnitDIE(m_die_array.front());
268
269 // With -fsplit-dwarf-inlining, clang will emit non-empty skeleton compile
270 // units. We are not able to access these DIE *and* the dwo file
271 // simultaneously. We also don't need to do that as the dwo file will
272 // contain a superset of information. So, we don't even attempt to parse
273 // any remaining DIEs.
274 if (m_dwo) {
275 m_die_array.front().SetHasChildren(false);
276 break;
277 }
278
279 } else {
280 if (null_die) {
281 if (prev_die_had_children) {
282 // This will only happen if a DIE says is has children but all it
283 // contains is a NULL tag. Since we are removing the NULL DIEs from
284 // the list (saves up to 25% in C++ code), we need a way to let the
285 // DIE know that it actually doesn't have children.
286 if (!m_die_array.empty())
287 m_die_array.back().SetHasChildren(false);
288 }
289 } else {
290 die.SetParentIndex(m_die_array.size() - die_index_stack[depth - 1]);
291
292 if (die_index_stack.back())
293 m_die_array[die_index_stack.back()].SetSiblingIndex(
294 m_die_array.size() - die_index_stack.back());
295
296 // Only push the DIE if it isn't a NULL DIE
297 m_die_array.push_back(die);
298 }
299 }
300
301 if (null_die) {
302 // NULL DIE.
303 if (!die_index_stack.empty())
304 die_index_stack.pop_back();
305
306 if (depth > 0)
307 --depth;
308 prev_die_had_children = false;
309 } else {
310 die_index_stack.back() = m_die_array.size() - 1;
311 // Normal DIE
312 const bool die_has_children = die.HasChildren();
313 if (die_has_children) {
314 die_index_stack.push_back(0);
315 ++depth;
316 }
317 prev_die_had_children = die_has_children;
318 }
319
320 if (depth == 0)
321 break; // We are done with this compile unit!
322 }
323
324 if (!m_die_array.empty()) {
325 // The last die cannot have children (if it did, it wouldn't be the last
326 // one). This only makes a difference for malformed dwarf that does not have
327 // a terminating null die.
328 m_die_array.back().SetHasChildren(false);
329
330 if (m_first_die) {
331 // Only needed for the assertion.
332 m_first_die.SetHasChildren(m_die_array.front().HasChildren());
334 }
335 m_first_die = m_die_array.front();
336 }
337
338 m_die_array.shrink_to_fit();
339
340 if (m_dwo)
341 m_dwo->ExtractDIEsIfNeeded();
342}
343
344// This is used when a split dwarf is enabled.
345// A skeleton compilation unit may contain the DW_AT_str_offsets_base attribute
346// that points to the first string offset of the CU contribution to the
347// .debug_str_offsets. At the same time, the corresponding split debug unit also
348// may use DW_FORM_strx* forms pointing to its own .debug_str_offsets.dwo and
349// for that case, we should find the offset (skip the section header).
351 lldb::offset_t baseOffset = 0;
352
353 // Size of offset for .debug_str_offsets is same as DWARF offset byte size
354 // of the DWARFUnit as a default. We might override this if below if needed.
355 m_str_offset_size = m_header.getDwarfOffsetByteSize();
356
357 if (const llvm::DWARFUnitIndex::Entry *entry = m_header.getIndexEntry()) {
358 if (const auto *contribution =
359 entry->getContribution(llvm::DW_SECT_STR_OFFSETS))
360 baseOffset = contribution->getOffset();
361 else
362 return;
363 }
364
365 if (GetVersion() >= 5) {
366 const llvm::DWARFDataExtractor &strOffsets = GetSymbolFileDWARF()
370
371 uint64_t length;
372 llvm::dwarf::DwarfFormat format;
373 std::tie(length, format) = strOffsets.getInitialLength(&baseOffset);
374 m_str_offset_size = format == llvm::dwarf::DwarfFormat::DWARF64 ? 8 : 4;
375 // Check version.
376 if (strOffsets.getU16(&baseOffset) < 5)
377 return;
378
379 // Skip padding.
380 baseOffset += 2;
381 }
382
383 SetStrOffsetsBase(baseOffset);
384}
385
386std::optional<uint64_t> DWARFUnit::GetDWOId() {
388 return m_dwo_id;
389}
390
391// m_die_array_mutex must be already held as read/write.
393 DWARFAttributes attributes = cu_die.GetAttributes(this);
394
395 // Extract DW_AT_addr_base first, as other attributes may need it.
396 for (size_t i = 0; i < attributes.Size(); ++i) {
397 if (attributes.AttributeAtIndex(i) != DW_AT_addr_base)
398 continue;
399 DWARFFormValue form_value;
400 if (attributes.ExtractFormValueAtIndex(i, form_value)) {
401 SetAddrBase(form_value.Unsigned());
402 break;
403 }
404 }
405
406 for (size_t i = 0; i < attributes.Size(); ++i) {
407 dw_attr_t attr = attributes.AttributeAtIndex(i);
408 DWARFFormValue form_value;
409 if (!attributes.ExtractFormValueAtIndex(i, form_value))
410 continue;
411 switch (attr) {
412 default:
413 break;
414 case DW_AT_loclists_base:
415 SetLoclistsBase(form_value.Unsigned());
416 break;
417 case DW_AT_rnglists_base:
418 SetRangesBase(form_value.Unsigned());
419 break;
420 case DW_AT_str_offsets_base:
421 // When we have a DW_AT_str_offsets_base attribute, it points us to the
422 // first string offset for this DWARFUnit which is after the string
423 // offsets table header. In this case we use the DWARF32/DWARF64 of the
424 // DWARFUnit to determine the string offset byte size. DWO files do not
425 // use this attribute and they point to the start of the string offsets
426 // table header which can be used to determine the DWARF32/DWARF64 status
427 // of the string table. See SetDwoStrOffsetsBase() for now it figures out
428 // the m_str_offset_size value that should be used.
429 SetStrOffsetsBase(form_value.Unsigned());
430 m_str_offset_size = m_header.getDwarfOffsetByteSize();
431 break;
432 case DW_AT_low_pc:
433 SetBaseAddress(form_value.Address());
434 break;
435 case DW_AT_entry_pc:
436 // If the value was already set by DW_AT_low_pc, don't update it.
438 SetBaseAddress(form_value.Address());
439 break;
440 case DW_AT_stmt_list:
441 m_line_table_offset = form_value.Unsigned();
442 break;
443 case DW_AT_GNU_addr_base:
444 m_gnu_addr_base = form_value.Unsigned();
445 break;
446 case DW_AT_GNU_ranges_base:
447 m_gnu_ranges_base = form_value.Unsigned();
448 break;
449 case DW_AT_GNU_dwo_id:
450 m_dwo_id = form_value.Unsigned();
451 break;
452 }
453 }
454
455 if (m_is_dwo) {
458 return;
459 }
460}
461
465
466const llvm::DWARFAbbreviationDeclarationSet *
468 return m_abbrevs;
469}
470
474
479
480void DWARFUnit::SetAddrBase(dw_addr_t addr_base) { m_addr_base = addr_base; }
481
482// Parse the rangelist table header, including the optional array of offsets
483// following it (DWARF v5 and later).
484template <typename ListTableType>
485static llvm::Expected<ListTableType>
486ParseListTableHeader(const llvm::DWARFDataExtractor &data, uint64_t offset,
487 DwarfFormat format) {
488 // We are expected to be called with Offset 0 or pointing just past the table
489 // header. Correct Offset in the latter case so that it points to the start
490 // of the header.
491 if (offset == 0) {
492 // This means DW_AT_rnglists_base is missing and therefore DW_FORM_rnglistx
493 // cannot be handled. Returning a default-constructed ListTableType allows
494 // DW_FORM_sec_offset to be supported.
495 return ListTableType();
496 }
497
498 uint64_t HeaderSize = llvm::DWARFListTableHeader::getHeaderSize(format);
499 if (offset < HeaderSize)
500 return llvm::createStringError(std::errc::invalid_argument,
501 "did not detect a valid"
502 " list table with base = 0x%" PRIx64 "\n",
503 offset);
504 offset -= HeaderSize;
505 ListTableType Table;
506 if (llvm::Error E = Table.extractHeaderAndOffsets(data, &offset))
507 return std::move(E);
508 return Table;
509}
510
512 uint64_t offset = 0;
513 if (const llvm::DWARFUnitIndex::Entry *entry = m_header.getIndexEntry()) {
514 const auto *contribution = entry->getContribution(llvm::DW_SECT_LOCLISTS);
515 if (!contribution) {
516 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
517 "Failed to find location list contribution for CU with DWO Id "
518 "{0:x16}",
519 *GetDWOId());
520 return;
521 }
522 offset += contribution->getOffset();
523 }
524 m_loclists_base = loclists_base;
525
526 uint64_t header_size =
527 llvm::DWARFListTableHeader::getHeaderSize(GetFormParams().Format);
528 if (loclists_base < header_size)
529 return;
530
531 m_loclist_table_header.emplace(".debug_loclists", "locations");
532 offset += loclists_base - header_size;
533 if (llvm::Error E = m_loclist_table_header->extract(
534 m_dwarf.GetDWARFContext().getOrLoadLocListsData().GetAsLLVMDWARF(),
535 &offset)) {
536 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
537 "Failed to extract location list table at offset {0:x16} (location "
538 "list base: {1:x16}): {2}",
539 offset, loclists_base, toString(std::move(E)).c_str());
540 }
541}
542
543std::unique_ptr<llvm::DWARFLocationTable>
545 llvm::DWARFDataExtractor llvm_data(
547 data.GetAddressByteSize());
548
549 if (m_is_dwo || GetVersion() >= 5)
550 return std::make_unique<llvm::DWARFDebugLoclists>(llvm_data, GetVersion());
551 return std::make_unique<llvm::DWARFDebugLoc>(llvm_data);
552}
553
556 const DWARFDataExtractor &data =
558 if (const llvm::DWARFUnitIndex::Entry *entry = m_header.getIndexEntry()) {
559 if (const auto *contribution = entry->getContribution(
560 GetVersion() >= 5 ? llvm::DW_SECT_LOCLISTS : llvm::DW_SECT_EXT_LOC))
561 return DWARFDataExtractor(data, contribution->getOffset(),
562 contribution->getLength32());
563 return DWARFDataExtractor();
564 }
565 return data;
566}
567
570 const DWARFDataExtractor &data = Ctx.getOrLoadRngListsData();
571 if (const llvm::DWARFUnitIndex::Entry *entry = m_header.getIndexEntry()) {
572 if (const auto *contribution =
573 entry->getContribution(llvm::DW_SECT_RNGLISTS))
574 return DWARFDataExtractor(data, contribution->getOffset(),
575 contribution->getLength32());
576 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
577 "Failed to find range list contribution for CU with signature {0:x16}",
578 entry->getSignature());
579
580 return DWARFDataExtractor();
581 }
582 return data;
583}
584
587
588 m_ranges_base = ranges_base;
589}
590
591const std::optional<llvm::DWARFDebugRnglistTable> &
593 if (GetVersion() >= 5 && !m_rnglist_table_done) {
595 if (auto table_or_error =
597 GetRnglistData().GetAsLLVMDWARF(), m_ranges_base,
599 m_rnglist_table = std::move(table_or_error.get());
600 else
601 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
602 "Failed to extract range list table at offset {0:x16}: {1}",
603 m_ranges_base, toString(table_or_error.takeError()).c_str());
604 }
605 return m_rnglist_table;
606}
607
608// This function is called only for DW_FORM_rnglistx.
609llvm::Expected<uint64_t> DWARFUnit::GetRnglistOffset(uint32_t Index) {
610 if (!GetRnglistTable())
611 return llvm::createStringError(std::errc::invalid_argument,
612 "missing or invalid range list table");
613 if (!m_ranges_base)
614 return llvm::createStringError(
615 std::errc::invalid_argument,
616 llvm::formatv("DW_FORM_rnglistx cannot be used without "
617 "DW_AT_rnglists_base for CU at {0:x16}",
618 GetOffset())
619 .str()
620 .c_str());
621 if (std::optional<uint64_t> off = GetRnglistTable()->getOffsetEntry(
622 GetRnglistData().GetAsLLVM(), Index))
623 return *off + m_ranges_base;
624 return llvm::createStringError(
625 std::errc::invalid_argument,
626 "invalid range list table index %u; OffsetEntryCount is %u, "
627 "DW_AT_rnglists_base is %" PRIu64,
628 Index, GetRnglistTable()->getOffsetEntryCount(), m_ranges_base);
629}
630
632 m_str_offsets_base = str_offsets_base;
633}
634
636 uint32_t index_size = GetAddressByteSize();
637 dw_offset_t addr_base = GetAddrBase();
638 dw_addr_t offset = addr_base + static_cast<dw_addr_t>(index) * index_size;
639 const DWARFDataExtractor &data =
640 m_dwarf.GetDWARFContext().getOrLoadAddrData();
641 if (data.ValidOffsetForDataOfSize(offset, index_size))
642 return data.GetMaxU64_unchecked(&offset, index_size);
644}
645
646// It may be called only with m_die_array_mutex held R/W.
648 m_die_array.clear();
649 m_die_array.shrink_to_fit();
650
651 if (m_dwo && !m_dwo->m_cancel_scopes)
652 m_dwo->ClearDIEsRWLocked();
653}
654
656 return m_dwarf.GetObjectFile()->GetByteOrder();
657}
658
659void DWARFUnit::SetBaseAddress(dw_addr_t base_addr) { m_base_addr = base_addr; }
660
661// Compare function DWARFDebugAranges::Range structures
663 const dw_offset_t die_offset) {
664 return die.GetOffset() < die_offset;
665}
666
667// GetDIE()
668//
669// Get the DIE (Debug Information Entry) with the specified offset by first
670// checking if the DIE is contained within this compile unit and grabbing the
671// DIE from this compile unit. Otherwise we grab the DIE from the DWARF file.
672DWARFDIE
674 if (die_offset == DW_INVALID_OFFSET)
675 return DWARFDIE(); // Not found
676
677 if (!ContainsDIEOffset(die_offset)) {
678 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
679 "GetDIE for DIE {0:x16} is outside of its CU {1:x16}", die_offset,
680 GetOffset());
681 return DWARFDIE(); // Not found
682 }
683
687 lower_bound(m_die_array.cbegin(), end, die_offset, CompareDIEOffset);
688
689 if (pos != end && die_offset == (*pos).GetOffset())
690 return DWARFDIE(this, &(*pos));
691 return DWARFDIE(); // Not found
692}
693
694llvm::StringRef DWARFUnit::PeekDIEName(dw_offset_t die_offset) {
696 if (!die.Extract(GetData(), *this, &die_offset))
697 return llvm::StringRef();
698
699 // Does die contain a DW_AT_Name?
700 if (const char *name =
701 die.GetAttributeValueAsString(this, DW_AT_name, nullptr))
702 return name;
703
704 // Does its DW_AT_specification or DW_AT_abstract_origin contain an AT_Name?
705 for (auto attr : {DW_AT_specification, DW_AT_abstract_origin}) {
706 DWARFFormValue form_value;
707 if (!die.GetAttributeValue(this, attr, form_value))
708 continue;
709 auto [unit, offset] = form_value.ReferencedUnitAndOffset();
710 if (unit)
711 if (auto name = unit->PeekDIEName(offset); !name.empty())
712 return name;
713 }
714
715 return llvm::StringRef();
716}
717
718llvm::Expected<std::pair<uint64_t, bool>>
719DWARFUnit::GetDIEBitSizeAndSign(uint64_t relative_die_offset) const {
720 // Retrieve the type DIE that the value is being converted to. This
721 // offset is compile unit relative so we need to fix it up.
722 const uint64_t abs_die_offset = relative_die_offset + GetOffset();
723 // FIXME: the constness has annoying ripple effects.
724 DWARFDIE die = const_cast<DWARFUnit *>(this)->GetDIE(abs_die_offset);
725 if (!die)
726 return llvm::createStringError("cannot resolve DW_OP_convert type DIE");
727 uint64_t encoding =
728 die.GetAttributeValueAsUnsigned(DW_AT_encoding, DW_ATE_hi_user);
729 uint64_t bit_size = die.GetAttributeValueAsUnsigned(DW_AT_byte_size, 0) * 8;
730 if (!bit_size)
731 bit_size = die.GetAttributeValueAsUnsigned(DW_AT_bit_size, 0);
732 if (!bit_size)
733 return llvm::createStringError("unsupported type size");
734 bool sign;
735 switch (encoding) {
736 case DW_ATE_signed:
737 case DW_ATE_signed_char:
738 sign = true;
739 break;
740 case DW_ATE_unsigned:
741 case DW_ATE_unsigned_char:
742 sign = false;
743 break;
744 default:
745 return llvm::createStringError("unsupported encoding");
746 }
747 return std::pair{bit_size, sign};
748}
749
752 const lldb::offset_t data_offset,
753 const uint8_t op) const {
754 return GetSymbolFileDWARF().GetVendorDWARFOpcodeSize(data, data_offset, op);
755}
756
757bool DWARFUnit::ParseVendorDWARFOpcode(uint8_t op, const DataExtractor &opcodes,
758 lldb::offset_t &offset,
759 RegisterContext *reg_ctx,
760 lldb::RegisterKind reg_kind,
761 std::vector<Value> &stack) const {
762 return GetSymbolFileDWARF().ParseVendorDWARFOpcode(op, opcodes, offset,
763 reg_ctx, reg_kind, stack);
764}
765
767 const DataExtractor &data, DWARFExpressionList &location_list) const {
768 location_list.Clear();
769 std::unique_ptr<llvm::DWARFLocationTable> loctable_up =
770 GetLocationTable(data);
772 auto lookup_addr =
773 [&](uint32_t index) -> std::optional<llvm::object::SectionedAddress> {
775 if (address == LLDB_INVALID_ADDRESS)
776 return std::nullopt;
777 return llvm::object::SectionedAddress{address};
778 };
779 auto process_list = [&](llvm::Expected<llvm::DWARFLocationExpression> loc) {
780 if (!loc) {
781 LLDB_LOG_ERROR(log, loc.takeError(), "{0}");
782 return true;
783 }
784 auto buffer_sp =
785 std::make_shared<DataBufferHeap>(loc->Expr.data(), loc->Expr.size());
787 buffer_sp, data.GetByteOrder(), data.GetAddressByteSize()));
788 location_list.AddExpression(loc->Range->LowPC, loc->Range->HighPC, expr);
789 return true;
790 };
791 llvm::Error error = loctable_up->visitAbsoluteLocationList(
792 0, llvm::object::SectionedAddress{GetBaseAddress()}, lookup_addr,
793 process_list);
794 location_list.Sort();
795 if (error) {
796 LLDB_LOG_ERROR(log, std::move(error), "{0}");
797 return false;
798 }
799 return true;
800}
801
804 if (m_dwo)
805 return *m_dwo;
806 return *this;
807}
808
810 if (cu)
811 return cu->GetAddressByteSize();
813}
814
815uint8_t DWARFUnit::GetDefaultAddressSize() { return 4; }
816
818 if (m_skeleton_unit.load() == nullptr && IsDWOUnit()) {
819 SymbolFileDWARFDwo *dwo =
820 llvm::dyn_cast_or_null<SymbolFileDWARFDwo>(&GetSymbolFileDWARF());
821 // Do a reverse lookup if the skeleton compile unit wasn't set.
822 DWARFUnit *candidate_skeleton_unit =
823 dwo ? dwo->GetBaseSymbolFile().GetSkeletonUnit(this) : nullptr;
824 if (candidate_skeleton_unit)
825 (void)LinkToSkeletonUnit(*candidate_skeleton_unit);
826 // Linking may fail due to a race, so be sure to return the actual value.
827 }
828 return llvm::dyn_cast_or_null<DWARFCompileUnit>(m_skeleton_unit.load());
829}
830
832 DWARFUnit *expected_unit = nullptr;
833 if (m_skeleton_unit.compare_exchange_strong(expected_unit, &skeleton_unit))
834 return true;
835 if (expected_unit == &skeleton_unit) {
836 // Exchange failed because it already contained the right value.
837 return true;
838 }
839 return false; // Already linked to a different unit.
840}
841
844 return GetProducerVersion() >= llvm::VersionTuple(425, 0, 13);
845 // Assume all other compilers didn't have incorrect ObjC bitfield info.
846 return true;
847}
848
852 if (!die)
853 return;
854
855 llvm::StringRef producer(
856 die->GetAttributeValueAsString(this, DW_AT_producer, nullptr));
857 if (producer.empty())
858 return;
859
860 static const RegularExpression g_swiftlang_version_regex(
861 llvm::StringRef(R"(swiftlang-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?))"));
862 static const RegularExpression g_clang_version_regex(
863 llvm::StringRef(R"(clang-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?))"));
864
865 llvm::SmallVector<llvm::StringRef, 3> matches;
866 if (g_swiftlang_version_regex.Execute(producer, &matches)) {
867 m_producer_version.tryParse(matches[1]);
869 } else if (producer.contains("clang")) {
870 if (g_clang_version_regex.Execute(producer, &matches))
871 m_producer_version.tryParse(matches[1]);
873 } else if (producer.contains("GNU")) {
875 }
876}
877
883
884llvm::VersionTuple DWARFUnit::GetProducerVersion() {
885 if (m_producer_version.empty())
887 return m_producer_version;
888}
889
891 if (m_language_type)
892 return *m_language_type;
893
895 if (!die)
896 m_language_type = 0;
897 else
898 m_language_type = die->GetAttributeValueAsUnsigned(this, DW_AT_language, 0);
899 return *m_language_type;
900}
901
905 if (die) {
907 if (die->GetAttributeValueAsUnsigned(this, DW_AT_APPLE_optimized, 0) ==
908 1) {
910 }
911 }
912 }
914}
915
921
927
933
934FileSpec DWARFUnit::GetFile(size_t file_idx) {
935 return m_dwarf.GetFile(*this, file_idx);
936}
937
938// DWARF2/3 suggests the form hostname:pathname for compilation directory.
939// Remove the host part if present.
940static llvm::StringRef
941removeHostnameFromPathname(llvm::StringRef path_from_dwarf) {
942 if (!path_from_dwarf.contains(':'))
943 return path_from_dwarf;
944 llvm::StringRef host, path;
945 std::tie(host, path) = path_from_dwarf.split(':');
946
947 if (host.contains('/'))
948 return path_from_dwarf;
949
950 // check whether we have a windows path, and so the first character is a
951 // drive-letter not a hostname.
952 if (host.size() == 1 && llvm::isAlpha(host[0]) &&
953 (path.starts_with("\\") || path.starts_with("/")))
954 return path_from_dwarf;
955
956 return path;
957}
958
962 if (!die)
963 return;
964
965 llvm::StringRef comp_dir = removeHostnameFromPathname(
966 die->GetAttributeValueAsString(this, DW_AT_comp_dir, nullptr));
967 if (!comp_dir.empty()) {
968 FileSpec::Style comp_dir_style =
969 FileSpec::GuessPathStyle(comp_dir).value_or(FileSpec::Style::native);
970 m_comp_dir = FileSpec(comp_dir, comp_dir_style);
971 } else {
972 // Try to detect the style based on the DW_AT_name attribute, but just store
973 // the detected style in the m_comp_dir field.
974 const char *name =
975 die->GetAttributeValueAsString(this, DW_AT_name, nullptr);
977 "", FileSpec::GuessPathStyle(name).value_or(FileSpec::Style::native));
978 }
979}
980
984 if (!die)
985 return;
986
988 FileSpec(die->GetAttributeValueAsString(this, DW_AT_name, nullptr),
989 GetPathStyle());
990
991 if (m_file_spec->IsRelative())
992 m_file_spec->MakeAbsolute(GetCompilationDirectory());
993}
994
996 if (load_all_debug_info)
998 if (m_dwo)
999 return &llvm::cast<SymbolFileDWARFDwo>(m_dwo->GetSymbolFileDWARF());
1000 return nullptr;
1001}
1002
1004 if (m_func_aranges_up == nullptr) {
1005 m_func_aranges_up = std::make_unique<DWARFDebugAranges>();
1006 const DWARFDebugInfoEntry *die = DIEPtr();
1007 if (die)
1009
1010 if (m_dwo) {
1011 const DWARFDebugInfoEntry *dwo_die = m_dwo->DIEPtr();
1012 if (dwo_die)
1014 m_func_aranges_up.get());
1015 }
1016
1017 const bool minimize = false;
1018 m_func_aranges_up->Sort(minimize);
1019 }
1020 return *m_func_aranges_up;
1021}
1022
1023llvm::Expected<DWARFUnitSP>
1025 const DWARFDataExtractor &debug_info,
1026 DIERef::Section section, lldb::offset_t *offset_ptr) {
1027 assert(debug_info.ValidOffset(*offset_ptr));
1028
1029 DWARFContext &context = dwarf.GetDWARFContext();
1030
1031 // FIXME: Either properly map between DIERef::Section and
1032 // llvm::DWARFSectionKind or switch to llvm's definition entirely.
1033 llvm::DWARFSectionKind section_kind_llvm =
1035 ? llvm::DWARFSectionKind::DW_SECT_INFO
1036 : llvm::DWARFSectionKind::DW_SECT_EXT_TYPES;
1037
1038 llvm::DWARFDataExtractor debug_info_llvm = debug_info.GetAsLLVMDWARF();
1039 llvm::DWARFUnitHeader header;
1040 if (llvm::Error extract_err = header.extract(
1041 context.GetAsLLVM(), debug_info_llvm, offset_ptr, section_kind_llvm))
1042 return std::move(extract_err);
1043
1044 if (context.isDwo()) {
1045 const llvm::DWARFUnitIndex::Entry *entry = nullptr;
1046 const llvm::DWARFUnitIndex &index = header.isTypeUnit()
1047 ? context.GetAsLLVM().getTUIndex()
1048 : context.GetAsLLVM().getCUIndex();
1049 if (index) {
1050 if (header.isTypeUnit())
1051 entry = index.getFromHash(header.getTypeHash());
1052 else if (auto dwo_id = header.getDWOId())
1053 entry = index.getFromHash(*dwo_id);
1054 }
1055 if (!entry)
1056 entry = index.getFromOffset(header.getOffset());
1057 if (entry)
1058 if (llvm::Error err = header.applyIndexEntry(entry))
1059 return std::move(err);
1060 }
1061
1062 const llvm::DWARFDebugAbbrev *abbr = dwarf.DebugAbbrev();
1063 if (!abbr)
1064 return llvm::make_error<llvm::object::GenericBinaryError>(
1065 "No debug_abbrev data");
1066
1067 bool abbr_offset_OK =
1068 dwarf.GetDWARFContext().getOrLoadAbbrevData().ValidOffset(
1069 header.getAbbrOffset());
1070 if (!abbr_offset_OK)
1071 return llvm::make_error<llvm::object::GenericBinaryError>(
1072 "Abbreviation offset for unit is not valid");
1073
1074 llvm::Expected<const llvm::DWARFAbbreviationDeclarationSet *> abbrevs_or_err =
1075 abbr->getAbbreviationDeclarationSet(header.getAbbrOffset());
1076 if (!abbrevs_or_err)
1077 return abbrevs_or_err.takeError();
1078
1079 const llvm::DWARFAbbreviationDeclarationSet *abbrevs = *abbrevs_or_err;
1080 if (!abbrevs)
1081 return llvm::make_error<llvm::object::GenericBinaryError>(
1082 "No abbrev exists at the specified offset.");
1083
1084 bool is_dwo = dwarf.GetDWARFContext().isDwo();
1085 if (header.isTypeUnit())
1086 return DWARFUnitSP(
1087 new DWARFTypeUnit(dwarf, uid, header, *abbrevs, section, is_dwo));
1088 return DWARFUnitSP(
1089 new DWARFCompileUnit(dwarf, uid, header, *abbrevs, section, is_dwo));
1090}
1091
1094 ? m_dwarf.GetDWARFContext().getOrLoadDebugTypesData()
1095 : m_dwarf.GetDWARFContext().getOrLoadDebugInfoData();
1096}
1097
1098uint32_t DWARFUnit::GetHeaderByteSize() const { return m_header.getSize(); }
1099
1100std::optional<uint64_t>
1103 return m_dwarf.GetDWARFContext().getOrLoadStrOffsetsData().GetMaxU64(
1104 &offset, m_str_offset_size);
1105}
1106
1107llvm::Expected<llvm::DWARFAddressRangesVector>
1109 if (GetVersion() <= 4) {
1110 llvm::DWARFDataExtractor data =
1111 m_dwarf.GetDWARFContext().getOrLoadRangesData().GetAsLLVMDWARF();
1112 data.setAddressSize(m_header.getAddressByteSize());
1113
1114 llvm::DWARFDebugRangeList list;
1115 if (llvm::Error e = list.extract(data, &offset))
1116 return e;
1117 return list.getAbsoluteRanges(
1118 llvm::object::SectionedAddress{GetBaseAddress()});
1119 }
1120
1121 // DWARF >= v5
1122 if (!GetRnglistTable())
1123 return llvm::createStringError(std::errc::invalid_argument,
1124 "missing or invalid range list table");
1125
1126 llvm::DWARFDataExtractor data = GetRnglistData().GetAsLLVMDWARF();
1127
1128 // As DW_AT_rnglists_base may be missing we need to call setAddressSize.
1129 data.setAddressSize(m_header.getAddressByteSize());
1130 auto range_list_or_error = GetRnglistTable()->findList(data, offset);
1131 if (!range_list_or_error)
1132 return range_list_or_error.takeError();
1133
1134 return range_list_or_error->getAbsoluteRanges(
1135 llvm::object::SectionedAddress{GetBaseAddress()}, GetAddressByteSize(),
1136 [&](uint32_t index) {
1137 uint32_t index_size = GetAddressByteSize();
1138 dw_offset_t addr_base = GetAddrBase();
1139 lldb::offset_t offset =
1140 addr_base + static_cast<lldb::offset_t>(index) * index_size;
1141 return llvm::object::SectionedAddress{
1142 m_dwarf.GetDWARFContext().getOrLoadAddrData().GetMaxU64(
1143 &offset, index_size)};
1144 });
1145}
1146
1147llvm::Expected<llvm::DWARFAddressRangesVector>
1149 llvm::Expected<uint64_t> maybe_offset = GetRnglistOffset(index);
1150 if (!maybe_offset)
1151 return maybe_offset.takeError();
1152 return FindRnglistFromOffset(*maybe_offset);
1153}
1154
1155bool DWARFUnit::HasAny(llvm::ArrayRef<dw_tag_t> tags) {
1157 if (m_dwo)
1158 return m_dwo->HasAny(tags);
1159
1160 for (const auto &die : m_die_array) {
1161 for (const auto tag : tags) {
1162 if (tag == die.Tag())
1163 return true;
1164 }
1165 }
1166 return false;
1167}
static llvm::raw_ostream & error(Stream &strm)
int g_verbose
static bool CompareDIEOffset(const DWARFDebugInfoEntry &die, const dw_offset_t die_offset)
static llvm::Expected< ListTableType > ParseListTableHeader(const llvm::DWARFDataExtractor &data, uint64_t offset, DwarfFormat format)
static llvm::StringRef removeHostnameFromPathname(llvm::StringRef path_from_dwarf)
#define lldbassert(x)
Definition LLDBAssert.h:16
#define LLDB_LOG_ERROR(log, error,...)
Definition Log.h:392
static double elapsed(const StatsTimepoint &start, const StatsTimepoint &end)
#define LLDB_SCOPED_TIMERF(...)
Definition Timer.h:86
llvm::DWARFDataExtractor GetAsLLVMDWARF() const
"lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file address range to a single ...
bool AddExpression(lldb::addr_t base, lldb::addr_t end, DWARFExpression expr)
"lldb/Expression/DWARFExpression.h" Encapsulates a DWARF location expression and interprets it.
An data extractor class.
virtual const void * GetData(lldb::offset_t *offset_ptr, lldb::offset_t length) const
Extract length bytes from *offset_ptr.
bool ValidOffset(lldb::offset_t offset) const
Test the validity of offset.
uint32_t GetAddressByteSize() const
Get the current address size.
lldb::ByteOrder GetByteOrder() const
Get the current byte order value.
A class that measures elapsed time in an exception safe way.
Definition Statistics.h:76
A file utility class.
Definition FileSpec.h:57
static std::optional< Style > GuessPathStyle(llvm::StringRef absolute_path)
Attempt to guess path style for a given path string.
Definition FileSpec.cpp:310
llvm::sys::path::Style Style
Definition FileSpec.h:59
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
bool Execute(llvm::StringRef string, llvm::SmallVectorImpl< llvm::StringRef > *matches=nullptr) const
Execute a regular expression match using the compiled regular expression that is already in this obje...
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
Definition Status.h:151
ObjectFile * GetObjectFile() override
Definition SymbolFile.h:569
dw_attr_t AttributeAtIndex(uint32_t i) const
bool ExtractFormValueAtIndex(uint32_t i, DWARFFormValue &form_value) const
uint64_t GetAttributeValueAsUnsigned(const dw_attr_t attr, uint64_t fail_value) const
const DWARFDataExtractor & getOrLoadLocListsData()
const DWARFDataExtractor & getOrLoadStrOffsetsData()
const DWARFDataExtractor & getOrLoadRngListsData()
const DWARFDataExtractor & getOrLoadLocData()
DWARFDebugInfoEntry objects assume that they are living in one big vector and do pointer arithmetic o...
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...
void BuildFunctionAddressRangeTable(DWARFUnit *cu, DWARFDebugAranges *debug_aranges) const
This function is builds a table very similar to the standard .debug_aranges table,...
const char * GetAttributeValueAsString(const DWARFUnit *cu, const dw_attr_t attr, const char *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
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
std::pair< DWARFUnit *, uint64_t > ReferencedUnitAndOffset() const
If this is a reference to another DIE, return the corresponding DWARFUnit and DIE offset such that Un...
const ScopedExtractDIEs & operator=(const ScopedExtractDIEs &)=delete
std::optional< dw_addr_t > m_addr_base
Value of DW_AT_addr_base.
Definition DWARFUnit.h:357
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...
std::unique_ptr< llvm::DWARFLocationTable > GetLocationTable(const DataExtractor &data) const
Return the location table for parsing the given location list data.
std::optional< FileSpec > m_file_spec
Definition DWARFUnit.h:356
size_t GetLengthByteSize() const
Get the size in bytes of the length field in the header.
Definition DWARFUnit.h:107
std::optional< llvm::DWARFDebugRnglistTable > m_rnglist_table
Definition DWARFUnit.h:369
virtual bool ParseVendorDWARFOpcode(uint8_t op, const DataExtractor &opcodes, lldb::offset_t &offset, RegisterContext *reg_ctx, lldb::RegisterKind reg_kind, std::vector< Value > &stack) const override
const DWARFDebugInfoEntry * GetUnitDIEPtrOnly()
Definition DWARFUnit.h:306
bool LinkToSkeletonUnit(DWARFUnit &skeleton_unit)
dw_offset_t m_line_table_offset
Value of DW_AT_stmt_list.
Definition DWARFUnit.h:364
void SetStrOffsetsBase(dw_offset_t str_offsets_base)
Status m_dwo_error
If we get an error when trying to load a .dwo file, save that error here.
Definition DWARFUnit.h:381
void SetLoclistsBase(dw_addr_t loclists_base)
SymbolFileDWARF & GetSymbolFileDWARF() const
Definition DWARFUnit.h:200
const DWARFDebugAranges & GetFunctionAranges()
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.
static llvm::Expected< DWARFUnitSP > extract(SymbolFileDWARF &dwarf2Data, lldb::user_id_t uid, const DWARFDataExtractor &debug_info, DIERef::Section section, lldb::offset_t *offset_ptr)
DWARFCompileUnit * GetSkeletonUnit()
Get the skeleton compile unit for a DWO file.
const DWARFDebugInfoEntry * DIEPtr()
Definition DWARFUnit.h:315
bool ContainsDIEOffset(dw_offset_t die_offset) const
Definition DWARFUnit.h:109
std::optional< FileSpec > m_comp_dir
Definition DWARFUnit.h:355
dw_offset_t GetFirstDIEOffset() const
Definition DWARFUnit.h:113
std::optional< uint64_t > m_language_type
Definition DWARFUnit.h:353
llvm::StringRef PeekDIEName(dw_offset_t die_offset)
Returns the AT_Name of the DIE at die_offset, if it exists, without parsing the entire compile unit.
DWARFDebugInfoEntry::collection m_die_array
Definition DWARFUnit.h:334
void SetBaseAddress(dw_addr_t base_addr)
std::optional< uint64_t > m_gnu_ranges_base
Definition DWARFUnit.h:361
const llvm::DWARFAbbreviationDeclarationSet * m_abbrevs
Definition DWARFUnit.h:329
llvm::Expected< std::pair< uint64_t, bool > > GetDIEBitSizeAndSign(uint64_t relative_die_offset) const override
uint8_t GetAddressByteSize() const override
Definition DWARFUnit.h:127
dw_offset_t GetNextUnitOffset() const
Definition DWARFUnit.h:116
DWARFDataExtractor GetLocationData() const
const std::optional< llvm::DWARFDebugRnglistTable > & GetRnglistTable()
llvm::Expected< uint64_t > GetRnglistOffset(uint32_t Index)
Return a rangelist's offset based on an index.
std::unique_ptr< DWARFDebugAranges > m_func_aranges_up
Definition DWARFUnit.h:349
dw_addr_t m_ranges_base
Value of DW_AT_rnglists_base.
Definition DWARFUnit.h:359
dw_addr_t m_loclists_base
Value of DW_AT_loclists_base.
Definition DWARFUnit.h:358
lldb::offset_t GetVendorDWARFOpcodeSize(const DataExtractor &data, const lldb::offset_t data_offset, const uint8_t op) const override
void SetRangesBase(dw_addr_t ranges_base)
uint32_t GetHeaderByteSize() const
Get the size in bytes of the unit header.
bool ParseDWARFLocationList(const DataExtractor &data, DWARFExpressionList &loc_list) const
void SetAddrBase(dw_addr_t addr_base)
void SetDwoError(Status &&error)
Set the fission .dwo file specific error for this compile unit.
Definition DWARFUnit.h:292
std::optional< llvm::DWARFListTableHeader > m_loclist_table_header
Definition DWARFUnit.h:371
llvm::VersionTuple GetProducerVersion()
std::optional< uint64_t > m_dwo_id
Value of DW_AT_GNU_dwo_id (v4) or dwo_id from CU header (v5).
Definition DWARFUnit.h:377
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...
std::shared_ptr< DWARFUnit > m_dwo
Definition DWARFUnit.h:327
std::optional< uint64_t > m_gnu_addr_base
Definition DWARFUnit.h:360
DWARFUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid, const llvm::DWARFUnitHeader &header, const llvm::DWARFAbbreviationDeclarationSet &abbrevs, DIERef::Section section, bool is_dwo)
Definition DWARFUnit.cpp:37
std::optional< uint64_t > GetStringOffsetSectionItem(uint32_t index) const
DWARFDIE GetDIE(dw_offset_t die_offset)
lldb::ByteOrder GetByteOrder() const
void AddUnitDIE(const DWARFDebugInfoEntry &cu_die)
SymbolFileDWARFDwo * GetDwoSymbolFile(bool load_all_debug_info=true)
uint16_t GetVersion() const override
Definition DWARFUnit.h:121
std::optional< uint64_t > GetDWOId()
Get the DWO ID from the DWARFUnitHeader for DWARF5, or from the unit DIE's DW_AT_dwo_id or DW_AT_GNU_...
const llvm::DWARFAbbreviationDeclarationSet * GetAbbreviations() const
bool HasAny(llvm::ArrayRef< dw_tag_t > tags)
Returns true if any DIEs in the unit match any DW_TAG values in tags.
const llvm::dwarf::FormParams & GetFormParams() const
Definition DWARFUnit.h:122
std::atomic< DWARFUnit * > m_skeleton_unit
Definition DWARFUnit.h:332
dw_addr_t ReadAddressFromDebugAddrSection(uint32_t index) const override
DWARFDataExtractor GetRnglistData() const
FileSpec GetFile(size_t file_idx)
DWARFUnit * GetSkeletonUnit(DWARFUnit *dwo_unit)
Given a DWO DWARFUnit, find the corresponding skeleton DWARFUnit in the main symbol file.
virtual lldb::offset_t GetVendorDWARFOpcodeSize(const DataExtractor &data, const lldb::offset_t data_offset, const uint8_t op) const
virtual bool ParseVendorDWARFOpcode(uint8_t op, const DataExtractor &opcodes, lldb::offset_t &offset, RegisterContext *reg_ctx, lldb::RegisterKind reg_kind, std::vector< Value > &stack) const
uint64_t dw_offset_t
Definition dwarf.h:24
#define DW_INVALID_OFFSET
Definition dwarf.h:29
llvm::dwarf::Attribute dw_attr_t
Definition dwarf.h:17
uint64_t dw_addr_t
Definition dwarf.h:20
#define LLDB_INVALID_ADDRESS
std::shared_ptr< DWARFUnit > DWARFUnitSP
Definition DWARFUnit.h:33
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
const char * toString(AppleArm64ExceptionClass EC)
Format
Display format definitions.
uint64_t offset_t
Definition lldb-types.h:85
ByteOrder
Byte ordering definitions.
uint64_t user_id_t
Definition lldb-types.h:82
uint64_t addr_t
Definition lldb-types.h:80
RegisterKind
Register numbering types.
UserID(lldb::user_id_t uid=LLDB_INVALID_UID)
Construct with optional user ID.
Definition UserID.h:33