07月01, 2019

sol source map for eth

The compiler can also generate a mapping from the bytecode to the range in the source code that generated the instruction. This is again important for static analysis tools that operate on bytecode level and for displaying the current position in the source code inside a debugger or for breakpoint handling.

Both kinds of source mappings use integer identifiers to refer to source files. The identifier of a source file is stored in output['sources'][sourceName]['id'] where output is the output of the standard-json compiler interface parsed as JSON.

the following rules are used:

If a field is empty, the value of the preceding element is used. If a : is missing, all following fields are considered empty.

The source map look like this:

0:63:1:-;;;15:46;32:10;:15;;:26;48:9;32:26;;;;;;;;;;;;;;;;;;;;;;15:46;0:63;;;;;;

there's one ; entry per assembly instruction.

#1. source location start index

#2. source location length

#3. source file index

#4. instruction jump type

What's the difference between srcmap and srcmap-runtime?

They map to the bytecode vs. runtime bytecode. The first one is used to deploy the contract, while the second is the actual contract code after creation.

本文链接:https://harry.ren/post/sol-sou-map.html

-- EOF --

Comments