mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-30 21:56:43 +00:00
[pdb] Add a pdb2yaml option to not dump file headers.
This will be useful once we start adding the ability to dump type records and symbol records, since it will allow us to generate mergeable information instead of information that specifies an entire file. llvm-svn: 275109
This commit is contained in:
parent
f52c3cf272
commit
f6b9382467
@ -1,5 +1,7 @@
|
||||
; RUN: llvm-pdbdump pdb2yaml -stream-metadata -stream-directory -pdb-stream %p/Inputs/empty.pdb \
|
||||
; RUN: | FileCheck -check-prefix=YAML %s
|
||||
; RUN: llvm-pdbdump pdb2yaml -no-file-headers -stream-metadata -stream-directory -pdb-stream \
|
||||
; RUN: %p/Inputs/empty.pdb | FileCheck -check-prefix=NO-HEADERS %s
|
||||
|
||||
; YAML: ---
|
||||
; YAML-NEXT: MSF:
|
||||
@ -74,3 +76,8 @@
|
||||
; YAML-NEXT: Signature: 1424295906
|
||||
; YAML-NEXT: Version: 20000404
|
||||
; YAML-NEXT: ...
|
||||
|
||||
; NO-HEADERS: ---
|
||||
; NO-HEADERS-NOT: MSF:
|
||||
; NO-HEADERS-NOT: SuperBlock:
|
||||
; NO-HEADERS: ...
|
@ -46,7 +46,7 @@ struct PdbInfoStream {
|
||||
};
|
||||
|
||||
struct PdbObject {
|
||||
MsfHeaders Headers;
|
||||
Optional<MsfHeaders> Headers;
|
||||
Optional<std::vector<support::ulittle32_t>> StreamSizes;
|
||||
Optional<std::vector<StreamBlockList>> StreamMap;
|
||||
Optional<PdbInfoStream> PdbStream;
|
||||
|
@ -42,20 +42,24 @@ Error YAMLOutputStyle::dump() {
|
||||
}
|
||||
|
||||
Error YAMLOutputStyle::dumpFileHeaders() {
|
||||
if (opts::pdb2yaml::NoFileHeaders)
|
||||
return Error::success();
|
||||
|
||||
yaml::MsfHeaders Headers;
|
||||
Obj.Headers.SuperBlock.NumBlocks = File.getBlockCount();
|
||||
Obj.Headers.SuperBlock.BlockMapAddr = File.getBlockMapIndex();
|
||||
Obj.Headers.BlockMapOffset = File.getBlockMapOffset();
|
||||
Obj.Headers.SuperBlock.BlockSize = File.getBlockSize();
|
||||
Obj.Headers.emplace();
|
||||
Obj.Headers->SuperBlock.NumBlocks = File.getBlockCount();
|
||||
Obj.Headers->SuperBlock.BlockMapAddr = File.getBlockMapIndex();
|
||||
Obj.Headers->BlockMapOffset = File.getBlockMapOffset();
|
||||
Obj.Headers->SuperBlock.BlockSize = File.getBlockSize();
|
||||
auto Blocks = File.getDirectoryBlockArray();
|
||||
Obj.Headers.DirectoryBlocks.assign(Blocks.begin(), Blocks.end());
|
||||
Obj.Headers.NumDirectoryBlocks = File.getNumDirectoryBlocks();
|
||||
Obj.Headers.SuperBlock.NumDirectoryBytes = File.getNumDirectoryBytes();
|
||||
Obj.Headers.NumStreams =
|
||||
Obj.Headers->DirectoryBlocks.assign(Blocks.begin(), Blocks.end());
|
||||
Obj.Headers->NumDirectoryBlocks = File.getNumDirectoryBlocks();
|
||||
Obj.Headers->SuperBlock.NumDirectoryBytes = File.getNumDirectoryBytes();
|
||||
Obj.Headers->NumStreams =
|
||||
opts::pdb2yaml::StreamMetadata ? File.getNumStreams() : 0;
|
||||
Obj.Headers.SuperBlock.Unknown0 = File.getUnknown0();
|
||||
Obj.Headers.SuperBlock.Unknown1 = File.getUnknown1();
|
||||
Obj.Headers.FileSize = File.getFileSize();
|
||||
Obj.Headers->SuperBlock.Unknown0 = File.getUnknown0();
|
||||
Obj.Headers->SuperBlock.Unknown1 = File.getUnknown1();
|
||||
Obj.Headers->FileSize = File.getFileSize();
|
||||
|
||||
return Error::success();
|
||||
}
|
||||
|
@ -261,18 +261,24 @@ cl::list<std::string> InputFilename(cl::Positional,
|
||||
}
|
||||
|
||||
namespace pdb2yaml {
|
||||
cl::opt<bool>
|
||||
NoFileHeaders("no-file-headers",
|
||||
cl::desc("Do not dump MSF file headers (you will not be able "
|
||||
"to generate a fresh PDB from the resulting YAML)"),
|
||||
cl::sub(PdbToYamlSubcommand), cl::init(false));
|
||||
|
||||
cl::opt<bool> StreamMetadata(
|
||||
"stream-metadata",
|
||||
cl::desc("Dump the number of streams and each stream's size"),
|
||||
cl::sub(PdbToYamlSubcommand));
|
||||
cl::sub(PdbToYamlSubcommand), cl::init(false));
|
||||
cl::opt<bool> StreamDirectory(
|
||||
"stream-directory",
|
||||
cl::desc("Dump each stream's block map (implies -stream-metadata)"),
|
||||
cl::sub(PdbToYamlSubcommand));
|
||||
cl::sub(PdbToYamlSubcommand), cl::init(false));
|
||||
cl::opt<bool> PdbStream(
|
||||
"pdb-stream",
|
||||
cl::desc("Dump the PDB Stream (Stream 1) (implies -stream-metadata)"),
|
||||
cl::sub(PdbToYamlSubcommand));
|
||||
cl::sub(PdbToYamlSubcommand), cl::init(false));
|
||||
|
||||
cl::list<std::string> InputFilename(cl::Positional,
|
||||
cl::desc("<input PDB file>"), cl::Required,
|
||||
@ -296,9 +302,12 @@ static void yamlToPdb(StringRef Path) {
|
||||
llvm::yaml::Input In(Buffer->getBuffer());
|
||||
pdb::yaml::PdbObject YamlObj;
|
||||
In >> YamlObj;
|
||||
if (!YamlObj.Headers.hasValue())
|
||||
ExitOnErr(make_error<GenericError>(generic_error_code::unspecified,
|
||||
"Yaml does not contain MSF headers"));
|
||||
|
||||
auto OutFileOrError = FileOutputBuffer::create(
|
||||
opts::yaml2pdb::YamlPdbOutputFile, YamlObj.Headers.FileSize);
|
||||
opts::yaml2pdb::YamlPdbOutputFile, YamlObj.Headers->FileSize);
|
||||
if (OutFileOrError.getError())
|
||||
ExitOnErr(make_error<GenericError>(generic_error_code::invalid_path,
|
||||
opts::yaml2pdb::YamlPdbOutputFile));
|
||||
@ -306,11 +315,11 @@ static void yamlToPdb(StringRef Path) {
|
||||
auto FileByteStream =
|
||||
llvm::make_unique<FileBufferByteStream>(std::move(*OutFileOrError));
|
||||
PDBFile Pdb(std::move(FileByteStream));
|
||||
ExitOnErr(Pdb.setSuperBlock(&YamlObj.Headers.SuperBlock));
|
||||
ExitOnErr(Pdb.setSuperBlock(&YamlObj.Headers->SuperBlock));
|
||||
if (YamlObj.StreamSizes.hasValue()) {
|
||||
Pdb.setStreamSizes(YamlObj.StreamSizes.getValue());
|
||||
}
|
||||
Pdb.setDirectoryBlocks(YamlObj.Headers.DirectoryBlocks);
|
||||
Pdb.setDirectoryBlocks(YamlObj.Headers->DirectoryBlocks);
|
||||
|
||||
if (YamlObj.StreamMap.hasValue()) {
|
||||
std::vector<ArrayRef<support::ulittle32_t>> StreamMap;
|
||||
|
@ -57,6 +57,7 @@ extern llvm::cl::opt<bool> DumpFpo;
|
||||
}
|
||||
|
||||
namespace pdb2yaml {
|
||||
extern llvm::cl::opt<bool> NoFileHeaders;
|
||||
extern llvm::cl::opt<bool> StreamMetadata;
|
||||
extern llvm::cl::opt<bool> StreamDirectory;
|
||||
extern llvm::cl::opt<bool> PdbStream;
|
||||
|
Loading…
x
Reference in New Issue
Block a user