Key concepts
A pointer is a region or a collection of other pointers
High-level languages allow programmers to describe and manipulate conceptual ideas as succinct, individual building blocks of machine execution. Nowadays, thanks to decades of compiler research, resulting low-level machine states are often reliably indecipherable, bearing no resemblance at all to even basic data abstractions.
The ethdebug/format/pointer schema provides a tree-based syntax for representing complete (and often minutely detailed) address information for finding a particular high-level data object. (For instance: a compiler may need to inform a debugger about where to find a particular array in memory.) As such, this schema is specified recursively: a pointer is either a single, continuous sequence of bytes addresses (a region), or it aggregates other pointers (a collection).
A region is a single continuous range of byte addresses
For simple allocations (like those that fit into a single word), the ethdebug/format/pointer representation is also quite simple: just a single, optionally named, continuous chunk of bytes in the machine state.
Example: Pointing to the first 32 bytes of memory
{
"name": "memory-start",
"location": "memory",
"offset": "0x0000000000000000000000000000000000000000000000000000000000000000",
"length": 32
}
This schema defines the concept of a region to be the representation
of the addressing details for a particular block of continuous bytes. Different
data locations use different, location-specific schemas for regions
(since, e.g., stack regions are very different than storage regions). The
ethdebug/format/pointer/region schema aggregates these using the
"location" field as a polymorphic discriminator.
A collection aggregates other pointers
Other allocations are not so cleanly represented by a single continuous block of bytes anywhere. In these situations, the ethdebug/format/pointer representation can describe the aggregation of other composed pointers.
Example: Solidity struct in memory
struct in memoryConsider the struct definition:
struct Record {
uint256 x;
uint256 y;
}
A minimal way to represent one possible memory allocation for this type is
to "group" together two single-region pointers for each of the two struct
members.
{
"group": [
{
"location": "memory",
"offset": "0x40",
"length": 32
},
{
"location": "memory",
"offset": "0x60",
"length": 32
}
]
}
This kind of pointer is defined to be a collection of other pointers. This schema includes several sub-schemas for different kinds of collections (e.g., since the allocation of struct types are very different from the allocation of array types, etc.). The ethdebug/format/pointer/collection schema aggregates these.