summaryrefslogtreecommitdiff
path: root/src/binary-reader-objdump.cc
diff options
context:
space:
mode:
authorBen Smith <binjimin@gmail.com>2018-05-08 16:17:16 -0700
committerGitHub <noreply@github.com>2018-05-08 16:17:16 -0700
commit9a31b42affa93298c66374ff2540d8c5e217a15d (patch)
tree6b045864cb1c365ef732b34571e326cc73d6599b /src/binary-reader-objdump.cc
parent9890d45ff4e04a89ba53137d5f569c5038df8d27 (diff)
downloadwabt-9a31b42affa93298c66374ff2540d8c5e217a15d.tar.gz
wabt-9a31b42affa93298c66374ff2540d8c5e217a15d.tar.bz2
wabt-9a31b42affa93298c66374ff2540d8c5e217a15d.zip
Display module name in wasm-objdump (#834)
Also Put `<>` around other names (functions, locals).
Diffstat (limited to 'src/binary-reader-objdump.cc')
-rw-r--r--src/binary-reader-objdump.cc22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc
index 083ee29d..ac814b40 100644
--- a/src/binary-reader-objdump.cc
+++ b/src/binary-reader-objdump.cc
@@ -64,6 +64,7 @@ class BinaryReaderObjdumpBase : public BinaryReaderNop {
// Map of section index to section type
std::vector<BinarySection> section_types_;
bool section_found_ = false;
+ std::string module_name_;
};
BinaryReaderObjdumpBase::BinaryReaderObjdumpBase(const uint8_t* data,
@@ -250,6 +251,14 @@ class BinaryReaderObjdumpPrepass : public BinaryReaderObjdumpBase {
Index index,
uint32_t addend) override;
+ Result OnModuleName(string_view name) override {
+ if (options_->mode == ObjdumpMode::Prepass) {
+ printf("module name: <" PRIstringview ">\n",
+ WABT_PRINTF_STRING_VIEW_ARG(name));
+ }
+ return Result::Ok;
+ }
+
protected:
void SetFunctionName(Index index, string_view name);
void SetGlobalName(Index index, string_view name);
@@ -664,6 +673,7 @@ class BinaryReaderObjdump : public BinaryReaderObjdumpBase {
const void* data,
Address size) override;
+ Result OnModuleName(string_view name) override;
Result OnFunctionName(Index function_index,
string_view function_name) override;
Result OnLocalName(Index function_index,
@@ -1164,8 +1174,14 @@ Result BinaryReaderObjdump::OnInitExprI64ConstExpr(Index index,
return Result::Ok;
}
+Result BinaryReaderObjdump::OnModuleName(string_view name) {
+ PrintDetails(" - module <" PRIstringview ">\n",
+ WABT_PRINTF_STRING_VIEW_ARG(name));
+ return Result::Ok;
+}
+
Result BinaryReaderObjdump::OnFunctionName(Index index, string_view name) {
- PrintDetails(" - func[%" PRIindex "] " PRIstringview "\n", index,
+ PrintDetails(" - func[%" PRIindex "] <" PRIstringview ">\n", index,
WABT_PRINTF_STRING_VIEW_ARG(name));
return Result::Ok;
}
@@ -1174,8 +1190,8 @@ Result BinaryReaderObjdump::OnLocalName(Index func_index,
Index local_index,
string_view name) {
if (!name.empty()) {
- PrintDetails(" - func[%" PRIindex "] local[%" PRIindex "] " PRIstringview
- "\n",
+ PrintDetails(" - func[%" PRIindex "] local[%" PRIindex "] <" PRIstringview
+ ">\n",
func_index, local_index, WABT_PRINTF_STRING_VIEW_ARG(name));
}
return Result::Ok;