diff --git a/src/libraries/consoleext.sol b/src/libraries/consoleext.sol index 16907d7..4ed14dd 100644 --- a/src/libraries/consoleext.sol +++ b/src/libraries/consoleext.sol @@ -2,13 +2,14 @@ pragma solidity ^0.8.0; import {console} from "forge-std/console.sol"; +import {safeconsole} from "forge-std/safeconsole.sol"; import {LibString} from "solady/src/utils/LibString.sol"; /// @author philogy library consoleext { using LibString for uint256; - function logWords(bytes memory data) public pure { + function logInWords(bytes memory data) public pure { for (uint256 i = 0; i < data.length; i += 32) { uint256 word; assembly ("memory-safe") { @@ -19,4 +20,12 @@ library consoleext { console.log("%s", word.toHexString(len)); } } + + function logMemWords(uint256 startOffset, uint256 endOffset) public pure { + for (uint256 offset = startOffset; offset < endOffset; offset += 32) { + uint256 wordEnd = offset + 32; + if (wordEnd > endOffset) wordEnd = endOffset; + safeconsole.logMemory(offset, wordEnd - offset); + } + } }