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(llvm::DWARFListTableHeader::getHeaderSize(DWARF32));
138
139 if (GetVersion() >= 5 &&
140 dwo_symbol_file->GetDWARFContext().getOrLoadLocListsData().GetByteSize() >
141 0)
142 dwo_cu->SetLoclistsBase(llvm::DWARFListTableHeader::getHeaderSize(DWARF32));
143
145
146 m_dwo = std::shared_ptr<DWARFUnit>(std::move(dwo_symbol_file), dwo_cu);
147}
148
149// Parses a compile unit and indexes its DIEs if it hasn't already been done.
150// It will leave this compile unit extracted forever.
152 m_cancel_scopes = true;
153
154 {
155 llvm::sys::ScopedReader lock(m_die_array_mutex);
156 if (!m_die_array.empty())
157 return; // Already parsed
158 }
159 llvm::sys::ScopedWriter lock(m_die_array_mutex);
160 if (!m_die_array.empty())
161 return; // Already parsed
162
164}
165
166// Parses a compile unit and indexes its DIEs if it hasn't already been done.
167// It will clear this compile unit after returned instance gets out of scope,
168// no other ScopedExtractDIEs instance is running for this compile unit
169// and no ExtractDIEsIfNeeded() has been executed during this ScopedExtractDIEs
170// lifetime.
172 ScopedExtractDIEs scoped(*this);
173
174 {
175 llvm::sys::ScopedReader lock(m_die_array_mutex);
176 if (!m_die_array.empty())
177 return scoped; // Already parsed
178 }
179 llvm::sys::ScopedWriter lock(m_die_array_mutex);
180 if (!m_die_array.empty())
181 return scoped; // Already parsed
182
183 // Otherwise m_die_array would be already populated.
185
187 scoped.m_clear_dies = true;
188 return scoped;
189}
190
192 llvm::sys::ScopedLock lock(m_cu->m_die_array_scoped_mutex);
193 ++m_cu->m_die_array_scoped_count;
194}
195
197 if (!m_cu)
198 return;
199 llvm::sys::ScopedLock lock(m_cu->m_die_array_scoped_mutex);
200 --m_cu->m_die_array_scoped_count;
201 if (m_cu->m_die_array_scoped_count == 0 && m_clear_dies &&
202 !m_cu->m_cancel_scopes) {
203 llvm::sys::ScopedWriter lock(m_cu->m_die_array_mutex);
204 m_cu->ClearDIEsRWLocked();
205 }
206}
207
212
215 m_cu = rhs.m_cu;
216 rhs.m_cu = nullptr;
217 m_clear_dies = rhs.m_clear_dies;
218 return *this;
219}
220
221// Parses a compile unit and indexes its DIEs, m_die_array_mutex must be
222// held R/W and m_die_array must be empty.
224 llvm::sys::ScopedWriter first_die_lock(m_first_die_mutex);
225
226 ElapsedTime elapsed(m_dwarf.GetDebugInfoParseTimeRef());
228 "%s",
229 llvm::formatv("{0:x16}: DWARFUnit::ExtractDIEsIfNeeded()", GetOffset())
230 .str()
231 .c_str());
232
233 // Set the offset to that of the first DIE and calculate the start of the
234 // next compilation unit header.
236 lldb::offset_t next_cu_offset = GetNextUnitOffset();
237
239
240 uint32_t depth = 0;
241 // We are in our compile unit, parse starting at the offset we were told to
242 // parse
243 const DWARFDataExtractor &data = GetData();
244 std::vector<uint32_t> die_index_stack;
245 die_index_stack.reserve(32);
246 die_index_stack.push_back(0);
247 bool prev_die_had_children = false;
248 while (offset < next_cu_offset && die.Extract(data, *this, &offset)) {
249 const bool null_die = die.IsNULL();
250 if (depth == 0) {
251 assert(m_die_array.empty() && "Compile unit DIE already added");
252
253 // The average bytes per DIE entry has been seen to be around 14-20 so
254 // lets pre-reserve half of that since we are now stripping the NULL
255 // tags.
256
257 // Only reserve the memory if we are adding children of the main
258 // compile unit DIE. The compile unit DIE is always the first entry, so
259 // if our size is 1, then we are adding the first compile unit child
260 // DIE and should reserve the memory.
261 m_die_array.reserve(GetDebugInfoSize() / 24);
262 m_die_array.push_back(die);
263
264 if (!m_first_die)
265 AddUnitDIE(m_die_array.front());
266
267 // With -fsplit-dwarf-inlining, clang will emit non-empty skeleton compile
268 // units. We are not able to access these DIE *and* the dwo file
269 // simultaneously. We also don't need to do that as the dwo file will
270 // contain a superset of information. So, we don't even attempt to parse
271 // any remaining DIEs.
272 if (m_dwo) {
273 m_die_array.front().SetHasChildren(false);
274 break;
275 }
276
277 } else {
278 if (null_die) {
279 if (prev_die_had_children) {
280 // This will only happen if a DIE says is has children but all it
281 // contains is a NULL tag. Since we are removing the NULL DIEs from
282 // the list (saves up to 25% in C++ code), we need a way to let the
283 // DIE know that it actually doesn't have children.
284 if (!m_die_array.empty())
285 m_die_array.back().SetHasChildren(false);
286 }
287 } else {
288 die.SetParentIndex(m_die_array.size() - die_index_stack[depth - 1]);
289
290 if (die_index_stack.back())
291 m_die_array[die_index_stack.back()].SetSiblingIndex(
292 m_die_array.size() - die_index_stack.back());
293
294 // Only push the DIE if it isn't a NULL DIE
295 m_die_array.push_back(die);
296 }
297 }
298
299 if (null_die) {
300 // NULL DIE.
301 if (!die_index_stack.empty())
302 die_index_stack.pop_back();
303
304 if (depth > 0)
305 --depth;
306 prev_die_had_children = false;
307 } else {
308 die_index_stack.back() = m_die_array.size() - 1;
309 // Normal DIE
310 const bool die_has_children = die.HasChildren();
311 if (die_has_children) {
312 die_index_stack.push_back(0);
313 ++depth;
314 }
315 prev_die_had_children = die_has_children;
316 }
317
318 if (depth == 0)
319 break; // We are done with this compile unit!
320 }
321
322 if (!m_die_array.empty()) {
323 // The last die cannot have children (if it did, it wouldn't be the last
324 // one). This only makes a difference for malformed dwarf that does not have
325 // a terminating null die.
326 m_die_array.back().SetHasChildren(false);
327
328 if (m_first_die) {
329 // Only needed for the assertion.
330 m_first_die.SetHasChildren(m_die_array.front().HasChildren());
332 }
333 m_first_die = m_die_array.front();
334 }
335
336 m_die_array.shrink_to_fit();
337
338 if (m_dwo)
339 m_dwo->ExtractDIEsIfNeeded();
340}
341
342// This is used when a split dwarf is enabled.
343// A skeleton compilation unit may contain the DW_AT_str_offsets_base attribute
344// that points to the first string offset of the CU contribution to the
345// .debug_str_offsets. At the same time, the corresponding split debug unit also
346// may use DW_FORM_strx* forms pointing to its own .debug_str_offsets.dwo and
347// for that case, we should find the offset (skip the section header).
349 lldb::offset_t baseOffset = 0;
350
351 if (const llvm::DWARFUnitIndex::Entry *entry = m_header.getIndexEntry()) {
352 if (const auto *contribution =
353 entry->getContribution(llvm::DW_SECT_STR_OFFSETS))
354 baseOffset = contribution->getOffset();
355 else
356 return;
357 }
358
359 if (GetVersion() >= 5) {
360 const DWARFDataExtractor &strOffsets =
362 uint64_t length = strOffsets.GetU32(&baseOffset);
363 if (length == 0xffffffff)
364 length = strOffsets.GetU64(&baseOffset);
365
366 // Check version.
367 if (strOffsets.GetU16(&baseOffset) < 5)
368 return;
369
370 // Skip padding.
371 baseOffset += 2;
372 }
373
374 SetStrOffsetsBase(baseOffset);
375}
376
377std::optional<uint64_t> DWARFUnit::GetDWOId() {
379 return m_dwo_id;
380}
381
382// m_die_array_mutex must be already held as read/write.
384 DWARFAttributes attributes = cu_die.GetAttributes(this);
385
386 // Extract DW_AT_addr_base first, as other attributes may need it.
387 for (size_t i = 0; i < attributes.Size(); ++i) {
388 if (attributes.AttributeAtIndex(i) != DW_AT_addr_base)
389 continue;
390 DWARFFormValue form_value;
391 if (attributes.ExtractFormValueAtIndex(i, form_value)) {
392 SetAddrBase(form_value.Unsigned());
393 break;
394 }
395 }
396
397 for (size_t i = 0; i < attributes.Size(); ++i) {
398 dw_attr_t attr = attributes.AttributeAtIndex(i);
399 DWARFFormValue form_value;
400 if (!attributes.ExtractFormValueAtIndex(i, form_value))
401 continue;
402 switch (attr) {
403 default:
404 break;
405 case DW_AT_loclists_base:
406 SetLoclistsBase(form_value.Unsigned());
407 break;
408 case DW_AT_rnglists_base:
409 SetRangesBase(form_value.Unsigned());
410 break;
411 case DW_AT_str_offsets_base:
412 SetStrOffsetsBase(form_value.Unsigned());
413 break;
414 case DW_AT_low_pc:
415 SetBaseAddress(form_value.Address());
416 break;
417 case DW_AT_entry_pc:
418 // If the value was already set by DW_AT_low_pc, don't update it.
420 SetBaseAddress(form_value.Address());
421 break;
422 case DW_AT_stmt_list:
423 m_line_table_offset = form_value.Unsigned();
424 break;
425 case DW_AT_GNU_addr_base:
426 m_gnu_addr_base = form_value.Unsigned();
427 break;
428 case DW_AT_GNU_ranges_base:
429 m_gnu_ranges_base = form_value.Unsigned();
430 break;
431 case DW_AT_GNU_dwo_id:
432 m_dwo_id = form_value.Unsigned();
433 break;
434 }
435 }
436
437 if (m_is_dwo) {
440 return;
441 }
442}
443
447
448const llvm::DWARFAbbreviationDeclarationSet *
450 return m_abbrevs;
451}
452
456
461
462void DWARFUnit::SetAddrBase(dw_addr_t addr_base) { m_addr_base = addr_base; }
463
464// Parse the rangelist table header, including the optional array of offsets
465// following it (DWARF v5 and later).
466template <typename ListTableType>
467static llvm::Expected<ListTableType>
468ParseListTableHeader(const llvm::DWARFDataExtractor &data, uint64_t offset,
469 DwarfFormat format) {
470 // We are expected to be called with Offset 0 or pointing just past the table
471 // header. Correct Offset in the latter case so that it points to the start
472 // of the header.
473 if (offset == 0) {
474 // This means DW_AT_rnglists_base is missing and therefore DW_FORM_rnglistx
475 // cannot be handled. Returning a default-constructed ListTableType allows
476 // DW_FORM_sec_offset to be supported.
477 return ListTableType();
478 }
479
480 uint64_t HeaderSize = llvm::DWARFListTableHeader::getHeaderSize(format);
481 if (offset < HeaderSize)
482 return llvm::createStringError(std::errc::invalid_argument,
483 "did not detect a valid"
484 " list table with base = 0x%" PRIx64 "\n",
485 offset);
486 offset -= HeaderSize;
487 ListTableType Table;
488 if (llvm::Error E = Table.extractHeaderAndOffsets(data, &offset))
489 return std::move(E);
490 return Table;
491}
492
494 uint64_t offset = 0;
495 if (const llvm::DWARFUnitIndex::Entry *entry = m_header.getIndexEntry()) {
496 const auto *contribution = entry->getContribution(llvm::DW_SECT_LOCLISTS);
497 if (!contribution) {
498 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
499 "Failed to find location list contribution for CU with DWO Id "
500 "{0:x16}",
501 *GetDWOId());
502 return;
503 }
504 offset += contribution->getOffset();
505 }
506 m_loclists_base = loclists_base;
507
508 uint64_t header_size = llvm::DWARFListTableHeader::getHeaderSize(DWARF32);
509 if (loclists_base < header_size)
510 return;
511
512 m_loclist_table_header.emplace(".debug_loclists", "locations");
513 offset += loclists_base - header_size;
514 if (llvm::Error E = m_loclist_table_header->extract(
515 m_dwarf.GetDWARFContext().getOrLoadLocListsData().GetAsLLVMDWARF(),
516 &offset)) {
517 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
518 "Failed to extract location list table at offset {0:x16} (location "
519 "list base: {1:x16}): {2}",
520 offset, loclists_base, toString(std::move(E)).c_str());
521 }
522}
523
524std::unique_ptr<llvm::DWARFLocationTable>
526 llvm::DWARFDataExtractor llvm_data(
528 data.GetAddressByteSize());
529
530 if (m_is_dwo || GetVersion() >= 5)
531 return std::make_unique<llvm::DWARFDebugLoclists>(llvm_data, GetVersion());
532 return std::make_unique<llvm::DWARFDebugLoc>(llvm_data);
533}
534
537 const DWARFDataExtractor &data =
539 if (const llvm::DWARFUnitIndex::Entry *entry = m_header.getIndexEntry()) {
540 if (const auto *contribution = entry->getContribution(
541 GetVersion() >= 5 ? llvm::DW_SECT_LOCLISTS : llvm::DW_SECT_EXT_LOC))
542 return DWARFDataExtractor(data, contribution->getOffset(),
543 contribution->getLength32());
544 return DWARFDataExtractor();
545 }
546 return data;
547}
548
551 const DWARFDataExtractor &data = Ctx.getOrLoadRngListsData();
552 if (const llvm::DWARFUnitIndex::Entry *entry = m_header.getIndexEntry()) {
553 if (const auto *contribution =
554 entry->getContribution(llvm::DW_SECT_RNGLISTS))
555 return DWARFDataExtractor(data, contribution->getOffset(),
556 contribution->getLength32());
557 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
558 "Failed to find range list contribution for CU with signature {0:x16}",
559 entry->getSignature());
560
561 return DWARFDataExtractor();
562 }
563 return data;
564}
565
568
569 m_ranges_base = ranges_base;
570}
571
572const std::optional<llvm::DWARFDebugRnglistTable> &
574 if (GetVersion() >= 5 && !m_rnglist_table_done) {
576 if (auto table_or_error =
578 GetRnglistData().GetAsLLVMDWARF(), m_ranges_base, DWARF32))
579 m_rnglist_table = std::move(table_or_error.get());
580 else
581 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
582 "Failed to extract range list table at offset {0:x16}: {1}",
583 m_ranges_base, toString(table_or_error.takeError()).c_str());
584 }
585 return m_rnglist_table;
586}
587
588// This function is called only for DW_FORM_rnglistx.
589llvm::Expected<uint64_t> DWARFUnit::GetRnglistOffset(uint32_t Index) {
590 if (!GetRnglistTable())
591 return llvm::createStringError(std::errc::invalid_argument,
592 "missing or invalid range list table");
593 if (!m_ranges_base)
594 return llvm::createStringError(
595 std::errc::invalid_argument,
596 llvm::formatv("DW_FORM_rnglistx cannot be used without "
597 "DW_AT_rnglists_base for CU at {0:x16}",
598 GetOffset())
599 .str()
600 .c_str());
601 if (std::optional<uint64_t> off = GetRnglistTable()->getOffsetEntry(
602 GetRnglistData().GetAsLLVM(), Index))
603 return *off + m_ranges_base;
604 return llvm::createStringError(
605 std::errc::invalid_argument,
606 "invalid range list table index %u; OffsetEntryCount is %u, "
607 "DW_AT_rnglists_base is %" PRIu64,
608 Index, GetRnglistTable()->getOffsetEntryCount(), m_ranges_base);
609}
610
612 m_str_offsets_base = str_offsets_base;
613}
614
616 uint32_t index_size = GetAddressByteSize();
617 dw_offset_t addr_base = GetAddrBase();
618 dw_addr_t offset = addr_base + static_cast<dw_addr_t>(index) * index_size;
619 const DWARFDataExtractor &data =
620 m_dwarf.GetDWARFContext().getOrLoadAddrData();
621 if (data.ValidOffsetForDataOfSize(offset, index_size))
622 return data.GetMaxU64_unchecked(&offset, index_size);
624}
625
626// It may be called only with m_die_array_mutex held R/W.
628 m_die_array.clear();
629 m_die_array.shrink_to_fit();
630
631 if (m_dwo && !m_dwo->m_cancel_scopes)
632 m_dwo->ClearDIEsRWLocked();
633}
634
636 return m_dwarf.GetObjectFile()->GetByteOrder();
637}
638
639void DWARFUnit::SetBaseAddress(dw_addr_t base_addr) { m_base_addr = base_addr; }
640
641// Compare function DWARFDebugAranges::Range structures
643 const dw_offset_t die_offset) {
644 return die.GetOffset() < die_offset;
645}
646
647// GetDIE()
648//
649// Get the DIE (Debug Information Entry) with the specified offset by first
650// checking if the DIE is contained within this compile unit and grabbing the
651// DIE from this compile unit. Otherwise we grab the DIE from the DWARF file.
652DWARFDIE
654 if (die_offset == DW_INVALID_OFFSET)
655 return DWARFDIE(); // Not found
656
657 if (!ContainsDIEOffset(die_offset)) {
658 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
659 "GetDIE for DIE {0:x16} is outside of its CU {1:x16}", die_offset,
660 GetOffset());
661 return DWARFDIE(); // Not found
662 }
663
667 lower_bound(m_die_array.cbegin(), end, die_offset, CompareDIEOffset);
668
669 if (pos != end && die_offset == (*pos).GetOffset())
670 return DWARFDIE(this, &(*pos));
671 return DWARFDIE(); // Not found
672}
673
674llvm::StringRef DWARFUnit::PeekDIEName(dw_offset_t die_offset) {
676 if (!die.Extract(GetData(), *this, &die_offset))
677 return llvm::StringRef();
678
679 // Does die contain a DW_AT_Name?
680 if (const char *name =
681 die.GetAttributeValueAsString(this, DW_AT_name, nullptr))
682 return name;
683
684 // Does its DW_AT_specification or DW_AT_abstract_origin contain an AT_Name?
685 for (auto attr : {DW_AT_specification, DW_AT_abstract_origin}) {
686 DWARFFormValue form_value;
687 if (!die.GetAttributeValue(this, attr, form_value))
688 continue;
689 auto [unit, offset] = form_value.ReferencedUnitAndOffset();
690 if (unit)
691 if (auto name = unit->PeekDIEName(offset); !name.empty())
692 return name;
693 }
694
695 return llvm::StringRef();
696}
697
698llvm::Expected<std::pair<uint64_t, bool>>
699DWARFUnit::GetDIEBitSizeAndSign(uint64_t relative_die_offset) const {
700 // Retrieve the type DIE that the value is being converted to. This
701 // offset is compile unit relative so we need to fix it up.
702 const uint64_t abs_die_offset = relative_die_offset + GetOffset();
703 // FIXME: the constness has annoying ripple effects.
704 DWARFDIE die = const_cast<DWARFUnit *>(this)->GetDIE(abs_die_offset);
705 if (!die)
706 return llvm::createStringError("cannot resolve DW_OP_convert type DIE");
707 uint64_t encoding =
708 die.GetAttributeValueAsUnsigned(DW_AT_encoding, DW_ATE_hi_user);
709 uint64_t bit_size = die.GetAttributeValueAsUnsigned(DW_AT_byte_size, 0) * 8;
710 if (!bit_size)
711 bit_size = die.GetAttributeValueAsUnsigned(DW_AT_bit_size, 0);
712 if (!bit_size)
713 return llvm::createStringError("unsupported type size");
714 bool sign;
715 switch (encoding) {
716 case DW_ATE_signed:
717 case DW_ATE_signed_char:
718 sign = true;
719 break;
720 case DW_ATE_unsigned:
721 case DW_ATE_unsigned_char:
722 sign = false;
723 break;
724 default:
725 return llvm::createStringError("unsupported encoding");
726 }
727 return std::pair{bit_size, sign};
728}
729
732 const lldb::offset_t data_offset,
733 const uint8_t op) const {
734 return GetSymbolFileDWARF().GetVendorDWARFOpcodeSize(data, data_offset, op);
735}
736
737bool DWARFUnit::ParseVendorDWARFOpcode(uint8_t op, const DataExtractor &opcodes,
738 lldb::offset_t &offset,
739 RegisterContext *reg_ctx,
740 lldb::RegisterKind reg_kind,
741 std::vector<Value> &stack) const {
742 return GetSymbolFileDWARF().ParseVendorDWARFOpcode(op, opcodes, offset,
743 reg_ctx, reg_kind, stack);
744}
745
747 const DataExtractor &data, DWARFExpressionList &location_list) const {
748 location_list.Clear();
749 std::unique_ptr<llvm::DWARFLocationTable> loctable_up =
750 GetLocationTable(data);
752 auto lookup_addr =
753 [&](uint32_t index) -> std::optional<llvm::object::SectionedAddress> {
755 if (address == LLDB_INVALID_ADDRESS)
756 return std::nullopt;
757 return llvm::object::SectionedAddress{address};
758 };
759 auto process_list = [&](llvm::Expected<llvm::DWARFLocationExpression> loc) {
760 if (!loc) {
761 LLDB_LOG_ERROR(log, loc.takeError(), "{0}");
762 return true;
763 }
764 auto buffer_sp =
765 std::make_shared<DataBufferHeap>(loc->Expr.data(), loc->Expr.size());
767 buffer_sp, data.GetByteOrder(), data.GetAddressByteSize()));
768 location_list.AddExpression(loc->Range->LowPC, loc->Range->HighPC, expr);
769 return true;
770 };
771 llvm::Error error = loctable_up->visitAbsoluteLocationList(
772 0, llvm::object::SectionedAddress{GetBaseAddress()}, lookup_addr,
773 process_list);
774 location_list.Sort();
775 if (error) {
776 LLDB_LOG_ERROR(log, std::move(error), "{0}");
777 return false;
778 }
779 return true;
780}
781
784 if (m_dwo)
785 return *m_dwo;
786 return *this;
787}
788
790 if (cu)
791 return cu->GetAddressByteSize();
793}
794
795uint8_t DWARFUnit::GetDefaultAddressSize() { return 4; }
796
798 if (m_skeleton_unit.load() == nullptr && IsDWOUnit()) {
799 SymbolFileDWARFDwo *dwo =
800 llvm::dyn_cast_or_null<SymbolFileDWARFDwo>(&GetSymbolFileDWARF());
801 // Do a reverse lookup if the skeleton compile unit wasn't set.
802 DWARFUnit *candidate_skeleton_unit =
803 dwo ? dwo->GetBaseSymbolFile().GetSkeletonUnit(this) : nullptr;
804 if (candidate_skeleton_unit)
805 (void)LinkToSkeletonUnit(*candidate_skeleton_unit);
806 // Linking may fail due to a race, so be sure to return the actual value.
807 }
808 return llvm::dyn_cast_or_null<DWARFCompileUnit>(m_skeleton_unit.load());
809}
810
812 DWARFUnit *expected_unit = nullptr;
813 if (m_skeleton_unit.compare_exchange_strong(expected_unit, &skeleton_unit))
814 return true;
815 if (expected_unit == &skeleton_unit) {
816 // Exchange failed because it already contained the right value.
817 return true;
818 }
819 return false; // Already linked to a different unit.
820}
821
824 return GetProducerVersion() >= llvm::VersionTuple(425, 0, 13);
825 // Assume all other compilers didn't have incorrect ObjC bitfield info.
826 return true;
827}
828
832 if (!die)
833 return;
834
835 llvm::StringRef producer(
836 die->GetAttributeValueAsString(this, DW_AT_producer, nullptr));
837 if (producer.empty())
838 return;
839
840 static const RegularExpression g_swiftlang_version_regex(
841 llvm::StringRef(R"(swiftlang-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?))"));
842 static const RegularExpression g_clang_version_regex(
843 llvm::StringRef(R"(clang-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?))"));
844
845 llvm::SmallVector<llvm::StringRef, 3> matches;
846 if (g_swiftlang_version_regex.Execute(producer, &matches)) {
847 m_producer_version.tryParse(matches[1]);
849 } else if (producer.contains("clang")) {
850 if (g_clang_version_regex.Execute(producer, &matches))
851 m_producer_version.tryParse(matches[1]);
853 } else if (producer.contains("GNU")) {
855 }
856}
857
863
864llvm::VersionTuple DWARFUnit::GetProducerVersion() {
865 if (m_producer_version.empty())
867 return m_producer_version;
868}
869
871 if (m_language_type)
872 return *m_language_type;
873
875 if (!die)
876 m_language_type = 0;
877 else
878 m_language_type = die->GetAttributeValueAsUnsigned(this, DW_AT_language, 0);
879 return *m_language_type;
880}
881
885 if (die) {
887 if (die->GetAttributeValueAsUnsigned(this, DW_AT_APPLE_optimized, 0) ==
888 1) {
890 }
891 }
892 }
894}
895
901
907
913
914FileSpec DWARFUnit::GetFile(size_t file_idx) {
915 return m_dwarf.GetFile(*this, file_idx);
916}
917
918// DWARF2/3 suggests the form hostname:pathname for compilation directory.
919// Remove the host part if present.
920static llvm::StringRef
921removeHostnameFromPathname(llvm::StringRef path_from_dwarf) {
922 if (!path_from_dwarf.contains(':'))
923 return path_from_dwarf;
924 llvm::StringRef host, path;
925 std::tie(host, path) = path_from_dwarf.split(':');
926
927 if (host.contains('/'))
928 return path_from_dwarf;
929
930 // check whether we have a windows path, and so the first character is a
931 // drive-letter not a hostname.
932 if (host.size() == 1 && llvm::isAlpha(host[0]) &&
933 (path.starts_with("\\") || path.starts_with("/")))
934 return path_from_dwarf;
935
936 return path;
937}
938
942 if (!die)
943 return;
944
945 llvm::StringRef comp_dir = removeHostnameFromPathname(
946 die->GetAttributeValueAsString(this, DW_AT_comp_dir, nullptr));
947 if (!comp_dir.empty()) {
948 FileSpec::Style comp_dir_style =
949 FileSpec::GuessPathStyle(comp_dir).value_or(FileSpec::Style::native);
950 m_comp_dir = FileSpec(comp_dir, comp_dir_style);
951 } else {
952 // Try to detect the style based on the DW_AT_name attribute, but just store
953 // the detected style in the m_comp_dir field.
954 const char *name =
955 die->GetAttributeValueAsString(this, DW_AT_name, nullptr);
957 "", FileSpec::GuessPathStyle(name).value_or(FileSpec::Style::native));
958 }
959}
960
964 if (!die)
965 return;
966
968 FileSpec(die->GetAttributeValueAsString(this, DW_AT_name, nullptr),
969 GetPathStyle());
970
971 if (m_file_spec->IsRelative())
972 m_file_spec->MakeAbsolute(GetCompilationDirectory());
973}
974
976 if (load_all_debug_info)
978 if (m_dwo)
979 return &llvm::cast<SymbolFileDWARFDwo>(m_dwo->GetSymbolFileDWARF());
980 return nullptr;
981}
982
984 if (m_func_aranges_up == nullptr) {
985 m_func_aranges_up = std::make_unique<DWARFDebugAranges>();
986 const DWARFDebugInfoEntry *die = DIEPtr();
987 if (die)
989
990 if (m_dwo) {
991 const DWARFDebugInfoEntry *dwo_die = m_dwo->DIEPtr();
992 if (dwo_die)
994 m_func_aranges_up.get());
995 }
996
997 const bool minimize = false;
998 m_func_aranges_up->Sort(minimize);
999 }
1000 return *m_func_aranges_up;
1001}
1002
1003llvm::Expected<DWARFUnitSP>
1005 const DWARFDataExtractor &debug_info,
1006 DIERef::Section section, lldb::offset_t *offset_ptr) {
1007 assert(debug_info.ValidOffset(*offset_ptr));
1008
1009 DWARFContext &context = dwarf.GetDWARFContext();
1010
1011 // FIXME: Either properly map between DIERef::Section and
1012 // llvm::DWARFSectionKind or switch to llvm's definition entirely.
1013 llvm::DWARFSectionKind section_kind_llvm =
1015 ? llvm::DWARFSectionKind::DW_SECT_INFO
1016 : llvm::DWARFSectionKind::DW_SECT_EXT_TYPES;
1017
1018 llvm::DWARFDataExtractor debug_info_llvm = debug_info.GetAsLLVMDWARF();
1019 llvm::DWARFUnitHeader header;
1020 if (llvm::Error extract_err = header.extract(
1021 context.GetAsLLVM(), debug_info_llvm, offset_ptr, section_kind_llvm))
1022 return std::move(extract_err);
1023
1024 if (context.isDwo()) {
1025 const llvm::DWARFUnitIndex::Entry *entry = nullptr;
1026 const llvm::DWARFUnitIndex &index = header.isTypeUnit()
1027 ? context.GetAsLLVM().getTUIndex()
1028 : context.GetAsLLVM().getCUIndex();
1029 if (index) {
1030 if (header.isTypeUnit())
1031 entry = index.getFromHash(header.getTypeHash());
1032 else if (auto dwo_id = header.getDWOId())
1033 entry = index.getFromHash(*dwo_id);
1034 }
1035 if (!entry)
1036 entry = index.getFromOffset(header.getOffset());
1037 if (entry)
1038 if (llvm::Error err = header.applyIndexEntry(entry))
1039 return std::move(err);
1040 }
1041
1042 const llvm::DWARFDebugAbbrev *abbr = dwarf.DebugAbbrev();
1043 if (!abbr)
1044 return llvm::make_error<llvm::object::GenericBinaryError>(
1045 "No debug_abbrev data");
1046
1047 bool abbr_offset_OK =
1048 dwarf.GetDWARFContext().getOrLoadAbbrevData().ValidOffset(
1049 header.getAbbrOffset());
1050 if (!abbr_offset_OK)
1051 return llvm::make_error<llvm::object::GenericBinaryError>(
1052 "Abbreviation offset for unit is not valid");
1053
1054 llvm::Expected<const llvm::DWARFAbbreviationDeclarationSet *> abbrevs_or_err =
1055 abbr->getAbbreviationDeclarationSet(header.getAbbrOffset());
1056 if (!abbrevs_or_err)
1057 return abbrevs_or_err.takeError();
1058
1059 const llvm::DWARFAbbreviationDeclarationSet *abbrevs = *abbrevs_or_err;
1060 if (!abbrevs)
1061 return llvm::make_error<llvm::object::GenericBinaryError>(
1062 "No abbrev exists at the specified offset.");
1063
1064 bool is_dwo = dwarf.GetDWARFContext().isDwo();
1065 if (header.isTypeUnit())
1066 return DWARFUnitSP(
1067 new DWARFTypeUnit(dwarf, uid, header, *abbrevs, section, is_dwo));
1068 return DWARFUnitSP(
1069 new DWARFCompileUnit(dwarf, uid, header, *abbrevs, section, is_dwo));
1070}
1071
1074 ? m_dwarf.GetDWARFContext().getOrLoadDebugTypesData()
1075 : m_dwarf.GetDWARFContext().getOrLoadDebugInfoData();
1076}
1077
1078uint32_t DWARFUnit::GetHeaderByteSize() const { return m_header.getSize(); }
1079
1080std::optional<uint64_t>
1082 lldb::offset_t offset =
1083 GetStrOffsetsBase() + index * m_header.getDwarfOffsetByteSize();
1084 return m_dwarf.GetDWARFContext().getOrLoadStrOffsetsData().GetMaxU64(
1085 &offset, m_header.getDwarfOffsetByteSize());
1086}
1087
1088llvm::Expected<llvm::DWARFAddressRangesVector>
1090 if (GetVersion() <= 4) {
1091 llvm::DWARFDataExtractor data =
1092 m_dwarf.GetDWARFContext().getOrLoadRangesData().GetAsLLVMDWARF();
1093 data.setAddressSize(m_header.getAddressByteSize());
1094
1095 llvm::DWARFDebugRangeList list;
1096 if (llvm::Error e = list.extract(data, &offset))
1097 return e;
1098 return list.getAbsoluteRanges(
1099 llvm::object::SectionedAddress{GetBaseAddress()});
1100 }
1101
1102 // DWARF >= v5
1103 if (!GetRnglistTable())
1104 return llvm::createStringError(std::errc::invalid_argument,
1105 "missing or invalid range list table");
1106
1107 llvm::DWARFDataExtractor data = GetRnglistData().GetAsLLVMDWARF();
1108
1109 // As DW_AT_rnglists_base may be missing we need to call setAddressSize.
1110 data.setAddressSize(m_header.getAddressByteSize());
1111 auto range_list_or_error = GetRnglistTable()->findList(data, offset);
1112 if (!range_list_or_error)
1113 return range_list_or_error.takeError();
1114
1115 return range_list_or_error->getAbsoluteRanges(
1116 llvm::object::SectionedAddress{GetBaseAddress()}, GetAddressByteSize(),
1117 [&](uint32_t index) {
1118 uint32_t index_size = GetAddressByteSize();
1119 dw_offset_t addr_base = GetAddrBase();
1120 lldb::offset_t offset =
1121 addr_base + static_cast<lldb::offset_t>(index) * index_size;
1122 return llvm::object::SectionedAddress{
1123 m_dwarf.GetDWARFContext().getOrLoadAddrData().GetMaxU64(
1124 &offset, index_size)};
1125 });
1126}
1127
1128llvm::Expected<llvm::DWARFAddressRangesVector>
1130 llvm::Expected<uint64_t> maybe_offset = GetRnglistOffset(index);
1131 if (!maybe_offset)
1132 return maybe_offset.takeError();
1133 return FindRnglistFromOffset(*maybe_offset);
1134}
1135
1136bool DWARFUnit::HasAny(llvm::ArrayRef<dw_tag_t> tags) {
1138 if (m_dwo)
1139 return m_dwo->HasAny(tags);
1140
1141 for (const auto &die : m_die_array) {
1142 for (const auto tag : tags) {
1143 if (tag == die.Tag())
1144 return true;
1145 }
1146 }
1147 return false;
1148}
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.
uint64_t GetU64(lldb::offset_t *offset_ptr) const
Extract a uint64_t value from *offset_ptr.
const void * GetData(lldb::offset_t *offset_ptr, lldb::offset_t length) const
Extract length bytes from *offset_ptr.
uint32_t GetU32(lldb::offset_t *offset_ptr) const
Extract a uint32_t value from *offset_ptr.
uint16_t GetU16(lldb::offset_t *offset_ptr) const
Extract a uint16_t value 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:566
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:368
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:380
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:370
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:376
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.
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)
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