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