2016-06-07 04:37:05 +08:00
|
|
|
//===- YAMLOutputStyle.cpp ------------------------------------ *- C++ --*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "YAMLOutputStyle.h"
|
|
|
|
|
|
|
|
#include "PdbYaml.h"
|
|
|
|
#include "llvm-pdbdump.h"
|
|
|
|
|
2016-07-01 01:42:48 +08:00
|
|
|
#include "llvm/DebugInfo/PDB/Raw/RawConstants.h"
|
2016-06-07 04:37:05 +08:00
|
|
|
#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
using namespace llvm::pdb;
|
|
|
|
|
|
|
|
YAMLOutputStyle::YAMLOutputStyle(PDBFile &File) : File(File), Out(outs()) {}
|
|
|
|
|
2016-07-01 01:42:48 +08:00
|
|
|
Error YAMLOutputStyle::dump() {
|
|
|
|
if (auto EC = dumpFileHeaders())
|
|
|
|
return EC;
|
|
|
|
|
|
|
|
if (auto EC = dumpStreamMetadata())
|
|
|
|
return EC;
|
|
|
|
|
|
|
|
if (auto EC = dumpStreamDirectory())
|
|
|
|
return EC;
|
|
|
|
|
|
|
|
flush();
|
|
|
|
return Error::success();
|
|
|
|
}
|
2016-06-07 04:37:05 +08:00
|
|
|
|
2016-07-01 01:42:48 +08:00
|
|
|
Error YAMLOutputStyle::dumpFileHeaders() {
|
2016-06-07 04:37:05 +08:00
|
|
|
yaml::MsfHeaders Headers;
|
2016-06-15 04:48:36 +08:00
|
|
|
Obj.Headers.SuperBlock.NumBlocks = File.getBlockCount();
|
|
|
|
Obj.Headers.SuperBlock.BlockMapAddr = File.getBlockMapIndex();
|
|
|
|
Obj.Headers.BlockMapOffset = File.getBlockMapOffset();
|
|
|
|
Obj.Headers.SuperBlock.BlockSize = File.getBlockSize();
|
2016-06-07 04:37:05 +08:00
|
|
|
auto Blocks = File.getDirectoryBlockArray();
|
2016-06-15 04:48:36 +08:00
|
|
|
Obj.Headers.DirectoryBlocks.assign(Blocks.begin(), Blocks.end());
|
|
|
|
Obj.Headers.NumDirectoryBlocks = File.getNumDirectoryBlocks();
|
|
|
|
Obj.Headers.SuperBlock.NumDirectoryBytes = File.getNumDirectoryBytes();
|
2016-07-01 01:42:48 +08:00
|
|
|
Obj.Headers.NumStreams = opts::pdb2yaml::StreamMetadata ? File.getNumStreams() : 0;
|
2016-06-15 04:48:36 +08:00
|
|
|
Obj.Headers.SuperBlock.Unknown0 = File.getUnknown0();
|
|
|
|
Obj.Headers.SuperBlock.Unknown1 = File.getUnknown1();
|
|
|
|
Obj.Headers.FileSize = File.getFileSize();
|
2016-06-07 04:37:05 +08:00
|
|
|
|
|
|
|
return Error::success();
|
|
|
|
}
|
|
|
|
|
2016-07-01 01:42:48 +08:00
|
|
|
Error YAMLOutputStyle::dumpStreamMetadata() {
|
|
|
|
if (!opts::pdb2yaml::StreamMetadata)
|
2016-06-07 04:37:05 +08:00
|
|
|
return Error::success();
|
|
|
|
|
2016-06-15 04:48:36 +08:00
|
|
|
Obj.StreamSizes = File.getStreamSizes();
|
2016-06-07 04:37:05 +08:00
|
|
|
return Error::success();
|
|
|
|
}
|
|
|
|
|
2016-07-01 01:42:48 +08:00
|
|
|
Error YAMLOutputStyle::dumpStreamDirectory() {
|
|
|
|
if (!opts::pdb2yaml::StreamDirectory)
|
2016-06-07 04:37:05 +08:00
|
|
|
return Error::success();
|
|
|
|
|
2016-06-15 04:48:36 +08:00
|
|
|
auto StreamMap = File.getStreamMap();
|
|
|
|
Obj.StreamMap.emplace();
|
|
|
|
for (auto &Stream : StreamMap) {
|
|
|
|
pdb::yaml::StreamBlockList BlockList;
|
|
|
|
BlockList.Blocks = Stream;
|
|
|
|
Obj.StreamMap->push_back(BlockList);
|
2016-06-07 04:37:17 +08:00
|
|
|
}
|
|
|
|
|
2016-06-07 04:37:05 +08:00
|
|
|
return Error::success();
|
|
|
|
}
|
|
|
|
|
|
|
|
void YAMLOutputStyle::flush() {
|
|
|
|
Out << Obj;
|
|
|
|
outs().flush();
|
|
|
|
}
|