Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to show operand stack's types in disassembly #1381

Open
fitzgen opened this issue Jan 18, 2024 · 3 comments
Open

Add option to show operand stack's types in disassembly #1381

fitzgen opened this issue Jan 18, 2024 · 3 comments

Comments

@fitzgen
Copy link
Member

fitzgen commented Jan 18, 2024

When debugging some fiddly wasm bits I often annotate the WAT disassembly with the types on the stack in between each instruction:

;; []
i32.const 32
;; [i32]
i32.const 10
;; [i32 i32]
i32.add
;; [i32]

Would be nice if we added a flag to wasm-tools print to do this automatically.

I guess wasmprinter can handle invalid Wasm at the moment, so we would have to maybe make this best effort or require valid input for when this is enabled or something.

@alexcrichton
Copy link
Member

The main tricky part here is that wasmprinter knows nothing of the type signatures of instructions, it "just" prints them and their opcode strings. Adding all the type information would be a pretty big change relative to what's done today

@fitzgen
Copy link
Member Author

fitzgen commented Jan 18, 2024

Oh I was imagining it would have a wasmparser::Validator when this option was enabled.

@alexcrichton
Copy link
Member

Now that's a neat idea yeah! Could even do something like ;; [ ... ERROR ...] on validation failure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants