diff options
author | Aaron Smith <aaron.smith@microsoft.com> | 2018-03-22 19:26:33 +0000 |
---|---|---|
committer | Aaron Smith <aaron.smith@microsoft.com> | 2018-03-22 19:26:33 +0000 |
commit | 308e39ca8d89f9b9891fe70b4c47c458a53871d4 (patch) | |
tree | e9ad48c09be60fc9bf9afdf8cccad1671b6673cc | |
parent | 4a3be6e5786f6a0ad96fc2e98f10ef801c5bdb93 (diff) | |
download | bcm5719-llvm-308e39ca8d89f9b9891fe70b4c47c458a53871d4.tar.gz bcm5719-llvm-308e39ca8d89f9b9891fe70b4c47c458a53871d4.zip |
[SymbolFilePDB] Use section contributions as another way to determine the compiland
Some PDB Symbols don't have line information. Use the section contributions to determine their compiland.
This is useful to determine the parent compiland for PDBSymbolTypeData, i.e. variables.
llvm-svn: 328232
-rw-r--r-- | lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp index c958d0c94a8..b1dd67c2c3f 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -19,14 +19,15 @@ #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/SymbolVendor.h" -#include "lldb/Symbol/TypeMap.h" #include "lldb/Symbol/TypeList.h" +#include "lldb/Symbol/TypeMap.h" #include "lldb/Utility/RegularExpression.h" #include "llvm/DebugInfo/PDB/GenericError.h" #include "llvm/DebugInfo/PDB/IPDBDataStream.h" #include "llvm/DebugInfo/PDB/IPDBEnumChildren.h" #include "llvm/DebugInfo/PDB/IPDBLineNumber.h" +#include "llvm/DebugInfo/PDB/IPDBSectionContrib.h" #include "llvm/DebugInfo/PDB/IPDBSourceFile.h" #include "llvm/DebugInfo/PDB/IPDBTable.h" #include "llvm/DebugInfo/PDB/PDBSymbol.h" @@ -264,7 +265,7 @@ lldb_private::Function *SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc( lldbassert(sc.comp_unit && sc.module_sp.get()); auto file_vm_addr = pdb_func.getVirtualAddress(); - if (file_vm_addr == LLDB_INVALID_ADDRESS) + if (file_vm_addr == LLDB_INVALID_ADDRESS || file_vm_addr == 0) return nullptr; auto func_length = pdb_func.getLength(); @@ -677,7 +678,7 @@ uint32_t SymbolFilePDB::ResolveSymbolContext( auto file_vm_addr = sc.line_entry.range.GetBaseAddress().GetFileAddress(); - if (file_vm_addr == LLDB_INVALID_ADDRESS) + if (file_vm_addr == LLDB_INVALID_ADDRESS || file_vm_addr == 0) continue; auto symbol_up = m_session_up->findSymbolByAddress( @@ -1341,24 +1342,26 @@ void SymbolFilePDB::BuildSupportFileIdToSupportFileIndexMap( } lldb::CompUnitSP SymbolFilePDB::GetCompileUnitContainsAddress( - const lldb_private::Address &so_addr) { + const lldb_private::Address &so_addr) { lldb::addr_t file_vm_addr = so_addr.GetFileAddress(); - if (file_vm_addr == LLDB_INVALID_ADDRESS) - return nullptr; - - auto lines_up = - m_session_up->findLineNumbersByAddress(file_vm_addr, /*Length=*/200); - if (!lines_up) + if (file_vm_addr == LLDB_INVALID_ADDRESS || file_vm_addr == 0) return nullptr; - auto first_line_up = lines_up->getNext(); - if (!first_line_up) - return nullptr; - auto compiland_up = GetPDBCompilandByUID(first_line_up->getCompilandId()); - if (compiland_up) { - return ParseCompileUnitForUID(compiland_up->getSymIndexId()); + // If it is a PDB function's vm addr, this is the first sure bet. + if (auto lines = + m_session_up->findLineNumbersByAddress(file_vm_addr, /*Length=*/1)) { + if (auto first_line = lines->getNext()) + return ParseCompileUnitForUID(first_line->getCompilandId()); } + // Otherwise we resort to section contributions. + if (auto sec_contribs = m_session_up->getSectionContribs()) { + while (auto section = sec_contribs->getNext()) { + auto va = section->getVirtualAddress(); + if (file_vm_addr >= va && file_vm_addr < va + section->getLength()) + return ParseCompileUnitForUID(section->getCompilandId()); + } + } return nullptr; } |