mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[llvm-pdbdump] Dump MSF headers to YAML.
This is the simplest possible patch to get some kind of YAML output. All it dumps is the MSF header fields so that in theory an empty MSF file could be reconstructed. Reviewed By: ruiu, majnemer Differential Revision: http://reviews.llvm.org/D20971 llvm-svn: 271939
This commit is contained in:
parent
8d4b0fab3b
commit
9cba8e4a60
17
test/DebugInfo/PDB/pdbdump-yaml.test
Normal file
17
test/DebugInfo/PDB/pdbdump-yaml.test
Normal file
@ -0,0 +1,17 @@
|
||||
; RUN: llvm-pdbdump -raw-headers -raw-output-style=YAML %p/Inputs/empty.pdb \
|
||||
; RUN: | FileCheck -check-prefix=YAML %s
|
||||
|
||||
; YAML: ---
|
||||
; YAML-NEXT: MSF:
|
||||
; YAML-NEXT: BlockSize: 4096
|
||||
; YAML-NEXT: Unknown0: 2
|
||||
; YAML-NEXT: NumBlocks: 25
|
||||
; YAML-NEXT: NumDirectoryBytes: 136
|
||||
; YAML-NEXT: Unknown1: 0
|
||||
; YAML-NEXT: BlockMapAddr: 24
|
||||
; YAML-NEXT: NumDirectoryBlocks: 1
|
||||
; YAML-NEXT: BlockMapOffset: 98304
|
||||
; YAML-NEXT: DirectoryBlocks:
|
||||
; YAML-NEXT: - 23
|
||||
; YAML-NEXT: NumStreams: 17
|
||||
; YAML-NEXT: ...
|
@ -15,9 +15,11 @@ add_llvm_tool(llvm-pdbdump
|
||||
FunctionDumper.cpp
|
||||
LinePrinter.cpp
|
||||
LLVMOutputStyle.cpp
|
||||
PdbYaml.cpp
|
||||
TypeDumper.cpp
|
||||
TypedefDumper.cpp
|
||||
VariableDumper.cpp
|
||||
YAMLOutputStyle.cpp
|
||||
)
|
||||
|
||||
if(LLVM_USE_SANITIZE_COVERAGE)
|
||||
|
@ -694,3 +694,4 @@ Error LLVMOutputStyle::dumpFpoStream() {
|
||||
}
|
||||
return Error::success();
|
||||
}
|
||||
void LLVMOutputStyle::flush() { P.flush(); }
|
||||
|
@ -35,6 +35,8 @@ public:
|
||||
Error dumpSectionHeaders() override;
|
||||
Error dumpFpoStream() override;
|
||||
|
||||
void flush() override;
|
||||
|
||||
private:
|
||||
PDBFile &File;
|
||||
ScopedPrinter P;
|
||||
|
@ -32,6 +32,8 @@ public:
|
||||
virtual Error dumpPublicsStream() = 0;
|
||||
virtual Error dumpSectionHeaders() = 0;
|
||||
virtual Error dumpFpoStream() = 0;
|
||||
|
||||
virtual void flush() = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
35
tools/llvm-pdbdump/PdbYaml.cpp
Normal file
35
tools/llvm-pdbdump/PdbYaml.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
//===- PdbYAML.cpp -------------------------------------------- *- C++ --*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "PdbYaml.h"
|
||||
|
||||
#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::pdb;
|
||||
using namespace llvm::pdb::yaml;
|
||||
|
||||
void llvm::yaml::MappingTraits<MsfHeaders>::mapping(
|
||||
IO &IO, pdb::yaml::MsfHeaders &Obj) {
|
||||
IO.mapRequired("BlockSize", Obj.BlockSize);
|
||||
IO.mapRequired("Unknown0", Obj.Unknown0);
|
||||
IO.mapRequired("NumBlocks", Obj.BlockCount);
|
||||
IO.mapRequired("NumDirectoryBytes", Obj.NumDirectoryBytes);
|
||||
IO.mapRequired("Unknown1", Obj.Unknown1);
|
||||
IO.mapRequired("BlockMapAddr", Obj.BlockMapIndex);
|
||||
IO.mapRequired("NumDirectoryBlocks", Obj.NumDirectoryBlocks);
|
||||
IO.mapRequired("BlockMapOffset", Obj.BlockMapOffset);
|
||||
IO.mapRequired("DirectoryBlocks", Obj.DirectoryBlocks);
|
||||
IO.mapRequired("NumStreams", Obj.NumStreams);
|
||||
}
|
||||
|
||||
void llvm::yaml::MappingTraits<pdb::yaml::PdbObject>::mapping(
|
||||
IO &IO, pdb::yaml::PdbObject &Obj) {
|
||||
IO.mapOptional("MSF", Obj.Headers);
|
||||
}
|
57
tools/llvm-pdbdump/PdbYaml.h
Normal file
57
tools/llvm-pdbdump/PdbYaml.h
Normal file
@ -0,0 +1,57 @@
|
||||
//===- PdbYAML.h ---------------------------------------------- *- C++ --*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H
|
||||
#define LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H
|
||||
|
||||
#include "OutputStyle.h"
|
||||
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/Support/Endian.h"
|
||||
#include "llvm/Support/YAMLTraits.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
namespace pdb {
|
||||
class PDBFile;
|
||||
|
||||
namespace yaml {
|
||||
struct MsfHeaders {
|
||||
uint32_t BlockSize;
|
||||
uint32_t Unknown0;
|
||||
uint32_t BlockCount;
|
||||
uint32_t NumDirectoryBytes;
|
||||
uint32_t Unknown1;
|
||||
uint32_t BlockMapIndex;
|
||||
uint32_t NumDirectoryBlocks;
|
||||
uint32_t BlockMapOffset;
|
||||
std::vector<uint32_t> DirectoryBlocks;
|
||||
uint32_t NumStreams;
|
||||
};
|
||||
|
||||
struct PdbObject {
|
||||
Optional<MsfHeaders> Headers;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
namespace yaml {
|
||||
template <> struct MappingTraits<pdb::yaml::MsfHeaders> {
|
||||
static void mapping(IO &IO, pdb::yaml::MsfHeaders &Obj);
|
||||
};
|
||||
template <> struct MappingTraits<pdb::yaml::PdbObject> {
|
||||
static void mapping(IO &IO, pdb::yaml::PdbObject &Obj);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
LLVM_YAML_IS_SEQUENCE_VECTOR(uint32_t)
|
||||
|
||||
#endif // LLVM_TOOLS_LLVMPDBDUMP_PDBYAML_H
|
126
tools/llvm-pdbdump/YAMLOutputStyle.cpp
Normal file
126
tools/llvm-pdbdump/YAMLOutputStyle.cpp
Normal file
@ -0,0 +1,126 @@
|
||||
//===- 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"
|
||||
|
||||
#include "llvm/DebugInfo/PDB/Raw/PDBFile.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::pdb;
|
||||
|
||||
YAMLOutputStyle::YAMLOutputStyle(PDBFile &File) : File(File), Out(outs()) {}
|
||||
|
||||
Error YAMLOutputStyle::dumpFileHeaders() {
|
||||
if (!opts::DumpHeaders)
|
||||
return Error::success();
|
||||
|
||||
yaml::MsfHeaders Headers;
|
||||
Headers.BlockCount = File.getBlockCount();
|
||||
Headers.BlockMapIndex = File.getBlockMapIndex();
|
||||
Headers.BlockMapOffset = File.getBlockMapOffset();
|
||||
Headers.BlockSize = File.getBlockSize();
|
||||
auto Blocks = File.getDirectoryBlockArray();
|
||||
Headers.DirectoryBlocks.assign(Blocks.begin(), Blocks.end());
|
||||
Headers.NumDirectoryBlocks = File.getNumDirectoryBlocks();
|
||||
Headers.NumDirectoryBytes = File.getNumDirectoryBytes();
|
||||
Headers.NumStreams = File.getNumStreams();
|
||||
Headers.Unknown0 = File.getUnknown0();
|
||||
Headers.Unknown1 = File.getUnknown1();
|
||||
|
||||
Obj.Headers.emplace(Headers);
|
||||
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
Error YAMLOutputStyle::dumpStreamSummary() {
|
||||
if (!opts::DumpStreamSummary)
|
||||
return Error::success();
|
||||
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
Error YAMLOutputStyle::dumpStreamBlocks() {
|
||||
if (!opts::DumpStreamBlocks)
|
||||
return Error::success();
|
||||
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
Error YAMLOutputStyle::dumpStreamData() {
|
||||
uint32_t StreamCount = File.getNumStreams();
|
||||
StringRef DumpStreamStr = opts::DumpStreamDataIdx;
|
||||
uint32_t DumpStreamNum;
|
||||
if (DumpStreamStr.getAsInteger(/*Radix=*/0U, DumpStreamNum) ||
|
||||
DumpStreamNum >= StreamCount)
|
||||
return Error::success();
|
||||
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
Error YAMLOutputStyle::dumpInfoStream() {
|
||||
if (!opts::DumpHeaders)
|
||||
return Error::success();
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
Error YAMLOutputStyle::dumpNamedStream() {
|
||||
if (opts::DumpStreamDataName.empty())
|
||||
return Error::success();
|
||||
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
Error YAMLOutputStyle::dumpTpiStream(uint32_t StreamIdx) {
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
Error YAMLOutputStyle::dumpDbiStream() { return Error::success(); }
|
||||
|
||||
Error YAMLOutputStyle::dumpSectionContribs() {
|
||||
if (!opts::DumpSectionContribs)
|
||||
return Error::success();
|
||||
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
Error YAMLOutputStyle::dumpSectionMap() {
|
||||
if (!opts::DumpSectionMap)
|
||||
return Error::success();
|
||||
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
Error YAMLOutputStyle::dumpPublicsStream() {
|
||||
if (!opts::DumpPublics)
|
||||
return Error::success();
|
||||
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
Error YAMLOutputStyle::dumpSectionHeaders() {
|
||||
if (!opts::DumpSectionHeaders)
|
||||
return Error::success();
|
||||
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
Error YAMLOutputStyle::dumpFpoStream() {
|
||||
if (!opts::DumpFpo)
|
||||
return Error::success();
|
||||
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
void YAMLOutputStyle::flush() {
|
||||
Out << Obj;
|
||||
outs().flush();
|
||||
}
|
51
tools/llvm-pdbdump/YAMLOutputStyle.h
Normal file
51
tools/llvm-pdbdump/YAMLOutputStyle.h
Normal file
@ -0,0 +1,51 @@
|
||||
//===- YAMLOutputStyle.h -------------------------------------- *- C++ --*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_TOOLS_LLVMPDBDUMP_YAMLOUTPUTSTYLE_H
|
||||
#define LLVM_TOOLS_LLVMPDBDUMP_YAMLOUTPUTSTYLE_H
|
||||
|
||||
#include "OutputStyle.h"
|
||||
#include "PdbYaml.h"
|
||||
|
||||
#include "llvm/DebugInfo/CodeView/TypeDumper.h"
|
||||
#include "llvm/Support/ScopedPrinter.h"
|
||||
#include "llvm/Support/YAMLTraits.h"
|
||||
|
||||
namespace llvm {
|
||||
namespace pdb {
|
||||
class YAMLOutputStyle : public OutputStyle {
|
||||
public:
|
||||
YAMLOutputStyle(PDBFile &File);
|
||||
|
||||
Error dumpFileHeaders() override;
|
||||
Error dumpStreamSummary() override;
|
||||
Error dumpStreamBlocks() override;
|
||||
Error dumpStreamData() override;
|
||||
Error dumpInfoStream() override;
|
||||
Error dumpNamedStream() override;
|
||||
Error dumpTpiStream(uint32_t StreamIdx) override;
|
||||
Error dumpDbiStream() override;
|
||||
Error dumpSectionContribs() override;
|
||||
Error dumpSectionMap() override;
|
||||
Error dumpPublicsStream() override;
|
||||
Error dumpSectionHeaders() override;
|
||||
Error dumpFpoStream() override;
|
||||
|
||||
void flush() override;
|
||||
|
||||
private:
|
||||
PDBFile &File;
|
||||
llvm::yaml::Output Out;
|
||||
|
||||
yaml::PdbObject Obj;
|
||||
};
|
||||
} // namespace pdb
|
||||
} // namespace llvm
|
||||
|
||||
#endif // LLVM_TOOLS_LLVMPDBDUMP_YAMLOUTPUTSTYLE_H
|
@ -22,6 +22,7 @@
|
||||
#include "OutputStyle.h"
|
||||
#include "TypeDumper.h"
|
||||
#include "VariableDumper.h"
|
||||
#include "YAMLOutputStyle.h"
|
||||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/BitVector.h"
|
||||
@ -211,6 +212,8 @@ static Error dumpStructure(RawSession &RS) {
|
||||
std::unique_ptr<OutputStyle> O;
|
||||
if (opts::RawOutputStyle == opts::OutputStyleTy::LLVM)
|
||||
O = llvm::make_unique<LLVMOutputStyle>(File);
|
||||
else if (opts::RawOutputStyle == opts::OutputStyleTy::YAML)
|
||||
O = llvm::make_unique<YAMLOutputStyle>(File);
|
||||
else
|
||||
return make_error<RawError>(raw_error_code::feature_unsupported,
|
||||
"Requested output style unsupported");
|
||||
@ -256,6 +259,7 @@ static Error dumpStructure(RawSession &RS) {
|
||||
|
||||
if (auto EC = O->dumpFpoStream())
|
||||
return EC;
|
||||
O->flush();
|
||||
return Error::success();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user