|
|
@ -52,13 +52,27 @@ func (self *DebuggerWindow) SetCode(code string) { |
|
|
|
func (self *DebuggerWindow) SetData(data string) { |
|
|
|
func (self *DebuggerWindow) SetData(data string) { |
|
|
|
self.win.Set("dataText", data) |
|
|
|
self.win.Set("dataText", data) |
|
|
|
} |
|
|
|
} |
|
|
|
func (self *DebuggerWindow) SetAsm(data string) { |
|
|
|
func (self *DebuggerWindow) SetAsm(data []byte) { |
|
|
|
dis := ethchain.Disassemble(ethutil.Hex2Bytes(data)) |
|
|
|
self.win.Root().Call("clearAsm") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dis := ethchain.Disassemble(data) |
|
|
|
for _, str := range dis { |
|
|
|
for _, str := range dis { |
|
|
|
self.win.Root().Call("setAsm", str) |
|
|
|
self.win.Root().Call("setAsm", str) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (self *DebuggerWindow) Compile(code string) { |
|
|
|
|
|
|
|
var err error |
|
|
|
|
|
|
|
script := ethutil.StringToByteFunc(code, func(s string) (ret []byte) { |
|
|
|
|
|
|
|
ret, err = ethutil.Compile(s) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if err == nil { |
|
|
|
|
|
|
|
self.SetAsm(script) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, dataStr string) { |
|
|
|
func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, dataStr string) { |
|
|
|
if !self.Db.done { |
|
|
|
if !self.Db.done { |
|
|
|
self.Db.Q <- true |
|
|
|
self.Db.Q <- true |
|
|
@ -91,12 +105,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dis := ethchain.Disassemble(script) |
|
|
|
self.SetAsm(script) |
|
|
|
self.win.Root().Call("clearAsm") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, str := range dis { |
|
|
|
|
|
|
|
self.win.Root().Call("setAsm", str) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
var ( |
|
|
|
gas = ethutil.Big(gasStr) |
|
|
|
gas = ethutil.Big(gasStr) |
|
|
@ -104,14 +113,13 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data |
|
|
|
value = ethutil.Big(valueStr) |
|
|
|
value = ethutil.Big(valueStr) |
|
|
|
// Contract addr as test address
|
|
|
|
// Contract addr as test address
|
|
|
|
keyPair = self.lib.eth.KeyManager().KeyPair() |
|
|
|
keyPair = self.lib.eth.KeyManager().KeyPair() |
|
|
|
callerTx = ethchain.NewContractCreationTx(ethutil.Big(valueStr), gas, gasPrice, script) |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
callerTx.Sign(keyPair.PrivateKey) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
state := self.lib.eth.BlockChain().CurrentBlock.State() |
|
|
|
state := self.lib.eth.StateManager().TransState() |
|
|
|
account := self.lib.eth.StateManager().TransState().GetAccount(keyPair.Address()) |
|
|
|
account := self.lib.eth.StateManager().TransState().GetAccount(keyPair.Address()) |
|
|
|
contract := ethchain.MakeContract(callerTx, state) |
|
|
|
contract := ethchain.NewStateObject([]byte{0}) |
|
|
|
contract.Amount = value |
|
|
|
contract.Amount = value |
|
|
|
|
|
|
|
|
|
|
|
callerClosure := ethchain.NewClosure(account, contract, script, state, gas, gasPrice) |
|
|
|
callerClosure := ethchain.NewClosure(account, contract, script, state, gas, gasPrice) |
|
|
|
|
|
|
|
|
|
|
|
block := self.lib.eth.BlockChain().CurrentBlock |
|
|
|
block := self.lib.eth.BlockChain().CurrentBlock |
|
|
@ -179,8 +187,9 @@ func (self *DebuggerWindow) ExecCommand(command string) { |
|
|
|
cmd := strings.Split(command, " ") |
|
|
|
cmd := strings.Split(command, " ") |
|
|
|
switch cmd[0] { |
|
|
|
switch cmd[0] { |
|
|
|
case "help": |
|
|
|
case "help": |
|
|
|
self.Logln("Debgger commands:") |
|
|
|
self.Logln("Debugger commands:") |
|
|
|
self.Logln("break, bp Set breakpoint") |
|
|
|
self.Logln("break, bp Set breakpoint on instruction") |
|
|
|
|
|
|
|
self.Logln("clear [break, bp] Clears previous set sub-command(s)") |
|
|
|
case "break", "bp": |
|
|
|
case "break", "bp": |
|
|
|
if len(cmd) > 1 { |
|
|
|
if len(cmd) > 1 { |
|
|
|
lineNo, err := strconv.Atoi(cmd[1]) |
|
|
|
lineNo, err := strconv.Atoi(cmd[1]) |
|
|
|