@@ -61,7 +61,7 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
6161 op OpCode
6262
6363 destinations = analyseJumpDests (closure .Code )
64- mem = & Memory {}
64+ mem = NewMemory ()
6565 stack = NewStack ()
6666 pc = big .NewInt (0 )
6767 step = 0
@@ -169,8 +169,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
169169 gas .Set (GasLog )
170170 addStepGasUsage (new (big.Int ).Mul (big .NewInt (int64 (n )), GasLog ))
171171 addStepGasUsage (new (big.Int ).Add (mSize , mStart ))
172- // BUG in C++
173- //gas.Set(ethutil.Big1)
174172 // Gas only
175173 case STOP :
176174 gas .Set (ethutil .Big0 )
@@ -263,11 +261,14 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
263261 memGasUsage .Div (memGasUsage , u256 (32 ))
264262
265263 addStepGasUsage (memGasUsage )
264+
265+ mem .Resize (newMemSize .Uint64 ())
266266 }
267+
267268 }
268269
269270 self .Printf ("(pc) %-3d -o- %-14s" , pc , op .String ())
270- self .Printf (" (g) %-3v (%v)" , gas , closure .Gas )
271+ self .Printf (" (m) %-4d (s) %-4d ( g) %-3v (%v)" , mem . Len (), stack . Len () , gas , closure .Gas )
271272
272273 if ! closure .UseGas (gas ) {
273274 self .Endl ()
@@ -279,8 +280,6 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
279280 return closure .Return (nil ), OOG (gas , tmp )
280281 }
281282
282- mem .Resize (newMemSize .Uint64 ())
283-
284283 switch op {
285284 // 0x20 range
286285 case ADD :
@@ -622,6 +621,8 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
622621 code := closure .Args [cOff : cOff + l ]
623622
624623 mem .Set (mOff , l , code )
624+
625+ self .Printf (" => [%v, %v, %v] %x" , mOff , cOff , l , code [cOff :cOff + l ])
625626 case CODESIZE , EXTCODESIZE :
626627 var code []byte
627628 if op == EXTCODESIZE {
@@ -663,6 +664,8 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
663664 codeCopy := code [cOff : cOff + l ]
664665
665666 mem .Set (mOff , l , codeCopy )
667+
668+ self .Printf (" => [%v, %v, %v] %x" , mOff , cOff , l , code [cOff :cOff + l ])
666669 case GASPRICE :
667670 stack .Push (closure .Price )
668671
0 commit comments