From bbd6ec83db018110cf56659b0e7623500e950de6 Mon Sep 17 00:00:00 2001 From: Sven Sauleau Date: Wed, 8 Feb 2023 16:04:26 +0000 Subject: [PATCH] Coredump: add local/stack value typing This change adds typing to local and stack values. Technically the type isn't strictly necessary as DWARF should indicate how to interpret the values. However, using types allows us to represent the lack of value, because it has been optimized out and more complex values like reference types. Closes https://github.com/WebAssembly/tool-conventions/issues/198 --- Coredump.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Coredump.md b/Coredump.md index 62dc9b9..62b171e 100644 --- a/Coredump.md +++ b/Coredump.md @@ -95,16 +95,26 @@ 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 [Value Types] (valtype) followed by bytes +representing the actual value: +``` +value ::= t:valtype x:t => x + | 0x01 => ∅ +``` + +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 @@ -145,3 +155,4 @@ tooling: [demo]. [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 +[Value Types]: https://webassembly.github.io/spec/core/binary/types.html#binary-valtype