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/DWARFDebugLoc.h"
17#include "llvm/Object/Error.h"
18
19#include "DWARFCompileUnit.h"
20#include "DWARFDebugAranges.h"
21#include "DWARFDebugInfo.h"
22#include "DWARFTypeUnit.h"
23#include "LogChannelDWARF.h"
24#include "SymbolFileDWARFDwo.h"
25#include <optional>
26
27using namespace lldb;
28using namespace lldb_private;
29using namespace lldb_private::dwarf;
30
31extern int g_verbose;
32
34 const DWARFUnitHeader &header,
36 DIERef::Section section, bool is_dwo)
37 : UserID(uid), m_dwarf(dwarf), m_header(header), m_abbrevs(&abbrevs),
38 m_cancel_scopes(false), m_section(section), m_is_dwo(is_dwo),
39 m_has_parsed_non_skeleton_unit(false), m_dwo_id(header.GetDWOId()) {}
40
41DWARFUnit::~DWARFUnit() = default;
42
43// Parses first DIE of a compile unit, excluding DWO.
45 {
46 llvm::sys::ScopedReader lock(m_first_die_mutex);
47 if (m_first_die)
48 return; // Already parsed
49 }
50 llvm::sys::ScopedWriter lock(m_first_die_mutex);
51 if (m_first_die)
52 return; // Already parsed
53
55
56 // Set the offset to that of the first DIE and calculate the start of the
57 // next compilation unit header.
59
60 // We are in our compile unit, parse starting at the offset we were told to
61 // parse
62 const DWARFDataExtractor &data = GetData();
63 if (offset < GetNextUnitOffset() &&
64 m_first_die.Extract(data, this, &offset)) {
66 return;
67 }
68}
69
70// Parses first DIE of a compile unit including DWO.
73
75 return;
76
79
80 if (!m_dwo_id)
81 return; // No DWO file.
82
83 std::shared_ptr<SymbolFileDWARFDwo> dwo_symbol_file =
85 if (!dwo_symbol_file)
86 return;
87
88 DWARFUnit *dwo_cu = dwo_symbol_file->GetDWOCompileUnitForHash(*m_dwo_id);
89
90 if (!dwo_cu) {
92 "unable to load .dwo file from \"{0}\" due to ID ({1:x16}) mismatch "
93 "for skeleton DIE at {2:x8}",
94 dwo_symbol_file->GetObjectFile()->GetFileSpec().GetPath().c_str(),
96 return; // Can't fetch the compile unit from the dwo file.
97 }
98 dwo_cu->SetUserData(this);
99
100 DWARFBaseDIE dwo_cu_die = dwo_cu->GetUnitDIEOnly();
101 if (!dwo_cu_die.IsValid()) {
102 // Can't fetch the compile unit DIE from the dwo file.
104 "unable to extract compile unit DIE from .dwo file for skeleton "
105 "DIE at {0:x16}",
107 return;
108 }
109
110 // Here for DWO CU we want to use the address base set in the skeleton unit
111 // (DW_AT_addr_base) if it is available and use the DW_AT_GNU_addr_base
112 // otherwise. We do that because pre-DWARF v5 could use the DW_AT_GNU_*
113 // attributes which were applicable to the DWO units. The corresponding
114 // DW_AT_* attributes standardized in DWARF v5 are also applicable to the
115 // main unit in contrast.
116 if (m_addr_base)
117 dwo_cu->SetAddrBase(*m_addr_base);
118 else if (m_gnu_addr_base)
120
121 if (GetVersion() <= 4 && m_gnu_ranges_base)
123 else if (dwo_symbol_file->GetDWARFContext()
124 .getOrLoadRngListsData()
125 .GetByteSize() > 0)
126 dwo_cu->SetRangesBase(llvm::DWARFListTableHeader::getHeaderSize(DWARF32));
127
128 if (GetVersion() >= 5 &&
129 dwo_symbol_file->GetDWARFContext().getOrLoadLocListsData().GetByteSize() >
130 0)
131 dwo_cu->SetLoclistsBase(llvm::DWARFListTableHeader::getHeaderSize(DWARF32));
132
134
135 m_dwo = std::shared_ptr<DWARFUnit>(std::move(dwo_symbol_file), dwo_cu);
136}
137
138// Parses a compile unit and indexes its DIEs if it hasn't already been done.
139// It will leave this compile unit extracted forever.
141 m_cancel_scopes = true;
142
143 {
144 llvm::sys::ScopedReader lock(m_die_array_mutex);
145 if (!m_die_array.empty())
146 return; // Already parsed
147 }
148 llvm::sys::ScopedWriter lock(m_die_array_mutex);
149 if (!m_die_array.empty())
150 return; // Already parsed
151
153}
154
155// Parses a compile unit and indexes its DIEs if it hasn't already been done.
156// It will clear this compile unit after returned instance gets out of scope,
157// no other ScopedExtractDIEs instance is running for this compile unit
158// and no ExtractDIEsIfNeeded() has been executed during this ScopedExtractDIEs
159// lifetime.
161 ScopedExtractDIEs scoped(*this);
162
163 {
164 llvm::sys::ScopedReader lock(m_die_array_mutex);
165 if (!m_die_array.empty())
166 return scoped; // Already parsed
167 }
168 llvm::sys::ScopedWriter lock(m_die_array_mutex);
169 if (!m_die_array.empty())
170 return scoped; // Already parsed
171
172 // Otherwise m_die_array would be already populated.
174
176 scoped.m_clear_dies = true;
177 return scoped;
178}
179
181 m_cu->m_die_array_scoped_mutex.lock_shared();
182}
183
185 if (!m_cu)
186 return;
187 m_cu->m_die_array_scoped_mutex.unlock_shared();
188 if (!m_clear_dies || m_cu->m_cancel_scopes)
189 return;
190 // Be sure no other ScopedExtractDIEs is running anymore.
191 llvm::sys::ScopedWriter lock_scoped(m_cu->m_die_array_scoped_mutex);
192 llvm::sys::ScopedWriter lock(m_cu->m_die_array_mutex);
193 if (m_cu->m_cancel_scopes)
194 return;
195 m_cu->ClearDIEsRWLocked();
196}
197
199 : m_cu(rhs.m_cu), m_clear_dies(rhs.m_clear_dies) {
200 rhs.m_cu = nullptr;
201}
202
205 m_cu = rhs.m_cu;
206 rhs.m_cu = nullptr;
207 m_clear_dies = rhs.m_clear_dies;
208 return *this;
209}
210
211// Parses a compile unit and indexes its DIEs, m_die_array_mutex must be
212// held R/W and m_die_array must be empty.
214 llvm::sys::ScopedWriter first_die_lock(m_first_die_mutex);
215
218 "%s",
219 llvm::formatv("{0:x16}: DWARFUnit::ExtractDIEsIfNeeded()", GetOffset())
220 .str()
221 .c_str());
222
223 // Set the offset to that of the first DIE and calculate the start of the
224 // next compilation unit header.
226 lldb::offset_t next_cu_offset = GetNextUnitOffset();
227
229
230 uint32_t depth = 0;
231 // We are in our compile unit, parse starting at the offset we were told to
232 // parse
233 const DWARFDataExtractor &data = GetData();
234 std::vector<uint32_t> die_index_stack;
235 die_index_stack.reserve(32);
236 die_index_stack.push_back(0);
237 bool prev_die_had_children = false;
238 while (offset < next_cu_offset && die.Extract(data, this, &offset)) {
239 const bool null_die = die.IsNULL();
240 if (depth == 0) {
241 assert(m_die_array.empty() && "Compile unit DIE already added");
242
243 // The average bytes per DIE entry has been seen to be around 14-20 so
244 // lets pre-reserve half of that since we are now stripping the NULL
245 // tags.
246
247 // Only reserve the memory if we are adding children of the main
248 // compile unit DIE. The compile unit DIE is always the first entry, so
249 // if our size is 1, then we are adding the first compile unit child
250 // DIE and should reserve the memory.
251 m_die_array.reserve(GetDebugInfoSize() / 24);
252 m_die_array.push_back(die);
253
254 if (!m_first_die)
255 AddUnitDIE(m_die_array.front());
256
257 // With -fsplit-dwarf-inlining, clang will emit non-empty skeleton compile
258 // units. We are not able to access these DIE *and* the dwo file
259 // simultaneously. We also don't need to do that as the dwo file will
260 // contain a superset of information. So, we don't even attempt to parse
261 // any remaining DIEs.
262 if (m_dwo) {
263 m_die_array.front().SetHasChildren(false);
264 break;
265 }
266
267 } else {
268 if (null_die) {
269 if (prev_die_had_children) {
270 // This will only happen if a DIE says is has children but all it
271 // contains is a NULL tag. Since we are removing the NULL DIEs from
272 // the list (saves up to 25% in C++ code), we need a way to let the
273 // DIE know that it actually doesn't have children.
274 if (!m_die_array.empty())
275 m_die_array.back().SetHasChildren(false);
276 }
277 } else {
278 die.SetParentIndex(m_die_array.size() - die_index_stack[depth - 1]);
279
280 if (die_index_stack.back())
281 m_die_array[die_index_stack.back()].SetSiblingIndex(
282 m_die_array.size() - die_index_stack.back());
283
284 // Only push the DIE if it isn't a NULL DIE
285 m_die_array.push_back(die);
286 }
287 }
288
289 if (null_die) {
290 // NULL DIE.
291 if (!die_index_stack.empty())
292 die_index_stack.pop_back();
293
294 if (depth > 0)
295 --depth;
296 prev_die_had_children = false;
297 } else {
298 die_index_stack.back() = m_die_array.size() - 1;
299 // Normal DIE
300 const bool die_has_children = die.HasChildren();
301 if (die_has_children) {
302 die_index_stack.push_back(0);
303 ++depth;
304 }
305 prev_die_had_children = die_has_children;
306 }
307
308 if (depth == 0)
309 break; // We are done with this compile unit!
310 }
311
312 if (!m_die_array.empty()) {
313 // The last die cannot have children (if it did, it wouldn't be the last one).
314 // This only makes a difference for malformed dwarf that does not have a
315 // terminating null die.
316 m_die_array.back().SetHasChildren(false);
317
318 if (m_first_die) {
319 // Only needed for the assertion.
320 m_first_die.SetHasChildren(m_die_array.front().HasChildren());
322 }
323 m_first_die = m_die_array.front();
324 }
325
326 m_die_array.shrink_to_fit();
327
328 if (m_dwo)
329 m_dwo->ExtractDIEsIfNeeded();
330}
331
332// This is used when a split dwarf is enabled.
333// A skeleton compilation unit may contain the DW_AT_str_offsets_base attribute
334// that points to the first string offset of the CU contribution to the
335// .debug_str_offsets. At the same time, the corresponding split debug unit also
336// may use DW_FORM_strx* forms pointing to its own .debug_str_offsets.dwo and
337// for that case, we should find the offset (skip the section header).
339 lldb::offset_t baseOffset = 0;
340
341 if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) {
342 if (const auto *contribution =
343 entry->getContribution(llvm::DW_SECT_STR_OFFSETS))
344 baseOffset = contribution->getOffset();
345 else
346 return;
347 }
348
349 if (GetVersion() >= 5) {
350 const DWARFDataExtractor &strOffsets =
352 uint64_t length = strOffsets.GetU32(&baseOffset);
353 if (length == 0xffffffff)
354 length = strOffsets.GetU64(&baseOffset);
355
356 // Check version.
357 if (strOffsets.GetU16(&baseOffset) < 5)
358 return;
359
360 // Skip padding.
361 baseOffset += 2;
362 }
363
364 SetStrOffsetsBase(baseOffset);
365}
366
367std::optional<uint64_t> DWARFUnit::GetDWOId() {
369 return m_dwo_id;
370}
371
372// m_die_array_mutex must be already held as read/write.
374 DWARFAttributes attributes;
375 size_t num_attributes = cu_die.GetAttributes(this, attributes);
376
377 // Extract DW_AT_addr_base first, as other attributes may need it.
378 for (size_t i = 0; i < num_attributes; ++i) {
379 if (attributes.AttributeAtIndex(i) != DW_AT_addr_base)
380 continue;
381 DWARFFormValue form_value;
382 if (attributes.ExtractFormValueAtIndex(i, form_value)) {
383 SetAddrBase(form_value.Unsigned());
384 break;
385 }
386 }
387
388 for (size_t i = 0; i < num_attributes; ++i) {
389 dw_attr_t attr = attributes.AttributeAtIndex(i);
390 DWARFFormValue form_value;
391 if (!attributes.ExtractFormValueAtIndex(i, form_value))
392 continue;
393 switch (attr) {
394 case DW_AT_loclists_base:
395 SetLoclistsBase(form_value.Unsigned());
396 break;
397 case DW_AT_rnglists_base:
398 SetRangesBase(form_value.Unsigned());
399 break;
400 case DW_AT_str_offsets_base:
401 SetStrOffsetsBase(form_value.Unsigned());
402 break;
403 case DW_AT_low_pc:
404 SetBaseAddress(form_value.Address());
405 break;
406 case DW_AT_entry_pc:
407 // If the value was already set by DW_AT_low_pc, don't update it.
409 SetBaseAddress(form_value.Address());
410 break;
411 case DW_AT_stmt_list:
412 m_line_table_offset = form_value.Unsigned();
413 break;
414 case DW_AT_GNU_addr_base:
415 m_gnu_addr_base = form_value.Unsigned();
416 break;
417 case DW_AT_GNU_ranges_base:
418 m_gnu_ranges_base = form_value.Unsigned();
419 break;
420 case DW_AT_GNU_dwo_id:
421 m_dwo_id = form_value.Unsigned();
422 break;
423 }
424 }
425
426 if (m_is_dwo) {
429 return;
430 }
431}
432
435}
436
438 return m_abbrevs;
439}
440
443}
444
447 return m_line_table_offset;
448}
449
450void DWARFUnit::SetAddrBase(dw_addr_t addr_base) { m_addr_base = addr_base; }
451
452// Parse the rangelist table header, including the optional array of offsets
453// following it (DWARF v5 and later).
454template <typename ListTableType>
455static llvm::Expected<ListTableType>
456ParseListTableHeader(const llvm::DWARFDataExtractor &data, uint64_t offset,
457 DwarfFormat format) {
458 // We are expected to be called with Offset 0 or pointing just past the table
459 // header. Correct Offset in the latter case so that it points to the start
460 // of the header.
461 if (offset == 0) {
462 // This means DW_AT_rnglists_base is missing and therefore DW_FORM_rnglistx
463 // cannot be handled. Returning a default-constructed ListTableType allows
464 // DW_FORM_sec_offset to be supported.
465 return ListTableType();
466 }
467
468 uint64_t HeaderSize = llvm::DWARFListTableHeader::getHeaderSize(format);
469 if (offset < HeaderSize)
470 return llvm::createStringError(std::errc::invalid_argument,
471 "did not detect a valid"
472 " list table with base = 0x%" PRIx64 "\n",
473 offset);
474 offset -= HeaderSize;
475 ListTableType Table;
476 if (llvm::Error E = Table.extractHeaderAndOffsets(data, &offset))
477 return std::move(E);
478 return Table;
479}
480
482 uint64_t offset = 0;
483 if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) {
484 const auto *contribution = entry->getContribution(llvm::DW_SECT_LOCLISTS);
485 if (!contribution) {
486 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
487 "Failed to find location list contribution for CU with DWO Id "
488 "{0:x16}",
489 *GetDWOId());
490 return;
491 }
492 offset += contribution->getOffset();
493 }
494 m_loclists_base = loclists_base;
495
496 uint64_t header_size = llvm::DWARFListTableHeader::getHeaderSize(DWARF32);
497 if (loclists_base < header_size)
498 return;
499
500 m_loclist_table_header.emplace(".debug_loclists", "locations");
501 offset += loclists_base - header_size;
502 if (llvm::Error E = m_loclist_table_header->extract(
504 &offset)) {
505 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
506 "Failed to extract location list table at offset {0:x16} (location "
507 "list base: {1:x16}): {2}",
508 offset, loclists_base, toString(std::move(E)).c_str());
509 }
510}
511
512std::unique_ptr<llvm::DWARFLocationTable>
514 llvm::DWARFDataExtractor llvm_data(
516 data.GetAddressByteSize());
517
518 if (m_is_dwo || GetVersion() >= 5)
519 return std::make_unique<llvm::DWARFDebugLoclists>(llvm_data, GetVersion());
520 return std::make_unique<llvm::DWARFDebugLoc>(llvm_data);
521}
522
525 const DWARFDataExtractor &data =
527 if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) {
528 if (const auto *contribution = entry->getContribution(
529 GetVersion() >= 5 ? llvm::DW_SECT_LOCLISTS : llvm::DW_SECT_EXT_LOC))
530 return DWARFDataExtractor(data, contribution->getOffset(),
531 contribution->getLength32());
532 return DWARFDataExtractor();
533 }
534 return data;
535}
536
539 const DWARFDataExtractor &data = Ctx.getOrLoadRngListsData();
540 if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) {
541 if (const auto *contribution =
542 entry->getContribution(llvm::DW_SECT_RNGLISTS))
543 return DWARFDataExtractor(data, contribution->getOffset(),
544 contribution->getLength32());
545 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
546 "Failed to find range list contribution for CU with signature {0:x16}",
547 entry->getSignature());
548
549 return DWARFDataExtractor();
550 }
551 return data;
552}
553
556
557 m_ranges_base = ranges_base;
558}
559
560const std::optional<llvm::DWARFDebugRnglistTable> &
562 if (GetVersion() >= 5 && !m_rnglist_table_done) {
564 if (auto table_or_error =
565 ParseListTableHeader<llvm::DWARFDebugRnglistTable>(
566 GetRnglistData().GetAsLLVM(), m_ranges_base, DWARF32))
567 m_rnglist_table = std::move(table_or_error.get());
568 else
569 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
570 "Failed to extract range list table at offset {0:x16}: {1}",
571 m_ranges_base, toString(table_or_error.takeError()).c_str());
572 }
573 return m_rnglist_table;
574}
575
576// This function is called only for DW_FORM_rnglistx.
577llvm::Expected<uint64_t> DWARFUnit::GetRnglistOffset(uint32_t Index) {
578 if (!GetRnglistTable())
579 return llvm::createStringError(std::errc::invalid_argument,
580 "missing or invalid range list table");
581 if (!m_ranges_base)
582 return llvm::createStringError(
583 std::errc::invalid_argument,
584 llvm::formatv("DW_FORM_rnglistx cannot be used without "
585 "DW_AT_rnglists_base for CU at {0:x16}",
586 GetOffset())
587 .str()
588 .c_str());
589 if (std::optional<uint64_t> off = GetRnglistTable()->getOffsetEntry(
590 GetRnglistData().GetAsLLVM(), Index))
591 return *off + m_ranges_base;
592 return llvm::createStringError(
593 std::errc::invalid_argument,
594 "invalid range list table index %u; OffsetEntryCount is %u, "
595 "DW_AT_rnglists_base is %" PRIu64,
596 Index, GetRnglistTable()->getOffsetEntryCount(), m_ranges_base);
597}
598
600 m_str_offsets_base = str_offsets_base;
601}
602
604 uint32_t index_size = GetAddressByteSize();
605 dw_offset_t addr_base = GetAddrBase();
606 dw_addr_t offset = addr_base + static_cast<dw_addr_t>(index) * index_size;
607 const DWARFDataExtractor &data =
609 if (data.ValidOffsetForDataOfSize(offset, index_size))
610 return data.GetMaxU64_unchecked(&offset, index_size);
612}
613
614// It may be called only with m_die_array_mutex held R/W.
616 m_die_array.clear();
617 m_die_array.shrink_to_fit();
618
619 if (m_dwo && !m_dwo->m_cancel_scopes)
620 m_dwo->ClearDIEsRWLocked();
621}
622
625}
626
627void DWARFUnit::SetBaseAddress(dw_addr_t base_addr) { m_base_addr = base_addr; }
628
629// Compare function DWARFDebugAranges::Range structures
631 const dw_offset_t die_offset) {
632 return die.GetOffset() < die_offset;
633}
634
635// GetDIE()
636//
637// Get the DIE (Debug Information Entry) with the specified offset by first
638// checking if the DIE is contained within this compile unit and grabbing the
639// DIE from this compile unit. Otherwise we grab the DIE from the DWARF file.
642 if (die_offset == DW_INVALID_OFFSET)
643 return DWARFDIE(); // Not found
644
645 if (!ContainsDIEOffset(die_offset)) {
646 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
647 "GetDIE for DIE {0:x16} is outside of its CU {0:x16}", die_offset,
648 GetOffset());
649 return DWARFDIE(); // Not found
650 }
651
655 lower_bound(m_die_array.cbegin(), end, die_offset, CompareDIEOffset);
656
657 if (pos != end && die_offset == (*pos).GetOffset())
658 return DWARFDIE(this, &(*pos));
659 return DWARFDIE(); // Not found
660}
661
664 if (m_dwo)
665 return *m_dwo;
666 return *this;
667}
668
670 if (cu)
671 return cu->GetAddressByteSize();
673}
674
675uint8_t DWARFUnit::GetDefaultAddressSize() { return 4; }
676
677void *DWARFUnit::GetUserData() const { return m_user_data; }
678
680
682 return GetProducer() != eProducerLLVMGCC;
683}
684
686 // llvm-gcc makes completely invalid decl file attributes and won't ever be
687 // fixed, so we need to know to ignore these.
688 return GetProducer() == eProducerLLVMGCC;
689}
690
693 return GetProducerVersion() >= llvm::VersionTuple(425, 0, 13);
694 // Assume all other compilers didn't have incorrect ObjC bitfield info.
695 return true;
696}
697
701 if (!die)
702 return;
703
704 llvm::StringRef producer(
705 die->GetAttributeValueAsString(this, DW_AT_producer, nullptr));
706 if (producer.empty())
707 return;
708
709 static const RegularExpression g_swiftlang_version_regex(
710 llvm::StringRef(R"(swiftlang-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?))"));
711 static const RegularExpression g_clang_version_regex(
712 llvm::StringRef(R"(clang-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?))"));
713 static const RegularExpression g_llvm_gcc_regex(
714 llvm::StringRef(R"(4\.[012]\.[01] )"
715 R"(\‍(Based on Apple Inc\. build [0-9]+\) )"
716 R"(\‍(LLVM build [\.0-9]+\)$)"));
717
718 llvm::SmallVector<llvm::StringRef, 3> matches;
719 if (g_swiftlang_version_regex.Execute(producer, &matches)) {
720 m_producer_version.tryParse(matches[1]);
722 } else if (producer.contains("clang")) {
723 if (g_clang_version_regex.Execute(producer, &matches))
724 m_producer_version.tryParse(matches[1]);
726 } else if (producer.contains("GNU")) {
728 } else if (g_llvm_gcc_regex.Execute(producer)) {
730 }
731}
732
736 return m_producer;
737}
738
739llvm::VersionTuple DWARFUnit::GetProducerVersion() {
740 if (m_producer_version.empty())
742 return m_producer_version;
743}
744
746 if (m_language_type)
747 return *m_language_type;
748
750 if (!die)
751 m_language_type = 0;
752 else
753 m_language_type = die->GetAttributeValueAsUnsigned(this, DW_AT_language, 0);
754 return *m_language_type;
755}
756
760 if (die) {
762 if (die->GetAttributeValueAsUnsigned(this, DW_AT_APPLE_optimized, 0) ==
763 1) {
765 }
766 }
767 }
769}
770
772 if (!m_comp_dir)
774 return m_comp_dir->GetPathStyle();
775}
776
778 if (!m_comp_dir)
780 return *m_comp_dir;
781}
782
784 if (!m_file_spec)
786 return *m_file_spec;
787}
788
789FileSpec DWARFUnit::GetFile(size_t file_idx) {
790 return m_dwarf.GetFile(*this, file_idx);
791}
792
793// DWARF2/3 suggests the form hostname:pathname for compilation directory.
794// Remove the host part if present.
795static llvm::StringRef
796removeHostnameFromPathname(llvm::StringRef path_from_dwarf) {
797 if (!path_from_dwarf.contains(':'))
798 return path_from_dwarf;
799 llvm::StringRef host, path;
800 std::tie(host, path) = path_from_dwarf.split(':');
801
802 if (host.contains('/'))
803 return path_from_dwarf;
804
805 // check whether we have a windows path, and so the first character is a
806 // drive-letter not a hostname.
807 if (host.size() == 1 && llvm::isAlpha(host[0]) &&
808 (path.startswith("\\") || path.startswith("/")))
809 return path_from_dwarf;
810
811 return path;
812}
813
817 if (!die)
818 return;
819
820 llvm::StringRef comp_dir = removeHostnameFromPathname(
821 die->GetAttributeValueAsString(this, DW_AT_comp_dir, nullptr));
822 if (!comp_dir.empty()) {
823 FileSpec::Style comp_dir_style =
824 FileSpec::GuessPathStyle(comp_dir).value_or(FileSpec::Style::native);
825 m_comp_dir = FileSpec(comp_dir, comp_dir_style);
826 } else {
827 // Try to detect the style based on the DW_AT_name attribute, but just store
828 // the detected style in the m_comp_dir field.
829 const char *name =
830 die->GetAttributeValueAsString(this, DW_AT_name, nullptr);
832 "", FileSpec::GuessPathStyle(name).value_or(FileSpec::Style::native));
833 }
834}
835
839 if (!die)
840 return;
841
843 FileSpec(die->GetAttributeValueAsString(this, DW_AT_name, nullptr),
844 GetPathStyle());
845
846 if (m_file_spec->IsRelative())
847 m_file_spec->MakeAbsolute(GetCompilationDirectory());
848}
849
852 if (m_dwo)
853 return &llvm::cast<SymbolFileDWARFDwo>(m_dwo->GetSymbolFileDWARF());
854 return nullptr;
855}
856
858 if (m_func_aranges_up == nullptr) {
859 m_func_aranges_up = std::make_unique<DWARFDebugAranges>();
860 const DWARFDebugInfoEntry *die = DIEPtr();
861 if (die)
863
864 if (m_dwo) {
865 const DWARFDebugInfoEntry *dwo_die = m_dwo->DIEPtr();
866 if (dwo_die)
868 m_func_aranges_up.get());
869 }
870
871 const bool minimize = false;
872 m_func_aranges_up->Sort(minimize);
873 }
874 return *m_func_aranges_up;
875}
876
877llvm::Expected<DWARFUnitHeader>
879 DIERef::Section section,
881 lldb::offset_t *offset_ptr) {
882 DWARFUnitHeader header;
883 header.m_offset = *offset_ptr;
884 header.m_length = data.GetDWARFInitialLength(offset_ptr);
885 header.m_version = data.GetU16(offset_ptr);
886 if (header.m_version == 5) {
887 header.m_unit_type = data.GetU8(offset_ptr);
888 header.m_addr_size = data.GetU8(offset_ptr);
889 header.m_abbr_offset = data.GetDWARFOffset(offset_ptr);
890 if (header.m_unit_type == llvm::dwarf::DW_UT_skeleton ||
891 header.m_unit_type == llvm::dwarf::DW_UT_split_compile)
892 header.m_dwo_id = data.GetU64(offset_ptr);
893 } else {
894 header.m_abbr_offset = data.GetDWARFOffset(offset_ptr);
895 header.m_addr_size = data.GetU8(offset_ptr);
896 header.m_unit_type =
897 section == DIERef::Section::DebugTypes ? DW_UT_type : DW_UT_compile;
898 }
899
900 if (header.IsTypeUnit()) {
901 header.m_type_hash = data.GetU64(offset_ptr);
902 header.m_type_offset = data.GetDWARFOffset(offset_ptr);
903 }
904
905 if (context.isDwo()) {
906 const llvm::DWARFUnitIndex *Index;
907 if (header.IsTypeUnit()) {
908 Index = &context.GetAsLLVM().getTUIndex();
909 if (*Index)
910 header.m_index_entry = Index->getFromHash(header.m_type_hash);
911 } else {
912 Index = &context.GetAsLLVM().getCUIndex();
913 if (*Index && header.m_version >= 5 && header.m_dwo_id)
914 header.m_index_entry = Index->getFromHash(*header.m_dwo_id);
915 }
916 if (!header.m_index_entry)
917 header.m_index_entry = Index->getFromOffset(header.m_offset);
918 }
919
920 if (header.m_index_entry) {
921 if (header.m_abbr_offset) {
922 return llvm::createStringError(
923 llvm::inconvertibleErrorCode(),
924 "Package unit with a non-zero abbreviation offset");
925 }
926 auto *unit_contrib = header.m_index_entry->getContribution();
927 if (!unit_contrib || unit_contrib->getLength32() != header.m_length + 4) {
928 return llvm::createStringError(llvm::inconvertibleErrorCode(),
929 "Inconsistent DWARF package unit index");
930 }
931 auto *abbr_entry =
932 header.m_index_entry->getContribution(llvm::DW_SECT_ABBREV);
933 if (!abbr_entry) {
934 return llvm::createStringError(
935 llvm::inconvertibleErrorCode(),
936 "DWARF package index missing abbreviation column");
937 }
938 header.m_abbr_offset = abbr_entry->getOffset();
939 }
940
941 bool length_OK = data.ValidOffset(header.GetNextUnitOffset() - 1);
942 bool version_OK = SymbolFileDWARF::SupportedVersion(header.m_version);
943 bool addr_size_OK = (header.m_addr_size == 4) || (header.m_addr_size == 8);
944 bool type_offset_OK =
945 !header.IsTypeUnit() || (header.m_type_offset <= header.GetLength());
946
947 if (!length_OK)
948 return llvm::make_error<llvm::object::GenericBinaryError>(
949 "Invalid unit length");
950 if (!version_OK)
951 return llvm::make_error<llvm::object::GenericBinaryError>(
952 "Unsupported unit version");
953 if (!addr_size_OK)
954 return llvm::make_error<llvm::object::GenericBinaryError>(
955 "Invalid unit address size");
956 if (!type_offset_OK)
957 return llvm::make_error<llvm::object::GenericBinaryError>(
958 "Type offset out of range");
959
960 return header;
961}
962
963llvm::Expected<DWARFUnitSP>
965 const DWARFDataExtractor &debug_info,
966 DIERef::Section section, lldb::offset_t *offset_ptr) {
967 assert(debug_info.ValidOffset(*offset_ptr));
968
969 auto expected_header = DWARFUnitHeader::extract(
970 debug_info, section, dwarf.GetDWARFContext(), offset_ptr);
971 if (!expected_header)
972 return expected_header.takeError();
973
974 const DWARFDebugAbbrev *abbr = dwarf.DebugAbbrev();
975 if (!abbr)
976 return llvm::make_error<llvm::object::GenericBinaryError>(
977 "No debug_abbrev data");
978
979 bool abbr_offset_OK =
980 dwarf.GetDWARFContext().getOrLoadAbbrevData().ValidOffset(
981 expected_header->GetAbbrOffset());
982 if (!abbr_offset_OK)
983 return llvm::make_error<llvm::object::GenericBinaryError>(
984 "Abbreviation offset for unit is not valid");
985
986 const DWARFAbbreviationDeclarationSet *abbrevs =
987 abbr->GetAbbreviationDeclarationSet(expected_header->GetAbbrOffset());
988 if (!abbrevs)
989 return llvm::make_error<llvm::object::GenericBinaryError>(
990 "No abbrev exists at the specified offset.");
991
992 bool is_dwo = dwarf.GetDWARFContext().isDwo();
993 if (expected_header->IsTypeUnit())
994 return DWARFUnitSP(new DWARFTypeUnit(dwarf, uid, *expected_header, *abbrevs,
995 section, is_dwo));
996 return DWARFUnitSP(new DWARFCompileUnit(dwarf, uid, *expected_header,
997 *abbrevs, section, is_dwo));
998}
999
1004}
1005
1007 switch (m_header.GetUnitType()) {
1008 case llvm::dwarf::DW_UT_compile:
1009 case llvm::dwarf::DW_UT_partial:
1010 return GetVersion() < 5 ? 11 : 12;
1011 case llvm::dwarf::DW_UT_skeleton:
1012 case llvm::dwarf::DW_UT_split_compile:
1013 return 20;
1014 case llvm::dwarf::DW_UT_type:
1015 case llvm::dwarf::DW_UT_split_type:
1016 return GetVersion() < 5 ? 23 : 24;
1017 }
1018 llvm_unreachable("invalid UnitType.");
1019}
1020
1021std::optional<uint64_t>
1023 offset_t offset = GetStrOffsetsBase() + index * 4;
1025}
1026
1027llvm::Expected<DWARFRangeList>
1029 if (GetVersion() <= 4) {
1030 const DWARFDebugRanges *debug_ranges = m_dwarf.GetDebugRanges();
1031 if (!debug_ranges)
1032 return llvm::make_error<llvm::object::GenericBinaryError>(
1033 "No debug_ranges section");
1034 DWARFRangeList ranges;
1035 debug_ranges->FindRanges(this, offset, ranges);
1036 return ranges;
1037 }
1038
1039 if (!GetRnglistTable())
1040 return llvm::createStringError(std::errc::invalid_argument,
1041 "missing or invalid range list table");
1042
1043 llvm::DWARFDataExtractor data = GetRnglistData().GetAsLLVM();
1044
1045 // As DW_AT_rnglists_base may be missing we need to call setAddressSize.
1046 data.setAddressSize(m_header.GetAddressByteSize());
1047 auto range_list_or_error = GetRnglistTable()->findList(data, offset);
1048 if (!range_list_or_error)
1049 return range_list_or_error.takeError();
1050
1051 llvm::Expected<llvm::DWARFAddressRangesVector> llvm_ranges =
1052 range_list_or_error->getAbsoluteRanges(
1053 llvm::object::SectionedAddress{GetBaseAddress()},
1054 GetAddressByteSize(), [&](uint32_t index) {
1055 uint32_t index_size = GetAddressByteSize();
1056 dw_offset_t addr_base = GetAddrBase();
1057 lldb::offset_t offset =
1058 addr_base + static_cast<lldb::offset_t>(index) * index_size;
1059 return llvm::object::SectionedAddress{
1061 &offset, index_size)};
1062 });
1063 if (!llvm_ranges)
1064 return llvm_ranges.takeError();
1065
1066 DWARFRangeList ranges;
1067 for (const llvm::DWARFAddressRange &llvm_range : *llvm_ranges) {
1068 ranges.Append(DWARFRangeList::Entry(llvm_range.LowPC,
1069 llvm_range.HighPC - llvm_range.LowPC));
1070 }
1071 return ranges;
1072}
1073
1074llvm::Expected<DWARFRangeList>
1076 llvm::Expected<uint64_t> maybe_offset = GetRnglistOffset(index);
1077 if (!maybe_offset)
1078 return maybe_offset.takeError();
1079 return FindRnglistFromOffset(*maybe_offset);
1080}
1081
1082
1083bool DWARFUnit::HasAny(llvm::ArrayRef<dw_tag_t> tags) {
1085 if (m_dwo)
1086 return m_dwo->HasAny(tags);
1087
1088 for (const auto &die: m_die_array) {
1089 for (const auto tag: tags) {
1090 if (tag == die.Tag())
1091 return true;
1092 }
1093 }
1094 return false;
1095}
static bool CompareDIEOffset(const DWARFDebugInfoEntry &die, const dw_offset_t die_offset)
Definition: DWARFUnit.cpp:630
static llvm::Expected< ListTableType > ParseListTableHeader(const llvm::DWARFDataExtractor &data, uint64_t offset, DwarfFormat format)
Definition: DWARFUnit.cpp:456
static llvm::StringRef removeHostnameFromPathname(llvm::StringRef path_from_dwarf)
Definition: DWARFUnit.cpp:796
int g_verbose
DWARFProducer
Definition: DWARFUnit.h:29
@ eProducerLLVMGCC
Definition: DWARFUnit.h:33
@ eProducerClang
Definition: DWARFUnit.h:31
@ eProducerInvalid
Definition: DWARFUnit.h:30
@ eProducerSwift
Definition: DWARFUnit.h:34
@ eProducerOther
Definition: DWARFUnit.h:35
@ eProducerGCC
Definition: DWARFUnit.h:32
std::shared_ptr< DWARFUnit > DWARFUnitSP
Definition: DWARFUnit.h:27
#define lldbassert(x)
Definition: LLDBAssert.h:15
static double elapsed(const StatsTimepoint &start, const StatsTimepoint &end)
Definition: Statistics.cpp:36
static std::optional< uint64_t > GetDWOId(DWARFCompileUnit &dwarf_cu, const DWARFDebugInfoEntry &cu_die)
Return the DW_AT_(GNU_)dwo_id.
#define LLDB_SCOPED_TIMERF(...)
Definition: Timer.h:86
Section
Definition: DIERef.h:30
@ DebugTypes
Definition: DIERef.h:30
dw_attr_t AttributeAtIndex(uint32_t i) const
bool ExtractFormValueAtIndex(uint32_t i, DWARFFormValue &form_value) const
bool IsValid() const
Definition: DWARFBaseDIE.h:46
const DWARFAbbreviationDeclarationSet * GetAbbreviationDeclarationSet(dw_offset_t cu_abbr_offset) const
DWARFDebugInfoEntry objects assume that they are living in one big vector and do pointer arithmetic o...
dw_offset_t GetOffset() const
size_t GetAttributes(DWARFUnit *cu, DWARFAttributes &attrs, Recurse recurse=Recurse::yes) const
const char * GetAttributeValueAsString(const DWARFUnit *cu, const dw_attr_t attr, const char *fail_value, bool check_specification_or_abstract_origin=false) const
bool Extract(const lldb_private::DWARFDataExtractor &data, const DWARFUnit *cu, lldb::offset_t *offset_ptr)
void BuildFunctionAddressRangeTable(DWARFUnit *cu, DWARFDebugAranges *debug_aranges) const
This function is builds a table very similar to the standard .debug_aranges table,...
void SetParentIndex(uint32_t idx)
uint64_t GetAttributeValueAsUnsigned(const DWARFUnit *cu, const dw_attr_t attr, uint64_t fail_value, bool check_specification_or_abstract_origin=false) const
collection::const_iterator const_iterator
bool FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset, DWARFRangeList &range_list) const
uint64_t Unsigned() const
dw_addr_t Address() const
Base class describing the header of any kind of "unit." Some information is specific to certain unit ...
Definition: DWARFUnit.h:41
uint8_t m_unit_type
Definition: DWARFUnit.h:49
uint16_t m_version
Definition: DWARFUnit.h:44
uint16_t GetAddressByteSize() const
Definition: DWARFUnit.h:62
dw_offset_t GetLength() const
Definition: DWARFUnit.h:63
const llvm::DWARFUnitIndex::Entry * m_index_entry
Definition: DWARFUnit.h:47
dw_offset_t m_offset
Definition: DWARFUnit.h:42
dw_offset_t m_abbr_offset
Definition: DWARFUnit.h:45
uint8_t m_addr_size
Definition: DWARFUnit.h:50
uint32_t m_type_offset
Definition: DWARFUnit.h:53
static llvm::Expected< DWARFUnitHeader > extract(const lldb_private::DWARFDataExtractor &data, DIERef::Section section, lldb_private::DWARFContext &dwarf_context, lldb::offset_t *offset_ptr)
Definition: DWARFUnit.cpp:878
uint32_t GetNextUnitOffset() const
Definition: DWARFUnit.h:76
bool IsTypeUnit() const
Definition: DWARFUnit.h:72
const llvm::DWARFUnitIndex::Entry * GetIndexEntry() const
Definition: DWARFUnit.h:66
dw_offset_t m_length
Definition: DWARFUnit.h:43
std::optional< uint64_t > m_dwo_id
Definition: DWARFUnit.h:55
uint8_t GetUnitType() const
Definition: DWARFUnit.h:65
uint64_t m_type_hash
Definition: DWARFUnit.h:52
const ScopedExtractDIEs & operator=(const ScopedExtractDIEs &)=delete
ScopedExtractDIEs(DWARFUnit &cu)
Definition: DWARFUnit.cpp:180
SymbolFileDWARFDwo * GetDwoSymbolFile()
Definition: DWARFUnit.cpp:850
void * GetUserData() const
Definition: DWARFUnit.cpp:677
bool m_rnglist_table_done
Definition: DWARFUnit.h:363
const DIERef::Section m_section
Definition: DWARFUnit.h:366
lldb_private::FileSpec::Style GetPathStyle()
Definition: DWARFUnit.cpp:771
SymbolFileDWARF & GetSymbolFileDWARF() const
Definition: DWARFUnit.h:200
void ExtractDIEsIfNeeded()
Definition: DWARFUnit.cpp:140
lldb_private::Status m_dwo_error
If we get an error when trying to load a .dwo file, save that error here.
Definition: DWARFUnit.h:374
bool GetIsOptimized()
Definition: DWARFUnit.cpp:757
dw_offset_t GetAbbrevOffset() const
Definition: DWARFUnit.cpp:441
bool m_is_dwo
Definition: DWARFUnit.h:367
dw_addr_t m_loclists_base
Value of DW_AT_loclists_base.
Definition: DWARFUnit.h:352
void ExtractUnitDIEIfNeeded()
Definition: DWARFUnit.cpp:71
void SetDwoError(const lldb_private::Status &error)
Set the fission .dwo file specific error for this compile unit.
Definition: DWARFUnit.h:289
DWARFDebugInfoEntry::collection m_die_array
Definition: DWARFUnit.h:329
const DWARFDebugInfoEntry * GetUnitDIEPtrOnly()
Definition: DWARFUnit.h:303
virtual ~DWARFUnit()
DWARFUnitHeader m_header
Definition: DWARFUnit.h:325
void ExtractUnitDIENoDwoIfNeeded()
Definition: DWARFUnit.cpp:44
dw_addr_t m_base_addr
Definition: DWARFUnit.h:344
void SetStrOffsetsBase(dw_offset_t str_offsets_base)
Definition: DWARFUnit.cpp:599
dw_offset_t m_str_offsets_base
Definition: DWARFUnit.h:360
void SetLoclistsBase(dw_addr_t loclists_base)
Definition: DWARFUnit.cpp:481
void SetDwoStrOffsetsBase()
Definition: DWARFUnit.cpp:338
const DWARFDebugAranges & GetFunctionAranges()
Definition: DWARFUnit.cpp:857
std::optional< uint64_t > m_language_type
Definition: DWARFUnit.h:347
dw_offset_t GetLineTableOffset()
Definition: DWARFUnit.cpp:445
dw_offset_t GetFirstDIEOffset() const
Definition: DWARFUnit.h:147
std::atomic< bool > m_cancel_scopes
Definition: DWARFUnit.h:335
bool m_has_parsed_non_skeleton_unit
Definition: DWARFUnit.h:368
bool Supports_DW_AT_APPLE_objc_complete_type()
Definition: DWARFUnit.cpp:681
const lldb_private::DWARFDataExtractor & GetData() const
Get the data that contains the DIE information for this unit.
Definition: DWARFUnit.cpp:1000
bool DW_AT_decl_file_attributes_are_invalid()
Definition: DWARFUnit.cpp:685
DWARFBaseDIE GetUnitDIEOnly()
Definition: DWARFUnit.h:178
dw_addr_t ReadAddressFromDebugAddrSection(uint32_t index) const
Definition: DWARFUnit.cpp:603
std::optional< uint64_t > m_gnu_addr_base
Definition: DWARFUnit.h:354
uint16_t GetVersion() const
Definition: DWARFUnit.h:155
std::optional< llvm::DWARFDebugRnglistTable > m_rnglist_table
Definition: DWARFUnit.h:362
lldb_private::LazyBool m_is_optimized
Definition: DWARFUnit.h:348
llvm::VersionTuple m_producer_version
Definition: DWARFUnit.h:346
dw_addr_t GetAddrBase() const
Definition: DWARFUnit.h:159
void ParseProducerInfo()
Definition: DWARFUnit.cpp:698
void SetBaseAddress(dw_addr_t base_addr)
Definition: DWARFUnit.cpp:627
void ComputeCompDirAndGuessPathStyle()
Definition: DWARFUnit.cpp:814
std::optional< dw_addr_t > m_addr_base
Value of DW_AT_addr_base.
Definition: DWARFUnit.h:351
void SetUserData(void *d)
Definition: DWARFUnit.cpp:679
size_t GetDebugInfoSize() const
Definition: DWARFUnit.cpp:433
lldb_private::DWARFDataExtractor GetLocationData() const
Definition: DWARFUnit.cpp:523
const std::optional< llvm::DWARFDebugRnglistTable > & GetRnglistTable()
Definition: DWARFUnit.cpp:561
llvm::sys::RWMutex m_die_array_scoped_mutex
Definition: DWARFUnit.h:332
const lldb_private::FileSpec & GetAbsolutePath()
Definition: DWARFUnit.cpp:783
llvm::Expected< uint64_t > GetRnglistOffset(uint32_t Index)
Return a rangelist's offset based on an index.
Definition: DWARFUnit.cpp:577
std::optional< lldb_private::FileSpec > m_file_spec
Definition: DWARFUnit.h:350
dw_addr_t GetStrOffsetsBase() const
Definition: DWARFUnit.h:163
bool Supports_unnamed_objc_bitfields()
Definition: DWARFUnit.cpp:691
uint8_t GetAddressByteSize() const
Definition: DWARFUnit.h:158
std::unique_ptr< llvm::DWARFLocationTable > GetLocationTable(const lldb_private::DataExtractor &data) const
Return the location table for parsing the given location list data.
Definition: DWARFUnit.cpp:513
llvm::sys::RWMutex m_die_array_mutex
Definition: DWARFUnit.h:330
DWARFDebugInfoEntry m_first_die
Definition: DWARFUnit.h:339
void SetRangesBase(dw_addr_t ranges_base)
Definition: DWARFUnit.cpp:554
uint32_t GetHeaderByteSize() const
Get the size in bytes of the unit header.
Definition: DWARFUnit.cpp:1006
ScopedExtractDIEs ExtractDIEsScoped()
Definition: DWARFUnit.cpp:160
void SetAddrBase(dw_addr_t addr_base)
Definition: DWARFUnit.cpp:450
static llvm::Expected< DWARFUnitSP > extract(SymbolFileDWARF &dwarf2Data, lldb::user_id_t uid, const lldb_private::DWARFDataExtractor &debug_info, DIERef::Section section, lldb::offset_t *offset_ptr)
Definition: DWARFUnit.cpp:964
llvm::Expected< DWARFRangeList > FindRnglistFromIndex(uint32_t index)
Return a list of address ranges retrieved from an encoded range list whose offset is found via a tabl...
Definition: DWARFUnit.cpp:1075
void ExtractDIEsRWLocked()
Definition: DWARFUnit.cpp:213
llvm::VersionTuple GetProducerVersion()
Definition: DWARFUnit.cpp:739
static uint8_t GetDefaultAddressSize()
Definition: DWARFUnit.cpp:675
DWARFProducer m_producer
Definition: DWARFUnit.h:345
std::optional< uint64_t > m_gnu_ranges_base
Definition: DWARFUnit.h:355
dw_offset_t GetNextUnitOffset() const
Definition: DWARFUnit.h:150
uint64_t GetDWARFLanguageType()
Definition: DWARFUnit.cpp:745
SymbolFileDWARF & m_dwarf
Definition: DWARFUnit.h:323
void ComputeAbsolutePath()
Definition: DWARFUnit.cpp:836
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:370
const DWARFDebugInfoEntry * DIEPtr()
Definition: DWARFUnit.h:312
size_t GetLengthByteSize() const
Get the size in bytes of the length field in the header.
Definition: DWARFUnit.h:141
std::shared_ptr< DWARFUnit > m_dwo
Definition: DWARFUnit.h:324
DWARFUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid, const DWARFUnitHeader &header, const DWARFAbbreviationDeclarationSet &abbrevs, DIERef::Section section, bool is_dwo)
Definition: DWARFUnit.cpp:33
void * m_user_data
Definition: DWARFUnit.h:327
std::optional< uint64_t > GetStringOffsetSectionItem(uint32_t index) const
Definition: DWARFUnit.cpp:1022
bool ContainsDIEOffset(dw_offset_t die_offset) const
Definition: DWARFUnit.h:143
std::unique_ptr< DWARFDebugAranges > m_func_aranges_up
Definition: DWARFUnit.h:343
DWARFUnit & GetNonSkeletonUnit()
Definition: DWARFUnit.cpp:662
DWARFDIE GetDIE(dw_offset_t die_offset)
Definition: DWARFUnit.cpp:641
const DWARFAbbreviationDeclarationSet * GetAbbreviations() const
Definition: DWARFUnit.cpp:437
lldb::ByteOrder GetByteOrder() const
Definition: DWARFUnit.cpp:623
void AddUnitDIE(const DWARFDebugInfoEntry &cu_die)
Definition: DWARFUnit.cpp:373
dw_offset_t m_line_table_offset
Value of DW_AT_stmt_list.
Definition: DWARFUnit.h:358
void ClearDIEsRWLocked()
Definition: DWARFUnit.cpp:615
const DWARFAbbreviationDeclarationSet * m_abbrevs
Definition: DWARFUnit.h:326
uint32_t GetLength() const
Definition: DWARFUnit.h:154
DWARFProducer GetProducer()
Definition: DWARFUnit.cpp:733
const lldb_private::FileSpec & GetCompilationDirectory()
Definition: DWARFUnit.cpp:777
std::optional< uint64_t > GetDWOId()
Definition: DWARFUnit.cpp:367
dw_addr_t GetBaseAddress() const
Definition: DWARFUnit.h:160
std::optional< lldb_private::FileSpec > m_comp_dir
Definition: DWARFUnit.h:349
dw_addr_t m_ranges_base
Value of DW_AT_rnglists_base.
Definition: DWARFUnit.h:353
bool HasAny(llvm::ArrayRef< dw_tag_t > tags)
Returns true if any DIEs in the unit match any DW_TAG values in tags.
Definition: DWARFUnit.cpp:1083
llvm::Expected< DWARFRangeList > FindRnglistFromOffset(dw_offset_t offset)
Return a list of address ranges resulting from a (possibly encoded) range list starting at a given of...
Definition: DWARFUnit.cpp:1028
std::optional< llvm::DWARFListTableHeader > m_loclist_table_header
Definition: DWARFUnit.h:364
lldb_private::DWARFDataExtractor GetRnglistData() const
Definition: DWARFUnit.cpp:537
lldb_private::FileSpec GetFile(size_t file_idx)
Definition: DWARFUnit.cpp:789
llvm::sys::RWMutex m_first_die_mutex
Definition: DWARFUnit.h:340
dw_offset_t GetOffset() const
Definition: DWARFUnit.h:134
static bool SupportedVersion(uint16_t version)
DWARFDebugRanges * GetDebugRanges()
lldb_private::StatsDuration & GetDebugInfoParseTimeRef()
lldb_private::FileSpec GetFile(DWARFUnit &unit, size_t file_idx)
std::shared_ptr< SymbolFileDWARFDwo > GetDwoSymbolFileForCompileUnit(DWARFUnit &dwarf_cu, const DWARFDebugInfoEntry &cu_die)
lldb_private::DWARFContext & GetDWARFContext()
const DWARFDataExtractor & getOrLoadLocListsData()
const DWARFDataExtractor & getOrLoadStrOffsetsData()
llvm::DWARFContext & GetAsLLVM()
const DWARFDataExtractor & getOrLoadDebugTypesData()
const DWARFDataExtractor & getOrLoadDebugInfoData()
const DWARFDataExtractor & getOrLoadRngListsData()
const DWARFDataExtractor & getOrLoadLocData()
const DWARFDataExtractor & getOrLoadAddrData()
uint64_t GetDWARFInitialLength(lldb::offset_t *offset_ptr) const
llvm::DWARFDataExtractor GetAsLLVM() const
dw_offset_t GetDWARFOffset(lldb::offset_t *offset_ptr) const
An data extractor class.
Definition: DataExtractor.h:48
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.
uint64_t GetMaxU64_unchecked(lldb::offset_t *offset_ptr, size_t byte_size) const
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.
uint64_t GetMaxU64(lldb::offset_t *offset_ptr, size_t byte_size) const
Extract an unsigned integer of size byte_size from *offset_ptr.
lldb::ByteOrder GetByteOrder() const
Get the current byte order value.
uint8_t GetU8(lldb::offset_t *offset_ptr) const
Extract a uint8_t value from *offset_ptr.
A class that measures elapsed time in an exception safe way.
Definition: Statistics.h:68
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:309
llvm::sys::path::Style Style
Definition: FileSpec.h:58
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Definition: ModuleChild.cpp:24
virtual lldb::ByteOrder GetByteOrder() const =0
Gets whether endian swapping should occur when extracting data from this object file.
void Append(const Entry &entry)
Definition: RangeMap.h:179
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...
void Clear()
Clear the object state.
Definition: Status.cpp:167
static Status createWithFormat(const char *format, Args &&...args)
Definition: Status.h:68
ObjectFile * GetObjectFile() override
Definition: SymbolFile.h:477
uint64_t dw_offset_t
Definition: dwarf.h:33
#define DW_INVALID_OFFSET
Definition: dwarf.h:38
uint64_t dw_addr_t
Definition: dwarf.h:29
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
const char * toString(AppleArm64ExceptionClass EC)
Definition: SBAddress.h:15
uint64_t offset_t
Definition: lldb-types.h:87
ByteOrder
Byte ordering definitions.
@ eByteOrderLittle
uint64_t user_id_t
Definition: lldb-types.h:84
A mix in class that contains a generic user ID.
Definition: UserID.h:31