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
229 "%s",
230 llvm::formatv("{0:x16}: DWARFUnit::ExtractDIEsIfNeeded()", GetOffset())
231 .str()
232 .c_str());
233
235
236 // The skeleton and its .dwo unit share a parse time counter, so timing the
237 // .dwo unit inside ExtractDIEsNoDwoRWLocked would count it twice.
238 if (m_dwo)
239 m_dwo->ExtractDIEsIfNeeded();
240}
241
243 ElapsedTime elapsed(m_dwarf.GetDebugInfoParseTimeRef());
244
245 // Set the offset to that of the first DIE and calculate the start of the
246 // next compilation unit header.
248 lldb::offset_t next_cu_offset = GetNextUnitOffset();
249
251
252 uint32_t depth = 0;
253 // We are in our compile unit, parse starting at the offset we were told to
254 // parse
255 const DWARFDataExtractor &data = GetData();
256 std::vector<uint32_t> die_index_stack;
257 die_index_stack.reserve(32);
258 die_index_stack.push_back(0);
259 bool prev_die_had_children = false;
260 while (offset < next_cu_offset && die.Extract(data, *this, &offset)) {
261 const bool null_die = die.IsNULL();
262 if (depth == 0) {
263 assert(m_die_array.empty() && "Compile unit DIE already added");
264
265 // The average bytes per DIE entry has been seen to be around 14-20 so
266 // lets pre-reserve half of that since we are now stripping the NULL
267 // tags.
268
269 // Only reserve the memory if we are adding children of the main
270 // compile unit DIE. The compile unit DIE is always the first entry, so
271 // if our size is 1, then we are adding the first compile unit child
272 // DIE and should reserve the memory.
273 m_die_array.reserve(GetDebugInfoSize() / 24);
274 m_die_array.push_back(die);
275
276 if (!m_first_die)
277 AddUnitDIE(m_die_array.front());
278
279 // With -fsplit-dwarf-inlining, clang will emit non-empty skeleton compile
280 // units. We are not able to access these DIE *and* the dwo file
281 // simultaneously. We also don't need to do that as the dwo file will
282 // contain a superset of information. So, we don't even attempt to parse
283 // any remaining DIEs.
284 if (m_dwo) {
285 m_die_array.front().SetHasChildren(false);
286 break;
287 }
288
289 } else {
290 if (null_die) {
291 if (prev_die_had_children) {
292 // This will only happen if a DIE says is has children but all it
293 // contains is a NULL tag. Since we are removing the NULL DIEs from
294 // the list (saves up to 25% in C++ code), we need a way to let the
295 // DIE know that it actually doesn't have children.
296 if (!m_die_array.empty())
297 m_die_array.back().SetHasChildren(false);
298 }
299 } else {
300 die.SetParentIndex(m_die_array.size() - die_index_stack[depth - 1]);
301
302 if (die_index_stack.back())
303 m_die_array[die_index_stack.back()].SetSiblingIndex(
304 m_die_array.size() - die_index_stack.back());
305
306 // Only push the DIE if it isn't a NULL DIE
307 m_die_array.push_back(die);
308 }
309 }
310
311 if (null_die) {
312 // NULL DIE.
313 if (!die_index_stack.empty())
314 die_index_stack.pop_back();
315
316 if (depth > 0)
317 --depth;
318 prev_die_had_children = false;
319 } else {
320 die_index_stack.back() = m_die_array.size() - 1;
321 // Normal DIE
322 const bool die_has_children = die.HasChildren();
323 if (die_has_children) {
324 die_index_stack.push_back(0);
325 ++depth;
326 }
327 prev_die_had_children = die_has_children;
328 }
329
330 if (depth == 0)
331 break; // We are done with this compile unit!
332 }
333
334 if (!m_die_array.empty()) {
335 // The last die cannot have children (if it did, it wouldn't be the last
336 // one). This only makes a difference for malformed dwarf that does not have
337 // a terminating null die.
338 m_die_array.back().SetHasChildren(false);
339
340 if (m_first_die) {
341 // Only needed for the assertion.
342 m_first_die.SetHasChildren(m_die_array.front().HasChildren());
344 }
345 m_first_die = m_die_array.front();
346 }
347
348 m_die_array.shrink_to_fit();
349}
350
351// This is used when a split dwarf is enabled.
352// A skeleton compilation unit may contain the DW_AT_str_offsets_base attribute
353// that points to the first string offset of the CU contribution to the
354// .debug_str_offsets. At the same time, the corresponding split debug unit also
355// may use DW_FORM_strx* forms pointing to its own .debug_str_offsets.dwo and
356// for that case, we should find the offset (skip the section header).
358 lldb::offset_t baseOffset = 0;
359
360 // Size of offset for .debug_str_offsets is same as DWARF offset byte size
361 // of the DWARFUnit as a default. We might override this if below if needed.
362 m_str_offset_size = m_header.getDwarfOffsetByteSize();
363
364 if (const llvm::DWARFUnitIndex::Entry *entry = m_header.getIndexEntry()) {
365 if (const auto *contribution =
366 entry->getContribution(llvm::DW_SECT_STR_OFFSETS))
367 baseOffset = contribution->getOffset();
368 else
369 return;
370 }
371
372 if (GetVersion() >= 5) {
373 const llvm::DWARFDataExtractor &strOffsets = GetSymbolFileDWARF()
377
378 uint64_t length;
379 llvm::dwarf::DwarfFormat format;
380 std::tie(length, format) = strOffsets.getInitialLength(&baseOffset);
381 m_str_offset_size = format == llvm::dwarf::DwarfFormat::DWARF64 ? 8 : 4;
382 // Check version.
383 if (strOffsets.getU16(&baseOffset) < 5)
384 return;
385
386 // Skip padding.
387 baseOffset += 2;
388 }
389
390 SetStrOffsetsBase(baseOffset);
391}
392
393std::optional<uint64_t> DWARFUnit::GetDWOId() {
395 return m_dwo_id;
396}
397
398// m_die_array_mutex must be already held as read/write.
400 DWARFAttributes attributes = cu_die.GetAttributes(this);
401
402 // Extract DW_AT_addr_base first, as other attributes may need it.
403 for (size_t i = 0; i < attributes.Size(); ++i) {
404 if (attributes.AttributeAtIndex(i) != DW_AT_addr_base)
405 continue;
406 DWARFFormValue form_value;
407 if (attributes.ExtractFormValueAtIndex(i, form_value)) {
408 SetAddrBase(form_value.Unsigned());
409 break;
410 }
411 }
412
413 for (size_t i = 0; i < attributes.Size(); ++i) {
414 dw_attr_t attr = attributes.AttributeAtIndex(i);
415 DWARFFormValue form_value;
416 if (!attributes.ExtractFormValueAtIndex(i, form_value))
417 continue;
418 switch (attr) {
419 default:
420 break;
421 case DW_AT_loclists_base:
422 SetLoclistsBase(form_value.Unsigned());
423 break;
424 case DW_AT_rnglists_base:
425 SetRangesBase(form_value.Unsigned());
426 break;
427 case DW_AT_str_offsets_base:
428 // When we have a DW_AT_str_offsets_base attribute, it points us to the
429 // first string offset for this DWARFUnit which is after the string
430 // offsets table header. In this case we use the DWARF32/DWARF64 of the
431 // DWARFUnit to determine the string offset byte size. DWO files do not
432 // use this attribute and they point to the start of the string offsets
433 // table header which can be used to determine the DWARF32/DWARF64 status
434 // of the string table. See SetDwoStrOffsetsBase() for now it figures out
435 // the m_str_offset_size value that should be used.
436 SetStrOffsetsBase(form_value.Unsigned());
437 m_str_offset_size = m_header.getDwarfOffsetByteSize();
438 break;
439 case DW_AT_low_pc:
440 SetBaseAddress(form_value.Address());
441 break;
442 case DW_AT_entry_pc:
443 // If the value was already set by DW_AT_low_pc, don't update it.
445 SetBaseAddress(form_value.Address());
446 break;
447 case DW_AT_stmt_list:
448 m_line_table_offset = form_value.Unsigned();
449 break;
450 case DW_AT_GNU_addr_base:
451 m_gnu_addr_base = form_value.Unsigned();
452 break;
453 case DW_AT_GNU_ranges_base:
454 m_gnu_ranges_base = form_value.Unsigned();
455 break;
456 case DW_AT_GNU_dwo_id:
457 m_dwo_id = form_value.Unsigned();
458 break;
459 }
460 }
461
462 if (m_is_dwo) {
465 return;
466 }
467}
468
472
473const llvm::DWARFAbbreviationDeclarationSet *
475 return m_abbrevs;
476}
477
481
486
487void DWARFUnit::SetAddrBase(dw_addr_t addr_base) { m_addr_base = addr_base; }
488
489// Parse the rangelist table header, including the optional array of offsets
490// following it (DWARF v5 and later).
491template <typename ListTableType>
492static llvm::Expected<ListTableType>
493ParseListTableHeader(const llvm::DWARFDataExtractor &data, uint64_t offset,
494 DwarfFormat format) {
495 // We are expected to be called with Offset 0 or pointing just past the table
496 // header. Correct Offset in the latter case so that it points to the start
497 // of the header.
498 if (offset == 0) {
499 // This means DW_AT_rnglists_base is missing and therefore DW_FORM_rnglistx
500 // cannot be handled. Returning a default-constructed ListTableType allows
501 // DW_FORM_sec_offset to be supported.
502 return ListTableType();
503 }
504
505 uint64_t HeaderSize = llvm::DWARFListTableHeader::getHeaderSize(format);
506 if (offset < HeaderSize)
507 return llvm::createStringError(std::errc::invalid_argument,
508 "did not detect a valid"
509 " list table with base = 0x%" PRIx64 "\n",
510 offset);
511 offset -= HeaderSize;
512 ListTableType Table;
513 if (llvm::Error E = Table.extractHeaderAndOffsets(data, &offset))
514 return std::move(E);
515 return Table;
516}
517
519 uint64_t offset = 0;
520 if (const llvm::DWARFUnitIndex::Entry *entry = m_header.getIndexEntry()) {
521 const auto *contribution = entry->getContribution(llvm::DW_SECT_LOCLISTS);
522 if (!contribution) {
523 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
524 "Failed to find location list contribution for CU with DWO Id "
525 "{0:x16}",
526 *GetDWOId());
527 return;
528 }
529 offset += contribution->getOffset();
530 }
531 m_loclists_base = loclists_base;
532
533 uint64_t header_size =
534 llvm::DWARFListTableHeader::getHeaderSize(GetFormParams().Format);
535 if (loclists_base < header_size)
536 return;
537
538 m_loclist_table_header.emplace(".debug_loclists", "locations");
539 offset += loclists_base - header_size;
540 if (llvm::Error E = m_loclist_table_header->extract(
541 m_dwarf.GetDWARFContext().getOrLoadLocListsData().GetAsLLVMDWARF(),
542 &offset)) {
543 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
544 "Failed to extract location list table at offset {0:x16} (location "
545 "list base: {1:x16}): {2}",
546 offset, loclists_base, toString(std::move(E)).c_str());
547 }
548}
549
550std::unique_ptr<llvm::DWARFLocationTable>
552 llvm::DWARFDataExtractor llvm_data(
554 data.GetAddressByteSize());
555
556 if (m_is_dwo || GetVersion() >= 5)
557 return std::make_unique<llvm::DWARFDebugLoclists>(llvm_data, GetVersion());
558 return std::make_unique<llvm::DWARFDebugLoc>(llvm_data);
559}
560
563 const DWARFDataExtractor &data =
565 if (const llvm::DWARFUnitIndex::Entry *entry = m_header.getIndexEntry()) {
566 if (const auto *contribution = entry->getContribution(
567 GetVersion() >= 5 ? llvm::DW_SECT_LOCLISTS : llvm::DW_SECT_EXT_LOC))
568 return DWARFDataExtractor(data, contribution->getOffset(),
569 contribution->getLength32());
570 return DWARFDataExtractor();
571 }
572 return data;
573}
574
577 const DWARFDataExtractor &data = Ctx.getOrLoadRngListsData();
578 if (const llvm::DWARFUnitIndex::Entry *entry = m_header.getIndexEntry()) {
579 if (const auto *contribution =
580 entry->getContribution(llvm::DW_SECT_RNGLISTS))
581 return DWARFDataExtractor(data, contribution->getOffset(),
582 contribution->getLength32());
583 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
584 "Failed to find range list contribution for CU with signature {0:x16}",
585 entry->getSignature());
586
587 return DWARFDataExtractor();
588 }
589 return data;
590}
591
594
595 m_ranges_base = ranges_base;
596}
597
598const std::optional<llvm::DWARFDebugRnglistTable> &
600 if (GetVersion() >= 5 && !m_rnglist_table_done) {
602 if (auto table_or_error =
604 GetRnglistData().GetAsLLVMDWARF(), m_ranges_base,
606 m_rnglist_table = std::move(table_or_error.get());
607 else
608 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
609 "Failed to extract range list table at offset {0:x16}: {1}",
610 m_ranges_base, toString(table_or_error.takeError()).c_str());
611 }
612 return m_rnglist_table;
613}
614
615// This function is called only for DW_FORM_rnglistx.
616llvm::Expected<uint64_t> DWARFUnit::GetRnglistOffset(uint32_t Index) {
617 if (!GetRnglistTable())
618 return llvm::createStringError(std::errc::invalid_argument,
619 "missing or invalid range list table");
620 if (!m_ranges_base)
621 return llvm::createStringError(
622 std::errc::invalid_argument,
623 llvm::formatv("DW_FORM_rnglistx cannot be used without "
624 "DW_AT_rnglists_base for CU at {0:x16}",
625 GetOffset())
626 .str()
627 .c_str());
628 if (std::optional<uint64_t> off = GetRnglistTable()->getOffsetEntry(
629 GetRnglistData().GetAsLLVM(), Index))
630 return *off + m_ranges_base;
631 return llvm::createStringError(
632 std::errc::invalid_argument,
633 "invalid range list table index %u; OffsetEntryCount is %u, "
634 "DW_AT_rnglists_base is %" PRIu64,
635 Index, GetRnglistTable()->getOffsetEntryCount(), m_ranges_base);
636}
637
639 m_str_offsets_base = str_offsets_base;
640}
641
643 uint32_t index_size = GetAddressByteSize();
644 dw_offset_t addr_base = GetAddrBase();
645 dw_addr_t offset = addr_base + static_cast<dw_addr_t>(index) * index_size;
646 const DWARFDataExtractor &data =
647 m_dwarf.GetDWARFContext().getOrLoadAddrData();
648 if (data.ValidOffsetForDataOfSize(offset, index_size))
649 return data.GetMaxU64_unchecked(&offset, index_size);
651}
652
653// It may be called only with m_die_array_mutex held R/W.
655 m_die_array.clear();
656 m_die_array.shrink_to_fit();
657
658 if (m_dwo && !m_dwo->m_cancel_scopes)
659 m_dwo->ClearDIEsRWLocked();
660}
661
663 return m_dwarf.GetObjectFile()->GetByteOrder();
664}
665
666void DWARFUnit::SetBaseAddress(dw_addr_t base_addr) { m_base_addr = base_addr; }
667
668// Compare function DWARFDebugAranges::Range structures
670 const dw_offset_t die_offset) {
671 return die.GetOffset() < die_offset;
672}
673
674// GetDIE()
675//
676// Get the DIE (Debug Information Entry) with the specified offset by first
677// checking if the DIE is contained within this compile unit and grabbing the
678// DIE from this compile unit. Otherwise we grab the DIE from the DWARF file.
679DWARFDIE
681 if (die_offset == DW_INVALID_OFFSET)
682 return DWARFDIE(); // Not found
683
684 if (!ContainsDIEOffset(die_offset)) {
685 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
686 "GetDIE for DIE {0:x16} is outside of its CU {1:x16}", die_offset,
687 GetOffset());
688 return DWARFDIE(); // Not found
689 }
690
694 lower_bound(m_die_array.cbegin(), end, die_offset, CompareDIEOffset);
695
696 if (pos != end && die_offset == (*pos).GetOffset())
697 return DWARFDIE(this, &(*pos));
698 return DWARFDIE(); // Not found
699}
700
701llvm::StringRef DWARFUnit::PeekDIEName(dw_offset_t die_offset) {
703 if (!die.Extract(GetData(), *this, &die_offset))
704 return llvm::StringRef();
705
706 // Does die contain a DW_AT_Name?
707 if (const char *name =
708 die.GetAttributeValueAsString(this, DW_AT_name, nullptr))
709 return name;
710
711 // Does its DW_AT_specification or DW_AT_abstract_origin contain an AT_Name?
712 for (auto attr : {DW_AT_specification, DW_AT_abstract_origin}) {
713 DWARFFormValue form_value;
714 if (!die.GetAttributeValue(this, attr, form_value))
715 continue;
716 auto [unit, offset] = form_value.ReferencedUnitAndOffset();
717 if (unit)
718 if (auto name = unit->PeekDIEName(offset); !name.empty())
719 return name;
720 }
721
722 return llvm::StringRef();
723}
724
725llvm::Expected<std::pair<uint64_t, llvm::dwarf::TypeKind>>
726DWARFUnit::GetDIEBitSizeAndEncoding(uint64_t relative_die_offset) const {
727 // Retrieve the type DIE that the value is being converted to. This
728 // offset is compile unit relative so we need to fix it up.
729 const uint64_t abs_die_offset = relative_die_offset + GetOffset();
730 // FIXME: the constness has annoying ripple effects.
731 DWARFDIE die = const_cast<DWARFUnit *>(this)->GetDIE(abs_die_offset);
732 if (!die)
733 return llvm::createStringError("cannot resolve DW_OP_convert type DIE");
734 if (die.Tag() != DW_TAG_base_type)
735 return llvm::createStringError(
736 "DW_OP_convert type DIE is not a DW_TAG_base_type");
737 uint64_t encoding =
738 die.GetAttributeValueAsUnsigned(DW_AT_encoding, DW_ATE_hi_user);
739 uint64_t bit_size = die.GetAttributeValueAsUnsigned(DW_AT_bit_size, 0);
740 if (!bit_size)
741 bit_size = die.GetAttributeValueAsUnsigned(DW_AT_byte_size, 0) * 8;
742 if (!bit_size)
743 return llvm::createStringError("unsupported type size");
744 switch (encoding) {
745 case DW_ATE_signed:
746 case DW_ATE_signed_char:
747 case DW_ATE_unsigned:
748 case DW_ATE_unsigned_char:
749 case DW_ATE_float:
750 break;
751 default:
752 return llvm::createStringError("unsupported encoding");
753 }
754 return std::pair{bit_size, static_cast<TypeKind>(encoding)};
755}
756
759 const lldb::offset_t data_offset,
760 const uint8_t op) const {
761 return GetSymbolFileDWARF().GetVendorDWARFOpcodeSize(data, data_offset, op);
762}
763
765 const llvm::DataExtractor &opcodes,
766 lldb::offset_t &offset,
767 RegisterContext *reg_ctx,
768 lldb::RegisterKind reg_kind,
769 std::vector<Value> &stack) const {
770 return GetSymbolFileDWARF().ParseVendorDWARFOpcode(op, opcodes, offset,
771 reg_ctx, reg_kind, stack);
772}
773
775 const DataExtractor &data, DWARFExpressionList &location_list) const {
776 location_list.Clear();
777 std::unique_ptr<llvm::DWARFLocationTable> loctable_up =
778 GetLocationTable(data);
780 auto lookup_addr =
781 [&](uint32_t index) -> std::optional<llvm::object::SectionedAddress> {
783 if (address == LLDB_INVALID_ADDRESS)
784 return std::nullopt;
785 return llvm::object::SectionedAddress{address};
786 };
787 auto process_list = [&](llvm::Expected<llvm::DWARFLocationExpression> loc) {
788 if (!loc) {
789 LLDB_LOG_ERROR(log, loc.takeError(), "{0}");
790 return true;
791 }
792 auto buffer_sp =
793 std::make_shared<DataBufferHeap>(loc->Expr.data(), loc->Expr.size());
795 buffer_sp, data.GetByteOrder(), data.GetAddressByteSize()));
796 location_list.AddExpression(loc->Range->LowPC, loc->Range->HighPC, expr);
797 return true;
798 };
799 llvm::Error error = loctable_up->visitAbsoluteLocationList(
800 0, llvm::object::SectionedAddress{GetBaseAddress()}, lookup_addr,
801 process_list);
802 location_list.Sort();
803 if (error) {
804 LLDB_LOG_ERROR(log, std::move(error), "{0}");
805 return false;
806 }
807 return true;
808}
809
812 if (m_dwo)
813 return *m_dwo;
814 return *this;
815}
816
818 if (cu)
819 return cu->GetAddressByteSize();
821}
822
823uint8_t DWARFUnit::GetDefaultAddressSize() { return 4; }
824
826 if (m_skeleton_unit.load() == nullptr && IsDWOUnit()) {
827 SymbolFileDWARFDwo *dwo =
828 llvm::dyn_cast_or_null<SymbolFileDWARFDwo>(&GetSymbolFileDWARF());
829 // Do a reverse lookup if the skeleton compile unit wasn't set.
830 DWARFUnit *candidate_skeleton_unit =
831 dwo ? dwo->GetBaseSymbolFile().GetSkeletonUnit(this) : nullptr;
832 if (candidate_skeleton_unit)
833 (void)LinkToSkeletonUnit(*candidate_skeleton_unit);
834 // Linking may fail due to a race, so be sure to return the actual value.
835 }
836 return llvm::dyn_cast_or_null<DWARFCompileUnit>(m_skeleton_unit.load());
837}
838
840 DWARFUnit *expected_unit = nullptr;
841 if (m_skeleton_unit.compare_exchange_strong(expected_unit, &skeleton_unit))
842 return true;
843 if (expected_unit == &skeleton_unit) {
844 // Exchange failed because it already contained the right value.
845 return true;
846 }
847 return false; // Already linked to a different unit.
848}
849
852 return GetProducerVersion() >= llvm::VersionTuple(425, 0, 13);
853 // Assume all other compilers didn't have incorrect ObjC bitfield info.
854 return true;
855}
856
860 if (!die)
861 return;
862
863 llvm::StringRef producer(
864 die->GetAttributeValueAsString(this, DW_AT_producer, nullptr));
865 if (producer.empty())
866 return;
867
868 static const RegularExpression g_swiftlang_version_regex(llvm::StringRef(
869 R"(swiftlang-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?(\.[0-9]+)?))"));
870 static const RegularExpression g_clang_version_regex(
871 llvm::StringRef(R"(clang-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?))"));
872
873 llvm::SmallVector<llvm::StringRef, 3> matches;
874 if (g_swiftlang_version_regex.Execute(producer, &matches)) {
875 m_producer_version.tryParse(matches[1]);
877 } else if (producer.contains("clang")) {
878 if (g_clang_version_regex.Execute(producer, &matches))
879 m_producer_version.tryParse(matches[1]);
881 } else if (producer.contains("GNU")) {
883 }
884}
885
891
892llvm::VersionTuple DWARFUnit::GetProducerVersion() {
893 if (m_producer_version.empty())
895 return m_producer_version;
896}
897
899 if (m_language_type)
900 return *m_language_type;
901
903 if (!die)
904 m_language_type = 0;
905 else
906 m_language_type = die->GetAttributeValueAsUnsigned(this, DW_AT_language, 0);
907 return *m_language_type;
908}
909
913 if (die) {
915 if (die->GetAttributeValueAsUnsigned(this, DW_AT_APPLE_optimized, 0) ==
916 1) {
918 }
919 }
920 }
922}
923
929
935
941
942FileSpec DWARFUnit::GetFile(size_t file_idx) {
943 return m_dwarf.GetFile(*this, file_idx);
944}
945
946// DWARF2/3 suggests the form hostname:pathname for compilation directory.
947// Remove the host part if present.
948static llvm::StringRef
949removeHostnameFromPathname(llvm::StringRef path_from_dwarf) {
950 if (!path_from_dwarf.contains(':'))
951 return path_from_dwarf;
952 llvm::StringRef host, path;
953 std::tie(host, path) = path_from_dwarf.split(':');
954
955 if (host.contains('/'))
956 return path_from_dwarf;
957
958 // check whether we have a windows path, and so the first character is a
959 // drive-letter not a hostname.
960 if (host.size() == 1 && llvm::isAlpha(host[0]) &&
961 (path.starts_with("\\") || path.starts_with("/")))
962 return path_from_dwarf;
963
964 return path;
965}
966
970 if (!die)
971 return;
972
973 llvm::StringRef comp_dir = removeHostnameFromPathname(
974 die->GetAttributeValueAsString(this, DW_AT_comp_dir, nullptr));
975 if (!comp_dir.empty()) {
976 FileSpec::Style comp_dir_style =
977 FileSpec::GuessPathStyle(comp_dir).value_or(FileSpec::Style::native);
978 m_comp_dir = FileSpec(comp_dir, comp_dir_style);
979 } else {
980 // Try to detect the style based on the DW_AT_name attribute, but just store
981 // the detected style in the m_comp_dir field.
982 const char *name =
983 die->GetAttributeValueAsString(this, DW_AT_name, nullptr);
985 "", FileSpec::GuessPathStyle(name).value_or(FileSpec::Style::native));
986 }
987}
988
992 if (!die)
993 return;
994
996 FileSpec(die->GetAttributeValueAsString(this, DW_AT_name, nullptr),
997 GetPathStyle());
998
999 if (m_file_spec->IsRelative())
1000 m_file_spec->MakeAbsolute(GetCompilationDirectory());
1001}
1002
1004 if (load_all_debug_info)
1006 if (m_dwo)
1007 return &llvm::cast<SymbolFileDWARFDwo>(m_dwo->GetSymbolFileDWARF());
1008 return nullptr;
1009}
1010
1012 if (m_func_aranges_up == nullptr) {
1013 m_func_aranges_up = std::make_unique<DWARFDebugAranges>();
1014 const DWARFDebugInfoEntry *die = DIEPtr();
1015 if (die)
1017
1018 if (m_dwo) {
1019 const DWARFDebugInfoEntry *dwo_die = m_dwo->DIEPtr();
1020 if (dwo_die)
1022 m_func_aranges_up.get());
1023 }
1024
1025 const bool minimize = false;
1026 m_func_aranges_up->Sort(minimize);
1027 }
1028 return *m_func_aranges_up;
1029}
1030
1031llvm::Expected<DWARFUnitSP>
1033 const DWARFDataExtractor &debug_info,
1034 DIERef::Section section, lldb::offset_t *offset_ptr) {
1035 assert(debug_info.ValidOffset(*offset_ptr));
1036
1037 DWARFContext &context = dwarf.GetDWARFContext();
1038
1039 // FIXME: Either properly map between DIERef::Section and
1040 // llvm::DWARFSectionKind or switch to llvm's definition entirely.
1041 llvm::DWARFSectionKind section_kind_llvm =
1043 ? llvm::DWARFSectionKind::DW_SECT_INFO
1044 : llvm::DWARFSectionKind::DW_SECT_EXT_TYPES;
1045
1046 llvm::DWARFDataExtractor debug_info_llvm = debug_info.GetAsLLVMDWARF();
1047 llvm::DWARFUnitHeader header;
1048 if (llvm::Error extract_err = header.extract(
1049 context.GetAsLLVM(), debug_info_llvm, offset_ptr, section_kind_llvm))
1050 return std::move(extract_err);
1051
1052 if (context.isDwo()) {
1053 const llvm::DWARFUnitIndex::Entry *entry = nullptr;
1054 const llvm::DWARFUnitIndex &index = header.isTypeUnit()
1055 ? context.GetAsLLVM().getTUIndex()
1056 : context.GetAsLLVM().getCUIndex();
1057 if (index) {
1058 if (header.isTypeUnit())
1059 entry = index.getFromHash(header.getTypeHash());
1060 else if (auto dwo_id = header.getDWOId())
1061 entry = index.getFromHash(*dwo_id);
1062 }
1063 if (!entry)
1064 entry = index.getFromOffset(header.getOffset());
1065 if (entry)
1066 if (llvm::Error err = header.applyIndexEntry(entry))
1067 return std::move(err);
1068 }
1069
1070 const llvm::DWARFDebugAbbrev *abbr = dwarf.DebugAbbrev();
1071 if (!abbr)
1072 return llvm::make_error<llvm::object::GenericBinaryError>(
1073 "No debug_abbrev data");
1074
1075 bool abbr_offset_OK =
1076 dwarf.GetDWARFContext().getOrLoadAbbrevData().ValidOffset(
1077 header.getAbbrOffset());
1078 if (!abbr_offset_OK)
1079 return llvm::make_error<llvm::object::GenericBinaryError>(
1080 "Abbreviation offset for unit is not valid");
1081
1082 llvm::Expected<const llvm::DWARFAbbreviationDeclarationSet *> abbrevs_or_err =
1083 abbr->getAbbreviationDeclarationSet(header.getAbbrOffset());
1084 if (!abbrevs_or_err)
1085 return abbrevs_or_err.takeError();
1086
1087 const llvm::DWARFAbbreviationDeclarationSet *abbrevs = *abbrevs_or_err;
1088 if (!abbrevs)
1089 return llvm::make_error<llvm::object::GenericBinaryError>(
1090 "No abbrev exists at the specified offset.");
1091
1092 bool is_dwo = dwarf.GetDWARFContext().isDwo();
1093 if (header.isTypeUnit())
1094 return DWARFUnitSP(
1095 new DWARFTypeUnit(dwarf, uid, header, *abbrevs, section, is_dwo));
1096 return DWARFUnitSP(
1097 new DWARFCompileUnit(dwarf, uid, header, *abbrevs, section, is_dwo));
1098}
1099
1102 ? m_dwarf.GetDWARFContext().getOrLoadDebugTypesData()
1103 : m_dwarf.GetDWARFContext().getOrLoadDebugInfoData();
1104}
1105
1106uint32_t DWARFUnit::GetHeaderByteSize() const { return m_header.getSize(); }
1107
1108std::optional<uint64_t>
1111 return m_dwarf.GetDWARFContext().getOrLoadStrOffsetsData().GetMaxU64(
1112 &offset, m_str_offset_size);
1113}
1114
1115llvm::Expected<llvm::DWARFAddressRangesVector>
1117 if (GetVersion() <= 4) {
1118 llvm::DWARFDataExtractor data =
1119 m_dwarf.GetDWARFContext().getOrLoadRangesData().GetAsLLVMDWARF();
1120 data.setAddressSize(m_header.getAddressByteSize());
1121
1122 llvm::DWARFDebugRangeList list;
1123 if (llvm::Error e = list.extract(data, &offset))
1124 return e;
1125 return list.getAbsoluteRanges(
1126 llvm::object::SectionedAddress{GetBaseAddress()});
1127 }
1128
1129 // DWARF >= v5
1130 if (!GetRnglistTable())
1131 return llvm::createStringError(std::errc::invalid_argument,
1132 "missing or invalid range list table");
1133
1134 llvm::DWARFDataExtractor data = GetRnglistData().GetAsLLVMDWARF();
1135
1136 // As DW_AT_rnglists_base may be missing we need to call setAddressSize.
1137 data.setAddressSize(m_header.getAddressByteSize());
1138 auto range_list_or_error = GetRnglistTable()->findList(data, offset);
1139 if (!range_list_or_error)
1140 return range_list_or_error.takeError();
1141
1142 return range_list_or_error->getAbsoluteRanges(
1143 llvm::object::SectionedAddress{GetBaseAddress()}, GetAddressByteSize(),
1144 [&](uint32_t index) {
1145 uint32_t index_size = GetAddressByteSize();
1146 dw_offset_t addr_base = GetAddrBase();
1147 lldb::offset_t offset =
1148 addr_base + static_cast<lldb::offset_t>(index) * index_size;
1149 return llvm::object::SectionedAddress{
1150 m_dwarf.GetDWARFContext().getOrLoadAddrData().GetMaxU64(
1151 &offset, index_size)};
1152 });
1153}
1154
1155llvm::Expected<llvm::DWARFAddressRangesVector>
1157 llvm::Expected<uint64_t> maybe_offset = GetRnglistOffset(index);
1158 if (!maybe_offset)
1159 return maybe_offset.takeError();
1160 return FindRnglistFromOffset(*maybe_offset);
1161}
1162
1163bool DWARFUnit::HasAny(llvm::ArrayRef<dw_tag_t> tags) {
1165 if (m_dwo)
1166 return m_dwo->HasAny(tags);
1167
1168 for (const auto &die : m_die_array) {
1169 for (const auto tag : tags) {
1170 if (tag == die.Tag())
1171 return true;
1172 }
1173 }
1174 return false;
1175}
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:405
static double elapsed(const StatsTimepoint &start, const StatsTimepoint &end)
#define LLDB_SCOPED_TIMERF(...)
Definition Timer.h:91
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:56
static std::optional< Style > GuessPathStyle(llvm::StringRef absolute_path)
Attempt to guess path style for a given path string.
Definition FileSpec.cpp:326
llvm::sys::path::Style Style
Definition FileSpec.h:58
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:601
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
llvm::Expected< std::pair< uint64_t, llvm::dwarf::TypeKind > > GetDIEBitSizeAndEncoding(uint64_t relative_die_offset) const override
std::optional< dw_addr_t > m_addr_base
Value of DW_AT_addr_base.
Definition DWARFUnit.h:358
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:357
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:370
const DWARFDebugInfoEntry * GetUnitDIEPtrOnly()
Definition DWARFUnit.h:307
bool LinkToSkeletonUnit(DWARFUnit &skeleton_unit)
dw_offset_t m_line_table_offset
Value of DW_AT_stmt_list.
Definition DWARFUnit.h:365
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:382
void SetLoclistsBase(dw_addr_t loclists_base)
SymbolFileDWARF & GetSymbolFileDWARF() const
Definition DWARFUnit.h:201
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:316
bool ContainsDIEOffset(dw_offset_t die_offset) const
Definition DWARFUnit.h:109
std::optional< FileSpec > m_comp_dir
Definition DWARFUnit.h:356
dw_offset_t GetFirstDIEOffset() const
Definition DWARFUnit.h:113
std::optional< uint64_t > m_language_type
Definition DWARFUnit.h:354
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:335
void SetBaseAddress(dw_addr_t base_addr)
std::optional< uint64_t > m_gnu_ranges_base
Definition DWARFUnit.h:362
const llvm::DWARFAbbreviationDeclarationSet * m_abbrevs
Definition DWARFUnit.h:330
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:350
dw_addr_t m_ranges_base
Value of DW_AT_rnglists_base.
Definition DWARFUnit.h:360
dw_addr_t m_loclists_base
Value of DW_AT_loclists_base.
Definition DWARFUnit.h:359
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)
virtual bool ParseVendorDWARFOpcode(uint8_t op, const llvm::DataExtractor &opcodes, lldb::offset_t &offset, RegisterContext *reg_ctx, lldb::RegisterKind reg_kind, std::vector< Value > &stack) const override
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:293
std::optional< llvm::DWARFListTableHeader > m_loclist_table_header
Definition DWARFUnit.h:372
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:378
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:328
std::optional< uint64_t > m_gnu_addr_base
Definition DWARFUnit.h:361
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:333
dw_addr_t ReadAddressFromDebugAddrSection(uint32_t index) const override
DWARFDataExtractor GetRnglistData() const
FileSpec GetFile(size_t file_idx)
virtual bool ParseVendorDWARFOpcode(uint8_t op, const llvm::DataExtractor &opcodes, lldb::offset_t &offset, RegisterContext *reg_ctx, lldb::RegisterKind reg_kind, std::vector< Value > &stack) const
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
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:338
std::string toString(FormatterBytecode::OpCodes op)
Format
Display format definitions.
uint64_t offset_t
Definition lldb-types.h:86
ByteOrder
Byte ordering definitions.
uint64_t user_id_t
Definition lldb-types.h:83
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