LLDB mainline
SymbolFileDWARFDebugMap.cpp
Go to the documentation of this file.
1//===-- SymbolFileDWARFDebugMap.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
10#include "DWARFCompileUnit.h"
11#include "DWARFDebugAranges.h"
12#include "DWARFDebugInfo.h"
13
14#include "lldb/Core/Module.h"
17#include "lldb/Core/Progress.h"
18#include "lldb/Core/Section.h"
24#include "lldb/Utility/Timer.h"
25
26//#define DEBUG_OSO_DMAP // DO NOT CHECKIN WITH THIS NOT COMMENTED OUT
27
32#include "lldb/Symbol/TypeMap.h"
34#include "llvm/ADT/STLExtras.h"
35#include "llvm/ADT/StringRef.h"
36#include "llvm/Support/ScopedPrinter.h"
37
39
40#include "LogChannelDWARF.h"
41#include "SymbolFileDWARF.h"
43
44#include <memory>
45#include <optional>
46
47using namespace lldb;
48using namespace lldb_private;
49using namespace lldb_private::plugin::dwarf;
50
52
53// Subclass lldb_private::Module so we can intercept the
54// "Module::GetObjectFile()" (so we can fixup the object file sections) and
55// also for "Module::GetSymbolFile()" (so we can fixup the symbol file id.
56
59 SymbolFileDWARFDebugMap *exe_symfile) {
61 return file_range_map;
62
64
65 Module *oso_module = exe_symfile->GetModuleByCompUnitInfo(this);
66 if (!oso_module)
67 return file_range_map;
68
69 ObjectFile *oso_objfile = oso_module->GetObjectFile();
70 if (!oso_objfile)
71 return file_range_map;
72
75 log,
76 "%p: SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap ('%s')",
77 static_cast<void *>(this),
78 oso_module->GetSpecificationDescription().c_str());
79
80 std::vector<SymbolFileDWARFDebugMap::CompileUnitInfo *> cu_infos;
81 if (exe_symfile->GetCompUnitInfosForModule(oso_module, cu_infos)) {
82 for (auto comp_unit_info : cu_infos) {
83 Symtab *exe_symtab = exe_symfile->GetObjectFile()->GetSymtab();
84 ModuleSP oso_module_sp(oso_objfile->GetModule());
85 Symtab *oso_symtab = oso_objfile->GetSymtab();
86
87 /// const uint32_t fun_resolve_flags = SymbolContext::Module |
88 /// eSymbolContextCompUnit | eSymbolContextFunction;
89 // SectionList *oso_sections = oso_objfile->Sections();
90 // Now we need to make sections that map from zero based object file
91 // addresses to where things ended up in the main executable.
92
93 assert(comp_unit_info->first_symbol_index != UINT32_MAX);
94 // End index is one past the last valid symbol index
95 const uint32_t oso_end_idx = comp_unit_info->last_symbol_index + 1;
96 for (uint32_t idx = comp_unit_info->first_symbol_index +
97 2; // Skip the N_SO and N_OSO
98 idx < oso_end_idx; ++idx) {
99 Symbol *exe_symbol = exe_symtab->SymbolAtIndex(idx);
100 if (exe_symbol) {
101 if (!exe_symbol->IsDebug())
102 continue;
103
104 switch (exe_symbol->GetType()) {
105 default:
106 break;
107
108 case eSymbolTypeCode: {
109 // For each N_FUN, or function that we run into in the debug map we
110 // make a new section that we add to the sections found in the .o
111 // file. This new section has the file address set to what the
112 // addresses are in the .o file, and the load address is adjusted
113 // to match where it ended up in the final executable! We do this
114 // before we parse any dwarf info so that when it goes get parsed
115 // all section/offset addresses that get registered will resolve
116 // correctly to the new addresses in the main executable.
117
118 // First we find the original symbol in the .o file's symbol table
119 Symbol *oso_fun_symbol = oso_symtab->FindFirstSymbolWithNameAndType(
122 if (oso_fun_symbol) {
123 // Add the inverse OSO file address to debug map entry mapping
124 exe_symfile->AddOSOFileRange(
125 this, exe_symbol->GetAddressRef().GetFileAddress(),
126 exe_symbol->GetByteSize(),
127 oso_fun_symbol->GetAddressRef().GetFileAddress(),
128 oso_fun_symbol->GetByteSize());
129 }
130 } break;
131
132 case eSymbolTypeData: {
133 // For each N_GSYM we remap the address for the global by making a
134 // new section that we add to the sections found in the .o file.
135 // This new section has the file address set to what the addresses
136 // are in the .o file, and the load address is adjusted to match
137 // where it ended up in the final executable! We do this before we
138 // parse any dwarf info so that when it goes get parsed all
139 // section/offset addresses that get registered will resolve
140 // correctly to the new addresses in the main executable. We
141 // initially set the section size to be 1 byte, but will need to
142 // fix up these addresses further after all globals have been
143 // parsed to span the gaps, or we can find the global variable
144 // sizes from the DWARF info as we are parsing.
145
146 // Next we find the non-stab entry that corresponds to the N_GSYM
147 // in the .o file
148 Symbol *oso_gsym_symbol =
152 if (exe_symbol && oso_gsym_symbol && exe_symbol->ValueIsAddress() &&
153 oso_gsym_symbol->ValueIsAddress()) {
154 // Add the inverse OSO file address to debug map entry mapping
155 exe_symfile->AddOSOFileRange(
156 this, exe_symbol->GetAddressRef().GetFileAddress(),
157 exe_symbol->GetByteSize(),
158 oso_gsym_symbol->GetAddressRef().GetFileAddress(),
159 oso_gsym_symbol->GetByteSize());
160 }
161 } break;
162 }
163 }
164 }
165
166 exe_symfile->FinalizeOSOFileRanges(this);
167 // We don't need the symbols anymore for the .o files
168 oso_objfile->ClearSymtab();
169 }
170 }
171 return file_range_map;
172}
173
174namespace lldb_private::plugin {
175namespace dwarf {
176class DebugMapModule : public Module {
177public:
178 DebugMapModule(const ModuleSP &exe_module_sp, uint32_t cu_idx,
179 const FileSpec &file_spec, const ArchSpec &arch,
180 ConstString object_name, off_t object_offset,
181 const llvm::sys::TimePoint<> object_mod_time)
182 : Module(file_spec, arch, object_name, object_offset, object_mod_time),
183 m_exe_module_wp(exe_module_sp), m_cu_idx(cu_idx) {}
184
185 ~DebugMapModule() override = default;
186
187 SymbolFile *
188 GetSymbolFile(bool can_create = true,
189 lldb_private::Stream *feedback_strm = nullptr) override {
190 // Scope for locker
191 if (m_symfile_up.get() || !can_create)
192 return m_symfile_up ? m_symfile_up->GetSymbolFile() : nullptr;
193
194 ModuleSP exe_module_sp(m_exe_module_wp.lock());
195 if (exe_module_sp) {
196 // Now get the object file outside of a locking scope
197 ObjectFile *oso_objfile = GetObjectFile();
198 if (oso_objfile) {
199 std::lock_guard<std::recursive_mutex> guard(m_mutex);
200 if (SymbolFile *symfile =
201 Module::GetSymbolFile(can_create, feedback_strm)) {
202 // Set a pointer to this class to set our OSO DWARF file know that
203 // the DWARF is being used along with a debug map and that it will
204 // have the remapped sections that we do below.
205 SymbolFileDWARF *oso_symfile =
207
208 if (!oso_symfile)
209 return nullptr;
210
211 ObjectFile *exe_objfile = exe_module_sp->GetObjectFile();
212 SymbolFile *exe_symfile = exe_module_sp->GetSymbolFile();
213
214 if (exe_objfile && exe_symfile) {
215 oso_symfile->SetDebugMapModule(exe_module_sp);
216 // Set the ID of the symbol file DWARF to the index of the OSO
217 // shifted left by 32 bits to provide a unique prefix for any
218 // UserID's that get created in the symbol file.
219 oso_symfile->SetFileIndex((uint64_t)m_cu_idx);
220 }
221 return symfile;
222 }
223 }
224 }
225 return nullptr;
226 }
227
228protected:
230 const uint32_t m_cu_idx;
231};
232} // namespace dwarf
233} // namespace lldb_private::plugin
234
239
243
245 return "DWARF and DWARF3 debug symbol file reader (debug map).";
246}
247
249 return new SymbolFileDWARFDebugMap(std::move(objfile_sp));
250}
251
255
257
259
262 return;
263
265
266 // If the object file has been stripped, there is no sense in looking further
267 // as all of the debug symbols for the debug map will not be available
268 if (m_objfile_sp->IsStripped())
269 return;
270
271 // Also make sure the file type is some sort of executable. Core files, debug
272 // info files (dSYM), object files (.o files), and stub libraries all can
273 switch (m_objfile_sp->GetType()) {
281 return;
282
286 break;
287 }
288
289 // In order to get the abilities of this plug-in, we look at the list of
290 // N_OSO entries (object files) from the symbol table and make sure that
291 // these files exist and also contain valid DWARF. If we get any of that then
292 // we return the abilities of the first N_OSO's DWARF.
293
294 Symtab *symtab = m_objfile_sp->GetSymtab();
295 if (!symtab)
296 return;
297
299
300 std::vector<uint32_t> oso_indexes;
301 // When a mach-o symbol is encoded, the n_type field is encoded in bits
302 // 23:16, and the n_desc field is encoded in bits 15:0.
303 //
304 // To find all N_OSO entries that are part of the DWARF + debug map we find
305 // only object file symbols with the flags value as follows: bits 23:16 ==
306 // 0x66 (N_OSO) bits 15: 0 == 0x0001 (specifies this is a debug map object
307 // file)
308 const uint32_t k_oso_symbol_flags_value = 0x660001u;
309
310 const uint32_t oso_index_count =
312 eSymbolTypeObjectFile, k_oso_symbol_flags_value, oso_indexes);
313
314 if (oso_index_count == 0)
315 return;
316
321
324
325 for (uint32_t sym_idx :
326 llvm::concat<uint32_t>(m_func_indexes, m_glob_indexes)) {
327 const Symbol *symbol = symtab->SymbolAtIndex(sym_idx);
328 lldb::addr_t file_addr = symbol->GetAddressRef().GetFileAddress();
329 lldb::addr_t byte_size = symbol->GetByteSize();
330 DebugMap::Entry debug_map_entry(file_addr, byte_size,
332 m_debug_map.Append(debug_map_entry);
333 }
334 m_debug_map.Sort();
335
336 m_compile_unit_infos.resize(oso_index_count);
337
338 for (uint32_t i = 0; i < oso_index_count; ++i) {
339 const uint32_t so_idx = oso_indexes[i] - 1;
340 const uint32_t oso_idx = oso_indexes[i];
341 const Symbol *so_symbol = symtab->SymbolAtIndex(so_idx);
342 const Symbol *oso_symbol = symtab->SymbolAtIndex(oso_idx);
343 if (so_symbol && oso_symbol &&
344 so_symbol->GetType() == eSymbolTypeSourceFile &&
345 oso_symbol->GetType() == eSymbolTypeObjectFile) {
346 m_compile_unit_infos[i].so_file.SetFile(so_symbol->GetName().AsCString(),
347 FileSpec::Style::native);
348 m_compile_unit_infos[i].oso_path = oso_symbol->GetName();
349 m_compile_unit_infos[i].oso_mod_time =
350 llvm::sys::toTimePoint(oso_symbol->GetIntegerValue(0));
351 uint32_t sibling_idx = so_symbol->GetSiblingIndex();
352 // The sibling index can't be less that or equal to the current index
353 // "i"
354 if (sibling_idx <= i || sibling_idx == UINT32_MAX) {
355 m_objfile_sp->GetModule()->ReportError(
356 "N_SO in symbol with UID {0} has invalid sibling in debug "
357 "map, "
358 "please file a bug and attach the binary listed in this error",
359 so_symbol->GetID());
360 } else {
361 const Symbol *last_symbol = symtab->SymbolAtIndex(sibling_idx - 1);
362 m_compile_unit_infos[i].first_symbol_index = so_idx;
363 m_compile_unit_infos[i].last_symbol_index = sibling_idx - 1;
364 m_compile_unit_infos[i].first_symbol_id = so_symbol->GetID();
365 m_compile_unit_infos[i].last_symbol_id = last_symbol->GetID();
366
367 LLDB_LOGF(log, "Initialized OSO 0x%8.8x: file=%s", i,
368 oso_symbol->GetName().GetCString());
369 }
370 } else {
371 if (oso_symbol == nullptr)
372 m_objfile_sp->GetModule()->ReportError(
373 "N_OSO symbol[{0}] can't be found, please file a bug and "
374 "attach "
375 "the binary listed in this error",
376 oso_idx);
377 else if (so_symbol == nullptr)
378 m_objfile_sp->GetModule()->ReportError(
379 "N_SO not found for N_OSO symbol[{0}], please file a bug and "
380 "attach the binary listed in this error",
381 oso_idx);
382 else if (so_symbol->GetType() != eSymbolTypeSourceFile)
383 m_objfile_sp->GetModule()->ReportError(
384 "N_SO has incorrect symbol type ({0}) for N_OSO "
385 "symbol[{1}], "
386 "please file a bug and attach the binary listed in this error",
387 so_symbol->GetType(), oso_idx);
388 else if (oso_symbol->GetType() != eSymbolTypeSourceFile)
389 m_objfile_sp->GetModule()->ReportError(
390 "N_OSO has incorrect symbol type ({0}) for N_OSO "
391 "symbol[{1}], "
392 "please file a bug and attach the binary listed in this error",
393 oso_symbol->GetType(), oso_idx);
394 }
395 }
396}
397
399 const uint32_t cu_count = GetNumCompileUnits();
400 if (oso_idx < cu_count)
402 return nullptr;
403}
404
406 CompileUnitInfo *comp_unit_info) {
407 if (!comp_unit_info->oso_sp) {
408 auto pos = m_oso_map.find(
409 {comp_unit_info->oso_path, comp_unit_info->oso_mod_time});
410 if (pos != m_oso_map.end()) {
411 comp_unit_info->oso_sp = pos->second;
412 } else {
413 ObjectFile *obj_file = GetObjectFile();
414 comp_unit_info->oso_sp = std::make_shared<OSOInfo>();
415 m_oso_map[{comp_unit_info->oso_path, comp_unit_info->oso_mod_time}] =
416 comp_unit_info->oso_sp;
417 const char *oso_path = comp_unit_info->oso_path.GetCString();
418 FileSpec oso_file(oso_path);
419 ConstString oso_object;
420 if (FileSystem::Instance().Exists(oso_file)) {
421 // The modification time returned by the FS can have a higher precision
422 // than the one from the CU.
423 auto oso_mod_time = std::chrono::time_point_cast<std::chrono::seconds>(
424 FileSystem::Instance().GetModificationTime(oso_file));
425 // A timestamp of 0 means that the linker was in deterministic mode. In
426 // that case, we should skip the check against the filesystem last
427 // modification timestamp, since it will never match.
428 if (comp_unit_info->oso_mod_time != llvm::sys::TimePoint<>() &&
429 oso_mod_time != comp_unit_info->oso_mod_time) {
431 "debug map object file \"%s\" changed (actual: 0x%8.8x, debug "
432 "map: 0x%8.8x) since this executable was linked, debug info "
433 "will not be loaded",
434 oso_file.GetPath().c_str(),
435 (uint32_t)llvm::sys::toTimeT(oso_mod_time),
436 (uint32_t)llvm::sys::toTimeT(comp_unit_info->oso_mod_time));
437 obj_file->GetModule()->ReportError(
438 "{0}", comp_unit_info->oso_load_error.AsCString());
439 return nullptr;
440 }
441
442 } else {
443 const bool must_exist = true;
444
445 if (!ObjectFile::SplitArchivePathWithObject(oso_path, oso_file,
446 oso_object, must_exist)) {
448 "debug map object file \"%s\" containing debug info does not "
449 "exist, debug info will not be loaded",
450 comp_unit_info->oso_path.GetCString());
451 return nullptr;
452 }
453 }
454 // Always create a new module for .o files. Why? Because we use the debug
455 // map, to add new sections to each .o file and even though a .o file
456 // might not have changed, the sections that get added to the .o file can
457 // change.
458 ArchSpec oso_arch;
459 // Only adopt the architecture from the module (not the vendor or OS)
460 // since .o files for "i386-apple-ios" will historically show up as "i386
461 // -apple-macosx" due to the lack of a LC_VERSION_MIN_MACOSX or
462 // LC_VERSION_MIN_IPHONEOS load command...
463 oso_arch.SetTriple(m_objfile_sp->GetModule()
464 ->GetArchitecture()
465 .GetTriple()
466 .getArchName()
467 .str()
468 .c_str());
469 comp_unit_info->oso_sp->module_sp = std::make_shared<DebugMapModule>(
470 obj_file->GetModule(), GetCompUnitInfoIndex(comp_unit_info), oso_file,
471 oso_arch, oso_object, 0,
472 oso_object ? comp_unit_info->oso_mod_time : llvm::sys::TimePoint<>());
473
474 if (oso_object && !comp_unit_info->oso_sp->module_sp->GetObjectFile() &&
475 FileSystem::Instance().Exists(oso_file)) {
476 // If we are loading a .o file from a .a file the "oso_object" will
477 // have a valid value name and if the .a file exists, either the .o
478 // file didn't exist in the .a file or the mod time didn't match.
480 "\"%s\" object from the \"%s\" archive: "
481 "either the .o file doesn't exist in the archive or the "
482 "modification time (0x%8.8x) of the .o file doesn't match",
483 oso_object.AsCString(), oso_file.GetPath().c_str(),
484 (uint32_t)llvm::sys::toTimeT(comp_unit_info->oso_mod_time));
485 }
486 }
487 }
488 if (comp_unit_info->oso_sp)
489 return comp_unit_info->oso_sp->module_sp.get();
490 return nullptr;
491}
492
494 FileSpec &file_spec) {
495 if (oso_idx < m_compile_unit_infos.size()) {
496 if (m_compile_unit_infos[oso_idx].so_file) {
497 file_spec = m_compile_unit_infos[oso_idx].so_file;
498 return true;
499 }
500 }
501 return false;
502}
503
505 Module *oso_module = GetModuleByOSOIndex(oso_idx);
506 if (oso_module)
507 return oso_module->GetObjectFile();
508 return nullptr;
509}
510
515
518 CompileUnitInfo *comp_unit_info = GetCompUnitInfo(comp_unit);
519 if (comp_unit_info)
520 return GetSymbolFileByCompUnitInfo(comp_unit_info);
521 return nullptr;
522}
523
525 CompileUnitInfo *comp_unit_info) {
526 Module *oso_module = GetModuleByCompUnitInfo(comp_unit_info);
527 if (oso_module)
528 return oso_module->GetObjectFile();
529 return nullptr;
530}
531
533 const CompileUnitInfo *comp_unit_info) {
534 if (!m_compile_unit_infos.empty()) {
535 const CompileUnitInfo *first_comp_unit_info = &m_compile_unit_infos.front();
536 const CompileUnitInfo *last_comp_unit_info = &m_compile_unit_infos.back();
537 if (first_comp_unit_info <= comp_unit_info &&
538 comp_unit_info <= last_comp_unit_info)
539 return comp_unit_info - first_comp_unit_info;
540 }
541 return UINT32_MAX;
542}
543
546 unsigned size = m_compile_unit_infos.size();
547 if (oso_idx < size)
549 return nullptr;
550}
551
554 if (sym_file &&
556 return static_cast<SymbolFileDWARF *>(sym_file);
557 return nullptr;
558}
559
561 CompileUnitInfo *comp_unit_info) {
562 if (Module *oso_module = GetModuleByCompUnitInfo(comp_unit_info))
563 return GetSymbolFileAsSymbolFileDWARF(oso_module->GetSymbolFile());
564 return nullptr;
565}
566
568 // In order to get the abilities of this plug-in, we look at the list of
569 // N_OSO entries (object files) from the symbol table and make sure that
570 // these files exist and also contain valid DWARF. If we get any of that then
571 // we return the abilities of the first N_OSO's DWARF.
572
573 const uint32_t oso_index_count = GetNumCompileUnits();
574 if (oso_index_count > 0) {
575 InitOSO();
576 if (!m_compile_unit_infos.empty()) {
581 }
582 }
583 return 0;
584}
585
590
592 CompUnitSP comp_unit_sp;
593 const uint32_t cu_count = GetNumCompileUnits();
594
595 if (cu_idx < cu_count) {
596 auto &cu_info = m_compile_unit_infos[cu_idx];
597 Module *oso_module = GetModuleByCompUnitInfo(&cu_info);
598 if (oso_module) {
599 FileSpec so_file_spec;
600 if (GetFileSpecForSO(cu_idx, so_file_spec)) {
601 // User zero as the ID to match the compile unit at offset zero in each
602 // .o file.
603 lldb::user_id_t cu_id = 0;
604 cu_info.compile_units_sps.push_back(std::make_shared<CompileUnit>(
605 m_objfile_sp->GetModule(), nullptr,
606 std::make_shared<SupportFile>(so_file_spec), cu_id,
608 cu_info.id_to_index_map.insert({0, 0});
609 SetCompileUnitAtIndex(cu_idx, cu_info.compile_units_sps[0]);
610 // If there's a symbol file also register all the extra compile units.
611 if (SymbolFileDWARF *oso_symfile =
612 GetSymbolFileByCompUnitInfo(&cu_info)) {
613 auto num_dwarf_units = oso_symfile->DebugInfo().GetNumUnits();
614 for (size_t i = 0; i < num_dwarf_units; ++i) {
615 auto *dwarf_unit = oso_symfile->DebugInfo().GetUnitAtIndex(i);
616 if (auto *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(dwarf_unit)) {
617 // The "main" one was already registered.
618 if (dwarf_cu->GetID() == 0)
619 continue;
620 cu_info.compile_units_sps.push_back(std::make_shared<CompileUnit>(
621 m_objfile_sp->GetModule(), nullptr,
622 std::make_shared<SupportFile>(so_file_spec),
623 dwarf_cu->GetID(), eLanguageTypeUnknown, eLazyBoolCalculate));
624 cu_info.id_to_index_map.insert(
625 {dwarf_cu->GetID(), cu_info.compile_units_sps.size() - 1});
626 }
627 }
628 }
629 }
630 }
631 if (!cu_info.compile_units_sps.empty())
632 comp_unit_sp = cu_info.compile_units_sps[0];
633 }
634
635 return comp_unit_sp;
636}
637
642
645 const uint32_t cu_count = GetNumCompileUnits();
646 for (uint32_t i = 0; i < cu_count; ++i) {
647 auto &id_to_index_map = m_compile_unit_infos[i].id_to_index_map;
648
649 auto it = id_to_index_map.find(comp_unit.GetID());
650 if (it != id_to_index_map.end() &&
651 &comp_unit ==
652 m_compile_unit_infos[i].compile_units_sps[it->getSecond()].get())
653 return &m_compile_unit_infos[i];
654 }
655 return nullptr;
656}
657
659 const lldb_private::Module *module,
660 std::vector<CompileUnitInfo *> &cu_infos) {
661 const uint32_t cu_count = GetNumCompileUnits();
662 for (uint32_t i = 0; i < cu_count; ++i) {
664 cu_infos.push_back(&m_compile_unit_infos[i]);
665 }
666 return cu_infos.size();
667}
668
671 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
672 SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
673 if (oso_dwarf)
674 return oso_dwarf->ParseLanguage(comp_unit);
676}
677
679 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
680 SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
681 if (oso_dwarf)
682 return oso_dwarf->ParseXcodeSDK(comp_unit);
683 return {};
684}
685
686llvm::SmallSet<lldb::LanguageType, 4>
688 lldb_private::CompileUnit &comp_unit) {
689 llvm::SmallSet<lldb::LanguageType, 4> langs;
690 auto *info = GetCompUnitInfo(comp_unit);
691 for (auto &comp_unit : info->compile_units_sps) {
692 langs.insert(comp_unit->GetLanguage());
693 }
694 return langs;
695}
696
698 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
699 SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
700 if (oso_dwarf)
701 return oso_dwarf->ParseFunctions(comp_unit);
702 return 0;
703}
704
706 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
707 SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
708 if (oso_dwarf)
709 return oso_dwarf->ParseLineTable(comp_unit);
710 return false;
711}
712
714 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
715 SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
716 if (oso_dwarf)
717 return oso_dwarf->ParseDebugMacros(comp_unit);
718 return false;
719}
720
722 std::string description,
723 std::function<IterationAction(SymbolFileDWARF &)> closure) {
724 const size_t num_oso_idxs = m_compile_unit_infos.size();
725 Progress progress(std::move(description), "", num_oso_idxs,
726 /*debugger=*/nullptr,
728 for (uint32_t oso_idx = 0; oso_idx < num_oso_idxs; ++oso_idx) {
729 if (SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx)) {
730 progress.Increment(oso_idx, oso_dwarf->GetObjectName());
731 if (closure(*oso_dwarf) == IterationAction::Stop)
732 return;
733 }
734 }
735}
736
738 CompileUnit &comp_unit,
739 llvm::DenseSet<lldb_private::SymbolFile *> &visited_symbol_files,
740 llvm::function_ref<bool(Module &)> f) {
741 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
742 SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
743 if (oso_dwarf)
744 return oso_dwarf->ForEachExternalModule(comp_unit, visited_symbol_files, f);
745 return false;
746}
747
749 CompileUnit &comp_unit, SupportFileList &support_files) {
750 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
751 SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
752 if (oso_dwarf)
753 return oso_dwarf->ParseSupportFiles(comp_unit, support_files);
754 return false;
755}
756
758 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
759 SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
760 if (oso_dwarf)
761 return oso_dwarf->ParseIsOptimized(comp_unit);
762 return false;
763}
764
766 const SymbolContext &sc, std::vector<SourceModule> &imported_modules) {
767 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
768 SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc);
769 if (oso_dwarf)
770 return oso_dwarf->ParseImportedModules(sc, imported_modules);
771 return false;
772}
773
775 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
776 CompileUnit *comp_unit = func.GetCompileUnit();
777 if (!comp_unit)
778 return 0;
779
780 SymbolFileDWARF *oso_dwarf = GetSymbolFile(*comp_unit);
781 if (oso_dwarf)
782 return oso_dwarf->ParseBlocksRecursive(func);
783 return 0;
784}
785
787 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
788 SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
789 if (oso_dwarf)
790 return oso_dwarf->ParseTypes(comp_unit);
791 return 0;
792}
793
794size_t
796 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
797 SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc);
798 if (oso_dwarf)
799 return oso_dwarf->ParseVariablesForContext(sc);
800 return 0;
801}
802
804 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
805 const uint64_t oso_idx = GetOSOIndexFromUserID(type_uid);
806 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx);
807 if (oso_dwarf)
808 return oso_dwarf->ResolveTypeUID(type_uid);
809 return nullptr;
810}
811
812std::optional<SymbolFile::ArrayInfo>
814 lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx) {
815 const uint64_t oso_idx = GetOSOIndexFromUserID(type_uid);
816 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx);
817 if (oso_dwarf)
818 return oso_dwarf->GetDynamicArrayInfoForUID(type_uid, exe_ctx);
819 return std::nullopt;
820}
821
823 bool success = false;
824 if (compiler_type) {
825 ForEachSymbolFile("Completing type", [&](SymbolFileDWARF &oso_dwarf) {
826 if (oso_dwarf.HasForwardDeclForCompilerType(compiler_type)) {
827 oso_dwarf.CompleteType(compiler_type);
828 success = true;
830 }
832 });
833 }
834 return success;
835}
836
837uint32_t
839 SymbolContextItem resolve_scope,
840 SymbolContext &sc) {
841 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
842 uint32_t resolved_flags = 0;
843 Symtab *symtab = m_objfile_sp->GetSymtab();
844 if (symtab) {
845 const addr_t exe_file_addr = exe_so_addr.GetFileAddress();
846
847 const DebugMap::Entry *debug_map_entry =
848 m_debug_map.FindEntryThatContains(exe_file_addr);
849 if (debug_map_entry) {
850
851 sc.symbol =
852 symtab->SymbolAtIndex(debug_map_entry->data.GetExeSymbolIndex());
853
854 if (sc.symbol != nullptr) {
855 resolved_flags |= eSymbolContextSymbol;
856
857 uint32_t oso_idx = 0;
858 CompileUnitInfo *comp_unit_info =
860 if (comp_unit_info) {
861 comp_unit_info->GetFileRangeMap(this);
862 Module *oso_module = GetModuleByCompUnitInfo(comp_unit_info);
863 if (oso_module) {
864 lldb::addr_t oso_file_addr =
865 exe_file_addr - debug_map_entry->GetRangeBase() +
866 debug_map_entry->data.GetOSOFileAddress();
867 Address oso_so_addr;
868 if (oso_module->ResolveFileAddress(oso_file_addr, oso_so_addr)) {
869 if (SymbolFile *sym_file = oso_module->GetSymbolFile()) {
870 resolved_flags |= sym_file->ResolveSymbolContext(
871 oso_so_addr, resolve_scope, sc);
872 } else {
873 ObjectFile *obj_file = GetObjectFile();
875 "Failed to get symfile for OSO: {0} in module: {1}",
876 oso_module->GetFileSpec(),
877 obj_file ? obj_file->GetFileSpec()
878 : FileSpec("unknown"));
879 }
880 }
881 }
882 }
883 }
884 }
885 }
886 return resolved_flags;
887}
888
890 const SourceLocationSpec &src_location_spec,
891 SymbolContextItem resolve_scope, SymbolContextList &sc_list) {
892 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
893 const uint32_t initial = sc_list.GetSize();
894 const uint32_t cu_count = GetNumCompileUnits();
895
896 for (uint32_t i = 0; i < cu_count; ++i) {
897 // If we are checking for inlines, then we need to look through all compile
898 // units no matter if "file_spec" matches.
899 bool resolve = src_location_spec.GetCheckInlines();
900
901 if (!resolve) {
902 FileSpec so_file_spec;
903 if (GetFileSpecForSO(i, so_file_spec))
904 resolve =
905 FileSpec::Match(src_location_spec.GetFileSpec(), so_file_spec);
906 }
907 if (resolve) {
909 if (oso_dwarf)
910 oso_dwarf->ResolveSymbolContext(src_location_spec, resolve_scope,
911 sc_list);
912 }
913 }
914 return sc_list.GetSize() - initial;
915}
916
918 ConstString name, const CompilerDeclContext &parent_decl_ctx,
919 const std::vector<uint32_t>
920 &indexes, // Indexes into the symbol table that match "name"
921 uint32_t max_matches, VariableList &variables) {
922 const size_t match_count = indexes.size();
923 for (size_t i = 0; i < match_count; ++i) {
924 uint32_t oso_idx;
925 CompileUnitInfo *comp_unit_info =
926 GetCompileUnitInfoForSymbolWithIndex(indexes[i], &oso_idx);
927 if (comp_unit_info) {
928 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx);
929 if (oso_dwarf) {
930 oso_dwarf->FindGlobalVariables(name, parent_decl_ctx, max_matches,
931 variables);
932 if (variables.GetSize() > max_matches)
933 break;
934 }
935 }
936 }
937}
938
940 ConstString name, const CompilerDeclContext &parent_decl_ctx,
941 uint32_t max_matches, VariableList &variables) {
942 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
943 uint32_t total_matches = 0;
944
946 "Looking up global variables", [&](SymbolFileDWARF &oso_dwarf) {
947 const uint32_t old_size = variables.GetSize();
948 oso_dwarf.FindGlobalVariables(name, parent_decl_ctx, max_matches,
949 variables);
950 const uint32_t oso_matches = variables.GetSize() - old_size;
951 if (oso_matches > 0) {
952 total_matches += oso_matches;
953
954 // If we are getting all matches, keep going.
955 if (max_matches == UINT32_MAX)
957
958 // If we have found enough matches, lets get out
959 if (max_matches >= total_matches)
961
962 // Update the max matches for any subsequent calls to find globals in
963 // any other object files with DWARF
964 max_matches -= oso_matches;
965 }
966
968 });
969}
970
972 const RegularExpression &regex, uint32_t max_matches,
973 VariableList &variables) {
974 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
975 uint32_t total_matches = 0;
977 "Looking up global variables", [&](SymbolFileDWARF &oso_dwarf) {
978 const uint32_t old_size = variables.GetSize();
979 oso_dwarf.FindGlobalVariables(regex, max_matches, variables);
980
981 const uint32_t oso_matches = variables.GetSize() - old_size;
982 if (oso_matches > 0) {
983 total_matches += oso_matches;
984
985 // If we are getting all matches, keep going.
986 if (max_matches == UINT32_MAX)
988
989 // If we have found enough matches, lets get out
990 if (max_matches >= total_matches)
992
993 // Update the max matches for any subsequent calls to find globals in
994 // any other object files with DWARF
995 max_matches -= oso_matches;
996 }
997
999 });
1000}
1001
1003 uint32_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info) {
1004 const uint32_t symbol_idx = *symbol_idx_ptr;
1005
1006 if (symbol_idx < comp_unit_info->first_symbol_index)
1007 return -1;
1008
1009 if (symbol_idx <= comp_unit_info->last_symbol_index)
1010 return 0;
1011
1012 return 1;
1013}
1014
1016 user_id_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info) {
1017 const user_id_t symbol_id = *symbol_idx_ptr;
1018
1019 if (symbol_id < comp_unit_info->first_symbol_id)
1020 return -1;
1021
1022 if (symbol_id <= comp_unit_info->last_symbol_id)
1023 return 0;
1024
1025 return 1;
1026}
1027
1030 uint32_t symbol_idx, uint32_t *oso_idx_ptr) {
1031 const uint32_t oso_index_count = m_compile_unit_infos.size();
1032 CompileUnitInfo *comp_unit_info = nullptr;
1033 if (oso_index_count) {
1034 comp_unit_info = (CompileUnitInfo *)bsearch(
1035 &symbol_idx, &m_compile_unit_infos[0], m_compile_unit_infos.size(),
1036 sizeof(CompileUnitInfo),
1038 }
1039
1040 if (oso_idx_ptr) {
1041 if (comp_unit_info != nullptr)
1042 *oso_idx_ptr = comp_unit_info - &m_compile_unit_infos[0];
1043 else
1044 *oso_idx_ptr = UINT32_MAX;
1045 }
1046 return comp_unit_info;
1047}
1048
1051 user_id_t symbol_id, uint32_t *oso_idx_ptr) {
1052 const uint32_t oso_index_count = m_compile_unit_infos.size();
1053 CompileUnitInfo *comp_unit_info = nullptr;
1054 if (oso_index_count) {
1055 comp_unit_info = (CompileUnitInfo *)::bsearch(
1056 &symbol_id, &m_compile_unit_infos[0], m_compile_unit_infos.size(),
1057 sizeof(CompileUnitInfo),
1059 }
1060
1061 if (oso_idx_ptr) {
1062 if (comp_unit_info != nullptr)
1063 *oso_idx_ptr = comp_unit_info - &m_compile_unit_infos[0];
1064 else
1065 *oso_idx_ptr = UINT32_MAX;
1066 }
1067 return comp_unit_info;
1068}
1069
1071 SymbolContextList &sc_list,
1072 uint32_t start_idx) {
1073 // We found functions in .o files. Not all functions in the .o files will
1074 // have made it into the final output file. The ones that did make it into
1075 // the final output file will have a section whose module matches the module
1076 // from the ObjectFile for this SymbolFile. When the modules don't match,
1077 // then we have something that was in a .o file, but doesn't map to anything
1078 // in the final executable.
1079 uint32_t i = start_idx;
1080 while (i < sc_list.GetSize()) {
1081 SymbolContext sc;
1082 sc_list.GetContextAtIndex(i, sc);
1083 if (sc.function) {
1084 const SectionSP section_sp = sc.function->GetAddress().GetSection();
1085 if (section_sp->GetModule() != module_sp) {
1086 sc_list.RemoveContextAtIndex(i);
1087 continue;
1088 }
1089 }
1090 ++i;
1091 }
1092}
1093
1095 const Module::LookupInfo &lookup_info,
1096 const CompilerDeclContext &parent_decl_ctx, bool include_inlines,
1097 SymbolContextList &sc_list) {
1098 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1099 LLDB_SCOPED_TIMERF("SymbolFileDWARFDebugMap::FindFunctions (name = %s)",
1100 lookup_info.GetLookupName().GetCString());
1101
1102 ForEachSymbolFile("Looking up functions", [&](SymbolFileDWARF &oso_dwarf) {
1103 uint32_t sc_idx = sc_list.GetSize();
1104 oso_dwarf.FindFunctions(lookup_info, parent_decl_ctx, include_inlines,
1105 sc_list);
1106 if (!sc_list.IsEmpty()) {
1108 sc_idx);
1109 }
1111 });
1112}
1113
1115 bool include_inlines,
1116 SymbolContextList &sc_list) {
1117 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1118 LLDB_SCOPED_TIMERF("SymbolFileDWARFDebugMap::FindFunctions (regex = '%s')",
1119 regex.GetText().str().c_str());
1120
1121 ForEachSymbolFile("Looking up functions", [&](SymbolFileDWARF &oso_dwarf) {
1122 uint32_t sc_idx = sc_list.GetSize();
1123
1124 oso_dwarf.FindFunctions(regex, include_inlines, sc_list);
1125 if (!sc_list.IsEmpty()) {
1127 sc_idx);
1128 }
1130 });
1131}
1132
1134 lldb::TypeClass type_mask,
1135 TypeList &type_list) {
1136 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1137 LLDB_SCOPED_TIMERF("SymbolFileDWARFDebugMap::GetTypes (type_mask = 0x%8.8x)",
1138 type_mask);
1139
1140 SymbolFileDWARF *oso_dwarf = nullptr;
1141 if (sc_scope) {
1142 SymbolContext sc;
1143 sc_scope->CalculateSymbolContext(&sc);
1144
1145 CompileUnitInfo *cu_info = GetCompUnitInfo(sc);
1146 if (cu_info) {
1147 oso_dwarf = GetSymbolFileByCompUnitInfo(cu_info);
1148 if (oso_dwarf)
1149 oso_dwarf->GetTypes(sc_scope, type_mask, type_list);
1150 }
1151 } else {
1152 ForEachSymbolFile("Looking up types", [&](SymbolFileDWARF &oso_dwarf) {
1153 oso_dwarf.GetTypes(sc_scope, type_mask, type_list);
1155 });
1156 }
1157}
1158
1159std::vector<std::unique_ptr<lldb_private::CallEdge>>
1161 lldb_private::UserID func_id) {
1162 uint32_t oso_idx = GetOSOIndexFromUserID(func_id.GetID());
1163 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx);
1164 if (oso_dwarf)
1165 return oso_dwarf->ParseCallEdgesInFunction(func_id);
1166 return {};
1167}
1168
1170 DWARFDIE result;
1172 "Looking up type definition", [&](SymbolFileDWARF &oso_dwarf) {
1173 result = oso_dwarf.FindDefinitionDIE(die);
1175 });
1176 return result;
1177}
1178
1180 const DWARFDIE &die, ConstString type_name, bool must_be_implementation) {
1181 // If we have a debug map, we will have an Objective-C symbol whose name is
1182 // the type name and whose type is eSymbolTypeObjCClass. If we can find that
1183 // symbol and find its containing parent, we can locate the .o file that will
1184 // contain the implementation definition since it will be scoped inside the
1185 // N_SO and we can then locate the SymbolFileDWARF that corresponds to that
1186 // N_SO.
1187 SymbolFileDWARF *oso_dwarf = nullptr;
1188 TypeSP type_sp;
1189 ObjectFile *module_objfile = m_objfile_sp->GetModule()->GetObjectFile();
1190 if (module_objfile) {
1191 Symtab *symtab = module_objfile->GetSymtab();
1192 if (symtab) {
1193 Symbol *objc_class_symbol = symtab->FindFirstSymbolWithNameAndType(
1196 if (objc_class_symbol) {
1197 // Get the N_SO symbol that contains the objective C class symbol as
1198 // this should be the .o file that contains the real definition...
1199 const Symbol *source_file_symbol = symtab->GetParent(objc_class_symbol);
1200
1201 if (source_file_symbol &&
1202 source_file_symbol->GetType() == eSymbolTypeSourceFile) {
1203 const uint32_t source_file_symbol_idx =
1204 symtab->GetIndexForSymbol(source_file_symbol);
1205 if (source_file_symbol_idx != UINT32_MAX) {
1206 CompileUnitInfo *compile_unit_info =
1207 GetCompileUnitInfoForSymbolWithIndex(source_file_symbol_idx,
1208 nullptr);
1209 if (compile_unit_info) {
1210 oso_dwarf = GetSymbolFileByCompUnitInfo(compile_unit_info);
1211 if (oso_dwarf) {
1213 die, type_name, must_be_implementation));
1214 if (type_sp) {
1215 return type_sp;
1216 }
1217 }
1218 }
1219 }
1220 }
1221 }
1222 }
1223 }
1224
1225 // Only search all .o files for the definition if we don't need the
1226 // implementation because otherwise, with a valid debug map we should have
1227 // the ObjC class symbol and the code above should have found it.
1228 if (!must_be_implementation) {
1229 TypeSP type_sp;
1230
1232 "Looking up Objective-C definition", [&](SymbolFileDWARF &oso_dwarf) {
1233 type_sp = oso_dwarf.FindCompleteObjCDefinitionTypeForDIE(
1234 die, type_name, must_be_implementation);
1236 });
1237
1238 return type_sp;
1239 }
1240 return TypeSP();
1241}
1242
1244 TypeResults &results) {
1245 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1246 ForEachSymbolFile("Looking up type", [&](SymbolFileDWARF &oso_dwarf) {
1247 oso_dwarf.FindTypes(query, results);
1248 return results.Done(query) ? IterationAction::Stop
1250 });
1251}
1252
1254 lldb_private::ConstString name, const CompilerDeclContext &parent_decl_ctx,
1255 bool only_root_namespaces) {
1256 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1257 CompilerDeclContext matching_namespace;
1258
1259 ForEachSymbolFile("Looking up namespace", [&](SymbolFileDWARF &oso_dwarf) {
1260 matching_namespace =
1261 oso_dwarf.FindNamespace(name, parent_decl_ctx, only_root_namespaces);
1262
1263 return matching_namespace ? IterationAction::Stop
1265 });
1266
1267 return matching_namespace;
1268}
1269
1270void SymbolFileDWARFDebugMap::DumpClangAST(Stream &s, llvm::StringRef filter,
1271 bool show_color) {
1272 ForEachSymbolFile("Dumping clang AST", [&](SymbolFileDWARF &oso_dwarf) {
1273 oso_dwarf.DumpClangAST(s, filter, show_color);
1274 // The underlying assumption is that DumpClangAST(...) will obtain the
1275 // AST from the underlying TypeSystem and therefore we only need to do
1276 // this once and can stop after the first iteration hence we return true.
1277 return IterationAction::Stop;
1278 });
1279}
1280
1282 lldb_private::StructuredData::Dictionary &d, bool errors_only,
1283 bool load_all_debug_info) {
1284 StructuredData::Array separate_debug_info_files;
1285 const uint32_t cu_count = GetNumCompileUnits();
1286 for (uint32_t cu_idx = 0; cu_idx < cu_count; ++cu_idx) {
1287 const auto &info = m_compile_unit_infos[cu_idx];
1289 std::make_shared<StructuredData::Dictionary>();
1290 oso_data->AddStringItem("so_file", info.so_file.GetPath());
1291 oso_data->AddStringItem("oso_path", info.oso_path);
1292 oso_data->AddIntegerItem("oso_mod_time",
1293 (uint32_t)llvm::sys::toTimeT(info.oso_mod_time));
1294
1295 bool loaded_successfully = false;
1296 if (GetModuleByOSOIndex(cu_idx)) {
1297 // If we have a valid pointer to the module, we successfully
1298 // loaded the oso if there are no load errors.
1299 if (!info.oso_load_error.Fail()) {
1300 loaded_successfully = true;
1301 }
1302 }
1303 if (!loaded_successfully) {
1304 oso_data->AddStringItem("error", info.oso_load_error.AsCString());
1305 }
1306 oso_data->AddBooleanItem("loaded", loaded_successfully);
1307 if (!errors_only || oso_data->HasKey("error"))
1308 separate_debug_info_files.AddItem(oso_data);
1309 }
1310
1311 d.AddStringItem("type", "oso");
1312 d.AddStringItem("symfile", GetMainObjectFile()->GetFileSpec().GetPath());
1313 d.AddItem("separate-debug-info-files",
1314 std::make_shared<StructuredData::Array>(
1315 std::move(separate_debug_info_files)));
1316 return true;
1317}
1318
1321 DWARFCompileUnit &dwarf_cu) {
1322 if (oso_dwarf) {
1323 const uint32_t cu_count = GetNumCompileUnits();
1324 for (uint32_t cu_idx = 0; cu_idx < cu_count; ++cu_idx) {
1325 SymbolFileDWARF *oso_symfile =
1327 if (oso_symfile == oso_dwarf) {
1328 if (m_compile_unit_infos[cu_idx].compile_units_sps.empty())
1330
1331 auto &id_to_index_map = m_compile_unit_infos[cu_idx].id_to_index_map;
1332 auto it = id_to_index_map.find(dwarf_cu.GetID());
1333 if (it != id_to_index_map.end())
1334 return m_compile_unit_infos[cu_idx]
1335 .compile_units_sps[it->getSecond()];
1336 }
1337 }
1338 }
1339 llvm_unreachable("this shouldn't happen");
1340}
1341
1344 if (oso_dwarf) {
1345 const uint32_t cu_count = GetNumCompileUnits();
1346 for (uint32_t cu_idx = 0; cu_idx < cu_count; ++cu_idx) {
1347 SymbolFileDWARF *oso_symfile =
1349 if (oso_symfile == oso_dwarf) {
1350 return &m_compile_unit_infos[cu_idx];
1351 }
1352 }
1353 }
1354 return nullptr;
1355}
1356
1358 const CompUnitSP &cu_sp) {
1359 if (oso_dwarf) {
1360 const uint32_t cu_count = GetNumCompileUnits();
1361 for (uint32_t cu_idx = 0; cu_idx < cu_count; ++cu_idx) {
1362 SymbolFileDWARF *oso_symfile =
1364 if (oso_symfile == oso_dwarf) {
1365 if (!m_compile_unit_infos[cu_idx].compile_units_sps.empty()) {
1366 assert(m_compile_unit_infos[cu_idx].compile_units_sps[0].get() ==
1367 cu_sp.get());
1368 } else {
1369 assert(cu_sp->GetID() == 0 &&
1370 "Setting first compile unit but with id different than 0!");
1371 auto &compile_units_sps =
1372 m_compile_unit_infos[cu_idx].compile_units_sps;
1373 compile_units_sps.push_back(cu_sp);
1374 m_compile_unit_infos[cu_idx].id_to_index_map.insert(
1375 {cu_sp->GetID(), compile_units_sps.size() - 1});
1376
1377 SetCompileUnitAtIndex(cu_idx, cu_sp);
1378 }
1379 }
1380 }
1381 }
1382}
1383
1386 const uint64_t oso_idx = GetOSOIndexFromUserID(type_uid);
1387 if (SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx))
1388 return oso_dwarf->GetDeclContextForUID(type_uid);
1389 return {};
1390}
1391
1394 const uint64_t oso_idx = GetOSOIndexFromUserID(type_uid);
1395 if (SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx))
1396 return oso_dwarf->GetDeclContextContainingUID(type_uid);
1397 return {};
1398}
1399
1400std::vector<CompilerContext>
1402 const uint64_t oso_idx = GetOSOIndexFromUserID(type_uid);
1403 if (SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx))
1404 return oso_dwarf->GetCompilerContextForUID(type_uid);
1405 return {};
1406}
1407
1410 ForEachSymbolFile("Parsing declarations", [&](SymbolFileDWARF &oso_dwarf) {
1411 oso_dwarf.ParseDeclsForContext(decl_ctx);
1413 });
1414}
1415
1417 lldb::addr_t exe_file_addr,
1418 lldb::addr_t exe_byte_size,
1419 lldb::addr_t oso_file_addr,
1420 lldb::addr_t oso_byte_size) {
1421 const uint32_t debug_map_idx =
1422 m_debug_map.FindEntryIndexThatContains(exe_file_addr);
1423 if (debug_map_idx != UINT32_MAX) {
1424 DebugMap::Entry *debug_map_entry =
1425 m_debug_map.FindEntryThatContains(exe_file_addr);
1426 debug_map_entry->data.SetOSOFileAddress(oso_file_addr);
1427 addr_t range_size = std::min<addr_t>(exe_byte_size, oso_byte_size);
1428 if (range_size == 0) {
1429 range_size = std::max<addr_t>(exe_byte_size, oso_byte_size);
1430 if (range_size == 0)
1431 range_size = 1;
1432 }
1433 cu_info->file_range_map.Append(
1434 FileRangeMap::Entry(oso_file_addr, range_size, exe_file_addr));
1435 return true;
1436 }
1437 return false;
1438}
1439
1441 cu_info->file_range_map.Sort();
1442#if defined(DEBUG_OSO_DMAP)
1443 const FileRangeMap &oso_file_range_map = cu_info->GetFileRangeMap(this);
1444 const size_t n = oso_file_range_map.GetSize();
1445 printf("SymbolFileDWARFDebugMap::FinalizeOSOFileRanges (cu_info = %p) %s\n",
1446 cu_info, cu_info->oso_sp->module_sp->GetFileSpec().GetPath().c_str());
1447 for (size_t i = 0; i < n; ++i) {
1448 const FileRangeMap::Entry &entry = oso_file_range_map.GetEntryRef(i);
1449 printf("oso [0x%16.16" PRIx64 " - 0x%16.16" PRIx64
1450 ") ==> exe [0x%16.16" PRIx64 " - 0x%16.16" PRIx64 ")\n",
1451 entry.GetRangeBase(), entry.GetRangeEnd(), entry.data,
1452 entry.data + entry.GetByteSize());
1453 }
1454#endif
1455}
1456
1459 lldb::addr_t oso_file_addr) {
1460 CompileUnitInfo *cu_info = GetCompileUnitInfo(oso_symfile);
1461 if (cu_info) {
1462 const FileRangeMap::Entry *oso_range_entry =
1463 cu_info->GetFileRangeMap(this).FindEntryThatContains(oso_file_addr);
1464 if (oso_range_entry) {
1465 const DebugMap::Entry *debug_map_entry =
1466 m_debug_map.FindEntryThatContains(oso_range_entry->data);
1467 if (debug_map_entry) {
1468 const lldb::addr_t offset =
1469 oso_file_addr - oso_range_entry->GetRangeBase();
1470 const lldb::addr_t exe_file_addr =
1471 debug_map_entry->GetRangeBase() + offset;
1472 return exe_file_addr;
1473 }
1474 }
1475 }
1476 return LLDB_INVALID_ADDRESS;
1477}
1478
1480 // Make sure this address hasn't been fixed already
1481 Module *exe_module = GetObjectFile()->GetModule().get();
1482 Module *addr_module = addr.GetModule().get();
1483 if (addr_module == exe_module)
1484 return true; // Address is already in terms of the main executable module
1485
1488 if (cu_info) {
1489 const lldb::addr_t oso_file_addr = addr.GetFileAddress();
1490 const FileRangeMap::Entry *oso_range_entry =
1491 cu_info->GetFileRangeMap(this).FindEntryThatContains(oso_file_addr);
1492 if (oso_range_entry) {
1493 const DebugMap::Entry *debug_map_entry =
1494 m_debug_map.FindEntryThatContains(oso_range_entry->data);
1495 if (debug_map_entry) {
1496 const lldb::addr_t offset =
1497 oso_file_addr - oso_range_entry->GetRangeBase();
1498 const lldb::addr_t exe_file_addr =
1499 debug_map_entry->GetRangeBase() + offset;
1500 return exe_module->ResolveFileAddress(exe_file_addr, addr);
1501 }
1502 }
1503 }
1504 return true;
1505}
1506
1508 LineTable *line_table) {
1509 CompileUnitInfo *cu_info = GetCompileUnitInfo(oso_dwarf);
1510 if (cu_info)
1511 return line_table->LinkLineTable(cu_info->GetFileRangeMap(this));
1512 return nullptr;
1513}
1514
1515size_t
1517 DWARFDebugAranges *debug_aranges) {
1518 size_t num_line_entries_added = 0;
1519 if (debug_aranges && dwarf2Data) {
1520 CompileUnitInfo *compile_unit_info = GetCompileUnitInfo(dwarf2Data);
1521 if (compile_unit_info) {
1522 const FileRangeMap &file_range_map =
1523 compile_unit_info->GetFileRangeMap(this);
1524 for (size_t idx = 0; idx < file_range_map.GetSize(); idx++) {
1525 const FileRangeMap::Entry *entry = file_range_map.GetEntryAtIndex(idx);
1526 if (entry) {
1527 debug_aranges->AppendRange(*dwarf2Data->GetFileIndex(),
1528 entry->GetRangeBase(),
1529 entry->GetRangeEnd());
1530 num_line_entries_added++;
1531 }
1532 }
1533 }
1534 }
1535 return num_line_entries_added;
1536}
1537
1539 ModuleList oso_modules;
1540 ForEachSymbolFile("Parsing modules", [&](SymbolFileDWARF &oso_dwarf) {
1541 ObjectFile *oso_objfile = oso_dwarf.GetObjectFile();
1542 if (oso_objfile) {
1543 ModuleSP module_sp = oso_objfile->GetModule();
1544 if (module_sp)
1545 oso_modules.Append(module_sp);
1546 }
1548 });
1549 return oso_modules;
1550}
1551
1553 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1554
1555 // We need to make sure that our PC value from the frame matches the module
1556 // for this object file since we will lookup the PC file address in the debug
1557 // map below.
1558 Address pc_addr = frame.GetFrameCodeAddress();
1559 if (pc_addr.GetModule() == m_objfile_sp->GetModule()) {
1560 Symtab *symtab = m_objfile_sp->GetSymtab();
1561 if (symtab) {
1562 const DebugMap::Entry *debug_map_entry =
1563 m_debug_map.FindEntryThatContains(pc_addr.GetFileAddress());
1564 if (debug_map_entry) {
1565 Symbol *symbol =
1566 symtab->SymbolAtIndex(debug_map_entry->data.GetExeSymbolIndex());
1567 if (symbol) {
1568 uint32_t oso_idx = 0;
1569 CompileUnitInfo *comp_unit_info =
1570 GetCompileUnitInfoForSymbolWithID(symbol->GetID(), &oso_idx);
1571 if (comp_unit_info) {
1572 Module *oso_module = GetModuleByCompUnitInfo(comp_unit_info);
1573 if (oso_module) {
1574 // Check the .o file's DWARF in case it has an error to display.
1575 SymbolFile *oso_sym_file = oso_module->GetSymbolFile();
1576 if (oso_sym_file)
1577 return oso_sym_file->GetFrameVariableError(frame);
1578 }
1579 // If we don't have a valid OSO module here, then something went
1580 // wrong as we have a symbol for the address in the debug map, but
1581 // we weren't able to open the .o file. Display an appropriate
1582 // error
1583 if (comp_unit_info->oso_load_error.Fail())
1584 return comp_unit_info->oso_load_error.Clone();
1585 else
1587 "unable to load debug map object file \"%s\" "
1588 "exist, debug info will not be loaded",
1589 comp_unit_info->oso_path.GetCString());
1590 }
1591 }
1592 }
1593 }
1594 }
1595 return Status();
1596}
1597
1599 std::unordered_map<lldb::CompUnitSP, lldb_private::Args> &args) {
1600
1601 ForEachSymbolFile("Parsing compile options", [&](SymbolFileDWARF &oso_dwarf) {
1602 oso_dwarf.GetCompileOptions(args);
1604 });
1605}
1606
1607llvm::Expected<SymbolContext>
1609 const uint64_t oso_idx = GetOSOIndexFromUserID(label.symbol_id);
1610 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx);
1611 if (!oso_dwarf)
1612 return llvm::createStringError(llvm::formatv(
1613 "couldn't find symbol file for {0} in debug-map.", label));
1614
1615 return oso_dwarf->ResolveFunctionCallLabel(label);
1616}
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
Definition Log.h:369
#define LLDB_LOGF(log,...)
Definition Log.h:376
static void RemoveFunctionsWithModuleNotEqualTo(const ModuleSP &module_sp, SymbolContextList &sc_list, uint32_t start_idx)
#define LLDB_SCOPED_TIMERF(...)
Definition Timer.h:86
A section + offset based address class.
Definition Address.h:62
lldb::SectionSP GetSection() const
Get const accessor for the section.
Definition Address.h:432
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
Definition Address.cpp:273
lldb::addr_t GetFileAddress() const
Get the file address.
Definition Address.cpp:281
An architecture specification class.
Definition ArchSpec.h:31
bool SetTriple(const llvm::Triple &triple)
Architecture triple setter.
Definition ArchSpec.cpp:732
A class that describes a compilation unit.
Definition CompileUnit.h:43
lldb::LanguageType GetLanguage()
Represents a generic declaration context in a program.
Generic representation of a type in a programming language.
A uniqued constant string class.
Definition ConstString.h:40
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
const char * GetCString() const
Get the string value as a C string.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A file utility class.
Definition FileSpec.h:57
static bool Match(const FileSpec &pattern, const FileSpec &file)
Match FileSpec pattern against FileSpec file.
Definition FileSpec.cpp:301
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition FileSpec.cpp:374
static FileSystem & Instance()
A class that describes a function.
Definition Function.h:400
const Address & GetAddress() const
Return the address of the function (its entry point).
Definition Function.h:453
CompileUnit * GetCompileUnit()
Get accessor for the compile unit that owns this function.
Definition Function.cpp:397
A line table class.
Definition LineTable.h:25
LineTable * LinkLineTable(const FileRangeMap &file_range_map)
ConstString GetName(NamePreference preference=ePreferDemangled) const
Best name get accessor.
Definition Mangled.cpp:369
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
A collection class for Module objects.
Definition ModuleList.h:104
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
A class that encapsulates name lookup information.
Definition Module.h:916
ConstString GetLookupName() const
Definition Module.h:927
A class that describes an executable image and its associated object and symbol files.
Definition Module.h:90
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
Definition Module.cpp:1177
virtual SymbolFile * GetSymbolFile(bool can_create=true, Stream *feedback_strm=nullptr)
Get the module's symbol file.
Definition Module.cpp:977
std::recursive_mutex m_mutex
A mutex to keep this object happy in multi-threaded environments.
Definition Module.h:1003
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr)
Definition Module.cpp:447
lldb::SymbolVendorUP m_symfile_up
A pointer to the symbol vendor for this module.
Definition Module.h:1040
Module(const FileSpec &file_spec, const ArchSpec &arch, ConstString object_name=ConstString(), lldb::offset_t object_offset=0, const llvm::sys::TimePoint<> &object_mod_time=llvm::sys::TimePoint<>())
Construct with file specification and architecture.
Definition Module.cpp:238
friend class ObjectFile
Definition Module.h:1091
std::string GetSpecificationDescription() const
Get the module path and object name.
Definition Module.cpp:1021
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
Definition Module.h:454
friend class SymbolFile
Definition Module.h:1092
A plug-in interface definition class for object file parsers.
Definition ObjectFile.h:45
Symtab * GetSymtab(bool can_create=true)
Gets the symbol table for the currently selected architecture (and object for archives).
@ eTypeExecutable
A normal executable.
Definition ObjectFile.h:54
@ eTypeDebugInfo
An object file that contains only debug information.
Definition ObjectFile.h:56
@ eTypeStubLibrary
A library that can be linked against but not used for execution.
Definition ObjectFile.h:64
@ eTypeObjectFile
An intermediate object file.
Definition ObjectFile.h:60
@ eTypeDynamicLinker
The platform's dynamic linker executable.
Definition ObjectFile.h:58
@ eTypeCoreFile
A core file that has a checkpoint of a program's execution state.
Definition ObjectFile.h:52
@ eTypeSharedLibrary
A shared library that can be used during execution.
Definition ObjectFile.h:62
@ eTypeJIT
JIT code that has symbols, sections and possibly debug info.
Definition ObjectFile.h:66
virtual void ClearSymtab()
Frees the symbol table.
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
Definition ObjectFile.h:281
static bool SplitArchivePathWithObject(llvm::StringRef path_with_object, lldb_private::FileSpec &archive_file, lldb_private::ConstString &archive_object, bool must_exist)
Split a path into a file path with object name.
virtual llvm::StringRef GetPluginName()=0
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A Progress indicator helper class.
Definition Progress.h:60
void Increment(uint64_t amount=1, std::optional< std::string > updated_detail={})
Increment the progress and send a notification to the installed callback.
Definition Progress.cpp:62
static constexpr std::chrono::milliseconds kDefaultHighFrequencyReportTime
The default report time for high frequency progress reports.
Definition Progress.h:119
Entry & GetEntryRef(size_t i)
Definition RangeMap.h:554
const Entry * GetEntryAtIndex(size_t i) const
Definition RangeMap.h:544
RangeData< lldb::addr_t, lldb::addr_t, OSOEntry > Entry
Definition RangeMap.h:462
void Append(const Entry &entry)
Definition RangeMap.h:470
Entry * FindEntryThatContains(B addr)
Definition RangeMap.h:579
llvm::StringRef GetText() const
Access the regular expression text.
This base class provides an interface to stack frames.
Definition StackFrame.h:44
const Address & GetFrameCodeAddress()
Get an Address for the current pc value in this StackFrame.
An error handling class.
Definition Status.h:118
Status Clone() const
Don't call this function in new code.
Definition Status.h:174
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition Status.cpp:106
bool Fail() const
Test for error condition.
Definition Status.cpp:294
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition Status.cpp:195
A stream class that can stream formatted output to a file.
Definition Stream.h:28
void AddItem(const ObjectSP &item)
void AddStringItem(llvm::StringRef key, llvm::StringRef value)
void AddItem(llvm::StringRef key, ObjectSP value_sp)
std::shared_ptr< Dictionary > DictionarySP
A list of support files for a CompileUnit.
Defines a list of symbol context objects.
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
uint32_t GetSize() const
Get accessor for a symbol context list size.
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
virtual void CalculateSymbolContext(SymbolContext *sc)=0
Reconstruct the object's symbol context into sc.
Defines a symbol context baton that can be handed other debug core functions.
Function * function
The Function for a given query.
CompileUnit * comp_unit
The CompileUnit for a given query.
Symbol * symbol
The Symbol for a given query.
ObjectFile * GetObjectFile() override
Definition SymbolFile.h:566
lldb::ObjectFileSP m_objfile_sp
Definition SymbolFile.h:642
ObjectFile * GetMainObjectFile() override
void SetCompileUnitAtIndex(uint32_t idx, const lldb::CompUnitSP &cu_sp)
SymbolFileCommon(lldb::ObjectFileSP objfile_sp)
Definition SymbolFile.h:551
uint32_t GetNumCompileUnits() override
Provides public interface for all SymbolFiles.
Definition SymbolFile.h:51
virtual std::recursive_mutex & GetModuleMutex() const
Symbols file subclasses should override this to return the Module that owns the TypeSystem that this ...
Status GetFrameVariableError(StackFrame &frame)
Get an error that describes why variables might be missing for a given symbol context.
Definition SymbolFile.h:280
std::unordered_map< lldb::CompUnitSP, Args > GetCompileOptions()
Returns a map of compilation unit to the compile option arguments associated with that compilation un...
Definition SymbolFile.h:516
uint32_t GetSiblingIndex() const
Definition Symbol.cpp:217
uint64_t GetIntegerValue(uint64_t fail_value=0) const
Definition Symbol.h:118
uint32_t GetID() const
Definition Symbol.h:137
bool ValueIsAddress() const
Definition Symbol.cpp:165
bool IsDebug() const
Definition Symbol.h:193
Mangled & GetMangled()
Definition Symbol.h:147
Address & GetAddressRef()
Definition Symbol.h:73
lldb::addr_t GetByteSize() const
Definition Symbol.cpp:431
ConstString GetName() const
Definition Symbol.cpp:511
lldb::SymbolType GetType() const
Definition Symbol.h:169
Symbol * SymbolAtIndex(size_t idx)
Definition Symtab.cpp:228
Symbol * FindFirstSymbolWithNameAndType(ConstString name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility)
Definition Symtab.cpp:874
void SortSymbolIndexesByValue(std::vector< uint32_t > &indexes, bool remove_duplicates) const
Definition Symtab.cpp:625
uint32_t AppendSymbolIndexesWithType(lldb::SymbolType symbol_type, std::vector< uint32_t > &indexes, uint32_t start_idx=0, uint32_t end_index=UINT32_MAX) const
Definition Symtab.cpp:499
uint32_t GetIndexForSymbol(const Symbol *symbol) const
Definition Symtab.cpp:560
uint32_t AppendSymbolIndexesWithTypeAndFlagsValue(lldb::SymbolType symbol_type, uint32_t flags_value, std::vector< uint32_t > &indexes, uint32_t start_idx=0, uint32_t end_index=UINT32_MAX) const
Definition Symtab.cpp:517
const Symbol * GetParent(Symbol *symbol) const
Get the parent symbol for the given symbol.
Definition Symtab.cpp:1160
A class that contains all state required for type lookups.
Definition Type.h:104
This class tracks the state and results of a TypeQuery.
Definition Type.h:344
bool Done(const TypeQuery &query) const
Check if the type matching has found all of the matches that it needs.
Definition Type.cpp:200
An abstraction for Xcode-style SDKs that works like ArchSpec.
Definition XcodeSDK.h:25
void AppendRange(dw_offset_t cu_offset, dw_addr_t low_pc, dw_addr_t high_pc)
DebugMapModule(const ModuleSP &exe_module_sp, uint32_t cu_idx, const FileSpec &file_spec, const ArchSpec &arch, ConstString object_name, off_t object_offset, const llvm::sys::TimePoint<> object_mod_time)
SymbolFile * GetSymbolFile(bool can_create=true, lldb_private::Stream *feedback_strm=nullptr) override
Get the module's symbol file.
void ForEachSymbolFile(std::string description, std::function< IterationAction(SymbolFileDWARF &)> closure)
If closure returns IterationAction::Continue, iteration continues.
static SymbolFileDWARF * GetSymbolFileAsSymbolFileDWARF(SymbolFile *sym_file)
RangeDataVector< lldb::addr_t, lldb::addr_t, lldb::addr_t > FileRangeMap
Status CalculateFrameVariableError(StackFrame &frame) override
Subclasses will override this function to for GetFrameVariableError().
CompileUnitInfo * GetCompUnitInfo(const SymbolContext &sc)
std::map< std::pair< ConstString, llvm::sys::TimePoint<> >, OSOInfoSP > m_oso_map
CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) override
void DumpClangAST(Stream &s, llvm::StringRef filter, bool show_color) override
void ParseDeclsForContext(CompilerDeclContext decl_ctx) override
bool GetSeparateDebugInfo(StructuredData::Dictionary &d, bool errors_only, bool load_all_debug_info=false) override
List separate oso files.
void FindGlobalVariables(ConstString name, const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, VariableList &variables) override
SymbolFileDWARF * GetSymbolFileByCompUnitInfo(CompileUnitInfo *comp_unit_info)
lldb::CompUnitSP GetCompileUnit(SymbolFileDWARF *oso_dwarf, DWARFCompileUnit &dwarf_cu)
Returns the compile unit associated with the dwarf compile unit.
bool ForEachExternalModule(CompileUnit &, llvm::DenseSet< SymbolFile * > &, llvm::function_ref< bool(Module &)>) override
uint32_t ResolveSymbolContext(const Address &so_addr, lldb::SymbolContextItem resolve_scope, SymbolContext &sc) override
lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE &die, ConstString type_name, bool must_be_implementation)
CompileUnitInfo * GetCompileUnitInfoForSymbolWithIndex(uint32_t symbol_idx, uint32_t *oso_idx_ptr)
bool CompleteType(CompilerType &compiler_type) override
ModuleList GetDebugInfoModules() override
Get the additional modules that this symbol file uses to parse debug info.
lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override
This function actually returns the first compile unit the object file at the given index contains.
std::vector< CompilerContext > GetCompilerContextForUID(lldb::user_id_t uid) override
lldb::addr_t LinkOSOFileAddress(SymbolFileDWARF *oso_symfile, lldb::addr_t oso_file_addr)
Convert a .o file "file address" to an executable "file address".
SymbolFileDWARF * GetSymbolFile(const SymbolContext &sc)
void PrivateFindGlobalVariables(ConstString name, const CompilerDeclContext &parent_decl_ctx, const std::vector< uint32_t > &name_symbol_indexes, uint32_t max_matches, VariableList &variables)
void FindTypes(const lldb_private::TypeQuery &match, lldb_private::TypeResults &results) override
Find types using a type-matching object that contains all search parameters.
std::optional< ArrayInfo > GetDynamicArrayInfoForUID(lldb::user_id_t type_uid, const ExecutionContext *exe_ctx) override
If type_uid points to an array type, return its characteristics.
CompileUnitInfo * GetCompileUnitInfo(SymbolFileDWARF *oso_dwarf)
bool GetFileSpecForSO(uint32_t oso_idx, FileSpec &file_spec)
ObjectFile * GetObjectFileByCompUnitInfo(CompileUnitInfo *comp_unit_info)
static SymbolFile * CreateInstance(lldb::ObjectFileSP objfile_sp)
CompilerDeclContext FindNamespace(ConstString name, const CompilerDeclContext &parent_decl_ctx, bool only_root_namespaces) override
Finds a namespace of name name and whose parent context is parent_decl_ctx.
std::vector< std::unique_ptr< CallEdge > > ParseCallEdgesInFunction(UserID func_id) override
lldb::LanguageType ParseLanguage(CompileUnit &comp_unit) override
size_t ParseVariablesForContext(const SymbolContext &sc) override
llvm::SmallSet< lldb::LanguageType, 4 > ParseAllLanguages(CompileUnit &comp_unit) override
This function exists because SymbolFileDWARFDebugMap may extra compile units which aren't exposed as ...
uint32_t GetCompUnitInfoIndex(const CompileUnitInfo *comp_unit_info)
Module * GetModuleByCompUnitInfo(CompileUnitInfo *comp_unit_info)
XcodeSDK ParseXcodeSDK(CompileUnit &comp_unit) override
Return the Xcode SDK comp_unit was compiled against.
size_t AddOSOARanges(SymbolFileDWARF *dwarf2Data, DWARFDebugAranges *debug_aranges)
void FindFunctions(const Module::LookupInfo &lookup_info, const CompilerDeclContext &parent_decl_ctx, bool include_inlines, SymbolContextList &sc_list) override
void GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask, TypeList &type_list) override
llvm::Expected< SymbolContext > ResolveFunctionCallLabel(FunctionCallLabel &label) override
Resolves the function corresponding to the specified LLDB function call label.
bool AddOSOFileRange(CompileUnitInfo *cu_info, lldb::addr_t exe_file_addr, lldb::addr_t exe_byte_size, lldb::addr_t oso_file_addr, lldb::addr_t oso_byte_size)
bool ParseSupportFiles(CompileUnit &comp_unit, SupportFileList &support_files) override
void SetCompileUnit(SymbolFileDWARF *oso_dwarf, const lldb::CompUnitSP &cu_sp)
Type * ResolveTypeUID(lldb::user_id_t type_uid) override
static int SymbolContainsSymbolWithID(lldb::user_id_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info)
static int SymbolContainsSymbolWithIndex(uint32_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info)
uint32_t CalculateNumCompileUnits() override
This function actually returns the number of object files, which may be less than the actual number o...
bool ParseImportedModules(const SymbolContext &sc, std::vector< SourceModule > &imported_modules) override
size_t GetCompUnitInfosForModule(const Module *oso_module, std::vector< CompileUnitInfo * > &cu_infos)
bool LinkOSOAddress(Address &addr)
Convert addr from a .o file address, to an executable address.
void InitializeObject() override
Initialize the SymbolFile object.
CompilerDeclContext GetDeclContextForUID(lldb::user_id_t uid) override
CompileUnitInfo * GetCompileUnitInfoForSymbolWithID(lldb::user_id_t symbol_id, uint32_t *oso_idx_ptr)
LineTable * LinkOSOLineTable(SymbolFileDWARF *oso_symfile, LineTable *line_table)
Given a line table full of lines with "file addresses" that are for a .o file represented by oso_symf...
CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) override
void FindGlobalVariables(ConstString name, const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, VariableList &variables) override
virtual DWARFDIE FindDefinitionDIE(const DWARFDIE &die)
bool ForEachExternalModule(CompileUnit &, llvm::DenseSet< SymbolFile * > &, llvm::function_ref< bool(Module &)>) override
virtual lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE &die, ConstString type_name, bool must_be_implementation)
llvm::Expected< SymbolContext > ResolveFunctionCallLabel(FunctionCallLabel &label) override
Resolves the function corresponding to the specified LLDB function call label.
void SetDebugMapModule(const lldb::ModuleSP &module_sp)
void DumpClangAST(Stream &s, llvm::StringRef filter, bool show_colors) override
std::vector< CompilerContext > GetCompilerContextForUID(lldb::user_id_t uid) override
void FindTypes(const lldb_private::TypeQuery &match, lldb_private::TypeResults &results) override
Find types using a type-matching object that contains all search parameters.
size_t ParseVariablesForContext(const SymbolContext &sc) override
void GetCompileOptions(std::unordered_map< lldb::CompUnitSP, Args > &args) override
std::optional< ArrayInfo > GetDynamicArrayInfoForUID(lldb::user_id_t type_uid, const ExecutionContext *exe_ctx) override
If type_uid points to an array type, return its characteristics.
size_t ParseBlocksRecursive(Function &func) override
Type * ResolveTypeUID(lldb::user_id_t type_uid) override
size_t ParseFunctions(CompileUnit &comp_unit) override
bool ParseDebugMacros(CompileUnit &comp_unit) override
bool ParseSupportFiles(CompileUnit &comp_unit, SupportFileList &support_files) override
XcodeSDK ParseXcodeSDK(CompileUnit &comp_unit) override
Return the Xcode SDK comp_unit was compiled against.
bool ParseImportedModules(const SymbolContext &sc, std::vector< SourceModule > &imported_modules) override
void GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask, TypeList &type_list) override
void ParseDeclsForContext(CompilerDeclContext decl_ctx) override
size_t ParseTypes(CompileUnit &comp_unit) override
bool CompleteType(CompilerType &compiler_type) override
bool ParseLineTable(CompileUnit &comp_unit) override
bool ParseIsOptimized(CompileUnit &comp_unit) override
void SetFileIndex(std::optional< uint64_t > file_index)
void FindFunctions(const Module::LookupInfo &lookup_info, const CompilerDeclContext &parent_decl_ctx, bool include_inlines, SymbolContextList &sc_list) override
uint32_t ResolveSymbolContext(const Address &so_addr, lldb::SymbolContextItem resolve_scope, SymbolContext &sc) override
bool HasForwardDeclForCompilerType(const CompilerType &compiler_type)
CompilerDeclContext FindNamespace(ConstString name, const CompilerDeclContext &parent_decl_ctx, bool only_root_namespaces) override
Finds a namespace of name name and whose parent context is parent_decl_ctx.
std::vector< std::unique_ptr< CallEdge > > ParseCallEdgesInFunction(UserID func_id) override
lldb::LanguageType ParseLanguage(CompileUnit &comp_unit) override
CompilerDeclContext GetDeclContextForUID(lldb::user_id_t uid) override
std::optional< uint64_t > GetFileIndex() const
#define LLDB_INVALID_ADDRESS
#define UINT32_MAX
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:332
int(* ComparisonFunction)(const void *, const void *)
IterationAction
Useful for callbacks whose return type indicates whether to continue iteration or short-circuit.
std::weak_ptr< lldb_private::Module > ModuleWP
std::shared_ptr< lldb_private::ObjectFile > ObjectFileSP
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::Type > TypeSP
@ eSymbolTypeObjCClass
@ eSymbolTypeObjectFile
@ eSymbolTypeSourceFile
uint64_t user_id_t
Definition lldb-types.h:82
std::shared_ptr< lldb_private::Section > SectionSP
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::Module > ModuleSP
std::shared_ptr< lldb_private::CompileUnit > CompUnitSP
Holds parsed information about a function call label that LLDB attaches as an AsmLabel to function AS...
Definition Expression.h:110
lldb::user_id_t symbol_id
Unique identifier of the function symbol on which to perform the function call.
Definition Expression.h:122
BaseType GetRangeBase() const
Definition RangeMap.h:45
SizeType GetByteSize() const
Definition RangeMap.h:87
BaseType GetRangeEnd() const
Definition RangeMap.h:78
A mix in class that contains a generic user ID.
Definition UserID.h:31
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition UserID.h:47
const FileRangeMap & GetFileRangeMap(SymbolFileDWARFDebugMap *exe_symfile)