Skip to content

Commit

Permalink
added tracer docs
Browse files Browse the repository at this point in the history
  • Loading branch information
apoorvsadana committed Jun 30, 2023
1 parent 86b2333 commit 1183d74
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
* [Custom Hint Processor](./hint_processor/)
* [How to run a cairo program with custom hints](./hint_processor/builtin_hint_processor)
* [References parsing](./references_parsing/)
* [Tracer](./tracer/)
39 changes: 39 additions & 0 deletions docs/tracer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Cairo Tracer

Cairo-rs offers a tracer which gives you a visualization of how your memory and registers change line after line as the VM executes the code.

## Setting up the tracer

To use the tracer, you need to build your the VM using the `with_tracer` feature flag.

```bash
cargo build --release --features with_tracer
```

## Running the tracer

Once the build in the above step is complete, you can use the `cairo-vm-cli` as you do normally with an additional argument `--tracer true`. This tells the VM to start a server where you can visualize the exection of your cairo program.

```bash
target/release/cairo-vm-cli <path_to_compiled_cairo_json> --layout <layout> --memory_file <path_to_store_memory_binary> --trace_file <path_to_store_tracer_binary> --tracer true
```

### NOTE
> The `--memory_file` and `--trace_file` arguments are compulsary at the moment as the current code relocates the memory and trace only when these arguments are supplied. However, edits can be made in future versions to relocate if only the `--tracer` option is specified.

## Using the tracer

![tracer](tracer.png)

You can go to [http://127.0.0.1:8100/static/index.html](http://127.0.0.1:8100/static/index.html) to see the tracer.

Use the following commands to visualize the code execution

- `s` to go to the next step
- `Shift + s` to go to the previous step
- `n` to step over
- `N` to previous step over
- `o` to step out
- `b` to run until you reach the next breakpoint
- `B` to run until you reach the previous breakpoint
Binary file added docs/tracer/tracer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1183d74

Please sign in to comment.