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"
84static std::unique_ptr<PDBFile>
87 using namespace llvm::object;
88 auto expected_binary = createBinary(exe_path);
91 if (!expected_binary) {
92 llvm::consumeError(expected_binary.takeError());
95 OwningBinary<Binary> binary = std::move(*expected_binary);
99 auto *obj = llvm::dyn_cast<llvm::object::COFFObjectFile>(binary.getBinary());
102 const llvm::codeview::DebugInfo *pdb_info =
nullptr;
105 llvm::StringRef pdb_file;
106 if (llvm::Error e = obj->getDebugPDBInfo(pdb_info, pdb_file)) {
107 consumeError(std::move(e));
117 pdb_file = exe_dir.CopyByAppendingPathComponent(pdb_name).GetPathAsConstString().GetStringRef();
125 auto expected_info = pdb->getPDBInfoStream();
126 if (!expected_info) {
127 llvm::consumeError(expected_info.takeError());
130 llvm::codeview::GUID guid;
131 memcpy(&guid, pdb_info->PDB70.Signature, 16);
133 if (expected_info->getGuid() != guid)
152 case SimpleTypeKind::Boolean128:
153 case SimpleTypeKind::Boolean16:
154 case SimpleTypeKind::Boolean32:
155 case SimpleTypeKind::Boolean64:
156 case SimpleTypeKind::Boolean8:
158 case SimpleTypeKind::Byte:
159 case SimpleTypeKind::UnsignedCharacter:
160 return "unsigned char";
161 case SimpleTypeKind::NarrowCharacter:
163 case SimpleTypeKind::SignedCharacter:
164 case SimpleTypeKind::SByte:
165 return "signed char";
166 case SimpleTypeKind::Character16:
168 case SimpleTypeKind::Character32:
170 case SimpleTypeKind::Character8:
172 case SimpleTypeKind::Complex80:
173 case SimpleTypeKind::Complex64:
174 case SimpleTypeKind::Complex32:
176 case SimpleTypeKind::Float128:
177 case SimpleTypeKind::Float80:
178 return "long double";
179 case SimpleTypeKind::Float64:
181 case SimpleTypeKind::Float32:
183 case SimpleTypeKind::Float16:
185 case SimpleTypeKind::Int128:
187 case SimpleTypeKind::Int64:
188 case SimpleTypeKind::Int64Quad:
190 case SimpleTypeKind::Int32:
192 case SimpleTypeKind::Int16:
194 case SimpleTypeKind::UInt128:
195 return "unsigned __int128";
196 case SimpleTypeKind::UInt64:
197 case SimpleTypeKind::UInt64Quad:
199 case SimpleTypeKind::HResult:
201 case SimpleTypeKind::UInt32:
203 case SimpleTypeKind::UInt16:
204 case SimpleTypeKind::UInt16Short:
205 return "unsigned short";
206 case SimpleTypeKind::Int32Long:
208 case SimpleTypeKind::UInt32Long:
209 return "unsigned long";
210 case SimpleTypeKind::Void:
212 case SimpleTypeKind::WideCharacter:
230static std::optional<CVTagRecord>
249 if (Record.Type.isSimple())
252 CVType cvt = tpi.getType(Record.Type);
261 std::string qname = std::string(parent.
asTag().getUniqueName());
262 if (qname.size() < 4 || child.
asTag().getUniqueName().size() < 4)
268 qname[3] = child.
asTag().getUniqueName()[3];
272 piece += Record.Name;
273 piece.push_back(
'@');
274 qname.insert(4, std::move(piece));
275 if (qname != child.
asTag().UniqueName)
278 return std::move(child);
294 return "Microsoft PDB debug symbol cross-platform file reader.";
314 if (
auto *pdb = llvm::dyn_cast<ObjectFilePDB>(
m_objfile_sp.get())) {
315 pdb_file = &pdb->GetPDBFile();
326 if (!expected_index) {
327 llvm::consumeError(expected_index.takeError());
330 m_index = std::move(*expected_index);
339 if (
m_index->dbi().isStripped())
350 m_index->ParseSectionContribs();
352 auto ts_or_err =
m_objfile_sp->GetModule()->GetTypeSystemForLanguage(
354 if (
auto err = ts_or_err.takeError()) {
356 "Failed to initialize");
358 if (
auto ts = *ts_or_err)
359 ts->SetSymbolFile(
this);
365 const DbiModuleList &modules =
m_index->dbi().modules();
366 uint32_t count = modules.getModuleCount();
373 DbiModuleDescriptor last = modules.getModuleDescriptor(count - 1);
374 if (last.getModuleName() ==
"* Linker *")
384 BlockSP child_block = std::make_shared<Block>(opaque_block_uid);
386 if (
auto err = ts_or_err.takeError())
388 auto ts = *ts_or_err;
393 switch (sym.kind()) {
400 Block &block = func->GetBlock(
false);
412 BlockSym block(
static_cast<SymbolRecordKind
>(sym.kind()));
413 cantFail(SymbolDeserializer::deserializeAs<BlockSym>(sym, block));
420 m_index->MakeVirtualAddress(block.Segment, block.CodeOffset);
423 if (block_base >= func_base)
424 child_block->AddRange(
Block::Range(block_base - func_base, block.CodeSize));
427 "S_BLOCK32 at modi: {0:d} offset: {1:d}: adding range "
428 "[{2:x16}-{3:x16}) which has a base that is less than the "
430 "low PC 0x%" PRIx64
". Please file a bug and attach the file at the "
431 "start of this error message",
433 block_base + block.CodeSize, func_base);
437 m_blocks.insert({opaque_block_uid, child_block});
442 comp_unit->GetLineTable();
444 std::shared_ptr<InlineSite> inline_site =
m_inline_sites[opaque_block_uid];
449 for (
size_t i = 0; i < inline_site->ranges.GetSize(); ++i) {
450 auto *entry = inline_site->ranges.GetEntryAtIndex(i);
451 child_block->AddRange(
452 Block::Range(entry->GetRangeBase(), entry->GetByteSize()));
454 child_block->FinalizeRanges();
457 Declaration &decl = inline_site->inline_function_info->GetDeclaration();
458 Declaration &callsite = inline_site->inline_function_info->GetCallSite();
459 child_block->SetInlinedFunctionInfo(
460 inline_site->inline_function_info->GetName().GetCString(),
nullptr,
462 m_blocks.insert({opaque_block_uid, child_block});
466 lldbassert(
false &&
"Symbol is not a block!");
479 lldbassert(sym_record.kind() == S_LPROC32 || sym_record.kind() == S_GPROC32);
488 comp_unit.
GetModule()->GetSectionList());
492 ProcSym proc(
static_cast<SymbolRecordKind
>(sym_record.kind()));
493 cantFail(SymbolDeserializer::deserializeAs<ProcSym>(sym_record, proc));
494 if (proc.FunctionType == TypeIndex::None())
501 Mangled mangled(proc.Name);
502 FunctionSP func_sp = std::make_shared<Function>(
504 func_type.get(), func_range);
509 if (
auto err = ts_or_err.takeError())
511 auto ts = *ts_or_err;
514 ts->GetNativePDBParser()->GetOrCreateFunctionDecl(func_id);
529 llvm::SmallString<64> source_file_name =
530 m_index->compilands().GetMainSourceFile(cci);
531 FileSpec fs(llvm::sys::path::convert_to_slash(
532 source_file_name, llvm::sys::path::Style::windows_backslash));
535 std::make_shared<CompileUnit>(
m_objfile_sp->GetModule(),
nullptr, fs,
543 const ModifierRecord &mr,
545 TpiStream &stream =
m_index->tpi();
548 if (mr.ModifiedType.isSimple())
551 name = computeTypeName(stream.typeCollection(), mr.ModifiedType);
556 modified_type->GetByteSize(
nullptr),
nullptr,
563 const llvm::codeview::PointerRecord &pr,
569 if (pr.isPointerToMember()) {
570 MemberPointerInfo mpi = pr.getMemberInfo();
583 if (ti == TypeIndex::NullptrT()) {
590 if (ti.getSimpleMode() != SimpleTypeMode::Direct) {
593 switch (ti.getSimpleMode()) {
594 case SimpleTypeMode::FarPointer32:
595 case SimpleTypeMode::NearPointer32:
598 case SimpleTypeMode::NearPointer64:
610 if (ti.getSimpleKind() == SimpleTypeKind::NotTranslated)
622 if (!record.hasUniqueName()) {
624 llvm::ArrayRef<MSVCUndecoratedNameSpecifier> specs = parser.
GetSpecifiers();
626 return std::string(specs.back().GetBaseName());
629 llvm::ms_demangle::Demangler demangler;
630 StringView sv(record.UniqueName.begin(), record.UniqueName.size());
631 llvm::ms_demangle::TagTypeNode *ttn = demangler.parseTagUniqueName(sv);
633 return std::string(record.Name);
635 llvm::ms_demangle::IdentifierNode *idn =
636 ttn->QualifiedName->getUnqualifiedIdentifier();
637 return idn->toString();
642 const TagRecord &record,
655 const ClassRecord &cr,
661 const UnionRecord &ur,
667 const EnumRecord &er,
675 underlying_type->GetByteSize(
nullptr),
nullptr,
681 const ArrayRecord &ar,
690 array_sp->SetEncodingType(element_type.get());
695 const MemberFunctionRecord &mfr,
704 const ProcedureRecord &pr,
713 if (type_id.
index.isSimple())
717 CVType cvt = stream.getType(type_id.
index);
719 if (cvt.kind() == LF_MODIFIER) {
720 ModifierRecord modifier;
722 TypeDeserializer::deserializeAs<ModifierRecord>(cvt, modifier));
726 if (cvt.kind() == LF_POINTER) {
727 PointerRecord pointer;
729 TypeDeserializer::deserializeAs<PointerRecord>(cvt, pointer));
735 llvm::cantFail(TypeDeserializer::deserializeAs<ClassRecord>(cvt, cr));
739 if (cvt.kind() == LF_ENUM) {
741 llvm::cantFail(TypeDeserializer::deserializeAs<EnumRecord>(cvt, er));
745 if (cvt.kind() == LF_UNION) {
747 llvm::cantFail(TypeDeserializer::deserializeAs<UnionRecord>(cvt, ur));
751 if (cvt.kind() == LF_ARRAY) {
753 llvm::cantFail(TypeDeserializer::deserializeAs<ArrayRecord>(cvt, ar));
757 if (cvt.kind() == LF_PROCEDURE) {
759 llvm::cantFail(TypeDeserializer::deserializeAs<ProcedureRecord>(cvt, pr));
762 if (cvt.kind() == LF_MFUNCTION) {
763 MemberFunctionRecord mfr;
764 llvm::cantFail(TypeDeserializer::deserializeAs<MemberFunctionRecord>(cvt, mfr));
774 std::optional<PdbTypeSymId> full_decl_uid;
776 auto expected_full_ti =
777 m_index->tpi().findFullDeclForForwardRef(type_id.
index);
778 if (!expected_full_ti)
779 llvm::consumeError(expected_full_ti.takeError());
780 else if (*expected_full_ti != type_id.
index) {
788 if (full_iter !=
m_types.end()) {
789 TypeSP result = full_iter->second;
798 PdbTypeSymId best_decl_id = full_decl_uid ? *full_decl_uid : type_id;
800 if (
auto err = ts_or_err.takeError())
802 auto ts = *ts_or_err;
840 CVSymbol sym =
m_index->symrecords().readRecord(var_id.
offset);
841 if (sym.kind() == S_CONSTANT)
846 llvm::StringRef name;
850 bool is_external =
false;
851 switch (sym.kind()) {
856 DataSym ds(sym.kind());
857 llvm::cantFail(SymbolDeserializer::deserializeAs<DataSym>(sym, ds));
862 section = ds.Segment;
863 offset = ds.DataOffset;
864 addr =
m_index->MakeVirtualAddress(ds.Segment, ds.DataOffset);
871 ThreadLocalDataSym tlds(sym.kind());
873 SymbolDeserializer::deserializeAs<ThreadLocalDataSym>(sym, tlds));
876 section = tlds.Segment;
877 offset = tlds.DataOffset;
878 addr =
m_index->MakeVirtualAddress(tlds.Segment, tlds.DataOffset);
883 llvm_unreachable(
"unreachable!");
886 CompUnitSP comp_unit;
887 std::optional<uint16_t> modi =
m_index->GetModuleIndexForVa(addr);
897 SymbolFileTypeSP type_sp =
898 std::make_shared<SymbolFileType>(*
this,
toOpaqueUid(tid));
901 if (
auto err = ts_or_err.takeError())
903 auto ts = *ts_or_err;
907 ts->GetNativePDBParser()->GetOrCreateVariableDecl(var_id);
914 std::string global_name(
"::");
916 bool artificial =
false;
917 bool location_is_constant_data =
false;
918 bool static_member =
false;
919 VariableSP var_sp = std::make_shared<Variable>(
920 toOpaqueUid(var_id), name.str().c_str(), global_name.c_str(), type_sp,
921 scope, comp_unit.get(), ranges, &decl, location, is_external, artificial,
922 location_is_constant_data, static_member);
929 const CVSymbol &cvs) {
930 TpiStream &tpi =
m_index->tpi();
931 ConstantSym constant(cvs.kind());
933 llvm::cantFail(SymbolDeserializer::deserializeAs<ConstantSym>(cvs, constant));
934 std::string global_name(
"::");
935 global_name += constant.Name;
937 SymbolFileTypeSP type_sp =
938 std::make_shared<SymbolFileType>(*
this,
toOpaqueUid(tid));
945 constant.Type, tpi, constant.Value, module),
948 bool external =
false;
949 bool artificial =
false;
950 bool location_is_constant_data =
true;
951 bool static_member =
false;
952 VariableSP var_sp = std::make_shared<Variable>(
953 toOpaqueUid(var_id), constant.Name.str().c_str(), global_name.c_str(),
955 external, artificial, location_is_constant_data, static_member);
962 if (emplace_result.second) {
964 emplace_result.first->second = var_sp;
969 return emplace_result.first->second;
979 if (emplace_result.second)
980 emplace_result.first->second =
CreateFunction(func_id, comp_unit);
982 return emplace_result.first->second;
988 auto emplace_result =
990 if (emplace_result.second)
994 return emplace_result.first->second;
1000 return *iter->second;
1019 return CompUnitSP();
1021 if (index >= UINT16_MAX)
1049 uint16_t modi = uid.asCompiland().modi;
1054 for (
auto iter = syms.begin(); iter != syms.end(); ++iter) {
1055 if (iter->kind() != S_LPROC32 && iter->kind() != S_GPROC32)
1065 return new_count - count;
1070 uint32_t flags = eSymbolContextCompUnit;
1071 flags |= eSymbolContextVariable;
1072 flags |= eSymbolContextFunction;
1073 flags |= eSymbolContextBlock;
1074 flags |= eSymbolContextLineEntry;
1075 return (resolve_scope & flags) != 0;
1085 std::optional<uint16_t> modi =
m_index->GetModuleIndexForVa(file_addr);
1093 resolved_flags |= eSymbolContextCompUnit;
1096 if (resolve_scope & eSymbolContextFunction ||
1097 resolve_scope & eSymbolContextBlock) {
1099 std::vector<SymbolAndUid> matches =
m_index->FindSymbolsByVa(file_addr);
1103 for (
const auto &match : llvm::reverse(matches)) {
1108 CVSymbol cvs =
m_index->ReadSymbolRecord(csid);
1110 if (type != PDB_SymType::Function && type != PDB_SymType::Block)
1112 if (type == PDB_SymType::Function) {
1118 addr_t offset = file_addr - func_base;
1123 if (type == PDB_SymType::Block) {
1130 addr_t offset = file_addr - func_base;
1135 resolved_flags |= eSymbolContextFunction;
1137 resolved_flags |= eSymbolContextBlock;
1142 if (resolve_scope & eSymbolContextLineEntry) {
1145 if (line_table->FindLineEntryByAddress(addr, sc.
line_entry))
1146 resolved_flags |= eSymbolContextLineEntry;
1150 return resolved_flags;
1158 if (resolve_scope & eSymbolContextCompUnit) {
1167 if (file_spec_matches_cu_file_spec) {
1173 return sc_list.
GetSize() - prev_size;
1192 std::set<LineTable::Entry, LineTableEntryComparator> line_set;
1197 for (
const DebugSubsectionRecord &dssr :
1199 if (dssr.kind() != DebugSubsectionKind::Lines)
1202 DebugLinesSubsectionRef lines;
1203 llvm::BinaryStreamReader reader(dssr.getRecordData());
1204 if (
auto EC = lines.initialize(reader)) {
1205 llvm::consumeError(std::move(EC));
1209 const LineFragmentHeader *lfh = lines.header();
1210 uint64_t virtual_addr =
1211 m_index->MakeVirtualAddress(lfh->RelocSegment, lfh->RelocOffset);
1215 for (
const LineColumnEntry &group : lines) {
1216 llvm::Expected<uint32_t> file_index_or_err =
1218 if (!file_index_or_err)
1220 uint32_t file_index = file_index_or_err.get();
1224 for (
const LineNumberEntry &entry : group.LineNumbers) {
1225 LineInfo cur_info(entry.Flags);
1227 if (cur_info.isAlwaysStepInto() || cur_info.isNeverStepInto())
1230 uint64_t addr = virtual_addr + entry.Offset;
1232 bool is_statement = cur_info.isStatement();
1236 uint32_t lno = cur_info.getStartLine();
1239 is_prologue, is_epilogue,
false);
1241 auto iter = line_set.find(new_entry);
1242 if (iter != line_set.end() && iter->is_terminal_entry)
1243 line_set.erase(iter);
1244 line_set.insert(new_entry);
1251 line_entry.
data = {file_index, lno};
1253 LineInfo last_line(group.LineNumbers.back().Flags);
1254 line_set.emplace(virtual_addr + lfh->CodeSize, last_line.getEndLine(), 0,
1255 file_index,
false,
false,
false,
false,
true);
1258 line_entry.
SetRangeEnd(virtual_addr + lfh->CodeSize);
1267 const CVSymbolArray &syms = cii->
m_debug_stream.getSymbolArray();
1268 for (
auto iter = syms.begin(); iter != syms.end();) {
1269 if (iter->kind() != S_LPROC32 && iter->kind() != S_GPROC32) {
1274 uint32_t record_offset = iter.offset();
1275 CVSymbol func_record =
1284 comp_unit.
GetModule()->GetSectionList());
1290 if (kind != S_INLINESITE)
1295 for (
const auto &line_entry :
1300 if (!line_entry.is_terminal_entry)
1301 line_set.erase(line_entry);
1302 line_set.insert(line_entry);
1310 iter = syms.at(getScopeEndOffset(func_record));
1316 auto line_table = std::make_unique<LineTable>(&comp_unit);
1317 std::unique_ptr<LineSequence> sequence(
1318 line_table->CreateLineSequenceContainer());
1319 for (
const auto &line_entry : line_set) {
1320 line_table->AppendLineEntryToSequence(
1321 sequence.get(), line_entry.file_addr, line_entry.line,
1322 line_entry.column, line_entry.file_idx,
1323 line_entry.is_start_of_statement, line_entry.is_start_of_basic_block,
1324 line_entry.is_prologue_end, line_entry.is_epilogue_begin,
1325 line_entry.is_terminal_entry);
1327 line_table->InsertSequence(sequence.get());
1329 if (line_table->GetSize() == 0)
1341llvm::Expected<uint32_t>
1344 const auto &checksums = cii.
m_strings.checksums().getArray();
1345 const auto &strings = cii.
m_strings.strings();
1349 auto iter = checksums.at(file_id);
1350 if (iter == checksums.end())
1351 return llvm::make_error<RawError>(raw_error_code::no_entry);
1353 llvm::Expected<llvm::StringRef> efn = strings.getString(iter->FileNameOffset);
1355 return efn.takeError();
1361 return std::distance(cii.
m_file_list.begin(), fn_iter);
1362 return llvm::make_error<RawError>(raw_error_code::no_entry);
1366 FileSpecList &support_files) {
1376 f.startswith(
"/") ? FileSpec::Style::posix : FileSpec::Style::windows;
1378 support_files.Append(spec);
1384 const SymbolContext &sc, std::vector<SourceModule> &imported_modules) {
1397 CVSymbol sym = cii->
m_debug_stream.readSymbolAtOffset(
id.offset);
1400 InlineSiteSym inline_site(
static_cast<SymbolRecordKind
>(sym.kind()));
1401 cantFail(SymbolDeserializer::deserializeAs<InlineSiteSym>(sym, inline_site));
1404 std::shared_ptr<InlineSite> inline_site_sp =
1405 std::make_shared<InlineSite>(parent_id);
1408 auto iter = cii->
m_inline_map.find(inline_site.Inlinee);
1411 InlineeSourceLine inlinee_line = iter->second;
1413 const FileSpecList &files = comp_unit->GetSupportFiles();
1415 llvm::Expected<uint32_t> file_index_or_err =
1417 if (!file_index_or_err)
1419 uint32_t file_offset = file_index_or_err.get();
1420 decl_file = files.GetFileSpecAtIndex(file_offset);
1421 uint32_t decl_line = inlinee_line.Header->SourceLineNum;
1422 std::unique_ptr<Declaration> decl_up =
1423 std::make_unique<Declaration>(decl_file, decl_line);
1427 int32_t line_offset = 0;
1428 std::optional<uint32_t> code_offset_base;
1429 std::optional<uint32_t> code_offset_end;
1430 std::optional<int32_t> cur_line_offset;
1431 std::optional<int32_t> next_line_offset;
1432 std::optional<uint32_t> next_file_offset;
1434 bool is_terminal_entry =
false;
1435 bool is_start_of_statement =
true;
1437 bool is_prologue_end =
true;
1439 auto update_code_offset = [&](
uint32_t code_delta) {
1440 if (!code_offset_base)
1441 code_offset_base = code_offset;
1442 else if (!code_offset_end)
1443 code_offset_end = *code_offset_base + code_delta;
1445 auto update_line_offset = [&](int32_t line_delta) {
1446 line_offset += line_delta;
1447 if (!code_offset_base || !cur_line_offset)
1448 cur_line_offset = line_offset;
1450 next_line_offset = line_offset;
1453 auto update_file_offset = [&](
uint32_t offset) {
1454 if (!code_offset_base)
1455 file_offset = offset;
1457 next_file_offset = offset;
1460 for (
auto &annot : inline_site.annotations()) {
1461 switch (annot.OpCode) {
1462 case BinaryAnnotationsOpCode::CodeOffset:
1463 case BinaryAnnotationsOpCode::ChangeCodeOffset:
1464 case BinaryAnnotationsOpCode::ChangeCodeOffsetBase:
1465 code_offset += annot.U1;
1466 update_code_offset(annot.U1);
1468 case BinaryAnnotationsOpCode::ChangeLineOffset:
1469 update_line_offset(annot.S1);
1471 case BinaryAnnotationsOpCode::ChangeCodeLength:
1472 update_code_offset(annot.U1);
1473 code_offset += annot.U1;
1474 is_terminal_entry =
true;
1476 case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset:
1477 code_offset += annot.U1;
1478 update_code_offset(annot.U1);
1479 update_line_offset(annot.S1);
1481 case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset:
1482 code_offset += annot.U2;
1483 update_code_offset(annot.U2);
1484 update_code_offset(annot.U1);
1485 code_offset += annot.U1;
1486 is_terminal_entry =
true;
1488 case BinaryAnnotationsOpCode::ChangeFile:
1489 update_file_offset(annot.U1);
1496 if (code_offset_base && code_offset_end && cur_line_offset) {
1498 *code_offset_base, *code_offset_end - *code_offset_base,
1499 decl_line + *cur_line_offset));
1501 if (next_file_offset)
1502 file_offset = *next_file_offset;
1503 if (next_line_offset) {
1504 cur_line_offset = next_line_offset;
1505 next_line_offset = std::nullopt;
1507 code_offset_base = is_terminal_entry ? std::nullopt : code_offset_end;
1508 code_offset_end = next_file_offset = std::nullopt;
1510 if (code_offset_base && cur_line_offset) {
1511 if (is_terminal_entry) {
1513 func_base + *code_offset_base, decl_line + *cur_line_offset, 0,
1514 file_offset,
false,
false,
false,
false,
true);
1515 inline_site_sp->line_entries.push_back(line_entry);
1518 decl_line + *cur_line_offset, 0,
1519 file_offset, is_start_of_statement,
false,
1520 is_prologue_end,
false,
false);
1521 inline_site_sp->line_entries.push_back(line_entry);
1522 is_prologue_end =
false;
1523 is_start_of_statement =
false;
1526 if (is_terminal_entry)
1527 is_start_of_statement =
true;
1528 is_terminal_entry =
false;
1531 inline_site_sp->ranges.Sort();
1534 std::unique_ptr<Declaration> callsite_up;
1535 if (!inline_site_sp->ranges.IsEmpty()) {
1536 auto *entry = inline_site_sp->ranges.GetEntryAtIndex(0);
1537 addr_t base_offset = entry->GetRangeBase();
1543 std::shared_ptr<InlineSite> parent_site =
1546 parent_site->inline_function_info->GetDeclaration().GetFile();
1547 if (
auto *parent_entry =
1548 parent_site->ranges.FindEntryThatContains(base_offset)) {
1550 std::make_unique<Declaration>(parent_decl_file, parent_entry->data);
1555 func_base + base_offset)) {
1557 files.GetFileSpecAtIndex(entry->data.first);
1559 std::make_unique<Declaration>(callsite_file, entry->data.second);
1565 CVType inlinee_cvt =
m_index->ipi().getType(inline_site.Inlinee);
1566 std::string inlinee_name;
1567 if (inlinee_cvt.kind() == LF_MFUNC_ID) {
1568 MemberFuncIdRecord mfr;
1570 TypeDeserializer::deserializeAs<MemberFuncIdRecord>(inlinee_cvt, mfr));
1571 LazyRandomTypeCollection &types =
m_index->tpi().typeCollection();
1572 inlinee_name.append(std::string(types.getTypeName(mfr.ClassType)));
1573 inlinee_name.append(
"::");
1574 inlinee_name.append(mfr.getName().str());
1575 }
else if (inlinee_cvt.kind() == LF_FUNC_ID) {
1577 cantFail(TypeDeserializer::deserializeAs<FuncIdRecord>(inlinee_cvt, fir));
1578 TypeIndex parent_idx = fir.getParentScope();
1579 if (!parent_idx.isNoneType()) {
1580 LazyRandomTypeCollection &ids =
m_index->ipi().typeCollection();
1581 inlinee_name.append(std::string(ids.getTypeName(parent_idx)));
1582 inlinee_name.append(
"::");
1584 inlinee_name.append(fir.getName().str());
1586 inline_site_sp->inline_function_info = std::make_shared<InlineFunctionInfo>(
1587 inlinee_name.c_str(), llvm::StringRef(), decl_up.get(),
1598 std::set<uint64_t> remove_uids;
1600 if (kind == S_GPROC32 || kind == S_LPROC32 || kind == S_BLOCK32 ||
1601 kind == S_INLINESITE) {
1603 if (kind == S_INLINESITE)
1610 for (uint64_t uid : remove_uids) {
1620 CVSymbolArray syms =
1624 for (
auto iter = syms.begin(); iter != syms.end(); ++iter) {
1626 if (fn(iter->kind(), child_id))
1637 auto ts = *ts_or_err;
1641 clang->GetNativePDBParser()->Dump(s);
1648 using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>;
1650 std::vector<SymbolAndOffset> results =
m_index->globals().findRecordsByName(
1652 for (
const SymbolAndOffset &result : results) {
1653 switch (result.second.kind()) {
1654 case SymbolKind::S_GDATA32:
1655 case SymbolKind::S_LDATA32:
1656 case SymbolKind::S_GTHREAD32:
1657 case SymbolKind::S_LTHREAD32:
1658 case SymbolKind::S_CONSTANT: {
1677 if (name_type_mask & eFunctionNameTypeFull)
1681 if (!(name_type_mask & eFunctionNameTypeFull ||
1682 name_type_mask & eFunctionNameTypeMethod))
1685 using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>;
1687 std::vector<SymbolAndOffset> matches =
m_index->globals().findRecordsByName(
1689 for (
const SymbolAndOffset &match : matches) {
1690 if (match.second.kind() != S_PROCREF && match.second.kind() != S_LPROCREF)
1692 ProcRefSym proc(match.second.kind());
1693 cantFail(SymbolDeserializer::deserializeAs<ProcRefSym>(match.second, proc));
1699 m_index->compilands().GetOrCreateCompiland(proc.modi());
1711 bool include_inlines,
1716 uint32_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files,
1722 searched_symbol_files.clear();
1723 searched_symbol_files.insert(
this);
1730 llvm::ArrayRef<CompilerContext> pattern,
LanguageSet languages,
1731 llvm::DenseSet<SymbolFile *> &searched_symbol_files,
TypeMap &types) {}
1737 std::vector<TypeIndex> matches =
m_index->tpi().findRecordsByName(name);
1738 if (max_matches > 0 && max_matches < matches.size())
1739 matches.resize(max_matches);
1741 for (TypeIndex ti : matches) {
1757 LazyRandomTypeCollection &types =
m_index->tpi().typeCollection();
1760 for (
auto ti = types.getFirst(); ti; ti = types.getNext(*ti)) {
1763 (void)type->GetFullCompilerType();
1769 CVSymbol sym =
m_index->ReadSymbolRecord(global);
1770 if (sym.kind() != S_UDT)
1773 UDTSym udt = llvm::cantFail(SymbolDeserializer::deserializeAs<UDTSym>(sym));
1774 bool is_typedef =
true;
1776 CVType cvt =
m_index->tpi().getType(udt.Type);
1778 if (name == udt.Name)
1790 return new_count - old_count;
1807 Block *func_block = █
1829 std::string name = var_info.
name.str();
1831 SymbolFileTypeSP sftype =
1832 std::make_shared<SymbolFileType>(*
this, type_sp->GetID());
1837 bool external =
false;
1838 bool artificial =
false;
1839 bool location_is_constant_data =
false;
1840 bool static_member =
false;
1842 VariableSP var_sp = std::make_shared<Variable>(
1843 toOpaqueUid(var_id), name.c_str(), name.c_str(), sftype, var_scope,
1844 &block, scope_ranges, &decl, var_info.
location, external, artificial,
1845 location_is_constant_data, static_member);
1848 if (
auto err = ts_or_err.takeError())
1850 auto ts = *ts_or_err;
1854 ts->GetNativePDBParser()->GetOrCreateVariableDecl(scope_id, var_id);
1864 return iter->second;
1870 CVSymbol sym =
m_index->ReadSymbolRecord(
id);
1873 UDTSym udt = llvm::cantFail(SymbolDeserializer::deserializeAs<UDTSym>(sym));
1878 if (
auto err = ts_or_err.takeError())
1880 auto ts = *ts_or_err;
1884 ts->GetNativePDBParser()->GetOrCreateTypedefDecl(
id);
1890 decl, target_type->GetForwardCompilerType(),
1897 return iter->second;
1910 switch (sym.kind()) {
1913 ProcSym proc(
static_cast<SymbolRecordKind
>(sym.kind()));
1914 cantFail(SymbolDeserializer::deserializeAs<ProcSym>(sym, proc));
1915 CVType signature =
m_index->tpi().getType(proc.FunctionType);
1916 if (signature.kind() == LF_PROCEDURE) {
1917 ProcedureRecord sig;
1918 if (llvm::Error e = TypeDeserializer::deserializeAs<ProcedureRecord>(
1920 llvm::consumeError(std::move(e));
1923 params_remaining = sig.getParameterCount();
1924 }
else if (signature.kind() == LF_MFUNCTION) {
1925 MemberFunctionRecord sig;
1926 if (llvm::Error e = TypeDeserializer::deserializeAs<MemberFunctionRecord>(
1928 llvm::consumeError(std::move(e));
1931 params_remaining = sig.getParameterCount();
1941 lldbassert(
false &&
"Symbol is not a block!");
1947 variables = std::make_shared<VariableList>();
1951 CVSymbolArray syms = limitSymbolArrayToScope(
1957 auto iter = syms.begin();
1958 auto end = syms.end();
1960 while (iter != end) {
1961 uint32_t record_offset = iter.offset();
1962 CVSymbol variable_cvs = *iter;
1968 if (variable_cvs.kind() == S_BLOCK32 ||
1969 variable_cvs.kind() == S_INLINESITE) {
1970 uint32_t block_end = getScopeEndOffset(variable_cvs);
1972 iter = syms.at(block_end);
1976 bool is_param = params_remaining > 0;
1977 VariableSP variable;
1978 switch (variable_cvs.kind()) {
1986 variables->AddVariableIfUnique(variable);
2004 VariableListSP variables;
2022 variables = std::make_shared<VariableList>();
2028 llvm_unreachable(
"Unreachable!");
2033 if (
auto err = ts_or_err.takeError())
2035 auto ts = *ts_or_err;
2039 if (
auto decl = ts->GetNativePDBParser()->GetOrCreateDeclForUid(uid))
2047 if (
auto err = ts_or_err.takeError())
2049 auto ts = *ts_or_err;
2054 clang::DeclContext *context =
2065 if (
auto err = ts_or_err.takeError())
2067 auto ts = *ts_or_err;
2080 auto iter =
m_types.find(type_uid);
2087 return &*iter->second;
2092 if (type_id.
index.isNoneType())
2101std::optional<SymbolFile::ArrayInfo>
2104 return std::nullopt;
2111 if (!clang_type_system)
2115 static_cast<PdbAstBuilder *
>(clang_type_system->GetNativePDBParser());
2119 clang::QualType qt =
2126 TypeClass type_mask,
2135llvm::Expected<lldb::TypeSystemSP>
2137 auto type_system_or_err =
2138 m_objfile_sp->GetModule()->GetTypeSystemForLanguage(language);
2139 if (type_system_or_err)
2140 if (
auto ts = *type_system_or_err)
2141 ts->SetSymbolFile(
this);
2142 return type_system_or_err;
2147 return m_index->pdb().getFileSize();
2151 LazyRandomTypeCollection &types =
m_index->tpi().typeCollection();
2153 llvm::DenseMap<TypeIndex, TypeIndex> forward_to_full;
2154 llvm::DenseMap<TypeIndex, TypeIndex> full_to_forward;
2156 struct RecordIndices {
2161 llvm::StringMap<RecordIndices> record_indices;
2163 for (
auto ti = types.getFirst(); ti; ti = types.getNext(*ti)) {
2164 CVType type = types.getType(*ti);
2170 RecordIndices &indices = record_indices[tag.
asTag().getUniqueName()];
2171 if (tag.
asTag().isForwardRef())
2172 indices.forward = *ti;
2176 if (indices.full != TypeIndex::None() &&
2177 indices.forward != TypeIndex::None()) {
2178 forward_to_full[indices.forward] = indices.full;
2179 full_to_forward[indices.full] = indices.forward;
2185 if (tag.
asTag().isForwardRef() || !tag.
asTag().containsNestedClass())
2189 ProcessTpiStream(
PdbIndex &index, TypeIndex parent,
2191 llvm::DenseMap<TypeIndex, TypeIndex> &parents)
2192 : index(index), parents(parents), parent(parent),
2193 parent_cvt(parent_cvt) {}
2196 llvm::DenseMap<TypeIndex, TypeIndex> &parents;
2198 unsigned unnamed_type_index = 1;
2202 llvm::Error visitKnownMember(CVMemberRecord &CVR,
2203 NestedTypeRecord &Record)
override {
2204 std::string unnamed_type_name;
2205 if (Record.Name.empty()) {
2207 llvm::formatv(
"<unnamed-type-$S{0}>", unnamed_type_index).str();
2208 Record.Name = unnamed_type_name;
2209 ++unnamed_type_index;
2211 std::optional<CVTagRecord> tag =
2214 return llvm::ErrorSuccess();
2216 parents[Record.Type] = parent;
2217 return llvm::ErrorSuccess();
2221 CVType field_list_cvt =
m_index->tpi().getType(tag.
asTag().FieldList);
2223 FieldListRecord field_list;
2224 if (llvm::Error
error = TypeDeserializer::deserializeAs<FieldListRecord>(
2225 field_list_cvt, field_list))
2226 llvm::consumeError(std::move(
error));
2227 if (llvm::Error
error = visitMemberRecordStream(field_list.Data, process))
2228 llvm::consumeError(std::move(
error));
2236 std::vector<TypeIndex> full_keys;
2237 std::vector<TypeIndex> fwd_keys;
2239 TypeIndex key = entry.first;
2240 TypeIndex value = entry.second;
2242 auto iter = forward_to_full.find(value);
2243 if (iter != forward_to_full.end())
2244 entry.second = iter->second;
2246 iter = forward_to_full.find(key);
2247 if (iter != forward_to_full.end())
2248 fwd_keys.push_back(key);
2250 full_keys.push_back(key);
2252 for (TypeIndex fwd : fwd_keys) {
2253 TypeIndex full = forward_to_full[fwd];
2256 for (TypeIndex full : full_keys) {
2257 TypeIndex fwd = full_to_forward[full];
2262std::optional<PdbCompilandSymId>
2264 CVSymbol sym =
m_index->ReadSymbolRecord(
id);
2265 if (symbolOpensScope(sym.kind())) {
2268 id.offset = getScopeParentOffset(sym);
2272 return std::nullopt;
2281 auto begin = syms.begin();
2282 auto end = syms.at(
id.offset);
2283 std::vector<PdbCompilandSymId> scope_stack;
2285 while (begin != end) {
2286 if (begin.offset() >
id.offset) {
2288 lldbassert(
false &&
"Invalid compiland symbol id!");
2289 return std::nullopt;
2294 if (symbolOpensScope(begin->kind())) {
2297 uint32_t scope_end = getScopeEndOffset(*begin);
2298 if (scope_end <
id.offset) {
2299 begin = syms.at(scope_end);
2302 scope_stack.emplace_back(
id.modi, begin.offset());
2304 }
else if (symbolEndsScope(begin->kind())) {
2305 scope_stack.pop_back();
2309 if (scope_stack.empty())
2310 return std::nullopt;
2312 return scope_stack.back();
2315std::optional<llvm::codeview::TypeIndex>
2319 return std::nullopt;
2320 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.
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
CompilerDeclContext FindNamespace(ConstString name, const CompilerDeclContext &parent_decl_ctx) 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 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.
@ eLanguageTypeSwift
Swift.
@ eLanguageTypeC
Non-standardized C, such as K&R.
@ 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)
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