|
|
@ -94,7 +94,40 @@ type memAddr struct { |
|
|
|
Value string |
|
|
|
Value string |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (ui *UiLib) DebugTx(recipient, valueStr, gasStr, gasPriceStr, data string) (string, error) { |
|
|
|
type Debugger struct { |
|
|
|
|
|
|
|
ui *UiLib |
|
|
|
|
|
|
|
next chan bool |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (d *Debugger) halting(op ethchain.OpCode, mem *ethchain.Memory, stack *ethchain.Stack) { |
|
|
|
|
|
|
|
d.ui.win.Root().Call("clearMem") |
|
|
|
|
|
|
|
d.ui.win.Root().Call("clearStack") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addr := 0 |
|
|
|
|
|
|
|
for i := 0; i+32 <= mem.Len(); i += 32 { |
|
|
|
|
|
|
|
d.ui.win.Root().Call("setMem", memAddr{fmt.Sprintf("%03d", addr), fmt.Sprintf("% x", mem.Data()[i:i+32])}) |
|
|
|
|
|
|
|
addr++ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, val := range stack.Data() { |
|
|
|
|
|
|
|
d.ui.win.Root().Call("setStack", val.String()) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
out: |
|
|
|
|
|
|
|
for { |
|
|
|
|
|
|
|
select { |
|
|
|
|
|
|
|
case <-d.next: |
|
|
|
|
|
|
|
break out |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (d *Debugger) Next() { |
|
|
|
|
|
|
|
d.next <- true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (ui *UiLib) DebugTx(recipient, valueStr, gasStr, gasPriceStr, data string) { |
|
|
|
state := ui.eth.BlockChain().CurrentBlock.State() |
|
|
|
state := ui.eth.BlockChain().CurrentBlock.State() |
|
|
|
|
|
|
|
|
|
|
|
asm, err := mutan.Compile(strings.NewReader(data), false) |
|
|
|
asm, err := mutan.Compile(strings.NewReader(data), false) |
|
|
@ -126,21 +159,12 @@ func (ui *UiLib) DebugTx(recipient, valueStr, gasStr, gasPriceStr, data string) |
|
|
|
Diff: block.Difficulty, |
|
|
|
Diff: block.Difficulty, |
|
|
|
TxData: nil, |
|
|
|
TxData: nil, |
|
|
|
}) |
|
|
|
}) |
|
|
|
callerClosure.Call(vm, nil, func(op ethchain.OpCode, mem *ethchain.Memory, stack *ethchain.Stack) { |
|
|
|
|
|
|
|
ui.win.Root().Call("clearMem") |
|
|
|
|
|
|
|
ui.win.Root().Call("clearStack") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addr := 0 |
|
|
|
|
|
|
|
for i := 0; i+32 <= mem.Len(); i += 32 { |
|
|
|
|
|
|
|
ui.win.Root().Call("setMem", memAddr{fmt.Sprintf("%03d", addr), fmt.Sprintf("% x", mem.Data()[i:i+32])}) |
|
|
|
|
|
|
|
addr++ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, val := range stack.Data() { |
|
|
|
db := &Debugger{ui, make(chan bool)} |
|
|
|
ui.win.Root().Call("setStack", val.String()) |
|
|
|
ui.engine.Context().SetVar("db", db) |
|
|
|
} |
|
|
|
go func() { |
|
|
|
}) |
|
|
|
callerClosure.Call(vm, nil, db.halting) |
|
|
|
state.Reset() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return "", nil |
|
|
|
state.Reset() |
|
|
|
|
|
|
|
}() |
|
|
|
} |
|
|
|
} |
|
|
|