Skip to content

Commit d1f6d48

Browse files
committed
Stop indexing instructions by their byte offset
1 parent 6f669ea commit d1f6d48

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

schemas/bytecode.schema.yaml

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,12 @@ properties:
1616
$ref: "schema:ethdebug/format/context"
1717

1818
instructions:
19-
type: object
19+
type: array
2020
description: |
21-
A mapping from instruction byte offset to instruction annotation.
22-
23-
For legacy contract bytecode (non-EOF), keys in this mapping are
24-
equivalent to the instruction's program counter. For EOF bytecode, keys
25-
in this mapping are byte offsets relative to _the start of the
26-
container_ (since program counters within EOF are relative to the start of
27-
individual code sections within the container).
28-
29-
Keys in this mapping **must** be specified as `0x`-prefixed hexadecimal
30-
strings. Keys **may** vary in bytes length and avoid left-padding with
31-
zeroes, except that keys **must** represent at least one byte (`0x` is
32-
not allowed).
33-
patternProperties:
34-
"^0x[0-9a-fA-F]{1,}$":
35-
$ref: "schema:ethdebug/format/bytecode/instruction"
36-
additionalProperties: false
21+
The full array of instructions for the bytecode.
22+
items:
23+
$ref: "schema:ethdebug/format/bytecode/instruction"
24+
additionalItems: false
3725

3826
types:
3927
type: object
@@ -52,7 +40,7 @@ examples:
5240
"my-bool":
5341
kind: bool
5442
instructions:
55-
"0x00":
43+
- offset: 0
5644
operation:
5745
mnemonic: PUSH1
5846
arguments: ["0x60"]

schemas/bytecode/instruction.schema.yaml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,27 @@ $id: "schema:ethdebug/format/bytecode/instruction"
33

44
title: ethdebug/format/bytecode/instruction
55
description: |
6-
A schema for representing the information pertaining to a particular instruction
7-
in machine code.
6+
A schema for representing the information pertaining to a particular
7+
instruction in machine code.
88
99
type: object
1010

1111
properties:
12+
offset:
13+
title: Instruction byte offset
14+
description: |
15+
The byte offset where the instruction begins within the bytecode.
16+
17+
For legacy contract bytecode (non-EOF), this value is equivalent to the
18+
instruction's program counter. For EOF bytecode, this value **must** be
19+
the offset from the start of the container, not the start of a particular
20+
code section within that container.
21+
oneOf:
22+
- type: number
23+
minimum: 0
24+
- type: string
25+
pattern: "^0x[0-9a-fA-F]{1,}$"
26+
1227
operation:
1328
title: Machine operation information
1429
type: object
@@ -35,10 +50,15 @@ properties:
3550
$ref: "schema:ethdebug/format/context"
3651

3752
required:
53+
- offset
3854
- context
3955

4056
examples:
41-
- context:
57+
- offset: 0
58+
operation:
59+
mnemonic: "PUSH1"
60+
arguments: ["0x60"]
61+
context:
4262
code:
4363
source:
4464
id: 5

0 commit comments

Comments
 (0)