diff options
Diffstat (limited to 'vm/vm_debug.go')
-rw-r--r-- | vm/vm_debug.go | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/vm/vm_debug.go b/vm/vm_debug.go index 2d34758f5..ae5a20175 100644 --- a/vm/vm_debug.go +++ b/vm/vm_debug.go @@ -47,6 +47,8 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { if r := recover(); r != nil { self.Endl() + closure.UseGas(closure.Gas) + ret = closure.Return(nil) err = fmt.Errorf("%v", r) @@ -59,7 +61,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { op OpCode destinations = analyseJumpDests(closure.Code) - mem = &Memory{} + mem = NewMemory() stack = NewStack() pc = big.NewInt(0) step = 0 @@ -259,11 +261,14 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { memGasUsage.Div(memGasUsage, u256(32)) addStepGasUsage(memGasUsage) + + mem.Resize(newMemSize.Uint64()) } + } self.Printf("(pc) %-3d -o- %-14s", pc, op.String()) - self.Printf(" (g) %-3v (%v)", gas, closure.Gas) + self.Printf(" (m) %-4d (s) %-4d (g) %-3v (%v)", mem.Len(), stack.Len(), gas, closure.Gas) if !closure.UseGas(gas) { self.Endl() @@ -275,8 +280,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { return closure.Return(nil), OOG(gas, tmp) } - mem.Resize(newMemSize.Uint64()) - switch op { // 0x20 range case ADD: @@ -618,6 +621,8 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { code := closure.Args[cOff : cOff+l] mem.Set(mOff, l, code) + + self.Printf(" => [%v, %v, %v] %x", mOff, cOff, l, code[cOff:cOff+l]) case CODESIZE, EXTCODESIZE: var code []byte if op == EXTCODESIZE { @@ -659,6 +664,8 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { codeCopy := code[cOff : cOff+l] mem.Set(mOff, l, codeCopy) + + self.Printf(" => [%v, %v, %v] %x", mOff, cOff, l, code[cOff:cOff+l]) case GASPRICE: stack.Push(closure.Price) @@ -730,12 +737,16 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) { case LOG0, LOG1, LOG2, LOG3, LOG4: n := int(op - LOG0) topics := make([][]byte, n) - mSize, mStart := stack.Pop().Int64(), stack.Pop().Int64() + mStart, mSize := stack.Pop().Int64(), stack.Pop().Int64() data := mem.Geti(mStart, mSize) for i := 0; i < n; i++ { topics[i] = stack.Pop().Bytes() } - self.env.AddLog(state.Log{closure.Address(), topics, data}) + + log := &state.Log{closure.Address(), topics, data} + self.env.AddLog(log) + + self.Printf(" => %v", log) case MLOAD: offset := stack.Pop() val := ethutil.BigD(mem.Get(offset.Int64(), 32)) |