LLDB  mainline
SymbolFileDWARF.cpp
Go to the documentation of this file.
1 //===-- SymbolFileDWARF.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 "SymbolFileDWARF.h"
10 
11 #include "llvm/ADT/Optional.h"
12 #include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
13 #include "llvm/Support/Casting.h"
14 #include "llvm/Support/Threading.h"
15 
16 #include "lldb/Core/Module.h"
17 #include "lldb/Core/ModuleList.h"
18 #include "lldb/Core/ModuleSpec.h"
20 #include "lldb/Core/Progress.h"
21 #include "lldb/Core/Section.h"
22 #include "lldb/Core/StreamFile.h"
23 #include "lldb/Core/Value.h"
24 #include "lldb/Utility/ArchSpec.h"
25 #include "lldb/Utility/LLDBLog.h"
27 #include "lldb/Utility/Scalar.h"
29 #include "lldb/Utility/Timer.h"
30 
33 
34 #include "lldb/Host/FileSystem.h"
35 #include "lldb/Host/Host.h"
36 
39 
43 #include "lldb/Symbol/Block.h"
48 #include "lldb/Symbol/LineTable.h"
50 #include "lldb/Symbol/ObjectFile.h"
51 #include "lldb/Symbol/SymbolFile.h"
52 #include "lldb/Symbol/TypeMap.h"
53 #include "lldb/Symbol/TypeSystem.h"
55 
56 #include "lldb/Target/Language.h"
57 #include "lldb/Target/Target.h"
58 
59 #include "AppleDWARFIndex.h"
60 #include "DWARFASTParser.h"
61 #include "DWARFASTParserClang.h"
62 #include "DWARFCompileUnit.h"
63 #include "DWARFDebugAbbrev.h"
64 #include "DWARFDebugAranges.h"
65 #include "DWARFDebugInfo.h"
66 #include "DWARFDebugMacro.h"
67 #include "DWARFDebugRanges.h"
68 #include "DWARFDeclContext.h"
69 #include "DWARFFormValue.h"
70 #include "DWARFTypeUnit.h"
71 #include "DWARFUnit.h"
72 #include "DebugNamesDWARFIndex.h"
73 #include "LogChannelDWARF.h"
74 #include "ManualDWARFIndex.h"
76 #include "SymbolFileDWARFDwo.h"
77 
78 #include "llvm/DebugInfo/DWARF/DWARFContext.h"
79 #include "llvm/Support/FileSystem.h"
80 #include "llvm/Support/FormatVariadic.h"
81 
82 #include <algorithm>
83 #include <map>
84 #include <memory>
85 
86 #include <cctype>
87 #include <cstring>
88 
89 //#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN
90 
91 #ifdef ENABLE_DEBUG_PRINTF
92 #include <cstdio>
93 #define DEBUG_PRINTF(fmt, ...) printf(fmt, __VA_ARGS__)
94 #else
95 #define DEBUG_PRINTF(fmt, ...)
96 #endif
97 
98 using namespace lldb;
99 using namespace lldb_private;
100 using namespace lldb_private::dwarf;
101 
103 
105 
106 namespace {
107 
108 #define LLDB_PROPERTIES_symbolfiledwarf
109 #include "SymbolFileDWARFProperties.inc"
110 
111 enum {
112 #define LLDB_PROPERTIES_symbolfiledwarf
113 #include "SymbolFileDWARFPropertiesEnum.inc"
114 };
115 
116 class PluginProperties : public Properties {
117 public:
118  static ConstString GetSettingName() {
120  }
121 
122  PluginProperties() {
123  m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName());
124  m_collection_sp->Initialize(g_symbolfiledwarf_properties);
125  }
126 
127  bool IgnoreFileIndexes() const {
128  return m_collection_sp->GetPropertyAtIndexAsBoolean(
129  nullptr, ePropertyIgnoreIndexes, false);
130  }
131 };
132 
133 } // namespace
134 
135 static PluginProperties &GetGlobalPluginProperties() {
136  static PluginProperties g_settings;
137  return g_settings;
138 }
139 
140 static const llvm::DWARFDebugLine::LineTable *
142  llvm::DWARFDebugLine &line, dw_offset_t line_offset,
143  dw_offset_t unit_offset) {
144  Log *log = GetLog(DWARFLog::DebugInfo);
145 
146  llvm::DWARFDataExtractor data = context.getOrLoadLineData().GetAsLLVM();
147  llvm::DWARFContext &ctx = context.GetAsLLVM();
148  llvm::Expected<const llvm::DWARFDebugLine::LineTable *> line_table =
149  line.getOrParseLineTable(
150  data, line_offset, ctx, nullptr, [&](llvm::Error e) {
152  log, std::move(e),
153  "SymbolFileDWARF::ParseLineTable failed to parse: {0}");
154  });
155 
156  if (!line_table) {
157  LLDB_LOG_ERROR(log, line_table.takeError(),
158  "SymbolFileDWARF::ParseLineTable failed to parse: {0}");
159  return nullptr;
160  }
161  return *line_table;
162 }
163 
165  llvm::DWARFDebugLine::Prologue &prologue,
166  dw_offset_t line_offset,
167  dw_offset_t unit_offset) {
168  Log *log = GetLog(DWARFLog::DebugInfo);
169  bool success = true;
170  llvm::DWARFDataExtractor data = context.getOrLoadLineData().GetAsLLVM();
171  llvm::DWARFContext &ctx = context.GetAsLLVM();
172  uint64_t offset = line_offset;
173  llvm::Error error = prologue.parse(
174  data, &offset,
175  [&](llvm::Error e) {
176  success = false;
177  LLDB_LOG_ERROR(log, std::move(e),
178  "SymbolFileDWARF::ParseSupportFiles failed to parse "
179  "line table prologue: {0}");
180  },
181  ctx, nullptr);
182  if (error) {
183  LLDB_LOG_ERROR(log, std::move(error),
184  "SymbolFileDWARF::ParseSupportFiles failed to parse line "
185  "table prologue: {0}");
186  return false;
187  }
188  return success;
189 }
190 
191 static llvm::Optional<std::string>
192 GetFileByIndex(const llvm::DWARFDebugLine::Prologue &prologue, size_t idx,
193  llvm::StringRef compile_dir, FileSpec::Style style) {
194  // Try to get an absolute path first.
195  std::string abs_path;
196  auto absolute = llvm::DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath;
197  if (prologue.getFileNameByIndex(idx, compile_dir, absolute, abs_path, style))
198  return std::move(abs_path);
199 
200  // Otherwise ask for a relative path.
201  std::string rel_path;
202  auto relative = llvm::DILineInfoSpecifier::FileLineInfoKind::RawValue;
203  if (!prologue.getFileNameByIndex(idx, compile_dir, relative, rel_path, style))
204  return {};
205  return std::move(rel_path);
206 }
207 
208 static FileSpecList
209 ParseSupportFilesFromPrologue(const lldb::ModuleSP &module,
210  const llvm::DWARFDebugLine::Prologue &prologue,
211  FileSpec::Style style,
212  llvm::StringRef compile_dir = {}) {
213  FileSpecList support_files;
214  size_t first_file = 0;
215  if (prologue.getVersion() <= 4) {
216  // File index 0 is not valid before DWARF v5. Add a dummy entry to ensure
217  // support file list indices match those we get from the debug info and line
218  // tables.
219  support_files.Append(FileSpec());
220  first_file = 1;
221  }
222 
223  const size_t number_of_files = prologue.FileNames.size();
224  for (size_t idx = first_file; idx <= number_of_files; ++idx) {
225  std::string remapped_file;
226  if (auto file_path = GetFileByIndex(prologue, idx, compile_dir, style)) {
227  if (auto remapped = module->RemapSourceFile(llvm::StringRef(*file_path)))
228  remapped_file = *remapped;
229  else
230  remapped_file = std::move(*file_path);
231  }
232 
233  // Unconditionally add an entry, so the indices match up.
234  support_files.EmplaceBack(remapped_file, style);
235  }
236 
237  return support_files;
238 }
239 
241  LogChannelDWARF::Initialize();
242  PluginManager::RegisterPlugin(GetPluginNameStatic(),
243  GetPluginDescriptionStatic(), CreateInstance,
244  DebuggerInitialize);
246 }
247 
249  if (!PluginManager::GetSettingForSymbolFilePlugin(
250  debugger, PluginProperties::GetSettingName())) {
251  const bool is_global_setting = true;
252  PluginManager::CreateSettingForSymbolFilePlugin(
253  debugger, GetGlobalPluginProperties().GetValueProperties(),
254  ConstString("Properties for the dwarf symbol-file plug-in."),
255  is_global_setting);
256  }
257 }
258 
261  PluginManager::UnregisterPlugin(CreateInstance);
262  LogChannelDWARF::Terminate();
263 }
264 
266  return "DWARF and DWARF3 debug symbol file reader.";
267 }
268 
269 SymbolFile *SymbolFileDWARF::CreateInstance(ObjectFileSP objfile_sp) {
270  return new SymbolFileDWARF(std::move(objfile_sp),
271  /*dwo_section_list*/ nullptr);
272 }
273 
275  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
276  if (SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile())
277  return debug_map_symfile->GetTypeList();
278  return SymbolFileCommon::GetTypeList();
279 }
280 void SymbolFileDWARF::GetTypes(const DWARFDIE &die, dw_offset_t min_die_offset,
281  dw_offset_t max_die_offset, uint32_t type_mask,
282  TypeSet &type_set) {
283  if (die) {
284  const dw_offset_t die_offset = die.GetOffset();
285 
286  if (die_offset >= max_die_offset)
287  return;
288 
289  if (die_offset >= min_die_offset) {
290  const dw_tag_t tag = die.Tag();
291 
292  bool add_type = false;
293 
294  switch (tag) {
295  case DW_TAG_array_type:
296  add_type = (type_mask & eTypeClassArray) != 0;
297  break;
298  case DW_TAG_unspecified_type:
299  case DW_TAG_base_type:
300  add_type = (type_mask & eTypeClassBuiltin) != 0;
301  break;
302  case DW_TAG_class_type:
303  add_type = (type_mask & eTypeClassClass) != 0;
304  break;
305  case DW_TAG_structure_type:
306  add_type = (type_mask & eTypeClassStruct) != 0;
307  break;
308  case DW_TAG_union_type:
309  add_type = (type_mask & eTypeClassUnion) != 0;
310  break;
311  case DW_TAG_enumeration_type:
312  add_type = (type_mask & eTypeClassEnumeration) != 0;
313  break;
314  case DW_TAG_subroutine_type:
315  case DW_TAG_subprogram:
316  case DW_TAG_inlined_subroutine:
317  add_type = (type_mask & eTypeClassFunction) != 0;
318  break;
319  case DW_TAG_pointer_type:
320  add_type = (type_mask & eTypeClassPointer) != 0;
321  break;
322  case DW_TAG_rvalue_reference_type:
323  case DW_TAG_reference_type:
324  add_type = (type_mask & eTypeClassReference) != 0;
325  break;
326  case DW_TAG_typedef:
327  add_type = (type_mask & eTypeClassTypedef) != 0;
328  break;
329  case DW_TAG_ptr_to_member_type:
330  add_type = (type_mask & eTypeClassMemberPointer) != 0;
331  break;
332  default:
333  break;
334  }
335 
336  if (add_type) {
337  const bool assert_not_being_parsed = true;
338  Type *type = ResolveTypeUID(die, assert_not_being_parsed);
339  if (type)
340  type_set.insert(type);
341  }
342  }
343 
344  for (DWARFDIE child_die : die.children()) {
345  GetTypes(child_die, min_die_offset, max_die_offset, type_mask, type_set);
346  }
347  }
348 }
349 
351  TypeClass type_mask, TypeList &type_list)
352 
353 {
354  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
355  TypeSet type_set;
356 
357  CompileUnit *comp_unit = nullptr;
358  if (sc_scope)
359  comp_unit = sc_scope->CalculateSymbolContextCompileUnit();
360 
361  const auto &get = [&](DWARFUnit *unit) {
362  if (!unit)
363  return;
364  unit = &unit->GetNonSkeletonUnit();
365  GetTypes(unit->DIE(), unit->GetOffset(), unit->GetNextUnitOffset(),
366  type_mask, type_set);
367  };
368  if (comp_unit) {
369  get(GetDWARFCompileUnit(comp_unit));
370  } else {
371  DWARFDebugInfo &info = DebugInfo();
372  const size_t num_cus = info.GetNumUnits();
373  for (size_t cu_idx = 0; cu_idx < num_cus; ++cu_idx)
374  get(info.GetUnitAtIndex(cu_idx));
375  }
376 
377  std::set<CompilerType> compiler_type_set;
378  for (Type *type : type_set) {
379  CompilerType compiler_type = type->GetForwardCompilerType();
380  if (compiler_type_set.find(compiler_type) == compiler_type_set.end()) {
381  compiler_type_set.insert(compiler_type);
382  type_list.Insert(type->shared_from_this());
383  }
384  }
385 }
386 
387 // Gets the first parent that is a lexical block, function or inlined
388 // subroutine, or compile unit.
389 DWARFDIE
391  DWARFDIE die;
392  for (die = child_die.GetParent(); die; die = die.GetParent()) {
393  dw_tag_t tag = die.Tag();
394 
395  switch (tag) {
396  case DW_TAG_compile_unit:
397  case DW_TAG_partial_unit:
398  case DW_TAG_subprogram:
399  case DW_TAG_inlined_subroutine:
400  case DW_TAG_lexical_block:
401  return die;
402  default:
403  break;
404  }
405  }
406  return DWARFDIE();
407 }
408 
409 SymbolFileDWARF::SymbolFileDWARF(ObjectFileSP objfile_sp,
410  SectionList *dwo_section_list)
411  : SymbolFileCommon(std::move(objfile_sp)),
412  UserID(0x7fffffff00000000), // Used by SymbolFileDWARFDebugMap to
413  // when this class parses .o files to
414  // contain the .o file index/ID
415  m_debug_map_module_wp(), m_debug_map_symfile(nullptr),
416  m_context(m_objfile_sp->GetModule()->GetSectionList(), dwo_section_list),
417  m_fetched_external_modules(false),
418  m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate) {}
419 
421 
423  static ConstString g_dwarf_section_name("__DWARF");
424  return g_dwarf_section_name;
425 }
426 
428  SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile();
429  if (debug_map_symfile)
430  return debug_map_symfile->GetUniqueDWARFASTTypeMap();
431  else
432  return m_unique_ast_type_map;
433 }
434 
435 llvm::Expected<lldb::TypeSystemSP>
437  if (SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile())
438  return debug_map_symfile->GetTypeSystemForLanguage(language);
439 
440  auto type_system_or_err =
441  m_objfile_sp->GetModule()->GetTypeSystemForLanguage(language);
442  if (type_system_or_err)
443  if (auto ts = *type_system_or_err)
444  ts->SetSymbolFile(this);
445  return type_system_or_err;
446 }
447 
449  Log *log = GetLog(DWARFLog::DebugInfo);
450 
452 
453  if (!GetGlobalPluginProperties().IgnoreFileIndexes()) {
454  StreamString module_desc;
455  GetObjectFile()->GetModule()->GetDescription(module_desc.AsRawOstream(),
457  DWARFDataExtractor apple_names, apple_namespaces, apple_types, apple_objc;
462 
463  if (apple_names.GetByteSize() > 0 || apple_namespaces.GetByteSize() > 0 ||
464  apple_types.GetByteSize() > 0 || apple_objc.GetByteSize() > 0) {
465  Progress progress(llvm::formatv("Loading Apple DWARF index for {0}",
466  module_desc.GetData()));
467  m_index = AppleDWARFIndex::Create(
468  *GetObjectFile()->GetModule(), apple_names, apple_namespaces,
469  apple_types, apple_objc, m_context.getOrLoadStrData());
470 
471  if (m_index)
472  return;
473  }
474 
475  DWARFDataExtractor debug_names;
477  if (debug_names.GetByteSize() > 0) {
478  Progress progress(
479  llvm::formatv("Loading DWARF5 index for {0}", module_desc.GetData()));
480  llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>> index_or =
481  DebugNamesDWARFIndex::Create(*GetObjectFile()->GetModule(),
482  debug_names,
483  m_context.getOrLoadStrData(), *this);
484  if (index_or) {
485  m_index = std::move(*index_or);
486  return;
487  }
488  LLDB_LOG_ERROR(log, index_or.takeError(),
489  "Unable to read .debug_names data: {0}");
490  }
491  }
492 
493  m_index =
494  std::make_unique<ManualDWARFIndex>(*GetObjectFile()->GetModule(), *this);
495 }
496 
499  *m_objfile_sp->GetModule()->GetSectionList());
502 }
503 
505  const lldb_private::SectionList &section_list) {
506  for (SectionSP section_sp : section_list) {
507  if (section_sp->GetChildren().GetSize() > 0) {
508  InitializeFirstCodeAddressRecursive(section_sp->GetChildren());
509  } else if (section_sp->GetType() == eSectionTypeCode) {
511  std::min(m_first_code_address, section_sp->GetFileAddress());
512  }
513  }
514 }
515 
517  return version >= 2 && version <= 5;
518 }
519 
521  uint32_t abilities = 0;
522  if (m_objfile_sp != nullptr) {
523  const Section *section = nullptr;
524  const SectionList *section_list = m_objfile_sp->GetSectionList();
525  if (section_list == nullptr)
526  return 0;
527 
528  uint64_t debug_abbrev_file_size = 0;
529  uint64_t debug_info_file_size = 0;
530  uint64_t debug_line_file_size = 0;
531 
532  section = section_list->FindSectionByName(GetDWARFMachOSegmentName()).get();
533 
534  if (section)
535  section_list = &section->GetChildren();
536 
537  section =
538  section_list->FindSectionByType(eSectionTypeDWARFDebugInfo, true).get();
539  if (section != nullptr) {
540  debug_info_file_size = section->GetFileSize();
541 
542  section =
544  .get();
545  if (section)
546  debug_abbrev_file_size = section->GetFileSize();
547 
548  DWARFDebugAbbrev *abbrev = DebugAbbrev();
549  if (abbrev) {
550  std::set<dw_form_t> invalid_forms;
551  abbrev->GetUnsupportedForms(invalid_forms);
552  if (!invalid_forms.empty()) {
554  error.Printf("unsupported DW_FORM value%s:",
555  invalid_forms.size() > 1 ? "s" : "");
556  for (auto form : invalid_forms)
557  error.Printf(" %#x", form);
558  m_objfile_sp->GetModule()->ReportWarning(
559  "%s", error.GetString().str().c_str());
560  return 0;
561  }
562  }
563 
564  section =
565  section_list->FindSectionByType(eSectionTypeDWARFDebugLine, true)
566  .get();
567  if (section)
568  debug_line_file_size = section->GetFileSize();
569  } else {
570  llvm::StringRef symfile_dir =
571  m_objfile_sp->GetFileSpec().GetDirectory().GetStringRef();
572  if (symfile_dir.contains_insensitive(".dsym")) {
573  if (m_objfile_sp->GetType() == ObjectFile::eTypeDebugInfo) {
574  // We have a dSYM file that didn't have a any debug info. If the
575  // string table has a size of 1, then it was made from an
576  // executable with no debug info, or from an executable that was
577  // stripped.
578  section =
579  section_list->FindSectionByType(eSectionTypeDWARFDebugStr, true)
580  .get();
581  if (section && section->GetFileSize() == 1) {
582  m_objfile_sp->GetModule()->ReportWarning(
583  "empty dSYM file detected, dSYM was created with an "
584  "executable with no debug info.");
585  }
586  }
587  }
588  }
589 
590  if (debug_abbrev_file_size > 0 && debug_info_file_size > 0)
591  abilities |= CompileUnits | Functions | Blocks | GlobalVariables |
593 
594  if (debug_line_file_size > 0)
595  abilities |= LineTables;
596  }
597  return abilities;
598 }
599 
601  DWARFDataExtractor &data) {
602  ModuleSP module_sp(m_objfile_sp->GetModule());
603  const SectionList *section_list = module_sp->GetSectionList();
604  if (!section_list)
605  return;
606 
607  SectionSP section_sp(section_list->FindSectionByType(sect_type, true));
608  if (!section_sp)
609  return;
610 
611  data.Clear();
612  m_objfile_sp->ReadSectionData(section_sp.get(), data);
613 }
614 
616  if (m_abbr)
617  return m_abbr.get();
618 
619  const DWARFDataExtractor &debug_abbrev_data = m_context.getOrLoadAbbrevData();
620  if (debug_abbrev_data.GetByteSize() == 0)
621  return nullptr;
622 
623  auto abbr = std::make_unique<DWARFDebugAbbrev>();
624  llvm::Error error = abbr->parse(debug_abbrev_data);
625  if (error) {
626  Log *log = GetLog(DWARFLog::DebugInfo);
627  LLDB_LOG_ERROR(log, std::move(error),
628  "Unable to read .debug_abbrev section: {0}");
629  return nullptr;
630  }
631 
632  m_abbr = std::move(abbr);
633  return m_abbr.get();
634 }
635 
637  llvm::call_once(m_info_once_flag, [&] {
638  LLDB_SCOPED_TIMERF("%s this = %p", LLVM_PRETTY_FUNCTION,
639  static_cast<void *>(this));
640  m_info = std::make_unique<DWARFDebugInfo>(*this, m_context);
641  });
642  return *m_info;
643 }
644 
646  if (!comp_unit)
647  return nullptr;
648 
649  // The compile unit ID is the index of the DWARF unit.
650  DWARFUnit *dwarf_cu = DebugInfo().GetUnitAtIndex(comp_unit->GetID());
651  if (dwarf_cu && dwarf_cu->GetUserData() == nullptr)
652  dwarf_cu->SetUserData(comp_unit);
653 
654  // It must be DWARFCompileUnit when it created a CompileUnit.
655  return llvm::cast_or_null<DWARFCompileUnit>(dwarf_cu);
656 }
657 
659  if (!m_ranges) {
660  LLDB_SCOPED_TIMERF("%s this = %p", LLVM_PRETTY_FUNCTION,
661  static_cast<void *>(this));
662 
664  m_ranges = std::make_unique<DWARFDebugRanges>();
665 
666  if (m_ranges)
667  m_ranges->Extract(m_context);
668  }
669  return m_ranges.get();
670 }
671 
672 /// Make an absolute path out of \p file_spec and remap it using the
673 /// module's source remapping dictionary.
674 static void MakeAbsoluteAndRemap(FileSpec &file_spec, DWARFUnit &dwarf_cu,
675  const ModuleSP &module_sp) {
676  if (!file_spec)
677  return;
678  // If we have a full path to the compile unit, we don't need to
679  // resolve the file. This can be expensive e.g. when the source
680  // files are NFS mounted.
681  file_spec.MakeAbsolute(dwarf_cu.GetCompilationDirectory());
682 
683  if (auto remapped_file = module_sp->RemapSourceFile(file_spec.GetPath()))
684  file_spec.SetFile(*remapped_file, FileSpec::Style::native);
685 }
686 
687 /// Return the DW_AT_(GNU_)dwo_name.
688 static const char *GetDWOName(DWARFCompileUnit &dwarf_cu,
689  const DWARFDebugInfoEntry &cu_die) {
690  const char *dwo_name =
691  cu_die.GetAttributeValueAsString(&dwarf_cu, DW_AT_GNU_dwo_name, nullptr);
692  if (!dwo_name)
693  dwo_name =
694  cu_die.GetAttributeValueAsString(&dwarf_cu, DW_AT_dwo_name, nullptr);
695  return dwo_name;
696 }
697 
699  CompUnitSP cu_sp;
700  CompileUnit *comp_unit = (CompileUnit *)dwarf_cu.GetUserData();
701  if (comp_unit) {
702  // We already parsed this compile unit, had out a shared pointer to it
703  cu_sp = comp_unit->shared_from_this();
704  } else {
705  if (GetDebugMapSymfile()) {
706  // Let the debug map create the compile unit
707  cu_sp = m_debug_map_symfile->GetCompileUnit(this, dwarf_cu);
708  dwarf_cu.SetUserData(cu_sp.get());
709  } else {
710  ModuleSP module_sp(m_objfile_sp->GetModule());
711  if (module_sp) {
712  auto initialize_cu = [&](const FileSpec &file_spec,
713  LanguageType cu_language) {
715  cu_sp = std::make_shared<CompileUnit>(
716  module_sp, &dwarf_cu, file_spec,
717  *GetDWARFUnitIndex(dwarf_cu.GetID()), cu_language,
719 
720  dwarf_cu.SetUserData(cu_sp.get());
721 
722  SetCompileUnitAtIndex(dwarf_cu.GetID(), cu_sp);
723  };
724 
725  auto lazy_initialize_cu = [&]() {
726  // If the version is < 5, we can't do lazy initialization.
727  if (dwarf_cu.GetVersion() < 5)
728  return false;
729 
730  // If there is no DWO, there is no reason to initialize
731  // lazily; we will do eager initialization in that case.
732  if (GetDebugMapSymfile())
733  return false;
734  const DWARFBaseDIE cu_die = dwarf_cu.GetUnitDIEOnly();
735  if (!cu_die)
736  return false;
737  if (!GetDWOName(dwarf_cu, *cu_die.GetDIE()))
738  return false;
739 
740  // With DWARFv5 we can assume that the first support
741  // file is also the name of the compile unit. This
742  // allows us to avoid loading the non-skeleton unit,
743  // which may be in a separate DWO file.
744  FileSpecList support_files;
745  if (!ParseSupportFiles(dwarf_cu, module_sp, support_files))
746  return false;
747  if (support_files.GetSize() == 0)
748  return false;
749 
750  initialize_cu(support_files.GetFileSpecAtIndex(0),
752  cu_sp->SetSupportFiles(std::move(support_files));
753  return true;
754  };
755 
756  if (!lazy_initialize_cu()) {
757  // Eagerly initialize compile unit
758  const DWARFBaseDIE cu_die =
759  dwarf_cu.GetNonSkeletonUnit().GetUnitDIEOnly();
760  if (cu_die) {
762  dwarf_cu.GetDWARFLanguageType());
763 
764  FileSpec cu_file_spec(cu_die.GetName(), dwarf_cu.GetPathStyle());
765 
766  // Path needs to be remapped in this case. In the support files
767  // case ParseSupportFiles takes care of the remapping.
768  MakeAbsoluteAndRemap(cu_file_spec, dwarf_cu, module_sp);
769 
770  initialize_cu(cu_file_spec, cu_language);
771  }
772  }
773  }
774  }
775  }
776  return cu_sp;
777 }
778 
780  if (!m_lldb_cu_to_dwarf_unit.empty())
781  return;
782 
783  DWARFDebugInfo &info = DebugInfo();
784  if (!info.ContainsTypeUnits()) {
785  // We can use a 1-to-1 mapping. No need to build a translation table.
786  return;
787  }
788  for (uint32_t i = 0, num = info.GetNumUnits(); i < num; ++i) {
789  if (auto *cu = llvm::dyn_cast<DWARFCompileUnit>(info.GetUnitAtIndex(i))) {
790  cu->SetID(m_lldb_cu_to_dwarf_unit.size());
791  m_lldb_cu_to_dwarf_unit.push_back(i);
792  }
793  }
794 }
795 
796 llvm::Optional<uint32_t> SymbolFileDWARF::GetDWARFUnitIndex(uint32_t cu_idx) {
798  if (m_lldb_cu_to_dwarf_unit.empty())
799  return cu_idx;
800  if (cu_idx >= m_lldb_cu_to_dwarf_unit.size())
801  return llvm::None;
802  return m_lldb_cu_to_dwarf_unit[cu_idx];
803 }
804 
807  return m_lldb_cu_to_dwarf_unit.empty() ? DebugInfo().GetNumUnits()
808  : m_lldb_cu_to_dwarf_unit.size();
809 }
810 
812  ASSERT_MODULE_LOCK(this);
813  if (llvm::Optional<uint32_t> dwarf_idx = GetDWARFUnitIndex(cu_idx)) {
814  if (auto *dwarf_cu = llvm::cast_or_null<DWARFCompileUnit>(
815  DebugInfo().GetUnitAtIndex(*dwarf_idx)))
816  return ParseCompileUnit(*dwarf_cu);
817  }
818  return {};
819 }
820 
822  const DWARFDIE &die) {
823  ASSERT_MODULE_LOCK(this);
824  if (!die.IsValid())
825  return nullptr;
826 
827  auto type_system_or_err = GetTypeSystemForLanguage(GetLanguage(*die.GetCU()));
828  if (auto err = type_system_or_err.takeError()) {
829  LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
830  "Unable to parse function");
831  return nullptr;
832  }
833  auto ts = *type_system_or_err;
834  if (!ts)
835  return nullptr;
836  DWARFASTParser *dwarf_ast = ts->GetDWARFParser();
837  if (!dwarf_ast)
838  return nullptr;
839 
840  DWARFRangeList ranges;
841  if (die.GetDIE()->GetAttributeAddressRanges(die.GetCU(), ranges,
842  /*check_hi_lo_pc=*/true) == 0)
843  return nullptr;
844 
845  // Union of all ranges in the function DIE (if the function is
846  // discontiguous)
847  lldb::addr_t lowest_func_addr = ranges.GetMinRangeBase(0);
848  lldb::addr_t highest_func_addr = ranges.GetMaxRangeEnd(0);
849  if (lowest_func_addr == LLDB_INVALID_ADDRESS ||
850  lowest_func_addr >= highest_func_addr ||
851  lowest_func_addr < m_first_code_address)
852  return nullptr;
853 
854  ModuleSP module_sp(die.GetModule());
855  AddressRange func_range;
857  lowest_func_addr, module_sp->GetSectionList());
858  if (!func_range.GetBaseAddress().IsValid())
859  return nullptr;
860 
861  func_range.SetByteSize(highest_func_addr - lowest_func_addr);
862  if (!FixupAddress(func_range.GetBaseAddress()))
863  return nullptr;
864 
865  return dwarf_ast->ParseFunctionFromDWARF(comp_unit, die, func_range);
866 }
867 
870  ASSERT_MODULE_LOCK(this);
871  if (!die.IsValid()) {
872  return ConstString();
873  }
874 
875  auto type_system_or_err = GetTypeSystemForLanguage(GetLanguage(*die.GetCU()));
876  if (auto err = type_system_or_err.takeError()) {
877  LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
878  "Unable to construct demangled name for function");
879  return ConstString();
880  }
881 
882  auto ts = *type_system_or_err;
883  if (!ts) {
884  LLDB_LOG(GetLog(LLDBLog::Symbols), "Type system no longer live");
885  return ConstString();
886  }
887  DWARFASTParser *dwarf_ast = ts->GetDWARFParser();
888  if (!dwarf_ast)
889  return ConstString();
890 
891  return dwarf_ast->ConstructDemangledNameFromDWARF(die);
892 }
893 
895  SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile();
896  if (debug_map_symfile)
897  return debug_map_symfile->LinkOSOFileAddress(this, file_addr);
898  return file_addr;
899 }
900 
902  SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile();
903  if (debug_map_symfile) {
904  return debug_map_symfile->LinkOSOAddress(addr);
905  }
906  // This is a normal DWARF file, no address fixups need to happen
907  return true;
908 }
910  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
911  DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
912  if (dwarf_cu)
913  return GetLanguage(dwarf_cu->GetNonSkeletonUnit());
914  else
915  return eLanguageTypeUnknown;
916 }
917 
919  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
920  DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
921  if (!dwarf_cu)
922  return {};
923  const DWARFBaseDIE cu_die = dwarf_cu->GetNonSkeletonUnit().GetUnitDIEOnly();
924  if (!cu_die)
925  return {};
926  const char *sdk = cu_die.GetAttributeValueAsString(DW_AT_APPLE_sdk, nullptr);
927  if (!sdk)
928  return {};
929  const char *sysroot =
930  cu_die.GetAttributeValueAsString(DW_AT_LLVM_sysroot, "");
931  // Register the sysroot path remapping with the module belonging to
932  // the CU as well as the one belonging to the symbol file. The two
933  // would be different if this is an OSO object and module is the
934  // corresponding debug map, in which case both should be updated.
935  ModuleSP module_sp = comp_unit.GetModule();
936  if (module_sp)
937  module_sp->RegisterXcodeSDK(sdk, sysroot);
938 
939  ModuleSP local_module_sp = m_objfile_sp->GetModule();
940  if (local_module_sp && local_module_sp != module_sp)
941  local_module_sp->RegisterXcodeSDK(sdk, sysroot);
942 
943  return {sdk};
944 }
945 
948  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
949  DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
950  if (!dwarf_cu)
951  return 0;
952 
953  size_t functions_added = 0;
954  dwarf_cu = &dwarf_cu->GetNonSkeletonUnit();
955  for (DWARFDebugInfoEntry &entry : dwarf_cu->dies()) {
956  if (entry.Tag() != DW_TAG_subprogram)
957  continue;
958 
959  DWARFDIE die(dwarf_cu, &entry);
960  if (comp_unit.FindFunctionByUID(die.GetID()))
961  continue;
962  if (ParseFunction(comp_unit, die))
963  ++functions_added;
964  }
965  // FixupTypes();
966  return functions_added;
967 }
968 
970  CompileUnit &comp_unit,
971  llvm::DenseSet<lldb_private::SymbolFile *> &visited_symbol_files,
972  llvm::function_ref<bool(Module &)> lambda) {
973  // Only visit each symbol file once.
974  if (!visited_symbol_files.insert(this).second)
975  return false;
976 
978  for (auto &p : m_external_type_modules) {
979  ModuleSP module = p.second;
980  if (!module)
981  continue;
982 
983  // Invoke the action and potentially early-exit.
984  if (lambda(*module))
985  return true;
986 
987  for (std::size_t i = 0; i < module->GetNumCompileUnits(); ++i) {
988  auto cu = module->GetCompileUnitAtIndex(i);
989  bool early_exit = cu->ForEachExternalModule(visited_symbol_files, lambda);
990  if (early_exit)
991  return true;
992  }
993  }
994  return false;
995 }
996 
998  FileSpecList &support_files) {
999  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1000  DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
1001  if (!dwarf_cu)
1002  return false;
1003 
1004  if (!ParseSupportFiles(*dwarf_cu, comp_unit.GetModule(), support_files))
1005  return false;
1006 
1007  comp_unit.SetSupportFiles(support_files);
1008  return true;
1009 }
1010 
1012  const ModuleSP &module,
1013  FileSpecList &support_files) {
1014 
1015  dw_offset_t offset = dwarf_cu.GetLineTableOffset();
1016  if (offset == DW_INVALID_OFFSET)
1017  return false;
1018 
1020  llvm::DWARFDebugLine::Prologue prologue;
1021  if (!ParseLLVMLineTablePrologue(m_context, prologue, offset,
1022  dwarf_cu.GetOffset()))
1023  return false;
1024 
1025  std::string comp_dir = dwarf_cu.GetCompilationDirectory().GetPath();
1026  support_files = ParseSupportFilesFromPrologue(
1027  module, prologue, dwarf_cu.GetPathStyle(), comp_dir);
1028  return true;
1029 }
1030 
1032  if (auto *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(&unit)) {
1033  if (CompileUnit *lldb_cu = GetCompUnitForDWARFCompUnit(*dwarf_cu))
1034  return lldb_cu->GetSupportFiles().GetFileSpecAtIndex(file_idx);
1035  return FileSpec();
1036  }
1037 
1038  auto &tu = llvm::cast<DWARFTypeUnit>(unit);
1039  return GetTypeUnitSupportFiles(tu).GetFileSpecAtIndex(file_idx);
1040 }
1041 
1042 const FileSpecList &
1044  static FileSpecList empty_list;
1045 
1046  dw_offset_t offset = tu.GetLineTableOffset();
1047  if (offset == DW_INVALID_OFFSET ||
1048  offset == llvm::DenseMapInfo<dw_offset_t>::getEmptyKey() ||
1049  offset == llvm::DenseMapInfo<dw_offset_t>::getTombstoneKey())
1050  return empty_list;
1051 
1052  // Many type units can share a line table, so parse the support file list
1053  // once, and cache it based on the offset field.
1054  auto iter_bool = m_type_unit_support_files.try_emplace(offset);
1055  FileSpecList &list = iter_bool.first->second;
1056  if (iter_bool.second) {
1057  uint64_t line_table_offset = offset;
1058  llvm::DWARFDataExtractor data = m_context.getOrLoadLineData().GetAsLLVM();
1059  llvm::DWARFContext &ctx = m_context.GetAsLLVM();
1060  llvm::DWARFDebugLine::Prologue prologue;
1061  auto report = [](llvm::Error error) {
1062  Log *log = GetLog(DWARFLog::DebugInfo);
1063  LLDB_LOG_ERROR(log, std::move(error),
1064  "SymbolFileDWARF::GetTypeUnitSupportFiles failed to parse "
1065  "the line table prologue");
1066  };
1068  llvm::Error error = prologue.parse(data, &line_table_offset, report, ctx);
1069  if (error) {
1070  report(std::move(error));
1071  } else {
1073  prologue, tu.GetPathStyle());
1074  }
1075  }
1076  return list;
1077 }
1078 
1080  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1081  DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
1082  if (dwarf_cu)
1083  return dwarf_cu->GetNonSkeletonUnit().GetIsOptimized();
1084  return false;
1085 }
1086 
1088  const lldb_private::SymbolContext &sc,
1089  std::vector<SourceModule> &imported_modules) {
1090  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1091  assert(sc.comp_unit);
1092  DWARFUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit);
1093  if (!dwarf_cu)
1094  return false;
1095  if (!ClangModulesDeclVendor::LanguageSupportsClangModules(
1096  sc.comp_unit->GetLanguage()))
1097  return false;
1099 
1100  const DWARFDIE die = dwarf_cu->DIE();
1101  if (!die)
1102  return false;
1103 
1104  for (DWARFDIE child_die : die.children()) {
1105  if (child_die.Tag() != DW_TAG_imported_declaration)
1106  continue;
1107 
1108  DWARFDIE module_die = child_die.GetReferencedDIE(DW_AT_import);
1109  if (module_die.Tag() != DW_TAG_module)
1110  continue;
1111 
1112  if (const char *name =
1113  module_die.GetAttributeValueAsString(DW_AT_name, nullptr)) {
1114  SourceModule module;
1115  module.path.push_back(ConstString(name));
1116 
1117  DWARFDIE parent_die = module_die;
1118  while ((parent_die = parent_die.GetParent())) {
1119  if (parent_die.Tag() != DW_TAG_module)
1120  break;
1121  if (const char *name =
1122  parent_die.GetAttributeValueAsString(DW_AT_name, nullptr))
1123  module.path.push_back(ConstString(name));
1124  }
1125  std::reverse(module.path.begin(), module.path.end());
1126  if (const char *include_path = module_die.GetAttributeValueAsString(
1127  DW_AT_LLVM_include_path, nullptr)) {
1128  FileSpec include_spec(include_path, dwarf_cu->GetPathStyle());
1129  MakeAbsoluteAndRemap(include_spec, *dwarf_cu,
1130  m_objfile_sp->GetModule());
1131  module.search_path = ConstString(include_spec.GetPath());
1132  }
1133  if (const char *sysroot = dwarf_cu->DIE().GetAttributeValueAsString(
1134  DW_AT_LLVM_sysroot, nullptr))
1135  module.sysroot = ConstString(sysroot);
1136  imported_modules.push_back(module);
1137  }
1138  }
1139  return true;
1140 }
1141 
1143  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1144  if (comp_unit.GetLineTable() != nullptr)
1145  return true;
1146 
1147  DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
1148  if (!dwarf_cu)
1149  return false;
1150 
1151  dw_offset_t offset = dwarf_cu->GetLineTableOffset();
1152  if (offset == DW_INVALID_OFFSET)
1153  return false;
1154 
1156  llvm::DWARFDebugLine line;
1157  const llvm::DWARFDebugLine::LineTable *line_table =
1158  ParseLLVMLineTable(m_context, line, offset, dwarf_cu->GetOffset());
1159 
1160  if (!line_table)
1161  return false;
1162 
1163  // FIXME: Rather than parsing the whole line table and then copying it over
1164  // into LLDB, we should explore using a callback to populate the line table
1165  // while we parse to reduce memory usage.
1166  std::vector<std::unique_ptr<LineSequence>> sequences;
1167  // The Sequences view contains only valid line sequences. Don't iterate over
1168  // the Rows directly.
1169  for (const llvm::DWARFDebugLine::Sequence &seq : line_table->Sequences) {
1170  // Ignore line sequences that do not start after the first code address.
1171  // All addresses generated in a sequence are incremental so we only need
1172  // to check the first one of the sequence. Check the comment at the
1173  // m_first_code_address declaration for more details on this.
1174  if (seq.LowPC < m_first_code_address)
1175  continue;
1176  std::unique_ptr<LineSequence> sequence =
1177  LineTable::CreateLineSequenceContainer();
1178  for (unsigned idx = seq.FirstRowIndex; idx < seq.LastRowIndex; ++idx) {
1179  const llvm::DWARFDebugLine::Row &row = line_table->Rows[idx];
1180  LineTable::AppendLineEntryToSequence(
1181  sequence.get(), row.Address.Address, row.Line, row.Column, row.File,
1182  row.IsStmt, row.BasicBlock, row.PrologueEnd, row.EpilogueBegin,
1183  row.EndSequence);
1184  }
1185  sequences.push_back(std::move(sequence));
1186  }
1187 
1188  std::unique_ptr<LineTable> line_table_up =
1189  std::make_unique<LineTable>(&comp_unit, std::move(sequences));
1190 
1191  if (SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile()) {
1192  // We have an object file that has a line table with addresses that are not
1193  // linked. We need to link the line table and convert the addresses that
1194  // are relative to the .o file into addresses for the main executable.
1195  comp_unit.SetLineTable(
1196  debug_map_symfile->LinkOSOLineTable(this, line_table_up.get()));
1197  } else {
1198  comp_unit.SetLineTable(line_table_up.release());
1199  }
1200 
1201  return true;
1202 }
1203 
1206  auto iter = m_debug_macros_map.find(*offset);
1207  if (iter != m_debug_macros_map.end())
1208  return iter->second;
1209 
1211  const DWARFDataExtractor &debug_macro_data = m_context.getOrLoadMacroData();
1212  if (debug_macro_data.GetByteSize() == 0)
1213  return DebugMacrosSP();
1214 
1216  m_debug_macros_map[*offset] = debug_macros_sp;
1217 
1218  const DWARFDebugMacroHeader &header =
1219  DWARFDebugMacroHeader::ParseHeader(debug_macro_data, offset);
1221  debug_macro_data, m_context.getOrLoadStrData(), header.OffsetIs64Bit(),
1222  offset, this, debug_macros_sp);
1223 
1224  return debug_macros_sp;
1225 }
1226 
1228  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1229 
1230  DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
1231  if (dwarf_cu == nullptr)
1232  return false;
1233 
1234  const DWARFBaseDIE dwarf_cu_die = dwarf_cu->GetUnitDIEOnly();
1235  if (!dwarf_cu_die)
1236  return false;
1237 
1238  lldb::offset_t sect_offset =
1239  dwarf_cu_die.GetAttributeValueAsUnsigned(DW_AT_macros, DW_INVALID_OFFSET);
1240  if (sect_offset == DW_INVALID_OFFSET)
1241  sect_offset = dwarf_cu_die.GetAttributeValueAsUnsigned(DW_AT_GNU_macros,
1243  if (sect_offset == DW_INVALID_OFFSET)
1244  return false;
1245 
1246  comp_unit.SetDebugMacros(ParseDebugMacros(&sect_offset));
1247 
1248  return true;
1249 }
1250 
1252  lldb_private::CompileUnit &comp_unit, Block *parent_block,
1253  const DWARFDIE &orig_die, addr_t subprogram_low_pc, uint32_t depth) {
1254  size_t blocks_added = 0;
1255  DWARFDIE die = orig_die;
1256  while (die) {
1257  dw_tag_t tag = die.Tag();
1258 
1259  switch (tag) {
1260  case DW_TAG_inlined_subroutine:
1261  case DW_TAG_subprogram:
1262  case DW_TAG_lexical_block: {
1263  Block *block = nullptr;
1264  if (tag == DW_TAG_subprogram) {
1265  // Skip any DW_TAG_subprogram DIEs that are inside of a normal or
1266  // inlined functions. These will be parsed on their own as separate
1267  // entities.
1268 
1269  if (depth > 0)
1270  break;
1271 
1272  block = parent_block;
1273  } else {
1274  BlockSP block_sp(new Block(die.GetID()));
1275  parent_block->AddChild(block_sp);
1276  block = block_sp.get();
1277  }
1278  DWARFRangeList ranges;
1279  const char *name = nullptr;
1280  const char *mangled_name = nullptr;
1281 
1282  int decl_file = 0;
1283  int decl_line = 0;
1284  int decl_column = 0;
1285  int call_file = 0;
1286  int call_line = 0;
1287  int call_column = 0;
1288  if (die.GetDIENamesAndRanges(name, mangled_name, ranges, decl_file,
1289  decl_line, decl_column, call_file, call_line,
1290  call_column, nullptr)) {
1291  if (tag == DW_TAG_subprogram) {
1292  assert(subprogram_low_pc == LLDB_INVALID_ADDRESS);
1293  subprogram_low_pc = ranges.GetMinRangeBase(0);
1294  } else if (tag == DW_TAG_inlined_subroutine) {
1295  // We get called here for inlined subroutines in two ways. The first
1296  // time is when we are making the Function object for this inlined
1297  // concrete instance. Since we're creating a top level block at
1298  // here, the subprogram_low_pc will be LLDB_INVALID_ADDRESS. So we
1299  // need to adjust the containing address. The second time is when we
1300  // are parsing the blocks inside the function that contains the
1301  // inlined concrete instance. Since these will be blocks inside the
1302  // containing "real" function the offset will be for that function.
1303  if (subprogram_low_pc == LLDB_INVALID_ADDRESS) {
1304  subprogram_low_pc = ranges.GetMinRangeBase(0);
1305  }
1306  }
1307 
1308  const size_t num_ranges = ranges.GetSize();
1309  for (size_t i = 0; i < num_ranges; ++i) {
1310  const DWARFRangeList::Entry &range = ranges.GetEntryRef(i);
1311  const addr_t range_base = range.GetRangeBase();
1312  if (range_base >= subprogram_low_pc)
1313  block->AddRange(Block::Range(range_base - subprogram_low_pc,
1314  range.GetByteSize()));
1315  else {
1316  GetObjectFile()->GetModule()->ReportError(
1317  "0x%8.8" PRIx64 ": adding range [0x%" PRIx64 "-0x%" PRIx64
1318  ") which has a base that is less than the function's low PC "
1319  "0x%" PRIx64 ". Please file a bug and attach the file at the "
1320  "start of this error message",
1321  block->GetID(), range_base, range.GetRangeEnd(),
1322  subprogram_low_pc);
1323  }
1324  }
1325  block->FinalizeRanges();
1326 
1327  if (tag != DW_TAG_subprogram &&
1328  (name != nullptr || mangled_name != nullptr)) {
1329  std::unique_ptr<Declaration> decl_up;
1330  if (decl_file != 0 || decl_line != 0 || decl_column != 0)
1331  decl_up = std::make_unique<Declaration>(
1332  comp_unit.GetSupportFiles().GetFileSpecAtIndex(decl_file),
1333  decl_line, decl_column);
1334 
1335  std::unique_ptr<Declaration> call_up;
1336  if (call_file != 0 || call_line != 0 || call_column != 0)
1337  call_up = std::make_unique<Declaration>(
1338  comp_unit.GetSupportFiles().GetFileSpecAtIndex(call_file),
1339  call_line, call_column);
1340 
1341  block->SetInlinedFunctionInfo(name, mangled_name, decl_up.get(),
1342  call_up.get());
1343  }
1344 
1345  ++blocks_added;
1346 
1347  if (die.HasChildren()) {
1348  blocks_added +=
1349  ParseBlocksRecursive(comp_unit, block, die.GetFirstChild(),
1350  subprogram_low_pc, depth + 1);
1351  }
1352  }
1353  } break;
1354  default:
1355  break;
1356  }
1357 
1358  // Only parse siblings of the block if we are not at depth zero. A depth of
1359  // zero indicates we are currently parsing the top level DW_TAG_subprogram
1360  // DIE
1361 
1362  if (depth == 0)
1363  die.Clear();
1364  else
1365  die = die.GetSibling();
1366  }
1367  return blocks_added;
1368 }
1369 
1371  if (parent_die) {
1372  for (DWARFDIE die : parent_die.children()) {
1373  dw_tag_t tag = die.Tag();
1374  bool check_virtuality = false;
1375  switch (tag) {
1376  case DW_TAG_inheritance:
1377  case DW_TAG_subprogram:
1378  check_virtuality = true;
1379  break;
1380  default:
1381  break;
1382  }
1383  if (check_virtuality) {
1384  if (die.GetAttributeValueAsUnsigned(DW_AT_virtuality, 0) != 0)
1385  return true;
1386  }
1387  }
1388  }
1389  return false;
1390 }
1391 
1393  auto *type_system = decl_ctx.GetTypeSystem();
1394  if (type_system != nullptr)
1396  decl_ctx);
1397 }
1398 
1400  if (GetDebugMapSymfile())
1401  return GetID() | ref.die_offset();
1402 
1403  lldbassert(GetDwoNum().value_or(0) <= 0x3fffffff);
1404  return user_id_t(GetDwoNum().value_or(0)) << 32 | ref.die_offset() |
1405  lldb::user_id_t(GetDwoNum().has_value()) << 62 |
1406  lldb::user_id_t(ref.section() == DIERef::Section::DebugTypes) << 63;
1407 }
1408 
1409 llvm::Optional<SymbolFileDWARF::DecodedUID>
1411  // This method can be called without going through the symbol vendor so we
1412  // need to lock the module.
1413  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1414  // Anytime we get a "lldb::user_id_t" from an lldb_private::SymbolFile API we
1415  // must make sure we use the correct DWARF file when resolving things. On
1416  // MacOSX, when using SymbolFileDWARFDebugMap, we will use multiple
1417  // SymbolFileDWARF classes, one for each .o file. We can often end up with
1418  // references to other DWARF objects and we must be ready to receive a
1419  // "lldb::user_id_t" that specifies a DIE from another SymbolFileDWARF
1420  // instance.
1421  if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile()) {
1422  SymbolFileDWARF *dwarf = debug_map->GetSymbolFileByOSOIndex(
1423  debug_map->GetOSOIndexFromUserID(uid));
1424  return DecodedUID{
1425  *dwarf, {llvm::None, DIERef::Section::DebugInfo, dw_offset_t(uid)}};
1426  }
1427  dw_offset_t die_offset = uid;
1428  if (die_offset == DW_INVALID_OFFSET)
1429  return llvm::None;
1430 
1431  DIERef::Section section =
1432  uid >> 63 ? DIERef::Section::DebugTypes : DIERef::Section::DebugInfo;
1433 
1434  llvm::Optional<uint32_t> dwo_num;
1435  bool dwo_valid = uid >> 62 & 1;
1436  if (dwo_valid)
1437  dwo_num = uid >> 32 & 0x3fffffff;
1438 
1439  return DecodedUID{*this, {dwo_num, section, die_offset}};
1440 }
1441 
1442 DWARFDIE
1444  // This method can be called without going through the symbol vendor so we
1445  // need to lock the module.
1446  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1447 
1448  llvm::Optional<DecodedUID> decoded = DecodeUID(uid);
1449 
1450  if (decoded)
1451  return decoded->dwarf.GetDIE(decoded->ref);
1452 
1453  return DWARFDIE();
1454 }
1455 
1457  // This method can be called without going through the symbol vendor so we
1458  // need to lock the module.
1459  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1460  // Anytime we have a lldb::user_id_t, we must get the DIE by calling
1461  // SymbolFileDWARF::GetDIE(). See comments inside the
1462  // SymbolFileDWARF::GetDIE() for details.
1463  if (DWARFDIE die = GetDIE(type_uid))
1464  return GetDecl(die);
1465  return CompilerDecl();
1466 }
1467 
1470  // This method can be called without going through the symbol vendor so we
1471  // need to lock the module.
1472  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1473  // Anytime we have a lldb::user_id_t, we must get the DIE by calling
1474  // SymbolFileDWARF::GetDIE(). See comments inside the
1475  // SymbolFileDWARF::GetDIE() for details.
1476  if (DWARFDIE die = GetDIE(type_uid))
1477  return GetDeclContext(die);
1478  return CompilerDeclContext();
1479 }
1480 
1483  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1484  // Anytime we have a lldb::user_id_t, we must get the DIE by calling
1485  // SymbolFileDWARF::GetDIE(). See comments inside the
1486  // SymbolFileDWARF::GetDIE() for details.
1487  if (DWARFDIE die = GetDIE(type_uid))
1488  return GetContainingDeclContext(die);
1489  return CompilerDeclContext();
1490 }
1491 
1493  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1494  // Anytime we have a lldb::user_id_t, we must get the DIE by calling
1495  // SymbolFileDWARF::GetDIE(). See comments inside the
1496  // SymbolFileDWARF::GetDIE() for details.
1497  if (DWARFDIE type_die = GetDIE(type_uid))
1498  return type_die.ResolveType();
1499  else
1500  return nullptr;
1501 }
1502 
1503 llvm::Optional<SymbolFile::ArrayInfo>
1505  lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx) {
1506  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1507  if (DWARFDIE type_die = GetDIE(type_uid))
1508  return DWARFASTParser::ParseChildArrayInfo(type_die, exe_ctx);
1509  else
1510  return llvm::None;
1511 }
1512 
1514  return ResolveType(GetDIE(die_ref), true);
1515 }
1516 
1518  bool assert_not_being_parsed) {
1519  if (die) {
1520  Log *log = GetLog(DWARFLog::DebugInfo);
1521  if (log)
1522  GetObjectFile()->GetModule()->LogMessage(
1523  log, "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s'",
1524  die.GetOffset(), die.GetTagAsCString(), die.GetName());
1525 
1526  // We might be coming in in the middle of a type tree (a class within a
1527  // class, an enum within a class), so parse any needed parent DIEs before
1528  // we get to this one...
1529  DWARFDIE decl_ctx_die = GetDeclContextDIEContainingDIE(die);
1530  if (decl_ctx_die) {
1531  if (log) {
1532  switch (decl_ctx_die.Tag()) {
1533  case DW_TAG_structure_type:
1534  case DW_TAG_union_type:
1535  case DW_TAG_class_type: {
1536  // Get the type, which could be a forward declaration
1537  if (log)
1538  GetObjectFile()->GetModule()->LogMessage(
1539  log,
1540  "SymbolFileDWARF::ResolveTypeUID (die = 0x%8.8x) %s '%s' "
1541  "resolve parent forward type for 0x%8.8x",
1542  die.GetOffset(), die.GetTagAsCString(), die.GetName(),
1543  decl_ctx_die.GetOffset());
1544  } break;
1545 
1546  default:
1547  break;
1548  }
1549  }
1550  }
1551  return ResolveType(die);
1552  }
1553  return nullptr;
1554 }
1555 
1556 // This function is used when SymbolFileDWARFDebugMap owns a bunch of
1557 // SymbolFileDWARF objects to detect if this DWARF file is the one that can
1558 // resolve a compiler_type.
1560  const CompilerType &compiler_type) {
1561  CompilerType compiler_type_no_qualifiers =
1562  ClangUtil::RemoveFastQualifiers(compiler_type);
1563  if (GetForwardDeclClangTypeToDie().count(
1564  compiler_type_no_qualifiers.GetOpaqueQualType())) {
1565  return true;
1566  }
1567  auto type_system = compiler_type.GetTypeSystem();
1568  auto clang_type_system = type_system.dyn_cast_or_null<TypeSystemClang>();
1569  if (!clang_type_system)
1570  return false;
1571  DWARFASTParserClang *ast_parser =
1572  static_cast<DWARFASTParserClang *>(clang_type_system->GetDWARFParser());
1573  return ast_parser->GetClangASTImporter().CanImport(compiler_type);
1574 }
1575 
1577  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1578  auto clang_type_system =
1579  compiler_type.GetTypeSystem().dyn_cast_or_null<TypeSystemClang>();
1580  if (clang_type_system) {
1581  DWARFASTParserClang *ast_parser =
1582  static_cast<DWARFASTParserClang *>(clang_type_system->GetDWARFParser());
1583  if (ast_parser &&
1584  ast_parser->GetClangASTImporter().CanImport(compiler_type))
1585  return ast_parser->GetClangASTImporter().CompleteType(compiler_type);
1586  }
1587 
1588  // We have a struct/union/class/enum that needs to be fully resolved.
1589  CompilerType compiler_type_no_qualifiers =
1590  ClangUtil::RemoveFastQualifiers(compiler_type);
1591  auto die_it = GetForwardDeclClangTypeToDie().find(
1592  compiler_type_no_qualifiers.GetOpaqueQualType());
1593  if (die_it == GetForwardDeclClangTypeToDie().end()) {
1594  // We have already resolved this type...
1595  return true;
1596  }
1597 
1598  DWARFDIE dwarf_die = GetDIE(die_it->getSecond());
1599  if (dwarf_die) {
1600  // Once we start resolving this type, remove it from the forward
1601  // declaration map in case anyone child members or other types require this
1602  // type to get resolved. The type will get resolved when all of the calls
1603  // to SymbolFileDWARF::ResolveClangOpaqueTypeDefinition are done.
1604  GetForwardDeclClangTypeToDie().erase(die_it);
1605 
1606  Type *type = GetDIEToType().lookup(dwarf_die.GetDIE());
1607 
1608  Log *log = GetLog(DWARFLog::DebugInfo | DWARFLog::TypeCompletion);
1609  if (log)
1610  GetObjectFile()->GetModule()->LogMessageVerboseBacktrace(
1611  log, "0x%8.8" PRIx64 ": %s '%s' resolving forward declaration...",
1612  dwarf_die.GetID(), dwarf_die.GetTagAsCString(),
1613  type->GetName().AsCString());
1614  assert(compiler_type);
1615  if (DWARFASTParser *dwarf_ast = GetDWARFParser(*dwarf_die.GetCU()))
1616  return dwarf_ast->CompleteTypeFromDWARF(dwarf_die, type, compiler_type);
1617  }
1618  return false;
1619 }
1620 
1622  bool assert_not_being_parsed,
1623  bool resolve_function_context) {
1624  if (die) {
1625  Type *type = GetTypeForDIE(die, resolve_function_context).get();
1626 
1627  if (assert_not_being_parsed) {
1628  if (type != DIE_IS_BEING_PARSED)
1629  return type;
1630 
1631  GetObjectFile()->GetModule()->ReportError(
1632  "Parsing a die that is being parsed die: 0x%8.8x: %s %s",
1633  die.GetOffset(), die.GetTagAsCString(), die.GetName());
1634 
1635  } else
1636  return type;
1637  }
1638  return nullptr;
1639 }
1640 
1641 CompileUnit *
1643  if (dwarf_cu.IsDWOUnit()) {
1644  DWARFCompileUnit *non_dwo_cu =
1645  static_cast<DWARFCompileUnit *>(dwarf_cu.GetUserData());
1646  assert(non_dwo_cu);
1647  return non_dwo_cu->GetSymbolFileDWARF().GetCompUnitForDWARFCompUnit(
1648  *non_dwo_cu);
1649  }
1650  // Check if the symbol vendor already knows about this compile unit?
1651  if (dwarf_cu.GetUserData() == nullptr) {
1652  // The symbol vendor doesn't know about this compile unit, we need to parse
1653  // and add it to the symbol vendor object.
1654  return ParseCompileUnit(dwarf_cu).get();
1655  }
1656  return static_cast<CompileUnit *>(dwarf_cu.GetUserData());
1657 }
1658 
1660  ConstString class_name, llvm::function_ref<bool(DWARFDIE die)> callback) {
1661  m_index->GetObjCMethods(class_name, callback);
1662 }
1663 
1665  sc.Clear(false);
1666 
1667  if (die && llvm::isa<DWARFCompileUnit>(die.GetCU())) {
1668  // Check if the symbol vendor already knows about this compile unit?
1669  sc.comp_unit =
1670  GetCompUnitForDWARFCompUnit(llvm::cast<DWARFCompileUnit>(*die.GetCU()));
1671 
1672  sc.function = sc.comp_unit->FindFunctionByUID(die.GetID()).get();
1673  if (sc.function == nullptr)
1674  sc.function = ParseFunction(*sc.comp_unit, die);
1675 
1676  if (sc.function) {
1678  return true;
1679  }
1680  }
1681 
1682  return false;
1683 }
1684 
1687  const auto &pos = m_external_type_modules.find(name);
1688  if (pos != m_external_type_modules.end())
1689  return pos->second;
1690  else
1691  return lldb::ModuleSP();
1692 }
1693 
1694 DWARFDIE
1696  if (die_ref.dwo_num()) {
1697  SymbolFileDWARF *dwarf = *die_ref.dwo_num() == 0x3fffffff
1698  ? m_dwp_symfile.get()
1699  : this->DebugInfo()
1700  .GetUnitAtIndex(*die_ref.dwo_num())
1701  ->GetDwoSymbolFile();
1702  return dwarf->DebugInfo().GetDIE(die_ref);
1703  }
1704 
1705  return DebugInfo().GetDIE(die_ref);
1706 }
1707 
1708 /// Return the DW_AT_(GNU_)dwo_id.
1709 static llvm::Optional<uint64_t> GetDWOId(DWARFCompileUnit &dwarf_cu,
1710  const DWARFDebugInfoEntry &cu_die) {
1711  llvm::Optional<uint64_t> dwo_id =
1712  cu_die.GetAttributeValueAsOptionalUnsigned(&dwarf_cu, DW_AT_GNU_dwo_id);
1713  if (dwo_id)
1714  return dwo_id;
1715  return cu_die.GetAttributeValueAsOptionalUnsigned(&dwarf_cu, DW_AT_dwo_id);
1716 }
1717 
1718 llvm::Optional<uint64_t> SymbolFileDWARF::GetDWOId() {
1719  if (GetNumCompileUnits() == 1) {
1720  if (auto comp_unit = GetCompileUnitAtIndex(0))
1721  if (DWARFCompileUnit *cu = GetDWARFCompileUnit(comp_unit.get()))
1722  if (DWARFDebugInfoEntry *cu_die = cu->DIE().GetDIE())
1723  return ::GetDWOId(*cu, *cu_die);
1724  }
1725  return {};
1726 }
1727 
1728 std::shared_ptr<SymbolFileDWARFDwo>
1730  DWARFUnit &unit, const DWARFDebugInfoEntry &cu_die) {
1731  // If this is a Darwin-style debug map (non-.dSYM) symbol file,
1732  // never attempt to load ELF-style DWO files since the -gmodules
1733  // support uses the same DWO mechanism to specify full debug info
1734  // files for modules. This is handled in
1735  // UpdateExternalModuleListIfNeeded().
1736  if (GetDebugMapSymfile())
1737  return nullptr;
1738 
1739  DWARFCompileUnit *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(&unit);
1740  // Only compile units can be split into two parts and we should only
1741  // look for a DWO file if there is a valid DWO ID.
1742  if (!dwarf_cu || !dwarf_cu->GetDWOId().has_value())
1743  return nullptr;
1744 
1745  const char *dwo_name = GetDWOName(*dwarf_cu, cu_die);
1746  if (!dwo_name) {
1747  unit.SetDwoError(Status("missing DWO name in skeleton DIE 0x%8.8" PRIx32,
1748  cu_die.GetOffset()));
1749  return nullptr;
1750  }
1751 
1752  if (std::shared_ptr<SymbolFileDWARFDwo> dwp_sp = GetDwpSymbolFile())
1753  return dwp_sp;
1754 
1755  const char *comp_dir = nullptr;
1756  FileSpec dwo_file(dwo_name);
1757  FileSystem::Instance().Resolve(dwo_file);
1758  if (dwo_file.IsRelative()) {
1759  comp_dir = cu_die.GetAttributeValueAsString(dwarf_cu, DW_AT_comp_dir,
1760  nullptr);
1761  if (!comp_dir) {
1762  unit.SetDwoError(
1763  Status("unable to locate relative .dwo debug file \"%s\" for "
1764  "skeleton DIE 0x%8.8" PRIx32 " without valid DW_AT_comp_dir "
1765  "attribute", dwo_name, cu_die.GetOffset()));
1766  return nullptr;
1767  }
1768 
1769  dwo_file.SetFile(comp_dir, FileSpec::Style::native);
1770  if (dwo_file.IsRelative()) {
1771  // if DW_AT_comp_dir is relative, it should be relative to the location
1772  // of the executable, not to the location from which the debugger was
1773  // launched.
1774  dwo_file.PrependPathComponent(
1775  m_objfile_sp->GetFileSpec().GetDirectory().GetStringRef());
1776  }
1777  FileSystem::Instance().Resolve(dwo_file);
1778  dwo_file.AppendPathComponent(dwo_name);
1779  }
1780 
1781  if (!FileSystem::Instance().Exists(dwo_file)) {
1782  unit.SetDwoError(
1783  Status("unable to locate .dwo debug file \"%s\" for skeleton DIE "
1784  "0x%8.8" PRIx32, dwo_file.GetPath().c_str(),
1785  cu_die.GetOffset()));
1786 
1787  if (m_dwo_warning_issued.test_and_set(std::memory_order_relaxed) == false) {
1788  GetObjectFile()->GetModule()->ReportWarning(
1789  "unable to locate separate debug file (dwo, dwp). Debugging will be "
1790  "degraded.");
1791  }
1792  return nullptr;
1793  }
1794 
1795  const lldb::offset_t file_offset = 0;
1796  DataBufferSP dwo_file_data_sp;
1797  lldb::offset_t dwo_file_data_offset = 0;
1798  ObjectFileSP dwo_obj_file = ObjectFile::FindPlugin(
1799  GetObjectFile()->GetModule(), &dwo_file, file_offset,
1800  FileSystem::Instance().GetByteSize(dwo_file), dwo_file_data_sp,
1801  dwo_file_data_offset);
1802  if (dwo_obj_file == nullptr) {
1803  unit.SetDwoError(
1804  Status("unable to load object file for .dwo debug file \"%s\" for "
1805  "unit DIE 0x%8.8" PRIx32, dwo_name, cu_die.GetOffset()));
1806  return nullptr;
1807  }
1808 
1809  return std::make_shared<SymbolFileDWARFDwo>(*this, dwo_obj_file,
1810  dwarf_cu->GetID());
1811 }
1812 
1815  return;
1817  DWARFDebugInfo &debug_info = DebugInfo();
1818 
1819  // Follow DWO skeleton unit breadcrumbs.
1820  const uint32_t num_compile_units = GetNumCompileUnits();
1821  for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
1822  auto *dwarf_cu =
1823  llvm::dyn_cast<DWARFCompileUnit>(debug_info.GetUnitAtIndex(cu_idx));
1824  if (!dwarf_cu)
1825  continue;
1826 
1827  const DWARFBaseDIE die = dwarf_cu->GetUnitDIEOnly();
1828  if (!die || die.HasChildren() || !die.GetDIE())
1829  continue;
1830 
1831  const char *name = die.GetAttributeValueAsString(DW_AT_name, nullptr);
1832  if (!name)
1833  continue;
1834 
1835  ConstString const_name(name);
1836  ModuleSP &module_sp = m_external_type_modules[const_name];
1837  if (module_sp)
1838  continue;
1839 
1840  const char *dwo_path = GetDWOName(*dwarf_cu, *die.GetDIE());
1841  if (!dwo_path)
1842  continue;
1843 
1844  ModuleSpec dwo_module_spec;
1845  dwo_module_spec.GetFileSpec().SetFile(dwo_path, FileSpec::Style::native);
1846  if (dwo_module_spec.GetFileSpec().IsRelative()) {
1847  const char *comp_dir =
1848  die.GetAttributeValueAsString(DW_AT_comp_dir, nullptr);
1849  if (comp_dir) {
1850  dwo_module_spec.GetFileSpec().SetFile(comp_dir,
1851  FileSpec::Style::native);
1852  FileSystem::Instance().Resolve(dwo_module_spec.GetFileSpec());
1853  dwo_module_spec.GetFileSpec().AppendPathComponent(dwo_path);
1854  }
1855  }
1856  dwo_module_spec.GetArchitecture() =
1857  m_objfile_sp->GetModule()->GetArchitecture();
1858 
1859  // When LLDB loads "external" modules it looks at the presence of
1860  // DW_AT_dwo_name. However, when the already created module
1861  // (corresponding to .dwo itself) is being processed, it will see
1862  // the presence of DW_AT_dwo_name (which contains the name of dwo
1863  // file) and will try to call ModuleList::GetSharedModule
1864  // again. In some cases (i.e., for empty files) Clang 4.0
1865  // generates a *.dwo file which has DW_AT_dwo_name, but no
1866  // DW_AT_comp_dir. In this case the method
1867  // ModuleList::GetSharedModule will fail and the warning will be
1868  // printed. However, as one can notice in this case we don't
1869  // actually need to try to load the already loaded module
1870  // (corresponding to .dwo) so we simply skip it.
1871  if (m_objfile_sp->GetFileSpec().GetFileNameExtension() == ".dwo" &&
1872  llvm::StringRef(m_objfile_sp->GetFileSpec().GetPath())
1873  .endswith(dwo_module_spec.GetFileSpec().GetPath())) {
1874  continue;
1875  }
1876 
1877  Status error = ModuleList::GetSharedModule(dwo_module_spec, module_sp,
1878  nullptr, nullptr, nullptr);
1879  if (!module_sp) {
1880  GetObjectFile()->GetModule()->ReportWarning(
1881  "0x%8.8x: unable to locate module needed for external types: "
1882  "%s\nerror: %s\nDebugging will be degraded due to missing "
1883  "types. Rebuilding the project will regenerate the needed "
1884  "module files.",
1885  die.GetOffset(), dwo_module_spec.GetFileSpec().GetPath().c_str(),
1886  error.AsCString("unknown error"));
1887  continue;
1888  }
1889 
1890  // Verify the DWO hash.
1891  // FIXME: Technically "0" is a valid hash.
1892  llvm::Optional<uint64_t> dwo_id = ::GetDWOId(*dwarf_cu, *die.GetDIE());
1893  if (!dwo_id)
1894  continue;
1895 
1896  auto *dwo_symfile =
1897  llvm::dyn_cast_or_null<SymbolFileDWARF>(module_sp->GetSymbolFile());
1898  if (!dwo_symfile)
1899  continue;
1900  llvm::Optional<uint64_t> dwo_dwo_id = dwo_symfile->GetDWOId();
1901  if (!dwo_dwo_id)
1902  continue;
1903 
1904  if (dwo_id != dwo_dwo_id) {
1905  GetObjectFile()->GetModule()->ReportWarning(
1906  "0x%8.8x: Module %s is out-of-date (hash mismatch). Type information "
1907  "from this module may be incomplete or inconsistent with the rest of "
1908  "the program. Rebuilding the project will regenerate the needed "
1909  "module files.",
1910  die.GetOffset(), dwo_module_spec.GetFileSpec().GetPath().c_str());
1911  }
1912  }
1913 }
1914 
1916  if (!m_global_aranges_up) {
1917  m_global_aranges_up = std::make_unique<GlobalVariableMap>();
1918 
1919  ModuleSP module_sp = GetObjectFile()->GetModule();
1920  if (module_sp) {
1921  const size_t num_cus = module_sp->GetNumCompileUnits();
1922  for (size_t i = 0; i < num_cus; ++i) {
1923  CompUnitSP cu_sp = module_sp->GetCompileUnitAtIndex(i);
1924  if (cu_sp) {
1925  VariableListSP globals_sp = cu_sp->GetVariableList(true);
1926  if (globals_sp) {
1927  const size_t num_globals = globals_sp->GetSize();
1928  for (size_t g = 0; g < num_globals; ++g) {
1929  VariableSP var_sp = globals_sp->GetVariableAtIndex(g);
1930  if (var_sp && !var_sp->GetLocationIsConstantValueData()) {
1931  const DWARFExpressionList &location =
1932  var_sp->LocationExpressionList();
1933  Value location_result;
1934  Status error;
1935  ExecutionContext exe_ctx;
1936  if (location.Evaluate(&exe_ctx, nullptr, LLDB_INVALID_ADDRESS,
1937  nullptr, nullptr, location_result,
1938  &error)) {
1939  if (location_result.GetValueType() ==
1940  Value::ValueType::FileAddress) {
1941  lldb::addr_t file_addr =
1942  location_result.GetScalar().ULongLong();
1943  lldb::addr_t byte_size = 1;
1944  if (var_sp->GetType())
1945  byte_size =
1946  var_sp->GetType()->GetByteSize(nullptr).value_or(0);
1948  file_addr, byte_size, var_sp.get()));
1949  }
1950  }
1951  }
1952  }
1953  }
1954  }
1955  }
1956  }
1957  m_global_aranges_up->Sort();
1958  }
1959  return *m_global_aranges_up;
1960 }
1961 
1963  bool lookup_block,
1964  SymbolContext &sc) {
1965  assert(sc.comp_unit);
1966  DWARFCompileUnit &cu =
1968  DWARFDIE function_die = cu.LookupAddress(file_vm_addr);
1969  DWARFDIE block_die;
1970  if (function_die) {
1971  sc.function = sc.comp_unit->FindFunctionByUID(function_die.GetID()).get();
1972  if (sc.function == nullptr)
1973  sc.function = ParseFunction(*sc.comp_unit, function_die);
1974 
1975  if (sc.function && lookup_block)
1976  block_die = function_die.LookupDeepestBlock(file_vm_addr);
1977  }
1978 
1979  if (!sc.function || !lookup_block)
1980  return;
1981 
1982  Block &block = sc.function->GetBlock(true);
1983  if (block_die)
1984  sc.block = block.FindBlockByID(block_die.GetID());
1985  else
1986  sc.block = block.FindBlockByID(function_die.GetID());
1987 }
1988 
1990  SymbolContextItem resolve_scope,
1991  SymbolContext &sc) {
1992  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1993  LLDB_SCOPED_TIMERF("SymbolFileDWARF::"
1994  "ResolveSymbolContext (so_addr = { "
1995  "section = %p, offset = 0x%" PRIx64
1996  " }, resolve_scope = 0x%8.8x)",
1997  static_cast<void *>(so_addr.GetSection().get()),
1998  so_addr.GetOffset(), resolve_scope);
1999  uint32_t resolved = 0;
2000  if (resolve_scope &
2001  (eSymbolContextCompUnit | eSymbolContextFunction | eSymbolContextBlock |
2002  eSymbolContextLineEntry | eSymbolContextVariable)) {
2003  lldb::addr_t file_vm_addr = so_addr.GetFileAddress();
2004 
2005  DWARFDebugInfo &debug_info = DebugInfo();
2006  const DWARFDebugAranges &aranges = debug_info.GetCompileUnitAranges();
2007  const dw_offset_t cu_offset = aranges.FindAddress(file_vm_addr);
2008  if (cu_offset == DW_INVALID_OFFSET) {
2009  // Global variables are not in the compile unit address ranges. The only
2010  // way to currently find global variables is to iterate over the
2011  // .debug_pubnames or the __apple_names table and find all items in there
2012  // that point to DW_TAG_variable DIEs and then find the address that
2013  // matches.
2014  if (resolve_scope & eSymbolContextVariable) {
2016  const GlobalVariableMap::Entry *entry =
2017  map.FindEntryThatContains(file_vm_addr);
2018  if (entry && entry->data) {
2019  Variable *variable = entry->data;
2020  SymbolContextScope *scc = variable->GetSymbolContextScope();
2021  if (scc) {
2022  scc->CalculateSymbolContext(&sc);
2023  sc.variable = variable;
2024  }
2025  return sc.GetResolvedMask();
2026  }
2027  }
2028  } else {
2029  uint32_t cu_idx = DW_INVALID_INDEX;
2030  if (auto *dwarf_cu = llvm::dyn_cast_or_null<DWARFCompileUnit>(
2031  debug_info.GetUnitAtOffset(DIERef::Section::DebugInfo, cu_offset,
2032  &cu_idx))) {
2033  sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
2034  if (sc.comp_unit) {
2035  resolved |= eSymbolContextCompUnit;
2036 
2037  bool force_check_line_table = false;
2038  if (resolve_scope & (eSymbolContextFunction | eSymbolContextBlock)) {
2039  ResolveFunctionAndBlock(file_vm_addr,
2040  resolve_scope & eSymbolContextBlock, sc);
2041  if (sc.function)
2042  resolved |= eSymbolContextFunction;
2043  else {
2044  // We might have had a compile unit that had discontiguous address
2045  // ranges where the gaps are symbols that don't have any debug
2046  // info. Discontiguous compile unit address ranges should only
2047  // happen when there aren't other functions from other compile
2048  // units in these gaps. This helps keep the size of the aranges
2049  // down.
2050  force_check_line_table = true;
2051  }
2052  if (sc.block)
2053  resolved |= eSymbolContextBlock;
2054  }
2055 
2056  if ((resolve_scope & eSymbolContextLineEntry) ||
2057  force_check_line_table) {
2058  LineTable *line_table = sc.comp_unit->GetLineTable();
2059  if (line_table != nullptr) {
2060  // And address that makes it into this function should be in terms
2061  // of this debug file if there is no debug map, or it will be an
2062  // address in the .o file which needs to be fixed up to be in
2063  // terms of the debug map executable. Either way, calling
2064  // FixupAddress() will work for us.
2065  Address exe_so_addr(so_addr);
2066  if (FixupAddress(exe_so_addr)) {
2067  if (line_table->FindLineEntryByAddress(exe_so_addr,
2068  sc.line_entry)) {
2069  resolved |= eSymbolContextLineEntry;
2070  }
2071  }
2072  }
2073  }
2074 
2075  if (force_check_line_table && !(resolved & eSymbolContextLineEntry)) {
2076  // We might have had a compile unit that had discontiguous address
2077  // ranges where the gaps are symbols that don't have any debug info.
2078  // Discontiguous compile unit address ranges should only happen when
2079  // there aren't other functions from other compile units in these
2080  // gaps. This helps keep the size of the aranges down.
2081  sc.comp_unit = nullptr;
2082  resolved &= ~eSymbolContextCompUnit;
2083  }
2084  } else {
2085  GetObjectFile()->GetModule()->ReportWarning(
2086  "0x%8.8x: compile unit %u failed to create a valid "
2087  "lldb_private::CompileUnit class.",
2088  cu_offset, cu_idx);
2089  }
2090  }
2091  }
2092  }
2093  return resolved;
2094 }
2095 
2097  const SourceLocationSpec &src_location_spec,
2098  SymbolContextItem resolve_scope, SymbolContextList &sc_list) {
2099  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
2100  const bool check_inlines = src_location_spec.GetCheckInlines();
2101  const uint32_t prev_size = sc_list.GetSize();
2102  if (resolve_scope & eSymbolContextCompUnit) {
2103  for (uint32_t cu_idx = 0, num_cus = GetNumCompileUnits(); cu_idx < num_cus;
2104  ++cu_idx) {
2105  CompileUnit *dc_cu = ParseCompileUnitAtIndex(cu_idx).get();
2106  if (!dc_cu)
2107  continue;
2108 
2109  bool file_spec_matches_cu_file_spec = FileSpec::Match(
2110  src_location_spec.GetFileSpec(), dc_cu->GetPrimaryFile());
2111  if (check_inlines || file_spec_matches_cu_file_spec) {
2112  dc_cu->ResolveSymbolContext(src_location_spec, resolve_scope, sc_list);
2113  if (!check_inlines)
2114  break;
2115  }
2116  }
2117  }
2118  return sc_list.GetSize() - prev_size;
2119 }
2120 
2122  // Get the symbol table for the symbol file prior to taking the module lock
2123  // so that it is available without needing to take the module lock. The DWARF
2124  // indexing might end up needing to relocate items when DWARF sections are
2125  // loaded as they might end up getting the section contents which can call
2126  // ObjectFileELF::RelocateSection() which in turn will ask for the symbol
2127  // table and can cause deadlocks.
2128  GetSymtab();
2129  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
2130  m_index->Preload();
2131 }
2132 
2133 std::recursive_mutex &SymbolFileDWARF::GetModuleMutex() const {
2134  lldb::ModuleSP module_sp(m_debug_map_module_wp.lock());
2135  if (module_sp)
2136  return module_sp->GetMutex();
2137  return GetObjectFile()->GetModule()->GetMutex();
2138 }
2139 
2141  const lldb_private::CompilerDeclContext &decl_ctx) {
2142  if (!decl_ctx.IsValid()) {
2143  // Invalid namespace decl which means we aren't matching only things in
2144  // this symbol file, so return true to indicate it matches this symbol
2145  // file.
2146  return true;
2147  }
2148 
2149  TypeSystem *decl_ctx_type_system = decl_ctx.GetTypeSystem();
2150  auto type_system_or_err = GetTypeSystemForLanguage(
2151  decl_ctx_type_system->GetMinimumLanguage(nullptr));
2152  if (auto err = type_system_or_err.takeError()) {
2153  LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
2154  "Unable to match namespace decl using TypeSystem");
2155  return false;
2156  }
2157 
2158  if (decl_ctx_type_system == type_system_or_err->get())
2159  return true; // The type systems match, return true
2160 
2161  // The namespace AST was valid, and it does not match...
2162  Log *log = GetLog(DWARFLog::Lookups);
2163 
2164  if (log)
2165  GetObjectFile()->GetModule()->LogMessage(
2166  log, "Valid namespace does not match symbol file");
2167 
2168  return false;
2169 }
2170 
2172  ConstString name, const CompilerDeclContext &parent_decl_ctx,
2173  uint32_t max_matches, VariableList &variables) {
2174  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
2175  Log *log = GetLog(DWARFLog::Lookups);
2176 
2177  if (log)
2178  GetObjectFile()->GetModule()->LogMessage(
2179  log,
2180  "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", "
2181  "parent_decl_ctx=%p, max_matches=%u, variables)",
2182  name.GetCString(), static_cast<const void *>(&parent_decl_ctx),
2183  max_matches);
2184 
2185  if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
2186  return;
2187 
2188  // Remember how many variables are in the list before we search.
2189  const uint32_t original_size = variables.GetSize();
2190 
2191  llvm::StringRef basename;
2192  llvm::StringRef context;
2193  bool name_is_mangled = Mangled::GetManglingScheme(name.GetStringRef()) !=
2194  Mangled::eManglingSchemeNone;
2195 
2196  if (!CPlusPlusLanguage::ExtractContextAndIdentifier(name.GetCString(),
2197  context, basename))
2198  basename = name.GetStringRef();
2199 
2200  // Loop invariant: Variables up to this index have been checked for context
2201  // matches.
2202  uint32_t pruned_idx = original_size;
2203 
2204  SymbolContext sc;
2205  m_index->GetGlobalVariables(ConstString(basename), [&](DWARFDIE die) {
2206  if (!sc.module_sp)
2207  sc.module_sp = m_objfile_sp->GetModule();
2208  assert(sc.module_sp);
2209 
2210  if (die.Tag() != DW_TAG_variable)
2211  return true;
2212 
2213  auto *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(die.GetCU());
2214  if (!dwarf_cu)
2215  return true;
2216  sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
2217 
2218  if (parent_decl_ctx) {
2219  if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU())) {
2220  CompilerDeclContext actual_parent_decl_ctx =
2221  dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
2222  if (!actual_parent_decl_ctx ||
2223  actual_parent_decl_ctx != parent_decl_ctx)
2224  return true;
2225  }
2226  }
2227 
2228  ParseAndAppendGlobalVariable(sc, die, variables);
2229  while (pruned_idx < variables.GetSize()) {
2230  VariableSP var_sp = variables.GetVariableAtIndex(pruned_idx);
2231  if (name_is_mangled ||
2232  var_sp->GetName().GetStringRef().contains(name.GetStringRef()))
2233  ++pruned_idx;
2234  else
2235  variables.RemoveVariableAtIndex(pruned_idx);
2236  }
2237 
2238  return variables.GetSize() - original_size < max_matches;
2239  });
2240 
2241  // Return the number of variable that were appended to the list
2242  const uint32_t num_matches = variables.GetSize() - original_size;
2243  if (log && num_matches > 0) {
2244  GetObjectFile()->GetModule()->LogMessage(
2245  log,
2246  "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", "
2247  "parent_decl_ctx=%p, max_matches=%u, variables) => %u",
2248  name.GetCString(), static_cast<const void *>(&parent_decl_ctx),
2249  max_matches, num_matches);
2250  }
2251 }
2252 
2254  uint32_t max_matches,
2255  VariableList &variables) {
2256  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
2257  Log *log = GetLog(DWARFLog::Lookups);
2258 
2259  if (log) {
2260  GetObjectFile()->GetModule()->LogMessage(
2261  log,
2262  "SymbolFileDWARF::FindGlobalVariables (regex=\"%s\", "
2263  "max_matches=%u, variables)",
2264  regex.GetText().str().c_str(), max_matches);
2265  }
2266 
2267  // Remember how many variables are in the list before we search.
2268  const uint32_t original_size = variables.GetSize();
2269 
2270  SymbolContext sc;
2271  m_index->GetGlobalVariables(regex, [&](DWARFDIE die) {
2272  if (!sc.module_sp)
2273  sc.module_sp = m_objfile_sp->GetModule();
2274  assert(sc.module_sp);
2275 
2276  DWARFCompileUnit *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(die.GetCU());
2277  if (!dwarf_cu)
2278  return true;
2279  sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
2280 
2281  ParseAndAppendGlobalVariable(sc, die, variables);
2282 
2283  return variables.GetSize() - original_size < max_matches;
2284  });
2285 }
2286 
2288  bool include_inlines,
2289  SymbolContextList &sc_list) {
2290  SymbolContext sc;
2291 
2292  if (!orig_die)
2293  return false;
2294 
2295  // If we were passed a die that is not a function, just return false...
2296  if (!(orig_die.Tag() == DW_TAG_subprogram ||
2297  (include_inlines && orig_die.Tag() == DW_TAG_inlined_subroutine)))
2298  return false;
2299 
2300  DWARFDIE die = orig_die;
2301  DWARFDIE inlined_die;
2302  if (die.Tag() == DW_TAG_inlined_subroutine) {
2303  inlined_die = die;
2304 
2305  while (true) {
2306  die = die.GetParent();
2307 
2308  if (die) {
2309  if (die.Tag() == DW_TAG_subprogram)
2310  break;
2311  } else
2312  break;
2313  }
2314  }
2315  assert(die && die.Tag() == DW_TAG_subprogram);
2316  if (GetFunction(die, sc)) {
2317  Address addr;
2318  // Parse all blocks if needed
2319  if (inlined_die) {
2320  Block &function_block = sc.function->GetBlock(true);
2321  sc.block = function_block.FindBlockByID(inlined_die.GetID());
2322  if (sc.block == nullptr)
2323  sc.block = function_block.FindBlockByID(inlined_die.GetOffset());
2324  if (sc.block == nullptr || !sc.block->GetStartAddress(addr))
2325  addr.Clear();
2326  } else {
2327  sc.block = nullptr;
2328  addr = sc.function->GetAddressRange().GetBaseAddress();
2329  }
2330 
2331  sc_list.Append(sc);
2332  return true;
2333  }
2334 
2335  return false;
2336 }
2337 
2339  const DWARFDIE &die) {
2340  // If we have no parent decl context to match this DIE matches, and if the
2341  // parent decl context isn't valid, we aren't trying to look for any
2342  // particular decl context so any die matches.
2343  if (!decl_ctx.IsValid())
2344  return true;
2345 
2346  if (die) {
2347  if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU())) {
2348  if (CompilerDeclContext actual_decl_ctx =
2349  dwarf_ast->GetDeclContextContainingUIDFromDWARF(die))
2350  return decl_ctx.IsContainedInLookup(actual_decl_ctx);
2351  }
2352  }
2353  return false;
2354 }
2355 
2357  const CompilerDeclContext &parent_decl_ctx,
2358  bool include_inlines,
2359  SymbolContextList &sc_list) {
2360  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
2361  ConstString name = lookup_info.GetLookupName();
2362  FunctionNameType name_type_mask = lookup_info.GetNameTypeMask();
2363 
2364  // eFunctionNameTypeAuto should be pre-resolved by a call to
2365  // Module::LookupInfo::LookupInfo()
2366  assert((name_type_mask & eFunctionNameTypeAuto) == 0);
2367 
2368  Log *log = GetLog(DWARFLog::Lookups);
2369 
2370  if (log) {
2371  GetObjectFile()->GetModule()->LogMessage(
2372  log,
2373  "SymbolFileDWARF::FindFunctions (name=\"%s\", name_type_mask=0x%x, "
2374  "sc_list)",
2375  name.GetCString(), name_type_mask);
2376  }
2377 
2378  if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
2379  return;
2380 
2381  // If name is empty then we won't find anything.
2382  if (name.IsEmpty())
2383  return;
2384 
2385  // Remember how many sc_list are in the list before we search in case we are
2386  // appending the results to a variable list.
2387 
2388  const uint32_t original_size = sc_list.GetSize();
2389 
2390  llvm::DenseSet<const DWARFDebugInfoEntry *> resolved_dies;
2391 
2392  m_index->GetFunctions(lookup_info, *this, parent_decl_ctx, [&](DWARFDIE die) {
2393  if (resolved_dies.insert(die.GetDIE()).second)
2394  ResolveFunction(die, include_inlines, sc_list);
2395  return true;
2396  });
2397  // With -gsimple-template-names, a templated type's DW_AT_name will not
2398  // contain the template parameters. Try again stripping '<' and anything
2399  // after, filtering out entries with template parameters that don't match.
2400  {
2401  const llvm::StringRef name_ref = name.GetStringRef();
2402  auto it = name_ref.find('<');
2403  if (it != llvm::StringRef::npos) {
2404  const llvm::StringRef name_no_template_params = name_ref.slice(0, it);
2405 
2406  Module::LookupInfo no_tp_lookup_info(lookup_info);
2407  no_tp_lookup_info.SetLookupName(ConstString(name_no_template_params));
2408  m_index->GetFunctions(no_tp_lookup_info, *this, parent_decl_ctx, [&](DWARFDIE die) {
2409  if (resolved_dies.insert(die.GetDIE()).second)
2410  ResolveFunction(die, include_inlines, sc_list);
2411  return true;
2412  });
2413  }
2414  }
2415 
2416  // Return the number of variable that were appended to the list
2417  const uint32_t num_matches = sc_list.GetSize() - original_size;
2418 
2419  if (log && num_matches > 0) {
2420  GetObjectFile()->GetModule()->LogMessage(
2421  log,
2422  "SymbolFileDWARF::FindFunctions (name=\"%s\", "
2423  "name_type_mask=0x%x, include_inlines=%d, sc_list) => %u",
2424  name.GetCString(), name_type_mask, include_inlines, num_matches);
2425  }
2426 }
2427 
2429  bool include_inlines,
2430  SymbolContextList &sc_list) {
2431  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
2432  LLDB_SCOPED_TIMERF("SymbolFileDWARF::FindFunctions (regex = '%s')",
2433  regex.GetText().str().c_str());
2434 
2435  Log *log = GetLog(DWARFLog::Lookups);
2436 
2437  if (log) {
2438  GetObjectFile()->GetModule()->LogMessage(
2439  log, "SymbolFileDWARF::FindFunctions (regex=\"%s\", sc_list)",
2440  regex.GetText().str().c_str());
2441  }
2442 
2443  llvm::DenseSet<const DWARFDebugInfoEntry *> resolved_dies;
2444  m_index->GetFunctions(regex, [&](DWARFDIE die) {
2445  if (resolved_dies.insert(die.GetDIE()).second)
2446  ResolveFunction(die, include_inlines, sc_list);
2447  return true;
2448  });
2449 }
2450 
2452  const std::string &scope_qualified_name,
2453  std::vector<ConstString> &mangled_names) {
2454  DWARFDebugInfo &info = DebugInfo();
2455  uint32_t num_comp_units = info.GetNumUnits();
2456  for (uint32_t i = 0; i < num_comp_units; i++) {
2457  DWARFUnit *cu = info.GetUnitAtIndex(i);
2458  if (cu == nullptr)
2459  continue;
2460 
2461  SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile();
2462  if (dwo)
2463  dwo->GetMangledNamesForFunction(scope_qualified_name, mangled_names);
2464  }
2465 
2466  for (DIERef die_ref :
2467  m_function_scope_qualified_name_map.lookup(scope_qualified_name)) {
2468  DWARFDIE die = GetDIE(die_ref);
2469  mangled_names.push_back(ConstString(die.GetMangledName()));
2470  }
2471 }
2472 
2474  ConstString name, const CompilerDeclContext &parent_decl_ctx,
2475  uint32_t max_matches,
2476  llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
2477  TypeMap &types) {
2478  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
2479  // Make sure we haven't already searched this SymbolFile before.
2480  if (!searched_symbol_files.insert(this).second)
2481  return;
2482 
2483  Log *log = GetLog(DWARFLog::Lookups);
2484 
2485  if (log) {
2486  if (parent_decl_ctx)
2487  GetObjectFile()->GetModule()->LogMessage(
2488  log,
2489  "SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx = "
2490  "%p (\"%s\"), max_matches=%u, type_list)",
2491  name.GetCString(), static_cast<const void *>(&parent_decl_ctx),
2492  parent_decl_ctx.GetName().AsCString("<NULL>"), max_matches);
2493  else
2494  GetObjectFile()->GetModule()->LogMessage(
2495  log,
2496  "SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx = "
2497  "NULL, max_matches=%u, type_list)",
2498  name.GetCString(), max_matches);
2499  }
2500 
2501  if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
2502  return;
2503 
2504  m_index->GetTypes(name, [&](DWARFDIE die) {
2505  if (!DIEInDeclContext(parent_decl_ctx, die))
2506  return true; // The containing decl contexts don't match
2507 
2508  Type *matching_type = ResolveType(die, true, true);
2509  if (!matching_type)
2510  return true;
2511 
2512  // We found a type pointer, now find the shared pointer form our type
2513  // list
2514  types.InsertUnique(matching_type->shared_from_this());
2515  return types.GetSize() < max_matches;
2516  });
2517 
2518  // With -gsimple-template-names, a templated type's DW_AT_name will not
2519  // contain the template parameters. Try again stripping '<' and anything
2520  // after, filtering out entries with template parameters that don't match.
2521  if (types.GetSize() < max_matches) {
2522  const llvm::StringRef name_ref = name.GetStringRef();
2523  auto it = name_ref.find('<');
2524  if (it != llvm::StringRef::npos) {
2525  const llvm::StringRef name_no_template_params = name_ref.slice(0, it);
2526  const llvm::StringRef template_params = name_ref.slice(it, name_ref.size());
2527  m_index->GetTypes(ConstString(name_no_template_params), [&](DWARFDIE die) {
2528  if (!DIEInDeclContext(parent_decl_ctx, die))
2529  return true; // The containing decl contexts don't match
2530 
2531  const llvm::StringRef base_name = GetTypeForDIE(die)->GetBaseName().AsCString();
2532  auto it = base_name.find('<');
2533  // If the candidate qualified name doesn't have '<', it doesn't have
2534  // template params to compare.
2535  if (it == llvm::StringRef::npos)
2536  return true;
2537 
2538  // Filter out non-matching instantiations by comparing template params.
2539  const llvm::StringRef base_name_template_params =
2540  base_name.slice(it, base_name.size());
2541 
2542  if (template_params != base_name_template_params)
2543  return true;
2544 
2545  Type *matching_type = ResolveType(die, true, true);
2546  if (!matching_type)
2547  return true;
2548 
2549  // We found a type pointer, now find the shared pointer form our type
2550  // list.
2551  types.InsertUnique(matching_type->shared_from_this());
2552  return types.GetSize() < max_matches;
2553  });
2554  }
2555  }
2556 
2557  // Next search through the reachable Clang modules. This only applies for
2558  // DWARF objects compiled with -gmodules that haven't been processed by
2559  // dsymutil.
2560  if (types.GetSize() < max_matches) {
2562 
2563  for (const auto &pair : m_external_type_modules)
2564  if (ModuleSP external_module_sp = pair.second)
2565  if (SymbolFile *sym_file = external_module_sp->GetSymbolFile())
2566  sym_file->FindTypes(name, parent_decl_ctx, max_matches,
2567  searched_symbol_files, types);
2568  }
2569 
2570  if (log && types.GetSize()) {
2571  if (parent_decl_ctx) {
2572  GetObjectFile()->GetModule()->LogMessage(
2573  log,
2574  "SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx "
2575  "= %p (\"%s\"), max_matches=%u, type_list) => %u",
2576  name.GetCString(), static_cast<const void *>(&parent_decl_ctx),
2577  parent_decl_ctx.GetName().AsCString("<NULL>"), max_matches,
2578  types.GetSize());
2579  } else {
2580  GetObjectFile()->GetModule()->LogMessage(
2581  log,
2582  "SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx "
2583  "= NULL, max_matches=%u, type_list) => %u",
2584  name.GetCString(), max_matches, types.GetSize());
2585  }
2586  }
2587 }
2588 
2590  llvm::ArrayRef<CompilerContext> pattern, LanguageSet languages,
2591  llvm::DenseSet<SymbolFile *> &searched_symbol_files, TypeMap &types) {
2592  // Make sure we haven't already searched this SymbolFile before.
2593  if (!searched_symbol_files.insert(this).second)
2594  return;
2595 
2596  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
2597  if (pattern.empty())
2598  return;
2599 
2600  ConstString name = pattern.back().name;
2601 
2602  if (!name)
2603  return;
2604 
2605  m_index->GetTypes(name, [&](DWARFDIE die) {
2606  if (!languages[GetLanguageFamily(*die.GetCU())])
2607  return true;
2608 
2609  llvm::SmallVector<CompilerContext, 4> die_context;
2610  die.GetDeclContext(die_context);
2611  if (!contextMatches(die_context, pattern))
2612  return true;
2613 
2614  if (Type *matching_type = ResolveType(die, true, true)) {
2615  // We found a type pointer, now find the shared pointer form our type
2616  // list.
2617  types.InsertUnique(matching_type->shared_from_this());
2618  }
2619  return true;
2620  });
2621 
2622  // Next search through the reachable Clang modules. This only applies for
2623  // DWARF objects compiled with -gmodules that haven't been processed by
2624  // dsymutil.
2626 
2627  for (const auto &pair : m_external_type_modules)
2628  if (ModuleSP external_module_sp = pair.second)
2629  external_module_sp->FindTypes(pattern, languages, searched_symbol_files,
2630  types);
2631 }
2632 
2635  const CompilerDeclContext &parent_decl_ctx) {
2636  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
2637  Log *log = GetLog(DWARFLog::Lookups);
2638 
2639  if (log) {
2640  GetObjectFile()->GetModule()->LogMessage(
2641  log, "SymbolFileDWARF::FindNamespace (sc, name=\"%s\")",
2642  name.GetCString());
2643  }
2644 
2645  CompilerDeclContext namespace_decl_ctx;
2646 
2647  if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
2648  return namespace_decl_ctx;
2649 
2650  m_index->GetNamespaces(name, [&](DWARFDIE die) {
2651  if (!DIEInDeclContext(parent_decl_ctx, die))
2652  return true; // The containing decl contexts don't match
2653 
2654  DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU());
2655  if (!dwarf_ast)
2656  return true;
2657 
2658  namespace_decl_ctx = dwarf_ast->GetDeclContextForUIDFromDWARF(die);
2659  return !namespace_decl_ctx.IsValid();
2660  });
2661 
2662  if (log && namespace_decl_ctx) {
2663  GetObjectFile()->GetModule()->LogMessage(
2664  log,
2665  "SymbolFileDWARF::FindNamespace (sc, name=\"%s\") => "
2666  "CompilerDeclContext(%p/%p) \"%s\"",
2667  name.GetCString(),
2668  static_cast<const void *>(namespace_decl_ctx.GetTypeSystem()),
2669  static_cast<const void *>(namespace_decl_ctx.GetOpaqueDeclContext()),
2670  namespace_decl_ctx.GetName().AsCString("<NULL>"));
2671  }
2672 
2673  return namespace_decl_ctx;
2674 }
2675 
2677  bool resolve_function_context) {
2678  TypeSP type_sp;
2679  if (die) {
2680  Type *type_ptr = GetDIEToType().lookup(die.GetDIE());
2681  if (type_ptr == nullptr) {
2682  SymbolContextScope *scope;
2683  if (auto *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(die.GetCU()))
2684  scope = GetCompUnitForDWARFCompUnit(*dwarf_cu);
2685  else
2686  scope = GetObjectFile()->GetModule().get();
2687  assert(scope);
2688  SymbolContext sc(scope);
2689  const DWARFDebugInfoEntry *parent_die = die.GetParent().GetDIE();
2690  while (parent_die != nullptr) {
2691  if (parent_die->Tag() == DW_TAG_subprogram)
2692  break;
2693  parent_die = parent_die->GetParent();
2694  }
2695  SymbolContext sc_backup = sc;
2696  if (resolve_function_context && parent_die != nullptr &&
2697  !GetFunction(DWARFDIE(die.GetCU(), parent_die), sc))
2698  sc = sc_backup;
2699 
2700  type_sp = ParseType(sc, die, nullptr);
2701  } else if (type_ptr != DIE_IS_BEING_PARSED) {
2702  // Get the original shared pointer for this type
2703  type_sp = type_ptr->shared_from_this();
2704  }
2705  }
2706  return type_sp;
2707 }
2708 
2709 DWARFDIE
2711  if (orig_die) {
2712  DWARFDIE die = orig_die;
2713 
2714  while (die) {
2715  // If this is the original DIE that we are searching for a declaration
2716  // for, then don't look in the cache as we don't want our own decl
2717  // context to be our decl context...
2718  if (orig_die != die) {
2719  switch (die.Tag()) {
2720  case DW_TAG_compile_unit:
2721  case DW_TAG_partial_unit:
2722  case DW_TAG_namespace:
2723  case DW_TAG_structure_type:
2724  case DW_TAG_union_type:
2725  case DW_TAG_class_type:
2726  case DW_TAG_lexical_block:
2727  case DW_TAG_subprogram:
2728  return die;
2729  case DW_TAG_inlined_subroutine: {
2730  DWARFDIE abs_die = die.GetReferencedDIE(DW_AT_abstract_origin);
2731  if (abs_die) {
2732  return abs_die;
2733  }
2734  break;
2735  }
2736  default:
2737  break;
2738  }
2739  }
2740 
2741  DWARFDIE spec_die = die.GetReferencedDIE(DW_AT_specification);
2742  if (spec_die) {
2743  DWARFDIE decl_ctx_die = GetDeclContextDIEContainingDIE(spec_die);
2744  if (decl_ctx_die)
2745  return decl_ctx_die;
2746  }
2747 
2748  DWARFDIE abs_die = die.GetReferencedDIE(DW_AT_abstract_origin);
2749  if (abs_die) {
2750  DWARFDIE decl_ctx_die = GetDeclContextDIEContainingDIE(abs_die);
2751  if (decl_ctx_die)
2752  return decl_ctx_die;
2753  }
2754 
2755  die = die.GetParent();
2756  }
2757  }
2758  return DWARFDIE();
2759 }
2760 
2762  Symbol *objc_class_symbol = nullptr;
2763  if (m_objfile_sp) {
2764  Symtab *symtab = m_objfile_sp->GetSymtab();
2765  if (symtab) {
2766  objc_class_symbol = symtab->FindFirstSymbolWithNameAndType(
2767  objc_class_name, eSymbolTypeObjCClass, Symtab::eDebugNo,
2768  Symtab::eVisibilityAny);
2769  }
2770  }
2771  return objc_class_symbol;
2772 }
2773 
2774 // Some compilers don't emit the DW_AT_APPLE_objc_complete_type attribute. If
2775 // they don't then we can end up looking through all class types for a complete
2776 // type and never find the full definition. We need to know if this attribute
2777 // is supported, so we determine this here and cache th result. We also need to
2778 // worry about the debug map
2779 // DWARF file
2780 // if we are doing darwin DWARF in .o file debugging.
2786  else {
2787  DWARFDebugInfo &debug_info = DebugInfo();
2788  const uint32_t num_compile_units = GetNumCompileUnits();
2789  for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
2790  DWARFUnit *dwarf_cu = debug_info.GetUnitAtIndex(cu_idx);
2791  if (dwarf_cu != cu &&
2794  break;
2795  }
2796  }
2797  }
2801  }
2803 }
2804 
2805 // This function can be used when a DIE is found that is a forward declaration
2806 // DIE and we want to try and find a type that has the complete definition.
2808  const DWARFDIE &die, ConstString type_name, bool must_be_implementation) {
2809 
2810  TypeSP type_sp;
2811 
2812  if (!type_name || (must_be_implementation && !GetObjCClassSymbol(type_name)))
2813  return type_sp;
2814 
2815  m_index->GetCompleteObjCClass(
2816  type_name, must_be_implementation, [&](DWARFDIE type_die) {
2817  bool try_resolving_type = false;
2818 
2819  // Don't try and resolve the DIE we are looking for with the DIE
2820  // itself!
2821  if (type_die != die) {
2822  switch (type_die.Tag()) {
2823  case DW_TAG_class_type:
2824  case DW_TAG_structure_type:
2825  try_resolving_type = true;
2826  break;
2827  default:
2828  break;
2829  }
2830  }
2831  if (!try_resolving_type)
2832  return true;
2833 
2834  if (must_be_implementation &&
2836  try_resolving_type = type_die.GetAttributeValueAsUnsigned(
2837  DW_AT_APPLE_objc_complete_type, 0);
2838  if (!try_resolving_type)
2839  return true;
2840 
2841  Type *resolved_type = ResolveType(type_die, false, true);
2842  if (!resolved_type || resolved_type == DIE_IS_BEING_PARSED)
2843  return true;
2844 
2845  DEBUG_PRINTF(
2846  "resolved 0x%8.8" PRIx64 " from %s to 0x%8.8" PRIx64
2847  " (cu 0x%8.8" PRIx64 ")\n",
2848  die.GetID(),
2849  m_objfile_sp->GetFileSpec().GetFilename().AsCString("<Unknown>"),
2850  type_die.GetID(), type_cu->GetID());
2851 
2852  if (die)
2853  GetDIEToType()[die.GetDIE()] = resolved_type;
2854  type_sp = resolved_type->shared_from_this();
2855  return false;
2856  });
2857  return type_sp;
2858 }
2859 
2860 // This function helps to ensure that the declaration contexts match for two
2861 // different DIEs. Often times debug information will refer to a forward
2862 // declaration of a type (the equivalent of "struct my_struct;". There will
2863 // often be a declaration of that type elsewhere that has the full definition.
2864 // When we go looking for the full type "my_struct", we will find one or more
2865 // matches in the accelerator tables and we will then need to make sure the
2866 // type was in the same declaration context as the original DIE. This function
2867 // can efficiently compare two DIEs and will return true when the declaration
2868 // context matches, and false when they don't.
2870  const DWARFDIE &die2) {
2871  if (die1 == die2)
2872  return true;
2873 
2874  std::vector<DWARFDIE> decl_ctx_1;
2875  std::vector<DWARFDIE> decl_ctx_2;
2876  // The declaration DIE stack is a stack of the declaration context DIEs all
2877  // the way back to the compile unit. If a type "T" is declared inside a class
2878  // "B", and class "B" is declared inside a class "A" and class "A" is in a
2879  // namespace "lldb", and the namespace is in a compile unit, there will be a
2880  // stack of DIEs:
2881  //
2882  // [0] DW_TAG_class_type for "B"
2883  // [1] DW_TAG_class_type for "A"
2884  // [2] DW_TAG_namespace for "lldb"
2885  // [3] DW_TAG_compile_unit or DW_TAG_partial_unit for the source file.
2886  //
2887  // We grab both contexts and make sure that everything matches all the way
2888  // back to the compiler unit.
2889 
2890  // First lets grab the decl contexts for both DIEs
2891  decl_ctx_1 = die1.GetDeclContextDIEs();
2892  decl_ctx_2 = die2.GetDeclContextDIEs();
2893  // Make sure the context arrays have the same size, otherwise we are done
2894  const size_t count1 = decl_ctx_1.size();
2895  const size_t count2 = decl_ctx_2.size();
2896  if (count1 != count2)
2897  return false;
2898 
2899  // Make sure the DW_TAG values match all the way back up the compile unit. If
2900  // they don't, then we are done.
2901  DWARFDIE decl_ctx_die1;
2902  DWARFDIE decl_ctx_die2;
2903  size_t i;
2904  for (i = 0; i < count1; i++) {
2905  decl_ctx_die1 = decl_ctx_1[i];
2906  decl_ctx_die2 = decl_ctx_2[i];
2907  if (decl_ctx_die1.Tag() != decl_ctx_die2.Tag())
2908  return false;
2909  }
2910 #ifndef NDEBUG
2911 
2912  // Make sure the top item in the decl context die array is always
2913  // DW_TAG_compile_unit or DW_TAG_partial_unit. If it isn't then
2914  // something went wrong in the DWARFDIE::GetDeclContextDIEs()
2915  // function.
2916  dw_tag_t cu_tag = decl_ctx_1[count1 - 1].Tag();
2917  UNUSED_IF_ASSERT_DISABLED(cu_tag);
2918  assert(cu_tag == DW_TAG_compile_unit || cu_tag == DW_TAG_partial_unit);
2919 
2920 #endif
2921  // Always skip the compile unit when comparing by only iterating up to "count
2922  // - 1". Here we compare the names as we go.
2923  for (i = 0; i < count1 - 1; i++) {
2924  decl_ctx_die1 = decl_ctx_1[i];
2925  decl_ctx_die2 = decl_ctx_2[i];
2926  const char *name1 = decl_ctx_die1.GetName();
2927  const char *name2 = decl_ctx_die2.GetName();
2928  // If the string was from a DW_FORM_strp, then the pointer will often be
2929  // the same!
2930  if (name1 == name2)
2931  continue;
2932 
2933  // Name pointers are not equal, so only compare the strings if both are not
2934  // NULL.
2935  if (name1 && name2) {
2936  // If the strings don't compare, we are done...
2937  if (strcmp(name1, name2) != 0)
2938  return false;
2939  } else {
2940  // One name was NULL while the other wasn't
2941  return false;
2942  }
2943  }
2944  // We made it through all of the checks and the declaration contexts are
2945  // equal.
2946  return true;
2947 }
2948 
2949 TypeSP
2951  TypeSP type_sp;
2952 
2953  if (die.GetName()) {
2954  const dw_tag_t tag = die.Tag();
2955 
2956  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
2957  if (log) {
2958  GetObjectFile()->GetModule()->LogMessage(
2959  log,
2960  "SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(tag=%"
2961  "s, name='%s')",
2962  DW_TAG_value_to_name(tag), die.GetName());
2963  }
2964 
2965  // Get the type system that we are looking to find a type for. We will
2966  // use this to ensure any matches we find are in a language that this
2967  // type system supports
2968  const LanguageType language = GetLanguage(*die.GetCU());
2969  TypeSystemSP type_system = nullptr;
2970  if (language != eLanguageTypeUnknown) {
2971  auto type_system_or_err = GetTypeSystemForLanguage(language);
2972  if (auto err = type_system_or_err.takeError()) {
2973  LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
2974  "Cannot get TypeSystem for language {}",
2975  Language::GetNameForLanguageType(language));
2976  } else {
2977  type_system = *type_system_or_err;
2978  }
2979  }
2980 
2981  m_index->GetTypes(GetDWARFDeclContext(die), [&](DWARFDIE type_die) {
2982  // Make sure type_die's language matches the type system we are
2983  // looking for. We don't want to find a "Foo" type from Java if we
2984  // are looking for a "Foo" type for C, C++, ObjC, or ObjC++.
2985  if (type_system &&
2986  !type_system->SupportsLanguage(GetLanguage(*type_die.GetCU())))
2987  return true;
2988  bool try_resolving_type = false;
2989 
2990  // Don't try and resolve the DIE we are looking for with the DIE
2991  // itself!
2992  const dw_tag_t type_tag = type_die.Tag();
2993  // Make sure the tags match
2994  if (type_tag == tag) {
2995  // The tags match, lets try resolving this type
2996  try_resolving_type = true;
2997  } else {
2998  // The tags don't match, but we need to watch our for a forward
2999  // declaration for a struct and ("struct foo") ends up being a
3000  // class ("class foo { ... };") or vice versa.
3001  switch (type_tag) {
3002  case DW_TAG_class_type:
3003  // We had a "class foo", see if we ended up with a "struct foo
3004  // { ... };"
3005  try_resolving_type = (tag == DW_TAG_structure_type);
3006  break;
3007  case DW_TAG_structure_type:
3008  // We had a "struct foo", see if we ended up with a "class foo
3009  // { ... };"
3010  try_resolving_type = (tag == DW_TAG_class_type);
3011  break;
3012  default:
3013  // Tags don't match, don't event try to resolve using this type
3014  // whose name matches....
3015  break;
3016  }
3017  }
3018 
3019  if (!try_resolving_type) {
3020  if (log) {
3021  GetObjectFile()->GetModule()->LogMessage(
3022  log,
3023  "SymbolFileDWARF::"
3024  "FindDefinitionTypeForDWARFDeclContext(tag=%s, "
3025  "name='%s') ignoring die=0x%8.8x (%s)",
3026  DW_TAG_value_to_name(tag), die.GetName(), type_die.GetOffset(),
3027  type_die.GetName());
3028  }
3029  return true;
3030  }
3031 
3032  DWARFDeclContext type_dwarf_decl_ctx = GetDWARFDeclContext(type_die);
3033 
3034  if (log) {
3035  GetObjectFile()->GetModule()->LogMessage(
3036  log,
3037  "SymbolFileDWARF::"
3038  "FindDefinitionTypeForDWARFDeclContext(tag=%s, "
3039  "name='%s') trying die=0x%8.8x (%s)",
3040  DW_TAG_value_to_name(tag), die.GetName(), type_die.GetOffset(),
3041  type_dwarf_decl_ctx.GetQualifiedName());
3042  }
3043 
3044  // Make sure the decl contexts match all the way up
3045  if (GetDWARFDeclContext(die) != type_dwarf_decl_ctx)
3046  return true;
3047 
3048  Type *resolved_type = ResolveType(type_die, false);
3049  if (!resolved_type || resolved_type == DIE_IS_BEING_PARSED)
3050  return true;
3051 
3052  type_sp = resolved_type->shared_from_this();
3053  return false;
3054  });
3055  }
3056  return type_sp;
3057 }
3058 
3060  bool *type_is_new_ptr) {
3061  if (!die)
3062  return {};
3063 
3064  auto type_system_or_err = GetTypeSystemForLanguage(GetLanguage(*die.GetCU()));
3065  if (auto err = type_system_or_err.takeError()) {
3066  LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
3067  "Unable to parse type");
3068  return {};
3069  }
3070  auto ts = *type_system_or_err;
3071  if (!ts)
3072  return {};
3073 
3074  DWARFASTParser *dwarf_ast = ts->GetDWARFParser();
3075  if (!dwarf_ast)
3076  return {};
3077 
3078  TypeSP type_sp = dwarf_ast->ParseTypeFromDWARF(sc, die, type_is_new_ptr);
3079  if (type_sp) {
3080  GetTypeList().Insert(type_sp);
3081 
3082  if (die.Tag() == DW_TAG_subprogram) {
3083  std::string scope_qualified_name(GetDeclContextForUID(die.GetID())
3085  .AsCString(""));
3086  if (scope_qualified_name.size()) {
3087  m_function_scope_qualified_name_map[scope_qualified_name].insert(
3088  *die.GetDIERef());
3089  }
3090  }
3091  }
3092 
3093  return type_sp;
3094 }
3095 
3097  const DWARFDIE &orig_die,
3098  bool parse_siblings, bool parse_children) {
3099  size_t types_added = 0;
3100  DWARFDIE die = orig_die;
3101 
3102  while (die) {
3103  const dw_tag_t tag = die.Tag();
3104  bool type_is_new = false;
3105 
3106  Tag dwarf_tag = static_cast<Tag>(tag);
3107 
3108  // TODO: Currently ParseTypeFromDWARF(...) which is called by ParseType(...)
3109  // does not handle DW_TAG_subrange_type. It is not clear if this is a bug or
3110  // not.
3111  if (isType(dwarf_tag) && tag != DW_TAG_subrange_type)
3112  ParseType(sc, die, &type_is_new);
3113 
3114  if (type_is_new)
3115  ++types_added;
3116 
3117  if (parse_children && die.HasChildren()) {
3118  if (die.Tag() == DW_TAG_subprogram) {
3119  SymbolContext child_sc(sc);
3120  child_sc.function = sc.comp_unit->FindFunctionByUID(die.GetID()).get();
3121  types_added += ParseTypes(child_sc, die.GetFirstChild(), true, true);
3122  } else
3123  types_added += ParseTypes(sc, die.GetFirstChild(), true, true);
3124  }
3125 
3126  if (parse_siblings)
3127  die = die.GetSibling();
3128  else
3129  die.Clear();
3130  }
3131  return types_added;
3132 }
3133 
3135  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
3136  CompileUnit *comp_unit = func.GetCompileUnit();
3137  lldbassert(comp_unit);
3138 
3139  DWARFUnit *dwarf_cu = GetDWARFCompileUnit(comp_unit);
3140  if (!dwarf_cu)
3141  return 0;
3142 
3143  size_t functions_added = 0;
3144  const dw_offset_t function_die_offset = func.GetID();
3145  DWARFDIE function_die =
3146  dwarf_cu->GetNonSkeletonUnit().GetDIE(function_die_offset);
3147  if (function_die) {
3148  ParseBlocksRecursive(*comp_unit, &func.GetBlock(false), function_die,
3150  }
3151 
3152  return functions_added;
3153 }
3154 
3156  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
3157  size_t types_added = 0;
3158  DWARFUnit *dwarf_cu = GetDWARFCompileUnit(&comp_unit);
3159  if (dwarf_cu) {
3160  DWARFDIE dwarf_cu_die = dwarf_cu->DIE();
3161  if (dwarf_cu_die && dwarf_cu_die.HasChildren()) {
3162  SymbolContext sc;
3163  sc.comp_unit = &comp_unit;
3164  types_added = ParseTypes(sc, dwarf_cu_die.GetFirstChild(), true, true);
3165  }
3166  }
3167 
3168  return types_added;
3169 }
3170 
3172  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
3173  if (sc.comp_unit != nullptr) {
3174  if (sc.function) {
3175  DWARFDIE function_die = GetDIE(sc.function->GetID());
3176 
3177  dw_addr_t func_lo_pc = LLDB_INVALID_ADDRESS;
3178  DWARFRangeList ranges;
3179  if (function_die.GetDIE()->GetAttributeAddressRanges(
3180  function_die.GetCU(), ranges,
3181  /*check_hi_lo_pc=*/true))
3182  func_lo_pc = ranges.GetMinRangeBase(0);
3183  if (func_lo_pc != LLDB_INVALID_ADDRESS) {
3184  const size_t num_variables =
3185  ParseVariablesInFunctionContext(sc, function_die, func_lo_pc);
3186 
3187  // Let all blocks know they have parse all their variables
3188  sc.function->GetBlock(false).SetDidParseVariables(true, true);
3189  return num_variables;
3190  }
3191  } else if (sc.comp_unit) {
3192  DWARFUnit *dwarf_cu = DebugInfo().GetUnitAtIndex(sc.comp_unit->GetID());
3193 
3194  if (dwarf_cu == nullptr)
3195  return 0;
3196 
3197  uint32_t vars_added = 0;
3198  VariableListSP variables(sc.comp_unit->GetVariableList(false));
3199 
3200  if (variables.get() == nullptr) {
3201  variables = std::make_shared<VariableList>();
3202  sc.comp_unit->SetVariableList(variables);
3203 
3204  m_index->GetGlobalVariables(*dwarf_cu, [&](DWARFDIE die) {
3205  VariableSP var_sp(ParseVariableDIECached(sc, die));
3206  if (var_sp) {
3207  variables->AddVariableIfUnique(var_sp);
3208  ++vars_added;
3209  }
3210  return true;
3211  });
3212  }
3213  return vars_added;
3214  }
3215  }
3216  return 0;
3217 }
3218 
3220  const DWARFDIE &die) {
3221  if (!die)
3222  return nullptr;
3223 
3224  DIEToVariableSP &die_to_variable = die.GetDWARF()->GetDIEToVariable();
3225 
3226  VariableSP var_sp = die_to_variable[die.GetDIE()];
3227  if (var_sp)
3228  return var_sp;
3229 
3230  var_sp = ParseVariableDIE(sc, die, LLDB_INVALID_ADDRESS);
3231  if (var_sp) {
3232  die_to_variable[die.GetDIE()] = var_sp;
3233  if (DWARFDIE spec_die = die.GetReferencedDIE(DW_AT_specification))
3234  die_to_variable[spec_die.GetDIE()] = var_sp;
3235  }
3236  return var_sp;
3237 }
3238 
3240  const DWARFDIE &die,
3241  const lldb::addr_t func_low_pc) {
3242  if (die.GetDWARF() != this)
3243  return die.GetDWARF()->ParseVariableDIE(sc, die, func_low_pc);
3244 
3245  if (!die)
3246  return nullptr;
3247 
3248  const dw_tag_t tag = die.Tag();
3249  ModuleSP module = GetObjectFile()->GetModule();
3250 
3251  if (tag != DW_TAG_variable && tag != DW_TAG_constant &&
3252  (tag != DW_TAG_formal_parameter || !sc.function))
3253  return nullptr;
3254 
3255  DWARFAttributes attributes;
3256  const size_t num_attributes = die.GetAttributes(attributes);
3257  const char *name = nullptr;
3258  const char *mangled = nullptr;
3259  Declaration decl;
3260  DWARFFormValue type_die_form;
3261  DWARFExpressionList location_list(module, DWARFExpression(), die.GetCU());
3262  bool is_external = false;
3263  bool is_artificial = false;
3264  DWARFFormValue const_value_form, location_form;
3265  Variable::RangeList scope_ranges;
3266 
3267  for (size_t i = 0; i < num_attributes; ++i) {
3268  dw_attr_t attr = attributes.AttributeAtIndex(i);
3269  DWARFFormValue form_value;
3270 
3271  if (!attributes.ExtractFormValueAtIndex(i, form_value))
3272  continue;
3273  switch (attr) {
3274  case DW_AT_decl_file:
3275  decl.SetFile(
3276  attributes.CompileUnitAtIndex(i)->GetFile(form_value.Unsigned()));
3277  break;
3278  case DW_AT_decl_line:
3279  decl.SetLine(form_value.Unsigned());
3280  break;
3281  case DW_AT_decl_column:
3282  decl.SetColumn(form_value.Unsigned());
3283  break;
3284  case DW_AT_name:
3285  name = form_value.AsCString();
3286  break;
3287  case DW_AT_linkage_name:
3288  case DW_AT_MIPS_linkage_name:
3289  mangled = form_value.AsCString();
3290  break;
3291  case DW_AT_type:
3292  type_die_form = form_value;
3293  break;
3294  case DW_AT_external:
3295  is_external = form_value.Boolean();
3296  break;
3297  case DW_AT_const_value:
3298  const_value_form = form_value;
3299  break;
3300  case DW_AT_location:
3301  location_form = form_value;
3302  break;
3303  case DW_AT_start_scope:
3304  // TODO: Implement this.
3305  break;
3306  case DW_AT_artificial:
3307  is_artificial = form_value.Boolean();
3308  break;
3309  case DW_AT_declaration:
3310  case DW_AT_description:
3311  case DW_AT_endianity:
3312  case DW_AT_segment:
3313  case DW_AT_specification:
3314  case DW_AT_visibility:
3315  default:
3316  case DW_AT_abstract_origin:
3317  case DW_AT_sibling:
3318  break;
3319  }
3320  }
3321 
3322  // Prefer DW_AT_location over DW_AT_const_value. Both can be emitted e.g.
3323  // for static constexpr member variables -- DW_AT_const_value will be
3324  // present in the class declaration and DW_AT_location in the DIE defining
3325  // the member.
3326  bool location_is_const_value_data = false;
3327  bool has_explicit_location = location_form.IsValid();
3328  bool use_type_size_for_value = false;
3329  if (location_form.IsValid()) {
3330  if (DWARFFormValue::IsBlockForm(location_form.Form())) {
3331  const DWARFDataExtractor &data = die.GetData();
3332 
3333  uint32_t block_offset = location_form.BlockData() - data.GetDataStart();
3334  uint32_t block_length = location_form.Unsigned();
3335  location_list = DWARFExpressionList(
3336  module, DataExtractor(data, block_offset, block_length), die.GetCU());
3337  } else {
3338  DataExtractor data = die.GetCU()->GetLocationData();
3339  dw_offset_t offset = location_form.Unsigned();
3340  if (location_form.Form() == DW_FORM_loclistx)
3341  offset = die.GetCU()->GetLoclistOffset(offset).value_or(-1);
3342  if (data.ValidOffset(offset)) {
3343  data = DataExtractor(data, offset, data.GetByteSize() - offset);
3344  const DWARFUnit *dwarf_cu = location_form.GetUnit();
3345  if (DWARFExpression::ParseDWARFLocationList(dwarf_cu, data,
3346  &location_list))
3347  location_list.SetFuncFileAddress(func_low_pc);
3348  }
3349  }
3350  } else if (const_value_form.IsValid()) {
3351  location_is_const_value_data = true;
3352  // The constant value will be either a block, a data value or a
3353  // string.
3354  const DWARFDataExtractor &debug_info_data = die.GetData();
3355  if (DWARFFormValue::IsBlockForm(const_value_form.Form())) {
3356  // Retrieve the value as a block expression.
3357  uint32_t block_offset =
3358  const_value_form.BlockData() - debug_info_data.GetDataStart();
3359  uint32_t block_length = const_value_form.Unsigned();
3360  location_list = DWARFExpressionList(
3361  module, DataExtractor(debug_info_data, block_offset, block_length),
3362  die.GetCU());
3363  } else if (DWARFFormValue::IsDataForm(const_value_form.Form())) {
3364  // Constant value size does not have to match the size of the
3365  // variable. We will fetch the size of the type after we create
3366  // it.
3367  use_type_size_for_value = true;
3368  } else if (const char *str = const_value_form.AsCString()) {
3369  uint32_t string_length = strlen(str) + 1;
3370  location_list = DWARFExpressionList(
3371  module,
3372  DataExtractor(str, string_length, die.GetCU()->GetByteOrder(),
3373  die.GetCU()->GetAddressByteSize()),
3374  die.GetCU());
3375  }
3376  }
3377 
3378  const DWARFDIE parent_context_die = GetDeclContextDIEContainingDIE(die);
3379  const DWARFDIE sc_parent_die = GetParentSymbolContextDIE(die);
3380  const dw_tag_t parent_tag = sc_parent_die.Tag();
3381  bool is_static_member = (parent_tag == DW_TAG_compile_unit ||
3382  parent_tag == DW_TAG_partial_unit) &&
3383  (parent_context_die.Tag() == DW_TAG_class_type ||
3384  parent_context_die.Tag() == DW_TAG_structure_type);
3385 
3386  ValueType scope = eValueTypeInvalid;
3387  SymbolContextScope *symbol_context_scope = nullptr;
3388 
3389  bool has_explicit_mangled = mangled != nullptr;
3390  if (!mangled) {
3391  // LLDB relies on the mangled name (DW_TAG_linkage_name or
3392  // DW_AT_MIPS_linkage_name) to generate fully qualified names
3393  // of global variables with commands like "frame var j". For
3394  // example, if j were an int variable holding a value 4 and
3395  // declared in a namespace B which in turn is contained in a
3396  // namespace A, the command "frame var j" returns
3397  // "(int) A::B::j = 4".
3398  // If the compiler does not emit a linkage name, we should be
3399  // able to generate a fully qualified name from the
3400  // declaration context.
3401  if ((parent_tag == DW_TAG_compile_unit ||
3402  parent_tag == DW_TAG_partial_unit) &&
3403  Language::LanguageIsCPlusPlus(GetLanguage(*die.GetCU())))
3404  mangled =
3406  }
3407 
3408  if (tag == DW_TAG_formal_parameter)
3410  else {
3411  // DWARF doesn't specify if a DW_TAG_variable is a local, global
3412  // or static variable, so we have to do a little digging:
3413  // 1) DW_AT_linkage_name implies static lifetime (but may be missing)
3414  // 2) An empty DW_AT_location is an (optimized-out) static lifetime var.
3415  // 3) DW_AT_location containing a DW_OP_addr implies static lifetime.
3416  // Clang likes to combine small global variables into the same symbol
3417  // with locations like: DW_OP_addr(0x1000), DW_OP_constu(2), DW_OP_plus
3418  // so we need to look through the whole expression.
3419  bool is_static_lifetime =
3420  has_explicit_mangled ||
3421  (has_explicit_location && !location_list.IsValid());
3422  // Check if the location has a DW_OP_addr with any address value...
3423  lldb::addr_t location_DW_OP_addr = LLDB_INVALID_ADDRESS;
3424  if (!location_is_const_value_data) {
3425  bool op_error = false;
3426  const DWARFExpression* location = location_list.GetAlwaysValidExpr();
3427  if (location)
3428  location_DW_OP_addr = location->GetLocation_DW_OP_addr(
3429  location_form.GetUnit(), 0, op_error);
3430  if (op_error) {
3431  StreamString strm;
3432  location->DumpLocation(&strm, eDescriptionLevelFull, nullptr);
3433  GetObjectFile()->GetModule()->ReportError(
3434  "0x%8.8x: %s has an invalid location: %s", die.GetOffset(),
3435  die.GetTagAsCString(), strm.GetData());
3436  }
3437  if (location_DW_OP_addr != LLDB_INVALID_ADDRESS)
3438  is_static_lifetime = true;
3439  }
3440  SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile();
3441  if (debug_map_symfile)
3442  // Set the module of the expression to the linked module
3443  // instead of the object file so the relocated address can be
3444  // found there.
3445  location_list.SetModule(debug_map_symfile->GetObjectFile()->GetModule());
3446 
3447  if (is_static_lifetime) {
3448  if (is_external)
3449  scope = eValueTypeVariableGlobal;
3450  else
3451  scope = eValueTypeVariableStatic;
3452 
3453  if (debug_map_symfile) {
3454  // When leaving the DWARF in the .o files on darwin, when we have a
3455  // global variable that wasn't initialized, the .o file might not
3456  // have allocated a virtual address for the global variable. In
3457  // this case it will have created a symbol for the global variable
3458  // that is undefined/data and external and the value will be the
3459  // byte size of the variable. When we do the address map in
3460  // SymbolFileDWARFDebugMap we rely on having an address, we need to
3461  // do some magic here so we can get the correct address for our
3462  // global variable. The address for all of these entries will be
3463  // zero, and there will be an undefined symbol in this object file,
3464  // and the executable will have a matching symbol with a good
3465  // address. So here we dig up the correct address and replace it in
3466  // the location for the variable, and set the variable's symbol
3467  // context scope to be that of the main executable so the file
3468  // address will resolve correctly.
3469  bool linked_oso_file_addr = false;
3470  if (is_external && location_DW_OP_addr == 0) {
3471  // we have a possible uninitialized extern global
3472  ConstString const_name(mangled ? mangled : name);
3473  ObjectFile *debug_map_objfile = debug_map_symfile->GetObjectFile();
3474  if (debug_map_objfile) {
3475  Symtab *debug_map_symtab = debug_map_objfile->GetSymtab();
3476  if (debug_map_symtab) {
3477  Symbol *exe_symbol =
3478  debug_map_symtab->FindFirstSymbolWithNameAndType(
3479  const_name, eSymbolTypeData, Symtab::eDebugYes,
3480  Symtab::eVisibilityExtern);
3481  if (exe_symbol) {
3482  if (exe_symbol->ValueIsAddress()) {
3483  const addr_t exe_file_addr =
3484  exe_symbol->GetAddressRef().GetFileAddress();
3485  if (exe_file_addr != LLDB_INVALID_ADDRESS) {
3486  DWARFExpression *location =
3487  location_list.GetMutableExpressionAtAddress();
3488  if (location->Update_DW_OP_addr(die.GetCU(),
3489  exe_file_addr)) {
3490  linked_oso_file_addr = true;
3491  symbol_context_scope = exe_symbol;
3492  }
3493  }
3494  }
3495  }
3496  }
3497  }
3498  }
3499 
3500  if (!linked_oso_file_addr) {
3501  // The DW_OP_addr is not zero, but it contains a .o file address
3502  // which needs to be linked up correctly.
3503  const lldb::addr_t exe_file_addr =
3504  debug_map_symfile->LinkOSOFileAddress(this, location_DW_OP_addr);
3505  if (exe_file_addr != LLDB_INVALID_ADDRESS) {
3506  // Update the file address for this variable
3507  DWARFExpression *location =
3508  location_list.GetMutableExpressionAtAddress();
3509  location->Update_DW_OP_addr(die.GetCU(), exe_file_addr);
3510  } else {
3511  // Variable didn't make it into the final executable
3512  return nullptr;
3513  }
3514  }
3515  }
3516  } else {
3517  if (location_is_const_value_data &&
3518  die.GetDIE()->IsGlobalOrStaticScopeVariable())
3519  scope = eValueTypeVariableStatic;
3520  else {
3521  scope = eValueTypeVariableLocal;
3522  if (debug_map_symfile) {
3523  // We need to check for TLS addresses that we need to fixup
3524  if (location_list.ContainsThreadLocalStorage()) {
3525  location_list.LinkThreadLocalStorage(
3526  debug_map_symfile->GetObjectFile()->GetModule(),
3527  [this, debug_map_symfile](
3528  lldb::addr_t unlinked_file_addr) -> lldb::addr_t {
3529  return debug_map_symfile->LinkOSOFileAddress(
3530  this, unlinked_file_addr);
3531  });
3533  }
3534  }
3535  }
3536  }
3537  }
3538 
3539  if (symbol_context_scope == nullptr) {
3540  switch (parent_tag) {
3541  case DW_TAG_subprogram:
3542  case DW_TAG_inlined_subroutine:
3543  case DW_TAG_lexical_block:
3544  if (sc.function) {
3545  symbol_context_scope =
3546  sc.function->GetBlock(true).FindBlockByID(sc_parent_die.GetID());
3547  if (symbol_context_scope == nullptr)
3548  symbol_context_scope = sc.function;
3549  }
3550  break;
3551 
3552  default:
3553  symbol_context_scope = sc.comp_unit;
3554  break;
3555  }
3556  }
3557 
3558  if (!symbol_context_scope) {
3559  // Not ready to parse this variable yet. It might be a global or static
3560  // variable that is in a function scope and the function in the symbol
3561  // context wasn't filled in yet
3562  return nullptr;
3563  }
3564 
3565  auto type_sp = std::make_shared<SymbolFileType>(
3566  *this, GetUID(type_die_form.Reference()));
3567 
3568  if (use_type_size_for_value && type_sp->GetType()) {
3569  DWARFExpression *location = location_list.GetMutableExpressionAtAddress();
3570  location->UpdateValue(const_value_form.Unsigned(),
3571  type_sp->GetType()->GetByteSize(nullptr).value_or(0),
3572  die.GetCU()->GetAddressByteSize());
3573  }
3574 
3575  return std::make_shared<Variable>(
3576  die.GetID(), name, mangled, type_sp, scope, symbol_context_scope,
3577  scope_ranges, &decl, location_list, is_external, is_artificial,
3578  location_is_const_value_data, is_static_member);
3579 }
3580 
3581 DWARFDIE
3583  const DIERef &func_die_ref, dw_offset_t spec_block_die_offset) {
3584  // Give the concrete function die specified by "func_die_offset", find the
3585  // concrete block whose DW_AT_specification or DW_AT_abstract_origin points
3586  // to "spec_block_die_offset"
3587  return FindBlockContainingSpecification(DebugInfo().GetDIE(func_die_ref),
3588  spec_block_die_offset);
3589 }
3590 
3591 DWARFDIE
3593  const DWARFDIE &die, dw_offset_t spec_block_die_offset) {
3594  if (die) {
3595  switch (die.Tag()) {
3596  case DW_TAG_subprogram:
3597  case DW_TAG_inlined_subroutine:
3598  case DW_TAG_lexical_block: {
3599  if (die.GetReferencedDIE(DW_AT_specification).GetOffset() ==
3600  spec_block_die_offset)
3601  return die;
3602 
3603  if (die.GetReferencedDIE(DW_AT_abstract_origin).GetOffset() ==
3604  spec_block_die_offset)
3605  return die;
3606  } break;
3607  default:
3608  break;
3609  }
3610 
3611  // Give the concrete function die specified by "func_die_offset", find the
3612  // concrete block whose DW_AT_specification or DW_AT_abstract_origin points
3613  // to "spec_block_die_offset"
3614  for (DWARFDIE child_die : die.children()) {
3615  DWARFDIE result_die =
3616  FindBlockContainingSpecification(child_die, spec_block_die_offset);
3617  if (result_die)
3618  return result_die;
3619  }
3620  }
3621 
3622  return DWARFDIE();
3623 }
3624 
3626  const SymbolContext &sc, const DWARFDIE &die,
3627  VariableList &cc_variable_list) {
3628  if (!die)
3629  return;
3630 
3631  dw_tag_t tag = die.Tag();
3632  if (tag != DW_TAG_variable && tag != DW_TAG_constant)
3633  return;
3634 
3635  // Check to see if we have already parsed this variable or constant?
3636  VariableSP var_sp = GetDIEToVariable()[die.GetDIE()];
3637  if (var_sp) {
3638  cc_variable_list.AddVariableIfUnique(var_sp);
3639  return;
3640  }
3641 
3642  // We haven't parsed the variable yet, lets do that now. Also, let us include
3643  // the variable in the relevant compilation unit's variable list, if it
3644  // exists.
3645  VariableListSP variable_list_sp;
3646  DWARFDIE sc_parent_die = GetParentSymbolContextDIE(die);
3647  dw_tag_t parent_tag = sc_parent_die.Tag();
3648  switch (parent_tag) {
3649  case DW_TAG_compile_unit:
3650  case DW_TAG_partial_unit:
3651  if (sc.comp_unit != nullptr) {
3652  variable_list_sp = sc.comp_unit->GetVariableList(false);
3653  } else {
3654  GetObjectFile()->GetModule()->ReportError(
3655  "parent 0x%8.8" PRIx64 " %s with no valid compile unit in "
3656  "symbol context for 0x%8.8" PRIx64 " %s.\n",
3657  sc_parent_die.GetID(), sc_parent_die.GetTagAsCString(), die.GetID(),
3658  die.GetTagAsCString());
3659  return;
3660  }
3661  break;
3662 
3663  default:
3664  GetObjectFile()->GetModule()->ReportError(
3665  "didn't find appropriate parent DIE for variable list for "
3666  "0x%8.8" PRIx64 " %s.\n",
3667  die.GetID(), die.GetTagAsCString());
3668  return;
3669  }
3670 
3671  var_sp = ParseVariableDIECached(sc, die);
3672  if (!var_sp)
3673  return;
3674 
3675  cc_variable_list.AddVariableIfUnique(var_sp);
3676  if (variable_list_sp)
3677  variable_list_sp->AddVariableIfUnique(var_sp);
3678 }
3679 
3680 DIEArray
3682  DIEArray &&variable_dies) {
3683  // DW_TAG_inline_subroutine objects may omit DW_TAG_formal_parameter in
3684  // instances of the function when they are unused (i.e., the parameter's
3685  // location list would be empty). The current DW_TAG_inline_subroutine may
3686  // refer to another DW_TAG_subprogram that might actually have the definitions
3687  // of the parameters and we need to include these so they show up in the
3688  // variables for this function (for example, in a stack trace). Let us try to
3689  // find the abstract subprogram that might contain the parameter definitions
3690  // and merge with the concrete parameters.
3691 
3692  // Nothing to merge if the block is not an inlined function.
3693  if (block_die.Tag() != DW_TAG_inlined_subroutine) {
3694  return std::move(variable_dies);
3695  }
3696 
3697  // Nothing to merge if the block does not have abstract parameters.
3698  DWARFDIE abs_die = block_die.GetReferencedDIE(DW_AT_abstract_origin);
3699  if (!abs_die || abs_die.Tag() != DW_TAG_subprogram ||
3700  !abs_die.HasChildren()) {
3701  return std::move(variable_dies);
3702  }
3703 
3704  // For each abstract parameter, if we have its concrete counterpart, insert
3705  // it. Otherwise, insert the abstract parameter.
3706  DIEArray::iterator concrete_it = variable_dies.begin();
3707  DWARFDIE abstract_child = abs_die.GetFirstChild();
3708  DIEArray merged;
3709  bool did_merge_abstract = false;
3710  for (; abstract_child; abstract_child = abstract_child.GetSibling()) {
3711  if (abstract_child.Tag() == DW_TAG_formal_parameter) {
3712  if (concrete_it == variable_dies.end() ||
3713  GetDIE(*concrete_it).Tag() != DW_TAG_formal_parameter) {
3714  // We arrived at the end of the concrete parameter list, so all
3715  // the remaining abstract parameters must have been omitted.
3716  // Let us insert them to the merged list here.
3717  merged.push_back(*abstract_child.GetDIERef());
3718  did_merge_abstract = true;
3719  continue;
3720  }
3721 
3722  DWARFDIE origin_of_concrete =
3723  GetDIE(*concrete_it).GetReferencedDIE(DW_AT_abstract_origin);
3724  if (origin_of_concrete == abstract_child) {
3725  // The current abstract parameter is the origin of the current
3726  // concrete parameter, just push the concrete parameter.
3727  merged.push_back(*concrete_it);
3728  ++concrete_it;
3729  } else {
3730  // Otherwise, the parameter must have been omitted from the concrete
3731  // function, so insert the abstract one.
3732  merged.push_back(*abstract_child.GetDIERef());
3733  did_merge_abstract = true;
3734  }
3735  }
3736  }
3737 
3738  // Shortcut if no merging happened.
3739  if (!did_merge_abstract)
3740  return std::move(variable_dies);
3741 
3742  // We inserted all the abstract parameters (or their concrete counterparts).
3743  // Let us insert all the remaining concrete variables to the merged list.
3744  // During the insertion, let us check there are no remaining concrete
3745  // formal parameters. If that's the case, then just bailout from the merge -
3746  // the variable list is malformed.
3747  for (; concrete_it != variable_dies.end(); ++concrete_it) {
3748  if (GetDIE(*concrete_it).Tag() == DW_TAG_formal_parameter) {
3749  return std::move(variable_dies);
3750  }
3751  merged.push_back(*concrete_it);
3752  }
3753  return merged;
3754 }
3755 
3757  const SymbolContext &sc, const DWARFDIE &die,
3758  const lldb::addr_t func_low_pc) {
3759  if (!die || !sc.function)
3760  return 0;
3761 
3762  DIEArray dummy_block_variables; // The recursive call should not add anything
3763  // to this vector because |die| should be a
3764  // subprogram, so all variables will be added
3765  // to the subprogram's list.
3766  return ParseVariablesInFunctionContextRecursive(sc, die, func_low_pc,
3767  dummy_block_variables);
3768 }
3769 
3770 // This method parses all the variables in the blocks in the subtree of |die|,
3771 // and inserts them to the variable list for all the nested blocks.
3772 // The uninserted variables for the current block are accumulated in
3773 // |accumulator|.
3775  const lldb_private::SymbolContext &sc, const DWARFDIE &die,
3776  lldb::addr_t func_low_pc, DIEArray &accumulator) {
3777  size_t vars_added = 0;
3778  dw_tag_t tag = die.Tag();
3779 
3780  if ((tag == DW_TAG_variable) || (tag == DW_TAG_constant) ||
3781  (tag == DW_TAG_formal_parameter)) {
3782  accumulator.push_back(*die.GetDIERef());
3783  }
3784 
3785  switch (tag) {
3786  case DW_TAG_subprogram:
3787  case DW_TAG_inlined_subroutine:
3788  case DW_TAG_lexical_block: {
3789  // If we start a new block, compute a new block variable list and recurse.
3790  Block *block =
3791  sc.function->GetBlock(/*can_create=*/true).FindBlockByID(die.GetID());
3792  if (block == nullptr) {
3793  // This must be a specification or abstract origin with a
3794  // concrete block counterpart in the current function. We need
3795  // to find the concrete block so we can correctly add the
3796  // variable to it.
3797  const DWARFDIE concrete_block_die = FindBlockContainingSpecification(
3798  GetDIE(sc.function->GetID()), die.GetOffset());
3799  if (concrete_block_die)
3800  block = sc.function->GetBlock(/*can_create=*/true)
3801  .FindBlockByID(concrete_block_die.GetID());
3802  }
3803 
3804  if (block == nullptr)
3805  return 0;
3806 
3807  const bool can_create = false;
3808  VariableListSP block_variable_list_sp =
3809  block->GetBlockVariableList(can_create);
3810  if (block_variable_list_sp.get() == nullptr) {
3811  block_variable_list_sp = std::make_shared<VariableList>();
3812  block->SetVariableList(block_variable_list_sp);
3813  }
3814 
3815  DIEArray block_variables;
3816  for (DWARFDIE child = die.GetFirstChild(); child;
3817  child = child.GetSibling()) {
3819  sc, child, func_low_pc, block_variables);
3820  }
3821  block_variables =
3822  MergeBlockAbstractParameters(die, std::move(block_variables));
3823  vars_added += PopulateBlockVariableList(*block_variable_list_sp, sc,
3824  block_variables, func_low_pc);
3825  break;
3826  }
3827 
3828  default:
3829  // Recurse to children with the same variable accumulator.
3830  for (DWARFDIE child = die.GetFirstChild(); child;
3831  child = child.GetSibling()) {
3833  sc, child, func_low_pc, accumulator);
3834  }
3835  break;
3836  }
3837 
3838  return vars_added;
3839 }
3840 
3842  VariableList &variable_list, const lldb_private::SymbolContext &sc,
3843  llvm::ArrayRef<DIERef> variable_dies, lldb::addr_t func_low_pc) {
3844  // Parse the variable DIEs and insert them to the list.
3845  for (auto &die : variable_dies) {
3846  if (VariableSP var_sp = ParseVariableDIE(sc, GetDIE(die), func_low_pc)) {
3847  variable_list.AddVariableIfUnique(var_sp);
3848  }
3849  }
3850  return variable_dies.size();
3851 }
3852 
3853 /// Collect call site parameters in a DW_TAG_call_site DIE.
3855 CollectCallSiteParameters(ModuleSP module, DWARFDIE call_site_die) {
3856  CallSiteParameterArray parameters;
3857  for (DWARFDIE child : call_site_die.children()) {
3858  if (child.Tag() != DW_TAG_call_site_parameter &&
3859  child.Tag() != DW_TAG_GNU_call_site_parameter)
3860  continue;
3861 
3862  llvm::Optional<DWARFExpressionList> LocationInCallee;
3863  llvm::Optional<DWARFExpressionList> LocationInCaller;
3864 
3865  DWARFAttributes attributes;
3866  const size_t num_attributes = child.GetAttributes(attributes);
3867 
3868  // Parse the location at index \p attr_index within this call site parameter
3869  // DIE, or return None on failure.
3870  auto parse_simple_location =
3871  [&](int attr_index) -> llvm::Optional<DWARFExpressionList> {
3872  DWARFFormValue form_value;
3873  if (!attributes.ExtractFormValueAtIndex(attr_index, form_value))
3874  return {};
3875  if (!DWARFFormValue::IsBlockForm(form_value.Form()))
3876  return {};
3877  auto data = child.GetData();
3878  uint32_t block_offset = form_value.BlockData() - data.GetDataStart();
3879  uint32_t block_length = form_value.Unsigned();
3880  return DWARFExpressionList(
3881  module, DataExtractor(data, block_offset, block_length),
3882  child.GetCU());
3883  };
3884 
3885  for (size_t i = 0; i < num_attributes; ++i) {
3886  dw_attr_t attr = attributes.AttributeAtIndex(i);
3887  if (attr == DW_AT_location)
3888  LocationInCallee = parse_simple_location(i);
3889  if (attr == DW_AT_call_value || attr == DW_AT_GNU_call_site_value)
3890  LocationInCaller = parse_simple_location(i);
3891  }
3892 
3893  if (LocationInCallee && LocationInCaller) {
3894  CallSiteParameter param = {*LocationInCallee, *LocationInCaller};
3895  parameters.push_back(param);
3896  }
3897  }
3898  return parameters;
3899 }
3900 
3901 /// Collect call graph edges present in a function DIE.
3902 std::vector<std::unique_ptr<lldb_private::CallEdge>>
3903 SymbolFileDWARF::CollectCallEdges(ModuleSP module, DWARFDIE function_die) {
3904  // Check if the function has a supported call site-related attribute.
3905  // TODO: In the future it may be worthwhile to support call_all_source_calls.
3906  bool has_call_edges =
3907  function_die.GetAttributeValueAsUnsigned(DW_AT_call_all_calls, 0) ||
3908  function_die.GetAttributeValueAsUnsigned(DW_AT_GNU_all_call_sites, 0);
3909  if (!has_call_edges)
3910  return {};
3911 
3912  Log *log = GetLog(LLDBLog::Step);
3913  LLDB_LOG(log, "CollectCallEdges: Found call site info in {0}",
3914  function_die.GetPubname());
3915 
3916  // Scan the DIE for TAG_call_site entries.
3917  // TODO: A recursive scan of all blocks in the subprogram is needed in order
3918  // to be DWARF5-compliant. This may need to be done lazily to be performant.
3919  // For now, assume that all entries are nested directly under the subprogram
3920  // (this is the kind of DWARF LLVM produces) and parse them eagerly.
3921  std::vector<std::unique_ptr<CallEdge>> call_edges;
3922  for (DWARFDIE child : function_die.children()) {
3923  if (child.Tag() != DW_TAG_call_site && child.Tag() != DW_TAG_GNU_call_site)
3924  continue;
3925 
3926  llvm::Optional<DWARFDIE> call_origin;
3927  llvm::Optional<DWARFExpressionList> call_target;
3928  addr_t return_pc = LLDB_INVALID_ADDRESS;
3929  addr_t call_inst_pc = LLDB_INVALID_ADDRESS;
3930  addr_t low_pc = LLDB_INVALID_ADDRESS;
3931  bool tail_call = false;
3932 
3933  // Second DW_AT_low_pc may come from DW_TAG_subprogram referenced by
3934  // DW_TAG_GNU_call_site's DW_AT_abstract_origin overwriting our 'low_pc'.
3935  // So do not inherit attributes from DW_AT_abstract_origin.
3936  DWARFAttributes attributes;
3937  const size_t num_attributes =
3938  child.GetAttributes(attributes, DWARFDIE::Recurse::no);
3939  for (size_t i = 0; i < num_attributes; ++i) {
3940  DWARFFormValue form_value;
3941  if (!attributes.ExtractFormValueAtIndex(i, form_value)) {
3942  LLDB_LOG(log, "CollectCallEdges: Could not extract TAG_call_site form");
3943  break;
3944  }
3945 
3946  dw_attr_t attr = attributes.AttributeAtIndex(i);
3947 
3948  if (attr == DW_AT_call_tail_call || attr == DW_AT_GNU_tail_call)
3949  tail_call = form_value.Boolean();
3950 
3951  // Extract DW_AT_call_origin (the call target's DIE).
3952  if (attr == DW_AT_call_origin || attr == DW_AT_abstract_origin) {
3953  call_origin = form_value.Reference();
3954  if (!call_origin->IsValid()) {
3955  LLDB_LOG(log, "CollectCallEdges: Invalid call origin in {0}",
3956  function_die.GetPubname());
3957  break;
3958  }
3959  }
3960 
3961  if (attr == DW_AT_low_pc)
3962  low_pc = form_value.Address();
3963 
3964  // Extract DW_AT_call_return_pc (the PC the call returns to) if it's
3965  // available. It should only ever be unavailable for tail call edges, in
3966  // which case use LLDB_INVALID_ADDRESS.
3967  if (attr == DW_AT_call_return_pc)
3968  return_pc = form_value.Address();
3969 
3970  // Extract DW_AT_call_pc (the PC at the call/branch instruction). It
3971  // should only ever be unavailable for non-tail calls, in which case use
3972  // LLDB_INVALID_ADDRESS.
3973  if (attr == DW_AT_call_pc)
3974  call_inst_pc = form_value.Address();
3975 
3976  // Extract DW_AT_call_target (the location of the address of the indirect
3977  // call).
3978  if (attr == DW_AT_call_target || attr == DW_AT_GNU_call_site_target) {
3979  if (!DWARFFormValue::IsBlockForm(form_value.Form())) {
3980  LLDB_LOG(log,
3981  "CollectCallEdges: AT_call_target does not have block form");
3982  break;
3983  }
3984 
3985  auto data = child.GetData();
3986  uint32_t block_offset = form_value.BlockData() - data.GetDataStart();
3987  uint32_t block_length = form_value.Unsigned();
3988  call_target = DWARFExpressionList(
3989  module, DataExtractor(data, block_offset, block_length),
3990  child.GetCU());
3991  }
3992  }
3993  if (!call_origin && !call_target) {
3994  LLDB_LOG(log, "CollectCallEdges: call site without any call target");
3995  continue;
3996  }
3997 
3998  addr_t caller_address;
3999  CallEdge::AddrType caller_address_type;
4000  if (return_pc != LLDB_INVALID_ADDRESS) {
4001  caller_address = return_pc;
4002  caller_address_type = CallEdge::AddrType::AfterCall;
4003  } else if (low_pc != LLDB_INVALID_ADDRESS) {
4004  caller_address = low_pc;
4005  caller_address_type = CallEdge::AddrType::AfterCall;
4006  } else if (call_inst_pc != LLDB_INVALID_ADDRESS) {
4007  caller_address = call_inst_pc;
4008  caller_address_type = CallEdge::AddrType::Call;
4009  } else {
4010  LLDB_LOG(log, "CollectCallEdges: No caller address");
4011  continue;
4012  }
4013  // Adjust any PC forms. It needs to be fixed up if the main executable
4014  // contains a debug map (i.e. pointers to object files), because we need a
4015  // file address relative to the executable's text section.
4016  caller_address = FixupAddress(caller_address);
4017 
4018  // Extract call site parameters.
4019  CallSiteParameterArray parameters =
4020  CollectCallSiteParameters(module, child);
4021 
4022  std::unique_ptr<CallEdge> edge;
4023  if (call_origin) {
4024  LLDB_LOG(log,
4025  "CollectCallEdges: Found call origin: {0} (retn-PC: {1:x}) "
4026  "(call-PC: {2:x})",
4027  call_origin->GetPubname(), return_pc, call_inst_pc);
4028  edge = std::make_unique<DirectCallEdge>(
4029  call_origin->GetMangledName(), caller_address_type, caller_address,
4030  tail_call, std::move(parameters));
4031  } else {
4032  if (log) {
4033  StreamString call_target_desc;
4034  call_target->GetDescription(&call_target_desc, eDescriptionLevelBrief,
4035  nullptr);
4036  LLDB_LOG(log, "CollectCallEdges: Found indirect call target: {0}",
4037  call_target_desc.GetString());
4038  }
4039  edge = std::make_unique<IndirectCallEdge>(
4040  *call_target, caller_address_type, caller_address, tail_call,
4041  std::move(parameters));
4042  }
4043 
4044  if (log && parameters.size()) {
4045  for (const CallSiteParameter &param : parameters) {
4046  StreamString callee_loc_desc, caller_loc_desc;
4047  param.LocationInCallee.GetDescription(&callee_loc_desc,
4048  eDescriptionLevelBrief, nullptr);
4049  param.LocationInCaller.GetDescription(&caller_loc_desc,
4050  eDescriptionLevelBrief, nullptr);
4051  LLDB_LOG(log, "CollectCallEdges: \tparam: {0} => {1}",
4052  callee_loc_desc.GetString(), caller_loc_desc.GetString());
4053  }
4054  }
4055 
4056  call_edges.push_back(std::move(edge));
4057  }
4058  return call_edges;
4059 }
4060 
4061 std::vector<std::unique_ptr<lldb_private::CallEdge>>
4063  // ParseCallEdgesInFunction must be called at the behest of an exclusively
4064  // locked lldb::Function instance. Storage for parsed call edges is owned by
4065  // the lldb::Function instance: locking at the SymbolFile level would be too
4066  // late, because the act of storing results from ParseCallEdgesInFunction
4067  // would be racy.
4068  DWARFDIE func_die = GetDIE(func_id.GetID());
4069  if (func_die.IsValid())
4070  return CollectCallEdges(GetObjectFile()->GetModule(), func_die);
4071  return {};
4072 }
4073 
4075  SymbolFileCommon::Dump(s);
4076  m_index->Dump(s);
4077 }
4078 
4081  if (!ts_or_err)
4082  return;
4083  auto ts = *ts_or_err;
4084  TypeSystemClang *clang = llvm::dyn_cast_or_null<TypeSystemClang>(ts.get());
4085  if (!clang)
4086  return;
4087  clang->Dump(s.AsRawOstream());
4088 }
4089 
4091  if (m_debug_map_symfile == nullptr) {
4092  lldb::ModuleSP module_sp(m_debug_map_module_wp.lock());
4093  if (module_sp) {
4094  m_debug_map_symfile = llvm::cast<SymbolFileDWARFDebugMap>(
4095  module_sp->GetSymbolFile()->GetBackingSymbolFile());
4096  }
4097  }
4098  return m_debug_map_symfile;
4099 }
4100 
4101 const std::shared_ptr<SymbolFileDWARFDwo> &SymbolFileDWARF::GetDwpSymbolFile() {
4102  llvm::call_once(m_dwp_symfile_once_flag, [this]() {
4103  ModuleSpec module_spec;
4104  module_spec.GetFileSpec() = m_objfile_sp->GetFileSpec();
4105  module_spec.GetSymbolFileSpec() =
4106  FileSpec(m_objfile_sp->GetModule()->GetFileSpec().GetPath() + ".dwp");
4107 
4108  FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
4109  FileSpec dwp_filespec =
4110  Symbols::LocateExecutableSymbolFile(module_spec, search_paths);
4111  if (FileSystem::Instance().Exists(dwp_filespec)) {
4112  DataBufferSP dwp_file_data_sp;
4113  lldb::offset_t dwp_file_data_offset = 0;
4114  ObjectFileSP dwp_obj_file = ObjectFile::FindPlugin(
4115  GetObjectFile()->GetModule(), &dwp_filespec, 0,
4116  FileSystem::Instance().GetByteSize(dwp_filespec), dwp_file_data_sp,
4117  dwp_file_data_offset);
4118  if (!dwp_obj_file)
4119  return;
4120  m_dwp_symfile =
4121  std::make_shared<SymbolFileDWARFDwo>(*this, dwp_obj_file, 0x3fffffff);
4122  }
4123  });
4124  return m_dwp_symfile;
4125 }
4126 
4127 llvm::Expected<lldb::TypeSystemSP>
4130 }
4131 
4133  auto type_system_or_err = GetTypeSystem(unit);
4134  if (auto err = type_system_or_err.takeError()) {
4135  LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
4136  "Unable to get DWARFASTParser");
4137  return nullptr;
4138  }
4139  if (auto ts = *type_system_or_err)
4140  return ts->GetDWARFParser();
4141  return nullptr;
4142 }
4143 
4145  if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU()))
4146  return dwarf_ast->GetDeclForUIDFromDWARF(die);
4147  return CompilerDecl();
4148 }
4149 
4151  if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU()))
4152  return dwarf_ast->GetDeclContextForUIDFromDWARF(die);
4153  return CompilerDeclContext();
4154 }
4155 
4158  if (DWARFASTParser *dwarf_ast = GetDWARFParser(*die.GetCU()))
4159  return dwarf_ast->GetDeclContextContainingUIDFromDWARF(die);
4160  return CompilerDeclContext();
4161 }
4162 
4164  if (!die.IsValid())
4165  return {};
4166  DWARFDeclContext dwarf_decl_ctx =
4167  die.GetDIE()->GetDWARFDeclContext(die.GetCU());
4168  return dwarf_decl_ctx;
4169 }
4170 
4172  // Note: user languages between lo_user and hi_user must be handled
4173  // explicitly here.
4174  switch (val) {
4175  case DW_LANG_Mips_Assembler:
4177  case DW_LANG_GOOGLE_RenderScript:
4179  default:
4180  return static_cast<LanguageType>(val);
4181  }
4182 }
4183 
4186 }
4187 
4189  auto lang = (llvm::dwarf::SourceLanguage)unit.GetDWARFLanguageType();
4190  if (llvm::dwarf::isCPlusPlus(lang))
4191  lang = DW_LANG_C_plus_plus;
4192  return LanguageTypeFromDWARF(lang);
4193 }
4194 
4196  if (m_index)
4197  return m_index->GetIndexTime();
4198  return {};
4199 }
4200 
4202  std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
4203  CompileUnit *cu = frame.GetSymbolContext(eSymbolContextCompUnit).comp_unit;
4204  if (!cu)
4205  return Status();
4206 
4207  DWARFCompileUnit *dwarf_cu = GetDWARFCompileUnit(cu);
4208  if (!dwarf_cu)
4209  return Status();
4210 
4211  // Check if we have a skeleton compile unit that had issues trying to load
4212  // its .dwo/.dwp file. First pares the Unit DIE to make sure we see any .dwo
4213  // related errors.
4214  dwarf_cu->ExtractUnitDIEIfNeeded();
4215  const Status &dwo_error = dwarf_cu->GetDwoError();
4216  if (dwo_error.Fail())
4217  return dwo_error;
4218 
4219  // Don't return an error for assembly files as they typically don't have
4220  // varaible information.
4221  if (dwarf_cu->GetDWARFLanguageType() == DW_LANG_Mips_Assembler)
4222  return Status();
4223 
4224  // Check if this compile unit has any variable DIEs. If it doesn't then there
4225  // is not variable information for the entire compile unit.
4226  if (dwarf_cu->HasAny({DW_TAG_variable, DW_TAG_formal_parameter}))
4227  return Status();
4228 
4229  return Status("no variable information is available in debug info for this "
4230  "compile unit");
4231 }
lldb_private::SourceLocationSpec::GetFileSpec
FileSpec GetFileSpec() const
Definition: SourceLocationSpec.h:166
lldb_private::Declaration::SetLine
void SetLine(uint32_t line)
Set accessor for the declaration line number.
Definition: Declaration.h:168
SymbolFileDWARF::GetCompUnitForDWARFCompUnit
lldb_private::CompileUnit * GetCompUnitForDWARFCompUnit(DWARFCompileUnit &dwarf_cu)
Definition: SymbolFileDWARF.cpp:1642
lldb_private::DWARFContext::getOrLoadAbbrevData
const DWARFDataExtractor & getOrLoadAbbrevData()
Definition: DWARFContext.cpp:53
RegularExpression.h
lldb_private::LineTable::FindLineEntryByAddress
bool FindLineEntryByAddress(const Address &so_addr, LineEntry &line_entry, uint32_t *index_ptr=nullptr)
Find a line entry that contains the section offset address so_addr.
Definition: LineTable.cpp:188
SymbolFileDWARF::CalculateNumCompileUnits
uint32_t CalculateNumCompileUnits() override
Definition: SymbolFileDWARF.cpp:805
lldb_private::AddressRange::GetBaseAddress
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:209
DWARFDebugInfo::ContainsTypeUnits
bool ContainsTypeUnits()
Definition: DWARFDebugInfo.cpp:171
Block.h
SymbolFileDWARF::DecodeUID
llvm::Optional< DecodedUID > DecodeUID(lldb::user_id_t uid)
Definition: SymbolFileDWARF.cpp:1410
DWARFFormValue.h
SymbolFileDWARF::m_debug_macros_map
DebugMacrosMap m_debug_macros_map
Definition: SymbolFileDWARF.h:554
SymbolFileDWARFDebugMap.h
list
MATCHES FreeBSD list(APPEND FBSDKERNEL_LIBS kvm) endif() if(NOT FBSDKERNEL_LIBS) message(STATUS "Skipping FreeBSDKernel plugin due to missing libfbsdvmcore") return() endif() add_lldb_library(lldbPluginProcessFreeBSDKernel PLUGIN ProcessFreeBSDKernel.cpp RegisterContextFreeBSDKernel_arm64.cpp RegisterContextFreeBSDKernel_i386.cpp RegisterContextFreeBSDKernel_x86_64.cpp ThreadFreeBSDKernel.cpp LINK_LIBS lldbCore lldbTarget $
Definition: Plugins/Process/FreeBSDKernel/CMakeLists.txt:6
lldb::eLanguageTypeExtRenderScript
@ eLanguageTypeExtRenderScript
RenderScript.
Definition: lldb-enumerations.h:482
SymbolFileDWARF::GetDebugInfoIndexTime
lldb_private::StatsDuration::Duration GetDebugInfoIndexTime() override
Return the time it took to index the debug information in the object file.
Definition: SymbolFileDWARF.cpp:4195
DIERef
Identifies a DWARF debug info entry within a given Module.
Definition: DIERef.h:26
lldb_private::SymbolFile
Provides public interface for all SymbolFiles.
Definition: SymbolFile.h:46
lldb_private::SymbolContext::block
Block * block
The Block for a given query.
Definition: SymbolContext.h:321
lldb_private::DW_TAG_value_to_name
const char * DW_TAG_value_to_name(uint32_t val)
Definition: DWARFDefines.cpp:17
SymbolFileDWARF::GetFunction
bool GetFunction(const DWARFDIE &die, lldb_private::SymbolContext &sc)
Definition: SymbolFileDWARF.cpp:1664
lldb_private::Range::GetRangeBase
BaseType GetRangeBase() const
Definition: RangeMap.h:46
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb_private::SymbolContext::comp_unit
CompileUnit * comp_unit
The CompileUnit for a given query.
Definition: SymbolContext.h:319
lldb_private::SectionList::FindSectionByName
lldb::SectionSP FindSectionByName(ConstString section_dstr) const
Definition: Section.cpp:546
DWARFUnit::SetUserData
void SetUserData(void *d)
Definition: DWARFUnit.cpp:671
lldb_private::CompileUnit::GetSupportFiles
const FileSpecList & GetSupportFiles()
Get the compile unit's support file list.
Definition: CompileUnit.cpp:416
Scalar.h
lldb_private::CompileUnit::GetVariableList
lldb::VariableListSP GetVariableList(bool can_create)
Get the variable list for a compile unit.
Definition: CompileUnit.cpp:208
SymbolFileDWARF::DIEDeclContextsMatch
bool DIEDeclContextsMatch(const DWARFDIE &die1, const DWARFDIE &die2)
Definition: SymbolFileDWARF.cpp:2869
lldb::eSectionTypeDWARFAppleNamespaces
@ eSectionTypeDWARFAppleNamespaces
Definition: lldb-enumerations.h:687
DWARFFormValue::Reference
DWARFDIE Reference() const
Definition: DWARFFormValue.cpp:502
LLDB_SCOPED_TIMERF
#define LLDB_SCOPED_TIMERF(...)
Definition: Timer.h:86
lldb::eSectionTypeDWARFAppleObjC
@ eSectionTypeDWARFAppleObjC
Definition: lldb-enumerations.h:688
DWARFDIE::GetParent
DWARFDIE GetParent() const
Definition: DWARFDIE.cpp:86
SymbolFileDWARF::InitializeFirstCodeAddressRecursive
void InitializeFirstCodeAddressRecursive(const lldb_private::SectionList &section_list)
Definition: SymbolFileDWARF.cpp:504
SymbolFileDWARF::m_dwo_warning_issued
std::atomic_flag m_dwo_warning_issued
Definition: SymbolFileDWARF.h:581
DWARFCompileUnit.h
DWARFDebugInfoEntry::GetOffset
dw_offset_t GetOffset() const
Definition: DWARFDebugInfoEntry.h:117
lldb::eValueTypeVariableGlobal
@ eValueTypeVariableGlobal
globals variable
Definition: lldb-enumerations.h:318
lldb_private::Block::GetBlockVariableList
lldb::VariableListSP GetBlockVariableList(bool can_create)
Get the variable list for this block only.
Definition: Block.cpp:399
lldb_private::Function::CalculateSymbolContextModule
lldb::ModuleSP CalculateSymbolContextModule() override
Definition: Function.cpp:408
lldb_private::RegularExpression
Definition: RegularExpression.h:18
DWARFBaseDIE::GetData
const lldb_private::DWARFDataExtractor & GetData() const
Definition: DWARFBaseDIE.cpp:130
FileSystem.h
lldb_private::DWARFContext::getOrLoadStrData
const DWARFDataExtractor & getOrLoadStrData()
Definition: DWARFContext.cpp:110
UNUSED_IF_ASSERT_DISABLED
#define UNUSED_IF_ASSERT_DISABLED(x)
Definition: lldb-defines.h:126
SymbolFileDWARF::m_abbr
std::unique_ptr< DWARFDebugAbbrev > m_abbr
Definition: SymbolFileDWARF.h:549
lldb_private::SymbolFileCommon::GetSymtab
Symtab * GetSymtab() override
Definition: SymbolFile.cpp:165
lldb_private::Address::Clear
void Clear()
Clear the object's state.
Definition: Address.h:178
lldb_private::Address::IsValid
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:345
SymbolFileDWARF::m_external_type_modules
ExternalTypeModuleMap m_external_type_modules
Definition: SymbolFileDWARF.h:556
SymbolFileDWARF::GetFile
lldb_private::FileSpec GetFile(DWARFUnit &unit, size_t file_idx)
Definition: SymbolFileDWARF.cpp:1031
CPlusPlusLanguage.h
CompilerDecl.h
lldb_private::CompilerDeclContext::GetScopeQualifiedName
ConstString GetScopeQualifiedName() const
Definition: CompilerDeclContext.cpp:31
DWARFBaseDIE::GetDIERef
llvm::Optional< DIERef > GetDIERef() const
Definition: DWARFBaseDIE.cpp:21
ClangModulesDeclVendor.h
DWARFDebugMacro.h
CompileUnit.h
ModuleSpec.h
SymbolFileDWARF::ParseLineTable
bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override
Definition: SymbolFileDWARF.cpp:1142
lldb_private::DebugMacros
Definition: DebugMacros.h:71
lldb_private::Function::GetAddressRange
const AddressRange & GetAddressRange()
Definition: Function.h:457
SymbolFileDWARF::ResolveTypeUID
lldb_private::Type * ResolveTypeUID(lldb::user_id_t type_uid) override
Definition: SymbolFileDWARF.cpp:1492
TypeMap.h
SymbolFileDWARF::ParseFunctions
size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override
Definition: SymbolFileDWARF.cpp:946
SymbolFileDWARF::m_parse_time
lldb_private::StatsDuration m_parse_time
Definition: SymbolFileDWARF.h:580
lldb_private::Value
Definition: Value.h:38
lldb_private::Symbol
Definition: Symbol.h:20
SymbolFileDWARF::ParseType
lldb::TypeSP ParseType(const lldb_private::SymbolContext &sc, const DWARFDIE &die, bool *type_is_new)
Definition: SymbolFileDWARF.cpp:3059
lldb_private::Symbol::ValueIsAddress
bool ValueIsAddress() const
Definition: Symbol.cpp:117
DWARFBaseDIE::Supports_DW_AT_APPLE_objc_complete_type
bool Supports_DW_AT_APPLE_objc_complete_type() const
Definition: DWARFBaseDIE.cpp:110
DWARFDebugAranges
Definition: DWARFDebugAranges.h:16
lldb_private::SourceLocationSpec
Definition: SourceLocationSpec.h:27
lldb_private::DataExtractor::ValidOffset
bool ValidOffset(lldb::offset_t offset) const
Test the validity of offset.
Definition: DataExtractor.h:956
SymbolFileDWARF::ParseVariableDIE
lldb::VariableSP ParseVariableDIE(const lldb_private::SymbolContext &sc, const DWARFDIE &die, const lldb::addr_t func_low_pc)
Definition: SymbolFileDWARF.cpp:3239
lldb_private::SymbolFile::VariableTypes
@ VariableTypes
Definition: SymbolFile.h:70
Host.h
SymbolFileDWARF::GetParentSymbolContextDIE
static DWARFDIE GetParentSymbolContextDIE(const DWARFDIE &die)
Definition: SymbolFileDWARF.cpp:390
lldb_private::DWARFExpressionList::LinkThreadLocalStorage
bool LinkThreadLocalStorage(lldb::ModuleSP new_module_sp, std::function< lldb::addr_t(lldb::addr_t file_addr)> const &link_address_callback)
Definition: DWARFExpressionList.cpp:96
SymbolFileDWARF::GetPluginNameStatic
static llvm::StringRef GetPluginNameStatic()
Definition: SymbolFileDWARF.h:88
lldb_private::contextMatches
bool contextMatches(llvm::ArrayRef< CompilerContext > context_chain, llvm::ArrayRef< CompilerContext > pattern)
Match context_chain against pattern, which may contain "Any" kinds.
Definition: Type.cpp:37
SymbolFileDWARF::ParseAndAppendGlobalVariable
void ParseAndAppendGlobalVariable(const lldb_private::SymbolContext &sc, const DWARFDIE &die, lldb_private::VariableList &cc_variable_list)
Definition: SymbolFileDWARF.cpp:3625
DWARFBaseDIE::GetAttributes
size_t GetAttributes(DWARFAttributes &attributes, Recurse recurse=Recurse::yes) const
Definition: DWARFBaseDIE.cpp:114
lldb_private::CompilerDeclContext::GetOpaqueDeclContext
void * GetOpaqueDeclContext() const
Definition: CompilerDeclContext.h:103
lldb_private::SymbolContextList::Append
void Append(const SymbolContext &sc)
Append a new symbol context to the list.
Definition: SymbolContext.cpp:1184
lldb_private::Value::GetValueType
ValueType GetValueType() const
Definition: Value.cpp:106
dw_tag_t
llvm::dwarf::Tag dw_tag_t
Definition: dwarf.h:28
SymbolFileDWARF::ParseLanguage
lldb::LanguageType ParseLanguage(lldb_private::CompileUnit &comp_unit) override
Definition: SymbolFileDWARF.cpp:909
DWARFASTParser::ParseChildArrayInfo
static llvm::Optional< lldb_private::SymbolFile::ArrayInfo > ParseChildArrayInfo(const DWARFDIE &parent_die, const lldb_private::ExecutionContext *exe_ctx=nullptr)
Definition: DWARFASTParser.cpp:22
lldb_private::SourceModule
Information needed to import a source-language module.
Definition: SourceModule.h:18
lldb_private::UserID
Definition: UserID.h:31
DWARFDebugInfo
Definition: DWARFDebugInfo.h:26
DWARFTypeUnit
Definition: DWARFTypeUnit.h:15
DWARFDebugInfo::GetNumUnits
size_t GetNumUnits()
Definition: DWARFDebugInfo.cpp:105
SymbolFileDWARF::m_unique_ast_type_map
UniqueDWARFASTTypeMap m_unique_ast_type_map
Definition: SymbolFileDWARF.h:565
DWARFFormValue::Address
dw_addr_t Address() const
Definition: DWARFFormValue.cpp:484
lldb_private::StatsDuration::Duration
std::chrono::duration< double > Duration
Definition: Statistics.h:30
SymbolFileDWARF::FindFunctions
void FindFunctions(const lldb_private::Module::LookupInfo &lookup_info, const lldb_private::CompilerDeclContext &parent_decl_ctx, bool include_inlines, lldb_private::SymbolContextList &sc_list) override
Definition: SymbolFileDWARF.cpp:2356
lldb_private::eLazyBoolYes
@ eLazyBoolYes
Definition: lldb-private-enumerations.h:115
lldb_private::ElapsedTime
A class that measures elapsed time in an exception safe way.
Definition: Statistics.h:67
DWARFUnit::GetDwoSymbolFile
SymbolFileDWARFDwo * GetDwoSymbolFile()
Definition: DWARFUnit.cpp:842
lldb_private::RangeVector::GetMinRangeBase
BaseType GetMinRangeBase(BaseType fail_value) const
Definition: RangeMap.h:261
SymbolFileDWARF::m_dwp_symfile_once_flag
llvm::once_flag m_dwp_symfile_once_flag
Definition: SymbolFileDWARF.h:541
Module.h
lldb::eSectionTypeDWARFDebugLine
@ eSectionTypeDWARFDebugLine
Definition: lldb-enumerations.h:676
SymbolFileDWARF::m_lldb_cu_to_dwarf_unit
std::vector< uint32_t > m_lldb_cu_to_dwarf_unit
Definition: SymbolFileDWARF.h:572
SymbolFileDWARF::GetTypeUnitSupportFiles
const lldb_private::FileSpecList & GetTypeUnitSupportFiles(DWARFTypeUnit &tu)
Definition: SymbolFileDWARF.cpp:1043
lldb_private::RangeVector::GetEntryRef
Entry & GetEntryRef(size_t i)
Definition: RangeMap.h:303
lldb_private::XcodeSDK
An abstraction for Xcode-style SDKs that works like ArchSpec.
Definition: XcodeSDK.h:24
DWARFDIE::GetDeclContextDIEs
std::vector< DWARFDIE > GetDeclContextDIEs() const
Definition: DWARFDIE.cpp:362
SymbolFileDWARF::ParseImportedModules
bool ParseImportedModules(const lldb_private::SymbolContext &sc, std::vector< lldb_private::SourceModule > &imported_modules) override
Definition: SymbolFileDWARF.cpp:1087
SymbolFileDWARF
Definition: SymbolFileDWARF.h:60
lldb_private::CompileUnit::SetVariableList
void SetVariableList(lldb::VariableListSP &variable_list_sp)
Set accessor for the variable list.
Definition: CompileUnit.cpp:391
lldb_private::VariableList::GetSize
size_t GetSize() const
Definition: VariableList.cpp:165
DIE_IS_BEING_PARSED
#define DIE_IS_BEING_PARSED
Definition: SymbolFileDWARF.h:58
DWARFUnit::HasAny
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:1075
SymbolFileDWARF.h
lldb::eSymbolTypeData
@ eSymbolTypeData
Definition: lldb-enumerations.h:625
lldb_private::SymbolContextList
Definition: SymbolContext.h:379
lldb_private::CompilerDecl
Represents a generic declaration such as a function declaration.
Definition: CompilerDecl.h:28
lldb_private::Module
Definition: Module.h:86
SymbolFileDWARF::GetDWARFCompileUnit
virtual DWARFCompileUnit * GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit)
Definition: SymbolFileDWARF.cpp:645
SymbolFileDWARFDebugMap::Supports_DW_AT_APPLE_objc_complete_type
bool Supports_DW_AT_APPLE_objc_complete_type(SymbolFileDWARF *skip_dwarf_oso)
Definition: SymbolFileDWARFDebugMap.cpp:1137
SymbolFileDWARF::Terminate
static void Terminate()
Definition: SymbolFileDWARF.cpp:259
lldb_private::ConstString::AsCString
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:192
LocateSymbolFile.h
lldb_private::Variable::GetSymbolContextScope
SymbolContextScope * GetSymbolContextScope() const
Definition: Variable.h:51
lldb_private::SectionList
Definition: Section.h:34
SymbolFileDWARF::ID
static char ID
LLVM RTTI support.
Definition: SymbolFileDWARF.h:63
lldb_private::Section::GetFileSize
lldb::offset_t GetFileSize() const
Definition: Section.h:152
lldb_private::CompilerType::GetOpaqueQualType
lldb::opaque_compiler_type_t GetOpaqueQualType() const
Definition: CompilerType.h:229
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext
virtual lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die)
Definition: SymbolFileDWARF.cpp:2950
DWARFDIE::GetDeclContext
void GetDeclContext(llvm::SmallVectorImpl< lldb_private::CompilerContext > &context) const
Return this DIE's decl context as it is needed to look up types in Clang's -gmodules debug info forma...
Definition: DWARFDIE.cpp:376
DWARFUnit::SetDwoError
void SetDwoError(const lldb_private::Status &error)
Set the fission .dwo file specific error for this compile unit.
Definition: DWARFUnit.h:286
DWARFBaseDIE::GetModule
lldb::ModuleSP GetModule() const
Definition: DWARFBaseDIE.cpp:84
SymbolFileDWARF::GetDebugRanges
DWARFDebugRanges * GetDebugRanges()
Definition: SymbolFileDWARF.cpp:658
DWARFBaseDIE::GetDWARF
SymbolFileDWARF * GetDWARF() const
Definition: DWARFBaseDIE.cpp:99
DWARFDebugAranges::FindAddress
dw_offset_t FindAddress(dw_addr_t address) const
Definition: DWARFDebugAranges.cpp:99
lldb_private::SymbolFile::CompileUnits
@ CompileUnits
Definition: SymbolFile.h:64
ManualDWARFIndex.h
SymbolFileDWARF::GetDIEToVariable
virtual DIEToVariableSP & GetDIEToVariable()
Definition: SymbolFileDWARF.h:510
DEBUG_PRINTF
#define DEBUG_PRINTF(fmt,...)
Definition: SymbolFileDWARF.cpp:95
lldb_private::Stream
Definition: Stream.h:28
lldb_private::FileSpec::MakeAbsolute
void MakeAbsolute(const FileSpec &dir)
Make the FileSpec absolute by treating it relative to dir.
Definition: FileSpec.cpp:514
lldb_private::Type::GetName
ConstString GetName()
Definition: Type.cpp:302
lldb_private::RangeData
Definition: RangeMap.h:415
lldb_private::DWARFDataExtractor
Definition: DWARFDataExtractor.h:18
SymbolFileDWARF::GetDWARFUnitIndex
llvm::Optional< uint32_t > GetDWARFUnitIndex(uint32_t cu_idx)
Definition: SymbolFileDWARF.cpp:796
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
Language.h
DWARFBaseDIE::GetCU
DWARFUnit * GetCU() const
Definition: DWARFBaseDIE.h:54
SymbolFileDWARF::FindNamespace
lldb_private::CompilerDeclContext FindNamespace(lldb_private::ConstString name, const lldb_private::CompilerDeclContext &parent_decl_ctx) override
Definition: SymbolFileDWARF.cpp:2634
dw_offset_t
uint32_t dw_offset_t
Definition: dwarf.h:33
SymbolFileDWARF::Supports_DW_AT_APPLE_objc_complete_type
bool Supports_DW_AT_APPLE_objc_complete_type(DWARFUnit *cu)
Definition: SymbolFileDWARF.cpp:2781
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:37
lldb_private::SymbolFileCommon
Containing protected virtual methods for child classes to override.
Definition: SymbolFile.h:424
DIERef::die_offset
dw_offset_t die_offset() const
Definition: DIERef.h:45
DWARFDebugInfo::GetCompileUnitAranges
const DWARFDebugAranges & GetCompileUnitAranges()
Definition: DWARFDebugInfo.cpp:36
lldb_private::SymbolContext
Definition: SymbolContext.h:33
Section.h
lldb_private::TypeMap::GetSize
uint32_t GetSize() const
Definition: TypeMap.cpp:75
SymbolFileDWARF::InitializeFirstCodeAddress
void InitializeFirstCodeAddress()
Definition: SymbolFileDWARF.cpp:497
lldb_private::SymbolFile::Functions
@ Functions
Definition: SymbolFile.h:66
SymbolFileDWARF::GetDynamicArrayInfoForUID
llvm::Optional< ArrayInfo > GetDynamicArrayInfoForUID(lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx) override
If type_uid points to an array type, return its characteristics.
Definition: SymbolFileDWARF.cpp:1504
ParseLLVMLineTable
static const llvm::DWARFDebugLine::LineTable * ParseLLVMLineTable(lldb_private::DWARFContext &context, llvm::DWARFDebugLine &line, dw_offset_t line_offset, dw_offset_t unit_offset)
Definition: SymbolFileDWARF.cpp:141
lldb_private::DWARFContext
Definition: DWARFContext.h:20
lldb_private::VariableList
Definition: VariableList.h:18
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
lldb_private::ModuleSpec::GetSymbolFileSpec
FileSpec & GetSymbolFileSpec()
Definition: ModuleSpec.h:77
DWARFAttributes
Definition: DWARFAttribute.h:44
SymbolFileDWARF::GetObjCMethods
virtual void GetObjCMethods(lldb_private::ConstString class_name, llvm::function_ref< bool(DWARFDIE die)> callback)
Definition: SymbolFileDWARF.cpp:1659
lldb_private::FileSpec::PrependPathComponent
void PrependPathComponent(llvm::StringRef component)
Definition: FileSpec.cpp:437
DWARFDeclContext.h
SymbolFileDWARF::GetDebugMapSymfile
SymbolFileDWARFDebugMap * GetDebugMapSymfile()
Definition: SymbolFileDWARF.cpp:4090
SymbolFileDWARF::FindGlobalVariables
void FindGlobalVariables(lldb_private::ConstString name, const lldb_private::CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, lldb_private::VariableList &variables) override
Definition: SymbolFileDWARF.cpp:2171
ClangUtil.h
DIEArray
std::vector< DIERef > DIEArray
Definition: DIERef.h:94
lldb_private::RangeDataVector::Entry
RangeData< B, S, T > Entry
Definition: RangeMap.h:443
lldb_private::CompileUnit
Definition: CompileUnit.h:38
lldb_private::TypeSystem::GetDWARFParser
virtual DWARFASTParser * GetDWARFParser()
Definition: TypeSystem.h:94
SymbolFileDWARF::ParseVariableDIECached
lldb::VariableSP ParseVariableDIECached(const lldb_private::SymbolContext &sc, const DWARFDIE &die)
Definition: SymbolFileDWARF.cpp:3219
lldb_private::VariableList::GetVariableAtIndex
lldb::VariableSP GetVariableAtIndex(size_t idx) const
Definition: VariableList.cpp:47
DWARFDIE
Definition: DWARFDIE.h:16
DWARFFormValue::Boolean
bool Boolean() const
Definition: DWARFFormValue.h:63
DWARFDeclContext::GetQualifiedNameAsConstString
lldb_private::ConstString GetQualifiedNameAsConstString() const
Definition: DWARFDeclContext.h:69
SymbolFileDWARF::DebuggerInitialize
static void DebuggerInitialize(lldb_private::Debugger &debugger)
Definition: SymbolFileDWARF.cpp:248
SymbolFileDWARF::GetMangledNamesForFunction
void GetMangledNamesForFunction(const std::string &scope_qualified_name, std::vector< lldb_private::ConstString > &mangled_names) override
Definition: SymbolFileDWARF.cpp:2451
Target.h
SymbolFileDWARF::ParseCompileUnit
lldb::CompUnitSP ParseCompileUnit(DWARFCompileUnit &dwarf_cu)
Definition: SymbolFileDWARF.cpp:698
lldb_private::Properties
Definition: UserSettingsController.h:33
lldb_private::Value::GetScalar
const Scalar & GetScalar() const
Definition: Value.h:112
lldb_private::ObjectFile::GetSymtab
Symtab * GetSymtab()
Gets the symbol table for the currently selected architecture (and object for archives).
Definition: ObjectFile.cpp:725
lldb_private::Block::AddRange
void AddRange(const Range &range)
Add a new offset range to this block.
Definition: Block.cpp:335
SymbolFileDWARF::GetDeclForUID
lldb_private::CompilerDecl GetDeclForUID(lldb::user_id_t uid) override
Definition: SymbolFileDWARF.cpp:1456
lldb_private::Symtab::FindFirstSymbolWithNameAndType
Symbol * FindFirstSymbolWithNameAndType(ConstString name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility)
Definition: Symtab.cpp:861
lldb_private::Module::LookupInfo
Definition: Module.h:936
SymbolFileDWARF::m_first_code_address
lldb::addr_t m_first_code_address
DWARF does not provide a good way for traditional (concatenating) linkers to invalidate debug info de...
Definition: SymbolFileDWARF.h:579
SymbolFileDWARF::ParseCompileUnitAtIndex
lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override
Definition: SymbolFileDWARF.cpp:811
DWARFUnit::GetDWARFLanguageType
uint64_t GetDWARFLanguageType()
Definition: DWARFUnit.cpp:737
lldb_private::FileSpec
Definition: FileSpec.h:55
SymbolFileDWARFDwo.h
DWARFCompileUnit
Definition: DWARFCompileUnit.h:15
elapsed
static double elapsed(const StatsTimepoint &start, const StatsTimepoint &end)
Definition: Statistics.cpp:36
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
SymbolFileDWARF::ResolveSymbolContext
uint32_t ResolveSymbolContext(const lldb_private::Address &so_addr, lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContext &sc) override
DWARFDIE::GetPubname
const char * GetPubname() const
Definition: DWARFDIE.cpp:206
DWARFUnit::GetAddressByteSize
uint8_t GetAddressByteSize() const
Definition: DWARFUnit.h:157
lldb_private::DWARFContext::GetAsLLVM
llvm::DWARFContext & GetAsLLVM()
Definition: DWARFContext.cpp:126
SymbolFileDWARFDebugMap::Terminate
static void Terminate()
Definition: SymbolFileDWARFDebugMap.cpp:232
SymbolFileDWARF::UpdateExternalModuleListIfNeeded
void UpdateExternalModuleListIfNeeded()
Definition: SymbolFileDWARF.cpp:1813
lldb_private::CompilerDeclContext::IsValid
bool IsValid() const
Definition: CompilerDeclContext.h:55
lldb_private::SymbolFileCommon::m_objfile_sp
lldb::ObjectFileSP m_objfile_sp
Definition: SymbolFile.h:500
SymbolFileDWARF::CreateInstance
static lldb_private::SymbolFile * CreateInstance(lldb::ObjectFileSP objfile_sp)
Definition: SymbolFileDWARF.cpp:269
lldb_private::LineTable
Definition: LineTable.h:40
lldb_private::Function
Definition: Function.h:409
SymbolFileDWARF::ForEachExternalModule
bool ForEachExternalModule(lldb_private::CompileUnit &, llvm::DenseSet< lldb_private::SymbolFile * > &, llvm::function_ref< bool(lldb_private::Module &)>) override
Definition: SymbolFileDWARF.cpp:969
DWARFUnit
Definition: DWARFUnit.h:83
SymbolFileDWARF::SymbolFileDWARF
SymbolFileDWARF(lldb::ObjectFileSP objfile_sp, lldb_private::SectionList *dwo_section_list)
SymbolFileDWARF::GetForwardDeclClangTypeToDie
virtual ClangTypeToDIE & GetForwardDeclClangTypeToDie()
Definition: SymbolFileDWARF.h:516
lldb_private::CompilerType::GetTypeSystem
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
Definition: CompilerType.cpp:980
ModuleList.h
SymbolFileDWARF::ResolveFunction
bool ResolveFunction(const DWARFDIE &die, bool include_inlines, lldb_private::SymbolContextList &sc_list)
Definition: SymbolFileDWARF.cpp:2287
DWARFASTParser::ParseFunctionFromDWARF
virtual lldb_private::Function * ParseFunctionFromDWARF(lldb_private::CompileUnit &comp_unit, const DWARFDIE &die, const lldb_private::AddressRange &range)=0
lldb::eSectionTypeDWARFDebugAbbrev
@ eSectionTypeDWARFDebugAbbrev
Definition: lldb-enumerations.h:670
DWARFUnit::GetCompilationDirectory
const lldb_private::FileSpec & GetCompilationDirectory()
Definition: DWARFUnit.cpp:769
lldb_private::Function::GetCompileUnit
CompileUnit * GetCompileUnit()
Get accessor for the compile unit that owns this function.
Definition: Function.cpp:360
DWARFBaseDIE::Recurse::no
@ no
dwarf
Definition: ABISysV_arc.cpp:61
GetFileByIndex
static llvm::Optional< std::string > GetFileByIndex(const llvm::DWARFDebugLine::Prologue &prologue, size_t idx, llvm::StringRef compile_dir, FileSpec::Style style)
Definition: SymbolFileDWARF.cpp:192
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb_private::ConstString::GetStringRef
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:201
lldb_private::Scalar::ULongLong
unsigned long long ULongLong(unsigned long long fail_value=0) const
Definition: Scalar.cpp:334
SymbolFileDWARF::GetDwoSymbolFileForCompileUnit
std::shared_ptr< SymbolFileDWARFDwo > GetDwoSymbolFileForCompileUnit(DWARFUnit &dwarf_cu, const DWARFDebugInfoEntry &cu_die)
Definition: SymbolFileDWARF.cpp:1729
SymbolFileDWARF::GetTypeSystem
static llvm::Expected< lldb::TypeSystemSP > GetTypeSystem(DWARFUnit &unit)
Definition: SymbolFileDWARF.cpp:4128
lldb_private::SymbolFile::LocalVariables
@ LocalVariables
Definition: SymbolFile.h:69
lldb_private::SymbolContextScope::CalculateSymbolContextCompileUnit
virtual CompileUnit * CalculateSymbolContextCompileUnit()
Definition: SymbolContextScope.h:82
TypeSystemClang.h
lldb_private::ConstString::IsEmpty
bool IsEmpty() const
Test for empty string.
Definition: ConstString.h:303
SymbolFileDWARF::DeclContextMatchesThisSymbolFile
bool DeclContextMatchesThisSymbolFile(const lldb_private::CompilerDeclContext &decl_ctx)
Definition: SymbolFileDWARF.cpp:2140
SymbolFileDWARF::GetGlobalAranges
GlobalVariableMap & GetGlobalAranges()
Definition: SymbolFileDWARF.cpp:1915
lldb::eSectionTypeDWARFDebugStr
@ eSectionTypeDWARFDebugStr
Definition: lldb-enumerations.h:683
ParseSupportFilesFromPrologue
static FileSpecList ParseSupportFilesFromPrologue(const lldb::ModuleSP &module, const llvm::DWARFDebugLine::Prologue &prologue, FileSpec::Style style, llvm::StringRef compile_dir={})
Definition: SymbolFileDWARF.cpp:209
lldb_private::Declaration::SetColumn
void SetColumn(uint16_t column)
Set accessor for the declaration column number.
Definition: Declaration.h:175
lldb_private::TypeList::Insert
void Insert(const lldb::TypeSP &type)
Definition: TypeList.cpp:27
lldb_private::DWARFExpression::Update_DW_OP_addr
bool Update_DW_OP_addr(const DWARFUnit *dwarf_cu, lldb::addr_t file_addr)
Definition: DWARFExpression.cpp:382
lldb_private::Function::GetBlock
Block & GetBlock(bool can_create)
Get accessor for the block list.
Definition: Function.cpp:345
MakeAbsoluteAndRemap
static void MakeAbsoluteAndRemap(FileSpec &file_spec, DWARFUnit &dwarf_cu, const ModuleSP &module_sp)
Make an absolute path out of file_spec and remap it using the module's source remapping dictionary.
Definition: SymbolFileDWARF.cpp:674
lldb_private::DWARFExpressionList::ContainsThreadLocalStorage
bool ContainsThreadLocalStorage() const
Definition: DWARFExpressionList.cpp:85
DWARFDebugMacroHeader::OffsetIs64Bit
bool OffsetIs64Bit() const
Definition: DWARFDebugMacro.h:39
DWARFDebugAbbrev::GetUnsupportedForms
void GetUnsupportedForms(std::set< dw_form_t > &invalid_forms) const
Definition: DWARFDebugAbbrev.cpp:141
DWARFDeclContext::GetQualifiedName
const char * GetQualifiedName() const
Definition: DWARFDeclContext.cpp:13
lldb_private::Status::Fail
bool Fail() const
Test for error condition.
Definition: Status.cpp:181
DWARFDebugInfo::GetUnitAtIndex
DWARFUnit * GetUnitAtIndex(size_t idx)
Definition: DWARFDebugInfo.cpp:110
lldb_private::Block::AddChild
void AddChild(const lldb::BlockSP &child_block_sp)
Add a child to this object.
Definition: Block.cpp:385
Progress.h
lldb_private::StreamString::GetData
const char * GetData() const
Definition: StreamString.h:43
DWARFBaseDIE::GetTagAsCString
const char * GetTagAsCString() const
Definition: DWARFBaseDIE.cpp:36
lldb_private::DWARFExpression::DumpLocation
void DumpLocation(Stream *s, lldb::DescriptionLevel level, ABI *abi) const
Definition: DWARFExpression.cpp:70
DWARFDIE::GetName
void GetName(lldb_private::Stream &s) const
Definition: DWARFDIE.cpp:218
DWARFBaseDIE::Clear
void Clear()
Definition: DWARFBaseDIE.h:69
DWARFBaseDIE::GetDIE
DWARFDebugInfoEntry * GetDIE() const
Definition: DWARFBaseDIE.h:56
lldb_private::Section::GetChildren
SectionList & GetChildren()
Definition: Section.h:132
SymbolFileDWARF::LoadSectionData
virtual void LoadSectionData(lldb::SectionType sect_type, lldb_private::DWARFDataExtractor &data)
Definition: SymbolFileDWARF.cpp:600
lldb_private::CallSiteParameterArray
llvm::SmallVector< CallSiteParameter, 0 > CallSiteParameterArray
A vector of CallSiteParameter.
Definition: Function.h:261
DWARFUnit::GetDWOId
llvm::Optional< uint64_t > GetDWOId()
Definition: DWARFUnit.cpp:361
lldb_private::SymbolContextScope::CalculateSymbolContext
virtual void CalculateSymbolContext(SymbolContext *sc)=0
Reconstruct the object's symbol context into sc.
DWARFUnit::GetPathStyle
lldb_private::FileSpec::Style GetPathStyle()
Definition: DWARFUnit.cpp:763
lldb_private::SymbolContext::function
Function * function
The Function for a given query.
Definition: SymbolContext.h:320
StreamString.h
lldb_private::Address::GetFileAddress
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:291
SymbolFileDWARF::GetLanguageFamily
static lldb::LanguageType GetLanguageFamily(DWARFUnit &unit)
Same as GetLanguage() but reports all C++ versions as C++ (no version).
Definition: SymbolFileDWARF.cpp:4188
SymbolFileDWARF::FindBlockContainingSpecification
DWARFDIE FindBlockContainingSpecification(const DIERef &func_die_ref, dw_offset_t spec_block_die_offset)
Definition: SymbolFileDWARF.cpp:3582
SymbolFileDWARF::ResolveFunctionAndBlock
void ResolveFunctionAndBlock(lldb::addr_t file_vm_addr, bool lookup_block, lldb_private::SymbolContext &sc)
Resolve functions and (possibly) blocks for the given file address and a compile unit.
Definition: SymbolFileDWARF.cpp:1962
lldb_private::Symbol::GetAddressRef
Address & GetAddressRef()
Definition: Symbol.h:57
DWARFASTParser.h
lldb_private::DWARFExpression
Definition: DWARFExpression.h:36
DWARFDIE::GetMangledName
const char * GetMangledName() const
Definition: DWARFDIE.cpp:199
lldb_private::ClangASTImporter::CompleteType
bool CompleteType(const CompilerType &compiler_type)
Definition: ClangASTImporter.cpp:505
lldb_private::DebugMacrosSP
std::shared_ptr< DebugMacros > DebugMacrosSP
Definition: DebugMacros.h:21
DWARFFormValue::Form
dw_form_t Form() const
Definition: DWARFFormValue.h:47
DWARFASTParser::EnsureAllDIEsInDeclContextHaveBeenParsed
virtual void EnsureAllDIEsInDeclContextHaveBeenParsed(lldb_private::CompilerDeclContext decl_context)=0
SymbolFileDWARF::GetModuleMutex
std::recursive_mutex & GetModuleMutex() const override
Symbols file subclasses should override this to return the Module that owns the TypeSystem that this ...
Definition: SymbolFileDWARF.cpp:2133
lldb_private::DataExtractor::GetDataStart
const uint8_t * GetDataStart() const
Get the data start pointer.
Definition: DataExtractor.h:422
lldb_private::SymbolContextList::GetSize
uint32_t GetSize() const
Get accessor for a symbol context list size.
Definition: SymbolContext.cpp:1274
SymbolFileDWARFDebugMap::GetCompileUnit
lldb::CompUnitSP GetCompileUnit(SymbolFileDWARF *oso_dwarf, DWARFCompileUnit &dwarf_cu)
Returns the compile unit associated with the dwarf compile unit.
Definition: SymbolFileDWARFDebugMap.cpp:1267
lldb_private::ConstString
Definition: ConstString.h:39
SymbolFileDWARFDebugMap
Definition: SymbolFileDWARFDebugMap.h:26
GetGlobalPluginProperties
static PluginProperties & GetGlobalPluginProperties()
Definition: SymbolFileDWARF.cpp:135
lldb_private::StreamString
Definition: StreamString.h:23
lldb::eSectionTypeDWARFDebugInfo
@ eSectionTypeDWARFDebugInfo
Definition: lldb-enumerations.h:675
lldb::eLanguageTypeC_plus_plus
@ eLanguageTypeC_plus_plus
ISO C++:1998.
Definition: lldb-enumerations.h:442
lldb::eDescriptionLevelFull
@ eDescriptionLevelFull
Definition: lldb-enumerations.h:210
lldb_private::AddressRange
Definition: AddressRange.h:25
Timer.h
DWARFDebugAranges.h
lldb_private::Module::LookupInfo::SetLookupName
void SetLookupName(ConstString name)
Definition: Module.h:949
DWARFASTParser::GetDeclContextForUIDFromDWARF
virtual lldb_private::CompilerDeclContext GetDeclContextForUIDFromDWARF(const DWARFDIE &die)=0
SymbolFileDWARF::GetDWARFDeclContext
static DWARFDeclContext GetDWARFDeclContext(const DWARFDIE &die)
Definition: SymbolFileDWARF.cpp:4163
lldb_private::Progress
A Progress indicator helper class.
Definition: Progress.h:55
DWARFFormValue
Definition: DWARFFormValue.h:20
lldb_private::CompileUnit::SetSupportFiles
void SetSupportFiles(const FileSpecList &support_files)
Definition: CompileUnit.cpp:180
SymbolFileDWARF::GetDIEToType
virtual DIEToTypePtr & GetDIEToType()
Definition: SymbolFileDWARF.h:508
SymbolFileDWARF::GetDwpSymbolFile
const std::shared_ptr< SymbolFileDWARFDwo > & GetDwpSymbolFile()
Definition: SymbolFileDWARF.cpp:4101
SymbolFileDWARF::m_debug_map_symfile
SymbolFileDWARFDebugMap * m_debug_map_symfile
Definition: SymbolFileDWARF.h:539
lldb_private::CompileUnit::SetLineTable
void SetLineTable(LineTable *line_table)
Set the line table for the compile unit.
Definition: CompileUnit.cpp:172
lldb_private::Declaration::SetFile
void SetFile(const FileSpec &file_spec)
Set accessor for the declaration file specification.
Definition: Declaration.h:161
SymbolFileDWARF::ParseTypes
size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override
Definition: SymbolFileDWARF.cpp:3155
SymbolFileDWARF::Dump
void Dump(lldb_private::Stream &s) override
Definition: SymbolFileDWARF.cpp:4074
lldb_private::Range
Definition: Process.h:61
SymbolFileDWARF::SupportedVersion
static bool SupportedVersion(uint16_t version)
Definition: SymbolFileDWARF.cpp:516
lldb::eSectionTypeDWARFAppleTypes
@ eSectionTypeDWARFAppleTypes
Definition: lldb-enumerations.h:686
lldb::eSectionTypeDWARFAppleNames
@ eSectionTypeDWARFAppleNames
Definition: lldb-enumerations.h:685
lldb_private::DWARFExpression::GetLocation_DW_OP_addr
lldb::addr_t GetLocation_DW_OP_addr(const DWARFUnit *dwarf_cu, uint32_t op_addr_idx, bool &error) const
If a location is not a location list, return true if the location contains a DW_OP_addr () opcode in ...
Definition: DWARFExpression.cpp:344
LLDB_SCOPED_TIMER
#define LLDB_SCOPED_TIMER()
Definition: Timer.h:83
SymbolFileDWARF::DIEInDeclContext
static bool DIEInDeclContext(const lldb_private::CompilerDeclContext &parent_decl_ctx, const DWARFDIE &die)
Definition: SymbolFileDWARF.cpp:2338
DWARFDIE::GetReferencedDIE
DWARFDIE GetReferencedDIE(const dw_attr_t attr) const
Definition: DWARFDIE.cpp:110
LogChannelDWARF.h
lldb::eSymbolTypeObjCClass
@ eSymbolTypeObjCClass
Definition: lldb-enumerations.h:647
lldb_private::SourceModule::sysroot
ConstString sysroot
Definition: SourceModule.h:22
SymbolFileDWARF::GetTypeForDIE
lldb::TypeSP GetTypeForDIE(const DWARFDIE &die, bool resolve_function_context=false)
Definition: SymbolFileDWARF.cpp:2676
lldb_private::SymbolContext::variable
Variable * variable
The global variable matching the given query.
Definition: SymbolContext.h:324
SymbolFileDWARF::m_dwp_symfile
std::shared_ptr< SymbolFileDWARFDwo > m_dwp_symfile
Definition: SymbolFileDWARF.h:542
DWARFFormValue::IsBlockForm
static bool IsBlockForm(const dw_form_t form)
Definition: DWARFFormValue.cpp:569
lldb_private::Debugger
Definition: Debugger.h:74
lldb_private::CompileUnit::SetDebugMacros
void SetDebugMacros(const DebugMacrosSP &debug_macros)
Definition: CompileUnit.cpp:200
lldb_private::CompileUnit::GetPrimaryFile
const FileSpec & GetPrimaryFile() const
Return the primary source file associated with this compile unit.
Definition: CompileUnit.h:227
SymbolFileDWARF::GetDeclContextForUID
lldb_private::CompilerDeclContext GetDeclContextForUID(lldb::user_id_t uid) override
Definition: SymbolFileDWARF.cpp:1469
lldb::eValueTypeVariableArgument
@ eValueTypeVariableArgument
function argument variables
Definition: lldb-enumerations.h:320
DWARFBaseDIE::GetAttributeValueAsString
const char * GetAttributeValueAsString(const dw_attr_t attr, const char *fail_value) const
Definition: DWARFBaseDIE.cpp:40
lldb_private::CallSiteParameter
Definition: Function.h:255
DWARFDebugRanges
Definition: DWARFDebugRanges.h:20
lldb_private::Block::SetInlinedFunctionInfo
void SetInlinedFunctionInfo(const char *name, const char *mangled, const Declaration *decl_ptr, const Declaration *call_decl_ptr)
Set accessor for any inlined function information.
Definition: Block.cpp:392
lldb_private::SymbolFileCommon::GetNumCompileUnits
uint32_t GetNumCompileUnits() override
Definition: SymbolFile.cpp:193
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
DWARFDIE::GetFirstChild
DWARFDIE GetFirstChild() const
Definition: DWARFDIE.cpp:94
DWARFDebugInfo.h
lldb_private::RangeVector::GetMaxRangeEnd
BaseType GetMaxRangeEnd(BaseType fail_value) const
Definition: RangeMap.h:272
lldb_private::Address::GetSection
lldb::SectionSP GetSection() const
Get const accessor for the section.
Definition: Address.h:429
AppleDWARFIndex.h
SymbolFileDWARF::GetExternalModule
lldb::ModuleSP GetExternalModule(lldb_private::ConstString name)
Definition: SymbolFileDWARF.cpp:1685
SymbolFileDWARF::GetObjCClassSymbol
lldb_private::Symbol * GetObjCClassSymbol(lldb_private::ConstString objc_class_name)
Definition: SymbolFileDWARF.cpp:2761
DWARFUnit.h
lldb_private::CompileUnit::GetLineTable
LineTable * GetLineTable()
Get the line table for the compile unit.
Definition: CompileUnit.cpp:161
lldb_private::CompileUnit::GetLanguage
lldb::LanguageType GetLanguage()
Definition: CompileUnit.cpp:150
lldb_private::CompilerDeclContext::GetName
ConstString GetName() const
Definition: CompilerDeclContext.cpp:25
TypeSystem.h
SymbolFileDWARFDebugMap::Initialize
static void Initialize()
Definition: SymbolFileDWARFDebugMap.cpp:227
DWARFUnit::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Definition: DWARFUnit.cpp:615
lldb_private::DWARFExpressionList::IsValid
bool IsValid() const
Return true if the location expression contains data.
Definition: DWARFExpressionList.h:40
DWARFAttributes::ExtractFormValueAtIndex
bool ExtractFormValueAtIndex(uint32_t i, DWARFFormValue &form_value) const
Definition: DWARFAttribute.cpp:38
lldb_private::RangeVector
Definition: RangeMap.h:136
DWARFDebugMacroEntry::ReadMacroEntries
static void ReadMacroEntries(const lldb_private::DWARFDataExtractor &debug_macro_data, const lldb_private::DWARFDataExtractor &debug_str_data, const bool offset_is_64_bit, lldb::offset_t *sect_offset, SymbolFileDWARF *sym_file_dwarf, lldb_private::DebugMacrosSP &debug_macros_sp)
Definition: DWARFDebugMacro.cpp:60
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:527
GetDWOId
static llvm::Optional< uint64_t > GetDWOId(DWARFCompileUnit &dwarf_cu, const DWARFDebugInfoEntry &cu_die)
Return the DW_AT_(GNU_)dwo_id.
Definition: SymbolFileDWARF.cpp:1709
SymbolFileDWARF::ParseXcodeSDK
lldb_private::XcodeSDK ParseXcodeSDK(lldb_private::CompileUnit &comp_unit) override
Return the Xcode SDK comp_unit was compiled against.
Definition: SymbolFileDWARF.cpp:918
DWARFFormValue::Unsigned
uint64_t Unsigned() const
Definition: DWARFFormValue.h:64
VariableList.h
SymbolFileDWARF::CollectCallEdges
std::vector< std::unique_ptr< lldb_private::CallEdge > > CollectCallEdges(lldb::ModuleSP module, DWARFDIE function_die)
Parse call site entries (DW_TAG_call_site), including any nested call site parameters (DW_TAG_call_si...
Definition: SymbolFileDWARF.cpp:3903
lldb_private::TypeMap
Definition: TypeMap.h:20
UniqueDWARFASTTypeMap
Definition: UniqueDWARFASTType.h:71
SymbolFileDWARF::GetDWARFParser
static DWARFASTParser * GetDWARFParser(DWARFUnit &unit)
Definition: SymbolFileDWARF.cpp:4132
DWARFUnit::GetLineTableOffset
dw_offset_t GetLineTableOffset()
Definition: DWARFUnit.cpp:439
lldb_private::CompilerDeclContext
Represents a generic declaration context in a program.
Definition: CompilerDeclContext.h:30
SymbolFileDWARF::m_info_once_flag
llvm::once_flag m_info_once_flag
Definition: SymbolFileDWARF.h:546
OptionValueProperties.h
DWARFUnit::dies
die_iterator_range dies()
Definition: DWARFUnit.h:216
lldb_private::DWARFExpression::UpdateValue
void UpdateValue(uint64_t const_value, lldb::offset_t const_value_byte_size, uint8_t addr_byte_size)
Definition: DWARFExpression.cpp:58
SymbolFileDWARF::DecodedUID
Definition: SymbolFileDWARF.h:523
lldb_private::SymbolContextScope
Definition: SymbolContextScope.h:64
ObjectFile.h
DWARFASTParserClang::GetClangASTImporter
lldb_private::ClangASTImporter & GetClangASTImporter()
Definition: DWARFASTParserClang.cpp:79
SymbolFileDWARF::ParseVariablesForContext
size_t ParseVariablesForContext(const lldb_private::SymbolContext &sc) override
Definition: SymbolFileDWARF.cpp:3171
lldb_private::UserID::GetID
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47
SymbolFileDWARF::m_function_scope_qualified_name_map
NameToOffsetMap m_function_scope_qualified_name_map
Definition: SymbolFileDWARF.h:563
lldb_private::DWARFExpressionList::Evaluate
bool Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx, lldb::addr_t func_load_addr, const Value *initial_value_ptr, const Value *object_address_ptr, Value &result, Status *error_ptr) const
Definition: DWARFExpressionList.cpp:201
DWARFUnit::GetOffset
dw_offset_t GetOffset() const
Definition: DWARFUnit.h:133
DWARFUnit::IsDWOUnit
bool IsDWOUnit()
Definition: DWARFUnit.h:94
SymbolFileDWARF::ParseIsOptimized
bool ParseIsOptimized(lldb_private::CompileUnit &comp_unit) override
Definition: SymbolFileDWARF.cpp:1079
SymbolFileDWARF::MergeBlockAbstractParameters
DIEArray MergeBlockAbstractParameters(const DWARFDIE &block_die, DIEArray &&variable_dies)
Definition: SymbolFileDWARF.cpp:3681
DWARFDebugMacroHeader
Definition: DWARFDebugMacro.h:27
SymbolFileDWARF::TypeSet
llvm::SetVector< lldb_private::Type * > TypeSet
Definition: SymbolFileDWARF.h:494
CollectCallSiteParameters
static CallSiteParameterArray CollectCallSiteParameters(ModuleSP module, DWARFDIE call_site_die)
Collect call site parameters in a DW_TAG_call_site DIE.
Definition: SymbolFileDWARF.cpp:3855
DWARFDebugAbbrev
Definition: DWARFDebugAbbrev.h:64
lldb_private::DWARFExpressionList::SetFuncFileAddress
void SetFuncFileAddress(lldb::addr_t func_file_addr)
Definition: DWARFExpressionList.h:57
lldb_private::Section
Definition: Section.h:102
DWARFFormValue::GetUnit
const DWARFUnit * GetUnit() const
Definition: DWARFFormValue.h:45
SymbolFileDWARF::m_context
lldb_private::DWARFContext m_context
Definition: SymbolFileDWARF.h:544
DWARFFormValue::IsDataForm
static bool IsDataForm(const dw_form_t form)
Definition: DWARFFormValue.cpp:581
lldb_private::DWARFContext::getOrLoadRangesData
const DWARFDataExtractor & getOrLoadRangesData()
Definition: DWARFContext.cpp:99
ASSERT_MODULE_LOCK
#define ASSERT_MODULE_LOCK(expr)
Definition: SymbolFile.h:35
DW_INVALID_INDEX
#define DW_INVALID_INDEX
Definition: dwarf.h:38
lldb_private::FileSpec::Style
llvm::sys::path::Style Style
Definition: FileSpec.h:57
SymbolFileDWARF::ResolveType
lldb_private::Type * ResolveType(const DWARFDIE &die, bool assert_not_being_parsed=true, bool resolve_function_context=false)
Definition: SymbolFileDWARF.cpp:1621
StreamFile.h
lldb::eSectionTypeCode
@ eSectionTypeCode
Definition: lldb-enumerations.h:655
lldbassert
#define lldbassert(x)
Definition: LLDBAssert.h:15
SymbolFileDWARF::CompleteType
bool CompleteType(lldb_private::CompilerType &compiler_type) override
Definition: SymbolFileDWARF.cpp:1576
SymbolFileDWARF::DIEToVariableSP
llvm::DenseMap< const DWARFDebugInfoEntry *, lldb::VariableSP > DIEToVariableSP
Definition: SymbolFileDWARF.h:353
lldb_private::TypeMap::InsertUnique
bool InsertUnique(const lldb::TypeSP &type)
Definition: TypeMap.cpp:34
SymbolFileDWARF::FixupAddress
lldb::addr_t FixupAddress(lldb::addr_t file_addr)
If this symbol file is linked to by a debug map (see SymbolFileDWARFDebugMap), and file_addr is a fil...
Definition: SymbolFileDWARF.cpp:894
lldb_private::TypeSystem::GetMinimumLanguage
virtual lldb::LanguageType GetMinimumLanguage(lldb::opaque_compiler_type_t type)=0
lldb_private::SectionList::FindSectionByType
lldb::SectionSP FindSectionByType(lldb::SectionType sect_type, bool check_children, size_t start_idx=0) const
Definition: Section.cpp:586
SymbolFileDWARF::m_index
std::unique_ptr< lldb_private::DWARFIndex > m_index
Definition: SymbolFileDWARF.h:557
lldb_private::VariableList::RemoveVariableAtIndex
lldb::VariableSP RemoveVariableAtIndex(size_t idx)
Definition: VariableList.cpp:54
lldb_private::Block::SetVariableList
void SetVariableList(lldb::VariableListSP &variable_list_sp)
Set accessor for the variable list.
Definition: Block.h:331
DWARFASTParserClang
Definition: DWARFASTParserClang.h:38
lldb_private::ModuleSpec::GetFileSpec
FileSpec & GetFileSpec()
Definition: ModuleSpec.h:53
lldb_private::ModuleSpec
Definition: ModuleSpec.h:27
SymbolFileDWARF::ConstructFunctionDemangledName
lldb_private::ConstString ConstructFunctionDemangledName(const DWARFDIE &die)
Definition: SymbolFileDWARF.cpp:869
SymbolFileDWARF::GetDecl
static lldb_private::CompilerDecl GetDecl(const DWARFDIE &die)
Definition: SymbolFileDWARF.cpp:4144
DWARFBaseDIE::GetAttributeValueAsUnsigned
uint64_t GetAttributeValueAsUnsigned(const dw_attr_t attr, uint64_t fail_value) const
Definition: DWARFBaseDIE.cpp:48
SymbolFileDWARF::LanguageTypeFromDWARF
static lldb::LanguageType LanguageTypeFromDWARF(uint64_t val)
Definition: SymbolFileDWARF.cpp:4171
lldb::eValueTypeVariableLocal
@ eValueTypeVariableLocal
function local variables
Definition: lldb-enumerations.h:321
lldb_private::Status
Definition: Status.h:44
lldb_private::Module::LookupInfo::GetLookupName
ConstString GetLookupName() const
Definition: Module.h:947
SymbolFileDWARF::ParseFunction
lldb_private::Function * ParseFunction(lldb_private::CompileUnit &comp_unit, const DWARFDIE &die)
Definition: SymbolFileDWARF.cpp:821
SymbolFileDWARF::GetLanguage
static lldb::LanguageType GetLanguage(DWARFUnit &unit)
Definition: SymbolFileDWARF.cpp:4184
lldb_private::FileSpec::IsRelative
bool IsRelative() const
Returns true if the filespec represents a relative path.
Definition: FileSpec.cpp:491
lldb::ValueType
ValueType
Definition: lldb-enumerations.h:316
SymbolFileDWARF::m_global_aranges_up
std::unique_ptr< GlobalVariableMap > m_global_aranges_up
Definition: SymbolFileDWARF.h:550
SymbolFileDWARF::ParseDebugMacros
bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override
Definition: SymbolFileDWARF.cpp:1227
lldb_private::Block
Definition: Block.h:41
lldb_private::Symtab
Definition: Symtab.h:22
SymbolFileDWARF::GetPluginDescriptionStatic
static llvm::StringRef GetPluginDescriptionStatic()
Definition: SymbolFileDWARF.cpp:265
uint32_t
DWARFDebugInfo::GetUnitAtOffset
DWARFUnit * GetUnitAtOffset(DIERef::Section section, dw_offset_t cu_offset, uint32_t *idx_ptr=nullptr)
Definition: DWARFDebugInfo.cpp:135
SymbolFileDWARFDebugMap::LinkOSOAddress
bool LinkOSOAddress(lldb_private::Address &addr)
Convert addr from a .o file address, to an executable address.
Definition: SymbolFileDWARFDebugMap.cpp:1418
DWARFASTParser
Definition: DWARFASTParser.h:26
lldb_private::eLazyBoolNo
@ eLazyBoolNo
Definition: lldb-private-enumerations.h:115
SymbolFileDWARF::GetTypeList
lldb_private::TypeList & GetTypeList() override
Definition: SymbolFileDWARF.cpp:274
DWARFDebugInfoEntry.h
DWARFUnit::GetUnitDIEOnly
DWARFBaseDIE GetUnitDIEOnly()
Definition: DWARFUnit.h:177
DWARFUnit::GetVersion
uint16_t GetVersion() const
Definition: DWARFUnit.h:154
lldb::SectionType
SectionType
Definition: lldb-enumerations.h:653
SymbolFileDWARF::m_fetched_external_modules
bool m_fetched_external_modules
Definition: SymbolFileDWARF.h:558
DWARFFormValue::BlockData
const uint8_t * BlockData() const
Definition: DWARFFormValue.cpp:567
SymbolFileDWARF::m_debug_map_module_wp
lldb::ModuleWP m_debug_map_module_wp
Definition: SymbolFileDWARF.h:538
SymbolFileDWARF::Initialize
static void Initialize()
Definition: SymbolFileDWARF.cpp:240
lldb_private::Address
Definition: Address.h:59
SymbolFileDWARF::m_ranges
std::unique_ptr< DWARFDebugRanges > m_ranges
Definition: SymbolFileDWARF.h:564
lldb::eSectionTypeDWARFDebugNames
@ eSectionTypeDWARFDebugNames
DWARF v5 .debug_names.
Definition: lldb-enumerations.h:703
DWARFASTParser::ParseTypeFromDWARF
virtual lldb::TypeSP ParseTypeFromDWARF(const lldb_private::SymbolContext &sc, const DWARFDIE &die, bool *type_is_new_ptr)=0
DWARFASTParserClang.h
SymbolFileDWARF::GetDeclContext
static lldb_private::CompilerDeclContext GetDeclContext(const DWARFDIE &die)
Definition: SymbolFileDWARF.cpp:4150
SymbolFileDWARF::InitializeObject
void InitializeObject() override
Initialize the SymbolFile object.
Definition: SymbolFileDWARF.cpp:448
SymbolFileDWARFDebugMap::GetUniqueDWARFASTTypeMap
UniqueDWARFASTTypeMap & GetUniqueDWARFASTTypeMap()
Definition: SymbolFileDWARFDebugMap.h:293
lldb_private::SymbolContext::GetResolvedMask
uint32_t GetResolvedMask() const
Definition: SymbolContext.cpp:285
lldb_private::Module::LookupInfo::GetNameTypeMask
lldb::FunctionNameType GetNameTypeMask() const
Definition: Module.h:951
SymbolFileDWARF::m_supports_DW_AT_APPLE_objc_complete_type
lldb_private::LazyBool m_supports_DW_AT_APPLE_objc_complete_type
Definition: SymbolFileDWARF.h:559
DIERef::section
Section section() const
Definition: DIERef.h:43
lldb_private::Block::FinalizeRanges
void FinalizeRanges()
Definition: Block.cpp:330
lldb_private::RangeDataVector
Definition: RangeMap.h:440
SymbolFileDWARF::GetContainingDeclContext
static lldb_private::CompilerDeclContext GetContainingDeclContext(const DWARFDIE &die)
Definition: SymbolFileDWARF.cpp:4157
lldb_private::Type
Definition: Type.h:66
LineTable.h
SymbolFileDWARF::CalculateFrameVariableError
lldb_private::Status CalculateFrameVariableError(lldb_private::StackFrame &frame) override
Subclasses will override this function to for GetFrameVariableError().
Definition: SymbolFileDWARF.cpp:4201
DWARFBaseDIE::GetOffset
dw_offset_t GetOffset() const
Definition: DWARFBaseDIE.cpp:92
DWARFBaseDIE::GetName
const char * GetName() const
Definition: DWARFBaseDIE.cpp:77
DWARFDebugRanges.h
lldb_private::Address::ResolveAddressUsingFileSections
bool ResolveAddressUsingFileSections(lldb::addr_t addr, const SectionList *sections)
Resolve a file virtual address using a section list.
Definition: Address.cpp:248
DWARFDIE::GetDIE
DWARFDIE GetDIE(dw_offset_t die_offset) const
Definition: DWARFDIE.cpp:118
ArchSpec.h
lldb_private::Range::GetByteSize
SizeType GetByteSize() const
Definition: RangeMap.h:87
lldb_private::Stream::AsRawOstream
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition: Stream.h:357
DWARFASTParser::ConstructDemangledNameFromDWARF
virtual lldb_private::ConstString ConstructDemangledNameFromDWARF(const DWARFDIE &die)=0
SymbolFileDWARFDwo
Definition: SymbolFileDWARFDwo.h:14
SymbolFileDWARF::m_type_unit_support_files
llvm::DenseMap< dw_offset_t, lldb_private::FileSpecList > m_type_unit_support_files
Definition: SymbolFileDWARF.h:571
DWARFUnit::GetNonSkeletonUnit
DWARFUnit & GetNonSkeletonUnit()
Definition: DWARFUnit.cpp:654
DWARFUnit::Supports_DW_AT_APPLE_objc_complete_type
bool Supports_DW_AT_APPLE_objc_complete_type()
Definition: DWARFUnit.cpp:673
lldb_private::ModuleChild::GetModule
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Definition: ModuleChild.cpp:24
SymbolFileDWARF::m_info
std::unique_ptr< DWARFDebugInfo > m_info
Definition: SymbolFileDWARF.h:547
SymbolFileDWARF::ParseDeclsForContext
void ParseDeclsForContext(lldb_private::CompilerDeclContext decl_ctx) override
Definition: SymbolFileDWARF.cpp:1392
if
if(APPLE AND LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY) remove_module_flags() endif() macro(add_host_subdirectory group) list(APPEND HOST_SOURCES $
Definition: Host/CMakeLists.txt:1
lldb_private::DWARFDataExtractor::GetAsLLVM
llvm::DWARFDataExtractor GetAsLLVM() const
Definition: DWARFDataExtractor.cpp:24
lldb_private::CompileUnit::ResolveSymbolContext
void ResolveSymbolContext(const SourceLocationSpec &src_location_spec, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list)
Resolve symbol contexts by file and line.
Definition: CompileUnit.cpp:250
lldb_private::SymbolContext::module_sp
lldb::ModuleSP module_sp
The Module for a given query.
Definition: SymbolContext.h:318
uint16_t
DWARFBaseDIE::GetID
lldb::user_id_t GetID() const
Definition: DWARFBaseDIE.cpp:71
DWARFDebugAbbrev.h
DWARFUnit::GetDwoError
const lldb_private::Status & GetDwoError() const
Get the fission .dwo file specific error for this compile unit.
Definition: DWARFUnit.h:278
SymbolFileDWARF::DebugInfo
DWARFDebugInfo & DebugInfo()
Definition: SymbolFileDWARF.cpp:636
PluginManager.h
DWARFUnit::GetLocationData
lldb_private::DWARFDataExtractor GetLocationData() const
Definition: DWARFUnit.cpp:517
lldb_private::Block::SetDidParseVariables
void SetDidParseVariables(bool b, bool set_children)
Definition: Block.cpp:496
lldb_private::AddressRange::SetByteSize
void SetByteSize(lldb::addr_t byte_size)
Set accessor for the byte size of this range.
Definition: AddressRange.h:237
DIERef::dwo_num
llvm::Optional< uint32_t > dwo_num() const
Definition: DIERef.h:37
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:215
lldb_private::ModuleSpec::GetArchitecture
ArchSpec & GetArchitecture()
Definition: ModuleSpec.h:89
SymbolFileDWARF::GetTypeSystemForLanguage
llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language) override
Definition: SymbolFileDWARF.cpp:436
lldb_private::CompileUnit::FindFunctionByUID
lldb::FunctionSP FindFunctionByUID(lldb::user_id_t uid)
Finds a function by user ID.
Definition: CompileUnit.cpp:143
LLDB_LOG
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition: Log.h:337
DWARFFormValue::AsCString
const char * AsCString() const
Definition: DWARFFormValue.cpp:459
lldb_private::DWARFContext::getOrLoadMacroData
const DWARFDataExtractor & getOrLoadMacroData()
Definition: DWARFContext.cpp:94
clang
Definition: ASTResultSynthesizer.h:15
lldb_private::CallEdge::AddrType
AddrType
Definition: Function.h:269
DWARFAttributes::AttributeAtIndex
dw_attr_t AttributeAtIndex(uint32_t i) const
Definition: DWARFAttribute.h:55
lldb_private::CompilerDeclContext::GetTypeSystem
TypeSystem * GetTypeSystem() const
Definition: CompilerDeclContext.h:101
lldb_private::CompilerType
Generic representation of a type in a programming language.
Definition: CompilerType.h:35
lldb_private::SymbolFileCommon::GetCompileUnitAtIndex
lldb::CompUnitSP GetCompileUnitAtIndex(uint32_t idx) override
Definition: SymbolFile.cpp:203
DWARFUnit::ExtractUnitDIEIfNeeded
void ExtractUnitDIEIfNeeded()
Definition: DWARFUnit.cpp:70
DWARFTypeUnit.h
DWARFUnit::GetLoclistOffset
llvm::Optional< uint64_t > GetLoclistOffset(uint32_t Index)
Definition: DWARFUnit.h:242
DWARFUnit::GetUserData
void * GetUserData() const
Definition: DWARFUnit.cpp:669
lldb_private::SymbolFileCommon::GetObjectFile
ObjectFile * GetObjectFile() override
Definition: SymbolFile.h:453
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
SymbolFileDWARF::FindTypes
void FindTypes(lldb_private::ConstString name, const lldb_private::CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, llvm::DenseSet< lldb_private::SymbolFile * > &searched_symbol_files, lldb_private::TypeMap &types) override
lldb_private::SymbolContext::Clear
void Clear(bool clear_target)
Clear the object's state.
Definition: SymbolContext.cpp:56
lldb::eValueTypeVariableThreadLocal
@ eValueTypeVariableThreadLocal
thread local storage variable
Definition: lldb-enumerations.h:325
SymbolFileDWARF::FindCompleteObjCDefinitionTypeForDIE
virtual lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE &die, lldb_private::ConstString type_name, bool must_be_implementation)
Definition: SymbolFileDWARF.cpp:2807
lldb_private::FileSpec::AppendPathComponent
void AppendPathComponent(llvm::StringRef component)
Definition: FileSpec.cpp:451
SymbolFileDWARF::ParseBlocksRecursive
size_t ParseBlocksRecursive(lldb_private::Function &func) override
Definition: SymbolFileDWARF.cpp:3134
CompilerDeclContext.h
DWARFDeclContext
Definition: DWARFDeclContext.h:23
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
DWARFDIE::children
llvm::iterator_range< child_iterator > children() const
The range of all the children of this DIE.
Definition: DWARFDIE.cpp:453
lldb_private::eLazyBoolCalculate
@ eLazyBoolCalculate
Definition: lldb-private-enumerations.h:115
SymbolFileDWARF::GetUniqueDWARFASTTypeMap
virtual UniqueDWARFASTTypeMap & GetUniqueDWARFASTTypeMap()
Definition: SymbolFileDWARF.cpp:427
lldb::eValueTypeInvalid
@ eValueTypeInvalid
Definition: lldb-enumerations.h:317
DWARFDebugInfoEntry::Tag
dw_tag_t Tag() const
Definition: DWARFDebugInfoEntry.h:113
lldb_private::Block::FindBlockByID
Block * FindBlockByID(lldb::user_id_t block_id)
Definition: Block.cpp:112
lldb_private::TypeSystem
Interface for representing a type system.
Definition: TypeSystem.h:75
Error
llvm::Error Error
Definition: UdtRecordCompleter.cpp:34
DWARFCompileUnit::LookupAddress
DWARFDIE LookupAddress(const dw_addr_t address)
Definition: DWARFCompileUnit.cpp:100
DWARFUnit::DIE
DWARFDIE DIE()
Definition: DWARFUnit.h:179
lldb_private::TypeList
Definition: TypeList.h:20
SymbolFileDWARF::DebugAbbrev
DWARFDebugAbbrev * DebugAbbrev()
Definition: SymbolFileDWARF.cpp:615
DWARFCompileUnit::GetNonSkeletonUnit
DWARFCompileUnit & GetNonSkeletonUnit()
Definition: DWARFCompileUnit.cpp:96
SymbolFileDWARF::PopulateBlockVariableList
size_t PopulateBlockVariableList(lldb_private::VariableList &variable_list, const lldb_private::SymbolContext &sc, llvm::ArrayRef< DIERef > variable_dies, lldb::addr_t func_low_pc)
Definition: SymbolFileDWARF.cpp:3841
lldb_private::TypeSystemClang
A TypeSystem implementation based on Clang.
Definition: TypeSystemClang.h:105
lldb_private::CompilerType::TypeSystemSPWrapper::dyn_cast_or_null
std::shared_ptr< TypeSystemType > dyn_cast_or_null()
Return a shared_ptr<TypeSystemType> if dyn_cast succeeds.
Definition: CompilerType.h:67
DWARFDIE::GetSibling
DWARFDIE GetSibling() const
Definition: DWARFDIE.cpp:102
SymbolFileDWARF::GetDwoNum
virtual llvm::Optional< uint32_t > GetDwoNum()
Definition: SymbolFileDWARF.h:281
SymbolFileDWARFDebugMap::LinkOSOFileAddress
lldb::addr_t LinkOSOFileAddress(SymbolFileDWARF *oso_symfile, lldb::addr_t oso_file_addr)
Convert a .o file "file address" to an executable "file address".
Definition: SymbolFileDWARFDebugMap.cpp:1397
lldb_private::VariableList::AddVariableIfUnique
bool AddVariableIfUnique(const lldb::VariableSP &var_sp)
Definition: VariableList.cpp:29
lldb_private::Address::GetOffset
lldb::addr_t GetOffset() const
Get the section relative offset value.
Definition: Address.h:319
SymbolFileDWARF::DWARFDIE
friend class DWARFDIE
Definition: SymbolFileDWARF.h:78
lldb_private::DataExtractor::Clear
void Clear()
Clears the object state.
Definition: DataExtractor.cpp:192
SymbolFileDWARF::GetDWOId
llvm::Optional< uint64_t > GetDWOId()
If this is a DWARF object with a single CU, return its DW_AT_dwo_id.
Definition: SymbolFileDWARF.cpp:1718
OptionValueFileSpecList.h
lldb_private::LanguageSet
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
Definition: TypeSystem.h:44
lldb_private::DWARFExpressionList
Definition: DWARFExpressionList.h:24
DWARFDebugMacroHeader::ParseHeader
static DWARFDebugMacroHeader ParseHeader(const lldb_private::DWARFDataExtractor &debug_macro_data, lldb::offset_t *offset)
Definition: DWARFDebugMacro.cpp:20
lldb_private::SourceModule::search_path
ConstString search_path
Definition: SourceModule.h:21
DebugMacros.h
DWARFDIE::LookupDeepestBlock
DWARFDIE LookupDeepestBlock(lldb::addr_t file_addr) const
Definition: DWARFDIE.cpp:139
DWARFDIE::GetDIENamesAndRanges
bool GetDIENamesAndRanges(const char *&name, const char *&mangled, DWARFRangeList &ranges, int &decl_file, int &decl_line, int &decl_column, int &call_file, int &call_line, int &call_column, lldb_private::DWARFExpressionList *frame_base) const
Definition: DWARFDIE.cpp:440
SymbolFileDWARF::PreloadSymbols
void PreloadSymbols() override
Definition: SymbolFileDWARF.cpp:2121
lldb_private::Block::GetStartAddress
bool GetStartAddress(Address &addr)
Definition: Block.cpp:317
SymbolFileDWARF::GetDeclContextContainingUID
lldb_private::CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) override
Definition: SymbolFileDWARF.cpp:1482
lldb_private::SymbolFile::Blocks
@ Blocks
Definition: SymbolFile.h:67
lldb_private::DWARFExpressionList::GetAlwaysValidExpr
const DWARFExpression * GetAlwaysValidExpr() const
Definition: DWARFExpressionList.cpp:24
SymbolFileDWARF::ParseSupportFiles
bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit, lldb_private::FileSpecList &support_files) override
LLDB_PLUGIN_DEFINE
#define LLDB_PLUGIN_DEFINE(PluginName)
Definition: PluginManager.h:31
lldb_private::Log
Definition: Log.h:115
lldb_private::SourceLocationSpec::GetCheckInlines
bool GetCheckInlines() const
Definition: SourceLocationSpec.h:172
lldb::eValueTypeVariableStatic
@ eValueTypeVariableStatic
static variable
Definition: lldb-enumerations.h:319
SymbolFileDWARF::GlobalVariableMap
lldb_private::RangeDataVector< lldb::addr_t, lldb::addr_t, lldb_private::Variable * > GlobalVariableMap
Definition: SymbolFileDWARF.h:502
lldb_private::Variable
Definition: Variable.h:25
SymbolFileDWARF::ParseVariablesInFunctionContextRecursive
size_t ParseVariablesInFunctionContextRecursive(const lldb_private::SymbolContext &sc, const DWARFDIE &die, lldb::addr_t func_low_pc, DIEArray &accumulator)
Definition: SymbolFileDWARF.cpp:3774
lldb_private::SymbolFile::GlobalVariables
@ GlobalVariables
Definition: SymbolFile.h:68
DWARFUnit::GetSymbolFileDWARF
SymbolFileDWARF & GetSymbolFileDWARF() const
Definition: DWARFUnit.h:199
lldb_private::FileSpec::SetFile
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
Definition: FileSpec.cpp:172
GetDWOName
static const char * GetDWOName(DWARFCompileUnit &dwarf_cu, const DWARFDebugInfoEntry &cu_die)
Return the DW_AT_(GNU_)dwo_name.
Definition: SymbolFileDWARF.cpp:688
ParseLLVMLineTablePrologue
static bool ParseLLVMLineTablePrologue(lldb_private::DWARFContext &context, llvm::DWARFDebugLine::Prologue &prologue, dw_offset_t line_offset, dw_offset_t unit_offset)
Definition: SymbolFileDWARF.cpp:164
DebugNamesDWARFIndex.h
lldb_private::RegularExpression::GetText
llvm::StringRef GetText() const
Access the regular expression text.
Definition: RegularExpression.cpp:33
lldb_private::CompilerDeclContext::IsContainedInLookup
bool IsContainedInLookup(CompilerDeclContext other) const
Check if the given other decl context is contained in the lookup of this decl context (for example be...
Definition: CompilerDeclContext.cpp:47
lldb_private::SymbolContext::line_entry
LineEntry line_entry
The LineEntry for a given query.
Definition: SymbolContext.h:322
SymbolFileDWARF::GetDIE
virtual DWARFDIE GetDIE(const DIERef &die_ref)
Definition: SymbolFileDWARF.cpp:1695
lldb_private::ClangASTImporter::CanImport
bool CanImport(const CompilerType &type)
Returns true iff the given type was copied from another TypeSystemClang and the original type in this...
Definition: ClangASTImporter.cpp:358
dw_addr_t
uint64_t dw_addr_t
Definition: dwarf.h:29
DWARFUnit::GetIsOptimized
bool GetIsOptimized()
Definition: DWARFUnit.cpp:749
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:309
lldb_private::FileSpec::GetPath
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:364
lldb_private::Declaration
Definition: Declaration.h:24
lldb::eLanguageTypeUnknown
@ eLanguageTypeUnknown
Unknown or invalid language value.
Definition: lldb-enumerations.h:438
DWARFAttributes::CompileUnitAtIndex
DWARFUnit * CompileUnitAtIndex(uint32_t i) const
Definition: DWARFAttribute.h:51
SymbolFileDWARF::~SymbolFileDWARF
~SymbolFileDWARF() override
SymbolFileDWARF::ParseVariablesInFunctionContext
size_t ParseVariablesInFunctionContext(const lldb_private::SymbolContext &sc, const DWARFDIE &die, const lldb::addr_t func_low_pc)
Definition: SymbolFileDWARF.cpp:3756
lldb_private::DataExtractor::GetByteSize
uint64_t GetByteSize() const
Get the number of bytes contained in this object.
Definition: DataExtractor.h:270
lldb_private::StackFrame
Definition: StackFrame.h:40
SymbolFileDWARF::GetDeclContextDIEContainingDIE
DWARFDIE GetDeclContextDIEContainingDIE(const DWARFDIE &die)
Definition: SymbolFileDWARF.cpp:2710
DWARFDebugInfoEntry::GetParent
DWARFDebugInfoEntry * GetParent()
Definition: DWARFDebugInfoEntry.h:125
lldb_private::SourceModule::path
std::vector< ConstString > path
Something like "Module.Submodule".
Definition: SourceModule.h:20
lldb::eLanguageTypeMipsAssembler
@ eLanguageTypeMipsAssembler
Mips_Assembler.
Definition: lldb-enumerations.h:481
lldb
Definition: SBAddress.h:15
lldb_private::DWARFExpressionList::SetModule
void SetModule(const lldb::ModuleSP &module)
Definition: DWARFExpressionList.h:110
DWARFDebugInfo::GetDIE
DWARFDIE GetDIE(const DIERef &die_ref)
Definition: DWARFDebugInfo.cpp:180
lldb_private::DWARFExpressionList::GetMutableExpressionAtAddress
DWARFExpression * GetMutableExpressionAtAddress(lldb::addr_t func_load_addr=LLDB_INVALID_ADDRESS, lldb::addr_t load_addr=0)
Definition: DWARFExpressionList.cpp:72
DWARFBaseDIE::Tag
dw_tag_t Tag() const
Definition: DWARFBaseDIE.cpp:29
LLDB_LOG_ERROR
#define LLDB_LOG_ERROR(log, error,...)
Definition: Log.h:360
SymbolFileDWARF::HasForwardDeclForClangType
bool HasForwardDeclForClangType(const lldb_private::CompilerType &compiler_type)
Definition: SymbolFileDWARF.cpp:1559
Value.h
SymbolFileDWARF::ParseCallEdgesInFunction
std::vector< std::unique_ptr< lldb_private::CallEdge > > ParseCallEdgesInFunction(UserID func_id) override
Definition: SymbolFileDWARF.cpp:4062
SymbolFileDWARF::GetTypes
void GetTypes(lldb_private::SymbolContextScope *sc_scope, lldb::TypeClass type_mask, lldb_private::TypeList &type_list) override
lldb_private::SymbolFile::LineTables
@ LineTables
Definition: SymbolFile.h:65
lldb_private::StackFrame::GetSymbolContext
const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
Definition: StackFrame.cpp:300
LLDBLog.h
SymbolFile.h
DWARFBaseDIE::HasChildren
bool HasChildren() const
Definition: DWARFBaseDIE.cpp:106
lldb_private::dwarf
Definition: dwarf.h:19
DWARFDebugInfoEntry::GetAttributeValueAsOptionalUnsigned
llvm::Optional< uint64_t > GetAttributeValueAsOptionalUnsigned(const DWARFUnit *cu, const dw_attr_t attr, bool check_specification_or_abstract_origin=false) const
Definition: DWARFDebugInfoEntry.cpp:551
lldb_private::ObjectFile
Definition: ObjectFile.h:60
lldb_private::SymbolFileCommon::SetCompileUnitAtIndex
void SetCompileUnitAtIndex(uint32_t idx, const lldb::CompUnitSP &cu_sp)
Definition: SymbolFile.cpp:214
lldb::eDescriptionLevelBrief
@ eDescriptionLevelBrief
Definition: lldb-enumerations.h:209
lldb_private::DWARFContext::getOrLoadLineData
const DWARFDataExtractor & getOrLoadLineData()
Definition: DWARFContext.cpp:73
SymbolFileDWARF::DumpClangAST
void DumpClangAST(lldb_private::Stream &s) override
Definition: SymbolFileDWARF.cpp:4079
DWARFFormValue::IsValid
bool IsValid() const
Definition: DWARFFormValue.h:70
SymbolFileDWARF::ClassOrStructIsVirtual
bool ClassOrStructIsVirtual(const DWARFDIE &die)
Definition: SymbolFileDWARF.cpp:1370
DIERef::Section
Section
Definition: DIERef.h:28
DWARFUnit::GetFile
lldb_private::FileSpec GetFile(size_t file_idx)
Definition: DWARFUnit.cpp:781
SymbolFileDWARF::BuildCuTranslationTable
void BuildCuTranslationTable()
Definition: SymbolFileDWARF.cpp:779
DWARFBaseDIE
Definition: DWARFBaseDIE.h:25
lldb::LanguageType
LanguageType
Programming language type.
Definition: lldb-enumerations.h:437
lldb_private::DWARFLog::DebugInfo
@ DebugInfo
SymbolFileDWARF::CalculateAbilities
uint32_t CalculateAbilities() override
Definition: SymbolFileDWARF.cpp:520
SymbolFileDWARF::GetUID
lldb::user_id_t GetUID(const DWARFBaseDIE &die)
Definition: SymbolFileDWARF.h:267
GetDWARFMachOSegmentName
static ConstString GetDWARFMachOSegmentName()
Definition: SymbolFileDWARF.cpp:422
lldb_private::RangeVector::GetSize
size_t GetSize() const
Definition: RangeMap.h:295
DWARFBaseDIE::IsValid
bool IsValid() const
Definition: DWARFBaseDIE.h:45
DWARFUnit::GetDIE
DWARFDIE GetDIE(dw_offset_t die_offset)
Definition: DWARFUnit.cpp:633
lldb_private::Range::GetRangeEnd
BaseType GetRangeEnd() const
Definition: RangeMap.h:78