Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InstrMapping ¶
type InstrMapping struct {
S int32 // start offset in bytes within source (negative when non-existent!)
L int32 // length in bytes within source (negative when non-existent!)
F int32 // file index of source (negative when non-existent!)
J byte // jump type (i=into, o=out, -=regular)
M int32 // modifier depth
}
type SourceID ¶ added in v1.9.1
type SourceID uint64
func (*SourceID) UnmarshalText ¶ added in v1.9.1
type SourceMap ¶
type SourceMap struct {
// per source, source offset -> line/col
// This data is lazy-loaded.
PosData map[SourceID][]LineCol
// per bytecode byte, byte index -> instr
Instr []InstrMapping
// contains filtered or unexported fields
}
SourceMap is a util to map solidity deployed-bytecode positions to source-file, line and column position data. It is best used in combination with foundry.SourceMapFS to load the source-map. The source-map functionality is tested as part of the FS.
func ParseSourceMap ¶
func ParseSourceMap(srcFs fs.FS, srcIDToPath map[SourceID]string, bytecode []byte, sourceMap string) (*SourceMap, error)
ParseSourceMap parses a solidity sourcemap: mapping bytecode indices to source references. See https://docs.soliditylang.org/en/latest/internals/source_mappings.html
The srcIDToPath is the mapping of source files, which will be read from the filesystem to transform token numbers into line/column numbers. Source-files are lazy-loaded when needed.
The source identifier mapping can be loaded through a foundry.SourceMapFS, also including a convenience util to load a source-map from an artifact.
func (*SourceMap) FormattedInfo ¶
FormattedInfo is a convenience method to run Info, and turn it into a formatted string. Any error is turned into a string also, to make this simple to plug into logging.
func (*SourceMap) Info ¶
Info translates a program-counter (execution position in the EVM bytecode) into the source-code location that is being executed. This location is the source file-path, the line number, and column number. This may return an error, as the source-file is lazy-loaded to calculate the position data.
type SourceMapTracer ¶
type SourceMapTracer struct {
// contains filtered or unexported fields
}
func NewSourceMapTracer ¶
func (*SourceMapTracer) Hooks ¶ added in v1.9.1
func (s *SourceMapTracer) Hooks() *tracing.Hooks