Skip to content

Add a wasmtime objdump subcommand #10405

Merged
alexcrichton merged 1 commit intobytecodealliance:mainfrom
alexcrichton:objdump
Mar 20, 2025
Merged

Add a wasmtime objdump subcommand #10405
alexcrichton merged 1 commit intobytecodealliance:mainfrom
alexcrichton:objdump

Conversation

@alexcrichton
Copy link
Member

This commit adds an objdump subcommand to the wasmtime CLI. Like all
other subcommands this can be disabled for a more minimal build of the
CLI as well. The purpose of this subcommand is to provide a
Wasmtime-specific spin on the venerable native objdump itself. Notably
this brings Wasmtime-specific knowledge for filtering functions, showing
Wasmtime metadata, etc.

This command is intended to look like objdump roughly but also has
configurable output with various flags and things that can be printed.
For now the main Wasmtime additions are showing the address map
section, stack map section, and trap section of a *.cwasm file.

This new subcommand replaces the infrastructure of the disas test
suite, and now that test suite uses wasmtime objdump to generate test
expectations. Additionally the subcommand replaces the Pulley objdump
example as a more full-featured objdump that also works natively with
Pulley.

The hope is that if we add more binary metadata in the future (such as
unwinding tables) that can be relatively easily added here for
exploration as well. Otherwise this is mostly just a developer
convenience for Wasmtime developers as well and hopefully doesn't cost
too much in maintenance burden.

Closes #10336

@alexcrichton alexcrichton requested review from a team as code owners March 15, 2025 17:30
@alexcrichton alexcrichton requested review from fitzgen and removed request for a team March 15, 2025 17:30
@alexcrichton
Copy link
Member Author

I'll note that this is built on #10404 currently and an example output looks like this:

Screenshot 2025-03-15 at 12 31 14 PM

@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator pulley Issues related to the Pulley interpreter wasmtime:api Related to the API of the `wasmtime` crate itself wasmtime:docs Issues related to Wasmtime's documentation winch Winch issues or pull requests labels Mar 15, 2025
@github-actions
Copy link

Subscribe to Label Action

cc @fitzgen, @saulecabrera

Details This issue or pull request has been labeled: "cranelift", "pulley", "wasmtime:api", "wasmtime:docs", "winch"

Thus the following users have been cc'd because of the following labels:

  • fitzgen: pulley
  • saulecabrera: winch

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fantastic! (modulo my comments on the stack-maps-in-an-elf-section bits in the other PR)

Thanks for putting this together, it is going to be super helpful going forward

Comment on lines +54 to +64
/// Whether or not to interleave instructions with address maps.
#[arg(long)]
addrmap: bool,

/// Whether or not to interleave instructions with stack maps.
#[arg(long)]
stack_maps: bool,

/// Column width of how large an address is rendered as.
#[arg(long, default_value = "10")]
address_width: usize,

/// Whether or not to show information about what instructions can trap.
#[arg(long)]
traps: bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These seem like they should all be on by default?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I found the address map pretty noisy so I'm not sure we'd want to have that on-by-default. For the others I figured it wasn't too too hard to enable but it means we'd need flags to disable them. Flags-to-disable I find a bit cumbersome with with clap so I left it as off-by-default.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that makes sense 👍

@alexcrichton
Copy link
Member Author

It'll take me some time to work through the stack map bits, so I'm splitting that out of this PR

@alexcrichton
Copy link
Member Author

I'm going to go ahead and merge this but @fitzgen I'm happy to continue to iterate on the CLI and defaults if you'd like

@alexcrichton alexcrichton added this pull request to the merge queue Mar 19, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 19, 2025
@alexcrichton alexcrichton enabled auto-merge March 19, 2025 16:57
@alexcrichton alexcrichton added this pull request to the merge queue Mar 19, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 19, 2025
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Mar 19, 2025
This commit consolidates all of the existing crates we have for testing
into a smaller set of crates. Specifically:

* `crates/misc/component-fuzz-util` => `wasmtime-test-util` + `component-fuzz`
  feature
* `crates/misc/component-test-util` => `wasmtime-test-util` + `component`
  feature
* `crates/wast-util` => `wasmtime-test-util` + `wast` feature
* `crates/misc/component-macro-test` => `wasmtime-test-macros`

The goal is to have one location we put various test helpers/macros
rather than our current organically-grown many locations. This is
inspired by the test failure on bytecodealliance#10405 where I'd like to refactor more
infrastructure to a "test util" location but it wasn't clear where to
put it so I wanted to do this refactoring first.
@alexcrichton alexcrichton requested a review from a team as a code owner March 19, 2025 19:15
@alexcrichton
Copy link
Member Author

This PR now depends on #10423 and is temporarily rebased on it

@github-actions github-actions bot added the fuzzing Issues related to our fuzzing infrastructure label Mar 19, 2025
@github-actions
Copy link

Subscribe to Label Action

cc @fitzgen

Details This issue or pull request has been labeled: "fuzzing"

Thus the following users have been cc'd because of the following labels:

  • fitzgen: fuzzing

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

github-merge-queue bot pushed a commit that referenced this pull request Mar 20, 2025
* Consolidate "util" crates for testing

This commit consolidates all of the existing crates we have for testing
into a smaller set of crates. Specifically:

* `crates/misc/component-fuzz-util` => `wasmtime-test-util` + `component-fuzz`
  feature
* `crates/misc/component-test-util` => `wasmtime-test-util` + `component`
  feature
* `crates/wast-util` => `wasmtime-test-util` + `wast` feature
* `crates/misc/component-macro-test` => `wasmtime-test-macros`

The goal is to have one location we put various test helpers/macros
rather than our current organically-grown many locations. This is
inspired by the test failure on #10405 where I'd like to refactor more
infrastructure to a "test util" location but it wasn't clear where to
put it so I wanted to do this refactoring first.

* Remove unused file
This commit adds an `objdump` subcommand to the `wasmtime` CLI. Like all
other subcommands this can be disabled for a more minimal build of the
CLI as well. The purpose of this subcommand is to provide a
Wasmtime-specific spin on the venerable native `objdump` itself. Notably
this brings Wasmtime-specific knowledge for filtering functions, showing
Wasmtime metadata, etc.

This command is intended to look like `objdump` roughly but also has
configurable output with various flags and things that can be printed.
For now the main Wasmtime additions are showing the address map
section, stack map section, and trap section of a `*.cwasm` file.

This new subcommand replaces the infrastructure of the `disas` test
suite, and now that test suite uses `wasmtime objdump` to generate test
expectations. Additionally the subcommand replaces the Pulley `objdump`
example as a more full-featured objdump that also works natively with
Pulley.

The hope is that if we add more binary metadata in the future (such as
unwinding tables) that can be relatively easily added here for
exploration as well. Otherwise this is mostly just a developer
convenience for Wasmtime developers as well and hopefully doesn't cost
too much in maintenance burden.

Closes bytecodealliance#10336
@alexcrichton alexcrichton enabled auto-merge March 20, 2025 19:09
@alexcrichton alexcrichton added this pull request to the merge queue Mar 20, 2025
@github-actions github-actions bot added the wasi Issues pertaining to WASI label Mar 20, 2025
Merged via the queue into bytecodealliance:main with commit 3e406d2 Mar 20, 2025
40 checks passed
@alexcrichton alexcrichton deleted the objdump branch March 20, 2025 19:45
alexcrichton added a commit to alexcrichton/wasmtime that referenced this pull request Mar 20, 2025
github-merge-queue bot pushed a commit that referenced this pull request Mar 20, 2025
* Add `--stack-maps` to `wasmtime objdump`

Follow-up to #10404 and #10405

* Enable traps/stack maps by default in objdump
tanishiking added a commit to tanishiking/runwasi that referenced this pull request Jun 8, 2025
`IOView` is split off of `WasiView`.
bytecodealliance/wasmtime#10016

`static_memory_maximum_size` is now `memory_reservation`.
bytecodealliance/wasmtime#9545

`detect_precompiled` is now associated function.
bytecodealliance/wasmtime#10405
tanishiking added a commit to tanishiking/runwasi that referenced this pull request Jun 8, 2025
`IOView` is split off of `WasiView`.
bytecodealliance/wasmtime#10016

`static_memory_maximum_size` is now `memory_reservation`.
bytecodealliance/wasmtime#9545

`detect_precompiled` is now associated function.
bytecodealliance/wasmtime#10405

Moved WASIp2 related things to `wasmtime_wasi::p2` module.
bytecodealliance/wasmtime#10073
tanishiking added a commit to tanishiking/runwasi that referenced this pull request Jun 8, 2025
`IOView` is split off of `WasiView`.
bytecodealliance/wasmtime#10016

`static_memory_maximum_size` is now `memory_reservation`.
bytecodealliance/wasmtime#9545

`detect_precompiled` is now associated function.
bytecodealliance/wasmtime#10405

Moved WASIp2 related things to `wasmtime_wasi::p2` module.
bytecodealliance/wasmtime#10073
jprendes pushed a commit to containerd/runwasi that referenced this pull request Jun 8, 2025
`IOView` is split off of `WasiView`.
bytecodealliance/wasmtime#10016

`static_memory_maximum_size` is now `memory_reservation`.
bytecodealliance/wasmtime#9545

`detect_precompiled` is now associated function.
bytecodealliance/wasmtime#10405

Moved WASIp2 related things to `wasmtime_wasi::p2` module.
bytecodealliance/wasmtime#10073
LindaSharp06 pushed a commit to LindaSharp06/Runwasi that referenced this pull request Feb 23, 2026
`IOView` is split off of `WasiView`.
bytecodealliance/wasmtime#10016

`static_memory_maximum_size` is now `memory_reservation`.
bytecodealliance/wasmtime#9545

`detect_precompiled` is now associated function.
bytecodealliance/wasmtime#10405

Moved WASIp2 related things to `wasmtime_wasi::p2` module.
bytecodealliance/wasmtime#10073
LindaSharp06 pushed a commit to LindaSharp06/Runwasi that referenced this pull request Feb 23, 2026
`IOView` is split off of `WasiView`.
bytecodealliance/wasmtime#10016

`static_memory_maximum_size` is now `memory_reservation`.
bytecodealliance/wasmtime#9545

`detect_precompiled` is now associated function.
bytecodealliance/wasmtime#10405

Moved WASIp2 related things to `wasmtime_wasi::p2` module.
bytecodealliance/wasmtime#10073
LindaSharp06 added a commit to LindaSharp06/Runwasi that referenced this pull request Feb 23, 2026
`IOView` is split off of `WasiView`.
bytecodealliance/wasmtime#10016

`static_memory_maximum_size` is now `memory_reservation`.
bytecodealliance/wasmtime#9545

`detect_precompiled` is now associated function.
bytecodealliance/wasmtime#10405

Moved WASIp2 related things to `wasmtime_wasi::p2` module.
bytecodealliance/wasmtime#10073
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift Issues related to the Cranelift code generator fuzzing Issues related to our fuzzing infrastructure pulley Issues related to the Pulley interpreter wasi Issues pertaining to WASI wasmtime:api Related to the API of the `wasmtime` crate itself wasmtime:docs Issues related to Wasmtime's documentation winch Winch issues or pull requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a wasmtime objdump subcommand

2 participants