29#include "llvm/DebugInfo/CodeView/CVRecord.h"
30#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
31#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
32#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
33#include "llvm/DebugInfo/CodeView/RecordName.h"
34#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
35#include "llvm/DebugInfo/CodeView/SymbolRecordHelpers.h"
36#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
37#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
38#include "llvm/DebugInfo/PDB/Native/GlobalsStream.h"
39#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
40#include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h"
41#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
42#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
43#include "llvm/DebugInfo/PDB/Native/SymbolStream.h"
44#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
45#include "llvm/DebugInfo/PDB/PDB.h"
46#include "llvm/DebugInfo/PDB/PDBTypes.h"
47#include "llvm/Demangle/MicrosoftDemangle.h"
48#include "llvm/Object/COFF.h"
49#include "llvm/Support/Allocator.h"
50#include "llvm/Support/BinaryStreamReader.h"
51#include "llvm/Support/Error.h"
52#include "llvm/Support/ErrorOr.h"
53#include "llvm/Support/MemoryBuffer.h"
82 case PDB_Lang::ObjCpp:
89static std::unique_ptr<PDBFile>
92 using namespace llvm::object;
93 auto expected_binary = createBinary(exe_path);
96 if (!expected_binary) {
97 llvm::consumeError(expected_binary.takeError());
100 OwningBinary<Binary> binary = std::move(*expected_binary);
104 auto *obj = llvm::dyn_cast<llvm::object::COFFObjectFile>(binary.getBinary());
107 const llvm::codeview::DebugInfo *pdb_info =
nullptr;
110 llvm::StringRef pdb_file;
111 if (llvm::Error e = obj->getDebugPDBInfo(pdb_info, pdb_file)) {
112 consumeError(std::move(e));
122 pdb_file = exe_dir.CopyByAppendingPathComponent(pdb_name).GetPathAsConstString().GetStringRef();
130 auto expected_info = pdb->getPDBInfoStream();
131 if (!expected_info) {
132 llvm::consumeError(expected_info.takeError());
135 llvm::codeview::GUID guid;
136 memcpy(&guid, pdb_info->PDB70.Signature, 16);
138 if (expected_info->getGuid() != guid)
157 case SimpleTypeKind::Boolean128:
158 case SimpleTypeKind::Boolean16:
159 case SimpleTypeKind::Boolean32:
160 case SimpleTypeKind::Boolean64:
161 case SimpleTypeKind::Boolean8:
163 case SimpleTypeKind::Byte:
164 case SimpleTypeKind::UnsignedCharacter:
165 return "unsigned char";
166 case SimpleTypeKind::NarrowCharacter:
168 case SimpleTypeKind::SignedCharacter:
169 case SimpleTypeKind::SByte:
170 return "signed char";
171 case SimpleTypeKind::Character16:
173 case SimpleTypeKind::Character32:
175 case SimpleTypeKind::Character8:
177 case SimpleTypeKind::Complex80:
178 case SimpleTypeKind::Complex64:
179 case SimpleTypeKind::Complex32:
181 case SimpleTypeKind::Float128:
182 case SimpleTypeKind::Float80:
183 return "long double";
184 case SimpleTypeKind::Float64:
186 case SimpleTypeKind::Float32:
188 case SimpleTypeKind::Float16:
190 case SimpleTypeKind::Int128:
192 case SimpleTypeKind::Int64:
193 case SimpleTypeKind::Int64Quad:
195 case SimpleTypeKind::Int32:
197 case SimpleTypeKind::Int16:
199 case SimpleTypeKind::UInt128:
200 return "unsigned __int128";
201 case SimpleTypeKind::UInt64:
202 case SimpleTypeKind::UInt64Quad:
204 case SimpleTypeKind::HResult:
206 case SimpleTypeKind::UInt32:
208 case SimpleTypeKind::UInt16:
209 case SimpleTypeKind::UInt16Short:
210 return "unsigned short";
211 case SimpleTypeKind::Int32Long:
213 case SimpleTypeKind::UInt32Long:
214 return "unsigned long";
215 case SimpleTypeKind::Void:
217 case SimpleTypeKind::WideCharacter:
235static std::optional<CVTagRecord>
254 if (Record.Type.isSimple())
257 CVType cvt = tpi.getType(Record.Type);
266 std::string qname = std::string(parent.
asTag().getUniqueName());
267 if (qname.size() < 4 || child.
asTag().getUniqueName().size() < 4)
273 qname[3] = child.
asTag().getUniqueName()[3];
277 piece += Record.Name;
278 piece.push_back(
'@');
279 qname.insert(4, std::move(piece));
280 if (qname != child.
asTag().UniqueName)
283 return std::move(child);
299 return "Microsoft PDB debug symbol cross-platform file reader.";
319 if (
auto *pdb = llvm::dyn_cast<ObjectFilePDB>(
m_objfile_sp.get())) {
320 pdb_file = &pdb->GetPDBFile();
331 if (!expected_index) {
332 llvm::consumeError(expected_index.takeError());
335 m_index = std::move(*expected_index);
344 if (
m_index->dbi().isStripped())
355 m_index->ParseSectionContribs();
357 auto ts_or_err =
m_objfile_sp->GetModule()->GetTypeSystemForLanguage(
359 if (
auto err = ts_or_err.takeError()) {
361 "Failed to initialize");
363 if (
auto ts = *ts_or_err)
364 ts->SetSymbolFile(
this);
370 const DbiModuleList &modules =
m_index->dbi().modules();
371 uint32_t count = modules.getModuleCount();
378 DbiModuleDescriptor last = modules.getModuleDescriptor(count - 1);
379 if (last.getModuleName() ==
"* Linker *")
389 BlockSP child_block = std::make_shared<Block>(opaque_block_uid);
391 if (
auto err = ts_or_err.takeError())
393 auto ts = *ts_or_err;
398 switch (sym.kind()) {
405 Block &block = func->GetBlock(
false);
417 BlockSym block(
static_cast<SymbolRecordKind
>(sym.kind()));
418 cantFail(SymbolDeserializer::deserializeAs<BlockSym>(sym, block));
425 m_index->MakeVirtualAddress(block.Segment, block.CodeOffset);
428 if (block_base >= func_base)
429 child_block->AddRange(
Block::Range(block_base - func_base, block.CodeSize));
432 "S_BLOCK32 at modi: {0:d} offset: {1:d}: adding range "
433 "[{2:x16}-{3:x16}) which has a base that is less than the "
435 "low PC 0x%" PRIx64
". Please file a bug and attach the file at the "
436 "start of this error message",
438 block_base + block.CodeSize, func_base);
442 m_blocks.insert({opaque_block_uid, child_block});
447 comp_unit->GetLineTable();
449 std::shared_ptr<InlineSite> inline_site =
m_inline_sites[opaque_block_uid];
454 for (
size_t i = 0; i < inline_site->ranges.GetSize(); ++i) {
455 auto *entry = inline_site->ranges.GetEntryAtIndex(i);
456 child_block->AddRange(
457 Block::Range(entry->GetRangeBase(), entry->GetByteSize()));
459 child_block->FinalizeRanges();
462 Declaration &decl = inline_site->inline_function_info->GetDeclaration();
463 Declaration &callsite = inline_site->inline_function_info->GetCallSite();
464 child_block->SetInlinedFunctionInfo(
465 inline_site->inline_function_info->GetName().GetCString(),
nullptr,
467 m_blocks.insert({opaque_block_uid, child_block});
471 lldbassert(
false &&
"Symbol is not a block!");
484 lldbassert(sym_record.kind() == S_LPROC32 || sym_record.kind() == S_GPROC32);
493 comp_unit.
GetModule()->GetSectionList());
497 ProcSym proc(
static_cast<SymbolRecordKind
>(sym_record.kind()));
498 cantFail(SymbolDeserializer::deserializeAs<ProcSym>(sym_record, proc));
499 if (proc.FunctionType == TypeIndex::None())
506 Mangled mangled(proc.Name);
507 FunctionSP func_sp = std::make_shared<Function>(
509 func_type.get(), func_range);
514 if (
auto err = ts_or_err.takeError())
516 auto ts = *ts_or_err;
519 ts->GetNativePDBParser()->GetOrCreateFunctionDecl(func_id);
534 llvm::SmallString<64> source_file_name =
535 m_index->compilands().GetMainSourceFile(cci);
536 FileSpec fs(llvm::sys::path::convert_to_slash(
537 source_file_name, llvm::sys::path::Style::windows_backslash));
540 std::make_shared<CompileUnit>(
m_objfile_sp->GetModule(),
nullptr, fs,
548 const ModifierRecord &mr,
550 TpiStream &stream =
m_index->tpi();
553 if (mr.ModifiedType.isSimple())
556 name = computeTypeName(stream.typeCollection(), mr.ModifiedType);
561 modified_type->GetByteSize(
nullptr),
nullptr,
568 const llvm::codeview::PointerRecord &pr,
574 if (pr.isPointerToMember()) {
575 MemberPointerInfo mpi = pr.getMemberInfo();
588 if (ti == TypeIndex::NullptrT()) {
595 if (ti.getSimpleMode() != SimpleTypeMode::Direct) {
598 switch (ti.getSimpleMode()) {
599 case SimpleTypeMode::FarPointer32:
600 case SimpleTypeMode::NearPointer32:
603 case SimpleTypeMode::NearPointer64:
615 if (ti.getSimpleKind() == SimpleTypeKind::NotTranslated)
627 if (!record.hasUniqueName()) {
629 llvm::ArrayRef<MSVCUndecoratedNameSpecifier> specs = parser.
GetSpecifiers();
631 return std::string(specs.back().GetBaseName());
634 llvm::ms_demangle::Demangler demangler;
635 std::string_view sv(record.UniqueName.begin(), record.UniqueName.size());
636 llvm::ms_demangle::TagTypeNode *ttn = demangler.parseTagUniqueName(sv);
638 return std::string(record.Name);
640 llvm::ms_demangle::IdentifierNode *idn =
641 ttn->QualifiedName->getUnqualifiedIdentifier();
642 return idn->toString();
647 const TagRecord &record,
660 const ClassRecord &cr,
666 const UnionRecord &ur,
672 const EnumRecord &er,
680 underlying_type->GetByteSize(
nullptr),
nullptr,
686 const ArrayRecord &ar,
695 array_sp->SetEncodingType(element_type.get());
700 const MemberFunctionRecord &mfr,
709 const ProcedureRecord &pr,
718 if (type_id.
index.isSimple())
722 CVType cvt = stream.getType(type_id.
index);
724 if (cvt.kind() == LF_MODIFIER) {
725 ModifierRecord modifier;
727 TypeDeserializer::deserializeAs<ModifierRecord>(cvt, modifier));
731 if (cvt.kind() == LF_POINTER) {
732 PointerRecord pointer;
734 TypeDeserializer::deserializeAs<PointerRecord>(cvt, pointer));
740 llvm::cantFail(TypeDeserializer::deserializeAs<ClassRecord>(cvt, cr));
744 if (cvt.kind() == LF_ENUM) {
746 llvm::cantFail(TypeDeserializer::deserializeAs<EnumRecord>(cvt, er));
750 if (cvt.kind() == LF_UNION) {
752 llvm::cantFail(TypeDeserializer::deserializeAs<UnionRecord>(cvt, ur));
756 if (cvt.kind() == LF_ARRAY) {
758 llvm::cantFail(TypeDeserializer::deserializeAs<ArrayRecord>(cvt, ar));
762 if (cvt.kind() == LF_PROCEDURE) {
764 llvm::cantFail(TypeDeserializer::deserializeAs<ProcedureRecord>(cvt, pr));
767 if (cvt.kind() == LF_MFUNCTION) {
768 MemberFunctionRecord mfr;
769 llvm::cantFail(TypeDeserializer::deserializeAs<MemberFunctionRecord>(cvt, mfr));
779 std::optional<PdbTypeSymId> full_decl_uid;
781 auto expected_full_ti =
782 m_index->tpi().findFullDeclForForwardRef(type_id.
index);
783 if (!expected_full_ti)
784 llvm::consumeError(expected_full_ti.takeError());
785 else if (*expected_full_ti != type_id.
index) {
793 if (full_iter !=
m_types.end()) {
794 TypeSP result = full_iter->second;
803 PdbTypeSymId best_decl_id = full_decl_uid ? *full_decl_uid : type_id;
805 if (
auto err = ts_or_err.takeError())
807 auto ts = *ts_or_err;
845 CVSymbol sym =
m_index->symrecords().readRecord(var_id.
offset);
846 if (sym.kind() == S_CONSTANT)
851 llvm::StringRef name;
855 bool is_external =
false;
856 switch (sym.kind()) {
861 DataSym ds(sym.kind());
862 llvm::cantFail(SymbolDeserializer::deserializeAs<DataSym>(sym, ds));
867 section = ds.Segment;
868 offset = ds.DataOffset;
869 addr =
m_index->MakeVirtualAddress(ds.Segment, ds.DataOffset);
876 ThreadLocalDataSym tlds(sym.kind());
878 SymbolDeserializer::deserializeAs<ThreadLocalDataSym>(sym, tlds));
881 section = tlds.Segment;
882 offset = tlds.DataOffset;
883 addr =
m_index->MakeVirtualAddress(tlds.Segment, tlds.DataOffset);
888 llvm_unreachable(
"unreachable!");
891 CompUnitSP comp_unit;
892 std::optional<uint16_t> modi =
m_index->GetModuleIndexForVa(addr);
902 SymbolFileTypeSP type_sp =
903 std::make_shared<SymbolFileType>(*
this,
toOpaqueUid(tid));
906 if (
auto err = ts_or_err.takeError())
908 auto ts = *ts_or_err;
912 ts->GetNativePDBParser()->GetOrCreateVariableDecl(var_id);
919 std::string global_name(
"::");
921 bool artificial =
false;
922 bool location_is_constant_data =
false;
923 bool static_member =
false;
924 VariableSP var_sp = std::make_shared<Variable>(
925 toOpaqueUid(var_id), name.str().c_str(), global_name.c_str(), type_sp,
926 scope, comp_unit.get(), ranges, &decl, location, is_external, artificial,
927 location_is_constant_data, static_member);
934 const CVSymbol &cvs) {
935 TpiStream &tpi =
m_index->tpi();
936 ConstantSym constant(cvs.kind());
938 llvm::cantFail(SymbolDeserializer::deserializeAs<ConstantSym>(cvs, constant));
939 std::string global_name(
"::");
940 global_name += constant.Name;
942 SymbolFileTypeSP type_sp =
943 std::make_shared<SymbolFileType>(*
this,
toOpaqueUid(tid));
950 constant.Type, tpi, constant.Value, module),
953 bool external =
false;
954 bool artificial =
false;
955 bool location_is_constant_data =
true;
956 bool static_member =
false;
957 VariableSP var_sp = std::make_shared<Variable>(
958 toOpaqueUid(var_id), constant.Name.str().c_str(), global_name.c_str(),
960 external, artificial, location_is_constant_data, static_member);
967 if (emplace_result.second) {
969 emplace_result.first->second = var_sp;
974 return emplace_result.first->second;
984 if (emplace_result.second)
985 emplace_result.first->second =
CreateFunction(func_id, comp_unit);
987 return emplace_result.first->second;
993 auto emplace_result =
995 if (emplace_result.second)
999 return emplace_result.first->second;
1005 return *iter->second;
1024 return CompUnitSP();
1026 if (index >= UINT16_MAX)
1054 uint16_t modi = uid.asCompiland().modi;
1059 for (
auto iter = syms.begin(); iter != syms.end(); ++iter) {
1060 if (iter->kind() != S_LPROC32 && iter->kind() != S_GPROC32)
1070 return new_count - count;
1075 uint32_t flags = eSymbolContextCompUnit;
1076 flags |= eSymbolContextVariable;
1077 flags |= eSymbolContextFunction;
1078 flags |= eSymbolContextBlock;
1079 flags |= eSymbolContextLineEntry;
1080 return (resolve_scope & flags) != 0;
1090 std::optional<uint16_t> modi =
m_index->GetModuleIndexForVa(file_addr);
1098 resolved_flags |= eSymbolContextCompUnit;
1101 if (resolve_scope & eSymbolContextFunction ||
1102 resolve_scope & eSymbolContextBlock) {
1104 std::vector<SymbolAndUid> matches =
m_index->FindSymbolsByVa(file_addr);
1108 for (
const auto &match : llvm::reverse(matches)) {
1113 CVSymbol cvs =
m_index->ReadSymbolRecord(csid);
1115 if (type != PDB_SymType::Function && type != PDB_SymType::Block)
1117 if (type == PDB_SymType::Function) {
1123 addr_t offset = file_addr - func_base;
1128 if (type == PDB_SymType::Block) {
1135 addr_t offset = file_addr - func_base;
1140 resolved_flags |= eSymbolContextFunction;
1142 resolved_flags |= eSymbolContextBlock;
1147 if (resolve_scope & eSymbolContextLineEntry) {
1150 if (line_table->FindLineEntryByAddress(addr, sc.
line_entry))
1151 resolved_flags |= eSymbolContextLineEntry;
1155 return resolved_flags;
1163 if (resolve_scope & eSymbolContextCompUnit) {
1172 if (file_spec_matches_cu_file_spec) {
1178 return sc_list.
GetSize() - prev_size;
1197 std::set<LineTable::Entry, LineTableEntryComparator> line_set;
1202 for (
const DebugSubsectionRecord &dssr :
1204 if (dssr.kind() != DebugSubsectionKind::Lines)
1207 DebugLinesSubsectionRef lines;
1208 llvm::BinaryStreamReader reader(dssr.getRecordData());
1209 if (
auto EC = lines.initialize(reader)) {
1210 llvm::consumeError(std::move(EC));
1214 const LineFragmentHeader *lfh = lines.header();
1215 uint64_t virtual_addr =
1216 m_index->MakeVirtualAddress(lfh->RelocSegment, lfh->RelocOffset);
1220 for (
const LineColumnEntry &group : lines) {
1221 llvm::Expected<uint32_t> file_index_or_err =
1223 if (!file_index_or_err)
1225 uint32_t file_index = file_index_or_err.get();
1229 for (
const LineNumberEntry &entry : group.LineNumbers) {
1230 LineInfo cur_info(entry.Flags);
1232 if (cur_info.isAlwaysStepInto() || cur_info.isNeverStepInto())
1235 uint64_t addr = virtual_addr + entry.Offset;
1237 bool is_statement = cur_info.isStatement();
1241 uint32_t lno = cur_info.getStartLine();
1244 is_prologue, is_epilogue,
false);
1246 auto iter = line_set.find(new_entry);
1247 if (iter != line_set.end() && iter->is_terminal_entry)
1248 line_set.erase(iter);
1249 line_set.insert(new_entry);
1256 line_entry.
data = {file_index, lno};
1258 LineInfo last_line(group.LineNumbers.back().Flags);
1259 line_set.emplace(virtual_addr + lfh->CodeSize, last_line.getEndLine(), 0,
1260 file_index,
false,
false,
false,
false,
true);
1263 line_entry.
SetRangeEnd(virtual_addr + lfh->CodeSize);
1272 const CVSymbolArray &syms = cii->
m_debug_stream.getSymbolArray();
1273 for (
auto iter = syms.begin(); iter != syms.end();) {
1274 if (iter->kind() != S_LPROC32 && iter->kind() != S_GPROC32) {
1279 uint32_t record_offset = iter.offset();
1280 CVSymbol func_record =
1289 comp_unit.
GetModule()->GetSectionList());
1295 if (kind != S_INLINESITE)
1300 for (
const auto &line_entry :
1305 if (!line_entry.is_terminal_entry)
1306 line_set.erase(line_entry);
1307 line_set.insert(line_entry);
1315 iter = syms.at(getScopeEndOffset(func_record));
1321 auto line_table = std::make_unique<LineTable>(&comp_unit);
1322 std::unique_ptr<LineSequence> sequence(
1323 line_table->CreateLineSequenceContainer());
1324 for (
const auto &line_entry : line_set) {
1325 line_table->AppendLineEntryToSequence(
1326 sequence.get(), line_entry.file_addr, line_entry.line,
1327 line_entry.column, line_entry.file_idx,
1328 line_entry.is_start_of_statement, line_entry.is_start_of_basic_block,
1329 line_entry.is_prologue_end, line_entry.is_epilogue_begin,
1330 line_entry.is_terminal_entry);
1332 line_table->InsertSequence(sequence.get());
1334 if (line_table->GetSize() == 0)
1346llvm::Expected<uint32_t>
1350 return llvm::make_error<RawError>(raw_error_code::no_entry);
1352 const auto &checksums = cii.
m_strings.checksums().getArray();
1353 const auto &strings = cii.
m_strings.strings();
1357 auto iter = checksums.at(file_id);
1358 if (iter == checksums.end())
1359 return llvm::make_error<RawError>(raw_error_code::no_entry);
1361 llvm::Expected<llvm::StringRef> efn = strings.getString(iter->FileNameOffset);
1363 return efn.takeError();
1369 return std::distance(cii.
m_file_list.begin(), fn_iter);
1370 return llvm::make_error<RawError>(raw_error_code::no_entry);
1384 f.startswith(
"/") ? FileSpec::Style::posix : FileSpec::Style::windows;
1386 support_files.
Append(spec);
1392 const SymbolContext &sc, std::vector<SourceModule> &imported_modules) {
1405 CVSymbol sym = cii->
m_debug_stream.readSymbolAtOffset(
id.offset);
1408 InlineSiteSym inline_site(
static_cast<SymbolRecordKind
>(sym.kind()));
1409 cantFail(SymbolDeserializer::deserializeAs<InlineSiteSym>(sym, inline_site));
1412 std::shared_ptr<InlineSite> inline_site_sp =
1413 std::make_shared<InlineSite>(parent_id);
1416 auto iter = cii->
m_inline_map.find(inline_site.Inlinee);
1419 InlineeSourceLine inlinee_line = iter->second;
1421 const FileSpecList &files = comp_unit->GetSupportFiles();
1423 llvm::Expected<uint32_t> file_index_or_err =
1425 if (!file_index_or_err)
1427 uint32_t file_offset = file_index_or_err.get();
1429 uint32_t decl_line = inlinee_line.Header->SourceLineNum;
1430 std::unique_ptr<Declaration> decl_up =
1431 std::make_unique<Declaration>(decl_file, decl_line);
1435 int32_t line_offset = 0;
1436 std::optional<uint32_t> code_offset_base;
1437 std::optional<uint32_t> code_offset_end;
1438 std::optional<int32_t> cur_line_offset;
1439 std::optional<int32_t> next_line_offset;
1440 std::optional<uint32_t> next_file_offset;
1442 bool is_terminal_entry =
false;
1443 bool is_start_of_statement =
true;
1445 bool is_prologue_end =
true;
1447 auto update_code_offset = [&](
uint32_t code_delta) {
1448 if (!code_offset_base)
1449 code_offset_base = code_offset;
1450 else if (!code_offset_end)
1451 code_offset_end = *code_offset_base + code_delta;
1453 auto update_line_offset = [&](int32_t line_delta) {
1454 line_offset += line_delta;
1455 if (!code_offset_base || !cur_line_offset)
1456 cur_line_offset = line_offset;
1458 next_line_offset = line_offset;
1461 auto update_file_offset = [&](
uint32_t offset) {
1462 if (!code_offset_base)
1463 file_offset = offset;
1465 next_file_offset = offset;
1468 for (
auto &annot : inline_site.annotations()) {
1469 switch (annot.OpCode) {
1470 case BinaryAnnotationsOpCode::CodeOffset:
1471 case BinaryAnnotationsOpCode::ChangeCodeOffset:
1472 case BinaryAnnotationsOpCode::ChangeCodeOffsetBase:
1473 code_offset += annot.U1;
1474 update_code_offset(annot.U1);
1476 case BinaryAnnotationsOpCode::ChangeLineOffset:
1477 update_line_offset(annot.S1);
1479 case BinaryAnnotationsOpCode::ChangeCodeLength:
1480 update_code_offset(annot.U1);
1481 code_offset += annot.U1;
1482 is_terminal_entry =
true;
1484 case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset:
1485 code_offset += annot.U1;
1486 update_code_offset(annot.U1);
1487 update_line_offset(annot.S1);
1489 case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset:
1490 code_offset += annot.U2;
1491 update_code_offset(annot.U2);
1492 update_code_offset(annot.U1);
1493 code_offset += annot.U1;
1494 is_terminal_entry =
true;
1496 case BinaryAnnotationsOpCode::ChangeFile:
1497 update_file_offset(annot.U1);
1504 if (code_offset_base && code_offset_end && cur_line_offset) {
1506 *code_offset_base, *code_offset_end - *code_offset_base,
1507 decl_line + *cur_line_offset));
1509 if (next_file_offset)
1510 file_offset = *next_file_offset;
1511 if (next_line_offset) {
1512 cur_line_offset = next_line_offset;
1513 next_line_offset = std::nullopt;
1515 code_offset_base = is_terminal_entry ? std::nullopt : code_offset_end;
1516 code_offset_end = next_file_offset = std::nullopt;
1518 if (code_offset_base && cur_line_offset) {
1519 if (is_terminal_entry) {
1521 func_base + *code_offset_base, decl_line + *cur_line_offset, 0,
1522 file_offset,
false,
false,
false,
false,
true);
1523 inline_site_sp->line_entries.push_back(line_entry);
1526 decl_line + *cur_line_offset, 0,
1527 file_offset, is_start_of_statement,
false,
1528 is_prologue_end,
false,
false);
1529 inline_site_sp->line_entries.push_back(line_entry);
1530 is_prologue_end =
false;
1531 is_start_of_statement =
false;
1534 if (is_terminal_entry)
1535 is_start_of_statement =
true;
1536 is_terminal_entry =
false;
1539 inline_site_sp->ranges.Sort();
1542 std::unique_ptr<Declaration> callsite_up;
1543 if (!inline_site_sp->ranges.IsEmpty()) {
1544 auto *entry = inline_site_sp->ranges.GetEntryAtIndex(0);
1545 addr_t base_offset = entry->GetRangeBase();
1551 std::shared_ptr<InlineSite> parent_site =
1554 parent_site->inline_function_info->GetDeclaration().GetFile();
1555 if (
auto *parent_entry =
1556 parent_site->ranges.FindEntryThatContains(base_offset)) {
1558 std::make_unique<Declaration>(parent_decl_file, parent_entry->data);
1563 func_base + base_offset)) {
1567 std::make_unique<Declaration>(callsite_file, entry->data.second);
1573 CVType inlinee_cvt =
m_index->ipi().getType(inline_site.Inlinee);
1574 std::string inlinee_name;
1575 if (inlinee_cvt.kind() == LF_MFUNC_ID) {
1576 MemberFuncIdRecord mfr;
1578 TypeDeserializer::deserializeAs<MemberFuncIdRecord>(inlinee_cvt, mfr));
1579 LazyRandomTypeCollection &types =
m_index->tpi().typeCollection();
1580 inlinee_name.append(std::string(types.getTypeName(mfr.ClassType)));
1581 inlinee_name.append(
"::");
1582 inlinee_name.append(mfr.getName().str());
1583 }
else if (inlinee_cvt.kind() == LF_FUNC_ID) {
1585 cantFail(TypeDeserializer::deserializeAs<FuncIdRecord>(inlinee_cvt, fir));
1586 TypeIndex parent_idx = fir.getParentScope();
1587 if (!parent_idx.isNoneType()) {
1588 LazyRandomTypeCollection &ids =
m_index->ipi().typeCollection();
1589 inlinee_name.append(std::string(ids.getTypeName(parent_idx)));
1590 inlinee_name.append(
"::");
1592 inlinee_name.append(fir.getName().str());
1594 inline_site_sp->inline_function_info = std::make_shared<InlineFunctionInfo>(
1595 inlinee_name.c_str(), llvm::StringRef(), decl_up.get(),
1606 std::set<uint64_t> remove_uids;
1608 if (kind == S_GPROC32 || kind == S_LPROC32 || kind == S_BLOCK32 ||
1609 kind == S_INLINESITE) {
1611 if (kind == S_INLINESITE)
1618 for (uint64_t uid : remove_uids) {
1628 CVSymbolArray syms =
1632 for (
auto iter = syms.begin(); iter != syms.end(); ++iter) {
1634 if (fn(iter->kind(), child_id))
1645 auto ts = *ts_or_err;
1649 clang->GetNativePDBParser()->Dump(s);
1656 using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>;
1658 std::vector<SymbolAndOffset> results =
m_index->globals().findRecordsByName(
1660 for (
const SymbolAndOffset &result : results) {
1661 switch (result.second.kind()) {
1662 case SymbolKind::S_GDATA32:
1663 case SymbolKind::S_LDATA32:
1664 case SymbolKind::S_GTHREAD32:
1665 case SymbolKind::S_LTHREAD32:
1666 case SymbolKind::S_CONSTANT: {
1685 if (name_type_mask & eFunctionNameTypeFull)
1689 if (!(name_type_mask & eFunctionNameTypeFull ||
1690 name_type_mask & eFunctionNameTypeMethod))
1693 using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>;
1695 std::vector<SymbolAndOffset> matches =
m_index->globals().findRecordsByName(
1697 for (
const SymbolAndOffset &match : matches) {
1698 if (match.second.kind() != S_PROCREF && match.second.kind() != S_LPROCREF)
1700 ProcRefSym proc(match.second.kind());
1701 cantFail(SymbolDeserializer::deserializeAs<ProcRefSym>(match.second, proc));
1707 m_index->compilands().GetOrCreateCompiland(proc.modi());
1719 bool include_inlines,
1724 uint32_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files,
1730 searched_symbol_files.clear();
1731 searched_symbol_files.insert(
this);
1738 llvm::ArrayRef<CompilerContext> pattern,
LanguageSet languages,
1739 llvm::DenseSet<SymbolFile *> &searched_symbol_files,
TypeMap &types) {}
1745 std::vector<TypeIndex> matches =
m_index->tpi().findRecordsByName(name);
1746 if (max_matches > 0 && max_matches < matches.size())
1747 matches.resize(max_matches);
1749 for (TypeIndex ti : matches) {
1765 LazyRandomTypeCollection &types =
m_index->tpi().typeCollection();
1768 for (
auto ti = types.getFirst(); ti; ti = types.getNext(*ti)) {
1771 (void)type->GetFullCompilerType();
1777 CVSymbol sym =
m_index->ReadSymbolRecord(global);
1778 if (sym.kind() != S_UDT)
1781 UDTSym udt = llvm::cantFail(SymbolDeserializer::deserializeAs<UDTSym>(sym));
1782 bool is_typedef =
true;
1784 CVType cvt =
m_index->tpi().getType(udt.Type);
1786 if (name == udt.Name)
1798 return new_count - old_count;
1815 Block *func_block = █
1837 std::string name = var_info.
name.str();
1839 SymbolFileTypeSP sftype =
1840 std::make_shared<SymbolFileType>(*
this, type_sp->GetID());
1845 bool external =
false;
1846 bool artificial =
false;
1847 bool location_is_constant_data =
false;
1848 bool static_member =
false;
1850 VariableSP var_sp = std::make_shared<Variable>(
1851 toOpaqueUid(var_id), name.c_str(), name.c_str(), sftype, var_scope,
1852 &block, scope_ranges, &decl, var_info.
location, external, artificial,
1853 location_is_constant_data, static_member);
1856 if (
auto err = ts_or_err.takeError())
1858 auto ts = *ts_or_err;
1862 ts->GetNativePDBParser()->GetOrCreateVariableDecl(scope_id, var_id);
1872 return iter->second;
1878 CVSymbol sym =
m_index->ReadSymbolRecord(
id);
1881 UDTSym udt = llvm::cantFail(SymbolDeserializer::deserializeAs<UDTSym>(sym));
1886 if (
auto err = ts_or_err.takeError())
1888 auto ts = *ts_or_err;
1892 ts->GetNativePDBParser()->GetOrCreateTypedefDecl(
id);
1898 decl, target_type->GetForwardCompilerType(),
1905 return iter->second;
1918 switch (sym.kind()) {
1921 ProcSym proc(
static_cast<SymbolRecordKind
>(sym.kind()));
1922 cantFail(SymbolDeserializer::deserializeAs<ProcSym>(sym, proc));
1923 CVType signature =
m_index->tpi().getType(proc.FunctionType);
1924 if (signature.kind() == LF_PROCEDURE) {
1925 ProcedureRecord sig;
1926 if (llvm::Error e = TypeDeserializer::deserializeAs<ProcedureRecord>(
1928 llvm::consumeError(std::move(e));
1931 params_remaining = sig.getParameterCount();
1932 }
else if (signature.kind() == LF_MFUNCTION) {
1933 MemberFunctionRecord sig;
1934 if (llvm::Error e = TypeDeserializer::deserializeAs<MemberFunctionRecord>(
1936 llvm::consumeError(std::move(e));
1939 params_remaining = sig.getParameterCount();
1949 lldbassert(
false &&
"Symbol is not a block!");
1955 variables = std::make_shared<VariableList>();
1959 CVSymbolArray syms = limitSymbolArrayToScope(
1965 auto iter = syms.begin();
1966 auto end = syms.end();
1968 while (iter != end) {
1969 uint32_t record_offset = iter.offset();
1970 CVSymbol variable_cvs = *iter;
1976 if (variable_cvs.kind() == S_BLOCK32 ||
1977 variable_cvs.kind() == S_INLINESITE) {
1978 uint32_t block_end = getScopeEndOffset(variable_cvs);
1980 iter = syms.at(block_end);
1984 bool is_param = params_remaining > 0;
1985 VariableSP variable;
1986 switch (variable_cvs.kind()) {
1994 variables->AddVariableIfUnique(variable);
2012 VariableListSP variables;
2030 variables = std::make_shared<VariableList>();
2036 llvm_unreachable(
"Unreachable!");
2041 if (
auto err = ts_or_err.takeError())
2043 auto ts = *ts_or_err;
2047 if (
auto decl = ts->GetNativePDBParser()->GetOrCreateDeclForUid(uid))
2055 if (
auto err = ts_or_err.takeError())
2057 auto ts = *ts_or_err;
2062 clang::DeclContext *context =
2073 if (
auto err = ts_or_err.takeError())
2075 auto ts = *ts_or_err;
2088 auto iter =
m_types.find(type_uid);
2095 return &*iter->second;
2100 if (type_id.
index.isNoneType())
2109std::optional<SymbolFile::ArrayInfo>
2112 return std::nullopt;
2119 if (!clang_type_system)
2123 static_cast<PdbAstBuilder *
>(clang_type_system->GetNativePDBParser());
2127 clang::QualType qt =
2134 TypeClass type_mask,
2142llvm::Expected<lldb::TypeSystemSP>
2144 auto type_system_or_err =
2145 m_objfile_sp->GetModule()->GetTypeSystemForLanguage(language);
2146 if (type_system_or_err)
2147 if (
auto ts = *type_system_or_err)
2148 ts->SetSymbolFile(
this);
2149 return type_system_or_err;
2154 return m_index->pdb().getFileSize();
2158 LazyRandomTypeCollection &types =
m_index->tpi().typeCollection();
2160 llvm::DenseMap<TypeIndex, TypeIndex> forward_to_full;
2161 llvm::DenseMap<TypeIndex, TypeIndex> full_to_forward;
2163 struct RecordIndices {
2168 llvm::StringMap<RecordIndices> record_indices;
2170 for (
auto ti = types.getFirst(); ti; ti = types.getNext(*ti)) {
2171 CVType type = types.getType(*ti);
2177 RecordIndices &indices = record_indices[tag.
asTag().getUniqueName()];
2178 if (tag.
asTag().isForwardRef())
2179 indices.forward = *ti;
2183 if (indices.full != TypeIndex::None() &&
2184 indices.forward != TypeIndex::None()) {
2185 forward_to_full[indices.forward] = indices.full;
2186 full_to_forward[indices.full] = indices.forward;
2192 if (tag.
asTag().isForwardRef() || !tag.
asTag().containsNestedClass())
2196 ProcessTpiStream(
PdbIndex &index, TypeIndex parent,
2198 llvm::DenseMap<TypeIndex, TypeIndex> &parents)
2199 : index(index), parents(parents), parent(parent),
2200 parent_cvt(parent_cvt) {}
2203 llvm::DenseMap<TypeIndex, TypeIndex> &parents;
2205 unsigned unnamed_type_index = 1;
2209 llvm::Error visitKnownMember(CVMemberRecord &CVR,
2210 NestedTypeRecord &Record)
override {
2211 std::string unnamed_type_name;
2212 if (Record.Name.empty()) {
2214 llvm::formatv(
"<unnamed-type-$S{0}>", unnamed_type_index).str();
2215 Record.Name = unnamed_type_name;
2216 ++unnamed_type_index;
2218 std::optional<CVTagRecord> tag =
2221 return llvm::ErrorSuccess();
2223 parents[Record.Type] = parent;
2224 return llvm::ErrorSuccess();
2228 CVType field_list_cvt =
m_index->tpi().getType(tag.
asTag().FieldList);
2230 FieldListRecord field_list;
2231 if (llvm::Error
error = TypeDeserializer::deserializeAs<FieldListRecord>(
2232 field_list_cvt, field_list))
2233 llvm::consumeError(std::move(
error));
2234 if (llvm::Error
error = visitMemberRecordStream(field_list.Data, process))
2235 llvm::consumeError(std::move(
error));
2243 std::vector<TypeIndex> full_keys;
2244 std::vector<TypeIndex> fwd_keys;
2246 TypeIndex key = entry.first;
2247 TypeIndex value = entry.second;
2249 auto iter = forward_to_full.find(value);
2250 if (iter != forward_to_full.end())
2251 entry.second = iter->second;
2253 iter = forward_to_full.find(key);
2254 if (iter != forward_to_full.end())
2255 fwd_keys.push_back(key);
2257 full_keys.push_back(key);
2259 for (TypeIndex fwd : fwd_keys) {
2260 TypeIndex full = forward_to_full[fwd];
2263 for (TypeIndex full : full_keys) {
2264 TypeIndex fwd = full_to_forward[full];
2269std::optional<PdbCompilandSymId>
2271 CVSymbol sym =
m_index->ReadSymbolRecord(
id);
2272 if (symbolOpensScope(sym.kind())) {
2275 id.offset = getScopeParentOffset(sym);
2279 return std::nullopt;
2288 auto begin = syms.begin();
2289 auto end = syms.at(
id.offset);
2290 std::vector<PdbCompilandSymId> scope_stack;
2292 while (begin != end) {
2293 if (begin.offset() >
id.offset) {
2295 lldbassert(
false &&
"Invalid compiland symbol id!");
2296 return std::nullopt;
2301 if (symbolOpensScope(begin->kind())) {
2304 uint32_t scope_end = getScopeEndOffset(*begin);
2305 if (scope_end <
id.offset) {
2306 begin = syms.at(scope_end);
2309 scope_stack.emplace_back(
id.modi, begin.offset());
2311 }
else if (symbolEndsScope(begin->kind())) {
2312 scope_stack.pop_back();
2316 if (scope_stack.empty())
2317 return std::nullopt;
2319 return scope_stack.back();
2322std::optional<llvm::codeview::TypeIndex>
2326 return std::nullopt;
2327 return parent_iter->second;
static llvm::raw_ostream & error(Stream &strm)
#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 bool IsFunctionPrologue(const CompilandIndexItem &cci, lldb::addr_t addr)
llvm::ArrayRef< MSVCUndecoratedNameSpecifier > GetSpecifiers() const
A section + offset based address range class.
Address & GetBaseAddress()
Get accessor for the base address of the range.
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)
Function * CalculateSymbolContextFunction() override
void SetVariableList(lldb::VariableListSP &variable_list_sp)
Set accessor for the variable list.
Block * GetParent() const
Get the parent block.
size_t GetNumRanges() const
bool GetStartAddress(Address &addr)
void SetDidParseVariables(bool b, bool set_children)
void AddRange(const Range &range)
Add a new offset range to this block.
void AddChild(const lldb::BlockSP &child_block_sp)
Add a child to this object.
bool CanImport(const CompilerType &type)
Returns true iff the given type was copied from another TypeSystemClang and the original type in this...
bool CompleteType(const CompilerType &compiler_type)
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 file associated with this compile unit.
void ResolveSymbolContext(const SourceLocationSpec &src_location_spec, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list)
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.
std::shared_ptr< TypeSystemType > dyn_cast_or_null()
Return a shared_ptr<TypeSystemType> if dyn_cast succeeds.
Generic representation of a type in a programming language.
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
A uniqued constant string class.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
const char * GetCString() const
Get the string value as a C string.
"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.
const FileSpec & GetFileSpecAtIndex(size_t idx) const
Get file at index.
void Append(const FileSpec &file)
Append a FileSpec object to the list.
static bool Match(const FileSpec &pattern, const FileSpec &file)
Match FileSpec pattern against FileSpec file.
const ConstString & GetFilename() const
Filename string const get accessor.
FileSpec CopyByRemovingLastPathComponent() const
llvm::sys::path::Style Style
static FileSystem & Instance()
A class that describes a function.
const AddressRange & GetAddressRange()
Block & GetBlock(bool can_create)
Get accessor for the block list.
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)
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.
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.
Containing protected virtual methods for child classes to override.
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)
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.
Provides public interface for all SymbolFiles.
virtual std::recursive_mutex & GetModuleMutex() const
Symbols file subclasses should override this to return the Module that owns the TypeSystem that this ...
void Insert(const lldb::TypeSP &type)
void Insert(const lldb::TypeSP &type)
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.
void AddVariable(const lldb::VariableSP &var_sp)
ClangASTImporter & GetClangASTImporter()
clang::DeclContext * GetParentDeclContext(PdbSymUid uid)
CompilerDeclContext ToCompilerDeclContext(clang::DeclContext &context)
clang::DeclContext * FromCompilerDeclContext(CompilerDeclContext context)
CompilerType ToCompilerType(clang::QualType qt)
bool CompleteType(clang::QualType qt)
clang::DeclContext * GetOrCreateDeclContextForUid(PdbSymUid uid)
void ParseDeclsForContext(clang::DeclContext &context)
clang::BlockDecl * GetOrCreateBlockDecl(PdbCompilandSymId block_id)
clang::QualType GetOrCreateType(PdbTypeSymId type)
clang::FunctionDecl * GetOrCreateInlinedFunctionDecl(PdbCompilandSymId inlinesite_id)
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
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.
lldb::VariableSP CreateGlobalVariable(PdbGlobalSymId var_id)
llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language) override
void InitializeObject() override
Initialize the SymbolFile object.
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
lldb::VariableSP GetOrCreateLocalVariable(PdbCompilandSymId scope_id, PdbCompilandSymId var_id, bool is_param)
Block & CreateBlock(PdbCompilandSymId block_id)
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
CompilerDecl GetDeclForUID(lldb::user_id_t uid) override
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 DumpClangAST(Stream &s) override
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)
void FindTypes(ConstString name, const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, llvm::DenseSet< SymbolFile * > &searched_symbol_files, TypeMap &types) override
void AddSymbols(Symtab &symtab) override
std::optional< llvm::codeview::TypeIndex > GetParentType(llvm::codeview::TypeIndex ti)
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::VariableSP CreateLocalVariable(PdbCompilandSymId scope_id, PdbCompilandSymId var_id, bool is_param)
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)
size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override
lldb::addr_t m_obj_load_address
size_t ParseBlocksRecursive(Function &func) override
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
bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit, FileSpecList &support_files) override
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
static void DebuggerInitialize(Debugger &debugger)
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)
Block & GetOrCreateBlock(PdbCompilandSymId block_id)
llvm::DenseMap< llvm::codeview::TypeIndex, llvm::codeview::TypeIndex > m_parent_types
lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override
lldb::TypeSP CreateFunctionType(PdbTypeSymId type_id, const llvm::codeview::MemberFunctionRecord &pr, CompilerType ct)
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
static char ID
LLVM RTTI support.
uint64_t GetDebugInfoSize() override
Metrics gathering functions.
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)
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)
DWARFExpression MakeConstantLocationExpression(llvm::codeview::TypeIndex underlying_ti, llvm::pdb::TpiStream &tpi, const llvm::APSInt &constant, lldb::ModuleSP module)
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.
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.
@ eValueTypeVariableGlobal
globals variable
@ eValueTypeVariableLocal
function local variables
@ eValueTypeVariableArgument
function argument variables
@ eValueTypeVariableStatic
static variable
@ eValueTypeVariableThreadLocal
thread local storage variable
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
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.
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