diff options
author | Sam Clegg <sbc@chromium.org> | 2019-12-04 02:19:51 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-04 02:19:51 -0600 |
commit | f346478e1eb510d61c603eb6533d2c01f413e47a (patch) | |
tree | bbc85b45d2649c16ce2d228330235a9a59aae6c6 /src/tools/wasm-opt.cpp | |
parent | 9cbe295d20dd8bf625e16f26953cb19d35c6daee (diff) | |
download | binaryen-f346478e1eb510d61c603eb6533d2c01f413e47a.tar.gz binaryen-f346478e1eb510d61c603eb6533d2c01f413e47a.tar.bz2 binaryen-f346478e1eb510d61c603eb6533d2c01f413e47a.zip |
Add BYN_DEBUG/BYN_TRACE macros similar to LLVM's debug system (#2496)
This allows for debug trace message to be split my channel. So you
can pass `--debug` to simply debug everything, or `--debug=opt`
to only debug wasm-opt.
This change is the initial introduction but as a followup I hope to
convert all tracing over to this new system so we can more easily
control the debug output.
Diffstat (limited to 'src/tools/wasm-opt.cpp')
-rw-r--r-- | src/tools/wasm-opt.cpp | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/src/tools/wasm-opt.cpp b/src/tools/wasm-opt.cpp index b2d1f2c14..1964019a5 100644 --- a/src/tools/wasm-opt.cpp +++ b/src/tools/wasm-opt.cpp @@ -29,6 +29,7 @@ #include "shell-interface.h" #include "spec-wrapper.h" #include "support/command-line.h" +#include "support/debug.h" #include "support/file.h" #include "wasm-binary.h" #include "wasm-interpreter.h" @@ -37,6 +38,8 @@ #include "wasm-s-parser.h" #include "wasm-validator.h" +#define DEBUG_TYPE "opt" + using namespace wasm; // runs a command and returns its output TODO: portability, return code checking @@ -203,9 +206,7 @@ int main(int argc, const char* argv[]) { Module wasm; - if (options.debug) { - std::cerr << "reading...\n"; - } + BYN_TRACE("reading...\n"); if (!translateToFuzz) { ModuleReader reader; @@ -282,10 +283,7 @@ int main(int argc, const char* argv[]) { std::string firstOutput; if (extraFuzzCommand.size() > 0 && options.extra.count("output") > 0) { - if (options.debug) { - std::cerr << "writing binary before opts, for extra fuzz command..." - << std::endl; - } + BYN_TRACE("writing binary before opts, for extra fuzz command...\n"); ModuleWriter writer; writer.setDebug(options.debug); writer.setBinary(emitBinary); @@ -323,9 +321,7 @@ int main(int argc, const char* argv[]) { std::cerr << "warning: no passes specified, not doing any work\n"; } } else { - if (options.debug) { - std::cerr << "running passes...\n"; - } + BYN_TRACE("running passes...\n"); auto runPasses = [&]() { options.runPasses(*curr); if (options.passOptions.validate) { @@ -348,10 +344,7 @@ int main(int argc, const char* argv[]) { }; auto lastSize = getSize(); while (1) { - if (options.debug) { - std::cerr << "running iteration for convergence (" << lastSize - << ")...\n"; - } + BYN_TRACE("running iteration for convergence (" << lastSize << ")..\n"); runPasses(); auto currSize = getSize(); if (currSize >= lastSize) { @@ -373,9 +366,7 @@ int main(int argc, const char* argv[]) { return 0; } - if (options.debug) { - std::cerr << "writing..." << std::endl; - } + BYN_TRACE("writing...\n"); ModuleWriter writer; writer.setDebug(options.debug); writer.setBinary(emitBinary); |