teak-llvm/llvm/lib/DebugInfo/CodeView/StringsAndChecksums.cpp
Zachary Turner a3da4467fa [codeview] Make obj2yaml/yaml2obj support .debug$S/T sections.
This allows us to use yaml2obj and obj2yaml to round-trip CodeView
symbol and type information without having to manually specify the bytes
of the section. This makes for much easier to maintain tests. See the
tests under lld/COFF in this patch for example. Before they just said
SectionData: <blob> whereas now we can use meaningful record
descriptions. Note that it still supports the SectionData yaml field,
which could be useful for initializing a section to invalid bytes for
testing, for example.

Differential Revision: https://reviews.llvm.org/D34127

llvm-svn: 305366
2017-06-14 05:31:00 +00:00

49 lines
1.7 KiB
C++

//===- StringsAndChecksums.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/StringsAndChecksums.h"
#include "llvm/DebugInfo/CodeView/DebugChecksumsSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
#include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h"
using namespace llvm;
using namespace llvm::codeview;
StringsAndChecksumsRef::StringsAndChecksumsRef() {}
StringsAndChecksumsRef::StringsAndChecksumsRef(
const DebugStringTableSubsectionRef &Strings)
: Strings(&Strings) {}
StringsAndChecksumsRef::StringsAndChecksumsRef(
const DebugStringTableSubsectionRef &Strings,
const DebugChecksumsSubsectionRef &Checksums)
: Strings(&Strings), Checksums(&Checksums) {}
void StringsAndChecksumsRef::initializeStrings(
const DebugSubsectionRecord &SR) {
assert(SR.kind() == DebugSubsectionKind::StringTable);
assert(!Strings && "Found a string table even though we already have one!");
OwnedStrings = llvm::make_unique<DebugStringTableSubsectionRef>();
consumeError(OwnedStrings->initialize(SR.getRecordData()));
Strings = OwnedStrings.get();
}
void StringsAndChecksumsRef::initializeChecksums(
const DebugSubsectionRecord &FCR) {
assert(FCR.kind() == DebugSubsectionKind::FileChecksums);
if (Checksums)
return;
OwnedChecksums = llvm::make_unique<DebugChecksumsSubsectionRef>();
consumeError(OwnedChecksums->initialize(FCR.getRecordData()));
Checksums = OwnedChecksums.get();
}