From b6c817056a35cab25944a95a3c3c1d11066f2bca Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 30 Jul 2018 18:43:40 +0100 Subject: [PATCH 1/2] Explain debug mode (and debug namespace) a bit better --- contract_interface.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/contract_interface.md b/contract_interface.md index 06e3e672..3b6a04ed 100644 --- a/contract_interface.md +++ b/contract_interface.md @@ -10,6 +10,18 @@ Every contract must be stored in the [WebAssembly Binary Encoding](https://githu A contract can only import symbols specified in the [Ethereum Environment Interface](./eth_interface.md). +As mentioned below, there is a `debug` namespace as well, but that is disallowed in production systems. + +#### Debug-mode + +Debug-mode is a special VM option, where an additional set of debugging interfaces are available to contracts. On a live VM, any bytecode trying to import these +symbols should be rejected. + +The imports are available under the `debug` namespace: +- `print(i64)`: print a number +- `printMem(i32 offset, i32 length)`: print a string as pointed by `offset` +- `printMemHex(i32 offset, i32 length)`: print a hex representation of the memory pointed to by `offset` + ### Exports A contract must have exactly two exported symbols: @@ -23,13 +35,3 @@ The method exported as `main` will be executed by the VM. On successful execution, the code should return via a normal code path. If it needs to abort due to a failure, an *unreachable* instruction should be executed. - -### Debug-mode - -Debug-mode is a special VM option, where an additional set of debugging interfaces are available to contracts. On a live VM, any bytecode trying to import these -symbols should be rejected. - -The imports are available under the `debug` namespace: -- `print(i64)`: print a number -- `printMem(i32 offset, i32 length)`: print a string as pointed by `offset` -- `printMemHex(i32 offset, i32 length)`: print a hex representation of the memory pointed to by `offset` From 7b42139832ac97b155d7be11f6fb4bd9189b7e06 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 30 Jul 2018 18:45:54 +0100 Subject: [PATCH 2/2] Document all method below the debug namespace --- contract_interface.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/contract_interface.md b/contract_interface.md index 3b6a04ed..d1a320a5 100644 --- a/contract_interface.md +++ b/contract_interface.md @@ -18,9 +18,12 @@ Debug-mode is a special VM option, where an additional set of debugging interfac symbols should be rejected. The imports are available under the `debug` namespace: -- `print(i64)`: print a number -- `printMem(i32 offset, i32 length)`: print a string as pointed by `offset` -- `printMemHex(i32 offset, i32 length)`: print a hex representation of the memory pointed to by `offset` +- `print32(value: i32)` - print value +- `print64(value: i64)` - print value +- `printMem(offset: i32, len: i32)` - print memory segment as printable characters +- `printMemHex(offset: i32, len: i32)` - print memory segment as hex +- `printStorage(pathOffset: i32)` - print storage value as printable characters +- `printStorageHex(pathOffset: i32)` - print storage value as hex ### Exports