diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-08-20 20:51:52 +0000 |
commit | 5f29bb8a675e8f96452b632e7129113f7dec850e (patch) | |
tree | 3d3f2a0d3ad10872a4dcaba8ec8d1d20c87ab147 /source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | |
parent | 88c643b6fec27eec436c8d138fee6346e92337d6 (diff) |
Notes
Diffstat (limited to 'source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp')
-rw-r--r-- | source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 65 |
1 files changed, 35 insertions, 30 deletions
diff --git a/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp index ad25842f4d05..17dfcdaceb9c 100644 --- a/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ b/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -1,9 +1,8 @@ //===-- SymbolFilePDB.cpp ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -65,6 +64,8 @@ lldb::LanguageType TranslateLanguage(PDB_Lang lang) { return lldb::LanguageType::eLanguageTypeC_plus_plus; case PDB_Lang::C: return lldb::LanguageType::eLanguageTypeC; + case PDB_Lang::Swift: + return lldb::LanguageType::eLanguageTypeSwift; default: return lldb::LanguageType::eLanguageTypeUnknown; } @@ -123,7 +124,7 @@ SymbolFilePDB::CreateInstance(lldb_private::ObjectFile *obj_file) { SymbolFilePDB::SymbolFilePDB(lldb_private::ObjectFile *object_file) : SymbolFile(object_file), m_session_up(), m_global_scope_up(), - m_cached_compile_unit_count(0), m_tu_decl_ctx_up() {} + m_cached_compile_unit_count(0) {} SymbolFilePDB::~SymbolFilePDB() {} @@ -182,20 +183,12 @@ uint32_t SymbolFilePDB::CalculateAbilities() { } void SymbolFilePDB::InitializeObject() { - lldb::addr_t obj_load_address = m_obj_file->GetFileOffset(); + lldb::addr_t obj_load_address = m_obj_file->GetBaseAddress().GetFileAddress(); lldbassert(obj_load_address && obj_load_address != LLDB_INVALID_ADDRESS); m_session_up->setLoadAddress(obj_load_address); if (!m_global_scope_up) m_global_scope_up = m_session_up->getGlobalScope(); lldbassert(m_global_scope_up.get()); - - TypeSystem *type_system = - GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus); - ClangASTContext *clang_type_system = - llvm::dyn_cast_or_null<ClangASTContext>(type_system); - lldbassert(clang_type_system); - m_tu_decl_ctx_up = llvm::make_unique<CompilerDeclContext>( - type_system, clang_type_system->GetTranslationUnitDecl()); } uint32_t SymbolFilePDB::GetNumCompileUnits() { @@ -308,7 +301,8 @@ SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc(const PDBSymbolFunc &pdb_func, comp_unit.AddFunction(func_sp); - TypeSystem *type_system = GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus); + LanguageType lang = ParseLanguage(comp_unit); + TypeSystem *type_system = GetTypeSystemForLanguage(lang); if (!type_system) return nullptr; ClangASTContext *clang_type_system = @@ -378,7 +372,7 @@ bool SymbolFilePDB::ParseSupportFiles( bool SymbolFilePDB::ParseImportedModules( const lldb_private::SymbolContext &sc, - std::vector<lldb_private::ConstString> &imported_modules) { + std::vector<SourceModule> &imported_modules) { // PDB does not yet support module debug info return false; } @@ -934,12 +928,25 @@ VariableSP SymbolFilePDB::ParseVariableForPDBData( Variable::RangeList ranges; SymbolContextScope *context_scope = sc.comp_unit; - if (scope == eValueTypeVariableLocal) { + if (scope == eValueTypeVariableLocal || scope == eValueTypeVariableArgument) { if (sc.function) { - context_scope = sc.function->GetBlock(true).FindBlockByID( - pdb_data.getLexicalParentId()); - if (context_scope == nullptr) - context_scope = sc.function; + Block &function_block = sc.function->GetBlock(true); + Block *block = + function_block.FindBlockByID(pdb_data.getLexicalParentId()); + if (!block) + block = &function_block; + + context_scope = block; + + for (size_t i = 0, num_ranges = block->GetNumRanges(); i < num_ranges; + ++i) { + AddressRange range; + if (!block->GetRangeAtIndex(i, range)) + continue; + + ranges.Append(range.GetBaseAddress().GetFileAddress(), + range.GetByteSize()); + } } } @@ -952,7 +959,7 @@ VariableSP SymbolFilePDB::ParseVariableForPDBData( bool is_constant; DWARFExpression location = ConvertPDBLocationToDWARFExpression( - GetObjectFile()->GetModule(), pdb_data, is_constant); + GetObjectFile()->GetModule(), pdb_data, ranges, is_constant); var_sp = std::make_shared<Variable>( var_uid, var_name.c_str(), mangled_cstr, type_sp, scope, context_scope, @@ -1034,7 +1041,7 @@ SymbolFilePDB::ParseVariables(const lldb_private::SymbolContext &sc, } uint32_t SymbolFilePDB::FindGlobalVariables( - const lldb_private::ConstString &name, + lldb_private::ConstString name, const lldb_private::CompilerDeclContext *parent_decl_ctx, uint32_t max_matches, lldb_private::VariableList &variables) { if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx)) @@ -1234,7 +1241,7 @@ void SymbolFilePDB::CacheFunctionNames() { } uint32_t SymbolFilePDB::FindFunctions( - const lldb_private::ConstString &name, + lldb_private::ConstString name, const lldb_private::CompilerDeclContext *parent_decl_ctx, FunctionNameType name_type_mask, bool include_inlines, bool append, lldb_private::SymbolContextList &sc_list) { @@ -1337,11 +1344,9 @@ void SymbolFilePDB::AddSymbols(lldb_private::Symtab &symtab) { return; while (auto pub_symbol = results->getNext()) { - auto section_idx = pub_symbol->getAddressSection() - 1; - if (section_idx >= section_list->GetSize()) - continue; + auto section_id = pub_symbol->getAddressSection(); - auto section = section_list->GetSectionAtIndex(section_idx); + auto section = section_list->FindSectionByID(section_id); if (!section) continue; @@ -1376,7 +1381,7 @@ void SymbolFilePDB::AddSymbols(lldb_private::Symtab &symtab) { } uint32_t SymbolFilePDB::FindTypes( - const lldb_private::ConstString &name, + lldb_private::ConstString name, const lldb_private::CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, @@ -1618,7 +1623,7 @@ PDBASTParser *SymbolFilePDB::GetPDBAstParser() { lldb_private::CompilerDeclContext SymbolFilePDB::FindNamespace( - const lldb_private::ConstString &name, + lldb_private::ConstString name, const lldb_private::CompilerDeclContext *parent_decl_ctx) { auto type_system = GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus); auto clang_type_system = llvm::dyn_cast_or_null<ClangASTContext>(type_system); |