From c5f0da9f2a5ffb5d9e8803839655f2f3d6972d83 Mon Sep 17 00:00:00 2001 From: Karl Schimpf Date: Wed, 3 Jul 2013 09:56:04 -0700 Subject: Cleanup output of pnacl-bcanalyzer. (1) Fix spacing in header of record histogram so that columns line up. (2) Only print 8 operands per line in the dump. Keeps lines from getting too long. BUG=None R=jvoung@chromium.org, mseaborn@chromium.org Review URL: https://codereview.chromium.org/18147006 --- tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'tools') diff --git a/tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp b/tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp index 7a44542022..225827e47b 100644 --- a/tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp +++ b/tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp @@ -54,6 +54,12 @@ static cl::opt static cl::opt Dump("dump", cl::desc("Dump low level bitcode trace")); +static cl::opt OpsPerLine( + "operands-per-line", + cl::desc("Number of operands to print per dump line. 0 implies " + "all operands will be printed on the same line (default)"), + cl::init(0)); + //===----------------------------------------------------------------------===// // Bitcode specific analysis. //===----------------------------------------------------------------------===// @@ -430,19 +436,29 @@ static bool ParseBlock(NaClBitstreamCursor &Stream, unsigned BlockID, if (Dump) { outs() << Indent << " <"; - if (const char *CodeName = - GetCodeName(Code, BlockID, *Stream.getBitStreamReader())) + const char *CodeName = + GetCodeName(Code, BlockID, *Stream.getBitStreamReader()); + if (CodeName) outs() << CodeName; else outs() << "UnknownCode" << Code; - if (NonSymbolic && - GetCodeName(Code, BlockID, *Stream.getBitStreamReader())) + if (NonSymbolic && CodeName) outs() << " codeid=" << Code; if (Entry.ID != naclbitc::UNABBREV_RECORD) outs() << " abbrevid=" << Entry.ID; - for (unsigned i = 0, e = Record.size(); i != e; ++i) + for (unsigned i = 0, e = Record.size(); i != e; ++i) { + if (OpsPerLine && (i % OpsPerLine) == 0 && i > 0) { + outs() << "\n" << Indent << " "; + if (CodeName) { + for (unsigned j = 0; j < strlen(CodeName); ++j) + outs() << " "; + } else { + outs() << " "; + } + } outs() << " op" << i << "=" << (int64_t)Record[i]; + } outs() << "/>"; @@ -584,7 +600,7 @@ static int AnalyzeBitcode() { std::reverse(FreqPairs.begin(), FreqPairs.end()); outs() << "\tRecord Histogram:\n"; - outs() << "\t\t Count # Bits %% Abv Record Kind\n"; + outs() << "\t\t Count # Bits %% Abv Record Kind\n"; for (unsigned i = 0, e = FreqPairs.size(); i != e; ++i) { const PerRecordStats &RecStats = Stats.CodeFreq[FreqPairs[i].second]; -- cgit v1.2.3-18-g5258