1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00
llvm-mirror/lib/DebugInfo/CodeView/ModuleSubstream.cpp
Zachary Turner 9277831e4a [codeview] Dump line number and column information.
To facilitate this, a couple of changes had to be made:

1. `ModuleSubstream` got moved from `DebugInfo/PDB` to
`DebugInfo/CodeView`, and various codeview related types are defined
there.  It turns out `DebugInfo/CodeView/Line.h` already defines many of
these structures, but this is really old code that is not endian aware,
doesn't interact well with `StreamInterface` and not very helpful for
getting stuff out of a PDB.  Eventually we should migrate the old readobj
`COFFDumper` code to these new structures, or at least merge their
functionality somehow.

2. A `ModuleSubstream` visitor is introduced.  Depending on where your
module substream array comes from, different subsets of record types can
be expected.  We are already hand parsing these substream arrays in many
places especially in `COFFDumper.cpp`.  In the future we can migrate these
paths to the visitor as well, which should reduce a lot of code in
`COFFDumper.cpp`.

Differential Revision: http://reviews.llvm.org/D20936
Reviewed By: ruiu, majnemer

llvm-svn: 271621
2016-06-03 03:25:59 +00:00

43 lines
1.3 KiB
C++

//===- ModuleSubstream.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/ModuleSubstream.h"
#include "llvm/DebugInfo/CodeView/StreamReader.h"
using namespace llvm;
using namespace llvm::codeview;
ModuleSubstream::ModuleSubstream() : Kind(ModuleSubstreamKind::None) {}
ModuleSubstream::ModuleSubstream(ModuleSubstreamKind Kind, StreamRef Data)
: Kind(Kind), Data(Data) {}
Error ModuleSubstream::initialize(StreamRef Stream, ModuleSubstream &Info) {
const ModuleSubsectionHeader *Header;
StreamReader Reader(Stream);
if (auto EC = Reader.readObject(Header))
return EC;
ModuleSubstreamKind Kind =
static_cast<ModuleSubstreamKind>(uint32_t(Header->Kind));
if (auto EC = Reader.readStreamRef(Info.Data, Header->Length))
return EC;
Info.Kind = Kind;
return Error::success();
}
uint32_t ModuleSubstream::getRecordLength() const {
return sizeof(ModuleSubsectionHeader) + Data.getLength();
}
ModuleSubstreamKind ModuleSubstream::getSubstreamKind() const { return Kind; }
StreamRef ModuleSubstream::getRecordData() const { return Data; }