From a03c43fc44290df41b1d662219e0d31c5ea8e074 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Thu, 11 Apr 2019 10:46:43 +0200 Subject: [PATCH] Add unsafe debug methods Update debug mod docs Add feature flag for debug api --- Cargo.toml | 1 + src/debug.rs | 10 ++++++++++ src/lib.rs | 3 +++ 3 files changed, 14 insertions(+) create mode 100644 src/debug.rs diff --git a/Cargo.toml b/Cargo.toml index 30bb711..2b39700 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,3 +10,4 @@ edition = "2018" [features] default = [ "std" ] std = [] +debug = [] diff --git a/src/debug.rs b/src/debug.rs new file mode 100644 index 0000000..bb26520 --- /dev/null +++ b/src/debug.rs @@ -0,0 +1,10 @@ +/// The native debug interface exposed to the ewasm contract. These functions are for testing +/// purposes only. On a live VM, any bytecode trying to import these symbols will be rejected. +extern "C" { + pub fn debug_print32(value: u32); + pub fn debug_print64(value: u64); + pub fn debug_printMem(offset: *const u32, len: u32); + pub fn debug_printMemHex(offset: *const u32, len: u32); + pub fn debug_printStorage(pathOffset: *const u32); + pub fn debug_printStorageHex(pathOffset: *const u32); +} diff --git a/src/lib.rs b/src/lib.rs index e74a45b..1dbf645 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,6 +21,9 @@ mod native; pub mod types; +#[cfg(feature = "debug")] +pub mod debug; + #[cfg(not(feature = "std"))] pub mod convert;