diff options
author | Alon Zakai <azakai@google.com> | 2020-10-21 09:24:29 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-21 09:24:29 -0700 |
commit | ddf0b590c48448176c9821669eedac6741434bd9 (patch) | |
tree | d3fd3d7127fc6b7878064e817d83a9ce9e4bbcb2 /src | |
parent | da68e75db7c4ca9c32d5c296499b51858d432c02 (diff) | |
download | binaryen-ddf0b590c48448176c9821669eedac6741434bd9.tar.gz binaryen-ddf0b590c48448176c9821669eedac6741434bd9.tar.bz2 binaryen-ddf0b590c48448176c9821669eedac6741434bd9.zip |
Fuzzer: Handle log_execution instrumentation, and warn on unknown imports (#3271)
log_execution can be useful to run on a fuzz testcase for debugging purposes. This
adds support to --fuzz-exec for printing out those values.
IOW, this PR allows the following debugging flow: you run
wasm-opt --log-execution
on the wasm, then run it in the fuzzer,
wasm-opt --fuzz-exec[-before]
and you get that logging printed out (showing where we enter functions, exit them,
etc.).
Also, in general --fuzz-exec ignores unknown imports (so that it can be run on more wasm
files, for at least some fuzz testing there). This also adds a warning in that case, so it
is less surprising (the behavior does not change in this PR).
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/execution-results.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/tools/execution-results.h b/src/tools/execution-results.h index 427100628..f57ffe101 100644 --- a/src/tools/execution-results.h +++ b/src/tools/execution-results.h @@ -40,7 +40,19 @@ struct LoggingExternalInterface : public ShellExternalInterface { loggings.push_back(argument); } std::cout << "]\n"; + return {}; + } else if (import->module == ENV) { + if (import->base == "log_execution") { + std::cout << "[LoggingExternalInterface log-execution"; + for (auto argument : arguments) { + std::cout << ' ' << argument; + } + std::cout << "]\n"; + return {}; + } } + std::cerr << "[LoggingExternalInterface ignoring an unknown import " + << import->module << " . " << import->base << '\n'; return {}; } }; |