aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-05-28 19:00:45 +0800
committerobscuren <geffobscura@gmail.com>2014-05-28 19:00:45 +0800
commit09728bf43ce5eaed3060d0ce8aae323055aa6cba (patch)
tree994fb1c96d6c158ab6226ad7625ab314f9397cf2 /ethereal
parent969b4a4a36c2f465de3ab980d13ec513ec6db780 (diff)
downloadgo-tangerine-09728bf43ce5eaed3060d0ce8aae323055aa6cba.tar
go-tangerine-09728bf43ce5eaed3060d0ce8aae323055aa6cba.tar.gz
go-tangerine-09728bf43ce5eaed3060d0ce8aae323055aa6cba.tar.bz2
go-tangerine-09728bf43ce5eaed3060d0ce8aae323055aa6cba.tar.lz
go-tangerine-09728bf43ce5eaed3060d0ce8aae323055aa6cba.tar.xz
go-tangerine-09728bf43ce5eaed3060d0ce8aae323055aa6cba.tar.zst
go-tangerine-09728bf43ce5eaed3060d0ce8aae323055aa6cba.zip
Debugger script&data now accept "0x" values
Diffstat (limited to 'ethereal')
-rw-r--r--ethereal/assets/debugger/debugger.qml6
-rw-r--r--ethereal/ui/debugger.go64
2 files changed, 45 insertions, 25 deletions
diff --git a/ethereal/assets/debugger/debugger.qml b/ethereal/assets/debugger/debugger.qml
index 7c3ffbceb..40b0b68b1 100644
--- a/ethereal/assets/debugger/debugger.qml
+++ b/ethereal/assets/debugger/debugger.qml
@@ -14,6 +14,9 @@ ApplicationWindow {
width: 1290
height: 900
+ property alias codeText: codeEditor.text
+ property alias dataText: rawDataField.text
+
MenuBar {
Menu {
title: "Debugger"
@@ -167,6 +170,7 @@ ApplicationWindow {
}
}
}
+
toolBar: ToolBar {
RowLayout {
spacing: 5
@@ -205,7 +209,7 @@ ApplicationWindow {
function setInstruction(num) {
asmTableView.selection.clear()
- asmTableView.selection.select(num-1)
+ asmTableView.selection.select(num)
}
function setMem(mem) {
diff --git a/ethereal/ui/debugger.go b/ethereal/ui/debugger.go
index 8b27c2fe5..5b1fb50a2 100644
--- a/ethereal/ui/debugger.go
+++ b/ethereal/ui/debugger.go
@@ -9,6 +9,23 @@ import (
"strings"
)
+func formatData(data string) []byte {
+ if len(data) == 0 {
+ return nil
+ }
+ // Simple stupid
+ d := new(big.Int)
+ if data[0:1] == "\"" && data[len(data)-1:] == "\"" {
+ d.SetBytes([]byte(data[1 : len(data)-1]))
+ } else if data[:2] == "0x" {
+ d.SetBytes(ethutil.FromHex(data[2:]))
+ } else {
+ d.SetString(data, 0)
+ }
+
+ return ethutil.BigToBytes(d, 256)
+}
+
type DebuggerWindow struct {
win *qml.Window
engine *qml.Engine
@@ -41,21 +58,12 @@ func (self *DebuggerWindow) Show() {
}()
}
-func formatData(data string) []byte {
- if len(data) == 0 {
- return nil
- }
- // Simple stupid
- d := new(big.Int)
- if data[0:1] == "\"" && data[len(data)-1:] == "\"" {
- d.SetBytes([]byte(data[1 : len(data)-1]))
- } else if data[:2] == "0x" {
- d.SetBytes(ethutil.FromHex(data[2:]))
- } else {
- d.SetString(data, 0)
- }
+func (self *DebuggerWindow) SetCode(code string) {
+ self.win.Set("codeText", code)
+}
- return ethutil.BigToBytes(d, 256)
+func (self *DebuggerWindow) SetData(data string) {
+ self.win.Set("dataText", data)
}
func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, dataStr string) {
@@ -63,22 +71,28 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
self.Db.Q <- true
}
- dataSlice := strings.Split(dataStr, "\n")
- var data []byte
- for _, dataItem := range dataSlice {
- d := formatData(dataItem)
- data = append(data, d...)
- }
-
- state := self.lib.eth.BlockChain().CurrentBlock.State()
-
defer func() {
if r := recover(); r != nil {
fmt.Println(r)
+ self.Db.done = true
}
}()
- script, err := ethutil.Compile(scriptStr)
+ data := ethutil.StringToByteFunc(dataStr, func(s string) (ret []byte) {
+ slice := strings.Split(dataStr, "\n")
+ for _, dataItem := range slice {
+ d := formatData(dataItem)
+ ret = append(ret, d...)
+ }
+ return
+ })
+
+ var err error
+ script := ethutil.StringToByteFunc(scriptStr, func(s string) (ret []byte) {
+ ret, err = ethutil.Compile(s)
+ return
+ })
+
if err != nil {
ethutil.Config.Log.Debugln(err)
@@ -91,11 +105,13 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
for _, str := range dis {
self.win.Root().Call("setAsm", str)
}
+
// Contract addr as test address
keyPair := ethutil.GetKeyRing().Get(0)
callerTx := ethchain.NewContractCreationTx(ethutil.Big(valueStr), ethutil.Big(gasStr), ethutil.Big(gasPriceStr), script)
callerTx.Sign(keyPair.PrivateKey)
+ state := self.lib.eth.BlockChain().CurrentBlock.State()
account := self.lib.eth.StateManager().TransState().GetAccount(keyPair.Address())
contract := ethchain.MakeContract(callerTx, state)
callerClosure := ethchain.NewClosure(account, contract, script, state, ethutil.Big(gasStr), ethutil.Big(gasPriceStr))