27#include "llvm/DebugInfo/CodeView/CVRecord.h"
28#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
29#include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h"
30#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
31#include "llvm/DebugInfo/CodeView/RecordName.h"
32#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
33#include "llvm/DebugInfo/CodeView/SymbolRecordHelpers.h"
34#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
35#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
36#include "llvm/DebugInfo/PDB/Native/GlobalsStream.h"
37#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
38#include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h"
39#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
40#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
41#include "llvm/DebugInfo/PDB/Native/SymbolStream.h"
42#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
43#include "llvm/DebugInfo/PDB/PDB.h"
44#include "llvm/DebugInfo/PDB/PDBTypes.h"
45#include "llvm/Demangle/MicrosoftDemangle.h"
46#include "llvm/Object/COFF.h"
47#include "llvm/Support/Allocator.h"
48#include "llvm/Support/BinaryStreamReader.h"
49#include "llvm/Support/Error.h"
50#include "llvm/Support/ErrorOr.h"
51#include "llvm/Support/MemoryBuffer.h"
80 case PDB_Lang::ObjCpp:
87static std::unique_ptr<PDBFile>
90 using namespace llvm::object;
91 auto expected_binary = createBinary(exe_path);
94 if (!expected_binary) {
95 llvm::consumeError(expected_binary.takeError());
98 OwningBinary<Binary> binary = std::move(*expected_binary);
102 auto *obj = llvm::dyn_cast<llvm::object::COFFObjectFile>(binary.getBinary());
105 const llvm::codeview::DebugInfo *pdb_info =
nullptr;
108 llvm::StringRef pdb_file;
109 if (llvm::Error e = obj->getDebugPDBInfo(pdb_info, pdb_file)) {
110 consumeError(std::move(e));
120 pdb_file = exe_dir.CopyByAppendingPathComponent(pdb_name).GetPathAsConstString().GetStringRef();
128 auto expected_info = pdb->getPDBInfoStream();
129 if (!expected_info) {
130 llvm::consumeError(expected_info.takeError());
133 llvm::codeview::GUID guid;
134 memcpy(&guid, pdb_info->PDB70.Signature, 16);
136 if (expected_info->getGuid() != guid)
155 case SimpleTypeKind::Boolean128:
156 case SimpleTypeKind::Boolean16:
157 case SimpleTypeKind::Boolean32:
158 case SimpleTypeKind::Boolean64:
159 case SimpleTypeKind::Boolean8:
161 case SimpleTypeKind::Byte:
162 case SimpleTypeKind::UnsignedCharacter:
163 return "unsigned char";
164 case SimpleTypeKind::NarrowCharacter:
166 case SimpleTypeKind::SignedCharacter:
167 case SimpleTypeKind::SByte:
168 return "signed char";
169 case SimpleTypeKind::Character16:
171 case SimpleTypeKind::Character32:
173 case SimpleTypeKind::Character8:
175 case SimpleTypeKind::Complex80:
176 case SimpleTypeKind::Complex64:
177 case SimpleTypeKind::Complex32:
179 case SimpleTypeKind::Float128:
180 case SimpleTypeKind::Float80:
181 return "long double";
182 case SimpleTypeKind::Float64:
184 case SimpleTypeKind::Float32:
186 case SimpleTypeKind::Float16:
188 case SimpleTypeKind::Int128:
190 case SimpleTypeKind::Int64:
191 case SimpleTypeKind::Int64Quad:
193 case SimpleTypeKind::Int32:
195 case SimpleTypeKind::Int16:
197 case SimpleTypeKind::UInt128:
198 return "unsigned __int128";
199 case SimpleTypeKind::UInt64:
200 case SimpleTypeKind::UInt64Quad:
202 case SimpleTypeKind::HResult:
204 case SimpleTypeKind::UInt32:
206 case SimpleTypeKind::UInt16:
207 case SimpleTypeKind::UInt16Short:
208 return "unsigned short";
209 case SimpleTypeKind::Int32Long:
211 case SimpleTypeKind::UInt32Long:
212 return "unsigned long";
213 case SimpleTypeKind::Void:
215 case SimpleTypeKind::WideCharacter:
233static std::optional<CVTagRecord>
252 if (Record.Type.isSimple())
255 CVType cvt = tpi.getType(Record.Type);
264 std::string qname = std::string(parent.
asTag().getUniqueName());
265 if (qname.size() < 4 || child.
asTag().getUniqueName().size() < 4)
271 qname[3] = child.
asTag().getUniqueName()[3];
275 piece += Record.Name;
276 piece.push_back(
'@');
277 qname.insert(4, std::move(piece));
278 if (qname != child.
asTag().UniqueName)
281 return std::move(child);
297 return "Microsoft PDB debug symbol cross-platform file reader.";
310 uint32_t abilities = 0;
317 if (
auto *pdb = llvm::dyn_cast<ObjectFilePDB>(
m_objfile_sp.get())) {
318 pdb_file = &pdb->GetPDBFile();
329 if (!expected_index) {
330 llvm::consumeError(expected_index.takeError());
333 m_index = std::move(*expected_index);
342 if (
m_index->dbi().isStripped())
353 m_index->ParseSectionContribs();
355 auto ts_or_err =
m_objfile_sp->GetModule()->GetTypeSystemForLanguage(
357 if (
auto err = ts_or_err.takeError()) {
359 "Failed to initialize: {0}");
361 if (
auto ts = *ts_or_err)
362 ts->SetSymbolFile(
this);
368 const DbiModuleList &modules =
m_index->dbi().modules();
369 uint32_t count = modules.getModuleCount();
376 DbiModuleDescriptor last = modules.getModuleDescriptor(count - 1);
377 if (last.getModuleName() ==
"* Linker *")
388 if (
auto err = ts_or_err.takeError())
390 auto ts = *ts_or_err;
395 switch (sym.kind()) {
401 return &func->GetBlock(
false);
408 BlockSym block(
static_cast<SymbolRecordKind
>(sym.kind()));
409 cantFail(SymbolDeserializer::deserializeAs<BlockSym>(sym, block));
418 m_index->MakeVirtualAddress(block.Segment, block.CodeOffset);
422 if (block_base >= func_base)
423 child_block->AddRange(
Block::Range(block_base - func_base, block.CodeSize));
426 "S_BLOCK32 at modi: {0:d} offset: {1:d}: adding range "
427 "[{2:x16}-{3:x16}) which has a base that is less than the "
429 "low PC 0x%" PRIx64
". Please file a bug and attach the file at the "
430 "start of this error message",
432 block_base + block.CodeSize, func_base);
435 m_blocks.insert({opaque_block_uid, child_block});
440 comp_unit->GetLineTable();
442 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())
502 FunctionSP func_sp = std::make_shared<Function>(
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));
534 CompUnitSP cu_sp = std::make_shared<CompileUnit>(
535 m_objfile_sp->GetModule(),
nullptr, std::make_shared<SupportFile>(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) {
592 uint32_t pointer_size = 0;
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 std::string_view 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;
848 uint16_t section = 0;
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!");
887 std::optional<uint16_t> modi =
m_index->GetModuleIndexForVa(addr);
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;
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.get();
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;
1081 uint32_t resolved_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) {
1132 addr_t offset = file_addr - func_base;
1137 resolved_flags |= eSymbolContextFunction;
1139 resolved_flags |= eSymbolContextBlock;
1144 if (resolve_scope & eSymbolContextLineEntry) {
1147 if (line_table->FindLineEntryByAddress(addr, sc.
line_entry))
1148 resolved_flags |= eSymbolContextLineEntry;
1152 return resolved_flags;
1159 const uint32_t prev_size = sc_list.
GetSize();
1160 if (resolve_scope & eSymbolContextCompUnit) {
1169 if (file_spec_matches_cu_file_spec) {
1175 return sc_list.
GetSize() - prev_size;
1194 std::set<LineTable::Entry, LineTableEntryComparator> line_set;
1199 for (
const DebugSubsectionRecord &dssr :
1201 if (dssr.kind() != DebugSubsectionKind::Lines)
1204 DebugLinesSubsectionRef lines;
1205 llvm::BinaryStreamReader reader(dssr.getRecordData());
1206 if (
auto EC = lines.initialize(reader)) {
1207 llvm::consumeError(std::move(EC));
1211 const LineFragmentHeader *lfh = lines.header();
1212 uint64_t virtual_addr =
1213 m_index->MakeVirtualAddress(lfh->RelocSegment, lfh->RelocOffset);
1217 for (
const LineColumnEntry &group : lines) {
1218 llvm::Expected<uint32_t> file_index_or_err =
1220 if (!file_index_or_err)
1222 uint32_t file_index = file_index_or_err.get();
1226 for (
const LineNumberEntry &entry : group.LineNumbers) {
1227 LineInfo cur_info(entry.Flags);
1229 if (cur_info.isAlwaysStepInto() || cur_info.isNeverStepInto())
1232 uint64_t addr = virtual_addr + entry.Offset;
1234 bool is_statement = cur_info.isStatement();
1238 uint32_t lno = cur_info.getStartLine();
1241 is_prologue, is_epilogue,
false);
1243 auto iter = line_set.find(new_entry);
1244 if (iter != line_set.end() && iter->is_terminal_entry)
1245 line_set.erase(iter);
1246 line_set.insert(new_entry);
1253 line_entry.
data = {file_index, lno};
1255 LineInfo last_line(group.LineNumbers.back().Flags);
1256 line_set.emplace(virtual_addr + lfh->CodeSize, last_line.getEndLine(), 0,
1257 file_index,
false,
false,
false,
false,
true);
1260 line_entry.
SetRangeEnd(virtual_addr + lfh->CodeSize);
1269 const CVSymbolArray &syms = cii->
m_debug_stream.getSymbolArray();
1270 for (
auto iter = syms.begin(); iter != syms.end();) {
1271 if (iter->kind() != S_LPROC32 && iter->kind() != S_GPROC32) {
1276 uint32_t record_offset = iter.offset();
1277 CVSymbol func_record =
1286 comp_unit.
GetModule()->GetSectionList());
1292 if (kind != S_INLINESITE)
1297 for (
const auto &line_entry :
1302 if (!line_entry.is_terminal_entry)
1303 line_set.erase(line_entry);
1304 line_set.insert(line_entry);
1312 iter = syms.at(getScopeEndOffset(func_record));
1318 auto line_table = std::make_unique<LineTable>(&comp_unit);
1319 std::unique_ptr<LineSequence> sequence(
1320 line_table->CreateLineSequenceContainer());
1321 for (
const auto &line_entry : line_set) {
1322 line_table->AppendLineEntryToSequence(
1323 sequence.get(), line_entry.file_addr, line_entry.line,
1324 line_entry.column, line_entry.file_idx,
1325 line_entry.is_start_of_statement, line_entry.is_start_of_basic_block,
1326 line_entry.is_prologue_end, line_entry.is_epilogue_begin,
1327 line_entry.is_terminal_entry);
1329 line_table->InsertSequence(sequence.get());
1331 if (line_table->GetSize() == 0)
1343llvm::Expected<uint32_t>
1347 return llvm::make_error<RawError>(raw_error_code::no_entry);
1349 const auto &checksums = cii.
m_strings.checksums().getArray();
1350 const auto &strings = cii.
m_strings.strings();
1354 auto iter = checksums.at(file_id);
1355 if (iter == checksums.end())
1356 return llvm::make_error<RawError>(raw_error_code::no_entry);
1358 llvm::Expected<llvm::StringRef> efn = strings.getString(iter->FileNameOffset);
1360 return efn.takeError();
1366 return std::distance(cii.
m_file_list.begin(), fn_iter);
1367 return llvm::make_error<RawError>(raw_error_code::no_entry);
1381 f.starts_with(
"/") ? FileSpec::Style::posix : FileSpec::Style::windows;
1383 support_files.
Append(spec);
1389 const SymbolContext &sc, std::vector<SourceModule> &imported_modules) {
1402 CVSymbol sym = cii->
m_debug_stream.readSymbolAtOffset(
id.offset);
1405 InlineSiteSym inline_site(
static_cast<SymbolRecordKind
>(sym.kind()));
1406 cantFail(SymbolDeserializer::deserializeAs<InlineSiteSym>(sym, inline_site));
1409 std::shared_ptr<InlineSite> inline_site_sp =
1410 std::make_shared<InlineSite>(parent_id);
1413 auto iter = cii->
m_inline_map.find(inline_site.Inlinee);
1416 InlineeSourceLine inlinee_line = iter->second;
1420 llvm::Expected<uint32_t> file_index_or_err =
1422 if (!file_index_or_err)
1424 uint32_t file_offset = file_index_or_err.get();
1426 uint32_t decl_line = inlinee_line.Header->SourceLineNum;
1427 std::unique_ptr<Declaration> decl_up =
1428 std::make_unique<Declaration>(decl_file, decl_line);
1431 uint32_t code_offset = 0;
1432 int32_t line_offset = 0;
1433 std::optional<uint32_t> code_offset_base;
1434 std::optional<uint32_t> code_offset_end;
1435 std::optional<int32_t> cur_line_offset;
1436 std::optional<int32_t> next_line_offset;
1437 std::optional<uint32_t> next_file_offset;
1439 bool is_terminal_entry =
false;
1440 bool is_start_of_statement =
true;
1442 bool is_prologue_end =
true;
1444 auto update_code_offset = [&](uint32_t code_delta) {
1445 if (!code_offset_base)
1446 code_offset_base = code_offset;
1447 else if (!code_offset_end)
1448 code_offset_end = *code_offset_base + code_delta;
1450 auto update_line_offset = [&](int32_t line_delta) {
1451 line_offset += line_delta;
1452 if (!code_offset_base || !cur_line_offset)
1453 cur_line_offset = line_offset;
1455 next_line_offset = line_offset;
1458 auto update_file_offset = [&](uint32_t offset) {
1459 if (!code_offset_base)
1460 file_offset = offset;
1462 next_file_offset = offset;
1465 for (
auto &annot : inline_site.annotations()) {
1466 switch (annot.OpCode) {
1467 case BinaryAnnotationsOpCode::CodeOffset:
1468 case BinaryAnnotationsOpCode::ChangeCodeOffset:
1469 case BinaryAnnotationsOpCode::ChangeCodeOffsetBase:
1470 code_offset += annot.U1;
1471 update_code_offset(annot.U1);
1473 case BinaryAnnotationsOpCode::ChangeLineOffset:
1474 update_line_offset(annot.S1);
1476 case BinaryAnnotationsOpCode::ChangeCodeLength:
1477 update_code_offset(annot.U1);
1478 code_offset += annot.U1;
1479 is_terminal_entry =
true;
1481 case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset:
1482 code_offset += annot.U1;
1483 update_code_offset(annot.U1);
1484 update_line_offset(annot.S1);
1486 case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset:
1487 code_offset += annot.U2;
1488 update_code_offset(annot.U2);
1489 update_code_offset(annot.U1);
1490 code_offset += annot.U1;
1491 is_terminal_entry =
true;
1493 case BinaryAnnotationsOpCode::ChangeFile:
1494 update_file_offset(annot.U1);
1501 if (code_offset_base && code_offset_end && cur_line_offset) {
1503 *code_offset_base, *code_offset_end - *code_offset_base,
1504 decl_line + *cur_line_offset));
1506 if (next_file_offset)
1507 file_offset = *next_file_offset;
1508 if (next_line_offset) {
1509 cur_line_offset = next_line_offset;
1510 next_line_offset = std::nullopt;
1512 code_offset_base = is_terminal_entry ? std::nullopt : code_offset_end;
1513 code_offset_end = next_file_offset = std::nullopt;
1515 if (code_offset_base && cur_line_offset) {
1516 if (is_terminal_entry) {
1518 func_base + *code_offset_base, decl_line + *cur_line_offset, 0,
1519 file_offset,
false,
false,
false,
false,
true);
1520 inline_site_sp->line_entries.push_back(line_entry);
1523 decl_line + *cur_line_offset, 0,
1524 file_offset, is_start_of_statement,
false,
1525 is_prologue_end,
false,
false);
1526 inline_site_sp->line_entries.push_back(line_entry);
1527 is_prologue_end =
false;
1528 is_start_of_statement =
false;
1531 if (is_terminal_entry)
1532 is_start_of_statement =
true;
1533 is_terminal_entry =
false;
1536 inline_site_sp->ranges.Sort();
1539 std::unique_ptr<Declaration> callsite_up;
1540 if (!inline_site_sp->ranges.IsEmpty()) {
1541 auto *entry = inline_site_sp->ranges.GetEntryAtIndex(0);
1542 addr_t base_offset = entry->GetRangeBase();
1548 std::shared_ptr<InlineSite> parent_site =
1551 parent_site->inline_function_info->GetDeclaration().GetFile();
1552 if (
auto *parent_entry =
1553 parent_site->ranges.FindEntryThatContains(base_offset)) {
1555 std::make_unique<Declaration>(parent_decl_file, parent_entry->data);
1560 func_base + base_offset)) {
1564 std::make_unique<Declaration>(callsite_file, entry->data.second);
1570 CVType inlinee_cvt =
m_index->ipi().getType(inline_site.Inlinee);
1571 std::string inlinee_name;
1572 if (inlinee_cvt.kind() == LF_MFUNC_ID) {
1573 MemberFuncIdRecord mfr;
1575 TypeDeserializer::deserializeAs<MemberFuncIdRecord>(inlinee_cvt, mfr));
1576 LazyRandomTypeCollection &types =
m_index->tpi().typeCollection();
1577 inlinee_name.append(std::string(types.getTypeName(mfr.ClassType)));
1578 inlinee_name.append(
"::");
1579 inlinee_name.append(mfr.getName().str());
1580 }
else if (inlinee_cvt.kind() == LF_FUNC_ID) {
1582 cantFail(TypeDeserializer::deserializeAs<FuncIdRecord>(inlinee_cvt, fir));
1583 TypeIndex parent_idx = fir.getParentScope();
1584 if (!parent_idx.isNoneType()) {
1585 LazyRandomTypeCollection &ids =
m_index->ipi().typeCollection();
1586 inlinee_name.append(std::string(ids.getTypeName(parent_idx)));
1587 inlinee_name.append(
"::");
1589 inlinee_name.append(fir.getName().str());
1591 inline_site_sp->inline_function_info = std::make_shared<InlineFunctionInfo>(
1592 inlinee_name.c_str(), llvm::StringRef(), decl_up.get(),
1603 std::set<uint64_t> remove_uids;
1605 if (kind == S_GPROC32 || kind == S_LPROC32 || kind == S_BLOCK32 ||
1606 kind == S_INLINESITE) {
1608 if (kind == S_INLINESITE)
1615 for (uint64_t uid : remove_uids) {
1625 CVSymbolArray syms =
1629 for (
auto iter = syms.begin(); iter != syms.end(); ++iter) {
1631 if (fn(iter->kind(), child_id))
1642 auto ts = *ts_or_err;
1646 clang->GetNativePDBParser()->Dump(s);
1653 using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>;
1655 std::vector<SymbolAndOffset> results =
m_index->globals().findRecordsByName(
1657 for (
const SymbolAndOffset &result : results) {
1658 switch (result.second.kind()) {
1659 case SymbolKind::S_GDATA32:
1660 case SymbolKind::S_LDATA32:
1661 case SymbolKind::S_GTHREAD32:
1662 case SymbolKind::S_LTHREAD32:
1663 case SymbolKind::S_CONSTANT: {
1682 if (name_type_mask & eFunctionNameTypeFull)
1686 if (!(name_type_mask & eFunctionNameTypeFull ||
1687 name_type_mask & eFunctionNameTypeMethod))
1690 using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>;
1692 std::vector<SymbolAndOffset> matches =
m_index->globals().findRecordsByName(
1694 for (
const SymbolAndOffset &match : matches) {
1695 if (match.second.kind() != S_PROCREF && match.second.kind() != S_LPROCREF)
1697 ProcRefSym proc(match.second.kind());
1698 cantFail(SymbolDeserializer::deserializeAs<ProcRefSym>(match.second, proc));
1704 m_index->compilands().GetOrCreateCompiland(proc.modi());
1716 bool include_inlines,
1728 std::vector<TypeIndex> matches =
1731 for (TypeIndex type_idx : matches) {
1741 if (results.
Done(query))
1748 uint32_t max_matches,
1751 std::vector<TypeIndex> matches =
m_index->tpi().findRecordsByName(name);
1752 if (max_matches > 0 && max_matches < matches.size())
1753 matches.resize(max_matches);
1755 for (TypeIndex ti : matches) {
1771 LazyRandomTypeCollection &types =
m_index->tpi().typeCollection();
1774 for (
auto ti = types.getFirst(); ti; ti = types.getNext(*ti)) {
1777 (void)type->GetFullCompilerType();
1781 for (
const uint32_t gid :
m_index->globals().getGlobalsTable()) {
1783 CVSymbol sym =
m_index->ReadSymbolRecord(global);
1784 if (sym.kind() != S_UDT)
1787 UDTSym udt = llvm::cantFail(SymbolDeserializer::deserializeAs<UDTSym>(sym));
1788 bool is_typedef =
true;
1790 CVType cvt =
m_index->tpi().getType(udt.Type);
1792 if (name == udt.Name)
1804 return new_count - old_count;
1812 for (
const uint32_t gid :
m_index->globals().getGlobalsTable()) {
1814 CVSymbol sym =
m_index->ReadSymbolRecord(global);
1819 switch (sym.kind()) {
1820 case SymbolKind::S_GDATA32:
1821 case SymbolKind::S_LDATA32:
1822 case SymbolKind::S_GTHREAD32:
1823 case SymbolKind::S_LTHREAD32: {
1844 Block *func_block = block;
1867 std::string name = var_info.
name.str();
1870 std::make_shared<SymbolFileType>(*
this, type_sp->GetID());
1875 bool external =
false;
1876 bool artificial =
false;
1877 bool location_is_constant_data =
false;
1878 bool static_member =
false;
1880 VariableSP var_sp = std::make_shared<Variable>(
1881 toOpaqueUid(var_id), name.c_str(), name.c_str(), sftype, var_scope, block,
1882 scope_ranges, &decl, var_info.
location, external, artificial,
1883 location_is_constant_data, static_member);
1886 if (
auto err = ts_or_err.takeError())
1888 auto ts = *ts_or_err;
1892 ts->GetNativePDBParser()->GetOrCreateVariableDecl(scope_id, var_id);
1902 return iter->second;
1908 CVSymbol sym =
m_index->ReadSymbolRecord(
id);
1911 UDTSym udt = llvm::cantFail(SymbolDeserializer::deserializeAs<UDTSym>(sym));
1916 if (
auto err = ts_or_err.takeError())
1918 auto ts = *ts_or_err;
1922 ts->GetNativePDBParser()->GetOrCreateTypedefDecl(
id);
1928 decl, target_type->GetForwardCompilerType(),
1935 return iter->second;
1949 uint32_t params_remaining = 0;
1950 switch (sym.kind()) {
1953 ProcSym proc(
static_cast<SymbolRecordKind
>(sym.kind()));
1954 cantFail(SymbolDeserializer::deserializeAs<ProcSym>(sym, proc));
1955 CVType signature =
m_index->tpi().getType(proc.FunctionType);
1956 if (signature.kind() == LF_PROCEDURE) {
1957 ProcedureRecord sig;
1958 if (llvm::Error e = TypeDeserializer::deserializeAs<ProcedureRecord>(
1960 llvm::consumeError(std::move(e));
1963 params_remaining = sig.getParameterCount();
1964 }
else if (signature.kind() == LF_MFUNCTION) {
1965 MemberFunctionRecord sig;
1966 if (llvm::Error e = TypeDeserializer::deserializeAs<MemberFunctionRecord>(
1968 llvm::consumeError(std::move(e));
1971 params_remaining = sig.getParameterCount();
1981 lldbassert(
false &&
"Symbol is not a block!");
1987 variables = std::make_shared<VariableList>();
1991 CVSymbolArray syms = limitSymbolArrayToScope(
1997 auto iter = syms.begin();
1998 auto end = syms.end();
2000 while (iter != end) {
2001 uint32_t record_offset = iter.offset();
2002 CVSymbol variable_cvs = *iter;
2008 if (variable_cvs.kind() == S_BLOCK32 ||
2009 variable_cvs.kind() == S_INLINESITE) {
2010 uint32_t block_end = getScopeEndOffset(variable_cvs);
2012 iter = syms.at(block_end);
2016 bool is_param = params_remaining > 0;
2018 switch (variable_cvs.kind()) {
2026 variables->AddVariableIfUnique(variable);
2062 variables = std::make_shared<VariableList>();
2068 llvm_unreachable(
"Unreachable!");
2073 if (
auto err = ts_or_err.takeError())
2075 auto ts = *ts_or_err;
2079 if (
auto decl = ts->GetNativePDBParser()->GetOrCreateDeclForUid(uid))
2087 if (
auto err = ts_or_err.takeError())
2089 auto ts = *ts_or_err;
2094 clang::DeclContext *context =
2105 if (
auto err = ts_or_err.takeError())
2107 auto ts = *ts_or_err;
2120 auto iter =
m_types.find(type_uid);
2127 return &*iter->second;
2132 if (type_id.
index.isNoneType())
2141std::optional<SymbolFile::ArrayInfo>
2144 return std::nullopt;
2151 if (!clang_type_system)
2155 static_cast<PdbAstBuilder *
>(clang_type_system->GetNativePDBParser());
2159 clang::QualType qt =
2166 TypeClass type_mask,
2174llvm::Expected<lldb::TypeSystemSP>
2176 auto type_system_or_err =
2177 m_objfile_sp->GetModule()->GetTypeSystemForLanguage(language);
2178 if (type_system_or_err)
2179 if (
auto ts = *type_system_or_err)
2180 ts->SetSymbolFile(
this);
2181 return type_system_or_err;
2186 return m_index->pdb().getFileSize();
2190 LazyRandomTypeCollection &types =
m_index->tpi().typeCollection();
2192 llvm::DenseMap<TypeIndex, TypeIndex> forward_to_full;
2193 llvm::DenseMap<TypeIndex, TypeIndex> full_to_forward;
2195 struct RecordIndices {
2200 llvm::StringMap<RecordIndices> record_indices;
2202 for (
auto ti = types.getFirst(); ti; ti = types.getNext(*ti)) {
2203 CVType type = types.getType(*ti);
2209 RecordIndices &indices = record_indices[tag.
asTag().getUniqueName()];
2210 if (tag.
asTag().isForwardRef())
2211 indices.forward = *ti;
2215 if (indices.full != TypeIndex::None() &&
2216 indices.forward != TypeIndex::None()) {
2217 forward_to_full[indices.forward] = indices.full;
2218 full_to_forward[indices.full] = indices.forward;
2224 if (tag.
asTag().isForwardRef() || !tag.
asTag().containsNestedClass())
2228 ProcessTpiStream(
PdbIndex &index, TypeIndex parent,
2230 llvm::DenseMap<TypeIndex, TypeIndex> &parents)
2231 : index(index), parents(parents), parent(parent),
2232 parent_cvt(parent_cvt) {}
2235 llvm::DenseMap<TypeIndex, TypeIndex> &parents;
2237 unsigned unnamed_type_index = 1;
2241 llvm::Error visitKnownMember(CVMemberRecord &CVR,
2242 NestedTypeRecord &Record)
override {
2243 std::string unnamed_type_name;
2244 if (Record.Name.empty()) {
2246 llvm::formatv(
"<unnamed-type-$S{0}>", unnamed_type_index).str();
2247 Record.Name = unnamed_type_name;
2248 ++unnamed_type_index;
2250 std::optional<CVTagRecord> tag =
2253 return llvm::ErrorSuccess();
2255 parents[Record.Type] = parent;
2256 return llvm::ErrorSuccess();
2260 CVType field_list_cvt =
m_index->tpi().getType(tag.
asTag().FieldList);
2262 FieldListRecord field_list;
2263 if (llvm::Error
error = TypeDeserializer::deserializeAs<FieldListRecord>(
2264 field_list_cvt, field_list))
2265 llvm::consumeError(std::move(
error));
2266 if (llvm::Error
error = visitMemberRecordStream(field_list.Data, process))
2267 llvm::consumeError(std::move(
error));
2275 std::vector<TypeIndex> full_keys;
2276 std::vector<TypeIndex> fwd_keys;
2278 TypeIndex key = entry.first;
2279 TypeIndex value = entry.second;
2281 auto iter = forward_to_full.find(value);
2282 if (iter != forward_to_full.end())
2283 entry.second = iter->second;
2285 iter = forward_to_full.find(key);
2286 if (iter != forward_to_full.end())
2287 fwd_keys.push_back(key);
2289 full_keys.push_back(key);
2291 for (TypeIndex fwd : fwd_keys) {
2292 TypeIndex full = forward_to_full[fwd];
2296 for (TypeIndex full : full_keys) {
2297 TypeIndex fwd = full_to_forward[full];
2302std::optional<PdbCompilandSymId>
2304 CVSymbol sym =
m_index->ReadSymbolRecord(
id);
2305 if (symbolOpensScope(sym.kind())) {
2308 id.offset = getScopeParentOffset(sym);
2312 return std::nullopt;
2321 auto begin = syms.begin();
2322 auto end = syms.at(
id.offset);
2323 std::vector<PdbCompilandSymId> scope_stack;
2325 while (begin != end) {
2326 if (begin.offset() >
id.offset) {
2328 lldbassert(
false &&
"Invalid compiland symbol id!");
2329 return std::nullopt;
2334 if (symbolOpensScope(begin->kind())) {
2337 uint32_t scope_end = getScopeEndOffset(*begin);
2338 if (scope_end <
id.offset) {
2339 begin = syms.at(scope_end);
2342 scope_stack.emplace_back(
id.modi, begin.offset());
2344 }
else if (symbolEndsScope(begin->kind())) {
2345 scope_stack.pop_back();
2349 if (scope_stack.empty())
2350 return std::nullopt;
2352 return scope_stack.back();
2355std::optional<llvm::codeview::TypeIndex>
2359 return std::nullopt;
2360 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)
lldb::BlockSP CreateChild(lldb::user_id_t uid)
Creates a block with the specified UID uid.
Function * CalculateSymbolContextFunction() override
void SetVariableList(lldb::VariableListSP &variable_list_sp)
Set accessor for the variable list.
Block * GetParent() const
Get the parent block.
bool GetStartAddress(Address &addr)
void SetDidParseVariables(bool b, bool set_children)
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 spec associated with this compile unit.
void ResolveSymbolContext(const SourceLocationSpec &src_location_spec, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list, RealpathPrefixes *realpath_prefixes=nullptr)
Resolve symbol contexts by file and line.
void SetLineTable(LineTable *line_table)
Set the line table for the compile unit.
void AddFunction(lldb::FunctionSP &function_sp)
Add a function to this compile unit.
size_t GetNumFunctions() const
Returns the number of functions in this compile unit.
lldb::LanguageType GetLanguage()
LineTable * GetLineTable()
Get the line table for the compile unit.
Represents a generic declaration context in a program.
TypeSystem * GetTypeSystem() const
Represents a generic declaration such as a function declaration.
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()
DEPRECATED: Use GetAddressRanges instead.
Block & GetBlock(bool can_create)
Get accessor for the block list.
A class that handles mangled names.
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.
A list of support files for a CompileUnit.
const FileSpec & GetFileSpecAtIndex(size_t idx) const
void Append(const FileSpec &file)
Defines a list of symbol context objects.
uint32_t GetSize() const
Get accessor for a symbol context list size.
void Append(const SymbolContext &sc)
Append a new symbol context to the list.
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
Defines a symbol context baton that can be handed other debug core functions.
Function * function
The Function for a given query.
Block * block
The Block for a given query.
CompileUnit * comp_unit
The CompileUnit for a given query.
LineEntry line_entry
The LineEntry for a given query.
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 class that contains all state required for type lookups.
std::vector< lldb_private::CompilerContext > & GetContextRef()
Access the internal compiler context array.
ConstString GetTypeBasename() const
Get the type basename to use when searching the type indexes in each SymbolFile object.
bool ContextMatches(llvm::ArrayRef< lldb_private::CompilerContext > context) const
Check of a CompilerContext array from matching type from a symbol file matches the m_context.
This class tracks the state and results of a TypeQuery.
bool InsertUnique(const lldb::TypeSP &type_sp)
When types that match a TypeQuery are found, this API is used to insert the matching types.
bool Done(const TypeQuery &query) const
Check if the type matching has found all of the matches that it needs.
bool AlreadySearched(lldb_private::SymbolFile *sym_file)
Check if a SymbolFile object has already been searched by this type match object.
A TypeSystem implementation based on Clang.
Interface for representing a type system.
virtual npdb::PdbAstBuilder * GetNativePDBParser()
@ eEncodingIsTypedefUID
This type is alias to a type whose UID is m_encoding_uid.
@ eEncodingIsUID
This type is the type whose UID is m_encoding_uid.
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)
size_t ParseVariablesForContext(const SymbolContext &sc) override
size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override
lldb::TypeSP CreatePointerType(PdbTypeSymId type_id, const llvm::codeview::PointerRecord &pr, CompilerType ct)
lldb::FunctionSP CreateFunction(PdbCompilandSymId func_id, CompileUnit &comp_unit)
llvm::DenseMap< lldb::user_id_t, lldb::BlockSP > m_blocks
bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit, SupportFileList &support_files) override
CompilerDecl GetDeclForUID(lldb::user_id_t uid) override
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 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)
uint64_t GetDebugInfoSize(bool load_all_debug_info=false) override
Metrics gathering functions.
size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override
Block * GetOrCreateBlock(PdbCompilandSymId block_id)
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
Block * CreateBlock(PdbCompilandSymId block_id)
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)
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
void FindTypes(const lldb_private::TypeQuery &match, lldb_private::TypeResults &results) override
Find types using a type-matching object that contains all search parameters.
static char ID
LLVM RTTI support.
uint32_t ResolveSymbolContext(const Address &so_addr, lldb::SymbolContextItem resolve_scope, SymbolContext &sc) override
std::unique_ptr< PdbIndex > m_index
llvm::DenseMap< lldb::user_id_t, lldb::VariableSP > m_global_vars
lldb::TypeSP CreateSimpleType(llvm::codeview::TypeIndex ti, CompilerType ct)
#define LLDB_INVALID_ADDRESS
uint64_t toOpaqueUid(const T &cid)
size_t GetTypeSizeForSimpleKind(llvm::codeview::SimpleTypeKind kind)
SegmentOffsetLength GetSegmentOffsetAndLength(const llvm::codeview::CVSymbol &sym)
bool IsTagRecord(llvm::codeview::CVType cvt)
bool IsValidRecord(const RecordT &sym)
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.
std::shared_ptr< lldb_private::Function > FunctionSP
std::shared_ptr< lldb_private::Block > BlockSP
std::shared_ptr< lldb_private::ObjectFile > ObjectFileSP
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ eLanguageTypeObjC_plus_plus
Objective-C++.
@ eLanguageTypeSwift
Swift.
@ eLanguageTypeC
Non-standardized C, such as K&R.
@ eLanguageTypeObjC
Objective-C.
@ eLanguageTypeC_plus_plus
ISO C++:1998.
std::shared_ptr< lldb_private::Type > TypeSP
std::shared_ptr< lldb_private::VariableList > VariableListSP
std::shared_ptr< lldb_private::SymbolFileType > SymbolFileTypeSP
std::shared_ptr< lldb_private::Variable > VariableSP
std::shared_ptr< lldb_private::Module > ModuleSP
std::shared_ptr< lldb_private::CompileUnit > CompUnitSP
@ eValueTypeVariableGlobal
globals variable
@ eValueTypeVariableLocal
function local variables
@ eValueTypeVariableArgument
function argument variables
@ eValueTypeVariableStatic
static variable
@ eValueTypeVariableThreadLocal
thread local storage variable
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