summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/CodeView
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-05-31 18:45:36 +0000
committerReid Kleckner <rnk@google.com>2016-05-31 18:45:36 +0000
commitfbdbe9e22ba3a383fff73546ff59b94f8a46f595 (patch)
treebaafed3a6f17cdf913171072f294c03aef771530 /llvm/lib/DebugInfo/CodeView
parent7aa4d977eaf3bf8122263227a6af3f5bd32390fd (diff)
downloadbcm5719-llvm-fbdbe9e22ba3a383fff73546ff59b94f8a46f595.tar.gz
bcm5719-llvm-fbdbe9e22ba3a383fff73546ff59b94f8a46f595.zip
[codeview] Improve readability of type record assembly
Adds the method MCStreamer::EmitBinaryData, which is usually an alias for EmitBytes. In the MCAsmStreamer case, it is overridden to emit hex dump output like this: .byte 0x0e, 0x00, 0x08, 0x10 .byte 0x03, 0x00, 0x00, 0x00 .byte 0x00, 0x00, 0x00, 0x00 .byte 0x00, 0x10, 0x00, 0x00 Also, when verbose asm comments are enabled, this patch prints the dump output for each comment before its record, like this: # ArgList (0x1000) { # TypeLeafKind: LF_ARGLIST (0x1201) # NumArgs: 0 # Arguments [ # ] # } .byte 0x06, 0x00, 0x01, 0x12 .byte 0x00, 0x00, 0x00, 0x00 This should make debugging easier and testing more convenient. Reviewers: aaboud Subscribers: majnemer, zturner, amccarth, aaboud, llvm-commits Differential Revision: http://reviews.llvm.org/D20711 llvm-svn: 271313
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView')
-rw-r--r--llvm/lib/DebugInfo/CodeView/MemoryTypeTableBuilder.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/MemoryTypeTableBuilder.cpp b/llvm/lib/DebugInfo/CodeView/MemoryTypeTableBuilder.cpp
index 9afce92eeb1..8b9e73b94ff 100644
--- a/llvm/lib/DebugInfo/CodeView/MemoryTypeTableBuilder.cpp
+++ b/llvm/lib/DebugInfo/CodeView/MemoryTypeTableBuilder.cpp
@@ -13,23 +13,34 @@
using namespace llvm;
using namespace codeview;
-MemoryTypeTableBuilder::Record::Record(StringRef RData)
- : Size(RData.size()), Data(new char[RData.size()]) {
- memcpy(Data.get(), RData.data(), RData.size());
-}
-
TypeIndex MemoryTypeTableBuilder::writeRecord(StringRef Data) {
+ assert(Data.size() <= UINT16_MAX);
auto I = HashedRecords.find(Data);
if (I != HashedRecords.end()) {
return I->second;
}
- std::unique_ptr<Record> R(new Record(Data));
+ // The record provided by the user lacks the 2 byte size field prefix and is
+ // not padded to 4 bytes. Ultimately, that is what gets emitted in the object
+ // file, so pad it out now.
+ const int SizeOfRecLen = 2;
+ const int Align = 4;
+ int TotalSize = alignTo(Data.size() + SizeOfRecLen, Align);
+ assert(TotalSize - SizeOfRecLen <= UINT16_MAX);
+ char *Mem =
+ reinterpret_cast<char *>(RecordStorage.Allocate(TotalSize, Align));
+ *reinterpret_cast<ulittle16_t *>(Mem) = uint16_t(TotalSize - SizeOfRecLen);
+ memcpy(Mem + SizeOfRecLen, Data.data(), Data.size());
+ for (int I = Data.size() + SizeOfRecLen; I < TotalSize; ++I)
+ Mem[I] = LF_PAD0 + (TotalSize - I);
TypeIndex TI(static_cast<uint32_t>(Records.size()) +
TypeIndex::FirstNonSimpleIndex);
- HashedRecords.insert(std::make_pair(StringRef(R->data(), R->size()), TI));
- Records.push_back(std::move(R));
+
+ // Use only the data supplied by the user as a key to the hash table, so that
+ // future lookups will succeed.
+ HashedRecords.insert(std::make_pair(StringRef(Mem + SizeOfRecLen, Data.size()), TI));
+ Records.push_back(StringRef(Mem, TotalSize));
return TI;
}
OpenPOWER on IntegriCloud