Repository navigation
bugc: describe a storage string's encoding in its pointer - #369
Merged
Merged
Conversation
Contributor
|
gnidan
force-pushed
the
bugc-storage-string-pointer
branch
from
October 7, 2026 03:37
a15c4f3 to
02da97a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since #368, bugc stores a
stringorbytesvalue with Solidity's encoding, but its pointer still named only the slot. A debugger could not read the value from the pointer; it had to know the encoding itself.The pointer now describes the encoding, in the same shape as solc's
t_string_storagepointer template (and the "string storageallocation" example in ethdebug/format/pointer): a one-bytelength-flagregion at the slot's low byte, then aconditionalon(length-flag + 1) % 2. When the flag is even, the data is adataregion in the slot itself,length-flag / 2bytes long. When it is odd, along-lengthregion covers the slot, and the data is a singledataregion fromkeccak256(slot),(long-length - 1) / 2bytes long, across as many slots as it needs. This applies to top-level variables, struct members (with names qualified by the member, such asname-data), and array elements.The new test compiles a program with a top-level
string, a top-levelbytes, a struct withstringandbytesmembers, a fixed-size array of strings, and a mapping to that struct. It runs the program, then reads each pointer with@ethdebug/pointersagainst the resulting storage and checks the exact bytes for lengths 0, 5, 31, 32 and 70 at optimization levels 0 to 3. A mapping's pointer still names only its slot, so the test checks the entryu[7]with the pointer that the struct type gets at the entry's slot.This changes only debug information. The create and runtime bytecode of every example, plus two string-heavy test programs, at levels 0 to 3, are byte-for-byte the same before and after.