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 support for GDB JIT debugging #1212

Merged
merged 29 commits into from
Feb 27, 2020
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
800b2a4
Add debug prototype 2 (fork of wasmtime-debug)
Jan 31, 2020
42132c4
Restructure to use external crate, add integration
Feb 4, 2020
0564000
Add wip debugging code
Feb 11, 2020
5e3c5f7
Fix validation issue, cast to the correct type
Feb 12, 2020
e34e0bb
Clean up, everything works
Feb 13, 2020
923e4ac
Add command line flag, make debug crate optional, clean up API
Feb 14, 2020
3653a44
Clean up code, add documentation, implement pieces properly
Feb 19, 2020
1ac59a3
Add various small improvements, update attributions file
Feb 19, 2020
68af917
Update field names in wasm-debug types
Feb 19, 2020
a2e531b
Update to use published wasm-debug; make dep optional in clif-backend
Feb 19, 2020
64cc591
Merge branch 'master' into feature/debug-prototype2
MarkMcCaskey Feb 20, 2020
3bca20d
Add changelog entry, clean up
Feb 20, 2020
65a9e04
Add updates from feedback
Feb 20, 2020
0ec08b5
Add updates from feedback
Feb 20, 2020
7c5f825
Flatten tuple in return type, conditionally remove more jit debug code
Feb 21, 2020
3d6e915
Merge branch 'master' into feature/debug-prototype2
MarkMcCaskey Feb 21, 2020
40e4ddd
Add updates from feedback
Feb 21, 2020
d7fca53
Make JitCodeDebugInfoEntryHandleInner Send and Sync
Feb 21, 2020
6f5ebb5
Allow building clif-backend without wasm-debug
Feb 26, 2020
52d4dac
Rename `feed_event`'s `loc` to `source_loc`
Feb 26, 2020
cb20cd9
Merge branch 'master' into feature/debug-prototype2
Feb 26, 2020
56e47c1
Revert Wasm parsing to improved old style, fixing singlepass
Feb 27, 2020
0c8464e
Update changelog entry for gdb jit PR
Feb 27, 2020
3691c80
Add generate_debug_info field to test
Feb 27, 2020
a089cf5
Link GDB JIT exposed global and fn as "linkonce"
Feb 27, 2020
dbb2ece
Work around unstable linkage attribute
Feb 27, 2020
b5cbb9d
Fix test and build for musl
Feb 27, 2020
0593965
Make gdb jit symbol weak linking default in llvm-backend features
Feb 27, 2020
91808b9
Update test-rest to explicitly test each crate
Feb 27, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions ATTRIBUTIONS.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
# Wasmer Attributions

Wasmer is a community effort.
In order to build the best WebAssembly runtime it's our duty to see how other runtimes are approaching the same space
and get inspired from them on the things that they got right, so Wasmer and its community can benefit from a solid
foundation.
Wasmer is a community effort and makes use of code from various other
projects. Listed below are notable sections of code that are licensed
from other projects and the relevant license of those projects.

These are the different project that we used as inspiration:
These are the projects that were used as inspiration and/or that we are using code from:

- [Nebulet](https://github.com/nebulet/nebulet): as the base for creating a great Rust WebAssembly runtime
- [WAVM](https://github.com/wavm/wavm): for their great integration and testing framework
- [greenwasm](https://github.com/Kimundi/greenwasm): for their [spectests framework](https://github.com/Kimundi/greenwasm/tree/master/greenwasm-spectest)
- [wasmtime](https://github.com/CraneStation/wasmtime): for their [mmap implementation](https://github.com/CraneStation/wasmtime/blob/3f24098edc81cd9bf0f877fb7fba018cad0f039e/lib/runtime/src/mmap.rs)
- [wasmtime](https://github.com/CraneStation/wasmtime):
- For their [mmap implementation](https://github.com/CraneStation/wasmtime/blob/3f24098edc81cd9bf0f877fb7fba018cad0f039e/lib/runtime/src/mmap.rs)
- For the implementation of the `__jit_debug_register_code` function
in Rust, the structure of using Cranelift with the GDB JIT
interface including implementation details regarding the structure
of generating debug information for each function with Cranelift
(for example, the sorting of the extended basic blocks before
processing the instructions), and the API for transforming DWARF
see wasm-debug's attribution file for more information (TODO: link
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we address the TODO before the merge?

and update here).
- [stackoverflow](https://stackoverflow.com/a/45795699/1072990): to create an efficient HashMap with pair keys
- [Emscripten](https://github.com/kripken/emscripten): for emtests test sources to ensure compatibility
- [The WebAssembly spec](https://github.com/WebAssembly/spec/tree/master/test): for implementation details of WebAssembly and spectests

We would love to hear from you if you think we can take inspiration from other projects that we haven't covered here.
😊
Please let us know if you believe there is an error or omission in
this list and we will do our best to correct it.

## Licenses

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- [#1233](https://github.com/wasmerio/wasmer/pull/1233) Improved Wasmer C API release artifacts.
- [#1216](https://github.com/wasmerio/wasmer/pull/1216) `wasmer-interface-types` receives a binary encoder.
- [#1212](https://github.com/wasmerio/wasmer/pull/1212) Add `--generate-debug-info` and `-g` flags to `wasmer run` to generate debug information during compilation that is passed via the GDB JIT interface to a debugger to allow source-level debugging of Wasm files. Currently only available on clif-backend, see PR for more information on its implementation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Two spaces before “Currently”:

Suggested change
- [#1212](https://github.com/wasmerio/wasmer/pull/1212) Add `--generate-debug-info` and `-g` flags to `wasmer run` to generate debug information during compilation that is passed via the GDB JIT interface to a debugger to allow source-level debugging of Wasm files. Currently only available on clif-backend, see PR for more information on its implementation.
- [#1212](https://github.com/wasmerio/wasmer/pull/1212) Add `--generate-debug-info` and `-g` flags to `wasmer run` to generate debug information during compilation that is passed via the GDB JIT interface to a debugger to allow source-level debugging of Wasm files. Currently only available on clif-backend, see PR for more information on its implementation.

Also, should we adopt the classic compiler -O option? -O0, -O1, -O2, -Oz etc.? I'll open a new issue to discuss about that. I'm even thinking about a -C option.

Please read #1237 before merging this PR 🙂.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm a big fan of two spaces after periods. I try to suppress it when writing in a shared space because inconsistent style is worse, but I find it much more readable, it chunks the sentences in my brain better and helps me read more quickly.

From Googling it, using two spaces after a period apparently means I'm over 40 years old and stuck to my ways using the typewriter 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there's quite a few instances of \. in CHANGELOG.md haha, probably all from me

- [#1228](https://github.com/wasmerio/wasmer/pull/1228) Singlepass cleanup: Resolve several FIXMEs and remove protect_unix.
- [#1218](https://github.com/wasmerio/wasmer/pull/1218) Enable Cranelift verifier in debug mode. Fix bug with table indices being the wrong type.
- [#787](https://github.com/wasmerio/wasmer/pull/787) New crate `wasmer-interface-types` to implement WebAssembly Interface Types.
Expand Down
127 changes: 120 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ serde = { version = "1", features = ["derive"] } # used by the plugin example
typetag = "0.1" # used by the plugin example

[features]
default = ["fast-tests", "wasi", "backend-cranelift", "wabt"]
default = ["fast-tests", "wasi", "backend-cranelift", "wabt", "wasmer-runtime-core/generate-debug-information"]
"loader-kernel" = ["wasmer-kernel-loader"]
debug = ["fern", "log/max_level_debug", "log/release_max_level_debug"]
trace = ["fern", "log/max_level_trace", "log/release_max_level_trace"]
Expand All @@ -89,6 +89,7 @@ docs = ["wasmer-runtime/docs"]
fast-tests = []
backend-cranelift = [
"wasmer-clif-backend",
"wasmer-clif-backend/generate-debug-information",
"wasmer-runtime/cranelift",
"wasmer-middleware-common-tests/clif",
]
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ check: check-bench
# builds, test as many combined features as possible with each backend
# as default, and test a minimal set of features with only one backend
# at a time.
cargo check --manifest-path lib/runtime-core/Cargo.toml
cargo check --manifest-path lib/runtime/Cargo.toml
# Check some of the cases where deterministic execution could matter
cargo check --manifest-path lib/runtime/Cargo.toml --features "deterministic-execution"
Expand Down
4 changes: 4 additions & 0 deletions lib/clif-backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ byteorder = "1.3.2"
nix = "0.15.0"
libc = "0.2.60"
rayon = "1.1"
wasm-debug = { optional = true, version = "0.1" }

# Dependencies for caching.
[dependencies.serde]
Expand All @@ -38,3 +39,6 @@ version = "0.0.7"
[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["errhandlingapi", "minwindef", "minwinbase", "winnt"] }
wasmer-win-exception-handler = { path = "../win-exception-handler", version = "0.14.0" }

[features]
generate-debug-information = ["wasm-debug"]
Loading