Skip to content

Commit f94248e

Browse files
authored
Merge pull request #116 from ewasm/debug-namespace
Explain debug mode (and debug namespace) a bit better
2 parents 1f541c2 + 7b42139 commit f94248e

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

contract_interface.md

+15-10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ Every contract must be stored in the [WebAssembly Binary Encoding](https://githu
1010

1111
A contract can only import symbols specified in the [Ethereum Environment Interface](./eth_interface.md).
1212

13+
As mentioned below, there is a `debug` namespace as well, but that is disallowed in production systems.
14+
15+
#### Debug-mode
16+
17+
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
18+
symbols should be rejected.
19+
20+
The imports are available under the `debug` namespace:
21+
- `print32(value: i32)` - print value
22+
- `print64(value: i64)` - print value
23+
- `printMem(offset: i32, len: i32)` - print memory segment as printable characters
24+
- `printMemHex(offset: i32, len: i32)` - print memory segment as hex
25+
- `printStorage(pathOffset: i32)` - print storage value as printable characters
26+
- `printStorageHex(pathOffset: i32)` - print storage value as hex
27+
1328
### Exports
1429

1530
A contract must have exactly two exported symbols:
@@ -23,13 +38,3 @@ The method exported as `main` will be executed by the VM.
2338
On successful execution, the code should return via a normal code path.
2439

2540
If it needs to abort due to a failure, an *unreachable* instruction should be executed.
26-
27-
### Debug-mode
28-
29-
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
30-
symbols should be rejected.
31-
32-
The imports are available under the `debug` namespace:
33-
- `print(i64)`: print a number
34-
- `printMem(i32 offset, i32 length)`: print a string as pointed by `offset`
35-
- `printMemHex(i32 offset, i32 length)`: print a hex representation of the memory pointed to by `offset`

0 commit comments

Comments
 (0)