diff options
| author | Jordan Rose <jordan_rose@apple.com> | 2015-05-13 18:51:49 +0000 |
|---|---|---|
| committer | Jordan Rose <jordan_rose@apple.com> | 2015-05-13 18:51:49 +0000 |
| commit | 0fa38b8f96c3b0ad54b7c3077dcdc80a0cb0d7a2 (patch) | |
| tree | 8531bcca6d08309678cc57ab7bd3495caa51c0e4 /llvm/tools | |
| parent | e9119e41efb5230324d7f997af0db94235034ffc (diff) | |
| download | bcm5719-llvm-0fa38b8f96c3b0ad54b7c3077dcdc80a0cb0d7a2.tar.gz bcm5719-llvm-0fa38b8f96c3b0ad54b7c3077dcdc80a0cb0d7a2.zip | |
[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.
llvm-svn: 237276
Diffstat (limited to 'llvm/tools')
| -rw-r--r-- | llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp index 8aa5697f6ad..58b02be7b92 100644 --- a/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp +++ b/llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp @@ -66,6 +66,10 @@ static cl::opt<std::string> BlockInfoFilename("block-info", 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 { /// CurStreamTypeType - A type for CurStreamType @@ -460,17 +464,22 @@ static bool ParseBlock(BitstreamCursor &Stream, unsigned BlockID, if (Blob.data()) { outs() << " blob data = "; - bool BlobIsPrintable = true; - for (unsigned i = 0, e = Blob.size(); i != e; ++i) - if (!isprint(static_cast<unsigned char>(Blob[i]))) { - BlobIsPrintable = false; - break; - } - - if (BlobIsPrintable) - outs() << "'" << Blob << "'"; - else - outs() << "unprintable, " << Blob.size() << " bytes."; + if (ShowBinaryBlobs) { + outs() << "'"; + outs().write_escaped(Blob, /*hex=*/true) << "'"; + } else { + bool BlobIsPrintable = true; + for (unsigned i = 0, e = Blob.size(); i != e; ++i) + if (!isprint(static_cast<unsigned char>(Blob[i]))) { + BlobIsPrintable = false; + break; + } + + if (BlobIsPrintable) + outs() << "'" << Blob << "'"; + else + outs() << "unprintable, " << Blob.size() << " bytes."; + } } outs() << "\n"; |

