Skip to content

Commit

Permalink
Merge pull request #116 from ewasm/debug-namespace
Browse files Browse the repository at this point in the history
 Explain debug mode (and debug namespace) a bit better
  • Loading branch information
axic committed Jul 30, 2018
2 parents 1f541c2 + 7b42139 commit f94248e
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions contract_interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ 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:
- `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

A contract must have exactly two exported symbols:
Expand All @@ -23,13 +38,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`

0 comments on commit f94248e

Please sign in to comment.