diff options
author | Ben Smith <binjimin@gmail.com> | 2017-09-26 19:02:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-26 19:02:54 -0700 |
commit | a5a4007efcf9f3386b76835cd647426560068ca7 (patch) | |
tree | be1bf30abf2a9a79a41ff089fd4dd1eaf071504f /src/binary-reader-objdump.cc | |
parent | c26acf2f6d4788dc2d1a582b5b10d93c8d87d6b7 (diff) | |
download | wabt-a5a4007efcf9f3386b76835cd647426560068ca7.tar.gz wabt-a5a4007efcf9f3386b76835cd647426560068ca7.tar.bz2 wabt-a5a4007efcf9f3386b76835cd647426560068ca7.zip |
[wasm-objdump] Continue reading sections on error (#636)
wasm-objdump wants to always try to read as much of the binary as
possible. This change adds a new BinaryReader option called
stop_on_first_error which can be set to false to enable this behavior.
Currently this will bail on any error in a section, but will try to read
the next section. We may expand the error-handling behavior to try and
recover inside of a section as well, but it's probably best to keep it
simple for now.
Because wasm-objdump does multiple passes over the binary, the errors
would normally be displayed multiple times. We also add a OnError
override which will suppress the error message for all passes other than
the first.
Diffstat (limited to 'src/binary-reader-objdump.cc')
-rw-r--r-- | src/binary-reader-objdump.cc | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc index 67b27cdc..d77cb8ad 100644 --- a/src/binary-reader-objdump.cc +++ b/src/binary-reader-objdump.cc @@ -37,6 +37,8 @@ class BinaryReaderObjdumpBase : public BinaryReaderNop { ObjdumpOptions* options, ObjdumpState* state); + bool OnError(const char* message) override; + Result BeginModule(uint32_t version) override; Result BeginSection(BinarySection section_type, Offset size) override; @@ -78,6 +80,13 @@ Result BinaryReaderObjdumpBase::BeginSection(BinarySection section_code, return Result::Ok; } +bool BinaryReaderObjdumpBase::OnError(const char* message) { + // Tell the BinaryReader that this error is "handled" for all passes other + // than the prepass. When the error is handled the default message will be + // suppressed. + return options_->mode != ObjdumpMode::Prepass; +} + Result BinaryReaderObjdumpBase::BeginModule(uint32_t version) { switch (options_->mode) { case ObjdumpMode::Headers: @@ -1129,7 +1138,10 @@ Result ReadBinaryObjdump(const uint8_t* data, ObjdumpState* state) { Features features; features.EnableAll(); - ReadBinaryOptions read_options(features, options->log_stream, true); + const bool kReadDebugNames = true; + const bool kStopOnFirstError = false; + ReadBinaryOptions read_options(features, options->log_stream, kReadDebugNames, + kStopOnFirstError); switch (options->mode) { case ObjdumpMode::Prepass: { |