summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.cpp
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-04-27 16:12:16 +0000
committerZachary Turner <zturner@google.com>2017-04-27 16:12:16 +0000
commitc37cb0c6a5c266f102c130bfe1daaa25329cb997 (patch)
tree48cd2b14c7b818b9b1a6eec14ae4518ee2dc195d /llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.cpp
parente5094474187a9b748589aa709c3e1e172d42e87f (diff)
downloadbcm5719-llvm-c37cb0c6a5c266f102c130bfe1daaa25329cb997.tar.gz
bcm5719-llvm-c37cb0c6a5c266f102c130bfe1daaa25329cb997.zip
[CodeView] Isolate Debug Info Fragments into standalone classes.
Previously parsing of these were all grouped together into a single master class that could parse any type of debug info fragment. With writing forthcoming, the complexity of each individual fragment is enough to warrant them having their own classes so that reading and writing of each fragment type can be grouped together, but isolated from the code for reading and writing other fragment types. In doing so, I found a place where parsing code was duplicated for the FileChecksums fragment, across llvm-readobj and the CodeView library, and one of the implementations had a bug. Now that the codepaths are merged, the bug is resolved. Differential Revision: https://reviews.llvm.org/D32547 llvm-svn: 301557
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.cpp')
-rw-r--r--llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.cpp b/llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.cpp
new file mode 100644
index 00000000000..20c06e9bebe
--- /dev/null
+++ b/llvm/lib/DebugInfo/CodeView/ModuleDebugFragmentRecord.cpp
@@ -0,0 +1,47 @@
+//===- ModuleDebugFragmentRecord.cpp -----------------------------*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h"
+
+#include "llvm/Support/BinaryStreamReader.h"
+
+using namespace llvm;
+using namespace llvm::codeview;
+
+ModuleDebugFragmentRecord::ModuleDebugFragmentRecord()
+ : Kind(ModuleDebugFragmentKind::None) {}
+
+ModuleDebugFragmentRecord::ModuleDebugFragmentRecord(
+ ModuleDebugFragmentKind Kind, BinaryStreamRef Data)
+ : Kind(Kind), Data(Data) {}
+
+Error ModuleDebugFragmentRecord::initialize(BinaryStreamRef Stream,
+ ModuleDebugFragmentRecord &Info) {
+ const ModuleDebugFragmentHeader *Header;
+ BinaryStreamReader Reader(Stream);
+ if (auto EC = Reader.readObject(Header))
+ return EC;
+
+ ModuleDebugFragmentKind Kind =
+ static_cast<ModuleDebugFragmentKind>(uint32_t(Header->Kind));
+ if (auto EC = Reader.readStreamRef(Info.Data, Header->Length))
+ return EC;
+ Info.Kind = Kind;
+ return Error::success();
+}
+
+uint32_t ModuleDebugFragmentRecord::getRecordLength() const {
+ return sizeof(ModuleDebugFragmentHeader) + Data.getLength();
+}
+
+ModuleDebugFragmentKind ModuleDebugFragmentRecord::kind() const { return Kind; }
+
+BinaryStreamRef ModuleDebugFragmentRecord::getRecordData() const {
+ return Data;
+}
OpenPOWER on IntegriCloud