diff options
author | obscuren <geffobscura@gmail.com> | 2014-07-02 19:08:32 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-07-02 19:08:32 +0800 |
commit | e4d2d00d414704559b38f80a918030613ea1cdf4 (patch) | |
tree | 69ade68c2d768b911dc93a4226ae7ee36d7d2448 /ethchain | |
parent | 315d65280bab295765cdaeb12cfde753c5387ebc (diff) | |
download | dexon-e4d2d00d414704559b38f80a918030613ea1cdf4.tar.gz dexon-e4d2d00d414704559b38f80a918030613ea1cdf4.tar.zst dexon-e4d2d00d414704559b38f80a918030613ea1cdf4.zip |
Added support for breakpoints on specific instructions
Diffstat (limited to 'ethchain')
-rw-r--r-- | ethchain/vm.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/ethchain/vm.go b/ethchain/vm.go index cd7516db7..909b375ae 100644 --- a/ethchain/vm.go +++ b/ethchain/vm.go @@ -53,7 +53,10 @@ type Vm struct { err error - Hook DebugHook + // Debugging + Hook DebugHook + BreakPoints []int64 + Stepping bool } type DebugHook func(step int, op OpCode, mem *Memory, stack *Stack, stateObject *StateObject) bool @@ -742,9 +745,16 @@ func (vm *Vm) RunClosure(closure *Closure) (ret []byte, err error) { vm.Endl() if vm.Hook != nil { - if !vm.Hook(prevStep, op, mem, stack, closure.Object()) { - return nil, nil + for _, instrNo := range vm.BreakPoints { + if pc.Cmp(big.NewInt(instrNo)) == 0 || vm.Stepping { + vm.Stepping = true + + if !vm.Hook(prevStep, op, mem, stack, closure.Object()) { + return nil, nil + } + } } } + } } |