summaryrefslogtreecommitdiff
path: root/src/binary-reader-objdump.cc
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2017-05-19 10:15:41 -0700
committerGitHub <noreply@github.com>2017-05-19 10:15:41 -0700
commit43afc1b880ba857110b0fdee6d3c82a2d4a13244 (patch)
treed53ab6d34933bfcc128b940b49fddaacbe722e29 /src/binary-reader-objdump.cc
parentc5b833e68b52dfc67b582b6f7fa60b55074d3aa8 (diff)
downloadwabt-43afc1b880ba857110b0fdee6d3c82a2d4a13244.tar.gz
wabt-43afc1b880ba857110b0fdee6d3c82a2d4a13244.tar.bz2
wabt-43afc1b880ba857110b0fdee6d3c82a2d4a13244.zip
[wasmdump] Display function names at call sites in disassembly (#441)
Also print Index types as decimal rather than hex since this seems to be the convention elsewhere.
Diffstat (limited to 'src/binary-reader-objdump.cc')
-rw-r--r--src/binary-reader-objdump.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/binary-reader-objdump.cc b/src/binary-reader-objdump.cc
index a28652dd..8b40c2ad 100644
--- a/src/binary-reader-objdump.cc
+++ b/src/binary-reader-objdump.cc
@@ -169,6 +169,7 @@ class BinaryReaderObjdumpDisassemble : public BinaryReaderObjdumpBase {
virtual Result OnOpcode(Opcode Opcode);
virtual Result OnOpcodeBare();
+ virtual Result OnOpcodeIndex(Index value);
virtual Result OnOpcodeUint32(uint32_t value);
virtual Result OnOpcodeUint32Uint32(uint32_t value, uint32_t value2);
virtual Result OnOpcodeUint64(uint64_t value);
@@ -296,6 +297,16 @@ Result BinaryReaderObjdumpDisassemble::OnOpcodeBare() {
return Result::Ok;
}
+Result BinaryReaderObjdumpDisassemble::OnOpcodeIndex(Index value) {
+ Offset immediate_len = state->offset - current_opcode_offset;
+ const char *name;
+ if (current_opcode == Opcode::Call && (name = GetFunctionName(value)))
+ LogOpcode(data, immediate_len, "%d <%s>", value, name);
+ else
+ LogOpcode(data, immediate_len, "%d", value);
+ return Result::Ok;
+}
+
Result BinaryReaderObjdumpDisassemble::OnOpcodeUint32(uint32_t value) {
Offset immediate_len = state->offset - current_opcode_offset;
LogOpcode(data, immediate_len, "%#x", value);