Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1 | //===-- SymbolFileNativePDB.cpp ---------------------------------*- C++ -*-===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "SymbolFileNativePDB.h" |
| 10 | |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 11 | #include "clang/AST/Attr.h" |
| 12 | #include "clang/AST/CharUnits.h" |
| 13 | #include "clang/AST/Decl.h" |
| 14 | #include "clang/AST/DeclCXX.h" |
Zachary Turner | 056e4ab | 2018-11-08 18:50:11 +0000 | [diff] [blame] | 15 | #include "clang/AST/Type.h" |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 16 | |
Zachary Turner | 44f1951 | 2019-01-10 20:57:32 +0000 | [diff] [blame] | 17 | #include "Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.h" |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 18 | #include "lldb/Core/Module.h" |
| 19 | #include "lldb/Core/PluginManager.h" |
Zachary Turner | 9f72795 | 2018-10-26 09:06:38 +0000 | [diff] [blame] | 20 | #include "lldb/Core/StreamBuffer.h" |
Zachary Turner | 056e4ab | 2018-11-08 18:50:11 +0000 | [diff] [blame] | 21 | #include "lldb/Core/StreamFile.h" |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 22 | #include "lldb/Symbol/ClangASTContext.h" |
| 23 | #include "lldb/Symbol/ClangASTImporter.h" |
| 24 | #include "lldb/Symbol/ClangExternalASTSourceCommon.h" |
Zachary Turner | 056e4ab | 2018-11-08 18:50:11 +0000 | [diff] [blame] | 25 | #include "lldb/Symbol/ClangUtil.h" |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 26 | #include "lldb/Symbol/CompileUnit.h" |
| 27 | #include "lldb/Symbol/LineTable.h" |
| 28 | #include "lldb/Symbol/ObjectFile.h" |
| 29 | #include "lldb/Symbol/SymbolContext.h" |
| 30 | #include "lldb/Symbol/SymbolVendor.h" |
Zachary Turner | 9f72795 | 2018-10-26 09:06:38 +0000 | [diff] [blame] | 31 | #include "lldb/Symbol/Variable.h" |
| 32 | #include "lldb/Symbol/VariableList.h" |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 33 | |
| 34 | #include "llvm/DebugInfo/CodeView/CVRecord.h" |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 35 | #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h" |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 36 | #include "llvm/DebugInfo/CodeView/DebugLinesSubsection.h" |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 37 | #include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h" |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 38 | #include "llvm/DebugInfo/CodeView/RecordName.h" |
| 39 | #include "llvm/DebugInfo/CodeView/SymbolDeserializer.h" |
Zachary Turner | a42bbe3 | 2018-12-07 19:34:02 +0000 | [diff] [blame] | 40 | #include "llvm/DebugInfo/CodeView/SymbolRecordHelpers.h" |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 41 | #include "llvm/DebugInfo/CodeView/TypeDeserializer.h" |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 42 | #include "llvm/DebugInfo/PDB/Native/DbiStream.h" |
| 43 | #include "llvm/DebugInfo/PDB/Native/GlobalsStream.h" |
| 44 | #include "llvm/DebugInfo/PDB/Native/InfoStream.h" |
| 45 | #include "llvm/DebugInfo/PDB/Native/ModuleDebugStream.h" |
| 46 | #include "llvm/DebugInfo/PDB/Native/PDBFile.h" |
| 47 | #include "llvm/DebugInfo/PDB/Native/SymbolStream.h" |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 48 | #include "llvm/DebugInfo/PDB/Native/TpiStream.h" |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 49 | #include "llvm/DebugInfo/PDB/PDBTypes.h" |
Zachary Turner | 056e4ab | 2018-11-08 18:50:11 +0000 | [diff] [blame] | 50 | #include "llvm/Demangle/MicrosoftDemangle.h" |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 51 | #include "llvm/Object/COFF.h" |
| 52 | #include "llvm/Support/Allocator.h" |
| 53 | #include "llvm/Support/BinaryStreamReader.h" |
Zachary Turner | 056e4ab | 2018-11-08 18:50:11 +0000 | [diff] [blame] | 54 | #include "llvm/Support/Error.h" |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 55 | #include "llvm/Support/ErrorOr.h" |
| 56 | #include "llvm/Support/MemoryBuffer.h" |
| 57 | |
Zachary Turner | a93458b | 2018-12-06 17:49:15 +0000 | [diff] [blame] | 58 | #include "DWARFLocationExpression.h" |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 59 | #include "PdbAstBuilder.h" |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 60 | #include "PdbSymUid.h" |
| 61 | #include "PdbUtil.h" |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 62 | #include "UdtRecordCompleter.h" |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 63 | |
| 64 | using namespace lldb; |
| 65 | using namespace lldb_private; |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 66 | using namespace npdb; |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 67 | using namespace llvm::codeview; |
| 68 | using namespace llvm::pdb; |
| 69 | |
| 70 | static lldb::LanguageType TranslateLanguage(PDB_Lang lang) { |
| 71 | switch (lang) { |
| 72 | case PDB_Lang::Cpp: |
| 73 | return lldb::LanguageType::eLanguageTypeC_plus_plus; |
| 74 | case PDB_Lang::C: |
| 75 | return lldb::LanguageType::eLanguageTypeC; |
Nathan Lanza | 0561be6 | 2019-03-11 23:30:58 +0000 | [diff] [blame] | 76 | case PDB_Lang::Swift: |
| 77 | return lldb::LanguageType::eLanguageTypeSwift; |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 78 | default: |
| 79 | return lldb::LanguageType::eLanguageTypeUnknown; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | static std::unique_ptr<PDBFile> loadPDBFile(std::string PdbPath, |
| 84 | llvm::BumpPtrAllocator &Allocator) { |
| 85 | llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> ErrorOrBuffer = |
| 86 | llvm::MemoryBuffer::getFile(PdbPath, /*FileSize=*/-1, |
| 87 | /*RequiresNullTerminator=*/false); |
| 88 | if (!ErrorOrBuffer) |
| 89 | return nullptr; |
| 90 | std::unique_ptr<llvm::MemoryBuffer> Buffer = std::move(*ErrorOrBuffer); |
| 91 | |
| 92 | llvm::StringRef Path = Buffer->getBufferIdentifier(); |
| 93 | auto Stream = llvm::make_unique<llvm::MemoryBufferByteStream>( |
| 94 | std::move(Buffer), llvm::support::little); |
| 95 | |
| 96 | auto File = llvm::make_unique<PDBFile>(Path, std::move(Stream), Allocator); |
Zachary Turner | 8040eea | 2018-10-12 22:57:40 +0000 | [diff] [blame] | 97 | if (auto EC = File->parseFileHeaders()) { |
| 98 | llvm::consumeError(std::move(EC)); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 99 | return nullptr; |
Zachary Turner | 8040eea | 2018-10-12 22:57:40 +0000 | [diff] [blame] | 100 | } |
| 101 | if (auto EC = File->parseStreamData()) { |
| 102 | llvm::consumeError(std::move(EC)); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 103 | return nullptr; |
Zachary Turner | 8040eea | 2018-10-12 22:57:40 +0000 | [diff] [blame] | 104 | } |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 105 | |
| 106 | return File; |
| 107 | } |
| 108 | |
| 109 | static std::unique_ptr<PDBFile> |
| 110 | loadMatchingPDBFile(std::string exe_path, llvm::BumpPtrAllocator &allocator) { |
| 111 | // Try to find a matching PDB for an EXE. |
| 112 | using namespace llvm::object; |
| 113 | auto expected_binary = createBinary(exe_path); |
| 114 | |
| 115 | // If the file isn't a PE/COFF executable, fail. |
| 116 | if (!expected_binary) { |
| 117 | llvm::consumeError(expected_binary.takeError()); |
| 118 | return nullptr; |
| 119 | } |
| 120 | OwningBinary<Binary> binary = std::move(*expected_binary); |
| 121 | |
| 122 | auto *obj = llvm::dyn_cast<llvm::object::COFFObjectFile>(binary.getBinary()); |
| 123 | if (!obj) |
| 124 | return nullptr; |
| 125 | const llvm::codeview::DebugInfo *pdb_info = nullptr; |
| 126 | |
| 127 | // If it doesn't have a debug directory, fail. |
| 128 | llvm::StringRef pdb_file; |
| 129 | auto ec = obj->getDebugPDBInfo(pdb_info, pdb_file); |
| 130 | if (ec) |
| 131 | return nullptr; |
| 132 | |
| 133 | // if the file doesn't exist, is not a pdb, or doesn't have a matching guid, |
| 134 | // fail. |
| 135 | llvm::file_magic magic; |
| 136 | ec = llvm::identify_magic(pdb_file, magic); |
| 137 | if (ec || magic != llvm::file_magic::pdb) |
| 138 | return nullptr; |
| 139 | std::unique_ptr<PDBFile> pdb = loadPDBFile(pdb_file, allocator); |
Zachary Turner | 8040eea | 2018-10-12 22:57:40 +0000 | [diff] [blame] | 140 | if (!pdb) |
| 141 | return nullptr; |
| 142 | |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 143 | auto expected_info = pdb->getPDBInfoStream(); |
| 144 | if (!expected_info) { |
| 145 | llvm::consumeError(expected_info.takeError()); |
| 146 | return nullptr; |
| 147 | } |
| 148 | llvm::codeview::GUID guid; |
| 149 | memcpy(&guid, pdb_info->PDB70.Signature, 16); |
| 150 | |
| 151 | if (expected_info->getGuid() != guid) |
| 152 | return nullptr; |
| 153 | return pdb; |
| 154 | } |
| 155 | |
| 156 | static bool IsFunctionPrologue(const CompilandIndexItem &cci, |
| 157 | lldb::addr_t addr) { |
| 158 | // FIXME: Implement this. |
| 159 | return false; |
| 160 | } |
| 161 | |
| 162 | static bool IsFunctionEpilogue(const CompilandIndexItem &cci, |
| 163 | lldb::addr_t addr) { |
| 164 | // FIXME: Implement this. |
| 165 | return false; |
| 166 | } |
| 167 | |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 168 | static llvm::StringRef GetSimpleTypeName(SimpleTypeKind kind) { |
| 169 | switch (kind) { |
| 170 | case SimpleTypeKind::Boolean128: |
| 171 | case SimpleTypeKind::Boolean16: |
| 172 | case SimpleTypeKind::Boolean32: |
| 173 | case SimpleTypeKind::Boolean64: |
| 174 | case SimpleTypeKind::Boolean8: |
| 175 | return "bool"; |
| 176 | case SimpleTypeKind::Byte: |
| 177 | case SimpleTypeKind::UnsignedCharacter: |
| 178 | return "unsigned char"; |
| 179 | case SimpleTypeKind::NarrowCharacter: |
| 180 | return "char"; |
| 181 | case SimpleTypeKind::SignedCharacter: |
| 182 | case SimpleTypeKind::SByte: |
Zachary Turner | 71ebb72 | 2018-10-23 22:15:05 +0000 | [diff] [blame] | 183 | return "signed char"; |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 184 | case SimpleTypeKind::Character16: |
| 185 | return "char16_t"; |
| 186 | case SimpleTypeKind::Character32: |
| 187 | return "char32_t"; |
| 188 | case SimpleTypeKind::Complex80: |
| 189 | case SimpleTypeKind::Complex64: |
| 190 | case SimpleTypeKind::Complex32: |
| 191 | return "complex"; |
| 192 | case SimpleTypeKind::Float128: |
| 193 | case SimpleTypeKind::Float80: |
| 194 | return "long double"; |
| 195 | case SimpleTypeKind::Float64: |
| 196 | return "double"; |
| 197 | case SimpleTypeKind::Float32: |
| 198 | return "float"; |
| 199 | case SimpleTypeKind::Float16: |
| 200 | return "single"; |
| 201 | case SimpleTypeKind::Int128: |
| 202 | return "__int128"; |
| 203 | case SimpleTypeKind::Int64: |
| 204 | case SimpleTypeKind::Int64Quad: |
Zachary Turner | 71ebb72 | 2018-10-23 22:15:05 +0000 | [diff] [blame] | 205 | return "int64_t"; |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 206 | case SimpleTypeKind::Int32: |
| 207 | return "int"; |
| 208 | case SimpleTypeKind::Int16: |
| 209 | return "short"; |
| 210 | case SimpleTypeKind::UInt128: |
| 211 | return "unsigned __int128"; |
| 212 | case SimpleTypeKind::UInt64: |
| 213 | case SimpleTypeKind::UInt64Quad: |
Zachary Turner | 71ebb72 | 2018-10-23 22:15:05 +0000 | [diff] [blame] | 214 | return "uint64_t"; |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 215 | case SimpleTypeKind::HResult: |
| 216 | return "HRESULT"; |
| 217 | case SimpleTypeKind::UInt32: |
| 218 | return "unsigned"; |
| 219 | case SimpleTypeKind::UInt16: |
| 220 | case SimpleTypeKind::UInt16Short: |
| 221 | return "unsigned short"; |
| 222 | case SimpleTypeKind::Int32Long: |
| 223 | return "long"; |
| 224 | case SimpleTypeKind::UInt32Long: |
| 225 | return "unsigned long"; |
| 226 | case SimpleTypeKind::Void: |
| 227 | return "void"; |
| 228 | case SimpleTypeKind::WideCharacter: |
| 229 | return "wchar_t"; |
| 230 | default: |
| 231 | return ""; |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | static bool IsClassRecord(TypeLeafKind kind) { |
| 236 | switch (kind) { |
| 237 | case LF_STRUCTURE: |
| 238 | case LF_CLASS: |
| 239 | case LF_INTERFACE: |
| 240 | return true; |
| 241 | default: |
| 242 | return false; |
| 243 | } |
| 244 | } |
| 245 | |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 246 | void SymbolFileNativePDB::Initialize() { |
| 247 | PluginManager::RegisterPlugin(GetPluginNameStatic(), |
| 248 | GetPluginDescriptionStatic(), CreateInstance, |
| 249 | DebuggerInitialize); |
| 250 | } |
| 251 | |
| 252 | void SymbolFileNativePDB::Terminate() { |
| 253 | PluginManager::UnregisterPlugin(CreateInstance); |
| 254 | } |
| 255 | |
Zachary Turner | b96181c | 2018-10-22 16:19:07 +0000 | [diff] [blame] | 256 | void SymbolFileNativePDB::DebuggerInitialize(Debugger &debugger) {} |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 257 | |
Zachary Turner | b96181c | 2018-10-22 16:19:07 +0000 | [diff] [blame] | 258 | ConstString SymbolFileNativePDB::GetPluginNameStatic() { |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 259 | static ConstString g_name("native-pdb"); |
| 260 | return g_name; |
| 261 | } |
| 262 | |
| 263 | const char *SymbolFileNativePDB::GetPluginDescriptionStatic() { |
| 264 | return "Microsoft PDB debug symbol cross-platform file reader."; |
| 265 | } |
| 266 | |
Zachary Turner | b96181c | 2018-10-22 16:19:07 +0000 | [diff] [blame] | 267 | SymbolFile *SymbolFileNativePDB::CreateInstance(ObjectFile *obj_file) { |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 268 | return new SymbolFileNativePDB(obj_file); |
| 269 | } |
| 270 | |
Zachary Turner | b96181c | 2018-10-22 16:19:07 +0000 | [diff] [blame] | 271 | SymbolFileNativePDB::SymbolFileNativePDB(ObjectFile *object_file) |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 272 | : SymbolFile(object_file) {} |
| 273 | |
| 274 | SymbolFileNativePDB::~SymbolFileNativePDB() {} |
| 275 | |
| 276 | uint32_t SymbolFileNativePDB::CalculateAbilities() { |
| 277 | uint32_t abilities = 0; |
| 278 | if (!m_obj_file) |
| 279 | return 0; |
| 280 | |
| 281 | if (!m_index) { |
| 282 | // Lazily load and match the PDB file, but only do this once. |
| 283 | std::unique_ptr<PDBFile> file_up = |
| 284 | loadMatchingPDBFile(m_obj_file->GetFileSpec().GetPath(), m_allocator); |
| 285 | |
| 286 | if (!file_up) { |
| 287 | auto module_sp = m_obj_file->GetModule(); |
| 288 | if (!module_sp) |
| 289 | return 0; |
| 290 | // See if any symbol file is specified through `--symfile` option. |
| 291 | FileSpec symfile = module_sp->GetSymbolFileFileSpec(); |
| 292 | if (!symfile) |
| 293 | return 0; |
| 294 | file_up = loadPDBFile(symfile.GetPath(), m_allocator); |
| 295 | } |
| 296 | |
| 297 | if (!file_up) |
| 298 | return 0; |
| 299 | |
| 300 | auto expected_index = PdbIndex::create(std::move(file_up)); |
| 301 | if (!expected_index) { |
| 302 | llvm::consumeError(expected_index.takeError()); |
| 303 | return 0; |
| 304 | } |
| 305 | m_index = std::move(*expected_index); |
| 306 | } |
| 307 | if (!m_index) |
| 308 | return 0; |
| 309 | |
| 310 | // We don't especially have to be precise here. We only distinguish between |
| 311 | // stripped and not stripped. |
| 312 | abilities = kAllAbilities; |
| 313 | |
| 314 | if (m_index->dbi().isStripped()) |
| 315 | abilities &= ~(Blocks | LocalVariables); |
| 316 | return abilities; |
| 317 | } |
| 318 | |
| 319 | void SymbolFileNativePDB::InitializeObject() { |
Pavel Labath | d1304bb | 2019-02-18 11:06:57 +0000 | [diff] [blame] | 320 | m_obj_load_address = m_obj_file->GetBaseAddress().GetFileAddress(); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 321 | m_index->SetLoadAddress(m_obj_load_address); |
| 322 | m_index->ParseSectionContribs(); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 323 | |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 324 | TypeSystem *ts = m_obj_file->GetModule()->GetTypeSystemForLanguage( |
| 325 | lldb::eLanguageTypeC_plus_plus); |
| 326 | if (ts) |
| 327 | ts->SetSymbolFile(this); |
Zachary Turner | 056e4ab | 2018-11-08 18:50:11 +0000 | [diff] [blame] | 328 | |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 329 | m_ast = llvm::make_unique<PdbAstBuilder>(*m_obj_file, *m_index); |
Zachary Turner | 056e4ab | 2018-11-08 18:50:11 +0000 | [diff] [blame] | 330 | } |
| 331 | |
Pavel Labath | e011990 | 2019-07-23 09:24:02 +0000 | [diff] [blame] | 332 | uint32_t SymbolFileNativePDB::CalculateNumCompileUnits() { |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 333 | const DbiModuleList &modules = m_index->dbi().modules(); |
| 334 | uint32_t count = modules.getModuleCount(); |
| 335 | if (count == 0) |
| 336 | return count; |
| 337 | |
| 338 | // The linker can inject an additional "dummy" compilation unit into the |
| 339 | // PDB. Ignore this special compile unit for our purposes, if it is there. |
| 340 | // It is always the last one. |
| 341 | DbiModuleDescriptor last = modules.getModuleDescriptor(count - 1); |
| 342 | if (last.getModuleName() == "* Linker *") |
| 343 | --count; |
| 344 | return count; |
| 345 | } |
| 346 | |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 347 | Block &SymbolFileNativePDB::CreateBlock(PdbCompilandSymId block_id) { |
| 348 | CompilandIndexItem *cii = m_index->compilands().GetCompiland(block_id.modi); |
| 349 | CVSymbol sym = cii->m_debug_stream.readSymbolAtOffset(block_id.offset); |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 350 | |
| 351 | if (sym.kind() == S_GPROC32 || sym.kind() == S_LPROC32) { |
| 352 | // This is a function. It must be global. Creating the Function entry for |
| 353 | // it automatically creates a block for it. |
| 354 | CompUnitSP comp_unit = GetOrCreateCompileUnit(*cii); |
| 355 | return GetOrCreateFunction(block_id, *comp_unit)->GetBlock(false); |
| 356 | } |
| 357 | |
| 358 | lldbassert(sym.kind() == S_BLOCK32); |
| 359 | |
| 360 | // This is a block. Its parent is either a function or another block. In |
| 361 | // either case, its parent can be viewed as a block (e.g. a function contains |
| 362 | // 1 big block. So just get the parent block and add this block to it. |
| 363 | BlockSym block(static_cast<SymbolRecordKind>(sym.kind())); |
| 364 | cantFail(SymbolDeserializer::deserializeAs<BlockSym>(sym, block)); |
| 365 | lldbassert(block.Parent != 0); |
| 366 | PdbCompilandSymId parent_id(block_id.modi, block.Parent); |
| 367 | Block &parent_block = GetOrCreateBlock(parent_id); |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 368 | lldb::user_id_t opaque_block_uid = toOpaqueUid(block_id); |
| 369 | BlockSP child_block = std::make_shared<Block>(opaque_block_uid); |
| 370 | parent_block.AddChild(child_block); |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 371 | |
| 372 | m_ast->GetOrCreateBlockDecl(block_id); |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 373 | |
| 374 | m_blocks.insert({opaque_block_uid, child_block}); |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 375 | return *child_block; |
| 376 | } |
| 377 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 378 | lldb::FunctionSP SymbolFileNativePDB::CreateFunction(PdbCompilandSymId func_id, |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 379 | CompileUnit &comp_unit) { |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 380 | const CompilandIndexItem *cci = |
| 381 | m_index->compilands().GetCompiland(func_id.modi); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 382 | lldbassert(cci); |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 383 | CVSymbol sym_record = cci->m_debug_stream.readSymbolAtOffset(func_id.offset); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 384 | |
| 385 | lldbassert(sym_record.kind() == S_LPROC32 || sym_record.kind() == S_GPROC32); |
| 386 | SegmentOffsetLength sol = GetSegmentOffsetAndLength(sym_record); |
| 387 | |
| 388 | auto file_vm_addr = m_index->MakeVirtualAddress(sol.so); |
| 389 | if (file_vm_addr == LLDB_INVALID_ADDRESS || file_vm_addr == 0) |
| 390 | return nullptr; |
| 391 | |
| 392 | AddressRange func_range(file_vm_addr, sol.length, |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 393 | comp_unit.GetModule()->GetSectionList()); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 394 | if (!func_range.GetBaseAddress().IsValid()) |
| 395 | return nullptr; |
| 396 | |
Zachary Turner | a42bbe3 | 2018-12-07 19:34:02 +0000 | [diff] [blame] | 397 | ProcSym proc(static_cast<SymbolRecordKind>(sym_record.kind())); |
| 398 | cantFail(SymbolDeserializer::deserializeAs<ProcSym>(sym_record, proc)); |
Zachary Turner | 44f1951 | 2019-01-10 20:57:32 +0000 | [diff] [blame] | 399 | if (proc.FunctionType == TypeIndex::None()) |
| 400 | return nullptr; |
Zachary Turner | a42bbe3 | 2018-12-07 19:34:02 +0000 | [diff] [blame] | 401 | TypeSP func_type = GetOrCreateType(proc.FunctionType); |
Zachary Turner | 44f1951 | 2019-01-10 20:57:32 +0000 | [diff] [blame] | 402 | if (!func_type) |
| 403 | return nullptr; |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 404 | |
Zachary Turner | a42bbe3 | 2018-12-07 19:34:02 +0000 | [diff] [blame] | 405 | PdbTypeSymId sig_id(proc.FunctionType, false); |
| 406 | Mangled mangled(proc.Name); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 407 | FunctionSP func_sp = std::make_shared<Function>( |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 408 | &comp_unit, toOpaqueUid(func_id), toOpaqueUid(sig_id), mangled, |
Zachary Turner | a42bbe3 | 2018-12-07 19:34:02 +0000 | [diff] [blame] | 409 | func_type.get(), func_range); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 410 | |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 411 | comp_unit.AddFunction(func_sp); |
| 412 | |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 413 | m_ast->GetOrCreateFunctionDecl(func_id); |
Zachary Turner | a42bbe3 | 2018-12-07 19:34:02 +0000 | [diff] [blame] | 414 | |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 415 | return func_sp; |
| 416 | } |
| 417 | |
| 418 | CompUnitSP |
| 419 | SymbolFileNativePDB::CreateCompileUnit(const CompilandIndexItem &cci) { |
| 420 | lldb::LanguageType lang = |
| 421 | cci.m_compile_opts ? TranslateLanguage(cci.m_compile_opts->getLanguage()) |
| 422 | : lldb::eLanguageTypeUnknown; |
| 423 | |
| 424 | LazyBool optimized = eLazyBoolNo; |
| 425 | if (cci.m_compile_opts && cci.m_compile_opts->hasOptimizations()) |
| 426 | optimized = eLazyBoolYes; |
| 427 | |
Zachary Turner | 51f88af | 2018-12-19 19:45:30 +0000 | [diff] [blame] | 428 | llvm::SmallString<64> source_file_name = |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 429 | m_index->compilands().GetMainSourceFile(cci); |
Jonas Devlieghere | 8f3be7a | 2018-11-01 21:05:36 +0000 | [diff] [blame] | 430 | FileSpec fs(source_file_name); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 431 | |
| 432 | CompUnitSP cu_sp = |
| 433 | std::make_shared<CompileUnit>(m_obj_file->GetModule(), nullptr, fs, |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 434 | toOpaqueUid(cci.m_id), lang, optimized); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 435 | |
Pavel Labath | e011990 | 2019-07-23 09:24:02 +0000 | [diff] [blame] | 436 | SetCompileUnitAtIndex(cci.m_id.modi, cu_sp); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 437 | return cu_sp; |
| 438 | } |
| 439 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 440 | lldb::TypeSP SymbolFileNativePDB::CreateModifierType(PdbTypeSymId type_id, |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 441 | const ModifierRecord &mr, |
| 442 | CompilerType ct) { |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 443 | TpiStream &stream = m_index->tpi(); |
| 444 | |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 445 | std::string name; |
| 446 | if (mr.ModifiedType.isSimple()) |
| 447 | name = GetSimpleTypeName(mr.ModifiedType.getSimpleKind()); |
| 448 | else |
| 449 | name = computeTypeName(stream.typeCollection(), mr.ModifiedType); |
| 450 | Declaration decl; |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 451 | lldb::TypeSP modified_type = GetOrCreateType(mr.ModifiedType); |
| 452 | |
| 453 | return std::make_shared<Type>(toOpaqueUid(type_id), this, ConstString(name), |
| 454 | modified_type->GetByteSize(), nullptr, |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 455 | LLDB_INVALID_UID, Type::eEncodingIsUID, decl, |
| 456 | ct, Type::eResolveStateFull); |
| 457 | } |
| 458 | |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 459 | lldb::TypeSP |
| 460 | SymbolFileNativePDB::CreatePointerType(PdbTypeSymId type_id, |
| 461 | const llvm::codeview::PointerRecord &pr, |
| 462 | CompilerType ct) { |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 463 | TypeSP pointee = GetOrCreateType(pr.ReferentType); |
Zachary Turner | 544a66d8 | 2018-11-01 16:37:29 +0000 | [diff] [blame] | 464 | if (!pointee) |
| 465 | return nullptr; |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 466 | |
| 467 | if (pr.isPointerToMember()) { |
| 468 | MemberPointerInfo mpi = pr.getMemberInfo(); |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 469 | GetOrCreateType(mpi.ContainingType); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 470 | } |
| 471 | |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 472 | Declaration decl; |
| 473 | return std::make_shared<Type>(toOpaqueUid(type_id), this, ConstString(), |
| 474 | pr.getSize(), nullptr, LLDB_INVALID_UID, |
| 475 | Type::eEncodingIsUID, decl, ct, |
| 476 | Type::eResolveStateFull); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 477 | } |
| 478 | |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 479 | lldb::TypeSP SymbolFileNativePDB::CreateSimpleType(TypeIndex ti, |
| 480 | CompilerType ct) { |
Zachary Turner | 9fbf935 | 2018-11-16 03:16:27 +0000 | [diff] [blame] | 481 | uint64_t uid = toOpaqueUid(PdbTypeSymId(ti, false)); |
Zachary Turner | 544a66d8 | 2018-11-01 16:37:29 +0000 | [diff] [blame] | 482 | if (ti == TypeIndex::NullptrT()) { |
Zachary Turner | 544a66d8 | 2018-11-01 16:37:29 +0000 | [diff] [blame] | 483 | Declaration decl; |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 484 | return std::make_shared<Type>( |
| 485 | uid, this, ConstString("std::nullptr_t"), 0, nullptr, LLDB_INVALID_UID, |
| 486 | Type::eEncodingIsUID, decl, ct, Type::eResolveStateFull); |
Zachary Turner | 544a66d8 | 2018-11-01 16:37:29 +0000 | [diff] [blame] | 487 | } |
| 488 | |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 489 | if (ti.getSimpleMode() != SimpleTypeMode::Direct) { |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 490 | TypeSP direct_sp = GetOrCreateType(ti.makeDirect()); |
Zachary Turner | 71ebb72 | 2018-10-23 22:15:05 +0000 | [diff] [blame] | 491 | uint32_t pointer_size = 0; |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 492 | switch (ti.getSimpleMode()) { |
| 493 | case SimpleTypeMode::FarPointer32: |
| 494 | case SimpleTypeMode::NearPointer32: |
| 495 | pointer_size = 4; |
| 496 | break; |
| 497 | case SimpleTypeMode::NearPointer64: |
| 498 | pointer_size = 8; |
| 499 | break; |
| 500 | default: |
| 501 | // 128-bit and 16-bit pointers unsupported. |
| 502 | return nullptr; |
| 503 | } |
| 504 | Declaration decl; |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 505 | return std::make_shared<Type>( |
| 506 | uid, this, ConstString(), pointer_size, nullptr, LLDB_INVALID_UID, |
| 507 | Type::eEncodingIsUID, decl, ct, Type::eResolveStateFull); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 508 | } |
| 509 | |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 510 | if (ti.getSimpleKind() == SimpleTypeKind::NotTranslated) |
| 511 | return nullptr; |
| 512 | |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 513 | size_t size = GetTypeSizeForSimpleKind(ti.getSimpleKind()); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 514 | llvm::StringRef type_name = GetSimpleTypeName(ti.getSimpleKind()); |
| 515 | |
| 516 | Declaration decl; |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 517 | return std::make_shared<Type>(uid, this, ConstString(type_name), size, |
| 518 | nullptr, LLDB_INVALID_UID, Type::eEncodingIsUID, |
| 519 | decl, ct, Type::eResolveStateFull); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 520 | } |
| 521 | |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 522 | static std::string GetUnqualifiedTypeName(const TagRecord &record) { |
Zachary Turner | 44f1951 | 2019-01-10 20:57:32 +0000 | [diff] [blame] | 523 | if (!record.hasUniqueName()) { |
| 524 | MSVCUndecoratedNameParser parser(record.Name); |
| 525 | llvm::ArrayRef<MSVCUndecoratedNameSpecifier> specs = parser.GetSpecifiers(); |
| 526 | |
| 527 | return specs.back().GetBaseName(); |
| 528 | } |
| 529 | |
Zachary Turner | 056e4ab | 2018-11-08 18:50:11 +0000 | [diff] [blame] | 530 | llvm::ms_demangle::Demangler demangler; |
| 531 | StringView sv(record.UniqueName.begin(), record.UniqueName.size()); |
| 532 | llvm::ms_demangle::TagTypeNode *ttn = demangler.parseTagUniqueName(sv); |
Zachary Turner | 44f1951 | 2019-01-10 20:57:32 +0000 | [diff] [blame] | 533 | if (demangler.Error) |
| 534 | return record.Name; |
| 535 | |
Zachary Turner | 056e4ab | 2018-11-08 18:50:11 +0000 | [diff] [blame] | 536 | llvm::ms_demangle::IdentifierNode *idn = |
| 537 | ttn->QualifiedName->getUnqualifiedIdentifier(); |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 538 | return idn->toString(); |
Zachary Turner | 056e4ab | 2018-11-08 18:50:11 +0000 | [diff] [blame] | 539 | } |
| 540 | |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 541 | lldb::TypeSP |
| 542 | SymbolFileNativePDB::CreateClassStructUnion(PdbTypeSymId type_id, |
| 543 | const TagRecord &record, |
| 544 | size_t size, CompilerType ct) { |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 545 | |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 546 | std::string uname = GetUnqualifiedTypeName(record); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 547 | |
| 548 | // FIXME: Search IPI stream for LF_UDT_MOD_SRC_LINE. |
| 549 | Declaration decl; |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 550 | return std::make_shared<Type>(toOpaqueUid(type_id), this, ConstString(uname), |
| 551 | size, nullptr, LLDB_INVALID_UID, |
| 552 | Type::eEncodingIsUID, decl, ct, |
| 553 | Type::eResolveStateForward); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 554 | } |
| 555 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 556 | lldb::TypeSP SymbolFileNativePDB::CreateTagType(PdbTypeSymId type_id, |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 557 | const ClassRecord &cr, |
| 558 | CompilerType ct) { |
| 559 | return CreateClassStructUnion(type_id, cr, cr.getSize(), ct); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 560 | } |
| 561 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 562 | lldb::TypeSP SymbolFileNativePDB::CreateTagType(PdbTypeSymId type_id, |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 563 | const UnionRecord &ur, |
| 564 | CompilerType ct) { |
| 565 | return CreateClassStructUnion(type_id, ur, ur.getSize(), ct); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 566 | } |
| 567 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 568 | lldb::TypeSP SymbolFileNativePDB::CreateTagType(PdbTypeSymId type_id, |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 569 | const EnumRecord &er, |
| 570 | CompilerType ct) { |
| 571 | std::string uname = GetUnqualifiedTypeName(er); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 572 | |
| 573 | Declaration decl; |
| 574 | TypeSP underlying_type = GetOrCreateType(er.UnderlyingType); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 575 | |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 576 | return std::make_shared<lldb_private::Type>( |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 577 | toOpaqueUid(type_id), this, ConstString(uname), |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 578 | underlying_type->GetByteSize(), nullptr, LLDB_INVALID_UID, |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 579 | lldb_private::Type::eEncodingIsUID, decl, ct, |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 580 | lldb_private::Type::eResolveStateForward); |
| 581 | } |
| 582 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 583 | TypeSP SymbolFileNativePDB::CreateArrayType(PdbTypeSymId type_id, |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 584 | const ArrayRecord &ar, |
| 585 | CompilerType ct) { |
Zachary Turner | 511bff2 | 2018-10-30 18:57:08 +0000 | [diff] [blame] | 586 | TypeSP element_type = GetOrCreateType(ar.ElementType); |
Zachary Turner | 511bff2 | 2018-10-30 18:57:08 +0000 | [diff] [blame] | 587 | |
| 588 | Declaration decl; |
| 589 | TypeSP array_sp = std::make_shared<lldb_private::Type>( |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 590 | toOpaqueUid(type_id), this, ConstString(), ar.Size, nullptr, |
| 591 | LLDB_INVALID_UID, lldb_private::Type::eEncodingIsUID, decl, ct, |
| 592 | lldb_private::Type::eResolveStateFull); |
Zachary Turner | 511bff2 | 2018-10-30 18:57:08 +0000 | [diff] [blame] | 593 | array_sp->SetEncodingType(element_type.get()); |
| 594 | return array_sp; |
| 595 | } |
| 596 | |
Aleksandr Urakov | 869f934 | 2019-05-13 09:41:57 +0000 | [diff] [blame] | 597 | |
| 598 | TypeSP SymbolFileNativePDB::CreateFunctionType(PdbTypeSymId type_id, |
| 599 | const MemberFunctionRecord &mfr, |
| 600 | CompilerType ct) { |
| 601 | Declaration decl; |
| 602 | return std::make_shared<lldb_private::Type>( |
| 603 | toOpaqueUid(type_id), this, ConstString(), 0, nullptr, LLDB_INVALID_UID, |
| 604 | lldb_private::Type::eEncodingIsUID, decl, ct, |
| 605 | lldb_private::Type::eResolveStateFull); |
| 606 | } |
| 607 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 608 | TypeSP SymbolFileNativePDB::CreateProcedureType(PdbTypeSymId type_id, |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 609 | const ProcedureRecord &pr, |
| 610 | CompilerType ct) { |
Zachary Turner | 544a66d8 | 2018-11-01 16:37:29 +0000 | [diff] [blame] | 611 | Declaration decl; |
| 612 | return std::make_shared<lldb_private::Type>( |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 613 | toOpaqueUid(type_id), this, ConstString(), 0, nullptr, LLDB_INVALID_UID, |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 614 | lldb_private::Type::eEncodingIsUID, decl, ct, |
Zachary Turner | 544a66d8 | 2018-11-01 16:37:29 +0000 | [diff] [blame] | 615 | lldb_private::Type::eResolveStateFull); |
| 616 | } |
| 617 | |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 618 | TypeSP SymbolFileNativePDB::CreateType(PdbTypeSymId type_id, CompilerType ct) { |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 619 | if (type_id.index.isSimple()) |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 620 | return CreateSimpleType(type_id.index, ct); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 621 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 622 | TpiStream &stream = type_id.is_ipi ? m_index->ipi() : m_index->tpi(); |
| 623 | CVType cvt = stream.getType(type_id.index); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 624 | |
| 625 | if (cvt.kind() == LF_MODIFIER) { |
| 626 | ModifierRecord modifier; |
| 627 | llvm::cantFail( |
| 628 | TypeDeserializer::deserializeAs<ModifierRecord>(cvt, modifier)); |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 629 | return CreateModifierType(type_id, modifier, ct); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 630 | } |
| 631 | |
| 632 | if (cvt.kind() == LF_POINTER) { |
| 633 | PointerRecord pointer; |
| 634 | llvm::cantFail( |
| 635 | TypeDeserializer::deserializeAs<PointerRecord>(cvt, pointer)); |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 636 | return CreatePointerType(type_id, pointer, ct); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 637 | } |
| 638 | |
| 639 | if (IsClassRecord(cvt.kind())) { |
| 640 | ClassRecord cr; |
| 641 | llvm::cantFail(TypeDeserializer::deserializeAs<ClassRecord>(cvt, cr)); |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 642 | return CreateTagType(type_id, cr, ct); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 643 | } |
| 644 | |
| 645 | if (cvt.kind() == LF_ENUM) { |
| 646 | EnumRecord er; |
| 647 | llvm::cantFail(TypeDeserializer::deserializeAs<EnumRecord>(cvt, er)); |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 648 | return CreateTagType(type_id, er, ct); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 649 | } |
| 650 | |
| 651 | if (cvt.kind() == LF_UNION) { |
| 652 | UnionRecord ur; |
| 653 | llvm::cantFail(TypeDeserializer::deserializeAs<UnionRecord>(cvt, ur)); |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 654 | return CreateTagType(type_id, ur, ct); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 655 | } |
| 656 | |
Zachary Turner | 511bff2 | 2018-10-30 18:57:08 +0000 | [diff] [blame] | 657 | if (cvt.kind() == LF_ARRAY) { |
| 658 | ArrayRecord ar; |
| 659 | llvm::cantFail(TypeDeserializer::deserializeAs<ArrayRecord>(cvt, ar)); |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 660 | return CreateArrayType(type_id, ar, ct); |
Zachary Turner | 511bff2 | 2018-10-30 18:57:08 +0000 | [diff] [blame] | 661 | } |
| 662 | |
Zachary Turner | 544a66d8 | 2018-11-01 16:37:29 +0000 | [diff] [blame] | 663 | if (cvt.kind() == LF_PROCEDURE) { |
| 664 | ProcedureRecord pr; |
| 665 | llvm::cantFail(TypeDeserializer::deserializeAs<ProcedureRecord>(cvt, pr)); |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 666 | return CreateProcedureType(type_id, pr, ct); |
Zachary Turner | 544a66d8 | 2018-11-01 16:37:29 +0000 | [diff] [blame] | 667 | } |
Aleksandr Urakov | 869f934 | 2019-05-13 09:41:57 +0000 | [diff] [blame] | 668 | if (cvt.kind() == LF_MFUNCTION) { |
| 669 | MemberFunctionRecord mfr; |
| 670 | llvm::cantFail(TypeDeserializer::deserializeAs<MemberFunctionRecord>(cvt, mfr)); |
| 671 | return CreateFunctionType(type_id, mfr, ct); |
| 672 | } |
Zachary Turner | 544a66d8 | 2018-11-01 16:37:29 +0000 | [diff] [blame] | 673 | |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 674 | return nullptr; |
| 675 | } |
| 676 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 677 | TypeSP SymbolFileNativePDB::CreateAndCacheType(PdbTypeSymId type_id) { |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 678 | // If they search for a UDT which is a forward ref, try and resolve the full |
| 679 | // decl and just map the forward ref uid to the full decl record. |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 680 | llvm::Optional<PdbTypeSymId> full_decl_uid; |
| 681 | if (IsForwardRefUdt(type_id, m_index->tpi())) { |
| 682 | auto expected_full_ti = |
| 683 | m_index->tpi().findFullDeclForForwardRef(type_id.index); |
| 684 | if (!expected_full_ti) |
| 685 | llvm::consumeError(expected_full_ti.takeError()); |
| 686 | else if (*expected_full_ti != type_id.index) { |
Zachary Turner | 9fbf935 | 2018-11-16 03:16:27 +0000 | [diff] [blame] | 687 | full_decl_uid = PdbTypeSymId(*expected_full_ti, false); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 688 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 689 | // It's possible that a lookup would occur for the full decl causing it |
| 690 | // to be cached, then a second lookup would occur for the forward decl. |
| 691 | // We don't want to create a second full decl, so make sure the full |
| 692 | // decl hasn't already been cached. |
| 693 | auto full_iter = m_types.find(toOpaqueUid(*full_decl_uid)); |
| 694 | if (full_iter != m_types.end()) { |
| 695 | TypeSP result = full_iter->second; |
| 696 | // Map the forward decl to the TypeSP for the full decl so we can take |
| 697 | // the fast path next time. |
| 698 | m_types[toOpaqueUid(type_id)] = result; |
| 699 | return result; |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 700 | } |
| 701 | } |
| 702 | } |
| 703 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 704 | PdbTypeSymId best_decl_id = full_decl_uid ? *full_decl_uid : type_id; |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 705 | |
| 706 | clang::QualType qt = m_ast->GetOrCreateType(best_decl_id); |
| 707 | |
| 708 | TypeSP result = CreateType(best_decl_id, m_ast->ToCompilerType(qt)); |
Zachary Turner | 544a66d8 | 2018-11-01 16:37:29 +0000 | [diff] [blame] | 709 | if (!result) |
| 710 | return nullptr; |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 711 | |
| 712 | uint64_t best_uid = toOpaqueUid(best_decl_id); |
| 713 | m_types[best_uid] = result; |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 714 | // If we had both a forward decl and a full decl, make both point to the new |
| 715 | // type. |
| 716 | if (full_decl_uid) |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 717 | m_types[toOpaqueUid(type_id)] = result; |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 718 | |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 719 | return result; |
| 720 | } |
| 721 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 722 | TypeSP SymbolFileNativePDB::GetOrCreateType(PdbTypeSymId type_id) { |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 723 | // We can't use try_emplace / overwrite here because the process of creating |
| 724 | // a type could create nested types, which could invalidate iterators. So |
| 725 | // we have to do a 2-phase lookup / insert. |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 726 | auto iter = m_types.find(toOpaqueUid(type_id)); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 727 | if (iter != m_types.end()) |
| 728 | return iter->second; |
| 729 | |
Zachary Turner | 44f1951 | 2019-01-10 20:57:32 +0000 | [diff] [blame] | 730 | TypeSP type = CreateAndCacheType(type_id); |
| 731 | if (type) |
| 732 | m_obj_file->GetModule()->GetTypeList()->Insert(type); |
| 733 | return type; |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 734 | } |
| 735 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 736 | VariableSP SymbolFileNativePDB::CreateGlobalVariable(PdbGlobalSymId var_id) { |
| 737 | CVSymbol sym = m_index->symrecords().readRecord(var_id.offset); |
Zachary Turner | 2af3416 | 2018-11-13 20:07:57 +0000 | [diff] [blame] | 738 | if (sym.kind() == S_CONSTANT) |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 739 | return CreateConstantSymbol(var_id, sym); |
Zachary Turner | 2af3416 | 2018-11-13 20:07:57 +0000 | [diff] [blame] | 740 | |
Zachary Turner | 9f72795 | 2018-10-26 09:06:38 +0000 | [diff] [blame] | 741 | lldb::ValueType scope = eValueTypeInvalid; |
| 742 | TypeIndex ti; |
| 743 | llvm::StringRef name; |
| 744 | lldb::addr_t addr = 0; |
| 745 | uint16_t section = 0; |
| 746 | uint32_t offset = 0; |
| 747 | bool is_external = false; |
| 748 | switch (sym.kind()) { |
| 749 | case S_GDATA32: |
| 750 | is_external = true; |
| 751 | LLVM_FALLTHROUGH; |
| 752 | case S_LDATA32: { |
| 753 | DataSym ds(sym.kind()); |
| 754 | llvm::cantFail(SymbolDeserializer::deserializeAs<DataSym>(sym, ds)); |
| 755 | ti = ds.Type; |
| 756 | scope = (sym.kind() == S_GDATA32) ? eValueTypeVariableGlobal |
| 757 | : eValueTypeVariableStatic; |
| 758 | name = ds.Name; |
| 759 | section = ds.Segment; |
| 760 | offset = ds.DataOffset; |
| 761 | addr = m_index->MakeVirtualAddress(ds.Segment, ds.DataOffset); |
| 762 | break; |
| 763 | } |
| 764 | case S_GTHREAD32: |
| 765 | is_external = true; |
| 766 | LLVM_FALLTHROUGH; |
| 767 | case S_LTHREAD32: { |
| 768 | ThreadLocalDataSym tlds(sym.kind()); |
| 769 | llvm::cantFail( |
| 770 | SymbolDeserializer::deserializeAs<ThreadLocalDataSym>(sym, tlds)); |
| 771 | ti = tlds.Type; |
| 772 | name = tlds.Name; |
| 773 | section = tlds.Segment; |
| 774 | offset = tlds.DataOffset; |
| 775 | addr = m_index->MakeVirtualAddress(tlds.Segment, tlds.DataOffset); |
| 776 | scope = eValueTypeVariableThreadLocal; |
| 777 | break; |
| 778 | } |
| 779 | default: |
| 780 | llvm_unreachable("unreachable!"); |
| 781 | } |
| 782 | |
| 783 | CompUnitSP comp_unit; |
| 784 | llvm::Optional<uint16_t> modi = m_index->GetModuleIndexForVa(addr); |
| 785 | if (modi) { |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 786 | CompilandIndexItem &cci = m_index->compilands().GetOrCreateCompiland(*modi); |
Zachary Turner | 9f72795 | 2018-10-26 09:06:38 +0000 | [diff] [blame] | 787 | comp_unit = GetOrCreateCompileUnit(cci); |
| 788 | } |
| 789 | |
| 790 | Declaration decl; |
Zachary Turner | 9fbf935 | 2018-11-16 03:16:27 +0000 | [diff] [blame] | 791 | PdbTypeSymId tid(ti, false); |
Zachary Turner | 9f72795 | 2018-10-26 09:06:38 +0000 | [diff] [blame] | 792 | SymbolFileTypeSP type_sp = |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 793 | std::make_shared<SymbolFileType>(*this, toOpaqueUid(tid)); |
Zachary Turner | 9f72795 | 2018-10-26 09:06:38 +0000 | [diff] [blame] | 794 | Variable::RangeList ranges; |
| 795 | |
Zachary Turner | 2256633 | 2019-01-02 18:33:54 +0000 | [diff] [blame] | 796 | m_ast->GetOrCreateVariableDecl(var_id); |
Zachary Turner | 3790029 | 2018-12-20 23:32:37 +0000 | [diff] [blame] | 797 | |
Zachary Turner | 9f72795 | 2018-10-26 09:06:38 +0000 | [diff] [blame] | 798 | DWARFExpression location = MakeGlobalLocationExpression( |
| 799 | section, offset, GetObjectFile()->GetModule()); |
| 800 | |
| 801 | std::string global_name("::"); |
| 802 | global_name += name; |
| 803 | VariableSP var_sp = std::make_shared<Variable>( |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 804 | toOpaqueUid(var_id), name.str().c_str(), global_name.c_str(), type_sp, |
Zachary Turner | 9f72795 | 2018-10-26 09:06:38 +0000 | [diff] [blame] | 805 | scope, comp_unit.get(), ranges, &decl, location, is_external, false, |
| 806 | false); |
| 807 | var_sp->SetLocationIsConstantValueData(false); |
| 808 | |
| 809 | return var_sp; |
| 810 | } |
| 811 | |
Zachary Turner | 2af3416 | 2018-11-13 20:07:57 +0000 | [diff] [blame] | 812 | lldb::VariableSP |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 813 | SymbolFileNativePDB::CreateConstantSymbol(PdbGlobalSymId var_id, |
Zachary Turner | 2af3416 | 2018-11-13 20:07:57 +0000 | [diff] [blame] | 814 | const CVSymbol &cvs) { |
| 815 | TpiStream &tpi = m_index->tpi(); |
| 816 | ConstantSym constant(cvs.kind()); |
| 817 | |
| 818 | llvm::cantFail(SymbolDeserializer::deserializeAs<ConstantSym>(cvs, constant)); |
| 819 | std::string global_name("::"); |
| 820 | global_name += constant.Name; |
Zachary Turner | 9fbf935 | 2018-11-16 03:16:27 +0000 | [diff] [blame] | 821 | PdbTypeSymId tid(constant.Type, false); |
Zachary Turner | 2af3416 | 2018-11-13 20:07:57 +0000 | [diff] [blame] | 822 | SymbolFileTypeSP type_sp = |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 823 | std::make_shared<SymbolFileType>(*this, toOpaqueUid(tid)); |
Zachary Turner | 2af3416 | 2018-11-13 20:07:57 +0000 | [diff] [blame] | 824 | |
| 825 | Declaration decl; |
| 826 | Variable::RangeList ranges; |
| 827 | ModuleSP module = GetObjectFile()->GetModule(); |
Zachary Turner | a93458b | 2018-12-06 17:49:15 +0000 | [diff] [blame] | 828 | DWARFExpression location = MakeConstantLocationExpression( |
| 829 | constant.Type, tpi, constant.Value, module); |
Zachary Turner | 2af3416 | 2018-11-13 20:07:57 +0000 | [diff] [blame] | 830 | |
| 831 | VariableSP var_sp = std::make_shared<Variable>( |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 832 | toOpaqueUid(var_id), constant.Name.str().c_str(), global_name.c_str(), |
Zachary Turner | 2af3416 | 2018-11-13 20:07:57 +0000 | [diff] [blame] | 833 | type_sp, eValueTypeVariableGlobal, module.get(), ranges, &decl, location, |
| 834 | false, false, false); |
| 835 | var_sp->SetLocationIsConstantValueData(true); |
| 836 | return var_sp; |
| 837 | } |
| 838 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 839 | VariableSP |
| 840 | SymbolFileNativePDB::GetOrCreateGlobalVariable(PdbGlobalSymId var_id) { |
| 841 | auto emplace_result = m_global_vars.try_emplace(toOpaqueUid(var_id), nullptr); |
Zachary Turner | 9f72795 | 2018-10-26 09:06:38 +0000 | [diff] [blame] | 842 | if (emplace_result.second) |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 843 | emplace_result.first->second = CreateGlobalVariable(var_id); |
Zachary Turner | 9f72795 | 2018-10-26 09:06:38 +0000 | [diff] [blame] | 844 | |
| 845 | return emplace_result.first->second; |
| 846 | } |
| 847 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 848 | lldb::TypeSP SymbolFileNativePDB::GetOrCreateType(TypeIndex ti) { |
Zachary Turner | 9fbf935 | 2018-11-16 03:16:27 +0000 | [diff] [blame] | 849 | return GetOrCreateType(PdbTypeSymId(ti, false)); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 850 | } |
| 851 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 852 | FunctionSP SymbolFileNativePDB::GetOrCreateFunction(PdbCompilandSymId func_id, |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 853 | CompileUnit &comp_unit) { |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 854 | auto emplace_result = m_functions.try_emplace(toOpaqueUid(func_id), nullptr); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 855 | if (emplace_result.second) |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 856 | emplace_result.first->second = CreateFunction(func_id, comp_unit); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 857 | |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 858 | return emplace_result.first->second; |
| 859 | } |
| 860 | |
| 861 | CompUnitSP |
| 862 | SymbolFileNativePDB::GetOrCreateCompileUnit(const CompilandIndexItem &cci) { |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 863 | |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 864 | auto emplace_result = |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 865 | m_compilands.try_emplace(toOpaqueUid(cci.m_id), nullptr); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 866 | if (emplace_result.second) |
| 867 | emplace_result.first->second = CreateCompileUnit(cci); |
| 868 | |
| 869 | lldbassert(emplace_result.first->second); |
| 870 | return emplace_result.first->second; |
| 871 | } |
| 872 | |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 873 | Block &SymbolFileNativePDB::GetOrCreateBlock(PdbCompilandSymId block_id) { |
| 874 | auto iter = m_blocks.find(toOpaqueUid(block_id)); |
| 875 | if (iter != m_blocks.end()) |
| 876 | return *iter->second; |
| 877 | |
| 878 | return CreateBlock(block_id); |
| 879 | } |
| 880 | |
Zachary Turner | 2256633 | 2019-01-02 18:33:54 +0000 | [diff] [blame] | 881 | void SymbolFileNativePDB::ParseDeclsForContext( |
| 882 | lldb_private::CompilerDeclContext decl_ctx) { |
| 883 | clang::DeclContext *context = m_ast->FromCompilerDeclContext(decl_ctx); |
| 884 | if (!context) |
| 885 | return; |
| 886 | m_ast->ParseDeclsForContext(*context); |
| 887 | } |
| 888 | |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 889 | lldb::CompUnitSP SymbolFileNativePDB::ParseCompileUnitAtIndex(uint32_t index) { |
| 890 | if (index >= GetNumCompileUnits()) |
| 891 | return CompUnitSP(); |
| 892 | lldbassert(index < UINT16_MAX); |
| 893 | if (index >= UINT16_MAX) |
| 894 | return nullptr; |
| 895 | |
| 896 | CompilandIndexItem &item = m_index->compilands().GetOrCreateCompiland(index); |
| 897 | |
| 898 | return GetOrCreateCompileUnit(item); |
| 899 | } |
| 900 | |
Zachary Turner | 863f8c1 | 2019-01-11 18:03:20 +0000 | [diff] [blame] | 901 | lldb::LanguageType SymbolFileNativePDB::ParseLanguage(CompileUnit &comp_unit) { |
| 902 | PdbSymUid uid(comp_unit.GetID()); |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 903 | lldbassert(uid.kind() == PdbSymUidKind::Compiland); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 904 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 905 | CompilandIndexItem *item = |
| 906 | m_index->compilands().GetCompiland(uid.asCompiland().modi); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 907 | lldbassert(item); |
| 908 | if (!item->m_compile_opts) |
| 909 | return lldb::eLanguageTypeUnknown; |
| 910 | |
| 911 | return TranslateLanguage(item->m_compile_opts->getLanguage()); |
| 912 | } |
| 913 | |
Zachary Turner | b3130b4 | 2019-01-02 18:32:50 +0000 | [diff] [blame] | 914 | void SymbolFileNativePDB::AddSymbols(Symtab &symtab) { return; } |
| 915 | |
Zachary Turner | 863f8c1 | 2019-01-11 18:03:20 +0000 | [diff] [blame] | 916 | size_t SymbolFileNativePDB::ParseFunctions(CompileUnit &comp_unit) { |
| 917 | PdbSymUid uid{comp_unit.GetID()}; |
Zachary Turner | 44f1951 | 2019-01-10 20:57:32 +0000 | [diff] [blame] | 918 | lldbassert(uid.kind() == PdbSymUidKind::Compiland); |
| 919 | uint16_t modi = uid.asCompiland().modi; |
| 920 | CompilandIndexItem &cii = m_index->compilands().GetOrCreateCompiland(modi); |
| 921 | |
Zachary Turner | 863f8c1 | 2019-01-11 18:03:20 +0000 | [diff] [blame] | 922 | size_t count = comp_unit.GetNumFunctions(); |
Zachary Turner | 44f1951 | 2019-01-10 20:57:32 +0000 | [diff] [blame] | 923 | const CVSymbolArray &syms = cii.m_debug_stream.getSymbolArray(); |
| 924 | for (auto iter = syms.begin(); iter != syms.end(); ++iter) { |
| 925 | if (iter->kind() != S_LPROC32 && iter->kind() != S_GPROC32) |
| 926 | continue; |
| 927 | |
| 928 | PdbCompilandSymId sym_id{modi, iter.offset()}; |
| 929 | |
Zachary Turner | 863f8c1 | 2019-01-11 18:03:20 +0000 | [diff] [blame] | 930 | FunctionSP func = GetOrCreateFunction(sym_id, comp_unit); |
Zachary Turner | 44f1951 | 2019-01-10 20:57:32 +0000 | [diff] [blame] | 931 | } |
| 932 | |
Zachary Turner | 863f8c1 | 2019-01-11 18:03:20 +0000 | [diff] [blame] | 933 | size_t new_count = comp_unit.GetNumFunctions(); |
Zachary Turner | 44f1951 | 2019-01-10 20:57:32 +0000 | [diff] [blame] | 934 | lldbassert(new_count >= count); |
| 935 | return new_count - count; |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 936 | } |
| 937 | |
| 938 | static bool NeedsResolvedCompileUnit(uint32_t resolve_scope) { |
| 939 | // If any of these flags are set, we need to resolve the compile unit. |
| 940 | uint32_t flags = eSymbolContextCompUnit; |
| 941 | flags |= eSymbolContextVariable; |
| 942 | flags |= eSymbolContextFunction; |
| 943 | flags |= eSymbolContextBlock; |
| 944 | flags |= eSymbolContextLineEntry; |
| 945 | return (resolve_scope & flags) != 0; |
| 946 | } |
| 947 | |
Zachary Turner | 991e445 | 2018-10-25 20:45:19 +0000 | [diff] [blame] | 948 | uint32_t SymbolFileNativePDB::ResolveSymbolContext( |
| 949 | const Address &addr, SymbolContextItem resolve_scope, SymbolContext &sc) { |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 950 | uint32_t resolved_flags = 0; |
| 951 | lldb::addr_t file_addr = addr.GetFileAddress(); |
| 952 | |
| 953 | if (NeedsResolvedCompileUnit(resolve_scope)) { |
| 954 | llvm::Optional<uint16_t> modi = m_index->GetModuleIndexForVa(file_addr); |
| 955 | if (!modi) |
| 956 | return 0; |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 957 | CompilandIndexItem *cci = m_index->compilands().GetCompiland(*modi); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 958 | if (!cci) |
| 959 | return 0; |
| 960 | |
| 961 | sc.comp_unit = GetOrCreateCompileUnit(*cci).get(); |
| 962 | resolved_flags |= eSymbolContextCompUnit; |
| 963 | } |
| 964 | |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 965 | if (resolve_scope & eSymbolContextFunction || |
| 966 | resolve_scope & eSymbolContextBlock) { |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 967 | lldbassert(sc.comp_unit); |
| 968 | std::vector<SymbolAndUid> matches = m_index->FindSymbolsByVa(file_addr); |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 969 | // Search the matches in reverse. This way if there are multiple matches |
| 970 | // (for example we are 3 levels deep in a nested scope) it will find the |
| 971 | // innermost one first. |
| 972 | for (const auto &match : llvm::reverse(matches)) { |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 973 | if (match.uid.kind() != PdbSymUidKind::CompilandSym) |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 974 | continue; |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 975 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 976 | PdbCompilandSymId csid = match.uid.asCompilandSym(); |
| 977 | CVSymbol cvs = m_index->ReadSymbolRecord(csid); |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 978 | PDB_SymType type = CVSymToPDBSym(cvs.kind()); |
| 979 | if (type != PDB_SymType::Function && type != PDB_SymType::Block) |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 980 | continue; |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 981 | if (type == PDB_SymType::Function) { |
| 982 | sc.function = GetOrCreateFunction(csid, *sc.comp_unit).get(); |
| 983 | sc.block = sc.GetFunctionBlock(); |
| 984 | } |
| 985 | |
| 986 | if (type == PDB_SymType::Block) { |
| 987 | sc.block = &GetOrCreateBlock(csid); |
| 988 | sc.function = sc.block->CalculateSymbolContextFunction(); |
| 989 | } |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 990 | resolved_flags |= eSymbolContextFunction; |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 991 | resolved_flags |= eSymbolContextBlock; |
| 992 | break; |
| 993 | } |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 994 | } |
| 995 | |
| 996 | if (resolve_scope & eSymbolContextLineEntry) { |
| 997 | lldbassert(sc.comp_unit); |
| 998 | if (auto *line_table = sc.comp_unit->GetLineTable()) { |
| 999 | if (line_table->FindLineEntryByAddress(addr, sc.line_entry)) |
| 1000 | resolved_flags |= eSymbolContextLineEntry; |
| 1001 | } |
| 1002 | } |
| 1003 | |
| 1004 | return resolved_flags; |
| 1005 | } |
| 1006 | |
Zachary Turner | b3130b4 | 2019-01-02 18:32:50 +0000 | [diff] [blame] | 1007 | uint32_t SymbolFileNativePDB::ResolveSymbolContext( |
| 1008 | const FileSpec &file_spec, uint32_t line, bool check_inlines, |
| 1009 | lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list) { |
| 1010 | return 0; |
| 1011 | } |
| 1012 | |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1013 | static void AppendLineEntryToSequence(LineTable &table, LineSequence &sequence, |
| 1014 | const CompilandIndexItem &cci, |
| 1015 | lldb::addr_t base_addr, |
| 1016 | uint32_t file_number, |
| 1017 | const LineFragmentHeader &block, |
| 1018 | const LineNumberEntry &cur) { |
| 1019 | LineInfo cur_info(cur.Flags); |
| 1020 | |
| 1021 | if (cur_info.isAlwaysStepInto() || cur_info.isNeverStepInto()) |
| 1022 | return; |
| 1023 | |
| 1024 | uint64_t addr = base_addr + cur.Offset; |
| 1025 | |
| 1026 | bool is_statement = cur_info.isStatement(); |
| 1027 | bool is_prologue = IsFunctionPrologue(cci, addr); |
| 1028 | bool is_epilogue = IsFunctionEpilogue(cci, addr); |
| 1029 | |
| 1030 | uint32_t lno = cur_info.getStartLine(); |
| 1031 | |
| 1032 | table.AppendLineEntryToSequence(&sequence, addr, lno, 0, file_number, |
| 1033 | is_statement, false, is_prologue, is_epilogue, |
| 1034 | false); |
| 1035 | } |
| 1036 | |
| 1037 | static void TerminateLineSequence(LineTable &table, |
| 1038 | const LineFragmentHeader &block, |
| 1039 | lldb::addr_t base_addr, uint32_t file_number, |
| 1040 | uint32_t last_line, |
| 1041 | std::unique_ptr<LineSequence> seq) { |
| 1042 | // The end is always a terminal entry, so insert it regardless. |
| 1043 | table.AppendLineEntryToSequence(seq.get(), base_addr + block.CodeSize, |
| 1044 | last_line, 0, file_number, false, false, |
| 1045 | false, false, true); |
| 1046 | table.InsertSequence(seq.release()); |
| 1047 | } |
| 1048 | |
Zachary Turner | 863f8c1 | 2019-01-11 18:03:20 +0000 | [diff] [blame] | 1049 | bool SymbolFileNativePDB::ParseLineTable(CompileUnit &comp_unit) { |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1050 | // Unfortunately LLDB is set up to parse the entire compile unit line table |
| 1051 | // all at once, even if all it really needs is line info for a specific |
| 1052 | // function. In the future it would be nice if it could set the sc.m_function |
| 1053 | // member, and we could only get the line info for the function in question. |
Zachary Turner | 863f8c1 | 2019-01-11 18:03:20 +0000 | [diff] [blame] | 1054 | PdbSymUid cu_id(comp_unit.GetID()); |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 1055 | lldbassert(cu_id.kind() == PdbSymUidKind::Compiland); |
| 1056 | CompilandIndexItem *cci = |
| 1057 | m_index->compilands().GetCompiland(cu_id.asCompiland().modi); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1058 | lldbassert(cci); |
Zachary Turner | 863f8c1 | 2019-01-11 18:03:20 +0000 | [diff] [blame] | 1059 | auto line_table = llvm::make_unique<LineTable>(&comp_unit); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1060 | |
| 1061 | // This is basically a copy of the .debug$S subsections from all original COFF |
| 1062 | // object files merged together with address relocations applied. We are |
| 1063 | // looking for all DEBUG_S_LINES subsections. |
| 1064 | for (const DebugSubsectionRecord &dssr : |
| 1065 | cci->m_debug_stream.getSubsectionsArray()) { |
| 1066 | if (dssr.kind() != DebugSubsectionKind::Lines) |
| 1067 | continue; |
| 1068 | |
| 1069 | DebugLinesSubsectionRef lines; |
| 1070 | llvm::BinaryStreamReader reader(dssr.getRecordData()); |
| 1071 | if (auto EC = lines.initialize(reader)) { |
| 1072 | llvm::consumeError(std::move(EC)); |
| 1073 | return false; |
| 1074 | } |
| 1075 | |
| 1076 | const LineFragmentHeader *lfh = lines.header(); |
| 1077 | uint64_t virtual_addr = |
| 1078 | m_index->MakeVirtualAddress(lfh->RelocSegment, lfh->RelocOffset); |
| 1079 | |
| 1080 | const auto &checksums = cci->m_strings.checksums().getArray(); |
| 1081 | const auto &strings = cci->m_strings.strings(); |
| 1082 | for (const LineColumnEntry &group : lines) { |
| 1083 | // Indices in this structure are actually offsets of records in the |
| 1084 | // DEBUG_S_FILECHECKSUMS subsection. Those entries then have an index |
| 1085 | // into the global PDB string table. |
| 1086 | auto iter = checksums.at(group.NameIndex); |
| 1087 | if (iter == checksums.end()) |
| 1088 | continue; |
| 1089 | |
| 1090 | llvm::Expected<llvm::StringRef> efn = |
| 1091 | strings.getString(iter->FileNameOffset); |
| 1092 | if (!efn) { |
| 1093 | llvm::consumeError(efn.takeError()); |
| 1094 | continue; |
| 1095 | } |
| 1096 | |
| 1097 | // LLDB wants the index of the file in the list of support files. |
| 1098 | auto fn_iter = llvm::find(cci->m_file_list, *efn); |
| 1099 | lldbassert(fn_iter != cci->m_file_list.end()); |
Zachary Turner | b3130b4 | 2019-01-02 18:32:50 +0000 | [diff] [blame] | 1100 | // LLDB support file indices are 1-based. |
| 1101 | uint32_t file_index = |
| 1102 | 1 + std::distance(cci->m_file_list.begin(), fn_iter); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1103 | |
| 1104 | std::unique_ptr<LineSequence> sequence( |
| 1105 | line_table->CreateLineSequenceContainer()); |
| 1106 | lldbassert(!group.LineNumbers.empty()); |
| 1107 | |
| 1108 | for (const LineNumberEntry &entry : group.LineNumbers) { |
| 1109 | AppendLineEntryToSequence(*line_table, *sequence, *cci, virtual_addr, |
| 1110 | file_index, *lfh, entry); |
| 1111 | } |
| 1112 | LineInfo last_line(group.LineNumbers.back().Flags); |
| 1113 | TerminateLineSequence(*line_table, *lfh, virtual_addr, file_index, |
| 1114 | last_line.getEndLine(), std::move(sequence)); |
| 1115 | } |
| 1116 | } |
| 1117 | |
| 1118 | if (line_table->GetSize() == 0) |
| 1119 | return false; |
| 1120 | |
Zachary Turner | 863f8c1 | 2019-01-11 18:03:20 +0000 | [diff] [blame] | 1121 | comp_unit.SetLineTable(line_table.release()); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1122 | return true; |
| 1123 | } |
| 1124 | |
Zachary Turner | 863f8c1 | 2019-01-11 18:03:20 +0000 | [diff] [blame] | 1125 | bool SymbolFileNativePDB::ParseDebugMacros(CompileUnit &comp_unit) { |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1126 | // PDB doesn't contain information about macros |
| 1127 | return false; |
| 1128 | } |
| 1129 | |
Zachary Turner | 863f8c1 | 2019-01-11 18:03:20 +0000 | [diff] [blame] | 1130 | bool SymbolFileNativePDB::ParseSupportFiles(CompileUnit &comp_unit, |
| 1131 | FileSpecList &support_files) { |
| 1132 | PdbSymUid cu_id(comp_unit.GetID()); |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 1133 | lldbassert(cu_id.kind() == PdbSymUidKind::Compiland); |
| 1134 | CompilandIndexItem *cci = |
| 1135 | m_index->compilands().GetCompiland(cu_id.asCompiland().modi); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1136 | lldbassert(cci); |
| 1137 | |
| 1138 | for (llvm::StringRef f : cci->m_file_list) { |
| 1139 | FileSpec::Style style = |
| 1140 | f.startswith("/") ? FileSpec::Style::posix : FileSpec::Style::windows; |
Jonas Devlieghere | 8f3be7a | 2018-11-01 21:05:36 +0000 | [diff] [blame] | 1141 | FileSpec spec(f, style); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1142 | support_files.Append(spec); |
| 1143 | } |
| 1144 | |
Zachary Turner | b3130b4 | 2019-01-02 18:32:50 +0000 | [diff] [blame] | 1145 | llvm::SmallString<64> main_source_file = |
| 1146 | m_index->compilands().GetMainSourceFile(*cci); |
| 1147 | FileSpec::Style style = main_source_file.startswith("/") |
| 1148 | ? FileSpec::Style::posix |
| 1149 | : FileSpec::Style::windows; |
| 1150 | FileSpec spec(main_source_file, style); |
| 1151 | support_files.Insert(0, spec); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1152 | return true; |
| 1153 | } |
| 1154 | |
| 1155 | bool SymbolFileNativePDB::ParseImportedModules( |
Adrian Prantl | 0f30a3b | 2019-02-13 18:10:41 +0000 | [diff] [blame] | 1156 | const SymbolContext &sc, std::vector<SourceModule> &imported_modules) { |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1157 | // PDB does not yet support module debug info |
| 1158 | return false; |
| 1159 | } |
| 1160 | |
Zachary Turner | ffc1b8f | 2019-01-14 22:40:41 +0000 | [diff] [blame] | 1161 | size_t SymbolFileNativePDB::ParseBlocksRecursive(Function &func) { |
| 1162 | GetOrCreateBlock(PdbSymUid(func.GetID()).asCompilandSym()); |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 1163 | // FIXME: Parse child blocks |
| 1164 | return 1; |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1165 | } |
| 1166 | |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 1167 | void SymbolFileNativePDB::DumpClangAST(Stream &s) { m_ast->Dump(s); } |
Zachary Turner | 4911023 | 2018-11-05 17:40:28 +0000 | [diff] [blame] | 1168 | |
Zachary Turner | 9f72795 | 2018-10-26 09:06:38 +0000 | [diff] [blame] | 1169 | uint32_t SymbolFileNativePDB::FindGlobalVariables( |
Adrian Prantl | 0e4c482 | 2019-03-06 21:22:25 +0000 | [diff] [blame] | 1170 | ConstString name, const CompilerDeclContext *parent_decl_ctx, |
Zachary Turner | 9f72795 | 2018-10-26 09:06:38 +0000 | [diff] [blame] | 1171 | uint32_t max_matches, VariableList &variables) { |
| 1172 | using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>; |
| 1173 | |
| 1174 | std::vector<SymbolAndOffset> results = m_index->globals().findRecordsByName( |
| 1175 | name.GetStringRef(), m_index->symrecords()); |
| 1176 | for (const SymbolAndOffset &result : results) { |
| 1177 | VariableSP var; |
| 1178 | switch (result.second.kind()) { |
| 1179 | case SymbolKind::S_GDATA32: |
| 1180 | case SymbolKind::S_LDATA32: |
| 1181 | case SymbolKind::S_GTHREAD32: |
Zachary Turner | 2af3416 | 2018-11-13 20:07:57 +0000 | [diff] [blame] | 1182 | case SymbolKind::S_LTHREAD32: |
| 1183 | case SymbolKind::S_CONSTANT: { |
Zachary Turner | 9fbf935 | 2018-11-16 03:16:27 +0000 | [diff] [blame] | 1184 | PdbGlobalSymId global(result.first, false); |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 1185 | var = GetOrCreateGlobalVariable(global); |
Zachary Turner | 9f72795 | 2018-10-26 09:06:38 +0000 | [diff] [blame] | 1186 | variables.AddVariable(var); |
| 1187 | break; |
| 1188 | } |
| 1189 | default: |
| 1190 | continue; |
| 1191 | } |
| 1192 | } |
| 1193 | return variables.GetSize(); |
| 1194 | } |
| 1195 | |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1196 | uint32_t SymbolFileNativePDB::FindFunctions( |
Adrian Prantl | 0e4c482 | 2019-03-06 21:22:25 +0000 | [diff] [blame] | 1197 | ConstString name, const CompilerDeclContext *parent_decl_ctx, |
Zachary Turner | 117b1fa | 2018-10-25 20:45:40 +0000 | [diff] [blame] | 1198 | FunctionNameType name_type_mask, bool include_inlines, bool append, |
Zachary Turner | b96181c | 2018-10-22 16:19:07 +0000 | [diff] [blame] | 1199 | SymbolContextList &sc_list) { |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1200 | // For now we only support lookup by method name. |
| 1201 | if (!(name_type_mask & eFunctionNameTypeMethod)) |
| 1202 | return 0; |
| 1203 | |
| 1204 | using SymbolAndOffset = std::pair<uint32_t, llvm::codeview::CVSymbol>; |
| 1205 | |
| 1206 | std::vector<SymbolAndOffset> matches = m_index->globals().findRecordsByName( |
| 1207 | name.GetStringRef(), m_index->symrecords()); |
| 1208 | for (const SymbolAndOffset &match : matches) { |
| 1209 | if (match.second.kind() != S_PROCREF && match.second.kind() != S_LPROCREF) |
| 1210 | continue; |
| 1211 | ProcRefSym proc(match.second.kind()); |
| 1212 | cantFail(SymbolDeserializer::deserializeAs<ProcRefSym>(match.second, proc)); |
| 1213 | |
| 1214 | if (!IsValidRecord(proc)) |
| 1215 | continue; |
| 1216 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 1217 | CompilandIndexItem &cci = |
| 1218 | m_index->compilands().GetOrCreateCompiland(proc.modi()); |
Zachary Turner | b96181c | 2018-10-22 16:19:07 +0000 | [diff] [blame] | 1219 | SymbolContext sc; |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1220 | |
| 1221 | sc.comp_unit = GetOrCreateCompileUnit(cci).get(); |
Zachary Turner | 9fbf935 | 2018-11-16 03:16:27 +0000 | [diff] [blame] | 1222 | PdbCompilandSymId func_id(proc.modi(), proc.SymOffset); |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 1223 | sc.function = GetOrCreateFunction(func_id, *sc.comp_unit).get(); |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1224 | |
| 1225 | sc_list.Append(sc); |
| 1226 | } |
| 1227 | |
| 1228 | return sc_list.GetSize(); |
| 1229 | } |
| 1230 | |
Zachary Turner | b96181c | 2018-10-22 16:19:07 +0000 | [diff] [blame] | 1231 | uint32_t SymbolFileNativePDB::FindFunctions(const RegularExpression ®ex, |
| 1232 | bool include_inlines, bool append, |
| 1233 | SymbolContextList &sc_list) { |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1234 | return 0; |
| 1235 | } |
| 1236 | |
Zachary Turner | b96181c | 2018-10-22 16:19:07 +0000 | [diff] [blame] | 1237 | uint32_t SymbolFileNativePDB::FindTypes( |
Adrian Prantl | 0e4c482 | 2019-03-06 21:22:25 +0000 | [diff] [blame] | 1238 | ConstString name, const CompilerDeclContext *parent_decl_ctx, |
Zachary Turner | 576495e | 2019-01-14 22:41:21 +0000 | [diff] [blame] | 1239 | bool append, uint32_t max_matches, |
| 1240 | llvm::DenseSet<SymbolFile *> &searched_symbol_files, TypeMap &types) { |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 1241 | if (!append) |
| 1242 | types.Clear(); |
| 1243 | if (!name) |
| 1244 | return 0; |
| 1245 | |
| 1246 | searched_symbol_files.clear(); |
| 1247 | searched_symbol_files.insert(this); |
| 1248 | |
| 1249 | // There is an assumption 'name' is not a regex |
| 1250 | size_t match_count = FindTypesByName(name.GetStringRef(), max_matches, types); |
| 1251 | |
| 1252 | return match_count; |
Zachary Turner | b96181c | 2018-10-22 16:19:07 +0000 | [diff] [blame] | 1253 | } |
| 1254 | |
| 1255 | size_t |
| 1256 | SymbolFileNativePDB::FindTypes(const std::vector<CompilerContext> &context, |
| 1257 | bool append, TypeMap &types) { |
| 1258 | return 0; |
| 1259 | } |
| 1260 | |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 1261 | size_t SymbolFileNativePDB::FindTypesByName(llvm::StringRef name, |
| 1262 | uint32_t max_matches, |
| 1263 | TypeMap &types) { |
| 1264 | |
| 1265 | size_t match_count = 0; |
| 1266 | std::vector<TypeIndex> matches = m_index->tpi().findRecordsByName(name); |
| 1267 | if (max_matches > 0 && max_matches < matches.size()) |
| 1268 | matches.resize(max_matches); |
| 1269 | |
| 1270 | for (TypeIndex ti : matches) { |
| 1271 | TypeSP type = GetOrCreateType(ti); |
| 1272 | if (!type) |
| 1273 | continue; |
| 1274 | |
| 1275 | types.Insert(type); |
| 1276 | ++match_count; |
| 1277 | } |
| 1278 | return match_count; |
| 1279 | } |
| 1280 | |
Zachary Turner | 863f8c1 | 2019-01-11 18:03:20 +0000 | [diff] [blame] | 1281 | size_t SymbolFileNativePDB::ParseTypes(CompileUnit &comp_unit) { |
Zachary Turner | 44f1951 | 2019-01-10 20:57:32 +0000 | [diff] [blame] | 1282 | // Only do the full type scan the first time. |
| 1283 | if (m_done_full_type_scan) |
| 1284 | return 0; |
| 1285 | |
| 1286 | size_t old_count = m_obj_file->GetModule()->GetTypeList()->GetSize(); |
| 1287 | LazyRandomTypeCollection &types = m_index->tpi().typeCollection(); |
| 1288 | |
| 1289 | // First process the entire TPI stream. |
| 1290 | for (auto ti = types.getFirst(); ti; ti = types.getNext(*ti)) { |
| 1291 | TypeSP type = GetOrCreateType(*ti); |
| 1292 | if (type) |
| 1293 | (void)type->GetFullCompilerType(); |
| 1294 | } |
| 1295 | |
| 1296 | // Next look for S_UDT records in the globals stream. |
| 1297 | for (const uint32_t gid : m_index->globals().getGlobalsTable()) { |
| 1298 | PdbGlobalSymId global{gid, false}; |
| 1299 | CVSymbol sym = m_index->ReadSymbolRecord(global); |
| 1300 | if (sym.kind() != S_UDT) |
| 1301 | continue; |
| 1302 | |
| 1303 | UDTSym udt = llvm::cantFail(SymbolDeserializer::deserializeAs<UDTSym>(sym)); |
| 1304 | bool is_typedef = true; |
| 1305 | if (IsTagRecord(PdbTypeSymId{udt.Type, false}, m_index->tpi())) { |
| 1306 | CVType cvt = m_index->tpi().getType(udt.Type); |
| 1307 | llvm::StringRef name = CVTagRecord::create(cvt).name(); |
| 1308 | if (name == udt.Name) |
| 1309 | is_typedef = false; |
| 1310 | } |
| 1311 | |
| 1312 | if (is_typedef) |
| 1313 | GetOrCreateTypedef(global); |
| 1314 | } |
| 1315 | |
| 1316 | size_t new_count = m_obj_file->GetModule()->GetTypeList()->GetSize(); |
| 1317 | |
| 1318 | m_done_full_type_scan = true; |
| 1319 | |
| 1320 | return new_count - old_count; |
| 1321 | } |
Zachary Turner | b96181c | 2018-10-22 16:19:07 +0000 | [diff] [blame] | 1322 | |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 1323 | size_t |
| 1324 | SymbolFileNativePDB::ParseVariablesForCompileUnit(CompileUnit &comp_unit, |
| 1325 | VariableList &variables) { |
| 1326 | PdbSymUid sym_uid(comp_unit.GetID()); |
| 1327 | lldbassert(sym_uid.kind() == PdbSymUidKind::Compiland); |
| 1328 | return 0; |
| 1329 | } |
| 1330 | |
| 1331 | VariableSP SymbolFileNativePDB::CreateLocalVariable(PdbCompilandSymId scope_id, |
| 1332 | PdbCompilandSymId var_id, |
| 1333 | bool is_param) { |
| 1334 | ModuleSP module = GetObjectFile()->GetModule(); |
Aleksandr Urakov | 758657e | 2019-02-01 10:01:18 +0000 | [diff] [blame] | 1335 | Block &block = GetOrCreateBlock(scope_id); |
| 1336 | VariableInfo var_info = |
| 1337 | GetVariableLocationInfo(*m_index, var_id, block, module); |
Zachary Turner | 44f1951 | 2019-01-10 20:57:32 +0000 | [diff] [blame] | 1338 | if (!var_info.location || !var_info.ranges) |
| 1339 | return nullptr; |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 1340 | |
| 1341 | CompilandIndexItem *cii = m_index->compilands().GetCompiland(var_id.modi); |
| 1342 | CompUnitSP comp_unit_sp = GetOrCreateCompileUnit(*cii); |
| 1343 | TypeSP type_sp = GetOrCreateType(var_info.type); |
| 1344 | std::string name = var_info.name.str(); |
| 1345 | Declaration decl; |
| 1346 | SymbolFileTypeSP sftype = |
| 1347 | std::make_shared<SymbolFileType>(*this, type_sp->GetID()); |
| 1348 | |
| 1349 | ValueType var_scope = |
| 1350 | is_param ? eValueTypeVariableArgument : eValueTypeVariableLocal; |
| 1351 | VariableSP var_sp = std::make_shared<Variable>( |
| 1352 | toOpaqueUid(var_id), name.c_str(), name.c_str(), sftype, var_scope, |
| 1353 | comp_unit_sp.get(), *var_info.ranges, &decl, *var_info.location, false, |
| 1354 | false, false); |
| 1355 | |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 1356 | if (!is_param) |
Zachary Turner | 2256633 | 2019-01-02 18:33:54 +0000 | [diff] [blame] | 1357 | m_ast->GetOrCreateVariableDecl(scope_id, var_id); |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 1358 | |
| 1359 | m_local_variables[toOpaqueUid(var_id)] = var_sp; |
| 1360 | return var_sp; |
| 1361 | } |
| 1362 | |
| 1363 | VariableSP SymbolFileNativePDB::GetOrCreateLocalVariable( |
| 1364 | PdbCompilandSymId scope_id, PdbCompilandSymId var_id, bool is_param) { |
| 1365 | auto iter = m_local_variables.find(toOpaqueUid(var_id)); |
| 1366 | if (iter != m_local_variables.end()) |
| 1367 | return iter->second; |
| 1368 | |
| 1369 | return CreateLocalVariable(scope_id, var_id, is_param); |
| 1370 | } |
| 1371 | |
Zachary Turner | 44f1951 | 2019-01-10 20:57:32 +0000 | [diff] [blame] | 1372 | TypeSP SymbolFileNativePDB::CreateTypedef(PdbGlobalSymId id) { |
| 1373 | CVSymbol sym = m_index->ReadSymbolRecord(id); |
| 1374 | lldbassert(sym.kind() == SymbolKind::S_UDT); |
| 1375 | |
| 1376 | UDTSym udt = llvm::cantFail(SymbolDeserializer::deserializeAs<UDTSym>(sym)); |
| 1377 | |
| 1378 | TypeSP target_type = GetOrCreateType(udt.Type); |
| 1379 | |
| 1380 | (void)m_ast->GetOrCreateTypedefDecl(id); |
| 1381 | |
| 1382 | Declaration decl; |
| 1383 | return std::make_shared<lldb_private::Type>( |
| 1384 | toOpaqueUid(id), this, ConstString(udt.Name), target_type->GetByteSize(), |
| 1385 | nullptr, target_type->GetID(), lldb_private::Type::eEncodingIsTypedefUID, |
| 1386 | decl, target_type->GetForwardCompilerType(), |
| 1387 | lldb_private::Type::eResolveStateForward); |
| 1388 | } |
| 1389 | |
| 1390 | TypeSP SymbolFileNativePDB::GetOrCreateTypedef(PdbGlobalSymId id) { |
| 1391 | auto iter = m_types.find(toOpaqueUid(id)); |
| 1392 | if (iter != m_types.end()) |
| 1393 | return iter->second; |
| 1394 | |
| 1395 | return CreateTypedef(id); |
| 1396 | } |
| 1397 | |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 1398 | size_t SymbolFileNativePDB::ParseVariablesForBlock(PdbCompilandSymId block_id) { |
| 1399 | Block &block = GetOrCreateBlock(block_id); |
| 1400 | |
| 1401 | size_t count = 0; |
| 1402 | |
| 1403 | CompilandIndexItem *cii = m_index->compilands().GetCompiland(block_id.modi); |
| 1404 | CVSymbol sym = cii->m_debug_stream.readSymbolAtOffset(block_id.offset); |
| 1405 | uint32_t params_remaining = 0; |
| 1406 | switch (sym.kind()) { |
| 1407 | case S_GPROC32: |
| 1408 | case S_LPROC32: { |
| 1409 | ProcSym proc(static_cast<SymbolRecordKind>(sym.kind())); |
| 1410 | cantFail(SymbolDeserializer::deserializeAs<ProcSym>(sym, proc)); |
| 1411 | CVType signature = m_index->tpi().getType(proc.FunctionType); |
| 1412 | ProcedureRecord sig; |
| 1413 | cantFail(TypeDeserializer::deserializeAs<ProcedureRecord>(signature, sig)); |
| 1414 | params_remaining = sig.getParameterCount(); |
| 1415 | break; |
| 1416 | } |
| 1417 | case S_BLOCK32: |
| 1418 | break; |
| 1419 | default: |
| 1420 | lldbassert(false && "Symbol is not a block!"); |
| 1421 | return 0; |
| 1422 | } |
| 1423 | |
| 1424 | VariableListSP variables = block.GetBlockVariableList(false); |
| 1425 | if (!variables) { |
| 1426 | variables = std::make_shared<VariableList>(); |
| 1427 | block.SetVariableList(variables); |
| 1428 | } |
| 1429 | |
| 1430 | CVSymbolArray syms = limitSymbolArrayToScope( |
| 1431 | cii->m_debug_stream.getSymbolArray(), block_id.offset); |
| 1432 | |
| 1433 | // Skip the first record since it's a PROC32 or BLOCK32, and there's |
| 1434 | // no point examining it since we know it's not a local variable. |
| 1435 | syms.drop_front(); |
| 1436 | auto iter = syms.begin(); |
| 1437 | auto end = syms.end(); |
| 1438 | |
| 1439 | while (iter != end) { |
| 1440 | uint32_t record_offset = iter.offset(); |
| 1441 | CVSymbol variable_cvs = *iter; |
| 1442 | PdbCompilandSymId child_sym_id(block_id.modi, record_offset); |
| 1443 | ++iter; |
| 1444 | |
| 1445 | // If this is a block, recurse into its children and then skip it. |
| 1446 | if (variable_cvs.kind() == S_BLOCK32) { |
| 1447 | uint32_t block_end = getScopeEndOffset(variable_cvs); |
| 1448 | count += ParseVariablesForBlock(child_sym_id); |
| 1449 | iter = syms.at(block_end); |
| 1450 | continue; |
| 1451 | } |
| 1452 | |
| 1453 | bool is_param = params_remaining > 0; |
| 1454 | VariableSP variable; |
| 1455 | switch (variable_cvs.kind()) { |
| 1456 | case S_REGREL32: |
| 1457 | case S_REGISTER: |
| 1458 | case S_LOCAL: |
| 1459 | variable = GetOrCreateLocalVariable(block_id, child_sym_id, is_param); |
| 1460 | if (is_param) |
| 1461 | --params_remaining; |
Zachary Turner | 44f1951 | 2019-01-10 20:57:32 +0000 | [diff] [blame] | 1462 | if (variable) |
| 1463 | variables->AddVariableIfUnique(variable); |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 1464 | break; |
| 1465 | default: |
| 1466 | break; |
| 1467 | } |
| 1468 | } |
| 1469 | |
| 1470 | // Pass false for set_children, since we call this recursively so that the |
| 1471 | // children will call this for themselves. |
| 1472 | block.SetDidParseVariables(true, false); |
| 1473 | |
| 1474 | return count; |
| 1475 | } |
| 1476 | |
| 1477 | size_t SymbolFileNativePDB::ParseVariablesForContext(const SymbolContext &sc) { |
| 1478 | lldbassert(sc.function || sc.comp_unit); |
| 1479 | |
| 1480 | VariableListSP variables; |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 1481 | if (sc.block) { |
| 1482 | PdbSymUid block_id(sc.block->GetID()); |
| 1483 | |
| 1484 | size_t count = ParseVariablesForBlock(block_id.asCompilandSym()); |
| 1485 | return count; |
| 1486 | } |
| 1487 | |
| 1488 | if (sc.function) { |
| 1489 | PdbSymUid block_id(sc.function->GetID()); |
| 1490 | |
| 1491 | size_t count = ParseVariablesForBlock(block_id.asCompilandSym()); |
| 1492 | return count; |
| 1493 | } |
| 1494 | |
| 1495 | if (sc.comp_unit) { |
| 1496 | variables = sc.comp_unit->GetVariableList(false); |
| 1497 | if (!variables) { |
| 1498 | variables = std::make_shared<VariableList>(); |
| 1499 | sc.comp_unit->SetVariableList(variables); |
| 1500 | } |
| 1501 | return ParseVariablesForCompileUnit(*sc.comp_unit, *variables); |
| 1502 | } |
| 1503 | |
| 1504 | llvm_unreachable("Unreachable!"); |
| 1505 | } |
| 1506 | |
| 1507 | CompilerDecl SymbolFileNativePDB::GetDeclForUID(lldb::user_id_t uid) { |
Nathan Lanza | fe1b8a0 | 2019-07-21 07:46:18 +0000 | [diff] [blame] | 1508 | if (auto decl = m_ast->GetOrCreateDeclForUid(uid)) |
| 1509 | return decl.getValue(); |
| 1510 | else |
| 1511 | return CompilerDecl(); |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 1512 | } |
| 1513 | |
| 1514 | CompilerDeclContext |
| 1515 | SymbolFileNativePDB::GetDeclContextForUID(lldb::user_id_t uid) { |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 1516 | clang::DeclContext *context = |
| 1517 | m_ast->GetOrCreateDeclContextForUid(PdbSymUid(uid)); |
| 1518 | if (!context) |
| 1519 | return {}; |
| 1520 | |
| 1521 | return m_ast->ToCompilerDeclContext(*context); |
Zachary Turner | d3d2b9b | 2018-12-13 18:17:51 +0000 | [diff] [blame] | 1522 | } |
| 1523 | |
Zachary Turner | a42bbe3 | 2018-12-07 19:34:02 +0000 | [diff] [blame] | 1524 | CompilerDeclContext |
| 1525 | SymbolFileNativePDB::GetDeclContextContainingUID(lldb::user_id_t uid) { |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 1526 | clang::DeclContext *context = m_ast->GetParentDeclContext(PdbSymUid(uid)); |
| 1527 | return m_ast->ToCompilerDeclContext(*context); |
Zachary Turner | a42bbe3 | 2018-12-07 19:34:02 +0000 | [diff] [blame] | 1528 | } |
| 1529 | |
Zachary Turner | b96181c | 2018-10-22 16:19:07 +0000 | [diff] [blame] | 1530 | Type *SymbolFileNativePDB::ResolveTypeUID(lldb::user_id_t type_uid) { |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 1531 | auto iter = m_types.find(type_uid); |
| 1532 | // lldb should not be passing us non-sensical type uids. the only way it |
| 1533 | // could have a type uid in the first place is if we handed it out, in which |
Zachary Turner | 9f72795 | 2018-10-26 09:06:38 +0000 | [diff] [blame] | 1534 | // case we should know about the type. However, that doesn't mean we've |
| 1535 | // instantiated it yet. We can vend out a UID for a future type. So if the |
| 1536 | // type doesn't exist, let's instantiate it now. |
| 1537 | if (iter != m_types.end()) |
| 1538 | return &*iter->second; |
| 1539 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 1540 | PdbSymUid uid(type_uid); |
| 1541 | lldbassert(uid.kind() == PdbSymUidKind::Type); |
| 1542 | PdbTypeSymId type_id = uid.asTypeSym(); |
| 1543 | if (type_id.index.isNoneType()) |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 1544 | return nullptr; |
Zachary Turner | 9f72795 | 2018-10-26 09:06:38 +0000 | [diff] [blame] | 1545 | |
Zachary Turner | 6284aee | 2018-11-16 02:42:32 +0000 | [diff] [blame] | 1546 | TypeSP type_sp = CreateAndCacheType(type_id); |
Zachary Turner | 9f72795 | 2018-10-26 09:06:38 +0000 | [diff] [blame] | 1547 | return &*type_sp; |
Zachary Turner | b96181c | 2018-10-22 16:19:07 +0000 | [diff] [blame] | 1548 | } |
| 1549 | |
Adrian Prantl | eca07c5 | 2018-11-05 20:49:07 +0000 | [diff] [blame] | 1550 | llvm::Optional<SymbolFile::ArrayInfo> |
| 1551 | SymbolFileNativePDB::GetDynamicArrayInfoForUID( |
| 1552 | lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx) { |
| 1553 | return llvm::None; |
| 1554 | } |
| 1555 | |
| 1556 | |
Zachary Turner | b96181c | 2018-10-22 16:19:07 +0000 | [diff] [blame] | 1557 | bool SymbolFileNativePDB::CompleteType(CompilerType &compiler_type) { |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 1558 | clang::QualType qt = |
| 1559 | clang::QualType::getFromOpaquePtr(compiler_type.GetOpaqueQualType()); |
Zachary Turner | 2f7efbc | 2018-10-23 16:37:53 +0000 | [diff] [blame] | 1560 | |
Zachary Turner | 594c85e | 2018-12-17 19:43:33 +0000 | [diff] [blame] | 1561 | return m_ast->CompleteType(qt); |
Zachary Turner | b96181c | 2018-10-22 16:19:07 +0000 | [diff] [blame] | 1562 | } |
| 1563 | |
| 1564 | size_t SymbolFileNativePDB::GetTypes(lldb_private::SymbolContextScope *sc_scope, |
Zachary Turner | 117b1fa | 2018-10-25 20:45:40 +0000 | [diff] [blame] | 1565 | TypeClass type_mask, |
Zachary Turner | b96181c | 2018-10-22 16:19:07 +0000 | [diff] [blame] | 1566 | lldb_private::TypeList &type_list) { |
| 1567 | return 0; |
| 1568 | } |
| 1569 | |
| 1570 | CompilerDeclContext |
Adrian Prantl | 0e4c482 | 2019-03-06 21:22:25 +0000 | [diff] [blame] | 1571 | SymbolFileNativePDB::FindNamespace(ConstString name, |
Zachary Turner | b96181c | 2018-10-22 16:19:07 +0000 | [diff] [blame] | 1572 | const CompilerDeclContext *parent_decl_ctx) { |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1573 | return {}; |
| 1574 | } |
| 1575 | |
Zachary Turner | b96181c | 2018-10-22 16:19:07 +0000 | [diff] [blame] | 1576 | TypeSystem * |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1577 | SymbolFileNativePDB::GetTypeSystemForLanguage(lldb::LanguageType language) { |
| 1578 | auto type_system = |
| 1579 | m_obj_file->GetModule()->GetTypeSystemForLanguage(language); |
| 1580 | if (type_system) |
| 1581 | type_system->SetSymbolFile(this); |
| 1582 | return type_system; |
| 1583 | } |
| 1584 | |
Zachary Turner | b96181c | 2018-10-22 16:19:07 +0000 | [diff] [blame] | 1585 | ConstString SymbolFileNativePDB::GetPluginName() { |
Zachary Turner | 307f5ae | 2018-10-12 19:47:13 +0000 | [diff] [blame] | 1586 | static ConstString g_name("pdb"); |
| 1587 | return g_name; |
| 1588 | } |
| 1589 | |
| 1590 | uint32_t SymbolFileNativePDB::GetPluginVersion() { return 1; } |