aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorKarl Schimpf <kschimpf@google.com>2013-08-14 09:08:17 -0700
committerKarl Schimpf <kschimpf@google.com>2013-08-14 09:08:17 -0700
commit1e864cc8d25b2cb67d3765bc0f8018278df571bf (patch)
tree2de6a750c3e2e910480fd8ff8da63f4efe4529bb /tools
parentb1a2aa7439342d336015de1ff7ca8098b562a8b6 (diff)
Allow record-level printing by pnacl-bcanalyzer.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3627 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/23060004
Diffstat (limited to 'tools')
-rw-r--r--tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp b/tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp
index 225827e47b..2e4ff2d162 100644
--- a/tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp
+++ b/tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp
@@ -15,6 +15,11 @@
// Options:
// --help - Output information about command line switches
// --dump - Dump low-level bitcode structure in readable format
+// --dump-records - Dump a neutral form of the low-level bitcode structure
+// in a readable form. This form doesn't print out summary
+// statistics. Also, unlike --dump, no bitstream file
+// encoding information is printed. Only the high-level
+// record data is dumped.
//
// This tool provides analytical information about a bitcode file. It is
// intended as an aid to developers of bitcode reading and writing software. It
@@ -54,6 +59,12 @@ static cl::opt<std::string>
static cl::opt<bool> Dump("dump", cl::desc("Dump low level bitcode trace"));
+static cl::opt<bool>
+ Records("dump-records",
+ cl::desc("Dump contents of records in bitcode, leaving out"
+ " all bitstreaming information (including abbreviations)"),
+ cl::init(false));
+
static cl::opt<unsigned> OpsPerLine(
"operands-per-line",
cl::desc("Number of operands to print per dump line. 0 implies "
@@ -361,8 +372,11 @@ static bool ParseBlock(NaClBitstreamCursor &Stream, unsigned BlockID,
if (NonSymbolic && BlockName)
outs() << " BlockID=" << BlockID;
- outs() << " NumWords=" << NumWords
- << " BlockCodeSize=" << Stream.getAbbrevIDWidth() << ">\n";
+ if (!Records) {
+ outs() << " NumWords=" << NumWords
+ << " BlockCodeSize=" << Stream.getAbbrevIDWidth();
+ }
+ outs() << ">\n";
}
SmallVector<uint64_t, 64> Record;
@@ -444,7 +458,7 @@ static bool ParseBlock(NaClBitstreamCursor &Stream, unsigned BlockID,
outs() << "UnknownCode" << Code;
if (NonSymbolic && CodeName)
outs() << " codeid=" << Code;
- if (Entry.ID != naclbitc::UNABBREV_RECORD)
+ if (!Records && Entry.ID != naclbitc::UNABBREV_RECORD)
outs() << " abbrevid=" << Entry.ID;
for (unsigned i = 0, e = Record.size(); i != e; ++i) {
@@ -544,6 +558,8 @@ static int AnalyzeBitcode() {
if (Dump) outs() << "\n\n";
+ if (Records) return 0;
+
uint64_t BufferSizeBits = (EndBufPtr-BufPtr)*CHAR_BIT;
// Print a summary of the read file.
outs() << "Summary of " << InputFilename << ":\n";
@@ -637,5 +653,7 @@ int main(int argc, char **argv) {
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
cl::ParseCommandLineOptions(argc, argv, "pnacl-bcanalyzer file analyzer\n");
+ if (Records) Dump = true;
+
return AnalyzeBitcode();
}