diff options
author | Karl Schimpf <kschimpf@google.com> | 2013-07-03 09:56:04 -0700 |
---|---|---|
committer | Karl Schimpf <kschimpf@google.com> | 2013-07-03 09:56:04 -0700 |
commit | c5f0da9f2a5ffb5d9e8803839655f2f3d6972d83 (patch) | |
tree | 3e5e46f1a12c2742750cae6acba0ae8f9152e9ad /tools | |
parent | a6817fbfe9248e8992132206448eb5eda1745c92 (diff) |
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
Diffstat (limited to 'tools')
-rw-r--r-- | tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
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<std::string> static cl::opt<bool> Dump("dump", cl::desc("Dump low level bitcode trace")); +static cl::opt<unsigned> 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]; |