Skip to content

Latest commit

 

History

History
48 lines (35 loc) · 2.03 KB

debugger.md

File metadata and controls

48 lines (35 loc) · 2.03 KB

Debugger

Forge ships with an interactive debugger.

Currently, the debugger is only accessible on forge run. To run the debugger, run:

$ forge run --debug $FILE --sig $FUNC

Where $FILE is the path to the contract you want to debug, and $FUNC is the signature of the function you want to debug. For example:

$ forge run --debug src/MyContract.sol --sig "someFunction()"

If your source file contains more than one contract, specify the contract you want to debug using the --target-contract flag.

Debugger layout

An image of the debugger UI

When the debugger is run, you are presented with a terminal divided into four quadrants:

  • Quadrant 1: The opcodes in the debugging session, with the current opcode highlighted. Additionally, the address of the current account, the program counter and the accumulated gas usage is also displayed
  • Quadrant 2: The current stack, as well as the size of the stack
  • Quadrant 3: The source view
  • Quadrant 4: The current memory of the EVM

Navigating

  • q: Quit the debugger
  • n + k: Step n times backwards (alternatively scroll up with your mouse)
  • n + j: Step n times forwards (alternatively scroll down with your mouse)
  • g: Move to the beginning of the transaction
  • G: Move to the end of the transaction
  • c: Move to the previous call-type instruction (i.e. CALL, STATICCALL, DELEGATECALL, and CALLCODE).
  • C: Move to the next call-type instruction
  • a: Move to the previous JUMP or JUMPI instruction
  • s: Move to the next JUMPDEST instruction