Skip to content

Commit

Permalink
docs: debugger breakpoints (#884)
Browse files Browse the repository at this point in the history
* documenting breakpoints

* wrong link and add help

* Update src/forge/debugger.md

---------

Co-authored-by: evalir <[email protected]>
  • Loading branch information
iFrostizz and Evalir authored May 9, 2023
1 parent b8f3b3a commit 27e6423
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@
- [`parseBool`](./cheatcodes/parse-bool.md)
- [`rememberKey`](./cheatcodes/remember-key.md)
- [`toString`](./cheatcodes/to-string.md)
- [`breakpoint`](./cheatcodes/breakpoint.md)
- [Snapshots](./cheatcodes/snapshots.md)
- [RPC](./cheatcodes/rpc.md)
- [Files](./cheatcodes/fs.md)
Expand Down
32 changes: 32 additions & 0 deletions src/cheatcodes/breakpoint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## `breakpoint`

### Signature

```solidity
function breakpoint(string) external;
function breakpoint(string, bool) external;
```

### Description

Places a breakpoint to jump to in the debugger view.

Calling `vm.breakpoint('<char>, true)` is equivalent to `vm.breakpoint('<char>)`, but calling `vm.breakpoint('<char, false)` will erase the breakpoint at `'<char`.

If the char is overwritten, only the last one that was visited in the execution steps is considered.

### Examples

```solidity
function testBreakpoint() public {
vm.breakpoint("a");
}
```

Opening up the debugger in a test environment and pressing `'a` will then place the debugger step at the place where the breakpoint cheatcode was called.

![breakpoint a](../images/breakpoint.png)

### SEE ALSO

[debugger](../forge/debugger.md)
1 change: 1 addition & 0 deletions src/cheatcodes/utilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
- [`deriveKey`](./derive-key.md)
- [`rememberKey`](./remember-key.md)
- [`toString`](./to-string.md)
- [`breakpoint`](./breakpoint.md)
3 changes: 3 additions & 0 deletions src/forge/debugger.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ For the stack, **cyan words** are either being read or popped by the current opc
### General

- <kbd>q</kbd>: Quit the debugger
- <kbd>h</kbd>: Show help

### Navigating calls

Expand All @@ -73,6 +74,7 @@ For the stack, **cyan words** are either being read or popped by the current opc
- <kbd>C</kbd>: Move to the next call-type instruction
- <kbd>a</kbd>: Move to the previous [`JUMP`][op-jump] or [`JUMPI`][op-jumpi] instruction
- <kbd>s</kbd>: Move to the next [`JUMPDEST`][op-jumpdest] instruction
- <kbd>'</kbd> + <kbd>a-z</kbd>: Move to `<char>` breakpoint set by a [`vm.breakpoint`][cheat-breakpoint] cheatcode

### Navigating memory

Expand All @@ -93,3 +95,4 @@ For the stack, **cyan words** are either being read or popped by the current opc
[op-jumpdest]: https://www.evm.codes/#5b
[op-jump]: https://www.evm.codes/#f1
[op-jumpi]: https://www.evm.codes/#57
[cheat-breakpoint]: ../cheatcodes/breakpoint.md
Binary file added src/images/breakpoint.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 27e6423

Please sign in to comment.