mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 16:17:17 +00:00
[llvm-bcanalyzer] Add -show-binary-blobs option.
-dump mode normally omits blob data that contains unprintable characters. When -show-binary-blobs is passed, it unilaterally escapes all blobs, allowing those with binary data to be displayed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237276 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -66,6 +66,10 @@ static cl::opt<std::string>
|
|||||||
BlockInfoFilename("block-info",
|
BlockInfoFilename("block-info",
|
||||||
cl::desc("Use the BLOCK_INFO from the given file"));
|
cl::desc("Use the BLOCK_INFO from the given file"));
|
||||||
|
|
||||||
|
static cl::opt<bool>
|
||||||
|
ShowBinaryBlobs("show-binary-blobs",
|
||||||
|
cl::desc("Print binary blobs using hex escapes"));
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
/// CurStreamTypeType - A type for CurStreamType
|
/// CurStreamTypeType - A type for CurStreamType
|
||||||
@@ -460,6 +464,10 @@ static bool ParseBlock(BitstreamCursor &Stream, unsigned BlockID,
|
|||||||
|
|
||||||
if (Blob.data()) {
|
if (Blob.data()) {
|
||||||
outs() << " blob data = ";
|
outs() << " blob data = ";
|
||||||
|
if (ShowBinaryBlobs) {
|
||||||
|
outs() << "'";
|
||||||
|
outs().write_escaped(Blob, /*hex=*/true) << "'";
|
||||||
|
} else {
|
||||||
bool BlobIsPrintable = true;
|
bool BlobIsPrintable = true;
|
||||||
for (unsigned i = 0, e = Blob.size(); i != e; ++i)
|
for (unsigned i = 0, e = Blob.size(); i != e; ++i)
|
||||||
if (!isprint(static_cast<unsigned char>(Blob[i]))) {
|
if (!isprint(static_cast<unsigned char>(Blob[i]))) {
|
||||||
@@ -472,6 +480,7 @@ static bool ParseBlock(BitstreamCursor &Stream, unsigned BlockID,
|
|||||||
else
|
else
|
||||||
outs() << "unprintable, " << Blob.size() << " bytes.";
|
outs() << "unprintable, " << Blob.size() << " bytes.";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
outs() << "\n";
|
outs() << "\n";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user