summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2017-06-19 17:21:45 +0000
committerReid Kleckner <rnk@google.com>2017-06-19 17:21:45 +0000
commit44cdb1096499982c1f46eadb5572792131cbd8b0 (patch)
tree3a410c90675e8f8626883367e0f590f8a265a371 /llvm/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp
parent214b354f2ea3eb050dc8b6b4e2cd7f4af1f32f5a (diff)
downloadbcm5719-llvm-44cdb1096499982c1f46eadb5572792131cbd8b0.tar.gz
bcm5719-llvm-44cdb1096499982c1f46eadb5572792131cbd8b0.zip
[PDB] Start emitting source file and line information
Summary: This is a first step towards getting line info to show up in VS and windbg. So far, only llvm-pdbutil can parse the PDBs that we produce. cvdump doesn't like something about our file checksum tables. I'll have to dig into that next. This patch adds a new DebugSubsectionRecordBuilder which takes bytes directly from some other producer, such as a linker, and sticks it into the PDB. Line tables only need to be relocated. No data needs to be rewritten. File checksums and string tables, on the other hand, need to be re-done. Reviewers: zturner, ruiu Subscribers: llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D34257 llvm-svn: 305713
Diffstat (limited to 'llvm/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp')
-rw-r--r--llvm/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/llvm/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp b/llvm/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp
index 334c5e002bb..d69eca018e0 100644
--- a/llvm/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp
+++ b/llvm/lib/DebugInfo/CodeView/DebugSubsectionRecord.cpp
@@ -53,12 +53,16 @@ DebugSubsectionRecordBuilder::DebugSubsectionRecordBuilder(
std::shared_ptr<DebugSubsection> Subsection, CodeViewContainer Container)
: Subsection(std::move(Subsection)), Container(Container) {}
+DebugSubsectionRecordBuilder::DebugSubsectionRecordBuilder(
+ const DebugSubsectionRecord &Contents, CodeViewContainer Container)
+ : Contents(Contents), Container(Container) {}
+
uint32_t DebugSubsectionRecordBuilder::calculateSerializedLength() {
- // The length of the entire subsection is always padded to 4 bytes, regardless
- // of the container kind.
- uint32_t Size = sizeof(DebugSubsectionHeader) +
- alignTo(Subsection->calculateSerializedSize(), 4);
- return Size;
+ uint32_t DataSize = Subsection ? Subsection->calculateSerializedSize()
+ : Contents.getRecordData().getLength();
+ // The length of the entire subsection is always padded to 4 bytes,
+ // regardless of the container kind.
+ return sizeof(DebugSubsectionHeader) + alignTo(DataSize, 4);
}
Error DebugSubsectionRecordBuilder::commit(BinaryStreamWriter &Writer) const {
@@ -66,16 +70,22 @@ Error DebugSubsectionRecordBuilder::commit(BinaryStreamWriter &Writer) const {
"Debug Subsection not properly aligned");
DebugSubsectionHeader Header;
- Header.Kind = uint32_t(Subsection->kind());
+ Header.Kind = uint32_t(Subsection ? Subsection->kind() : Contents.kind());
// The value written into the Header's Length field is only padded to the
// container's alignment
- Header.Length =
- alignTo(Subsection->calculateSerializedSize(), alignOf(Container));
+ uint32_t DataSize = Subsection ? Subsection->calculateSerializedSize()
+ : Contents.getRecordData().getLength();
+ Header.Length = alignTo(DataSize, alignOf(Container));
if (auto EC = Writer.writeObject(Header))
return EC;
- if (auto EC = Subsection->commit(Writer))
- return EC;
+ if (Subsection) {
+ if (auto EC = Subsection->commit(Writer))
+ return EC;
+ } else {
+ if (auto EC = Writer.writeStreamRef(Contents.getRecordData()))
+ return EC;
+ }
if (auto EC = Writer.padToAlignment(4))
return EC;
OpenPOWER on IntegriCloud