Skip to content

How to disassemble aot snapshots #50059

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

Closed
nielsenko opened this issue Sep 27, 2022 · 2 comments
Closed

How to disassemble aot snapshots #50059

nielsenko opened this issue Sep 27, 2022 · 2 comments

Comments

@nielsenko
Copy link

Is it possible to decompile AOT compiled dart code?

I know how to do it for JIT snapshots, with the secret dart --disassemble flag, but I would like to do it for an AOT snapshot as well.

I see some reference to a dart_precompiled_runtime that apparently supports a --disassemble flag (ie. #41705), but this dart_precompiled_runtime is a mystery to me, and perhaps others outside google.

Could you elaborate on how to do this?

@mraleph
Copy link
Member

mraleph commented Sep 27, 2022

There are few options.

If you are fine with using flutter tooling (rather than dart compile exe) you can just use

$ flutter build apk --extra-gen-snapshot-options=--disassemble,--code-comments,--print-flow-graph,--print-flow-graph-filter=xyz

To see code (and IL) for functions containing xyz in their names. This is not that different from JIT.

If you want to use dart compile exe then you could do:

$ dart compile aot-snapshot /tmp/test.dart
$ llvm-objdump --disassemble /tmp/test.aot

You can also use https://godbolt.org/ which has support for Dart.

@mraleph mraleph closed this as completed Sep 27, 2022
copybara-service bot pushed a commit that referenced this issue Sep 28, 2022
Make `dart compile exe -v` forward gen_snapshot output in
verbose mode.

Fix --write_code_comments_as_synthetic_source_to=... flag. There
was a change to Dwarf writer API which broke it.

Motivated by #50059

TEST=manually

Change-Id: I0431925f724a9b24e938bdb9d7ae1019143da83a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261360
Commit-Queue: Slava Egorov <[email protected]>
Reviewed-by: Tess Strickland <[email protected]>
@osa1
Copy link
Member

osa1 commented Sep 29, 2022

With the commit referenced above you can also do

dart compile exe \
    --extra-gen-snapshot-options=--disassemble,--print-flow-graph,--print-flow-graph-filter=<function name> \
    -v <Dart file>

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

3 participants