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

Coredump: add local/stack value typing #199

Merged
merged 1 commit into from
Feb 16, 2023
Merged
Changes from all commits
Commits
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
28 changes: 21 additions & 7 deletions Coredump.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,29 @@ For each thread a [Custom section], called `corestack`, is used to store the
debugging information.

```
corestack ::= customsec(thread-info vec(frame))
corestack ::= customsec(thread-info vec(frame))
thread-info ::= 0x0 thread-name:name
frame ::= codeoffset:u32
locals:vec(u32)
stack:vec(u32)
locals:vec(value)
stack:vec(value)
reserved:u32
```

The `reserved` byte is decoded as an empty vector and reserved for future use.

Local and stack values are encoded using one byte for the type (similar to
Wasm's [Number Types]) followed by bytes representing the actual value:
```
value ::= 0x01 => ∅
| 0x7F n:i32 => n
| 0x7E n:i64 => n
| 0x7D n:f32 => n
| 0x7C n:f64 => n
```

The special byte `0x01` is used to represent a missing value, usually because it
was optimized out by the WebAssembly engine.

## Memory

The process memory is captured in the [Data Section], either entirely as one
Expand All @@ -131,17 +144,18 @@ tooling: [demo].
[ELF coredump]: https://www.gabriel.urdhr.fr/2015/05/29/core-file/
[Core dump on Wikipedia]: https://en.wikipedia.org/wiki/Core_dump
[gdb]: https://linux.die.net/man/1/gdb
[wasm-edit coredump]: https://github.com/xtuc/wasm-edit/blob/main/src/coredump.rs
[wasm-edit]: https://github.com/xtuc/wasm-edit
[wasmgdb]: https://github.com/xtuc/wasmgdb
[wasm-edit coredump]: https://github.com/xtuc/wasm-coredump/blob/main/bin/rewriter/src/rewriter.rs
[wasm-edit]: https://github.com/xtuc/wasm-coredump/tree/main/bin/rewriter
[wasmgdb]: https://github.com/xtuc/wasm-coredump/tree/main/bin/wasmgdb
[DWARF]: https://yurydelendik.github.io/webassembly-dwarf
[Wasmer FrameInfo]: https://docs.rs/wasmer/latest/wasmer/struct.FrameInfo.html
[Wasm u32]: https://webassembly.github.io/spec/core/binary/values.html#binary-int
[demo]: https://github.com/xtuc/wasmgdb/wiki/Demo
[demo]: https://github.com/xtuc/wasm-coredump/blob/main/bin/wasmgdb/demo.md
[multi-memory]: https://github.com/WebAssembly/multi-memory
[Wasm binary format]: https://webassembly.github.io/spec/core/binary/index.html
[Data Section]: https://webassembly.github.io/spec/core/binary/modules.html#data-section
[Custom section]: https://webassembly.github.io/spec/core/binary/modules.html#binary-customsec
[Memory Section]: https://webassembly.github.io/spec/core/binary/modules.html#binary-memsec
[instantiated]: https://webassembly.github.io/spec/core/exec/modules.html#instantiation
[Global Section]: https://webassembly.github.io/spec/core/binary/modules.html#binary-globalsec
[Number Types]: https://webassembly.github.io/spec/core/binary/types.html#binary-numtype