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);
421 if (block_base >= func_base)
422 child_block->AddRange(
Block::Range(block_base - func_base, block.CodeSize));
425 "S_BLOCK32 at modi: {0:d} offset: {1:d}: adding range "
426 "[{2:x16}-{3:x16}) which has a base that is less than the "
428 "low PC 0x%" PRIx64
". Please file a bug and attach the file at the "
429 "start of this error message",
431 block_base + block.CodeSize, func_base);
434 m_blocks.insert({opaque_block_uid, child_block});
439 comp_unit->GetLineTable();
441 std::shared_ptr<InlineSite> inline_site =
m_inline_sites[opaque_block_uid];
448 for (
size_t i = 0; i < inline_site->ranges.GetSize(); ++i) {
449 auto *entry = inline_site->ranges.GetEntryAtIndex(i);
450 child_block->AddRange(
451 Block::Range(entry->GetRangeBase(), entry->GetByteSize()));
453 child_block->FinalizeRanges();
456 Declaration &decl = inline_site->inline_function_info->GetDeclaration();
457 Declaration &callsite = inline_site->inline_function_info->GetCallSite();
458 child_block->SetInlinedFunctionInfo(
459 inline_site->inline_function_info->GetName().GetCString(),
nullptr,
461 m_blocks.insert({opaque_block_uid, child_block});
465 lldbassert(
false &&
"Symbol is not a block!");
478 lldbassert(sym_record.kind() == S_LPROC32 || sym_record.kind() == S_GPROC32);
487 comp_unit.
GetModule()->GetSectionList());
491 ProcSym proc(
static_cast<SymbolRecordKind
>(sym_record.kind()));
492 cantFail(SymbolDeserializer::deserializeAs<ProcSym>(sym_record, proc));
493 if (proc.FunctionType == TypeIndex::None())
501 FunctionSP func_sp = std::make_shared<Function>(
508 if (
auto err = ts_or_err.takeError())
510 auto ts = *ts_or_err;
513 ts->GetNativePDBParser()->GetOrCreateFunctionDecl(func_id);
528 llvm::SmallString<64> source_file_name =
529 m_index->compilands().GetMainSourceFile(cci);
530 FileSpec fs(llvm::sys::path::convert_to_slash(
531 source_file_name, llvm::sys::path::Style::windows_backslash));
533 CompUnitSP cu_sp = std::make_shared<CompileUnit>(
534 m_objfile_sp->GetModule(),
nullptr, std::make_shared<SupportFile>(fs),
542 const ModifierRecord &mr,
544 TpiStream &stream =
m_index->tpi();
547 if (mr.ModifiedType.isSimple())
550 name = computeTypeName(stream.typeCollection(), mr.ModifiedType);
555 modified_type->GetByteSize(
nullptr),
nullptr,
562 const llvm::codeview::PointerRecord &pr,
568 if (pr.isPointerToMember()) {
569 MemberPointerInfo mpi = pr.getMemberInfo();
582 if (ti == TypeIndex::NullptrT()) {
589 if (ti.getSimpleMode() != SimpleTypeMode::Direct) {
591 uint32_t pointer_size = 0;
592 switch (ti.getSimpleMode()) {
593 case SimpleTypeMode::FarPointer32:
594 case SimpleTypeMode::NearPointer32:
597 case SimpleTypeMode::NearPointer64:
609 if (ti.getSimpleKind() == SimpleTypeKind::NotTranslated)
621 if (!record.hasUniqueName()) {
623 llvm::ArrayRef<MSVCUndecoratedNameSpecifier> specs = parser.
GetSpecifiers();
625 return std::string(specs.back().GetBaseName());
628 llvm::ms_demangle::Demangler demangler;
629 std::string_view sv(record.UniqueName.begin(), record.UniqueName.size());
630 llvm::ms_demangle::TagTypeNode *ttn = demangler.parseTagUniqueName(sv);
632 return std::string(record.Name);
634 llvm::ms_demangle::IdentifierNode *idn =
635 ttn->QualifiedName->getUnqualifiedIdentifier();
636 return idn->toString();
641 const TagRecord &record,
654 const ClassRecord &cr,
660 const UnionRecord &ur,
666 const EnumRecord &er,
674 underlying_type->GetByteSize(
nullptr),
nullptr,
680 const ArrayRecord &ar,
689 array_sp->SetEncodingType(element_type.get());
694 const MemberFunctionRecord &mfr,
703 const ProcedureRecord &pr,
712 if (type_id.
index.isSimple())
716 CVType cvt = stream.getType(type_id.
index);
718 if (cvt.kind() == LF_MODIFIER) {
719 ModifierRecord modifier;
721 TypeDeserializer::deserializeAs<ModifierRecord>(cvt, modifier));
725 if (cvt.kind() == LF_POINTER) {
726 PointerRecord pointer;
728 TypeDeserializer::deserializeAs<PointerRecord>(cvt, pointer));
734 llvm::cantFail(TypeDeserializer::deserializeAs<ClassRecord>(cvt, cr));
738 if (cvt.kind() == LF_ENUM) {
740 llvm::cantFail(TypeDeserializer::deserializeAs<EnumRecord>(cvt, er));
744 if (cvt.kind() == LF_UNION) {
746 llvm::cantFail(TypeDeserializer::deserializeAs<UnionRecord>(cvt, ur));
750 if (cvt.kind() == LF_ARRAY) {
752 llvm::cantFail(TypeDeserializer::deserializeAs<ArrayRecord>(cvt, ar));
756 if (cvt.kind() == LF_PROCEDURE) {
758 llvm::cantFail(TypeDeserializer::deserializeAs<ProcedureRecord>(cvt, pr));
761 if (cvt.kind() == LF_MFUNCTION) {
762 MemberFunctionRecord mfr;
763 llvm::cantFail(TypeDeserializer::deserializeAs<MemberFunctionRecord>(cvt, mfr));
773 std::optional<PdbTypeSymId> full_decl_uid;
775 auto expected_full_ti =
776 m_index->tpi().findFullDeclForForwardRef(type_id.
index);
777 if (!expected_full_ti)
778 llvm::consumeError(expected_full_ti.takeError());
779 else if (*expected_full_ti != type_id.
index) {
787 if (full_iter !=
m_types.end()) {
788 TypeSP result = full_iter->second;
797 PdbTypeSymId best_decl_id = full_decl_uid ? *full_decl_uid : type_id;
799 if (
auto err = ts_or_err.takeError())
801 auto ts = *ts_or_err;
839 CVSymbol sym =
m_index->symrecords().readRecord(var_id.
offset);
840 if (sym.kind() == S_CONSTANT)
845 llvm::StringRef name;
847 uint16_t section = 0;
849 bool is_external =
false;
850 switch (sym.kind()) {
855 DataSym ds(sym.kind());
856 llvm::cantFail(SymbolDeserializer::deserializeAs<DataSym>(sym, ds));
861 section = ds.Segment;
862 offset = ds.DataOffset;
863 addr =
m_index->MakeVirtualAddress(ds.Segment, ds.DataOffset);
870 ThreadLocalDataSym tlds(sym.kind());
872 SymbolDeserializer::deserializeAs<ThreadLocalDataSym>(sym, tlds));
875 section = tlds.Segment;
876 offset = tlds.DataOffset;
877 addr =
m_index->MakeVirtualAddress(tlds.Segment, tlds.DataOffset);
882 llvm_unreachable(
"unreachable!");
886 std::optional<uint16_t> modi =
m_index->GetModuleIndexForVa(addr);
897 std::make_shared<SymbolFileType>(*
this,
toOpaqueUid(tid));
900 if (
auto err = ts_or_err.takeError())
902 auto ts = *ts_or_err;
906 ts->GetNativePDBParser()->GetOrCreateVariableDecl(var_id);
913 std::string global_name(
"::");
915 bool artificial =
false;
916 bool location_is_constant_data =
false;
917 bool static_member =
false;
918 VariableSP var_sp = std::make_shared<Variable>(
919 toOpaqueUid(var_id), name.str().c_str(), global_name.c_str(), type_sp,
920 scope, comp_unit.get(), ranges, &decl, location, is_external, artificial,
921 location_is_constant_data, static_member);
928 const CVSymbol &cvs) {
929 TpiStream &tpi =
m_index->tpi();
930 ConstantSym constant(cvs.kind());
932 llvm::cantFail(SymbolDeserializer::deserializeAs<ConstantSym>(cvs, constant));
933 std::string global_name(
"::");
934 global_name += constant.Name;
937 std::make_shared<SymbolFileType>(*
this,
toOpaqueUid(tid));
944 constant.Type, tpi, constant.Value, module),
947 bool external =
false;
948 bool artificial =
false;
949 bool location_is_constant_data =
true;
950 bool static_member =
false;
951 VariableSP var_sp = std::make_shared<Variable>(
952 toOpaqueUid(var_id), constant.Name.str().c_str(), global_name.c_str(),
954 external, artificial, location_is_constant_data, static_member);
961 if (emplace_result.second) {
963 emplace_result.first->second = var_sp;
968 return emplace_result.first->second;
978 if (emplace_result.second)
979 emplace_result.first->second =
CreateFunction(func_id, comp_unit);
981 return emplace_result.first->second;
987 auto emplace_result =
989 if (emplace_result.second)
993 return emplace_result.first->second;
999 return iter->second.get();
1020 if (index >= UINT16_MAX)
1048 uint16_t modi = uid.asCompiland().modi;
1053 for (
auto iter = syms.begin(); iter != syms.end(); ++iter) {
1054 if (iter->kind() != S_LPROC32 && iter->kind() != S_GPROC32)
1064 return new_count - count;
1069 uint32_t flags = eSymbolContextCompUnit;
1070 flags |= eSymbolContextVariable;
1071 flags |= eSymbolContextFunction;
1072 flags |= eSymbolContextBlock;
1073 flags |= eSymbolContextLineEntry;
1074 return (resolve_scope & flags) != 0;
1080 uint32_t resolved_flags = 0;
1084 std::optional<uint16_t> modi =
m_index->GetModuleIndexForVa(file_addr);
1092 resolved_flags |= eSymbolContextCompUnit;
1095 if (resolve_scope & eSymbolContextFunction ||
1096 resolve_scope & eSymbolContextBlock) {
1098 std::vector<SymbolAndUid> matches =
m_index->FindSymbolsByVa(file_addr);
1102 for (
const auto &match : llvm::reverse(matches)) {
1107 CVSymbol cvs =
m_index->ReadSymbolRecord(csid);
1109 if (type != PDB_SymType::Function && type != PDB_SymType::Block)
1111 if (type == PDB_SymType::Function) {
1116 addr_t offset = file_addr - func_base;
1121 if (type == PDB_SymType::Block) {
1129 addr_t offset = file_addr - func_base;
1134 resolved_flags |= eSymbolContextFunction;
1136 resolved_flags |= eSymbolContextBlock;
1141 if (resolve_scope & eSymbolContextLineEntry) {
1144 if (line_table->FindLineEntryByAddress(addr, sc.
line_entry))
1145 resolved_flags |= eSymbolContextLineEntry;
1149 return resolved_flags;
1156 const uint32_t prev_size = sc_list.
GetSize();
1157 if (resolve_scope & eSymbolContextCompUnit) {
1166 if (file_spec_matches_cu_file_spec) {
1172 return sc_list.
GetSize() - prev_size;
1191 std::set<LineTable::Entry, LineTableEntryComparator> line_set;
1196 for (
const DebugSubsectionRecord &dssr :
1198 if (dssr.kind() != DebugSubsectionKind::Lines)
1201 DebugLinesSubsectionRef lines;
1202 llvm::BinaryStreamReader reader(dssr.getRecordData());
1203 if (
auto EC = lines.initialize(reader)) {
1204 llvm::consumeError(std::move(EC));
1208 const LineFragmentHeader *lfh = lines.header();
1209 uint64_t virtual_addr =
1210 m_index->MakeVirtualAddress(lfh->RelocSegment, lfh->RelocOffset);
1214 for (
const LineColumnEntry &group : lines) {
1215 llvm::Expected<uint32_t> file_index_or_err =
1217 if (!file_index_or_err)
1219 uint32_t file_index = file_index_or_err.get();
1223 for (
const LineNumberEntry &entry : group.LineNumbers) {
1224 LineInfo cur_info(entry.Flags);
1226 if (cur_info.isAlwaysStepInto() || cur_info.isNeverStepInto())
1229 uint64_t addr = virtual_addr + entry.Offset;
1231 bool is_statement = cur_info.isStatement();
1235 uint32_t lno = cur_info.getStartLine();
1238 is_prologue, is_epilogue,
false);
1240 auto iter = line_set.find(new_entry);
1241 if (iter != line_set.end() && iter->is_terminal_entry)
1242 line_set.erase(iter);
1243 line_set.insert(new_entry);
1250 line_entry.
data = {file_index, lno};
1252 LineInfo last_line(group.LineNumbers.back().Flags);
1253 line_set.emplace(virtual_addr + lfh->CodeSize, last_line.getEndLine(), 0,
1254 file_index,
false,
false,
false,
false,
true);
1257 line_entry.
SetRangeEnd(virtual_addr + lfh->CodeSize);
1266 const CVSymbolArray &syms = cii->
m_debug_stream.getSymbolArray();
1267 for (
auto iter = syms.begin(); iter != syms.end();) {
1268 if (iter->kind() != S_LPROC32 && iter->kind() != S_GPROC32) {
1273 uint32_t record_offset = iter.offset();
1274 CVSymbol func_record =
1283 comp_unit.
GetModule()->GetSectionList());
1289 if (kind != S_INLINESITE)
1294 for (
const auto &line_entry :
1299 if (!line_entry.is_terminal_entry)
1300 line_set.erase(line_entry);
1301 line_set.insert(line_entry);
1309 iter = syms.at(getScopeEndOffset(func_record));
1315 auto line_table = std::make_unique<LineTable>(&comp_unit);
1316 std::unique_ptr<LineSequence> sequence(
1317 line_table->CreateLineSequenceContainer());
1318 for (
const auto &line_entry : line_set) {
1319 line_table->AppendLineEntryToSequence(
1320 sequence.get(), line_entry.file_addr, line_entry.line,
1321 line_entry.column, line_entry.file_idx,
1322 line_entry.is_start_of_statement, line_entry.is_start_of_basic_block,
1323 line_entry.is_prologue_end, line_entry.is_epilogue_begin,
1324 line_entry.is_terminal_entry);
1326 line_table->InsertSequence(sequence.get());
1328 if (line_table->GetSize() == 0)
1340llvm::Expected<uint32_t>
1344 return llvm::make_error<RawError>(raw_error_code::no_entry);
1346 const auto &checksums = cii.
m_strings.checksums().getArray();
1347 const auto &strings = cii.
m_strings.strings();
1351 auto iter = checksums.at(file_id);
1352 if (iter == checksums.end())
1353 return llvm::make_error<RawError>(raw_error_code::no_entry);
1355 llvm::Expected<llvm::StringRef> efn = strings.getString(iter->FileNameOffset);
1357 return efn.takeError();
1363 return std::distance(cii.
m_file_list.begin(), fn_iter);
1364 return llvm::make_error<RawError>(raw_error_code::no_entry);
1378 f.starts_with(
"/") ? FileSpec::Style::posix : FileSpec::Style::windows;
1380 support_files.
Append(spec);
1386 const SymbolContext &sc, std::vector<SourceModule> &imported_modules) {
1399 CVSymbol sym = cii->
m_debug_stream.readSymbolAtOffset(
id.offset);
1402 InlineSiteSym inline_site(
static_cast<SymbolRecordKind
>(sym.kind()));
1403 cantFail(SymbolDeserializer::deserializeAs<InlineSiteSym>(sym, inline_site));
1406 std::shared_ptr<InlineSite> inline_site_sp =
1407 std::make_shared<InlineSite>(parent_id);
1410 auto iter = cii->
m_inline_map.find(inline_site.Inlinee);
1413 InlineeSourceLine inlinee_line = iter->second;
1417 llvm::Expected<uint32_t> file_index_or_err =
1419 if (!file_index_or_err)
1421 uint32_t file_offset = file_index_or_err.get();
1423 uint32_t decl_line = inlinee_line.Header->SourceLineNum;
1424 std::unique_ptr<Declaration> decl_up =
1425 std::make_unique<Declaration>(decl_file, decl_line);
1428 uint32_t code_offset = 0;
1429 int32_t line_offset = 0;
1430 std::optional<uint32_t> code_offset_base;
1431 std::optional<uint32_t> code_offset_end;
1432 std::optional<int32_t> cur_line_offset;
1433 std::optional<int32_t> next_line_offset;
1434 std::optional<uint32_t> next_file_offset;
1436 bool is_terminal_entry =
false;
1437 bool is_start_of_statement =
true;
1439 bool is_prologue_end =
true;
1441 auto update_code_offset = [&](uint32_t code_delta) {
1442 if (!code_offset_base)
1443 code_offset_base = code_offset;
1444 else if (!code_offset_end)
1445 code_offset_end = *code_offset_base + code_delta;
1447 auto update_line_offset = [&](int32_t line_delta) {
1448 line_offset += line_delta;
1449 if (!code_offset_base || !cur_line_offset)
1450 cur_line_offset = line_offset;
1452 next_line_offset = line_offset;
1455 auto update_file_offset = [&](uint32_t offset) {
1456 if (!code_offset_base)
1457 file_offset = offset;
1459 next_file_offset = offset;
1462 for (
auto &annot : inline_site.annotations()) {
1463 switch (annot.OpCode) {
1464 case BinaryAnnotationsOpCode::CodeOffset:
1465 case BinaryAnnotationsOpCode::ChangeCodeOffset:
1466 case BinaryAnnotationsOpCode::ChangeCodeOffsetBase:
1467 code_offset += annot.U1;
1468 update_code_offset(annot.U1);
1470 case BinaryAnnotationsOpCode::ChangeLineOffset:
1471 update_line_offset(annot.S1);
1473 case BinaryAnnotationsOpCode::ChangeCodeLength:
1474 update_code_offset(annot.U1);
1475 code_offset += annot.U1;
1476 is_terminal_entry =
true;
1478 case BinaryAnnotationsOpCode::ChangeCodeOffsetAndLineOffset:
1479 code_offset += annot.U1;
1480 update_code_offset(annot.U1);
1481 update_line_offset(annot.S1);
1483 case BinaryAnnotationsOpCode::ChangeCodeLengthAndCodeOffset:
1484 code_offset += annot.U2;
1485 update_code_offset(annot.U2);
1486 update_code_offset(annot.U1);
1487 code_offset += annot.U1;
1488 is_terminal_entry =
true;
1490 case BinaryAnnotationsOpCode::ChangeFile:
1491 update_file_offset(annot.U1);
1498 if (code_offset_base && code_offset_end && cur_line_offset) {
1500 *code_offset_base, *code_offset_end - *code_offset_base,
1501 decl_line + *cur_line_offset));
1503 if (next_file_offset)
1504 file_offset = *next_file_offset;
1505 if (next_line_offset) {
1506 cur_line_offset = next_line_offset;
1507 next_line_offset = std::nullopt;
1509 code_offset_base = is_terminal_entry ? std::nullopt : code_offset_end;
1510 code_offset_end = next_file_offset = std::nullopt;
1512 if (code_offset_base && cur_line_offset) {
1513 if (is_terminal_entry) {
1515 func_base + *code_offset_base, decl_line + *cur_line_offset, 0,
1516 file_offset,
false,
false,
false,
false,
true);
1517 inline_site_sp->line_entries.push_back(line_entry);
1520 decl_line + *cur_line_offset, 0,
1521 file_offset, is_start_of_statement,
false,
1522 is_prologue_end,
false,
false);
1523 inline_site_sp->line_entries.push_back(line_entry);
1524 is_prologue_end =
false;
1525 is_start_of_statement =
false;
1528 if (is_terminal_entry)
1529 is_start_of_statement =
true;
1530 is_terminal_entry =
false;
1533 inline_site_sp->ranges.Sort();
1536 std::unique_ptr<Declaration> callsite_up;
1537 if (!inline_site_sp->ranges.IsEmpty()) {
1538 auto *entry = inline_site_sp->ranges.GetEntryAtIndex(0);
1539 addr_t base_offset = entry->GetRangeBase();
1545 std::shared_ptr<InlineSite> parent_site =
1548 parent_site->inline_function_info->GetDeclaration().GetFile();
1549 if (
auto *parent_entry =
1550 parent_site->ranges.FindEntryThatContains(base_offset)) {
1552 std::make_unique<Declaration>(parent_decl_file, parent_entry->data);
1557 func_base + base_offset)) {
1561 std::make_unique<Declaration>(callsite_file, entry->data.second);
1567 CVType inlinee_cvt =
m_index->ipi().getType(inline_site.Inlinee);
1568 std::string inlinee_name;
1569 if (inlinee_cvt.kind() == LF_MFUNC_ID) {
1570 MemberFuncIdRecord mfr;
1572 TypeDeserializer::deserializeAs<MemberFuncIdRecord>(inlinee_cvt, mfr));
1573 LazyRandomTypeCollection &types =
m_index->tpi().typeCollection();
1574 inlinee_name.append(std::string(types.getTypeName(mfr.ClassType)));
1575 inlinee_name.append(
"::");
1576 inlinee_name.append(mfr.getName().str());
1577 }
else if (inlinee_cvt.kind() == LF_FUNC_ID) {
1579 cantFail(TypeDeserializer::deserializeAs<FuncIdRecord>(inlinee_cvt, fir));
1580 TypeIndex parent_idx = fir.getParentScope();
1581 if (!parent_idx.isNoneType()) {
1582 LazyRandomTypeCollection &ids =
m_index->ipi().typeCollection();
1583 inlinee_name.append(std::string(ids.getTypeName(parent_idx)));
1584 inlinee_name.append(
"::");
1586 inlinee_name.append(fir.getName().str());
1588 inline_site_sp->inline_function_info = std::make_shared<InlineFunctionInfo>(
1589 inlinee_name.c_str(), llvm::StringRef(), decl_up.get(),
1600 std::set<uint64_t> remove_uids;
1602 if (kind == S_GPROC32 || kind == S_LPROC32 || kind == S_BLOCK32 ||
1603 kind == S_INLINESITE) {
1605 if (kind == S_INLINESITE)
1612 for (uint64_t uid : remove_uids) {
1622 CVSymbolArray syms =
1626 for (
auto iter = syms.begin(); iter != syms.end(); ++iter) {
1628 if (fn(iter->kind(), child_id))
1639 auto ts = *ts_or_err;
1643 clang->GetNativePDBParser()->Dump(s);
1650 using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>;
1652 std::vector<SymbolAndOffset> results =
m_index->globals().findRecordsByName(
1654 for (
const SymbolAndOffset &result : results) {
1655 switch (result.second.kind()) {
1656 case SymbolKind::S_GDATA32:
1657 case SymbolKind::S_LDATA32:
1658 case SymbolKind::S_GTHREAD32:
1659 case SymbolKind::S_LTHREAD32:
1660 case SymbolKind::S_CONSTANT: {
1679 if (name_type_mask & eFunctionNameTypeFull)
1683 if (!(name_type_mask & eFunctionNameTypeFull ||
1684 name_type_mask & eFunctionNameTypeMethod))
1687 using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>;
1689 std::vector<SymbolAndOffset> matches =
m_index->globals().findRecordsByName(
1691 for (
const SymbolAndOffset &match : matches) {
1692 if (match.second.kind() != S_PROCREF && match.second.kind() != S_LPROCREF)
1694 ProcRefSym proc(match.second.kind());
1695 cantFail(SymbolDeserializer::deserializeAs<ProcRefSym>(match.second, proc));
1701 m_index->compilands().GetOrCreateCompiland(proc.modi());
1713 bool include_inlines,
1725 std::vector<TypeIndex> matches =
1728 for (TypeIndex type_idx : matches) {
1738 if (results.
Done(query))
1745 uint32_t max_matches,
1748 std::vector<TypeIndex> matches =
m_index->tpi().findRecordsByName(name);
1749 if (max_matches > 0 && max_matches < matches.size())
1750 matches.resize(max_matches);
1752 for (TypeIndex ti : matches) {
1768 LazyRandomTypeCollection &types =
m_index->tpi().typeCollection();
1771 for (
auto ti = types.getFirst(); ti; ti = types.getNext(*ti)) {
1774 (void)type->GetFullCompilerType();
1778 for (
const uint32_t gid :
m_index->globals().getGlobalsTable()) {
1780 CVSymbol sym =
m_index->ReadSymbolRecord(global);
1781 if (sym.kind() != S_UDT)
1784 UDTSym udt = llvm::cantFail(SymbolDeserializer::deserializeAs<UDTSym>(sym));
1785 bool is_typedef =
true;
1787 CVType cvt =
m_index->tpi().getType(udt.Type);
1789 if (name == udt.Name)
1801 return new_count - old_count;
1809 for (
const uint32_t gid :
m_index->globals().getGlobalsTable()) {
1811 CVSymbol sym =
m_index->ReadSymbolRecord(global);
1816 switch (sym.kind()) {
1817 case SymbolKind::S_GDATA32:
1818 case SymbolKind::S_LDATA32:
1819 case SymbolKind::S_GTHREAD32:
1820 case SymbolKind::S_LTHREAD32: {
1841 Block *func_block = block;
1863 std::string name = var_info.
name.str();
1866 std::make_shared<SymbolFileType>(*
this, type_sp->GetID());
1871 bool external =
false;
1872 bool artificial =
false;
1873 bool location_is_constant_data =
false;
1874 bool static_member =
false;
1876 VariableSP var_sp = std::make_shared<Variable>(
1877 toOpaqueUid(var_id), name.c_str(), name.c_str(), sftype, var_scope, block,
1878 scope_ranges, &decl, var_info.
location, external, artificial,
1879 location_is_constant_data, static_member);
1882 if (
auto err = ts_or_err.takeError())
1884 auto ts = *ts_or_err;
1888 ts->GetNativePDBParser()->GetOrCreateVariableDecl(scope_id, var_id);
1898 return iter->second;
1904 CVSymbol sym =
m_index->ReadSymbolRecord(
id);
1907 UDTSym udt = llvm::cantFail(SymbolDeserializer::deserializeAs<UDTSym>(sym));
1912 if (
auto err = ts_or_err.takeError())
1914 auto ts = *ts_or_err;
1918 ts->GetNativePDBParser()->GetOrCreateTypedefDecl(
id);
1924 decl, target_type->GetForwardCompilerType(),
1931 return iter->second;
1945 uint32_t params_remaining = 0;
1946 switch (sym.kind()) {
1949 ProcSym proc(
static_cast<SymbolRecordKind
>(sym.kind()));
1950 cantFail(SymbolDeserializer::deserializeAs<ProcSym>(sym, proc));
1951 CVType signature =
m_index->tpi().getType(proc.FunctionType);
1952 if (signature.kind() == LF_PROCEDURE) {
1953 ProcedureRecord sig;
1954 if (llvm::Error e = TypeDeserializer::deserializeAs<ProcedureRecord>(
1956 llvm::consumeError(std::move(e));
1959 params_remaining = sig.getParameterCount();
1960 }
else if (signature.kind() == LF_MFUNCTION) {
1961 MemberFunctionRecord sig;
1962 if (llvm::Error e = TypeDeserializer::deserializeAs<MemberFunctionRecord>(
1964 llvm::consumeError(std::move(e));
1967 params_remaining = sig.getParameterCount();
1977 lldbassert(
false &&
"Symbol is not a block!");
1983 variables = std::make_shared<VariableList>();
1987 CVSymbolArray syms = limitSymbolArrayToScope(
1993 auto iter = syms.begin();
1994 auto end = syms.end();
1996 while (iter != end) {
1997 uint32_t record_offset = iter.offset();
1998 CVSymbol variable_cvs = *iter;
2004 if (variable_cvs.kind() == S_BLOCK32 ||
2005 variable_cvs.kind() == S_INLINESITE) {
2006 uint32_t block_end = getScopeEndOffset(variable_cvs);
2008 iter = syms.at(block_end);
2012 bool is_param = params_remaining > 0;
2014 switch (variable_cvs.kind()) {
2022 variables->AddVariableIfUnique(variable);
2058 variables = std::make_shared<VariableList>();
2064 llvm_unreachable(
"Unreachable!");
2069 if (
auto err = ts_or_err.takeError())
2071 auto ts = *ts_or_err;
2075 if (
auto decl = ts->GetNativePDBParser()->GetOrCreateDeclForUid(uid))
2083 if (
auto err = ts_or_err.takeError())
2085 auto ts = *ts_or_err;
2090 clang::DeclContext *context =
2101 if (
auto err = ts_or_err.takeError())
2103 auto ts = *ts_or_err;
2116 auto iter =
m_types.find(type_uid);
2123 return &*iter->second;
2128 if (type_id.
index.isNoneType())
2137std::optional<SymbolFile::ArrayInfo>
2140 return std::nullopt;
2147 if (!clang_type_system)
2151 static_cast<PdbAstBuilder *
>(clang_type_system->GetNativePDBParser());
2155 clang::QualType qt =
2162 TypeClass type_mask,
2170llvm::Expected<lldb::TypeSystemSP>
2172 auto type_system_or_err =
2173 m_objfile_sp->GetModule()->GetTypeSystemForLanguage(language);
2174 if (type_system_or_err)
2175 if (
auto ts = *type_system_or_err)
2176 ts->SetSymbolFile(
this);
2177 return type_system_or_err;
2182 return m_index->pdb().getFileSize();
2186 LazyRandomTypeCollection &types =
m_index->tpi().typeCollection();
2188 llvm::DenseMap<TypeIndex, TypeIndex> forward_to_full;
2189 llvm::DenseMap<TypeIndex, TypeIndex> full_to_forward;
2191 struct RecordIndices {
2196 llvm::StringMap<RecordIndices> record_indices;
2198 for (
auto ti = types.getFirst(); ti; ti = types.getNext(*ti)) {
2199 CVType type = types.getType(*ti);
2205 RecordIndices &indices = record_indices[tag.
asTag().getUniqueName()];
2206 if (tag.
asTag().isForwardRef())
2207 indices.forward = *ti;
2211 if (indices.full != TypeIndex::None() &&
2212 indices.forward != TypeIndex::None()) {
2213 forward_to_full[indices.forward] = indices.full;
2214 full_to_forward[indices.full] = indices.forward;
2220 if (tag.
asTag().isForwardRef() || !tag.
asTag().containsNestedClass())
2224 ProcessTpiStream(
PdbIndex &index, TypeIndex parent,
2226 llvm::DenseMap<TypeIndex, TypeIndex> &parents)
2227 : index(index), parents(parents), parent(parent),
2228 parent_cvt(parent_cvt) {}
2231 llvm::DenseMap<TypeIndex, TypeIndex> &parents;
2233 unsigned unnamed_type_index = 1;
2237 llvm::Error visitKnownMember(CVMemberRecord &CVR,
2238 NestedTypeRecord &Record)
override {
2239 std::string unnamed_type_name;
2240 if (Record.Name.empty()) {
2242 llvm::formatv(
"<unnamed-type-$S{0}>", unnamed_type_index).str();
2243 Record.Name = unnamed_type_name;
2244 ++unnamed_type_index;
2246 std::optional<CVTagRecord> tag =
2249 return llvm::ErrorSuccess();
2251 parents[Record.Type] = parent;
2252 return llvm::ErrorSuccess();
2256 CVType field_list_cvt =
m_index->tpi().getType(tag.
asTag().FieldList);
2258 FieldListRecord field_list;
2259 if (llvm::Error
error = TypeDeserializer::deserializeAs<FieldListRecord>(
2260 field_list_cvt, field_list))
2261 llvm::consumeError(std::move(
error));
2262 if (llvm::Error
error = visitMemberRecordStream(field_list.Data, process))
2263 llvm::consumeError(std::move(
error));
2271 std::vector<TypeIndex> full_keys;
2272 std::vector<TypeIndex> fwd_keys;
2274 TypeIndex key = entry.first;
2275 TypeIndex value = entry.second;
2277 auto iter = forward_to_full.find(value);
2278 if (iter != forward_to_full.end())
2279 entry.second = iter->second;
2281 iter = forward_to_full.find(key);
2282 if (iter != forward_to_full.end())
2283 fwd_keys.push_back(key);
2285 full_keys.push_back(key);
2287 for (TypeIndex fwd : fwd_keys) {
2288 TypeIndex full = forward_to_full[fwd];
2292 for (TypeIndex full : full_keys) {
2293 TypeIndex fwd = full_to_forward[full];
2298std::optional<PdbCompilandSymId>
2300 CVSymbol sym =
m_index->ReadSymbolRecord(
id);
2301 if (symbolOpensScope(sym.kind())) {
2304 id.offset = getScopeParentOffset(sym);
2308 return std::nullopt;
2317 auto begin = syms.begin();
2318 auto end = syms.at(
id.offset);
2319 std::vector<PdbCompilandSymId> scope_stack;
2321 while (begin != end) {
2322 if (begin.offset() >
id.offset) {
2324 lldbassert(
false &&
"Invalid compiland symbol id!");
2325 return std::nullopt;
2330 if (symbolOpensScope(begin->kind())) {
2333 uint32_t scope_end = getScopeEndOffset(*begin);
2334 if (scope_end <
id.offset) {
2335 begin = syms.at(scope_end);
2338 scope_stack.emplace_back(
id.modi, begin.offset());
2340 }
else if (symbolEndsScope(begin->kind())) {
2341 scope_stack.pop_back();
2345 if (scope_stack.empty())
2346 return std::nullopt;
2348 return scope_stack.back();
2351std::optional<llvm::codeview::TypeIndex>
2355 return std::nullopt;
2356 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 Address & GetAddress() const
Return the address of the function (its entry point).
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