aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/debugger.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-07-04 19:04:25 +0800
committerobscuren <geffobscura@gmail.com>2014-07-04 19:04:25 +0800
commitca395306e3997c1f2fd2aa2e780518eb2e2f1845 (patch)
tree9f5cfa687c7538e98081d247b8d274dab39333c0 /ethereal/debugger.go
parent24ff81d14ea8f83bf3693474cd30ee048e006abe (diff)
downloadgo-tangerine-ca395306e3997c1f2fd2aa2e780518eb2e2f1845.tar.gz
go-tangerine-ca395306e3997c1f2fd2aa2e780518eb2e2f1845.tar.zst
go-tangerine-ca395306e3997c1f2fd2aa2e780518eb2e2f1845.zip
Updated debugger
* Compile on the go. Continues compilation in order to update the ASM view * Short cuts commands
Diffstat (limited to 'ethereal/debugger.go')
-rw-r--r--ethereal/debugger.go39
1 files changed, 24 insertions, 15 deletions
diff --git a/ethereal/debugger.go b/ethereal/debugger.go
index 8eab04b4d..d1516c5d5 100644
--- a/ethereal/debugger.go
+++ b/ethereal/debugger.go
@@ -52,13 +52,27 @@ func (self *DebuggerWindow) SetCode(code string) {
func (self *DebuggerWindow) SetData(data string) {
self.win.Set("dataText", data)
}
-func (self *DebuggerWindow) SetAsm(data string) {
- dis := ethchain.Disassemble(ethutil.Hex2Bytes(data))
+func (self *DebuggerWindow) SetAsm(data []byte) {
+ self.win.Root().Call("clearAsm")
+
+ dis := ethchain.Disassemble(data)
for _, str := range dis {
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) {
if !self.Db.done {
self.Db.Q <- true
@@ -91,27 +105,21 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
return
}
- dis := ethchain.Disassemble(script)
- self.win.Root().Call("clearAsm")
-
- for _, str := range dis {
- self.win.Root().Call("setAsm", str)
- }
+ self.SetAsm(script)
var (
gas = ethutil.Big(gasStr)
gasPrice = ethutil.Big(gasPriceStr)
value = ethutil.Big(valueStr)
// Contract addr as test address
- keyPair = self.lib.eth.KeyManager().KeyPair()
- callerTx = ethchain.NewContractCreationTx(ethutil.Big(valueStr), gas, gasPrice, script)
+ keyPair = self.lib.eth.KeyManager().KeyPair()
)
- 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())
- contract := ethchain.MakeContract(callerTx, state)
+ contract := ethchain.NewStateObject([]byte{0})
contract.Amount = value
+
callerClosure := ethchain.NewClosure(account, contract, script, state, gas, gasPrice)
block := self.lib.eth.BlockChain().CurrentBlock
@@ -179,8 +187,9 @@ func (self *DebuggerWindow) ExecCommand(command string) {
cmd := strings.Split(command, " ")
switch cmd[0] {
case "help":
- self.Logln("Debgger commands:")
- self.Logln("break, bp Set breakpoint")
+ self.Logln("Debugger commands:")
+ self.Logln("break, bp Set breakpoint on instruction")
+ self.Logln("clear [break, bp] Clears previous set sub-command(s)")
case "break", "bp":
if len(cmd) > 1 {
lineNo, err := strconv.Atoi(cmd[1])