[Lldb-commits] [lldb] r328232 - [SymbolFilePDB] Use section contributions as another way to determine the compiland
Aaron Smith via lldb-commits
lldb-commits at lists.llvm.org
Thu Mar 22 12:26:34 PDT 2018
Author: asmith
Date: Thu Mar 22 12:26:33 2018
New Revision: 328232
URL: http://llvm.org/viewvc/llvm-project?rev=328232&view=rev
Log:
[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.
Modified:
lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
Modified: lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp?rev=328232&r1=328231&r2=328232&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp Thu Mar 22 12:26:33 2018
@@ -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::P
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::ResolveSymbolCon
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::BuildSupportFileIdTo
}
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;
}
More information about the lldb-commits
mailing list