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/Section.h"
21#include "lldb/Utility/Timer.h"
23
24//#define DEBUG_OSO_DMAP // DO NOT CHECKIN WITH THIS NOT COMMENTED OUT
25#if defined(DEBUG_OSO_DMAP)
27#endif
28
33#include "lldb/Symbol/TypeMap.h"
35#include "llvm/Support/ScopedPrinter.h"
36
38
39#include "LogChannelDWARF.h"
40#include "SymbolFileDWARF.h"
41
42#include <memory>
43#include <optional>
44
45using namespace lldb;
46using namespace lldb_private;
47
49
50// Subclass lldb_private::Module so we can intercept the
51// "Module::GetObjectFile()" (so we can fixup the object file sections) and
52// also for "Module::GetSymbolFile()" (so we can fixup the symbol file id.
53
56 SymbolFileDWARFDebugMap *exe_symfile) {
58 return file_range_map;
59
61
62 Module *oso_module = exe_symfile->GetModuleByCompUnitInfo(this);
63 if (!oso_module)
64 return file_range_map;
65
66 ObjectFile *oso_objfile = oso_module->GetObjectFile();
67 if (!oso_objfile)
68 return file_range_map;
69
70 Log *log = GetLog(DWARFLog::DebugMap);
72 log,
73 "%p: SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap ('%s')",
74 static_cast<void *>(this),
75 oso_module->GetSpecificationDescription().c_str());
76
77 std::vector<SymbolFileDWARFDebugMap::CompileUnitInfo *> cu_infos;
78 if (exe_symfile->GetCompUnitInfosForModule(oso_module, cu_infos)) {
79 for (auto comp_unit_info : cu_infos) {
80 Symtab *exe_symtab = exe_symfile->GetObjectFile()->GetSymtab();
81 ModuleSP oso_module_sp(oso_objfile->GetModule());
82 Symtab *oso_symtab = oso_objfile->GetSymtab();
83
84 /// const uint32_t fun_resolve_flags = SymbolContext::Module |
85 /// eSymbolContextCompUnit | eSymbolContextFunction;
86 // SectionList *oso_sections = oso_objfile->Sections();
87 // Now we need to make sections that map from zero based object file
88 // addresses to where things ended up in the main executable.
89
90 assert(comp_unit_info->first_symbol_index != UINT32_MAX);
91 // End index is one past the last valid symbol index
92 const uint32_t oso_end_idx = comp_unit_info->last_symbol_index + 1;
93 for (uint32_t idx = comp_unit_info->first_symbol_index +
94 2; // Skip the N_SO and N_OSO
95 idx < oso_end_idx; ++idx) {
96 Symbol *exe_symbol = exe_symtab->SymbolAtIndex(idx);
97 if (exe_symbol) {
98 if (!exe_symbol->IsDebug())
99 continue;
100
101 switch (exe_symbol->GetType()) {
102 default:
103 break;
104
105 case eSymbolTypeCode: {
106 // For each N_FUN, or function that we run into in the debug map we
107 // make a new section that we add to the sections found in the .o
108 // file. This new section has the file address set to what the
109 // addresses are in the .o file, and the load address is adjusted
110 // to match where it ended up in the final executable! We do this
111 // before we parse any dwarf info so that when it goes get parsed
112 // all section/offset addresses that get registered will resolve
113 // correctly to the new addresses in the main executable.
114
115 // First we find the original symbol in the .o file's symbol table
116 Symbol *oso_fun_symbol = oso_symtab->FindFirstSymbolWithNameAndType(
117 exe_symbol->GetMangled().GetName(Mangled::ePreferMangled),
119 if (oso_fun_symbol) {
120 // Add the inverse OSO file address to debug map entry mapping
121 exe_symfile->AddOSOFileRange(
122 this, exe_symbol->GetAddressRef().GetFileAddress(),
123 exe_symbol->GetByteSize(),
124 oso_fun_symbol->GetAddressRef().GetFileAddress(),
125 oso_fun_symbol->GetByteSize());
126 }
127 } break;
128
129 case eSymbolTypeData: {
130 // For each N_GSYM we remap the address for the global by making a
131 // new section that we add to the sections found in the .o file.
132 // This new section has the file address set to what the addresses
133 // are in the .o file, and the load address is adjusted to match
134 // where it ended up in the final executable! We do this before we
135 // parse any dwarf info so that when it goes get parsed all
136 // section/offset addresses that get registered will resolve
137 // correctly to the new addresses in the main executable. We
138 // initially set the section size to be 1 byte, but will need to
139 // fix up these addresses further after all globals have been
140 // parsed to span the gaps, or we can find the global variable
141 // sizes from the DWARF info as we are parsing.
142
143 // Next we find the non-stab entry that corresponds to the N_GSYM
144 // in the .o file
145 Symbol *oso_gsym_symbol =
147 exe_symbol->GetMangled().GetName(Mangled::ePreferMangled),
149 if (exe_symbol && oso_gsym_symbol && exe_symbol->ValueIsAddress() &&
150 oso_gsym_symbol->ValueIsAddress()) {
151 // Add the inverse OSO file address to debug map entry mapping
152 exe_symfile->AddOSOFileRange(
153 this, exe_symbol->GetAddressRef().GetFileAddress(),
154 exe_symbol->GetByteSize(),
155 oso_gsym_symbol->GetAddressRef().GetFileAddress(),
156 oso_gsym_symbol->GetByteSize());
157 }
158 } break;
159 }
160 }
161 }
162
163 exe_symfile->FinalizeOSOFileRanges(this);
164 // We don't need the symbols anymore for the .o files
165 oso_objfile->ClearSymtab();
166 }
167 }
168 return file_range_map;
169}
170
171class DebugMapModule : public Module {
172public:
173 DebugMapModule(const ModuleSP &exe_module_sp, uint32_t cu_idx,
174 const FileSpec &file_spec, const ArchSpec &arch,
175 const ConstString *object_name, off_t object_offset,
176 const llvm::sys::TimePoint<> object_mod_time)
177 : Module(file_spec, arch, object_name, object_offset, object_mod_time),
178 m_exe_module_wp(exe_module_sp), m_cu_idx(cu_idx) {}
179
180 ~DebugMapModule() override = default;
181
182 SymbolFile *
183 GetSymbolFile(bool can_create = true,
184 lldb_private::Stream *feedback_strm = nullptr) override {
185 // Scope for locker
186 if (m_symfile_up.get() || !can_create)
187 return m_symfile_up ? m_symfile_up->GetSymbolFile() : nullptr;
188
189 ModuleSP exe_module_sp(m_exe_module_wp.lock());
190 if (exe_module_sp) {
191 // Now get the object file outside of a locking scope
192 ObjectFile *oso_objfile = GetObjectFile();
193 if (oso_objfile) {
194 std::lock_guard<std::recursive_mutex> guard(m_mutex);
195 if (SymbolFile *symfile =
196 Module::GetSymbolFile(can_create, feedback_strm)) {
197 // Set a pointer to this class to set our OSO DWARF file know that
198 // the DWARF is being used along with a debug map and that it will
199 // have the remapped sections that we do below.
200 SymbolFileDWARF *oso_symfile =
202
203 if (!oso_symfile)
204 return nullptr;
205
206 ObjectFile *exe_objfile = exe_module_sp->GetObjectFile();
207 SymbolFile *exe_symfile = exe_module_sp->GetSymbolFile();
208
209 if (exe_objfile && exe_symfile) {
210 oso_symfile->SetDebugMapModule(exe_module_sp);
211 // Set the ID of the symbol file DWARF to the index of the OSO
212 // shifted left by 32 bits to provide a unique prefix for any
213 // UserID's that get created in the symbol file.
214 oso_symfile->SetFileIndex((uint64_t)m_cu_idx);
215 }
216 return symfile;
217 }
218 }
219 }
220 return nullptr;
221 }
222
223protected:
226};
227
231}
232
235}
236
238 return "DWARF and DWARF3 debug symbol file reader (debug map).";
239}
240
242 return new SymbolFileDWARFDebugMap(std::move(objfile_sp));
243}
244
246 : SymbolFileCommon(std::move(objfile_sp)), m_flags(), m_compile_unit_infos(),
249
251
253
256 return;
257
259
260 // If the object file has been stripped, there is no sense in looking further
261 // as all of the debug symbols for the debug map will not be available
262 if (m_objfile_sp->IsStripped())
263 return;
264
265 // Also make sure the file type is some sort of executable. Core files, debug
266 // info files (dSYM), object files (.o files), and stub libraries all can
267 switch (m_objfile_sp->GetType()) {
275 return;
276
280 break;
281 }
282
283 // In order to get the abilities of this plug-in, we look at the list of
284 // N_OSO entries (object files) from the symbol table and make sure that
285 // these files exist and also contain valid DWARF. If we get any of that then
286 // we return the abilities of the first N_OSO's DWARF.
287
288 Symtab *symtab = m_objfile_sp->GetSymtab();
289 if (symtab) {
290 Log *log = GetLog(DWARFLog::DebugMap);
291
292 std::vector<uint32_t> oso_indexes;
293 // When a mach-o symbol is encoded, the n_type field is encoded in bits
294 // 23:16, and the n_desc field is encoded in bits 15:0.
295 //
296 // To find all N_OSO entries that are part of the DWARF + debug map we find
297 // only object file symbols with the flags value as follows: bits 23:16 ==
298 // 0x66 (N_OSO) bits 15: 0 == 0x0001 (specifies this is a debug map object
299 // file)
300 const uint32_t k_oso_symbol_flags_value = 0x660001u;
301
302 const uint32_t oso_index_count =
304 eSymbolTypeObjectFile, k_oso_symbol_flags_value, oso_indexes);
305
306 if (oso_index_count > 0) {
313
316
317 for (uint32_t sym_idx : m_func_indexes) {
318 const Symbol *symbol = symtab->SymbolAtIndex(sym_idx);
319 lldb::addr_t file_addr = symbol->GetAddressRef().GetFileAddress();
320 lldb::addr_t byte_size = symbol->GetByteSize();
321 DebugMap::Entry debug_map_entry(
322 file_addr, byte_size, OSOEntry(sym_idx, LLDB_INVALID_ADDRESS));
323 m_debug_map.Append(debug_map_entry);
324 }
325 for (uint32_t sym_idx : m_glob_indexes) {
326 const Symbol *symbol = symtab->SymbolAtIndex(sym_idx);
327 lldb::addr_t file_addr = symbol->GetAddressRef().GetFileAddress();
328 lldb::addr_t byte_size = symbol->GetByteSize();
329 DebugMap::Entry debug_map_entry(
330 file_addr, byte_size, OSOEntry(sym_idx, LLDB_INVALID_ADDRESS));
331 m_debug_map.Append(debug_map_entry);
332 }
334
335 m_compile_unit_infos.resize(oso_index_count);
336
337 for (uint32_t i = 0; i < oso_index_count; ++i) {
338 const uint32_t so_idx = oso_indexes[i] - 1;
339 const uint32_t oso_idx = oso_indexes[i];
340 const Symbol *so_symbol = symtab->SymbolAtIndex(so_idx);
341 const Symbol *oso_symbol = symtab->SymbolAtIndex(oso_idx);
342 if (so_symbol && oso_symbol &&
343 so_symbol->GetType() == eSymbolTypeSourceFile &&
344 oso_symbol->GetType() == eSymbolTypeObjectFile) {
345 m_compile_unit_infos[i].so_file.SetFile(
346 so_symbol->GetName().AsCString(), FileSpec::Style::native);
347 m_compile_unit_infos[i].oso_path = oso_symbol->GetName();
348 m_compile_unit_infos[i].oso_mod_time =
349 llvm::sys::toTimePoint(oso_symbol->GetIntegerValue(0));
350 uint32_t sibling_idx = so_symbol->GetSiblingIndex();
351 // The sibling index can't be less that or equal to the current index
352 // "i"
353 if (sibling_idx == UINT32_MAX) {
354 m_objfile_sp->GetModule()->ReportError(
355 "N_SO in symbol with UID {0} has invalid sibling in debug "
356 "map, "
357 "please file a bug and attach the binary listed in this error",
358 so_symbol->GetID());
359 } else {
360 const Symbol *last_symbol = symtab->SymbolAtIndex(sibling_idx - 1);
361 m_compile_unit_infos[i].first_symbol_index = so_idx;
362 m_compile_unit_infos[i].last_symbol_index = sibling_idx - 1;
363 m_compile_unit_infos[i].first_symbol_id = so_symbol->GetID();
364 m_compile_unit_infos[i].last_symbol_id = last_symbol->GetID();
365
366 LLDB_LOGF(log, "Initialized OSO 0x%8.8x: file=%s", i,
367 oso_symbol->GetName().GetCString());
368 }
369 } else {
370 if (oso_symbol == nullptr)
371 m_objfile_sp->GetModule()->ReportError(
372 "N_OSO symbol[{0}] can't be found, please file a bug and "
373 "attach "
374 "the binary listed in this error",
375 oso_idx);
376 else if (so_symbol == nullptr)
377 m_objfile_sp->GetModule()->ReportError(
378 "N_SO not found for N_OSO symbol[{0}], please file a bug and "
379 "attach the binary listed in this error",
380 oso_idx);
381 else if (so_symbol->GetType() != eSymbolTypeSourceFile)
382 m_objfile_sp->GetModule()->ReportError(
383 "N_SO has incorrect symbol type ({0}) for N_OSO "
384 "symbol[{1}], "
385 "please file a bug and attach the binary listed in this error",
386 so_symbol->GetType(), oso_idx);
387 else if (oso_symbol->GetType() != eSymbolTypeSourceFile)
388 m_objfile_sp->GetModule()->ReportError(
389 "N_OSO has incorrect symbol type ({0}) for N_OSO "
390 "symbol[{1}], "
391 "please file a bug and attach the binary listed in this error",
392 oso_symbol->GetType(), oso_idx);
393 }
394 }
395 }
396 }
397}
398
400 const uint32_t cu_count = GetNumCompileUnits();
401 if (oso_idx < cu_count)
403 return nullptr;
404}
405
407 CompileUnitInfo *comp_unit_info) {
408 if (!comp_unit_info->oso_sp) {
409 auto pos = m_oso_map.find(
410 {comp_unit_info->oso_path, comp_unit_info->oso_mod_time});
411 if (pos != m_oso_map.end()) {
412 comp_unit_info->oso_sp = pos->second;
413 } else {
414 ObjectFile *obj_file = GetObjectFile();
415 comp_unit_info->oso_sp = std::make_shared<OSOInfo>();
416 m_oso_map[{comp_unit_info->oso_path, comp_unit_info->oso_mod_time}] =
417 comp_unit_info->oso_sp;
418 const char *oso_path = comp_unit_info->oso_path.GetCString();
419 FileSpec oso_file(oso_path);
420 ConstString oso_object;
421 if (FileSystem::Instance().Exists(oso_file)) {
422 // The modification time returned by the FS can have a higher precision
423 // than the one from the CU.
424 auto oso_mod_time = std::chrono::time_point_cast<std::chrono::seconds>(
425 FileSystem::Instance().GetModificationTime(oso_file));
426 // A timestamp of 0 means that the linker was in deterministic mode. In
427 // that case, we should skip the check against the filesystem last
428 // modification timestamp, since it will never match.
429 if (comp_unit_info->oso_mod_time != llvm::sys::TimePoint<>() &&
430 oso_mod_time != comp_unit_info->oso_mod_time) {
432 "debug map object file \"%s\" changed (actual: 0x%8.8x, debug "
433 "map: 0x%8.8x) since this executable was linked, debug info "
434 "will not be loaded", 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 ? &oso_object : nullptr, 0,
472 oso_object ? comp_unit_info->oso_mod_time : llvm::sys::TimePoint<>());
473
474 if (!comp_unit_info->oso_sp->module_sp || !comp_unit_info->oso_sp->module_sp->GetObjectFile()) {
475 if (oso_object && 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 }
489 if (comp_unit_info->oso_sp)
490 return comp_unit_info->oso_sp->module_sp.get();
491 return nullptr;
492}
493
495 FileSpec &file_spec) {
496 if (oso_idx < m_compile_unit_infos.size()) {
497 if (m_compile_unit_infos[oso_idx].so_file) {
498 file_spec = m_compile_unit_infos[oso_idx].so_file;
499 return true;
500 }
501 }
502 return false;
503}
504
506 Module *oso_module = GetModuleByOSOIndex(oso_idx);
507 if (oso_module)
508 return oso_module->GetObjectFile();
509 return nullptr;
510}
511
514 return GetSymbolFile(*sc.comp_unit);
515}
516
519 CompileUnitInfo *comp_unit_info = GetCompUnitInfo(comp_unit);
520 if (comp_unit_info)
521 return GetSymbolFileByCompUnitInfo(comp_unit_info);
522 return nullptr;
523}
524
526 CompileUnitInfo *comp_unit_info) {
527 Module *oso_module = GetModuleByCompUnitInfo(comp_unit_info);
528 if (oso_module)
529 return oso_module->GetObjectFile();
530 return nullptr;
531}
532
534 const CompileUnitInfo *comp_unit_info) {
535 if (!m_compile_unit_infos.empty()) {
536 const CompileUnitInfo *first_comp_unit_info = &m_compile_unit_infos.front();
537 const CompileUnitInfo *last_comp_unit_info = &m_compile_unit_infos.back();
538 if (first_comp_unit_info <= comp_unit_info &&
539 comp_unit_info <= last_comp_unit_info)
540 return comp_unit_info - first_comp_unit_info;
541 }
542 return UINT32_MAX;
543}
544
547 unsigned size = m_compile_unit_infos.size();
548 if (oso_idx < size)
550 return nullptr;
551}
552
555 if (sym_file &&
557 return static_cast<SymbolFileDWARF *>(sym_file);
558 return nullptr;
559}
560
562 CompileUnitInfo *comp_unit_info) {
563 if (Module *oso_module = GetModuleByCompUnitInfo(comp_unit_info))
564 return GetSymbolFileAsSymbolFileDWARF(oso_module->GetSymbolFile());
565 return nullptr;
566}
567
569 // In order to get the abilities of this plug-in, we look at the list of
570 // N_OSO entries (object files) from the symbol table and make sure that
571 // these files exist and also contain valid DWARF. If we get any of that then
572 // we return the abilities of the first N_OSO's DWARF.
573
574 const uint32_t oso_index_count = GetNumCompileUnits();
575 if (oso_index_count > 0) {
576 InitOSO();
577 if (!m_compile_unit_infos.empty()) {
582 }
583 }
584 return 0;
585}
586
588 InitOSO();
589 return m_compile_unit_infos.size();
590}
591
593 CompUnitSP comp_unit_sp;
594 const uint32_t cu_count = GetNumCompileUnits();
595
596 if (cu_idx < cu_count) {
597 auto &cu_info = m_compile_unit_infos[cu_idx];
598 Module *oso_module = GetModuleByCompUnitInfo(&cu_info);
599 if (oso_module) {
600 FileSpec so_file_spec;
601 if (GetFileSpecForSO(cu_idx, so_file_spec)) {
602 // User zero as the ID to match the compile unit at offset zero in each
603 // .o file.
604 lldb::user_id_t cu_id = 0;
605 cu_info.compile_units_sps.push_back(
606 std::make_shared<CompileUnit>(
607 m_objfile_sp->GetModule(), nullptr, so_file_spec, cu_id,
609 cu_info.id_to_index_map.insert({0, 0});
610 SetCompileUnitAtIndex(cu_idx, cu_info.compile_units_sps[0]);
611 // If there's a symbol file also register all the extra compile units.
612 if (SymbolFileDWARF *oso_symfile =
613 GetSymbolFileByCompUnitInfo(&cu_info)) {
614 auto num_dwarf_units = oso_symfile->DebugInfo().GetNumUnits();
615 for (size_t i = 0; i < num_dwarf_units; ++i) {
616 auto *dwarf_unit = oso_symfile->DebugInfo().GetUnitAtIndex(i);
617 if (auto *dwarf_cu = llvm::dyn_cast<DWARFCompileUnit>(dwarf_unit)) {
618 // The "main" one was already registered.
619 if (dwarf_cu->GetID() == 0)
620 continue;
621 cu_info.compile_units_sps.push_back(std::make_shared<CompileUnit>(
622 m_objfile_sp->GetModule(), nullptr, 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
640 return GetCompUnitInfo(*sc.comp_unit);
641}
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 CompileUnit &comp_unit,
723 llvm::DenseSet<lldb_private::SymbolFile *> &visited_symbol_files,
724 llvm::function_ref<bool(Module &)> f) {
725 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
726 SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
727 if (oso_dwarf)
728 return oso_dwarf->ForEachExternalModule(comp_unit, visited_symbol_files, f);
729 return false;
730}
731
733 FileSpecList &support_files) {
734 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
735 SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
736 if (oso_dwarf)
737 return oso_dwarf->ParseSupportFiles(comp_unit, support_files);
738 return false;
739}
740
742 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
743 SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
744 if (oso_dwarf)
745 return oso_dwarf->ParseIsOptimized(comp_unit);
746 return false;
747}
748
750 const SymbolContext &sc, std::vector<SourceModule> &imported_modules) {
751 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
752 SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc);
753 if (oso_dwarf)
754 return oso_dwarf->ParseImportedModules(sc, imported_modules);
755 return false;
756}
757
759 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
760 CompileUnit *comp_unit = func.GetCompileUnit();
761 if (!comp_unit)
762 return 0;
763
764 SymbolFileDWARF *oso_dwarf = GetSymbolFile(*comp_unit);
765 if (oso_dwarf)
766 return oso_dwarf->ParseBlocksRecursive(func);
767 return 0;
768}
769
771 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
772 SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit);
773 if (oso_dwarf)
774 return oso_dwarf->ParseTypes(comp_unit);
775 return 0;
776}
777
778size_t
780 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
781 SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc);
782 if (oso_dwarf)
783 return oso_dwarf->ParseVariablesForContext(sc);
784 return 0;
785}
786
788 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
789 const uint64_t oso_idx = GetOSOIndexFromUserID(type_uid);
790 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx);
791 if (oso_dwarf)
792 return oso_dwarf->ResolveTypeUID(type_uid);
793 return nullptr;
794}
795
796std::optional<SymbolFile::ArrayInfo>
798 lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx) {
799 const uint64_t oso_idx = GetOSOIndexFromUserID(type_uid);
800 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx);
801 if (oso_dwarf)
802 return oso_dwarf->GetDynamicArrayInfoForUID(type_uid, exe_ctx);
803 return std::nullopt;
804}
805
807 bool success = false;
808 if (compiler_type) {
809 ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
810 if (oso_dwarf->HasForwardDeclForClangType(compiler_type)) {
811 oso_dwarf->CompleteType(compiler_type);
812 success = true;
813 return true;
814 }
815 return false;
816 });
817 }
818 return success;
819}
820
823 SymbolContextItem resolve_scope,
824 SymbolContext &sc) {
825 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
826 uint32_t resolved_flags = 0;
827 Symtab *symtab = m_objfile_sp->GetSymtab();
828 if (symtab) {
829 const addr_t exe_file_addr = exe_so_addr.GetFileAddress();
830
831 const DebugMap::Entry *debug_map_entry =
832 m_debug_map.FindEntryThatContains(exe_file_addr);
833 if (debug_map_entry) {
834
835 sc.symbol =
836 symtab->SymbolAtIndex(debug_map_entry->data.GetExeSymbolIndex());
837
838 if (sc.symbol != nullptr) {
839 resolved_flags |= eSymbolContextSymbol;
840
841 uint32_t oso_idx = 0;
842 CompileUnitInfo *comp_unit_info =
844 if (comp_unit_info) {
845 comp_unit_info->GetFileRangeMap(this);
846 Module *oso_module = GetModuleByCompUnitInfo(comp_unit_info);
847 if (oso_module) {
848 lldb::addr_t oso_file_addr =
849 exe_file_addr - debug_map_entry->GetRangeBase() +
850 debug_map_entry->data.GetOSOFileAddress();
851 Address oso_so_addr;
852 if (oso_module->ResolveFileAddress(oso_file_addr, oso_so_addr)) {
853 resolved_flags |=
854 oso_module->GetSymbolFile()->ResolveSymbolContext(
855 oso_so_addr, resolve_scope, sc);
856 }
857 }
858 }
859 }
860 }
861 }
862 return resolved_flags;
863}
864
866 const SourceLocationSpec &src_location_spec,
867 SymbolContextItem resolve_scope, SymbolContextList &sc_list) {
868 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
869 const uint32_t initial = sc_list.GetSize();
870 const uint32_t cu_count = GetNumCompileUnits();
871
872 for (uint32_t i = 0; i < cu_count; ++i) {
873 // If we are checking for inlines, then we need to look through all compile
874 // units no matter if "file_spec" matches.
875 bool resolve = src_location_spec.GetCheckInlines();
876
877 if (!resolve) {
878 FileSpec so_file_spec;
879 if (GetFileSpecForSO(i, so_file_spec))
880 resolve =
881 FileSpec::Match(src_location_spec.GetFileSpec(), so_file_spec);
882 }
883 if (resolve) {
885 if (oso_dwarf)
886 oso_dwarf->ResolveSymbolContext(src_location_spec, resolve_scope,
887 sc_list);
888 }
889 }
890 return sc_list.GetSize() - initial;
891}
892
894 ConstString name, const CompilerDeclContext &parent_decl_ctx,
895 const std::vector<uint32_t>
896 &indexes, // Indexes into the symbol table that match "name"
897 uint32_t max_matches, VariableList &variables) {
898 const size_t match_count = indexes.size();
899 for (size_t i = 0; i < match_count; ++i) {
900 uint32_t oso_idx;
901 CompileUnitInfo *comp_unit_info =
902 GetCompileUnitInfoForSymbolWithIndex(indexes[i], &oso_idx);
903 if (comp_unit_info) {
904 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx);
905 if (oso_dwarf) {
906 oso_dwarf->FindGlobalVariables(name, parent_decl_ctx, max_matches,
907 variables);
908 if (variables.GetSize() > max_matches)
909 break;
910 }
911 }
912 }
913}
914
916 ConstString name, const CompilerDeclContext &parent_decl_ctx,
917 uint32_t max_matches, VariableList &variables) {
918 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
919 uint32_t total_matches = 0;
920
921 ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
922 const uint32_t old_size = variables.GetSize();
923 oso_dwarf->FindGlobalVariables(name, parent_decl_ctx, max_matches,
924 variables);
925 const uint32_t oso_matches = variables.GetSize() - old_size;
926 if (oso_matches > 0) {
927 total_matches += oso_matches;
928
929 // Are we getting all matches?
930 if (max_matches == UINT32_MAX)
931 return false; // Yep, continue getting everything
932
933 // If we have found enough matches, lets get out
934 if (max_matches >= total_matches)
935 return true;
936
937 // Update the max matches for any subsequent calls to find globals in any
938 // other object files with DWARF
939 max_matches -= oso_matches;
940 }
941
942 return false;
943 });
944}
945
947 const RegularExpression &regex, uint32_t max_matches,
948 VariableList &variables) {
949 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
950 uint32_t total_matches = 0;
951 ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
952 const uint32_t old_size = variables.GetSize();
953 oso_dwarf->FindGlobalVariables(regex, max_matches, variables);
954
955 const uint32_t oso_matches = variables.GetSize() - old_size;
956 if (oso_matches > 0) {
957 total_matches += oso_matches;
958
959 // Are we getting all matches?
960 if (max_matches == UINT32_MAX)
961 return false; // Yep, continue getting everything
962
963 // If we have found enough matches, lets get out
964 if (max_matches >= total_matches)
965 return true;
966
967 // Update the max matches for any subsequent calls to find globals in any
968 // other object files with DWARF
969 max_matches -= oso_matches;
970 }
971
972 return false;
973 });
974}
975
977 uint32_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info) {
978 const uint32_t symbol_idx = *symbol_idx_ptr;
979
980 if (symbol_idx < comp_unit_info->first_symbol_index)
981 return -1;
982
983 if (symbol_idx <= comp_unit_info->last_symbol_index)
984 return 0;
985
986 return 1;
987}
988
990 user_id_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info) {
991 const user_id_t symbol_id = *symbol_idx_ptr;
992
993 if (symbol_id < comp_unit_info->first_symbol_id)
994 return -1;
995
996 if (symbol_id <= comp_unit_info->last_symbol_id)
997 return 0;
998
999 return 1;
1000}
1001
1004 uint32_t symbol_idx, uint32_t *oso_idx_ptr) {
1005 const uint32_t oso_index_count = m_compile_unit_infos.size();
1006 CompileUnitInfo *comp_unit_info = nullptr;
1007 if (oso_index_count) {
1008 comp_unit_info = (CompileUnitInfo *)bsearch(
1009 &symbol_idx, &m_compile_unit_infos[0], m_compile_unit_infos.size(),
1010 sizeof(CompileUnitInfo),
1011 (ComparisonFunction)SymbolContainsSymbolWithIndex);
1012 }
1013
1014 if (oso_idx_ptr) {
1015 if (comp_unit_info != nullptr)
1016 *oso_idx_ptr = comp_unit_info - &m_compile_unit_infos[0];
1017 else
1018 *oso_idx_ptr = UINT32_MAX;
1019 }
1020 return comp_unit_info;
1021}
1022
1025 user_id_t symbol_id, uint32_t *oso_idx_ptr) {
1026 const uint32_t oso_index_count = m_compile_unit_infos.size();
1027 CompileUnitInfo *comp_unit_info = nullptr;
1028 if (oso_index_count) {
1029 comp_unit_info = (CompileUnitInfo *)::bsearch(
1030 &symbol_id, &m_compile_unit_infos[0], m_compile_unit_infos.size(),
1031 sizeof(CompileUnitInfo),
1032 (ComparisonFunction)SymbolContainsSymbolWithID);
1033 }
1034
1035 if (oso_idx_ptr) {
1036 if (comp_unit_info != nullptr)
1037 *oso_idx_ptr = comp_unit_info - &m_compile_unit_infos[0];
1038 else
1039 *oso_idx_ptr = UINT32_MAX;
1040 }
1041 return comp_unit_info;
1042}
1043
1044static void RemoveFunctionsWithModuleNotEqualTo(const ModuleSP &module_sp,
1045 SymbolContextList &sc_list,
1046 uint32_t start_idx) {
1047 // We found functions in .o files. Not all functions in the .o files will
1048 // have made it into the final output file. The ones that did make it into
1049 // the final output file will have a section whose module matches the module
1050 // from the ObjectFile for this SymbolFile. When the modules don't match,
1051 // then we have something that was in a .o file, but doesn't map to anything
1052 // in the final executable.
1053 uint32_t i = start_idx;
1054 while (i < sc_list.GetSize()) {
1055 SymbolContext sc;
1056 sc_list.GetContextAtIndex(i, sc);
1057 if (sc.function) {
1058 const SectionSP section_sp(
1060 if (section_sp->GetModule() != module_sp) {
1061 sc_list.RemoveContextAtIndex(i);
1062 continue;
1063 }
1064 }
1065 ++i;
1066 }
1067}
1068
1070 const Module::LookupInfo &lookup_info,
1071 const CompilerDeclContext &parent_decl_ctx, bool include_inlines,
1072 SymbolContextList &sc_list) {
1073 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1074 LLDB_SCOPED_TIMERF("SymbolFileDWARFDebugMap::FindFunctions (name = %s)",
1075 lookup_info.GetLookupName().GetCString());
1076
1077 ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
1078 uint32_t sc_idx = sc_list.GetSize();
1079 oso_dwarf->FindFunctions(lookup_info, parent_decl_ctx, include_inlines,
1080 sc_list);
1081 if (!sc_list.IsEmpty()) {
1082 RemoveFunctionsWithModuleNotEqualTo(m_objfile_sp->GetModule(), sc_list,
1083 sc_idx);
1084 }
1085 return false;
1086 });
1087}
1088
1090 bool include_inlines,
1091 SymbolContextList &sc_list) {
1092 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1093 LLDB_SCOPED_TIMERF("SymbolFileDWARFDebugMap::FindFunctions (regex = '%s')",
1094 regex.GetText().str().c_str());
1095
1096 ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
1097 uint32_t sc_idx = sc_list.GetSize();
1098
1099 oso_dwarf->FindFunctions(regex, include_inlines, sc_list);
1100 if (!sc_list.IsEmpty()) {
1101 RemoveFunctionsWithModuleNotEqualTo(m_objfile_sp->GetModule(), sc_list,
1102 sc_idx);
1103 }
1104 return false;
1105 });
1106}
1107
1109 lldb::TypeClass type_mask,
1110 TypeList &type_list) {
1111 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1112 LLDB_SCOPED_TIMERF("SymbolFileDWARFDebugMap::GetTypes (type_mask = 0x%8.8x)",
1113 type_mask);
1114
1115 SymbolFileDWARF *oso_dwarf = nullptr;
1116 if (sc_scope) {
1117 SymbolContext sc;
1118 sc_scope->CalculateSymbolContext(&sc);
1119
1120 CompileUnitInfo *cu_info = GetCompUnitInfo(sc);
1121 if (cu_info) {
1122 oso_dwarf = GetSymbolFileByCompUnitInfo(cu_info);
1123 if (oso_dwarf)
1124 oso_dwarf->GetTypes(sc_scope, type_mask, type_list);
1125 }
1126 } else {
1127 ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
1128 oso_dwarf->GetTypes(sc_scope, type_mask, type_list);
1129 return false;
1130 });
1131 }
1132}
1133
1134std::vector<std::unique_ptr<lldb_private::CallEdge>>
1136 lldb_private::UserID func_id) {
1137 uint32_t oso_idx = GetOSOIndexFromUserID(func_id.GetID());
1138 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx);
1139 if (oso_dwarf)
1140 return oso_dwarf->ParseCallEdgesInFunction(func_id);
1141 return {};
1142}
1143
1145 const DWARFDIE &die) {
1146 TypeSP type_sp;
1147 ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
1148 type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die);
1149 return ((bool)type_sp);
1150 });
1151 return type_sp;
1152}
1153
1155 SymbolFileDWARF *skip_dwarf_oso) {
1158 ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
1159 if (skip_dwarf_oso != oso_dwarf &&
1160 oso_dwarf->Supports_DW_AT_APPLE_objc_complete_type(nullptr)) {
1161 m_supports_DW_AT_APPLE_objc_complete_type = eLazyBoolYes;
1162 return true;
1163 }
1164 return false;
1165 });
1166 }
1168}
1169
1171 const DWARFDIE &die, ConstString type_name,
1172 bool must_be_implementation) {
1173 // If we have a debug map, we will have an Objective-C symbol whose name is
1174 // the type name and whose type is eSymbolTypeObjCClass. If we can find that
1175 // symbol and find its containing parent, we can locate the .o file that will
1176 // contain the implementation definition since it will be scoped inside the
1177 // N_SO and we can then locate the SymbolFileDWARF that corresponds to that
1178 // N_SO.
1179 SymbolFileDWARF *oso_dwarf = nullptr;
1180 TypeSP type_sp;
1181 ObjectFile *module_objfile = m_objfile_sp->GetModule()->GetObjectFile();
1182 if (module_objfile) {
1183 Symtab *symtab = module_objfile->GetSymtab();
1184 if (symtab) {
1185 Symbol *objc_class_symbol = symtab->FindFirstSymbolWithNameAndType(
1188 if (objc_class_symbol) {
1189 // Get the N_SO symbol that contains the objective C class symbol as
1190 // this should be the .o file that contains the real definition...
1191 const Symbol *source_file_symbol = symtab->GetParent(objc_class_symbol);
1192
1193 if (source_file_symbol &&
1194 source_file_symbol->GetType() == eSymbolTypeSourceFile) {
1195 const uint32_t source_file_symbol_idx =
1196 symtab->GetIndexForSymbol(source_file_symbol);
1197 if (source_file_symbol_idx != UINT32_MAX) {
1198 CompileUnitInfo *compile_unit_info =
1199 GetCompileUnitInfoForSymbolWithIndex(source_file_symbol_idx,
1200 nullptr);
1201 if (compile_unit_info) {
1202 oso_dwarf = GetSymbolFileByCompUnitInfo(compile_unit_info);
1203 if (oso_dwarf) {
1204 TypeSP type_sp(oso_dwarf->FindCompleteObjCDefinitionTypeForDIE(
1205 die, type_name, must_be_implementation));
1206 if (type_sp) {
1207 return type_sp;
1208 }
1209 }
1210 }
1211 }
1212 }
1213 }
1214 }
1215 }
1216
1217 // Only search all .o files for the definition if we don't need the
1218 // implementation because otherwise, with a valid debug map we should have
1219 // the ObjC class symbol and the code above should have found it.
1220 if (!must_be_implementation) {
1221 TypeSP type_sp;
1222
1223 ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
1224 type_sp = oso_dwarf->FindCompleteObjCDefinitionTypeForDIE(
1225 die, type_name, must_be_implementation);
1226 return (bool)type_sp;
1227 });
1228
1229 return type_sp;
1230 }
1231 return TypeSP();
1232}
1233
1235 ConstString name, const CompilerDeclContext &parent_decl_ctx,
1236 uint32_t max_matches,
1237 llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
1238 TypeMap &types) {
1239 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1240 ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
1241 oso_dwarf->FindTypes(name, parent_decl_ctx, max_matches,
1242 searched_symbol_files, types);
1243 return types.GetSize() >= max_matches;
1244 });
1245}
1246
1248 llvm::ArrayRef<CompilerContext> context, LanguageSet languages,
1249 llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
1250 TypeMap &types) {
1252 ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
1253 oso_dwarf->FindTypes(context, languages, searched_symbol_files, types);
1254 return false;
1255 });
1256}
1257
1260 const CompilerDeclContext &parent_decl_ctx) {
1261 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1262 CompilerDeclContext matching_namespace;
1263
1264 ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
1265 matching_namespace = oso_dwarf->FindNamespace(name, parent_decl_ctx);
1266
1267 return (bool)matching_namespace;
1268 });
1269
1270 return matching_namespace;
1271}
1272
1274 ForEachSymbolFile([&s](SymbolFileDWARF *oso_dwarf) -> bool {
1275 oso_dwarf->DumpClangAST(s);
1276 // The underlying assumption is that DumpClangAST(...) will obtain the
1277 // AST from the underlying TypeSystem and therefore we only need to do
1278 // this once and can stop after the first iteration hence we return true.
1279 return true;
1280 });
1281}
1282
1283lldb::CompUnitSP
1285 if (oso_dwarf) {
1286 const uint32_t cu_count = GetNumCompileUnits();
1287 for (uint32_t cu_idx = 0; cu_idx < cu_count; ++cu_idx) {
1288 SymbolFileDWARF *oso_symfile =
1290 if (oso_symfile == oso_dwarf) {
1291 if (m_compile_unit_infos[cu_idx].compile_units_sps.empty())
1293
1294 auto &id_to_index_map = m_compile_unit_infos[cu_idx].id_to_index_map;
1295 auto it = id_to_index_map.find(dwarf_cu.GetID());
1296 if (it != id_to_index_map.end())
1297 return m_compile_unit_infos[cu_idx]
1298 .compile_units_sps[it->getSecond()];
1299 }
1300 }
1301 }
1302 llvm_unreachable("this shouldn't happen");
1303}
1304
1307 if (oso_dwarf) {
1308 const uint32_t cu_count = GetNumCompileUnits();
1309 for (uint32_t cu_idx = 0; cu_idx < cu_count; ++cu_idx) {
1310 SymbolFileDWARF *oso_symfile =
1312 if (oso_symfile == oso_dwarf) {
1313 return &m_compile_unit_infos[cu_idx];
1314 }
1315 }
1316 }
1317 return nullptr;
1318}
1319
1321 const CompUnitSP &cu_sp) {
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()) {
1329 assert(m_compile_unit_infos[cu_idx].compile_units_sps[0].get() ==
1330 cu_sp.get());
1331 } else {
1332 assert(cu_sp->GetID() == 0 &&
1333 "Setting first compile unit but with id different than 0!");
1334 auto &compile_units_sps = m_compile_unit_infos[cu_idx].compile_units_sps;
1335 compile_units_sps.push_back(cu_sp);
1336 m_compile_unit_infos[cu_idx].id_to_index_map.insert(
1337 {cu_sp->GetID(), compile_units_sps.size() - 1});
1338
1339 SetCompileUnitAtIndex(cu_idx, cu_sp);
1340 }
1341 }
1342 }
1343 }
1344}
1345
1348 const uint64_t oso_idx = GetOSOIndexFromUserID(type_uid);
1349 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx);
1350 if (oso_dwarf)
1351 return oso_dwarf->GetDeclContextForUID(type_uid);
1352 return CompilerDeclContext();
1353}
1354
1357 const uint64_t oso_idx = GetOSOIndexFromUserID(type_uid);
1358 SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx);
1359 if (oso_dwarf)
1360 return oso_dwarf->GetDeclContextContainingUID(type_uid);
1361 return CompilerDeclContext();
1362}
1363
1366 ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
1367 oso_dwarf->ParseDeclsForContext(decl_ctx);
1368 return true; // Keep iterating
1369 });
1370}
1371
1373 lldb::addr_t exe_file_addr,
1374 lldb::addr_t exe_byte_size,
1375 lldb::addr_t oso_file_addr,
1376 lldb::addr_t oso_byte_size) {
1377 const uint32_t debug_map_idx =
1379 if (debug_map_idx != UINT32_MAX) {
1380 DebugMap::Entry *debug_map_entry =
1381 m_debug_map.FindEntryThatContains(exe_file_addr);
1382 debug_map_entry->data.SetOSOFileAddress(oso_file_addr);
1383 addr_t range_size = std::min<addr_t>(exe_byte_size, oso_byte_size);
1384 if (range_size == 0) {
1385 range_size = std::max<addr_t>(exe_byte_size, oso_byte_size);
1386 if (range_size == 0)
1387 range_size = 1;
1388 }
1389 cu_info->file_range_map.Append(
1390 FileRangeMap::Entry(oso_file_addr, range_size, exe_file_addr));
1391 return true;
1392 }
1393 return false;
1394}
1395
1397 cu_info->file_range_map.Sort();
1398#if defined(DEBUG_OSO_DMAP)
1399 const FileRangeMap &oso_file_range_map = cu_info->GetFileRangeMap(this);
1400 const size_t n = oso_file_range_map.GetSize();
1401 printf("SymbolFileDWARFDebugMap::FinalizeOSOFileRanges (cu_info = %p) %s\n",
1402 cu_info, cu_info->oso_sp->module_sp->GetFileSpec().GetPath().c_str());
1403 for (size_t i = 0; i < n; ++i) {
1404 const FileRangeMap::Entry &entry = oso_file_range_map.GetEntryRef(i);
1405 printf("oso [0x%16.16" PRIx64 " - 0x%16.16" PRIx64
1406 ") ==> exe [0x%16.16" PRIx64 " - 0x%16.16" PRIx64 ")\n",
1407 entry.GetRangeBase(), entry.GetRangeEnd(), entry.data,
1408 entry.data + entry.GetByteSize());
1409 }
1410#endif
1411}
1412
1415 lldb::addr_t oso_file_addr) {
1416 CompileUnitInfo *cu_info = GetCompileUnitInfo(oso_symfile);
1417 if (cu_info) {
1418 const FileRangeMap::Entry *oso_range_entry =
1419 cu_info->GetFileRangeMap(this).FindEntryThatContains(oso_file_addr);
1420 if (oso_range_entry) {
1421 const DebugMap::Entry *debug_map_entry =
1422 m_debug_map.FindEntryThatContains(oso_range_entry->data);
1423 if (debug_map_entry) {
1424 const lldb::addr_t offset =
1425 oso_file_addr - oso_range_entry->GetRangeBase();
1426 const lldb::addr_t exe_file_addr =
1427 debug_map_entry->GetRangeBase() + offset;
1428 return exe_file_addr;
1429 }
1430 }
1431 }
1432 return LLDB_INVALID_ADDRESS;
1433}
1434
1436 // Make sure this address hasn't been fixed already
1437 Module *exe_module = GetObjectFile()->GetModule().get();
1438 Module *addr_module = addr.GetModule().get();
1439 if (addr_module == exe_module)
1440 return true; // Address is already in terms of the main executable module
1441
1444 if (cu_info) {
1445 const lldb::addr_t oso_file_addr = addr.GetFileAddress();
1446 const FileRangeMap::Entry *oso_range_entry =
1447 cu_info->GetFileRangeMap(this).FindEntryThatContains(oso_file_addr);
1448 if (oso_range_entry) {
1449 const DebugMap::Entry *debug_map_entry =
1450 m_debug_map.FindEntryThatContains(oso_range_entry->data);
1451 if (debug_map_entry) {
1452 const lldb::addr_t offset =
1453 oso_file_addr - oso_range_entry->GetRangeBase();
1454 const lldb::addr_t exe_file_addr =
1455 debug_map_entry->GetRangeBase() + offset;
1456 return exe_module->ResolveFileAddress(exe_file_addr, addr);
1457 }
1458 }
1459 }
1460 return true;
1461}
1462
1464 LineTable *line_table) {
1465 CompileUnitInfo *cu_info = GetCompileUnitInfo(oso_dwarf);
1466 if (cu_info)
1467 return line_table->LinkLineTable(cu_info->GetFileRangeMap(this));
1468 return nullptr;
1469}
1470
1471size_t
1473 DWARFDebugAranges *debug_aranges) {
1474 size_t num_line_entries_added = 0;
1475 if (debug_aranges && dwarf2Data) {
1476 CompileUnitInfo *compile_unit_info = GetCompileUnitInfo(dwarf2Data);
1477 if (compile_unit_info) {
1478 const FileRangeMap &file_range_map =
1479 compile_unit_info->GetFileRangeMap(this);
1480 for (size_t idx = 0; idx < file_range_map.GetSize(); idx++) {
1481 const FileRangeMap::Entry *entry = file_range_map.GetEntryAtIndex(idx);
1482 if (entry) {
1483 debug_aranges->AppendRange(*dwarf2Data->GetFileIndex(),
1484 entry->GetRangeBase(),
1485 entry->GetRangeEnd());
1486 num_line_entries_added++;
1487 }
1488 }
1489 }
1490 }
1491 return num_line_entries_added;
1492}
1493
1495 ModuleList oso_modules;
1496 ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
1497 ObjectFile *oso_objfile = oso_dwarf->GetObjectFile();
1498 if (oso_objfile) {
1499 ModuleSP module_sp = oso_objfile->GetModule();
1500 if (module_sp)
1501 oso_modules.Append(module_sp);
1502 }
1503 return false; // Keep iterating
1504 });
1505 return oso_modules;
1506}
1507
1509 std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
1510
1511 // We need to make sure that our PC value from the frame matches the module
1512 // for this object file since we will lookup the PC file address in the debug
1513 // map below.
1514 Address pc_addr = frame.GetFrameCodeAddress();
1515 if (pc_addr.GetModule() == m_objfile_sp->GetModule()) {
1516 Symtab *symtab = m_objfile_sp->GetSymtab();
1517 if (symtab) {
1518 const DebugMap::Entry *debug_map_entry =
1520 if (debug_map_entry) {
1521 Symbol *symbol =
1522 symtab->SymbolAtIndex(debug_map_entry->data.GetExeSymbolIndex());
1523 if (symbol) {
1524 uint32_t oso_idx = 0;
1525 CompileUnitInfo *comp_unit_info =
1526 GetCompileUnitInfoForSymbolWithID(symbol->GetID(), &oso_idx);
1527 if (comp_unit_info) {
1528 Module *oso_module = GetModuleByCompUnitInfo(comp_unit_info);
1529 if (oso_module) {
1530 // Check the .o file's DWARF in case it has an error to display.
1531 SymbolFile *oso_sym_file = oso_module->GetSymbolFile();
1532 if (oso_sym_file)
1533 return oso_sym_file->GetFrameVariableError(frame);
1534 }
1535 // If we don't have a valid OSO module here, then something went
1536 // wrong as we have a symbol for the address in the debug map, but
1537 // we weren't able to open the .o file. Display an appropriate
1538 // error
1539 if (comp_unit_info->oso_load_error.Fail())
1540 return comp_unit_info->oso_load_error;
1541 else
1542 return Status("unable to load debug map object file \"%s\" "
1543 "exist, debug info will not be loaded",
1544 comp_unit_info->oso_path.GetCString());
1545 }
1546 }
1547 }
1548 }
1549 }
1550 return Status();
1551}
#define LLDB_LOGF(log,...)
Definition: Log.h:344
static void RemoveFunctionsWithModuleNotEqualTo(const ModuleSP &module_sp, SymbolContextList &sc_list, uint32_t start_idx)
#define LLDB_SCOPED_TIMER()
Definition: Timer.h:83
#define LLDB_SCOPED_TIMERF(...)
Definition: Timer.h:86
void AppendRange(dw_offset_t cu_offset, dw_addr_t low_pc, dw_addr_t high_pc)
SymbolFile * GetSymbolFile(bool can_create=true, lldb_private::Stream *feedback_strm=nullptr) override
Get the module's symbol file.
~DebugMapModule() override=default
DebugMapModule(const ModuleSP &exe_module_sp, uint32_t cu_idx, const FileSpec &file_spec, const ArchSpec &arch, const ConstString *object_name, off_t object_offset, const llvm::sys::TimePoint<> object_mod_time)
std::vector< uint32_t > m_func_indexes
SymbolFileDWARF * GetSymbolFileByOSOIndex(uint32_t oso_idx)
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
static SymbolFileDWARF * GetSymbolFileAsSymbolFileDWARF(SymbolFile *sym_file)
static llvm::StringRef GetPluginDescriptionStatic()
lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE &die, lldb_private::ConstString type_name, bool must_be_implementation)
lldb_private::ObjectFile * GetObjectFileByOSOIndex(uint32_t oso_idx)
std::map< std::pair< lldb_private::ConstString, llvm::sys::TimePoint<> >, OSOInfoSP > m_oso_map
lldb_private::CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) override
void GetTypes(lldb_private::SymbolContextScope *sc_scope, lldb::TypeClass type_mask, lldb_private::TypeList &type_list) override
void DumpClangAST(lldb_private::Stream &s) override
lldb::LanguageType ParseLanguage(lldb_private::CompileUnit &comp_unit) 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.
lldb_private::Status CalculateFrameVariableError(lldb_private::StackFrame &frame) override
Subclasses will override this function to for GetFrameVariableError().
CompileUnitInfo * GetCompileUnitInfoForSymbolWithIndex(uint32_t symbol_idx, uint32_t *oso_idx_ptr)
lldb_private::ModuleList GetDebugInfoModules() override
Get the additional modules that this symbol file uses to parse debug info.
bool Supports_DW_AT_APPLE_objc_complete_type(SymbolFileDWARF *skip_dwarf_oso)
llvm::SmallSet< lldb::LanguageType, 4 > ParseAllLanguages(lldb_private::CompileUnit &comp_unit) override
This function exists because SymbolFileDWARFDebugMap may extra compile units which aren't exposed as ...
lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override
This function actually returns the first compile unit the object file at the given index contains.
bool ParseIsOptimized(lldb_private::CompileUnit &comp_unit) override
CompileUnitInfo * GetCompUnitInfo(const lldb_private::SymbolContext &sc)
size_t ParseVariablesForContext(const lldb_private::SymbolContext &sc) override
size_t ParseTypes(lldb_private::CompileUnit &comp_unit) 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".
void FindGlobalVariables(lldb_private::ConstString name, const lldb_private::CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, lldb_private::VariableList &variables) override
lldb_private::LineTable * LinkOSOLineTable(SymbolFileDWARF *oso_symfile, lldb_private::LineTable *line_table)
Given a line table full of lines with "file addresses" that are for a .o file represented by oso_symf...
CompileUnitInfo * GetCompileUnitInfo(SymbolFileDWARF *oso_dwarf)
bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override
void PrivateFindGlobalVariables(lldb_private::ConstString name, const lldb_private::CompilerDeclContext &parent_decl_ctx, const std::vector< uint32_t > &name_symbol_indexes, uint32_t max_matches, lldb_private::VariableList &variables)
lldb_private::ObjectFile * GetObjectFileByCompUnitInfo(CompileUnitInfo *comp_unit_info)
bool ForEachExternalModule(lldb_private::CompileUnit &, llvm::DenseSet< lldb_private::SymbolFile * > &, llvm::function_ref< bool(lldb_private::Module &)>) override
bool ParseImportedModules(const lldb_private::SymbolContext &sc, std::vector< lldb_private::SourceModule > &imported_modules) override
static lldb_private::SymbolFile * CreateInstance(lldb::ObjectFileSP objfile_sp)
bool CompleteType(lldb_private::CompilerType &compiler_type) override
size_t ParseBlocksRecursive(lldb_private::Function &func) override
bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override
static char ID
LLVM RTTI support.
lldb_private::XcodeSDK ParseXcodeSDK(lldb_private::CompileUnit &comp_unit) override
Return the Xcode SDK comp_unit was compiled against.
std::bitset< kNumFlags > m_flags
lldb_private::CompilerDeclContext FindNamespace(lldb_private::ConstString name, const lldb_private::CompilerDeclContext &parent_decl_ctx) override
lldb_private::Module * GetModuleByOSOIndex(uint32_t oso_idx)
static uint32_t GetOSOIndexFromUserID(lldb::user_id_t uid)
uint32_t GetCompUnitInfoIndex(const CompileUnitInfo *comp_unit_info)
size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override
lldb_private::Module * GetModuleByCompUnitInfo(CompileUnitInfo *comp_unit_info)
size_t AddOSOARanges(SymbolFileDWARF *dwarf2Data, DWARFDebugAranges *debug_aranges)
~SymbolFileDWARFDebugMap() override
uint32_t CalculateAbilities() override
SymbolFileDWARFDebugMap(lldb::ObjectFileSP objfile_sp)
std::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.
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)
void SetCompileUnit(SymbolFileDWARF *oso_dwarf, const lldb::CompUnitSP &cu_sp)
lldb_private::Type * ResolveTypeUID(lldb::user_id_t type_uid) override
std::vector< CompileUnitInfo > m_compile_unit_infos
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...
void FinalizeOSOFileRanges(CompileUnitInfo *cu_info)
SymbolFileDWARF * GetSymbolFile(const lldb_private::SymbolContext &sc)
lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die)
static llvm::StringRef GetPluginNameStatic()
void InitializeObject() override
Initialize the SymbolFile object.
std::vector< std::unique_ptr< lldb_private::CallEdge > > ParseCallEdgesInFunction(lldb_private::UserID func_id) override
void ForEachSymbolFile(std::function< bool(SymbolFileDWARF *)> closure)
std::vector< uint32_t > m_glob_indexes
bool LinkOSOAddress(lldb_private::Address &addr)
Convert addr from a .o file address, to an executable address.
lldb_private::LazyBool m_supports_DW_AT_APPLE_objc_complete_type
void ParseDeclsForContext(lldb_private::CompilerDeclContext decl_ctx) override
size_t GetCompUnitInfosForModule(const lldb_private::Module *oso_module, std::vector< CompileUnitInfo * > &cu_infos)
lldb_private::CompilerDeclContext GetDeclContextForUID(lldb::user_id_t uid) override
CompileUnitInfo * GetCompileUnitInfoForSymbolWithID(lldb::user_id_t symbol_id, uint32_t *oso_idx_ptr)
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
uint32_t ResolveSymbolContext(const lldb_private::Address &so_addr, lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContext &sc) override
bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit, lldb_private::FileSpecList &support_files) override
bool GetFileSpecForSO(uint32_t oso_idx, lldb_private::FileSpec &file_spec)
lldb_private::CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) override
virtual lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE &die, lldb_private::ConstString type_name, bool must_be_implementation)
size_t ParseVariablesForContext(const lldb_private::SymbolContext &sc) override
bool HasForwardDeclForClangType(const lldb_private::CompilerType &compiler_type)
bool Supports_DW_AT_APPLE_objc_complete_type(DWARFUnit *cu)
size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override
std::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.
lldb_private::CompilerDeclContext FindNamespace(lldb_private::ConstString name, const lldb_private::CompilerDeclContext &parent_decl_ctx) override
uint32_t ResolveSymbolContext(const lldb_private::Address &so_addr, lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContext &sc) override
bool ParseImportedModules(const lldb_private::SymbolContext &sc, std::vector< lldb_private::SourceModule > &imported_modules) override
size_t ParseBlocksRecursive(lldb_private::Function &func) override
lldb::LanguageType ParseLanguage(lldb_private::CompileUnit &comp_unit) override
bool ForEachExternalModule(lldb_private::CompileUnit &, llvm::DenseSet< lldb_private::SymbolFile * > &, llvm::function_ref< bool(lldb_private::Module &)>) override
std::optional< uint64_t > GetFileIndex() const
size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override
void SetFileIndex(std::optional< uint64_t > file_index)
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
static llvm::StringRef GetPluginNameStatic()
lldb_private::Type * ResolveTypeUID(lldb::user_id_t type_uid) override
void FindGlobalVariables(lldb_private::ConstString name, const lldb_private::CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, lldb_private::VariableList &variables) override
lldb_private::XcodeSDK ParseXcodeSDK(lldb_private::CompileUnit &comp_unit) override
Return the Xcode SDK comp_unit was compiled against.
virtual lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die)
std::vector< std::unique_ptr< lldb_private::CallEdge > > ParseCallEdgesInFunction(lldb_private::UserID func_id) override
void DumpClangAST(lldb_private::Stream &s) override
bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit, lldb_private::FileSpecList &support_files) override
void GetTypes(lldb_private::SymbolContextScope *sc_scope, lldb::TypeClass type_mask, lldb_private::TypeList &type_list) override
lldb_private::CompilerDeclContext GetDeclContextForUID(lldb::user_id_t uid) override
void SetDebugMapModule(const lldb::ModuleSP &module_sp)
bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override
void ParseDeclsForContext(lldb_private::CompilerDeclContext decl_ctx) override
bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override
bool ParseIsOptimized(lldb_private::CompileUnit &comp_unit) override
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
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:209
A section + offset based address class.
Definition: Address.h:59
lldb::SectionSP GetSection() const
Get const accessor for the section.
Definition: Address.h:429
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
Definition: Address.cpp:283
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:291
An architecture specification class.
Definition: ArchSpec.h:32
bool SetTriple(const llvm::Triple &triple)
Architecture triple setter.
Definition: ArchSpec.cpp:750
A class that describes a compilation unit.
Definition: CompileUnit.h:41
lldb::LanguageType GetLanguage()
Represents a generic declaration context in a program.
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
A uniqued constant string class.
Definition: ConstString.h:39
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:192
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:215
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A file utility class.
Definition: FileSpec.h:56
static bool Match(const FileSpec &pattern, const FileSpec &file)
Match FileSpec pattern against FileSpec file.
Definition: FileSpec.cpp:300
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:366
static FileSystem & Instance()
A class that describes a function.
Definition: Function.h:409
const AddressRange & GetAddressRange()
Definition: Function.h:457
CompileUnit * GetCompileUnit()
Get accessor for the compile unit that owns this function.
Definition: Function.cpp:360
A line table class.
Definition: LineTable.h:40
LineTable * LinkLineTable(const FileRangeMap &file_range_map)
Definition: LineTable.cpp:406
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Definition: ModuleChild.cpp:24
A collection class for Module objects.
Definition: ModuleList.h:82
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:950
ConstString GetLookupName() const
Definition: Module.h:961
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:88
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
Definition: Module.cpp:1232
virtual SymbolFile * GetSymbolFile(bool can_create=true, Stream *feedback_strm=nullptr)
Get the module's symbol file.
Definition: Module.cpp:1052
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr)
Definition: Module.cpp:440
std::string GetSpecificationDescription() const
Get the module path and object name.
Definition: Module.cpp:1085
A plug-in interface definition class for object file parsers.
Definition: ObjectFile.h:62
Symtab * GetSymtab()
Gets the symbol table for the currently selected architecture (and object for archives).
Definition: ObjectFile.cpp:725
@ eTypeExecutable
A normal executable.
Definition: ObjectFile.h:71
@ eTypeDebugInfo
An object file that contains only debug information.
Definition: ObjectFile.h:73
@ eTypeStubLibrary
A library that can be linked against but not used for execution.
Definition: ObjectFile.h:81
@ eTypeObjectFile
An intermediate object file.
Definition: ObjectFile.h:77
@ eTypeDynamicLinker
The platform's dynamic linker executable.
Definition: ObjectFile.h:75
@ eTypeCoreFile
A core file that has a checkpoint of a program's execution state.
Definition: ObjectFile.h:69
@ eTypeSharedLibrary
A shared library that can be used during execution.
Definition: ObjectFile.h:79
@ eTypeJIT
JIT code that has symbols, sections and possibly debug info.
Definition: ObjectFile.h:83
virtual void ClearSymtab()
Frees the symbol table.
Definition: ObjectFile.cpp:574
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.
Definition: ObjectFile.cpp:556
virtual llvm::StringRef GetPluginName()=0
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
Entry & GetEntryRef(size_t i)
Definition: RangeMap.h:538
uint32_t FindEntryIndexThatContains(B addr) const
Definition: RangeMap.h:545
const Entry * GetEntryAtIndex(size_t i) const
Definition: RangeMap.h:528
RangeData< lldb::addr_t, lldb::addr_t, OSOEntry > Entry
Definition: RangeMap.h:443
void Append(const Entry &entry)
Definition: RangeMap.h:451
Entry * FindEntryThatContains(B addr)
Definition: RangeMap.h:563
llvm::StringRef GetText() const
Access the regular expression text.
"lldb/Core/SourceLocationSpec.h" A source location specifier class.
This base class provides an interface to stack frames.
Definition: StackFrame.h:41
const Address & GetFrameCodeAddress()
Get an Address for the current pc value in this StackFrame.
Definition: StackFrame.cpp:190
An error handling class.
Definition: Status.h:44
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Set the current error string to a formatted error string.
Definition: Status.cpp:255
bool Fail() const
Test for error condition.
Definition: Status.cpp:181
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition: Status.cpp:130
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
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.
Definition: SymbolContext.h:33
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.
Containing protected virtual methods for child classes to override.
Definition: SymbolFile.h:448
ObjectFile * GetObjectFile() override
Definition: SymbolFile.h:477
lldb::ObjectFileSP m_objfile_sp
Definition: SymbolFile.h:553
void SetCompileUnitAtIndex(uint32_t idx, const lldb::CompUnitSP &cu_sp)
Definition: SymbolFile.cpp:213
uint32_t GetNumCompileUnits() override
Definition: SymbolFile.cpp:192
Provides public interface for all SymbolFiles.
Definition: SymbolFile.h:48
virtual std::recursive_mutex & GetModuleMutex() const
Symbols file subclasses should override this to return the Module that owns the TypeSystem that this ...
Definition: SymbolFile.cpp:35
Status GetFrameVariableError(StackFrame &frame)
Get an error that describes why variables might be missing for a given symbol context.
Definition: SymbolFile.h:267
virtual uint32_t ResolveSymbolContext(const Address &so_addr, lldb::SymbolContextItem resolve_scope, SymbolContext &sc)=0
uint32_t GetSiblingIndex() const
Definition: Symbol.cpp:219
uint64_t GetIntegerValue(uint64_t fail_value=0) const
Definition: Symbol.h:116
uint32_t GetID() const
Definition: Symbol.h:135
bool ValueIsAddress() const
Definition: Symbol.cpp:167
bool IsDebug() const
Definition: Symbol.h:190
Mangled & GetMangled()
Definition: Symbol.h:145
Address & GetAddressRef()
Definition: Symbol.h:71
lldb::addr_t GetByteSize() const
Definition: Symbol.cpp:464
ConstString GetName() const
Definition: Symbol.cpp:550
lldb::SymbolType GetType() const
Definition: Symbol.h:167
Symbol * SymbolAtIndex(size_t idx)
Definition: Symtab.cpp:217
Symbol * FindFirstSymbolWithNameAndType(ConstString name, lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility)
Definition: Symtab.cpp:861
void SortSymbolIndexesByValue(std::vector< uint32_t > &indexes, bool remove_duplicates) const
Definition: Symtab.cpp:613
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:487
uint32_t GetIndexForSymbol(const Symbol *symbol) const
Definition: Symtab.cpp:548
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:505
const Symbol * GetParent(Symbol *symbol) const
Get the parent symbol for the given symbol.
Definition: Symtab.cpp:1152
uint32_t GetSize() const
Definition: TypeMap.cpp:75
An abstraction for Xcode-style SDKs that works like ArchSpec.
Definition: XcodeSDK.h:24
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
#define UINT32_MAX
Definition: lldb-defines.h:19
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:309
Definition: SBAddress.h:15
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eSymbolTypeObjCClass
@ eSymbolTypeObjectFile
@ eSymbolTypeSourceFile
uint64_t user_id_t
Definition: lldb-types.h:80
uint64_t addr_t
Definition: lldb-types.h:79
const FileRangeMap & GetFileRangeMap(SymbolFileDWARFDebugMap *exe_symfile)
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
Definition: TypeSystem.h:45
BaseType GetRangeBase() const
Definition: RangeMap.h:46
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