aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-05-27 19:28:11 +0800
committerobscuren <geffobscura@gmail.com>2014-05-27 19:28:11 +0800
commit47417506c377dd0848739473fa14a51708b6a034 (patch)
tree13b37fd06822bc53924bd7e61c7784ca57ee0e19
parentd0b31e203053f3f176e61719d877dcaa04169bb3 (diff)
downloadgo-tangerine-47417506c377dd0848739473fa14a51708b6a034.tar.gz
go-tangerine-47417506c377dd0848739473fa14a51708b6a034.tar.zst
go-tangerine-47417506c377dd0848739473fa14a51708b6a034.zip
New debugger implemented
-rw-r--r--ethereal/assets/debugger/debugger.qml9
-rw-r--r--ethereal/assets/qml/wallet.qml8
-rw-r--r--ethereal/ui/debugger.go24
-rw-r--r--ethereal/ui/gui.go2
4 files changed, 25 insertions, 18 deletions
diff --git a/ethereal/assets/debugger/debugger.qml b/ethereal/assets/debugger/debugger.qml
index 07a78411b..bf69b4254 100644
--- a/ethereal/assets/debugger/debugger.qml
+++ b/ethereal/assets/debugger/debugger.qml
@@ -175,19 +175,18 @@ ApplicationWindow {
}
function setAsm(asm) {
- console.log("set asm", asm)
asmModel.append({asm: asm})
}
+ function clearAsm() {
+ asmModel.clear()
+ }
+
function setInstruction(num) {
asmTableView.selection.clear()
asmTableView.selection.select(num-1)
}
- function clearAsm() {
- asmModel.clear()
- }
-
function setMem(mem) {
memModel.append({num: mem.num, value: mem.value})
}
diff --git a/ethereal/assets/qml/wallet.qml b/ethereal/assets/qml/wallet.qml
index 40de8624e..4aa22dddc 100644
--- a/ethereal/assets/qml/wallet.qml
+++ b/ethereal/assets/qml/wallet.qml
@@ -306,14 +306,6 @@ ApplicationWindow {
text: "Connect"
}
*/
- Button {
- property var enabled: true
- id: debuggerWindow
- onClicked: {
- ui.startDebugger()
- }
- text: "Debugger"
- }
Button {
id: importAppButton
diff --git a/ethereal/ui/debugger.go b/ethereal/ui/debugger.go
index ce2d73b9a..817c0b08f 100644
--- a/ethereal/ui/debugger.go
+++ b/ethereal/ui/debugger.go
@@ -24,7 +24,7 @@ func NewDebuggerWindow(lib *UiLib) *DebuggerWindow {
}
win := component.CreateWindow(nil)
- db := &Debugger{win, make(chan bool), true}
+ db := &Debugger{win, make(chan bool), make(chan bool), true}
return &DebuggerWindow{engine: engine, win: win, lib: lib, Db: db}
}
@@ -40,8 +40,18 @@ func (self *DebuggerWindow) Show() {
}
func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, data string) {
+ if !self.Db.done {
+ self.Db.Q <- true
+ }
+
state := self.lib.eth.BlockChain().CurrentBlock.State()
+ defer func() {
+ if r := recover(); r != nil {
+ fmt.Println(r)
+ }
+ }()
+
script, err := ethutil.Compile(data)
if err != nil {
ethutil.Config.Log.Debugln(err)
@@ -50,7 +60,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, data string) {
}
dis := ethchain.Disassemble(script)
- self.lib.win.Root().Call("clearAsm")
+ self.win.Root().Call("clearAsm")
for _, str := range dis {
self.win.Root().Call("setAsm", str)
@@ -91,6 +101,7 @@ func (self *DebuggerWindow) Next() {
type Debugger struct {
win *qml.Window
N chan bool
+ Q chan bool
done bool
}
@@ -98,7 +109,7 @@ type storeVal struct {
Key, Value string
}
-func (d *Debugger) halting(pc int, op ethchain.OpCode, mem *ethchain.Memory, stack *ethchain.Stack, stateObject *ethchain.StateObject) {
+func (d *Debugger) halting(pc int, op ethchain.OpCode, mem *ethchain.Memory, stack *ethchain.Stack, stateObject *ethchain.StateObject) bool {
d.win.Root().Call("setInstruction", pc)
d.win.Root().Call("clearMem")
d.win.Root().Call("clearStack")
@@ -123,9 +134,14 @@ out:
select {
case <-d.N:
break out
- default:
+ case <-d.Q:
+ d.done = true
+
+ return false
}
}
+
+ return true
}
func (d *Debugger) Next() {
diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go
index 1018d77ac..ca6da5c49 100644
--- a/ethereal/ui/gui.go
+++ b/ethereal/ui/gui.go
@@ -130,7 +130,7 @@ func (gui *Gui) createWindow(comp qml.Object) *qml.Window {
gui.win = win
gui.uiLib.win = win
- db := &Debugger{gui.win, make(chan bool), true}
+ db := &Debugger{gui.win, make(chan bool), make(chan bool), true}
gui.lib.Db = db
gui.uiLib.Db = db