0xmozak / mozak-vm

Mozak RISC-V Virtual Machine
Apache License 2.0
12 stars 8 forks source link

feat: revive trace ecall #1782

Closed codeblooded1729 closed 4 months ago

codeblooded1729 commented 4 months ago

We can now use trace ecalls to debug variables through macro with same name. Check out the new trace example Run with

# inside `trace/mozakvm`
cargo mozakvm-run --features="trace"

Output:

[2024-06-24T07:19:50Z DEBUG mozak_cli::runner] Read 23332 of ELF data.
[2024-06-24T07:19:50Z DEBUG mozak_runner::ecall] VM TRACE LOG: Debugging variables inside mozakvm is simple with trace!
[2024-06-24T07:19:50Z DEBUG mozak_runner::ecall] VM TRACE LOG: Simply write the debug code, and use trace in this scope.
[2024-06-24T07:19:50Z DEBUG mozak_runner::ecall] VM TRACE LOG: The code in this scope will be ignored when trace feature is off.
[2024-06-24T07:19:50Z DEBUG mozak_runner::ecall] VM TRACE LOG: Lets deserialize the bytes
[2024-06-24T07:19:50Z DEBUG mozak_runner::ecall] VM TRACE LOG: Here is the deserialized struct: Account { id: 4660, owner: "Alice", balance: 10000 }

I have also added a macro debug_scope to include the extra code that might be needed for debugging with trace. The code inside this macro would be ignored when the "trace" feature is off.