28#include "llvm/ADT/DenseMap.h"
29#include "llvm/ADT/STLExtras.h"
30#include "llvm/ADT/SmallVector.h"
31#include "llvm/DebugInfo/CodeView/CVRecord.h"
32#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
33#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
34#include "llvm/DebugInfo/CodeView/Formatters.h"
35#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
36#include "llvm/DebugInfo/CodeView/RecordName.h"
37#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
38#include "llvm/DebugInfo/CodeView/SymbolRecordHelpers.h"
39#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
40#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
41#include "llvm/DebugInfo/PDB/Native/GlobalsStream.h"
42#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
43#include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h"
44#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
45#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
46#include "llvm/DebugInfo/PDB/Native/PublicsStream.h"
47#include "llvm/DebugInfo/PDB/Native/SymbolStream.h"
48#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
49#include "llvm/DebugInfo/PDB/PDB.h"
50#include "llvm/DebugInfo/PDB/PDBTypes.h"
51#include "llvm/Demangle/MicrosoftDemangle.h"
52#include "llvm/Object/COFF.h"
53#include "llvm/Support/Allocator.h"
54#include "llvm/Support/BinaryStreamReader.h"
55#include "llvm/Support/Error.h"
56#include "llvm/Support/ErrorOr.h"
57#include "llvm/Support/MemoryBuffer.h"
86 case PDB_Lang::ObjCpp:
93static std::optional<std::string>
95 llvm::StringRef exe_path) {
98 if (fs.
Exists(original_pdb_path))
99 return std::string(original_pdb_path);
104 const FileSpec original_pdb_spec(original_pdb_path,
106 .value_or(FileSpec::Style::native));
107 const llvm::StringRef pdb_filename = original_pdb_spec.
GetFilename();
118 for (
const FileSpec &search_dir : search_paths) {
127static std::unique_ptr<PDBFile>
130 using namespace llvm::object;
131 auto expected_binary = createBinary(exe_path);
134 if (!expected_binary) {
135 llvm::consumeError(expected_binary.takeError());
138 OwningBinary<Binary> binary = std::move(*expected_binary);
142 auto *obj = llvm::dyn_cast<llvm::object::COFFObjectFile>(binary.getBinary());
145 const llvm::codeview::DebugInfo *pdb_info =
nullptr;
148 llvm::StringRef pdb_file;
149 if (llvm::Error e = obj->getDebugPDBInfo(pdb_info, pdb_file)) {
150 consumeError(std::move(e));
154 std::optional<std::string> resolved_pdb_path =
156 if (!resolved_pdb_path)
165 auto expected_info =
pdb->getPDBInfoStream();
166 if (!expected_info) {
167 llvm::consumeError(expected_info.takeError());
170 llvm::codeview::GUID guid;
171 memcpy(&guid, pdb_info->PDB70.Signature, 16);
173 if (expected_info->getGuid() != guid)
198 case SimpleTypeKind::Boolean128:
200 case SimpleTypeKind::Boolean64:
202 case SimpleTypeKind::Boolean32:
204 case SimpleTypeKind::Boolean16:
206 case SimpleTypeKind::Boolean8:
209 case SimpleTypeKind::Byte:
210 case SimpleTypeKind::UnsignedCharacter:
211 return "unsigned char";
212 case SimpleTypeKind::NarrowCharacter:
214 case SimpleTypeKind::SignedCharacter:
215 case SimpleTypeKind::SByte:
216 return "signed char";
217 case SimpleTypeKind::Character32:
219 case SimpleTypeKind::Character16:
221 case SimpleTypeKind::Character8:
224 case SimpleTypeKind::Complex128:
225 return "_Complex __float128";
226 case SimpleTypeKind::Complex80:
227 return "_Complex long double";
228 case SimpleTypeKind::Complex64:
229 return "_Complex double";
230 case SimpleTypeKind::Complex48:
231 return "_Complex __float48";
232 case SimpleTypeKind::Complex32:
233 case SimpleTypeKind::Complex32PartialPrecision:
234 return "_Complex float";
235 case SimpleTypeKind::Complex16:
236 return "_Complex _Float16";
238 case SimpleTypeKind::Float128:
240 case SimpleTypeKind::Float80:
241 return "long double";
242 case SimpleTypeKind::Float64:
244 case SimpleTypeKind::Float48:
246 case SimpleTypeKind::Float32:
247 case SimpleTypeKind::Float32PartialPrecision:
249 case SimpleTypeKind::Float16:
252 case SimpleTypeKind::Int128Oct:
253 case SimpleTypeKind::Int128:
255 case SimpleTypeKind::Int64:
256 case SimpleTypeKind::Int64Quad:
258 case SimpleTypeKind::Int32Long:
260 case SimpleTypeKind::Int32:
262 case SimpleTypeKind::Int16:
263 case SimpleTypeKind::Int16Short:
266 case SimpleTypeKind::UInt128Oct:
267 case SimpleTypeKind::UInt128:
268 return "unsigned __int128";
269 case SimpleTypeKind::UInt64:
270 case SimpleTypeKind::UInt64Quad:
271 return "unsigned long long";
272 case SimpleTypeKind::UInt32:
274 case SimpleTypeKind::UInt16:
275 case SimpleTypeKind::UInt16Short:
276 return "unsigned short";
277 case SimpleTypeKind::UInt32Long:
278 return "unsigned long";
280 case SimpleTypeKind::HResult:
282 case SimpleTypeKind::Void:
284 case SimpleTypeKind::WideCharacter:
287 case SimpleTypeKind::None:
288 case SimpleTypeKind::NotTranslated:
305static std::optional<CVTagRecord>
324 if (Record.Type.isSimple())
327 CVType cvt = tpi.getType(Record.Type);
336 std::string qname = std::string(parent.
asTag().getUniqueName());
337 if (qname.size() < 4 || child.
asTag().getUniqueName().size() < 4)
343 qname[3] = child.
asTag().getUniqueName()[3];
347 piece += Record.Name;
348 piece.push_back(
'@');
349 qname.insert(4, std::move(piece));
350 if (qname != child.
asTag().UniqueName)
353 return std::move(child);
369 return "Microsoft PDB debug symbol cross-platform file reader.";
385 uint32_t abilities = 0;
393 pdb_file = &
pdb->GetPDBFile();
405 pdb_file->getFilePath(),
406 m_objfile_sp->GetModule()->GetObjectFile()->GetFileSpec().GetPath());
409 if (!expected_index) {
410 llvm::consumeError(expected_index.takeError());
413 m_index = std::move(*expected_index);
422 if (
m_index->dbi().isStripped())
433 m_index->ParseSectionContribs();
435 auto ts_or_err =
m_objfile_sp->GetModule()->GetTypeSystemForLanguage(
437 if (
auto err = ts_or_err.takeError()) {
439 "Failed to initialize: {0}");
441 if (
auto ts = *ts_or_err)
442 ts->SetSymbolFile(
this);
447 const DbiModuleList &modules =
m_index->dbi().modules();
448 uint32_t count = modules.getModuleCount();
455 DbiModuleDescriptor last = modules.getModuleDescriptor(count - 1);
456 if (last.getModuleName() ==
"* Linker *")
467 if (
auto err = ts_or_err.takeError())
469 auto ts = *ts_or_err;
474 switch (sym.kind()) {
480 return &func->GetBlock(
false);
487 BlockSym block(
static_cast<SymbolRecordKind
>(sym.kind()));
488 if (
auto err = SymbolDeserializer::deserializeAs<BlockSym>(sym, block)) {
490 "Failed to deserialize BlockSym record: {0}");
493 if (block.Parent == 0) {
509 m_index->MakeVirtualAddress(block.Segment, block.CodeOffset);
512 if (block_base >= func_base)
513 child_block->AddRange(
Block::Range(block_base - func_base, block.CodeSize));
516 "S_BLOCK32 at modi: {0:d} offset: {1:d}: adding range "
517 "[{2:x16}-{3:x16}) which has a base that is less than the "
519 "low PC 0x%" PRIx64
". Please file a bug and attach the file at the "
520 "start of this error message",
522 block_base + block.CodeSize, func_base);
526 m_blocks.insert({opaque_block_uid, child_block});
531 comp_unit->GetLineTable();
533 std::shared_ptr<InlineSite> inline_site =
m_inline_sites[opaque_block_uid];
541 for (
size_t i = 0; i < inline_site->ranges.GetSize(); ++i) {
542 auto *entry = inline_site->ranges.GetEntryAtIndex(i);
543 child_block->AddRange(
544 Block::Range(entry->GetRangeBase(), entry->GetByteSize()));
546 child_block->FinalizeRanges();
549 Declaration &decl = inline_site->inline_function_info->GetDeclaration();
550 Declaration &callsite = inline_site->inline_function_info->GetCallSite();
551 child_block->SetInlinedFunctionInfo(
552 inline_site->inline_function_info->GetName().GetCString(),
nullptr,
554 m_blocks.insert({opaque_block_uid, child_block});
575 if (sym_record.kind() != S_LPROC32 && sym_record.kind() != S_GPROC32) {
591 ProcSym proc(
static_cast<SymbolRecordKind
>(sym_record.kind()));
592 if (
auto err = SymbolDeserializer::deserializeAs<ProcSym>(sym_record, proc)) {
594 "Failed to deserialize ProcSym record: {0}");
597 if (proc.FunctionType == TypeIndex::None())
606 SegmentOffset(proc.Segment, proc.CodeOffset), proc.FunctionType);
607 Mangled mangled(mangled_opt.value_or(proc.Name));
609 FunctionSP func_sp = std::make_shared<Function>(
611 func_type.get(), func_addr,
617 if (
auto err = ts_or_err.takeError())
619 auto ts = *ts_or_err;
622 ast_builder->EnsureFunction(func_id);
638 llvm::SmallString<64> source_file_name;
639 if (
auto main_file_or_err =
m_index->compilands().GetMainSourceFile(cci)) {
640 source_file_name = std::move(*main_file_or_err);
643 "Failed to determine main source file: {0}");
645 FileSpec fs(llvm::sys::path::convert_to_slash(
646 source_file_name, llvm::sys::path::Style::windows_backslash));
648 CompUnitSP cu_sp = std::make_shared<CompileUnit>(
649 m_objfile_sp->GetModule(),
nullptr, std::make_shared<SupportFile>(fs),
657 const ModifierRecord &mr,
659 TpiStream &stream =
m_index->tpi();
663 if ((mr.Modifiers & ModifierOptions::Const) != ModifierOptions::None)
665 if ((mr.Modifiers & ModifierOptions::Volatile) != ModifierOptions::None)
667 if ((mr.Modifiers & ModifierOptions::Unaligned) != ModifierOptions::None)
668 name +=
"__unaligned ";
670 if (mr.ModifiedType.isSimple())
673 name += computeTypeName(stream.typeCollection(), mr.ModifiedType);
678 llvm::expectedToOptional(modified_type->GetByteSize(
nullptr)),
685 const llvm::codeview::PointerRecord &pr,
691 if (pr.isPointerToMember()) {
692 MemberPointerInfo mpi = pr.getMemberInfo();
705 if (ti == TypeIndex::NullptrT()) {
712 if (ti.getSimpleMode() != SimpleTypeMode::Direct) {
714 uint32_t pointer_size = 0;
715 switch (ti.getSimpleMode()) {
716 case SimpleTypeMode::FarPointer32:
717 case SimpleTypeMode::NearPointer32:
720 case SimpleTypeMode::NearPointer64:
732 if (ti.getSimpleKind() == SimpleTypeKind::NotTranslated)
744 if (!record.hasUniqueName())
747 llvm::ms_demangle::Demangler demangler;
748 std::string_view sv(record.UniqueName.begin(), record.UniqueName.size());
749 llvm::ms_demangle::TagTypeNode *ttn = demangler.parseTagUniqueName(sv);
753 llvm::ms_demangle::IdentifierNode *idn =
754 ttn->QualifiedName->getUnqualifiedIdentifier();
755 return idn->toString();
760 const TagRecord &record,
768 decl = std::move(*maybeDecl);
771 "Failed to resolve declaration for '{1}': {0}", uname);
779 const ClassRecord &cr,
785 const UnionRecord &ur,
791 const EnumRecord &er,
798 decl = std::move(*maybeDecl);
801 "Failed to resolve declaration for '{1}': {0}", uname);
807 llvm::expectedToOptional(underlying_type->GetByteSize(
nullptr)),
nullptr,
813 const ArrayRecord &ar,
822 array_sp->SetEncodingType(element_type.get());
827 const MemberFunctionRecord &mfr,
829 if (mfr.ReturnType.isSimple())
840 const ProcedureRecord &pr,
842 if (pr.ReturnType.isSimple())
853 llvm::codeview::TypeIndex arglist_ti) {
854 if (arglist_ti.isNoneType())
857 CVType arglist_cvt =
m_index->tpi().getType(arglist_ti);
858 if (arglist_cvt.kind() != LF_ARGLIST)
863 TypeDeserializer::deserializeAs<ArgListRecord>(arglist_cvt, alr)) {
865 "Failed to deserialize ArgListRecord record ({1}): {0}",
869 for (TypeIndex
id : alr.getIndices())
870 if (!
id.isNoneType() &&
id.isSimple())
875 if (type_id.
index.isSimple())
879 CVType cvt = stream.getType(type_id.
index);
881 if (cvt.kind() == LF_MODIFIER) {
882 ModifierRecord modifier;
884 TypeDeserializer::deserializeAs<ModifierRecord>(cvt, modifier)) {
886 "Failed to deserialize ModifierRecord record ({1}): {0}",
893 if (cvt.kind() == LF_POINTER) {
894 PointerRecord pointer;
896 TypeDeserializer::deserializeAs<PointerRecord>(cvt, pointer)) {
898 "Failed to deserialize PointerRecord record ({1}): {0}",
907 if (
auto err = TypeDeserializer::deserializeAs<ClassRecord>(cvt, cr)) {
909 "Failed to deserialize ClassRecord record ({1}): {0}",
916 if (cvt.kind() == LF_ENUM) {
918 if (
auto err = TypeDeserializer::deserializeAs<EnumRecord>(cvt, er)) {
920 "Failed to deserialize EnumRecord record ({1}): {0}",
927 if (cvt.kind() == LF_UNION) {
929 if (
auto err = TypeDeserializer::deserializeAs<UnionRecord>(cvt, ur)) {
931 "Failed to deserialize UnionRecord record ({1}): {0}",
938 if (cvt.kind() == LF_ARRAY) {
940 if (
auto err = TypeDeserializer::deserializeAs<ArrayRecord>(cvt, ar)) {
942 "Failed to deserialize ArrayRecord record ({1}): {0}",
949 if (cvt.kind() == LF_PROCEDURE) {
951 if (
auto err = TypeDeserializer::deserializeAs<ProcedureRecord>(cvt, pr)) {
953 "Failed to deserialize ProcedureRecord record ({1}): {0}",
959 if (cvt.kind() == LF_MFUNCTION) {
960 MemberFunctionRecord mfr;
962 TypeDeserializer::deserializeAs<MemberFunctionRecord>(cvt, mfr)) {
965 "Failed to deserialize MemberFunctionRecord record ({1}): {0}",
978 std::optional<PdbTypeSymId> full_decl_uid;
980 auto expected_full_ti =
981 m_index->tpi().findFullDeclForForwardRef(type_id.
index);
982 if (!expected_full_ti)
983 llvm::consumeError(expected_full_ti.takeError());
984 else if (*expected_full_ti != type_id.
index) {
992 if (full_iter !=
m_types.end()) {
993 TypeSP result = full_iter->second;
1002 PdbTypeSymId best_decl_id = full_decl_uid ? *full_decl_uid : type_id;
1004 if (
auto err = ts_or_err.takeError())
1006 auto ts = *ts_or_err;
1036 return iter->second;
1045 CVSymbol sym =
m_index->symrecords().readRecord(var_id.
offset);
1046 if (sym.kind() == S_CONSTANT)
1051 llvm::StringRef name;
1053 uint16_t section = 0;
1054 uint32_t offset = 0;
1055 bool is_external =
false;
1056 switch (sym.kind()) {
1061 DataSym ds(sym.kind());
1062 if (
auto err = SymbolDeserializer::deserializeAs<DataSym>(sym, ds)) {
1064 "Failed to deserialize DataSym record: {0}");
1071 section = ds.Segment;
1072 offset = ds.DataOffset;
1073 addr =
m_index->MakeVirtualAddress(ds.Segment, ds.DataOffset);
1080 ThreadLocalDataSym tlds(sym.kind());
1082 SymbolDeserializer::deserializeAs<ThreadLocalDataSym>(sym, tlds)) {
1084 "Failed to deserialize ThreadLocalDataSym record: {0}");
1089 section = tlds.Segment;
1090 offset = tlds.DataOffset;
1091 addr =
m_index->MakeVirtualAddress(tlds.Segment, tlds.DataOffset);
1096 llvm_unreachable(
"unreachable!");
1100 std::optional<uint16_t> modi =
m_index->GetModuleIndexForVa(addr);
1111 std::make_shared<SymbolFileType>(*
this,
toOpaqueUid(tid));
1114 if (
auto err = ts_or_err.takeError())
1116 auto ts = *ts_or_err;
1119 ast_builder->EnsureVariable(var_id);
1127 std::string global_name(
"::");
1128 global_name += name;
1129 bool artificial =
false;
1130 bool location_is_constant_data =
false;
1131 bool static_member =
false;
1132 VariableSP var_sp = std::make_shared<Variable>(
1133 toOpaqueUid(var_id), name.str().c_str(), global_name.c_str(), type_sp,
1134 scope, comp_unit.get(), ranges, &decl, location, is_external, artificial,
1135 location_is_constant_data, static_member);
1142 const CVSymbol &cvs) {
1143 TpiStream &tpi =
m_index->tpi();
1144 ConstantSym constant(cvs.kind());
1146 if (cvs.kind() != S_CONSTANT)
1150 SymbolDeserializer::deserializeAs<ConstantSym>(cvs, constant)) {
1152 "Failed to deserialize ConstantSym record: {0}");
1155 std::string global_name(
"::");
1156 global_name += constant.Name;
1159 std::make_shared<SymbolFileType>(*
this,
toOpaqueUid(tid));
1165 constant.Value, module);
1166 if (!location_or_err) {
1168 "Failed to make constant location expression for {1}: {0}",
1174 bool external =
false;
1175 bool artificial =
false;
1176 bool location_is_constant_data =
true;
1177 bool static_member =
false;
1178 VariableSP var_sp = std::make_shared<Variable>(
1179 toOpaqueUid(var_id), constant.Name.str().c_str(), global_name.c_str(),
1181 external, artificial, location_is_constant_data, static_member);
1188 if (emplace_result.second) {
1190 emplace_result.first->second = var_sp;
1195 return emplace_result.first->second;
1205 if (emplace_result.second)
1206 emplace_result.first->second =
CreateFunction(func_id, comp_unit);
1208 return emplace_result.first->second;
1214 auto emplace_result =
1216 if (emplace_result.second) {
1222 return emplace_result.first->second;
1228 return iter->second.get();
1247 assert(index < UINT16_MAX &&
"Invalid compile unit index");
1248 if (index >= UINT16_MAX)
1260 assert(
false &&
"uid of compile unit not a compiland");
1274 auto *section_list =
1275 m_objfile_sp->GetModule()->GetObjectFile()->GetSectionList();
1279 llvm::DenseMap<lldb::addr_t, llvm::SmallVector<uint32_t, 1>> symbols_by_addr;
1280 for (uint32_t i = 0, n = symtab.
GetNumSymbols(); i < n; ++i) {
1286 PublicSym32 last_sym;
1287 size_t last_sym_idx = 0;
1295 auto finish_last_symbol = [&](
const PublicSym32 *next) {
1302 if (next && last_sym.Segment == next->Segment) {
1303 if (next->Offset < last_sym.Offset) {
1305 "Ignoring size estimate for '{0}': segment {1} offset {2} is "
1306 "greater than the following offset {3}",
1307 last_sym.Name, last_sym.Segment, last_sym.Offset,
1311 last->
SetByteSize(next->Offset - last_sym.Offset);
1314 if (section_sp->GetByteSize() < last_sym.Offset) {
1316 "Ignoring size estimate for '{0}': segment {1} offset {2} is "
1317 "past the end of section '{3}' (size {4})",
1318 last_sym.Name, last_sym.Segment, last_sym.Offset,
1319 section_sp->GetName(), section_sp->GetByteSize());
1322 last->
SetByteSize(section_sp->GetByteSize() - last_sym.Offset);
1327 for (
auto pid :
m_index->publics().getAddressMap()) {
1329 CVSymbol sym =
m_index->ReadSymbolRecord(global);
1330 auto kind = sym.kind();
1331 if (kind != S_PUB32)
1333 auto pub_or_err = SymbolDeserializer::deserializeAs<PublicSym32>(sym);
1336 "Failed to deserialize PublicSym32 record: {0}");
1339 PublicSym32 pub = std::move(*pub_or_err);
1340 finish_last_symbol(&pub);
1342 if (!section_sp || last_sym.Segment != pub.Segment)
1343 section_sp = section_list->FindSectionByID(pub.Segment);
1349 if ((pub.Flags & PublicSymFlags::Function) != PublicSymFlags::None ||
1350 (pub.Flags & PublicSymFlags::Code) != PublicSymFlags::None)
1368 if (it != symbols_by_addr.end() &&
1369 llvm::any_of(it->second, [&](uint32_t idx) {
1370 Symbol *sym = symtab.SymbolAtIndex(idx);
1371 return sym && sym->GetMangled() == pub_symbol.GetMangled();
1375 last_sym_idx = symtab.
AddSymbol(pub_symbol);
1379 finish_last_symbol(
nullptr);
1386 assert(
false &&
"uid of compile unit not a compiland");
1394 for (
auto iter = syms.begin(); iter != syms.end(); ++iter) {
1395 if (iter->kind() != S_LPROC32 && iter->kind() != S_GPROC32)
1404 if (new_count < count) {
1405 assert(
false &&
"less functions after parsing than before");
1408 return new_count - count;
1413 uint32_t flags = eSymbolContextCompUnit;
1414 flags |= eSymbolContextVariable;
1415 flags |= eSymbolContextFunction;
1416 flags |= eSymbolContextBlock;
1417 flags |= eSymbolContextLineEntry;
1418 return (resolve_scope & flags) != 0;
1422 const Address &addr, SymbolContextItem resolve_scope, SymbolContext &sc) {
1424 uint32_t resolved_flags = 0;
1428 std::optional<uint16_t> modi =
m_index->GetModuleIndexForVa(file_addr);
1436 resolved_flags |= eSymbolContextCompUnit;
1439 if (resolve_scope & eSymbolContextFunction ||
1440 resolve_scope & eSymbolContextBlock) {
1443 "missing compile unit for symbol at address {0:x}", file_addr);
1446 std::vector<SymbolAndUid> matches =
m_index->FindSymbolsByVa(file_addr);
1450 for (
const auto &match : llvm::reverse(matches)) {
1454 PdbCompilandSymId csid = match.uid.asCompilandSym();
1455 CVSymbol cvs =
m_index->ReadSymbolRecord(csid);
1457 if (type != PDB_SymType::Function && type != PDB_SymType::Block)
1459 if (type == PDB_SymType::Function) {
1464 addr_t offset = file_addr - func_base;
1469 if (type == PDB_SymType::Block) {
1477 addr_t offset = file_addr - func_base;
1482 resolved_flags |= eSymbolContextFunction;
1484 resolved_flags |= eSymbolContextBlock;
1489 if (resolve_scope & eSymbolContextLineEntry) {
1492 "missing compile unit for symbol at address {0:x}", file_addr);
1496 if (line_table->FindLineEntryByAddress(addr, sc.
line_entry))
1497 resolved_flags |= eSymbolContextLineEntry;
1501 return resolved_flags;
1508 const uint32_t prev_size = sc_list.
GetSize();
1509 if (resolve_scope & eSymbolContextCompUnit) {
1518 if (file_spec_matches_cu_file_spec) {
1524 return sc_list.
GetSize() - prev_size;
1535 assert(
false &&
"uid of compile unit not a compiland");
1549 std::set<LineTable::Entry, LineTableEntryComparator> line_set;
1554 for (
const DebugSubsectionRecord &dssr :
1556 if (dssr.kind() != DebugSubsectionKind::Lines)
1559 DebugLinesSubsectionRef lines;
1560 llvm::BinaryStreamReader reader(dssr.getRecordData());
1561 if (
auto EC = lines.initialize(reader)) {
1562 llvm::consumeError(std::move(EC));
1566 const LineFragmentHeader *lfh = lines.header();
1567 uint64_t virtual_addr =
1568 m_index->MakeVirtualAddress(lfh->RelocSegment, lfh->RelocOffset);
1572 for (
const LineColumnEntry &group : lines) {
1573 llvm::Expected<uint32_t> file_index_or_err =
1575 if (!file_index_or_err) {
1577 "failed to get file index for line entry: {0}");
1580 uint32_t file_index = file_index_or_err.get();
1581 if (group.LineNumbers.empty()) {
1583 "no line numbers for {0} in modi={1}", group.NameIndex, modi);
1588 for (
const LineNumberEntry &entry : group.LineNumbers) {
1589 LineInfo cur_info(entry.Flags);
1591 if (cur_info.isAlwaysStepInto() || cur_info.isNeverStepInto())
1594 uint64_t addr = virtual_addr + entry.Offset;
1596 bool is_statement = cur_info.isStatement();
1600 uint32_t lno = cur_info.getStartLine();
1603 is_prologue, is_epilogue,
false);
1605 auto iter = line_set.find(new_entry);
1606 if (iter != line_set.end() && iter->is_terminal_entry)
1607 line_set.erase(iter);
1608 line_set.insert(new_entry);
1615 line_entry.
data = {file_index, lno};
1617 LineInfo last_line(group.LineNumbers.back().Flags);
1618 line_set.emplace(virtual_addr + lfh->CodeSize, last_line.getEndLine(), 0,
1619 file_index,
false,
false,
false,
false,
true);
1622 line_entry.
SetRangeEnd(virtual_addr + lfh->CodeSize);
1631 const CVSymbolArray &syms = cii->
m_debug_stream.getSymbolArray();
1632 for (
auto iter = syms.begin(); iter != syms.end();) {
1633 if (iter->kind() != S_LPROC32 && iter->kind() != S_GPROC32) {
1638 uint32_t record_offset = iter.offset();
1639 CVSymbol func_record =
1652 if (kind != S_INLINESITE)
1657 for (
const auto &line_entry :
1662 if (!line_entry.is_terminal_entry)
1663 line_set.erase(line_entry);
1664 line_set.insert(line_entry);
1672 iter = syms.at(getScopeEndOffset(func_record));
1678 std::vector<LineTable::Sequence> sequence(1);
1679 for (
const auto &line_entry : line_set) {
1681 sequence.back(), line_entry.file_addr, line_entry.line,
1682 line_entry.column, line_entry.file_idx,
1683 line_entry.is_start_of_statement, line_entry.is_start_of_basic_block,
1684 line_entry.is_prologue_end, line_entry.is_epilogue_begin,
1685 line_entry.is_terminal_entry);
1688 std::make_unique<LineTable>(&comp_unit, std::move(sequence));
1690 if (line_table->GetSize() == 0)
1702llvm::Expected<uint32_t>
1706 return llvm::make_error<RawError>(raw_error_code::no_entry);
1708 const auto &checksums = cii.
m_strings.checksums().getArray();
1709 const auto &strings = cii.
m_strings.strings();
1713 auto iter = checksums.at(file_id);
1714 if (iter == checksums.end())
1715 return llvm::make_error<RawError>(raw_error_code::no_entry);
1717 llvm::Expected<llvm::StringRef> efn = strings.getString(iter->FileNameOffset);
1719 return efn.takeError();
1725 return std::distance(cii.
m_file_list.begin(), fn_iter);
1726 return llvm::make_error<RawError>(raw_error_code::no_entry);
1734 assert(
false &&
"uid of compile unit not a compiland");
1747 f.starts_with(
"/") ? FileSpec::Style::posix : FileSpec::Style::windows;
1749 support_files.
Append(spec);
1755 const SymbolContext &sc, std::vector<SourceModule> &imported_modules) {
1768 CVSymbol sym = cii->
m_debug_stream.readSymbolAtOffset(
id.offset);
1770 if (sym.kind() != S_INLINESITE)
1773 InlineSiteSym inline_site(
static_cast<SymbolRecordKind
>(sym.kind()));
1775 SymbolDeserializer::deserializeAs<InlineSiteSym>(sym, inline_site)) {
1777 "Failed to deserialize InlineSiteSym record: {0}");
1782 std::shared_ptr<InlineSite> inline_site_sp =
1783 std::make_shared<InlineSite>(parent_id);
1786 auto iter = cii->
m_inline_map.find(inline_site.Inlinee);
1789 InlineeSourceLine inlinee_line = iter->second;
1793 llvm::Expected<uint32_t> file_index_or_err =
1795 if (!file_index_or_err) {
1797 "failed to get file index for inline site: {0}");
1800 uint32_t file_offset = file_index_or_err.get();
1802 uint32_t decl_line = inlinee_line.Header->SourceLineNum;
1803 std::unique_ptr<Declaration> decl_up =
1804 std::make_unique<Declaration>(decl_file, decl_line);
1807 uint32_t code_offset = 0;
1808 int32_t line_offset = 0;
1809 std::optional<uint32_t> code_offset_base;
1810 std::optional<uint32_t> code_offset_end;
1811 std::optional<int32_t> cur_line_offset;
1812 std::optional<int32_t> next_line_offset;
1813 std::optional<uint32_t> next_file_offset;
1815 bool is_terminal_entry =
false;
1816 bool is_start_of_statement =
true;
1818 bool is_prologue_end =
true;
1820 auto update_code_offset = [&](uint32_t code_delta) {
1821 if (!code_offset_base)
1822 code_offset_base = code_offset;
1823 else if (!code_offset_end)
1824 code_offset_end = *code_offset_base + code_delta;
1826 auto update_line_offset = [&](int32_t line_delta) {
1827 line_offset += line_delta;
1828 if (!code_offset_base || !cur_line_offset)
1829 cur_line_offset = line_offset;
1831 next_line_offset = line_offset;
1834 auto update_file_offset = [&](uint32_t offset) {
1835 if (!code_offset_base)
1836 file_offset = offset;
1838 next_file_offset = offset;
1841 for (
auto &annot : inline_site.annotations()) {
1842 switch (annot.OpCode) {
1843 case BinaryAnnotationsOpCode::CodeOffset:
1844 case BinaryAnnotationsOpCode::ChangeCodeOffset:
1845 case BinaryAnnotationsOpCode::ChangeCodeOffsetBase:
1846 code_offset += annot.U1;
1847 update_code_offset(annot.U1);
1849 case BinaryAnnotationsOpCode::ChangeLineOffset:
1850 update_line_offset(annot.S1);
1852 case BinaryAnnotationsOpCode::ChangeCodeLength:
1853 update_code_offset(annot.U1);
1854 code_offset += annot.U1;
1855 is_terminal_entry =
true;
1857 case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset:
1858 code_offset += annot.U1;
1859 update_code_offset(annot.U1);
1860 update_line_offset(annot.S1);
1862 case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset:
1863 code_offset += annot.U2;
1864 update_code_offset(annot.U2);
1865 update_code_offset(annot.U1);
1866 code_offset += annot.U1;
1867 is_terminal_entry =
true;
1869 case BinaryAnnotationsOpCode::ChangeFile:
1870 update_file_offset(annot.U1);
1877 if (code_offset_base && code_offset_end && cur_line_offset) {
1879 *code_offset_base, *code_offset_end - *code_offset_base,
1880 decl_line + *cur_line_offset));
1882 if (next_file_offset)
1883 file_offset = *next_file_offset;
1884 if (next_line_offset) {
1885 cur_line_offset = next_line_offset;
1886 next_line_offset = std::nullopt;
1888 code_offset_base = is_terminal_entry ? std::nullopt : code_offset_end;
1889 code_offset_end = next_file_offset = std::nullopt;
1891 if (code_offset_base && cur_line_offset) {
1892 if (is_terminal_entry) {
1894 func_base + *code_offset_base, decl_line + *cur_line_offset, 0,
1895 file_offset,
false,
false,
false,
false,
true);
1896 inline_site_sp->line_entries.push_back(line_entry);
1899 decl_line + *cur_line_offset, 0,
1900 file_offset, is_start_of_statement,
false,
1901 is_prologue_end,
false,
false);
1902 inline_site_sp->line_entries.push_back(line_entry);
1903 is_prologue_end =
false;
1904 is_start_of_statement =
false;
1907 if (is_terminal_entry)
1908 is_start_of_statement =
true;
1909 is_terminal_entry =
false;
1912 inline_site_sp->ranges.Sort();
1915 std::unique_ptr<Declaration> callsite_up;
1916 if (!inline_site_sp->ranges.IsEmpty()) {
1917 auto *entry = inline_site_sp->ranges.GetEntryAtIndex(0);
1918 addr_t base_offset = entry->GetRangeBase();
1924 std::shared_ptr<InlineSite> parent_site =
1927 parent_site->inline_function_info->GetDeclaration().GetFile();
1928 if (
auto *parent_entry =
1929 parent_site->ranges.FindEntryThatContains(base_offset)) {
1931 std::make_unique<Declaration>(parent_decl_file, parent_entry->data);
1936 func_base + base_offset)) {
1940 std::make_unique<Declaration>(callsite_file, entry->data.second);
1946 std::string inlinee_name;
1947 llvm::Expected<CVType> inlinee_cvt =
1948 m_index->ipi().typeCollection().getTypeOrError(inline_site.Inlinee);
1950 inlinee_name =
"[error reading function name: " +
1951 llvm::toString(inlinee_cvt.takeError()) +
"]";
1952 }
else if (inlinee_cvt->kind() == LF_MFUNC_ID) {
1953 MemberFuncIdRecord mfr;
1954 if (
auto err = TypeDeserializer::deserializeAs<MemberFuncIdRecord>(
1955 *inlinee_cvt, mfr)) {
1957 "[error reading function name: " + llvm::toString(std::move(err)) +
1960 LazyRandomTypeCollection &types =
m_index->tpi().typeCollection();
1961 inlinee_name.append(std::string(types.getTypeName(mfr.ClassType)));
1962 inlinee_name.append(
"::");
1963 inlinee_name.append(mfr.getName().str());
1965 }
else if (inlinee_cvt->kind() == LF_FUNC_ID) {
1968 TypeDeserializer::deserializeAs<FuncIdRecord>(*inlinee_cvt, fir)) {
1970 "[error reading function name: " + llvm::toString(std::move(err)) +
1973 TypeIndex parent_idx = fir.getParentScope();
1974 if (!parent_idx.isNoneType()) {
1975 LazyRandomTypeCollection &ids =
m_index->ipi().typeCollection();
1976 inlinee_name.append(std::string(ids.getTypeName(parent_idx)));
1977 inlinee_name.append(
"::");
1979 inlinee_name.append(fir.getName().str());
1982 inline_site_sp->inline_function_info = std::make_shared<InlineFunctionInfo>(
1983 inlinee_name.c_str(), llvm::StringRef(), decl_up.get(),
1994 std::set<uint64_t> remove_uids;
1996 if (kind == S_GPROC32 || kind == S_LPROC32 || kind == S_BLOCK32 ||
1997 kind == S_INLINESITE) {
1999 if (kind == S_INLINESITE)
2006 for (uint64_t uid : remove_uids) {
2018 CVSymbolArray syms =
2022 for (
auto iter = syms.begin(); iter != syms.end(); ++iter) {
2024 if (fn(iter->kind(), child_id))
2036 "failed to get C++ type system: {0}");
2039 auto ts = *ts_or_err;
2046 ast_builder->
Dump(s, filter, show_color);
2054 std::map<std::pair<uint16_t, uint32_t>, uint32_t> func_addr_ids;
2057 for (
const uint32_t gid :
m_index->globals().getGlobalsTable()) {
2058 CVSymbol sym =
m_index->symrecords().readRecord(gid);
2059 auto kind = sym.kind();
2062 llvm::StringRef name;
2064 case SymbolKind::S_GDATA32:
2065 case SymbolKind::S_LDATA32: {
2066 auto data_or_err = SymbolDeserializer::deserializeAs<DataSym>(sym);
2069 "Failed to deserialize DataSym record: {0}");
2072 name = data_or_err->Name;
2075 case SymbolKind::S_GTHREAD32:
2076 case SymbolKind::S_LTHREAD32: {
2078 SymbolDeserializer::deserializeAs<ThreadLocalDataSym>(sym);
2081 "Failed to deserialize ThreadLocalDataSym record: {0}");
2084 name = data_or_err->Name;
2087 case SymbolKind::S_CONSTANT: {
2088 auto data_or_err = SymbolDeserializer::deserializeAs<ConstantSym>(sym);
2091 "Failed to deserialize ConstantSym record: {0}");
2094 name = data_or_err->Name;
2101 if (!name.empty()) {
2110 if (kind != S_PROCREF && kind != S_LPROCREF)
2116 auto ref_or_err = SymbolDeserializer::deserializeAs<ProcRefSym>(sym);
2119 "Failed to deserialize ProcRefSym record: {0}");
2122 ProcRefSym ref = std::move(*ref_or_err);
2123 if (ref.Name.empty())
2128 m_index->compilands().GetOrCreateCompiland(ref.modi());
2129 auto iter = cci.
m_debug_stream.getSymbolArray().at(ref.SymOffset);
2132 kind = iter->kind();
2133 if (kind != S_GPROC32 && kind != S_LPROC32)
2136 auto proc_or_err = SymbolDeserializer::deserializeAs<ProcSym>(*iter);
2139 "Failed to deserialize ProcSym record: {0}");
2142 ProcSym proc = std::move(*proc_or_err);
2143 if ((proc.Flags & ProcSymFlags::IsUnreachable) != ProcSymFlags::None)
2145 if (proc.Name.empty() || proc.FunctionType.isSimple())
2151 func_addr_ids.emplace(std::make_pair(proc.Segment, proc.CodeOffset), gid);
2154 if (basename.empty())
2155 basename = proc.Name;
2161 auto type =
m_index->tpi().getType(proc.FunctionType);
2162 if (type.kind() == LF_MFUNCTION) {
2163 MemberFunctionRecord mfr;
2164 if (
auto err = TypeDeserializer::deserializeAs<MemberFunctionRecord>(
2168 "Failed to deserialize MemberFunctionRecord record ({1}): {0}",
2170 }
else if (!mfr.getThisType().isNoneType())
2176 for (
auto pid :
m_index->publics().getPublicsTable()) {
2178 CVSymbol sym =
m_index->ReadSymbolRecord(global);
2179 auto kind = sym.kind();
2180 if (kind != S_PUB32)
2182 auto pub_or_err = SymbolDeserializer::deserializeAs<PublicSym32>(sym);
2185 "Failed to deserialize PublicSym32 record: {0}");
2188 PublicSym32 pub = std::move(*pub_or_err);
2195 auto it = func_addr_ids.find({pub.Segment, pub.Offset});
2196 if (it != func_addr_ids.end())
2218 std::vector<uint32_t> results;
2221 size_t n_matches = 0;
2222 for (uint32_t gid : results) {
2225 if (parent_decl_ctx.
IsValid() &&
2234 if (++n_matches >= max_matches)
2246 if (name_type_mask & eFunctionNameTypeFull)
2249 if (!(name_type_mask & eFunctionNameTypeFull ||
2250 name_type_mask & eFunctionNameTypeBase ||
2251 name_type_mask & eFunctionNameTypeMethod))
2255 std::set<uint32_t> resolved_ids;
2257 std::vector<uint32_t> ids;
2258 if (!Names.GetValues(name, ids))
2261 for (uint32_t
id : ids) {
2262 if (!resolved_ids.insert(
id).second)
2266 if (parent_decl_ctx.
IsValid() &&
2270 CVSymbol sym =
m_index->ReadSymbolRecord(global);
2271 auto kind = sym.kind();
2272 if (kind != S_PROCREF && kind != S_LPROCREF) {
2278 auto proc_or_err = SymbolDeserializer::deserializeAs<ProcRefSym>(sym);
2281 "Failed to deserialize ProcRefSym record: {0}");
2284 ProcRefSym proc = std::move(*proc_or_err);
2290 m_index->compilands().GetOrCreateCompiland(proc.modi());
2306 if (name_type_mask & eFunctionNameTypeFull)
2308 if (name_type_mask & eFunctionNameTypeBase)
2310 if (name_type_mask & eFunctionNameTypeMethod)
2315 bool include_inlines,
2332 std::vector<uint32_t> matches;
2335 for (uint32_t match_idx : matches) {
2337 if (context.empty())
2346 if (results.
Done(query))
2353 uint32_t max_matches,
2356 std::vector<TypeIndex> matches =
m_index->tpi().findRecordsByName(name);
2357 if (max_matches > 0 && max_matches < matches.size())
2358 matches.resize(max_matches);
2360 for (TypeIndex ti : matches) {
2376 LazyRandomTypeCollection &types =
m_index->tpi().typeCollection();
2379 for (
auto ti = types.getFirst(); ti; ti = types.getNext(*ti)) {
2382 (void)type->GetFullCompilerType();
2386 for (
const uint32_t gid :
m_index->globals().getGlobalsTable()) {
2388 CVSymbol sym =
m_index->ReadSymbolRecord(global);
2389 if (sym.kind() != S_UDT)
2392 auto udt_or_err = SymbolDeserializer::deserializeAs<UDTSym>(sym);
2395 "Failed to deserialize UDTSym record: {0}");
2398 UDTSym udt = std::move(*udt_or_err);
2399 bool is_typedef =
true;
2401 CVType cvt =
m_index->tpi().getType(udt.Type);
2403 if (name == udt.Name)
2415 return new_count - old_count;
2421 for (
const uint32_t gid :
m_index->globals().getGlobalsTable()) {
2423 CVSymbol sym =
m_index->ReadSymbolRecord(global);
2428 switch (sym.kind()) {
2429 case SymbolKind::S_GDATA32:
2430 case SymbolKind::S_LDATA32:
2431 case SymbolKind::S_GTHREAD32:
2432 case SymbolKind::S_LTHREAD32: {
2459 bool location_is_constant_data = is_constant;
2463 if (sym.kind() != S_CONSTANT)
2465 ConstantSym constant(sym.kind());
2467 SymbolDeserializer::deserializeAs<ConstantSym>(sym, constant)) {
2469 "Failed to deserialize ConstantSym record: {0}");
2473 var_info.
name = constant.Name;
2474 var_info.
type = constant.Type;
2476 constant.Type,
m_index->tpi(), constant.Value, module);
2477 if (!location_or_err) {
2479 "Failed to make constant location expression for {1}: {0}",
2487 Block *func_block = block;
2508 std::string name = var_info.
name.str();
2511 std::make_shared<SymbolFileType>(*
this, type_sp->GetID());
2516 bool external =
false;
2517 bool artificial =
false;
2518 bool static_member =
false;
2520 VariableSP var_sp = std::make_shared<Variable>(
2521 toOpaqueUid(var_id), name.c_str(), name.c_str(), sftype, var_scope, block,
2522 scope_ranges, &decl, var_info.
location, external, artificial,
2523 location_is_constant_data, static_member);
2526 if (
auto err = ts_or_err.takeError())
2528 auto ts = *ts_or_err;
2531 ast_builder->EnsureVariable(scope_id, var_id);
2541 bool is_param,
bool is_constant) {
2544 return iter->second;
2550 CVSymbol sym =
m_index->ReadSymbolRecord(
id);
2551 if (sym.kind() != S_UDT) {
2556 auto udt_or_err = SymbolDeserializer::deserializeAs<UDTSym>(sym);
2559 "Failed to deserialize UDTSym record: {0}");
2562 UDTSym udt = std::move(*udt_or_err);
2567 if (
auto err = ts_or_err.takeError())
2569 auto ts = *ts_or_err;
2577 ct = target_type->GetForwardCompilerType();
2581 llvm::expectedToOptional(target_type->GetByteSize(
nullptr)),
2582 nullptr, target_type->GetID(),
2590 return iter->second;
2604 uint32_t params_remaining = 0;
2605 switch (sym.kind()) {
2608 ProcSym proc(
static_cast<SymbolRecordKind
>(sym.kind()));
2609 if (
auto err = SymbolDeserializer::deserializeAs<ProcSym>(sym, proc)) {
2611 "Failed to deserialize ProcSym record: {0}");
2614 CVType signature =
m_index->tpi().getType(proc.FunctionType);
2615 if (signature.kind() == LF_PROCEDURE) {
2616 ProcedureRecord sig;
2617 if (llvm::Error e = TypeDeserializer::deserializeAs<ProcedureRecord>(
2619 llvm::consumeError(std::move(e));
2622 params_remaining = sig.getParameterCount();
2623 }
else if (signature.kind() == LF_MFUNCTION) {
2624 MemberFunctionRecord sig;
2625 if (llvm::Error e = TypeDeserializer::deserializeAs<MemberFunctionRecord>(
2627 llvm::consumeError(std::move(e));
2630 params_remaining = sig.getParameterCount();
2646 variables = std::make_shared<VariableList>();
2650 CVSymbolArray syms = limitSymbolArrayToScope(
2656 auto iter = syms.begin();
2657 auto end = syms.end();
2659 while (iter != end) {
2660 uint32_t record_offset = iter.offset();
2661 CVSymbol variable_cvs = *iter;
2667 if (variable_cvs.kind() == S_BLOCK32 ||
2668 variable_cvs.kind() == S_INLINESITE) {
2669 uint32_t block_end = getScopeEndOffset(variable_cvs);
2671 iter = syms.at(block_end);
2675 bool is_param = params_remaining > 0;
2677 switch (variable_cvs.kind()) {
2679 case S_REGREL32_INDIR:
2686 variables->AddVariableIfUnique(variable);
2693 variables->AddVariableIfUnique(variable);
2727 variables = std::make_shared<VariableList>();
2734 "missing missing block, function, or module for symbol context");
2740 if (
auto err = ts_or_err.takeError())
2742 auto ts = *ts_or_err;
2754 if (
auto err = ts_or_err.takeError())
2756 auto ts = *ts_or_err;
2768 if (
auto err = ts_or_err.takeError())
2770 auto ts = *ts_or_err;
2781 auto iter =
m_types.find(type_uid);
2788 return &*iter->second;
2792 assert(
false &&
"uid is not a type index");
2796 if (type_id.
index.isNoneType())
2805std::optional<SymbolFile::ArrayInfo>
2808 return std::nullopt;
2824 TypeClass type_mask,
2833 if (
auto err = ts_or_err.takeError())
2835 auto ts = *ts_or_err;
2838 auto *
clang = llvm::dyn_cast_or_null<TypeSystemClang>(ts.get());
2849llvm::Expected<lldb::TypeSystemSP>
2851 auto type_system_or_err =
2852 m_objfile_sp->GetModule()->GetTypeSystemForLanguage(language);
2853 if (type_system_or_err)
2854 if (
auto ts = *type_system_or_err)
2855 ts->SetSymbolFile(
this);
2856 return type_system_or_err;
2861 return m_index->pdb().getFileSize();
2869 LazyRandomTypeCollection &types =
m_index->tpi().typeCollection();
2871 llvm::DenseMap<TypeIndex, TypeIndex> forward_to_full;
2872 llvm::DenseMap<TypeIndex, TypeIndex> full_to_forward;
2874 struct RecordIndices {
2879 llvm::StringMap<RecordIndices> record_indices;
2881 for (
auto ti = types.getFirst(); ti; ti = types.getNext(*ti)) {
2882 CVType type = types.getType(*ti);
2888 RecordIndices &indices = record_indices[tag.
asTag().getUniqueName()];
2889 if (tag.
asTag().isForwardRef()) {
2890 indices.forward = *ti;
2898 if (indices.full != TypeIndex::None() &&
2899 indices.forward != TypeIndex::None()) {
2900 forward_to_full[indices.forward] = indices.full;
2901 full_to_forward[indices.full] = indices.forward;
2907 if (tag.
asTag().isForwardRef() || !tag.
asTag().containsNestedClass())
2911 ProcessTpiStream(
PdbIndex &index, TypeIndex parent,
2913 llvm::DenseMap<TypeIndex, TypeIndex> &parents)
2914 : index(index), parents(parents), parent(parent),
2915 parent_cvt(parent_cvt) {}
2918 llvm::DenseMap<TypeIndex, TypeIndex> &parents;
2920 unsigned unnamed_type_index = 1;
2924 llvm::Error visitKnownMember(CVMemberRecord &CVR,
2925 NestedTypeRecord &Record)
override {
2926 std::string unnamed_type_name;
2927 if (Record.Name.empty()) {
2929 llvm::formatv(
"<unnamed-type-$S{0}>", unnamed_type_index).str();
2930 Record.Name = unnamed_type_name;
2931 ++unnamed_type_index;
2933 std::optional<CVTagRecord> tag =
2936 return llvm::ErrorSuccess();
2938 parents[Record.Type] = parent;
2939 return llvm::ErrorSuccess();
2943 CVType field_list_cvt =
m_index->tpi().getType(tag.
asTag().FieldList);
2944 if (field_list_cvt.kind() != LF_FIELDLIST)
2948 FieldListRecord field_list;
2949 if (llvm::Error
error = TypeDeserializer::deserializeAs<FieldListRecord>(
2950 field_list_cvt, field_list))
2951 llvm::consumeError(std::move(
error));
2952 if (llvm::Error
error = visitMemberRecordStream(field_list.Data, process))
2953 llvm::consumeError(std::move(
error));
2965 std::vector<TypeIndex> full_keys;
2966 std::vector<TypeIndex> fwd_keys;
2968 TypeIndex key = entry.first;
2969 TypeIndex value = entry.second;
2971 auto iter = forward_to_full.find(value);
2972 if (iter != forward_to_full.end())
2973 entry.second = iter->second;
2975 iter = forward_to_full.find(key);
2976 if (iter != forward_to_full.end())
2977 fwd_keys.push_back(key);
2979 full_keys.push_back(key);
2981 for (TypeIndex fwd : fwd_keys) {
2982 TypeIndex full = forward_to_full[fwd];
2986 for (TypeIndex full : full_keys) {
2987 TypeIndex fwd = full_to_forward[full];
2992std::optional<PdbCompilandSymId>
2994 CVSymbol sym =
m_index->ReadSymbolRecord(
id);
2995 if (symbolOpensScope(sym.kind())) {
2998 id.offset = getScopeParentOffset(sym);
3002 return std::nullopt;
3011 auto begin = syms.begin();
3012 auto end = syms.at(
id.offset);
3013 std::vector<PdbCompilandSymId> scope_stack;
3015 while (begin != end) {
3016 if (begin.offset() >
id.offset) {
3020 return std::nullopt;
3025 if (symbolOpensScope(begin->kind())) {
3028 uint32_t scope_end = getScopeEndOffset(*begin);
3029 if (scope_end <
id.offset) {
3030 begin = syms.at(scope_end);
3033 scope_stack.emplace_back(
id.modi, begin.offset());
3035 }
else if (symbolEndsScope(begin->kind())) {
3036 scope_stack.pop_back();
3040 if (scope_stack.empty())
3041 return std::nullopt;
3043 return scope_stack.back();
3046std::optional<llvm::codeview::TypeIndex>
3051 return std::nullopt;
3052 return parent_iter->second;
3055std::vector<CompilerContext>
3057 CVType type =
m_index->tpi().getType(ti);
3063 std::optional<Type::ParsedName> parsed_name =
3068 std::vector<CompilerContext> ctx;
3070 for (llvm::StringRef scope : parsed_name->scope) {
3077 for (
auto &el : llvm::reverse(llvm::drop_end(ctx))) {
3083 type =
m_index->tpi().getType(ti);
3084 switch (type.kind()) {
3104std::optional<llvm::StringRef>
3109 return std::nullopt;
3112 if (sym_record.kind() != S_LPROC32 && sym_record.kind() != S_GPROC32)
3113 return std::nullopt;
3115 ProcSym proc(
static_cast<SymbolRecordKind
>(sym_record.kind()));
3116 if (
auto err = SymbolDeserializer::deserializeAs<ProcSym>(sym_record, proc)) {
3118 "Failed to deserialize ProcSym record: {0}");
3119 return std::nullopt;
3126std::optional<llvm::StringRef>
3128 TypeIndex function_type) {
3129 auto symbol =
m_index->publics().findByAddress(
m_index->symrecords(),
3132 return std::nullopt;
3134 llvm::StringRef name = symbol->first.Name;
3137 if (!function_type.isNoneType() &&
3138 (symbol->first.Flags & PublicSymFlags::Function) != PublicSymFlags::None)
3155 if (!mangled.starts_with(
'_') ||
3156 m_index->dbi().getMachineType() != PDB_Machine::x86)
3160 PDB_CallingConv cc = PDB_CallingConv::NearC;
3161 if (cvt.kind() == LF_PROCEDURE) {
3162 ProcedureRecord proc;
3163 if (llvm::Error
error =
3164 TypeDeserializer::deserializeAs<ProcedureRecord>(cvt, proc))
3165 llvm::consumeError(std::move(
error));
3167 }
else if (cvt.kind() == LF_MFUNCTION) {
3168 MemberFunctionRecord mfunc;
3169 if (llvm::Error
error =
3170 TypeDeserializer::deserializeAs<MemberFunctionRecord>(cvt, mfunc))
3171 llvm::consumeError(std::move(
error));
3172 cc = mfunc.CallConv;
3179 if (cc == PDB_CallingConv::NearC || cc == PDB_CallingConv::FarC)
3180 return mangled.drop_front();
3186 for (CVType cvt :
m_index->ipi().typeArray()) {
3187 switch (cvt.kind()) {
3188 case LF_UDT_SRC_LINE: {
3189 UdtSourceLineRecord udt_src;
3190 if (
auto err = TypeDeserializer::deserializeAs(cvt, udt_src)) {
3192 "Failed to deserialize UdtSourceLineRecord record: {0}");
3198 udt_src.LineNumber});
3200 case LF_UDT_MOD_SRC_LINE: {
3201 UdtModSourceLineRecord udt_mod_src;
3202 if (
auto err = TypeDeserializer::deserializeAs(cvt, udt_mod_src)) {
3205 "Failed to deserialize UdtModSourceLineRecord record: {0}");
3215 udt_mod_src.LineNumber});
3223llvm::Expected<Declaration>
3229 return llvm::createStringError(
"no UDT declaration found");
3231 llvm::StringRef file_name;
3232 if (it->second.IsIpiIndex) {
3233 CVType cvt =
m_index->ipi().getType(it->second.FileNameIndex);
3234 if (cvt.kind() != LF_STRING_ID)
3235 return llvm::createStringError(
"file name was not a LF_STRING_ID");
3238 if (
auto err = TypeDeserializer::deserializeAs(cvt, sid))
3239 return std::move(err);
3240 file_name = sid.String;
3243 auto string_table =
m_index->pdb().getStringTable();
3245 return string_table.takeError();
3247 llvm::Expected<llvm::StringRef>
string =
3248 string_table->getStringTable().getString(
3249 it->second.FileNameIndex.getIndex());
3251 return string.takeError();
3252 file_name = *string;
3256 if (file_name ==
"\\<unknown>")
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOG_ERROR(log, error,...)
static std::unique_ptr< PDBFile > loadMatchingPDBFile(std::string exe_path, llvm::BumpPtrAllocator &allocator)
static std::optional< CVTagRecord > GetNestedTagDefinition(const NestedTypeRecord &Record, const CVTagRecord &parent, TpiStream &tpi)
static lldb::LanguageType TranslateLanguage(PDB_Lang lang)
static std::string GetUnqualifiedTypeName(const TagRecord &record)
static llvm::StringRef GetSimpleTypeName(SimpleTypeKind kind)
static bool IsClassRecord(TypeLeafKind kind)
static bool IsFunctionEpilogue(const CompilandIndexItem &cci, lldb::addr_t addr)
static bool NeedsResolvedCompileUnit(uint32_t resolve_scope)
static std::optional< std::string > findMatchingPDBFilePath(llvm::StringRef original_pdb_path, llvm::StringRef exe_path)
static bool IsFunctionPrologue(const CompilandIndexItem &cci, lldb::addr_t addr)
static llvm::StringRef DropScope(llvm::StringRef name)
static bool UseNativePDB()
A section + offset based address class.
lldb::addr_t GetFileAddress() const
Get the file address.
bool IsValid() const
Check if the object state is valid.
A class that describes a single lexical block.
lldb::VariableListSP GetBlockVariableList(bool can_create)
Get the variable list for this block only.
Block * FindInnermostBlockByOffset(const lldb::addr_t offset)
void SetBlockInfoHasBeenParsed(bool b, bool set_children)
lldb::BlockSP CreateChild(lldb::user_id_t uid)
Creates a block with the specified UID uid.
Function * CalculateSymbolContextFunction() override
void SetVariableList(lldb::VariableListSP &variable_list_sp)
Set accessor for the variable list.
Block * GetParent() const
Get the parent block.
bool GetStartAddress(Address &addr)
void SetDidParseVariables(bool b, bool set_children)
A class that describes a compilation unit.
void SetVariableList(lldb::VariableListSP &variable_list_sp)
Set accessor for the variable list.
lldb::VariableListSP GetVariableList(bool can_create)
Get the variable list for a compile unit.
const FileSpec & GetPrimaryFile() const
Return the primary source spec associated with this compile unit.
void ResolveSymbolContext(const SourceLocationSpec &src_location_spec, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list, RealpathPrefixes *realpath_prefixes=nullptr)
Resolve symbol contexts by file and line.
void SetLineTable(LineTable *line_table)
Set the line table for the compile unit.
void AddFunction(lldb::FunctionSP &function_sp)
Add a function to this compile unit.
size_t GetNumFunctions() const
Returns the number of functions in this compile unit.
lldb::LanguageType GetLanguage()
LineTable * GetLineTable()
Get the line table for the compile unit.
Represents a generic declaration context in a program.
TypeSystem * GetTypeSystem() const
Represents a generic declaration such as a function declaration.
Generic representation of a type in a programming language.
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
A uniqued constant string class.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
"lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file address range to a single ...
bool IsValid() const
Return true if the location expression contains data.
void SetFuncFileAddress(lldb::addr_t func_file_addr)
"lldb/Expression/DWARFExpression.h" Encapsulates a DWARF location expression and interprets it.
A class to manage flag bits.
A class that describes the declaration location of a lldb object.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
FileSpec CopyByAppendingPathComponent(llvm::StringRef component) const
static std::optional< Style > GuessPathStyle(llvm::StringRef absolute_path)
Attempt to guess path style for a given path string.
static bool Match(const FileSpec &pattern, const FileSpec &file)
Match FileSpec pattern against FileSpec file.
llvm::StringRef GetFilename() const
Filename string const get accessor.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
FileSpec CopyByRemovingLastPathComponent() const
llvm::sys::path::Style Style
bool Exists(const FileSpec &file_spec) const
Returns whether the given file exists.
static FileSystem & Instance()
A class that describes a function.
const Address & GetAddress() const
Return the address of the function (its entry point).
Block & GetBlock(bool can_create)
Get accessor for the block list.
static void AppendLineEntryToSequence(Sequence &sequence, lldb::addr_t file_addr, uint32_t line, uint16_t column, uint16_t file_idx, bool is_start_of_statement, bool is_start_of_basic_block, bool is_prologue_end, bool is_epilogue_begin, bool is_terminal_entry)
A class that handles mangled names.
static bool IsMangledName(llvm::StringRef name)
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
A class that encapsulates name lookup information.
lldb::FunctionNameType GetNameTypeMask() const
ConstString GetLookupName() const
ConstString GetName() const
static std::unique_ptr< llvm::pdb::PDBFile > loadPDBFile(std::string PdbPath, llvm::BumpPtrAllocator &Allocator)
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
RangeData< lldb::addr_t, uint32_t, std::pair< uint32_t, uint32_t > > Entry
void Append(const Entry &entry)
Entry * FindEntryThatContains(B addr)
"lldb/Core/SourceLocationSpec.h" A source location specifier class.
FileSpec GetFileSpec() const
A stream class that can stream formatted output to a file.
A list of support files for a CompileUnit.
const FileSpec & GetFileSpecAtIndex(size_t idx) const
void Append(const FileSpec &file)
Defines a list of symbol context objects.
uint32_t GetSize() const
Get accessor for a symbol context list size.
void Append(const SymbolContext &sc)
Append a new symbol context to the list.
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
Defines a symbol context baton that can be handed other debug core functions.
Function * function
The Function for a given query.
Block * block
The Block for a given query.
CompileUnit * comp_unit
The CompileUnit for a given query.
LineEntry line_entry
The LineEntry for a given query.
lldb::CompUnitSP GetCompileUnitAtIndex(uint32_t idx) override
ObjectFile * GetObjectFile() override
virtual TypeList & GetTypeList()
lldb::ObjectFileSP m_objfile_sp
void SetCompileUnitAtIndex(uint32_t idx, const lldb::CompUnitSP &cu_sp)
SymbolFileCommon(lldb::ObjectFileSP objfile_sp)
uint32_t GetNumCompileUnits() override
lldb::TypeSP MakeType(lldb::user_id_t uid, ConstString name, std::optional< uint64_t > byte_size, SymbolContextScope *context, lldb::user_id_t encoding_uid, Type::EncodingDataType encoding_uid_type, const Declaration &decl, const CompilerType &compiler_qual_type, Type::ResolveState compiler_type_resolve_state, uint32_t opaque_payload=0) override
This function is used to create types that belong to a SymbolFile.
virtual std::recursive_mutex & GetModuleMutex() const
Symbols file subclasses should override this to return the Module that owns the TypeSystem that this ...
bool ValueIsAddress() const
void SetType(lldb::SymbolType type)
Address & GetAddressRef()
void SetByteSize(lldb::addr_t size)
Symbol * SymbolAtIndex(size_t idx)
uint32_t AddSymbol(const Symbol &symbol)
size_t GetNumSymbols() const
static FileSpecList GetDefaultDebugFileSearchPaths()
void Insert(const lldb::TypeSP &type)
void Insert(const lldb::TypeSP &type)
A class that contains all state required for type lookups.
ConstString GetTypeBasename() const
Get the type basename to use when searching the type indexes in each SymbolFile object.
bool ContextMatches(llvm::ArrayRef< lldb_private::CompilerContext > context) const
Check of a CompilerContext array from matching type from a symbol file matches the m_context.
This class tracks the state and results of a TypeQuery.
bool InsertUnique(const lldb::TypeSP &type_sp)
When types that match a TypeQuery are found, this API is used to insert the matching types.
bool Done(const TypeQuery &query) const
Check if the type matching has found all of the matches that it needs.
bool AlreadySearched(lldb_private::SymbolFile *sym_file)
Check if a SymbolFile object has already been searched by this type match object.
A TypeSystem implementation based on Clang.
Interface for representing a type system.
virtual npdb::PdbAstBuilder * GetNativePDBParser()
@ eEncodingIsTypedefUID
This type is alias to a type whose UID is m_encoding_uid.
@ eEncodingIsUID
This type is the type whose UID is m_encoding_uid.
static std::optional< ParsedName > GetTypeScopeAndBasename(llvm::StringRef name)
void AddVariable(const lldb::VariableSP &var_sp)
RangeVector< lldb::addr_t, lldb::addr_t > RangeList
virtual CompilerType GetOrCreateTypedefType(PdbGlobalSymId id)=0
virtual void Dump(Stream &stream, llvm::StringRef filter, bool show_color)=0
virtual CompilerDeclContext FindNamespaceDecl(CompilerDeclContext parent_ctx, llvm::StringRef name)=0
virtual bool CompleteType(CompilerType ct)=0
virtual void EnsureBlock(PdbCompilandSymId block_id)=0
virtual CompilerDeclContext GetParentDeclContext(PdbSymUid uid)=0
virtual CompilerType GetOrCreateType(PdbTypeSymId type)=0
virtual CompilerDecl GetOrCreateDeclForUid(PdbSymUid uid)=0
virtual void EnsureInlinedFunction(PdbCompilandSymId inlinesite_id)=0
virtual void ParseDeclsForContext(CompilerDeclContext context)=0
virtual CompilerDeclContext GetOrCreateDeclContextForUid(PdbSymUid uid)=0
PdbIndex - Lazy access to the important parts of a PDB file.
static llvm::Expected< std::unique_ptr< PdbIndex > > create(llvm::pdb::PDBFile *)
llvm::pdb::TpiStream & tpi()
PdbCompilandId asCompiland() const
PdbCompilandSymId asCompilandSym() const
PdbTypeSymId asTypeSym() const
PdbSymUidKind kind() const
void CreateSimpleArgumentListTypes(llvm::codeview::TypeIndex arglist_ti)
lldb::VariableSP GetOrCreateGlobalVariable(PdbGlobalSymId var_id)
bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override
lldb::TypeSP CreateArrayType(PdbTypeSymId type_id, const llvm::codeview::ArrayRecord &ar, CompilerType ct)
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.
void CacheGlobalBaseNames()
Caches the basenames of symbols found in the globals stream.
llvm::Expected< Declaration > ResolveUdtDeclaration(PdbTypeSymId type_id)
lldb::VariableSP CreateGlobalVariable(PdbGlobalSymId var_id)
llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language) override
void InitializeObject() override
Initialize the SymbolFile object.
lldb_private::UniqueCStringMap< uint32_t > m_func_base_names
basename -> Global ID(s)
static SymbolFile * CreateInstance(lldb::ObjectFileSP objfile_sp)
uint32_t CalculateNumCompileUnits() override
llvm::DenseMap< lldb::user_id_t, lldb::TypeSP > m_types
bool CompleteType(CompilerType &compiler_type) override
lldb::LanguageType ParseLanguage(lldb_private::CompileUnit &comp_unit) override
CompilerDeclContext GetDeclContextForUID(lldb::user_id_t uid) override
void DumpClangAST(Stream &s, llvm::StringRef filter, bool show_color) override
size_t ParseVariablesForContext(const SymbolContext &sc) override
size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override
lldb::TypeSP CreatePointerType(PdbTypeSymId type_id, const llvm::codeview::PointerRecord &pr, CompilerType ct)
lldb::FunctionSP CreateFunction(PdbCompilandSymId func_id, CompileUnit &comp_unit)
llvm::DenseMap< lldb::user_id_t, lldb::BlockSP > m_blocks
bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit, SupportFileList &support_files) override
CompilerDecl GetDeclForUID(lldb::user_id_t uid) override
std::optional< llvm::StringRef > FindMangledFunctionName(PdbCompilandSymId id)
Find the mangled name for a function.
SymbolFileNativePDB(lldb::ObjectFileSP objfile_sp)
lldb::TypeSP GetOrCreateTypedef(PdbGlobalSymId id)
void FindTypesByName(llvm::StringRef name, uint32_t max_matches, TypeMap &types)
lldb::TypeSP CreateTagType(PdbTypeSymId type_id, const llvm::codeview::ClassRecord &cr, CompilerType ct)
lldb::TypeSP GetOrCreateType(PdbTypeSymId type_id)
llvm::BumpPtrAllocator m_allocator
void GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask, TypeList &type_list) override
llvm::DenseMap< lldb::user_id_t, lldb::VariableSP > m_local_variables
~SymbolFileNativePDB() override
lldb::VariableSP CreateConstantSymbol(PdbGlobalSymId var_id, const llvm::codeview::CVSymbol &cvs)
lldb::TypeSP CreateType(PdbTypeSymId type_id, CompilerType ct)
lldb_private::UniqueCStringMap< uint32_t > m_func_method_names
method basename -> Global ID(s)
void AddSymbols(Symtab &symtab) override
std::optional< llvm::codeview::TypeIndex > GetParentType(llvm::codeview::TypeIndex ti)
lldb_private::UniqueCStringMap< uint32_t > m_global_variable_base_names
global variable basename -> Global ID(s)
void FindFunctions(const Module::LookupInfo &lookup_info, const CompilerDeclContext &parent_decl_ctx, bool include_inlines, SymbolContextList &sc_list) override
static llvm::StringRef GetPluginDescriptionStatic()
std::unique_ptr< llvm::pdb::PDBFile > m_file_up
lldb::TypeSP CreateProcedureType(PdbTypeSymId type_id, const llvm::codeview::ProcedureRecord &pr, CompilerType ct)
lldb::TypeSP CreateModifierType(PdbTypeSymId type_id, const llvm::codeview::ModifierRecord &mr, CompilerType ct)
uint64_t GetDebugInfoSize(bool load_all_debug_info=false) override
Metrics gathering functions.
std::optional< llvm::StringRef > FindMangledSymbol(SegmentOffset so, llvm::codeview::TypeIndex function_type=llvm::codeview::TypeIndex())
Find a symbol name at a specific address (so).
size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override
Block * GetOrCreateBlock(PdbCompilandSymId block_id)
lldb::VariableSP GetOrCreateLocalVariable(PdbCompilandSymId scope_id, PdbCompilandSymId var_id, bool is_param, bool is_constant=false)
lldb::addr_t m_obj_load_address
size_t ParseBlocksRecursive(Function &func) override
std::once_flag m_cached_udt_declarations
void CacheUdtDeclarations()
lldb::CompUnitSP CreateCompileUnit(const CompilandIndexItem &cci)
std::optional< PdbCompilandSymId > FindSymbolScope(PdbCompilandSymId id)
size_t ParseSymbolArrayInScope(PdbCompilandSymId parent, llvm::function_ref< bool(llvm::codeview::SymbolKind, PdbCompilandSymId)> fn)
size_t ParseVariablesForCompileUnit(CompileUnit &comp_unit, VariableList &variables)
uint32_t CalculateAbilities() override
llvm::DenseMap< lldb::user_id_t, lldb::CompUnitSP > m_compilands
Block * CreateBlock(PdbCompilandSymId block_id)
std::vector< CompilerContext > GetContextForType(llvm::codeview::TypeIndex ti)
llvm::Expected< uint32_t > GetFileIndex(const CompilandIndexItem &cii, uint32_t file_id)
lldb::CompUnitSP GetOrCreateCompileUnit(const CompilandIndexItem &cci)
Type * ResolveTypeUID(lldb::user_id_t type_uid) override
llvm::DenseMap< lldb::user_id_t, lldb::FunctionSP > m_functions
bool ParseImportedModules(const SymbolContext &sc, std::vector< lldb_private::SourceModule > &imported_modules) override
llvm::StringRef StripMangledFunctionName(llvm::StringRef mangled, PdbTypeSymId func_ty)
static void DebuggerInitialize(Debugger &debugger)
lldb::VariableSP CreateLocalVariable(PdbCompilandSymId scope_id, PdbCompilandSymId var_id, bool is_param, bool is_constant=false)
llvm::DenseMap< lldb::user_id_t, std::shared_ptr< InlineSite > > m_inline_sites
void ParseInlineSite(PdbCompilandSymId inline_site_id, Address func_addr)
lldb::TypeSP CreateClassStructUnion(PdbTypeSymId type_id, const llvm::codeview::TagRecord &record, size_t size, CompilerType ct)
void FindGlobalVariables(ConstString name, const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, VariableList &variables) override
static llvm::StringRef GetPluginNameStatic()
size_t ParseVariablesForBlock(PdbCompilandSymId block_id)
void ParseDeclsForContext(lldb_private::CompilerDeclContext decl_ctx) override
lldb::FunctionSP GetOrCreateFunction(PdbCompilandSymId func_id, CompileUnit &comp_unit)
llvm::DenseMap< llvm::codeview::TypeIndex, llvm::codeview::TypeIndex > m_parent_types
lldb_private::UniqueCStringMap< uint32_t > m_func_full_names
mangled name/full function name -> Global ID(s)
lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override
lldb::TypeSP CreateFunctionType(PdbTypeSymId type_id, const llvm::codeview::MemberFunctionRecord &pr, CompilerType ct)
lldb_private::UniqueCStringMap< uint32_t > m_type_base_names
lldb::TypeSP CreateAndCacheType(PdbTypeSymId type_id)
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.
CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) override
bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override
lldb::TypeSP CreateTypedef(PdbGlobalSymId id)
bool m_done_full_type_scan
llvm::DenseMap< llvm::codeview::TypeIndex, UdtDeclaration > m_udt_declarations
void FindTypes(const lldb_private::TypeQuery &match, lldb_private::TypeResults &results) override
Find types using a type-matching object that contains all search parameters.
static char ID
LLVM RTTI support.
uint32_t ResolveSymbolContext(const Address &so_addr, lldb::SymbolContextItem resolve_scope, SymbolContext &sc) override
std::unique_ptr< PdbIndex > m_index
llvm::DenseMap< lldb::user_id_t, lldb::VariableSP > m_global_vars
lldb::TypeSP CreateSimpleType(llvm::codeview::TypeIndex ti, CompilerType ct)
#define LLDB_INVALID_ADDRESS
uint64_t toOpaqueUid(const T &cid)
size_t GetTypeSizeForSimpleKind(llvm::codeview::SimpleTypeKind kind)
SegmentOffsetLength GetSegmentOffsetAndLength(const llvm::codeview::CVSymbol &sym)
bool IsTagRecord(llvm::codeview::CVType cvt)
bool IsValidRecord(const RecordT &sym)
llvm::Expected< DWARFExpression > MakeConstantLocationExpression(llvm::codeview::TypeIndex underlying_ti, llvm::pdb::TpiStream &tpi, const llvm::APSInt &constant, lldb::ModuleSP module)
DWARFExpression MakeGlobalLocationExpression(uint16_t section, uint32_t offset, lldb::ModuleSP module)
VariableInfo GetVariableLocationInfo(PdbIndex &index, PdbCompilandSymId var_id, Block &func_block, lldb::ModuleSP module)
bool IsForwardRefUdt(llvm::codeview::CVType cvt)
llvm::pdb::PDB_SymType CVSymToPDBSym(llvm::codeview::SymbolKind kind)
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.
std::shared_ptr< lldb_private::Function > FunctionSP
std::shared_ptr< lldb_private::Block > BlockSP
std::shared_ptr< lldb_private::ObjectFile > ObjectFileSP
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eLanguageTypeObjC_plus_plus
Objective-C++.
@ eLanguageTypeSwift
Swift.
@ eLanguageTypeC
Non-standardized C, such as K&R.
@ eLanguageTypeObjC
Objective-C.
@ eLanguageTypeC_plus_plus
ISO C++:1998.
std::shared_ptr< lldb_private::Type > TypeSP
@ eSymbolTypeAdditional
When symbols take more than one entry, the extra entries get this type.
std::shared_ptr< lldb_private::VariableList > VariableListSP
std::shared_ptr< lldb_private::SymbolFileType > SymbolFileTypeSP
std::shared_ptr< lldb_private::Variable > VariableSP
@ eValueTypeVariableGlobal
globals variable
@ eValueTypeVariableLocal
function local variables
@ eValueTypeVariableArgument
function argument variables
@ eValueTypeVariableStatic
static variable
@ eValueTypeVariableThreadLocal
thread local storage variable
std::shared_ptr< lldb_private::Section > SectionSP
std::shared_ptr< lldb_private::Module > ModuleSP
std::shared_ptr< lldb_private::CompileUnit > CompUnitSP
BaseType GetRangeBase() const
void SetRangeEnd(BaseType end)
void SetRangeBase(BaseType b)
Set the start value for the range, and keep the same size.
lldb::user_id_t GetID() const
Get accessor for the user ID.
CompilerContextKind contextKind() const
static CVTagRecord create(llvm::codeview::CVType type)
const llvm::codeview::TagRecord & asTag() const
llvm::StringRef name() const
Represents a single compile unit.
std::map< llvm::codeview::TypeIndex, llvm::codeview::InlineeSourceLine > m_inline_map
std::optional< llvm::codeview::Compile3Sym > m_compile_opts
llvm::pdb::ModuleDebugStreamRef m_debug_stream
GlobalLineTable m_global_line_table
llvm::codeview::StringsAndChecksumsRef m_strings
std::vector< llvm::StringRef > m_file_list
llvm::codeview::TypeIndex index
DWARFExpressionList location
llvm::codeview::TypeIndex type