summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2018-12-06 16:55:00 +0000
committerZachary Turner <zturner@google.com>2018-12-06 16:55:00 +0000
commit579264bd5999931aea53b8e9bb7687f93a828247 (patch)
tree6149f93ae63a3f1f76500f79e2437cc8abd5a730 /lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp
parentbb650daeaf5d7dd9786ce90431c4c68afb09fabc (diff)
downloadbcm5719-llvm-579264bd5999931aea53b8e9bb7687f93a828247.tar.gz
bcm5719-llvm-579264bd5999931aea53b8e9bb7687f93a828247.zip
Support skewed stream arrays.
VarStreamArray was built on the assumption that it is backed by a StreamRef, and offset 0 of that StreamRef is the first byte of the first record in the array. This is a logical and intuitive assumption, but unfortunately we have use cases where it doesn't hold. Specifically, a PDB module's symbol stream is prefixed by 4 bytes containing a magic value, and the first byte of record data in the array is actually at offset 4 of this byte sequence. Previously, we would just truncate the first 4 bytes and then construct the VarStreamArray with the resulting StreamRef, so that offset 0 of the underlying stream did correspond to the first byte of the first record, but this is problematic, because symbol records reference other symbol records by the absolute offset including that initial magic 4 bytes. So if another record wants to refer to the first record in the array, it would say "the record at offset 4". This led to extremely confusing hacks and semantics in loading code, and after spending 30 minutes trying to get some math right and failing, I decided to fix this in the underlying implementation of VarStreamArray. Now, we can say that a stream is skewed by a particular amount. This way, when we access a record by absolute offset, we can use the same values that the records themselves contain, instead of having to do fixups. Differential Revision: https://reviews.llvm.org/D55344 llvm-svn: 348499
Diffstat (limited to 'lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp')
-rw-r--r--lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp
index 7aa656a405d..20bea853d6a 100644
--- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp
@@ -131,10 +131,7 @@ void PdbIndex::BuildAddrToSymbolMap(CompilandIndexItem &cci) {
SegmentOffset so = GetSegmentAndOffset(*iter);
lldb::addr_t va = MakeVirtualAddress(so);
- // We need to add 4 here to adjust for the codeview debug magic
- // at the beginning of the debug info stream.
- uint32_t sym_offset = iter.offset() + 4;
- PdbCompilandSymId cu_sym_id(modi, sym_offset);
+ PdbCompilandSymId cu_sym_id(modi, iter.offset());
// If the debug info is incorrect, we could have multiple symbols with the
// same address. So use try_emplace instead of insert, and the first one
@@ -201,7 +198,7 @@ CVSymbol PdbIndex::ReadSymbolRecord(PdbCompilandSymId cu_sym) const {
// We need to subtract 4 here to adjust for the codeview debug magic
// at the beginning of the debug info stream.
const CompilandIndexItem *cci = compilands().GetCompiland(cu_sym.modi);
- auto iter = cci->m_debug_stream.getSymbolArray().at(cu_sym.offset - 4);
+ auto iter = cci->m_debug_stream.getSymbolArray().at(cu_sym.offset);
lldbassert(iter != cci->m_debug_stream.getSymbolArray().end());
return *iter;
}
OpenPOWER on IntegriCloud