Solidity – Using Foundry Forge Debugger to Inspect Contents of Variables

contract-debuggingdebuggingforgefoundrysolidity

Is there a convenient way to view the contents of a variable while debugging? Similar to other tooling, like the python debugger in pycharm, or the lldb debugger in Xcode.

The forge debugger has a section for EVM memory, but it's represented as bytes.
enter image description here

The testing framework has verbose options that allow function results to be shown, but only at the level they are called in the test method. For instance, in this basic example the result of calledFromTest is viewable, but not _calledInternally. How would I know the contents of value if the right side of the expression was more complex?

enter image description here

// Example.sol
contract Example {
    function calledFromTest() public view returns (uint256) {
        return _calledInternally() + 10;
    }

    function _calledInternally() internal view returns (uint256) {
        uint256 value = 12;
        return value;
    }
}

// Example.t.sol
contract ExampleTest is Test {
    Example internal example;

    function setUp() public {
        example = new Example();
    }

    function testExample() public {
        example.calledFromTest();
    }
}

Best Answer

Currently it seems the forge debugger doesn't support this. However, there is other tooling that does! Remix has additional windows for this. As local and storage variables.

enter image description here

Related Topic