diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2021-08-24 15:50:19 +0000 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2021-09-22 15:40:02 +0200 |
| commit | a7ce77be27d8e3728b97122a005bc5b23298cfc3 (patch) | |
| tree | 1f3adbdd7719ec9c6bf7eb4d48f308004410f775 /prog/decodeexec.go | |
| parent | 041a868956e51efc0dace9e3dff874332a8cdccc (diff) | |
all: introduce call properties
Call properties let us specify how each individual call within a program
must be executed. So far the only way to enforce extra rules was to pass
extra program-level properties (e.g. that is how fault injection was done).
However, it entangles the logic and not flexible enough.
Implement an ability to pass properties along with each individual call.
Diffstat (limited to 'prog/decodeexec.go')
| -rw-r--r-- | prog/decodeexec.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/prog/decodeexec.go b/prog/decodeexec.go index e2ef2586c..ff1ab5727 100644 --- a/prog/decodeexec.go +++ b/prog/decodeexec.go @@ -5,6 +5,7 @@ package prog import ( "fmt" + "reflect" ) type ExecProg struct { @@ -14,6 +15,7 @@ type ExecProg struct { type ExecCall struct { Meta *Syscall + Props CallProps Index uint64 Args []ExecArg Copyin []ExecCopyin @@ -119,6 +121,7 @@ func (dec *execDecoder) parse() { dec.setErr(fmt.Errorf("bad syscall %v", instr)) return } + dec.readCallProps(&dec.call.Props) dec.call.Meta = dec.target.Syscalls[instr] dec.call.Index = dec.read() for i := dec.read(); i > 0; i-- { @@ -134,6 +137,18 @@ func (dec *execDecoder) parse() { } } +func (dec *execDecoder) readCallProps(props *CallProps) { + props.ForeachProp(func(_, _ string, value reflect.Value) { + arg := dec.read() + switch kind := value.Kind(); kind { + case reflect.Int: + value.SetInt(int64(arg)) + default: + panic("Unsupported (yet) kind: " + kind.String()) + } + }) +} + func (dec *execDecoder) readArg() ExecArg { switch typ := dec.read(); typ { case execArgConst: |
