-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add a wasmtime objdump subcommand #10336
Description
We talked about this in today's Cranelift meeting but I wanted to write down an issue for this idea. The basic idea is that we have *.cwasm files which have binary tables/metadata in various sections, and we only have objdump -S today to look at the .text section. Otherwise most of our other sections are not easily debuggable. Most sections, however, have something to do with the .text section, so it'd be great to be able to debug all these at the same time.
The general idea is to do something roughly along these lines:
- Add a new subcommand,
wasmtime objdump, that takes a*.cwasmfile as input. - This primarily either use Capstone to disassemble the
.textsection or invokesllvm-objdumporobjdumpor similar. My preference would be to use Capstone to have deterministic output regardless of what's installed on the system. - Disasembly would then be printed in a manner similar to
objdump -S, one line per instructions. The main difference is that we would weave debug views of other tables at the same time. - For example
.wasmtime.trapswould be interleaved as;; trap = CODEafter each instruction - Another example is
.wasmtime.addrmapwould ineterleave;; @0x0FF537to show where the instruction maps back to the original binary location. - The reach goal would be to integrate both stack maps and exception tables from the exception-handling proposal into this view as well. That'd ideally make it much easier to view and debug issues with stack maps and exception tables.
Ideally this view would then be used for all disas tests instead of today's "just use capstone". We could then add various --flags to this subcommand to customize exactly what's disassembled (everything? just stack maps? nothing?) along with other options like "print the instruction bytes" etc