Skip to main content

miden_stdlib_sys/intrinsics/
debug.rs

1#[cfg(all(target_family = "wasm", miden))]
2unsafe extern "C" {
3    #[cfg_attr(all(target_family = "wasm", miden), linkage = "extern_weak")]
4    #[link_name = "intrinsics::debug::break"]
5    fn extern_break();
6    #[cfg_attr(all(target_family = "wasm", miden), linkage = "extern_weak")]
7    #[link_name = "intrinsics::debug::println"]
8    fn extern_println(ptr: *const u8, len: usize);
9}
10
11/// Sets a breakpoint in the emitted Miden Assembly at the point this function is called.
12#[inline(always)]
13#[track_caller]
14#[cfg(all(target_family = "wasm", miden))]
15pub fn breakpoint() {
16    unsafe {
17        extern_break();
18    }
19}
20
21/// Sets a breakpoint in the emitted Miden Assembly at the point this function is called.
22#[inline(always)]
23#[track_caller]
24#[cfg(not(all(target_family = "wasm", miden)))]
25pub fn breakpoint() {
26    unimplemented!("debug intrinsics are only available when targeting the Miden VM")
27}
28
29/// Prints the string pointed to by `ptr` in the debug executor.
30#[inline(always)]
31#[cfg(all(target_family = "wasm", miden))]
32pub fn println(ptr: *const u8, len: usize) {
33    unsafe {
34        extern_println(ptr, len);
35    }
36}
37
38/// Prints the string pointed to by `ptr` in the debug executor.
39#[inline(always)]
40#[cfg(not(all(target_family = "wasm", miden)))]
41pub fn println(_ptr: *const u8, _len: usize) {
42    unimplemented!("debug intrinsics are only available when targeting the Miden VM")
43}