From aba3066658a32723543f9e4eda74a14ef140fc0e Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 27 May 2014 13:10:18 +0200 Subject: Changed debug hook and added state iterator --- ethchain/closure.go | 2 +- ethchain/state.go | 5 +++++ ethchain/vm.go | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'ethchain') diff --git a/ethchain/closure.go b/ethchain/closure.go index 59194e4e8..e65cfd252 100644 --- a/ethchain/closure.go +++ b/ethchain/closure.go @@ -72,7 +72,7 @@ func (c *Closure) Address() []byte { return c.object.Address() } -type DebugHook func(step int, op OpCode, mem *Memory, stack *Stack) +type DebugHook func(step int, op OpCode, mem *Memory, stack *Stack, stateObject *StateObject) func (c *Closure) Call(vm *Vm, args []byte, hook DebugHook) ([]byte, error) { c.Args = args diff --git a/ethchain/state.go b/ethchain/state.go index e209e0e2f..5af748e00 100644 --- a/ethchain/state.go +++ b/ethchain/state.go @@ -49,6 +49,11 @@ func (s *State) Purge() int { return s.trie.NewIterator().Purge() } +func (s *State) EachStorage(cb ethutil.EachCallback) { + it := s.trie.NewIterator() + it.Each(cb) +} + func (s *State) GetStateObject(addr []byte) *StateObject { data := s.trie.Get(string(addr)) if data == "" { diff --git a/ethchain/vm.go b/ethchain/vm.go index e025920f3..0d9e8599e 100644 --- a/ethchain/vm.go +++ b/ethchain/vm.go @@ -543,7 +543,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro pc.Add(pc, ethutil.Big1) if hook != nil { - hook(step-1, op, mem, stack) + hook(step-1, op, mem, stack, closure.Object()) } } } -- cgit