mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-15 16:28:48 +00:00
[llvm-pdbdump] Restore error messages, handle bad block sizes
We lost the ability to report errors, bring it back. Also, correctly validate the block size. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267955 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
66bbcee0a9
commit
00a5029707
@ -127,7 +127,7 @@ std::error_code PDBFile::parseFileHeaders() {
|
||||
return std::make_error_code(std::errc::illegal_byte_sequence);
|
||||
|
||||
// We don't support blocksizes which aren't a multiple of four bytes.
|
||||
if (SB->BlockSize % sizeof(support::ulittle32_t) != 0)
|
||||
if (SB->BlockSize == 0 || SB->BlockSize % sizeof(support::ulittle32_t) != 0)
|
||||
return std::make_error_code(std::errc::not_supported);
|
||||
|
||||
// We don't support directories whose sizes aren't a multiple of four bytes.
|
||||
|
2
test/DebugInfo/PDB/Inputs/bad-block-size.pdb
Normal file
2
test/DebugInfo/PDB/Inputs/bad-block-size.pdb
Normal file
@ -0,0 +1,2 @@
|
||||
Microsoft C/C++ MSF 7.00
|
||||
DS
|
@ -1,5 +1,6 @@
|
||||
; RUN: llvm-pdbdump --dump-headers %p/Inputs/empty.pdb | FileCheck -check-prefix=EMPTY %s
|
||||
; RUN: llvm-pdbdump --dump-headers %p/Inputs/big-read.pdb | FileCheck -check-prefix=BIG %s
|
||||
; RUN: llvm-pdbdump --dump-headers %p/Inputs/bad-block-size.pdb | FileCheck -check-prefix=BAD-BLOCK-SIZE %s
|
||||
|
||||
; EMPTY: BlockSize: 4096
|
||||
; EMPTY-NEXT: Unknown0: 2
|
||||
@ -977,3 +978,5 @@ BIG-NEXT: Symbol Byte Size: 3080
|
||||
BIG-NEXT: Type Server Index: 0
|
||||
BIG-NEXT: Has EC Info: 0
|
||||
BIG-NEXT: 0 Contributing Source Files:
|
||||
|
||||
BAD-BLOCK-SIZE: The file has an unrecognized format.
|
||||
|
@ -308,20 +308,7 @@ static void dumpStructure(RawSession &RS) {
|
||||
}
|
||||
}
|
||||
|
||||
static void dumpInput(StringRef Path) {
|
||||
std::unique_ptr<IPDBSession> Session;
|
||||
if (opts::DumpHeaders || !opts::DumpStreamData.empty()) {
|
||||
PDB_ErrorCode Error = loadDataForPDB(PDB_ReaderType::Raw, Path, Session);
|
||||
if (Error == PDB_ErrorCode::Success) {
|
||||
RawSession *RS = static_cast<RawSession *>(Session.get());
|
||||
dumpStructure(*RS);
|
||||
}
|
||||
|
||||
outs().flush();
|
||||
return;
|
||||
}
|
||||
|
||||
PDB_ErrorCode Error = loadDataForPDB(PDB_ReaderType::DIA, Path, Session);
|
||||
static void reportError(StringRef Path, PDB_ErrorCode Error) {
|
||||
switch (Error) {
|
||||
case PDB_ErrorCode::Success:
|
||||
break;
|
||||
@ -347,6 +334,28 @@ static void dumpInput(StringRef Path) {
|
||||
<< "'. An unknown error occured.\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void dumpInput(StringRef Path) {
|
||||
std::unique_ptr<IPDBSession> Session;
|
||||
if (opts::DumpHeaders || !opts::DumpStreamData.empty()) {
|
||||
PDB_ErrorCode Error = loadDataForPDB(PDB_ReaderType::Raw, Path, Session);
|
||||
if (Error == PDB_ErrorCode::Success) {
|
||||
RawSession *RS = static_cast<RawSession *>(Session.get());
|
||||
dumpStructure(*RS);
|
||||
}
|
||||
|
||||
reportError(Path, Error);
|
||||
outs().flush();
|
||||
return;
|
||||
}
|
||||
|
||||
PDB_ErrorCode Error = loadDataForPDB(PDB_ReaderType::DIA, Path, Session);
|
||||
if (Error != PDB_ErrorCode::Success) {
|
||||
reportError(Path, Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (opts::LoadAddress)
|
||||
Session->setLoadAddress(opts::LoadAddress);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user