diff options
author | obscuren <geffobscura@gmail.com> | 2014-07-08 04:15:35 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-07-08 04:15:35 +0800 |
commit | 685aebc72e9d5fc3fde275961709c4496fdb73cd (patch) | |
tree | 21b5d90e92714f5ed92b9efddeaa7633447f51f0 /ethereal | |
parent | 0ae3bbc3f5eda7ccabbd067fc8e361155004748c (diff) | |
parent | 0360e60dd54f773a922ada86fa669a9e78e31e18 (diff) | |
download | dexon-685aebc72e9d5fc3fde275961709c4496fdb73cd.tar dexon-685aebc72e9d5fc3fde275961709c4496fdb73cd.tar.gz dexon-685aebc72e9d5fc3fde275961709c4496fdb73cd.tar.bz2 dexon-685aebc72e9d5fc3fde275961709c4496fdb73cd.tar.lz dexon-685aebc72e9d5fc3fde275961709c4496fdb73cd.tar.xz dexon-685aebc72e9d5fc3fde275961709c4496fdb73cd.tar.zst dexon-685aebc72e9d5fc3fde275961709c4496fdb73cd.zip |
Merge branch 'develop'
Diffstat (limited to 'ethereal')
-rw-r--r-- | ethereal/debugger.go | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/ethereal/debugger.go b/ethereal/debugger.go index 89e0f36eb..64ca316f8 100644 --- a/ethereal/debugger.go +++ b/ethereal/debugger.go @@ -15,9 +15,8 @@ type DebuggerWindow struct { engine *qml.Engine lib *UiLib - vm *ethchain.Vm - Db *Debugger - breakPoints []int64 + vm *ethchain.Vm + Db *Debugger } func NewDebuggerWindow(lib *UiLib) *DebuggerWindow { @@ -30,9 +29,11 @@ func NewDebuggerWindow(lib *UiLib) *DebuggerWindow { } win := component.CreateWindow(nil) - db := &Debugger{win, make(chan bool), make(chan bool), true, false} - return &DebuggerWindow{engine: engine, win: win, lib: lib, Db: db, vm: ðchain.Vm{}} + w := &DebuggerWindow{engine: engine, win: win, lib: lib, vm: ðchain.Vm{}} + w.Db = NewDebugger(w) + + return w } func (self *DebuggerWindow) Show() { @@ -138,8 +139,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data Value: ethutil.Big(valueStr), }) vm.Verbose = true - vm.Hook = self.Db.halting - vm.BreakPoints = self.breakPoints + vm.Dbg = self.Db self.vm = vm self.Db.done = false @@ -201,8 +201,7 @@ func (self *DebuggerWindow) ExecCommand(command string) { self.Logln(err) break } - self.breakPoints = append(self.breakPoints, int64(lineNo)) - self.vm.BreakPoints = self.breakPoints + self.Db.breakPoints = append(self.Db.breakPoints, int64(lineNo)) self.Logf("break point set on instruction %d", lineNo) } else { self.Logf("'%s' requires line number", cmd[0]) @@ -211,8 +210,7 @@ func (self *DebuggerWindow) ExecCommand(command string) { if len(cmd) > 1 { switch cmd[1] { case "break", "bp": - self.breakPoints = nil - self.vm.BreakPoints = nil + self.Db.breakPoints = nil self.Logln("Breakpoints cleared") case "log": @@ -231,16 +229,38 @@ func (self *DebuggerWindow) ExecCommand(command string) { } type Debugger struct { - win *qml.Window N chan bool Q chan bool done, interrupt bool + breakPoints []int64 + main *DebuggerWindow + win *qml.Window +} + +func NewDebugger(main *DebuggerWindow) *Debugger { + db := &Debugger{make(chan bool), make(chan bool), true, false, nil, main, main.win} + + return db } type storeVal struct { Key, Value string } +func (self *Debugger) BreakHook(pc int, op ethchain.OpCode, mem *ethchain.Memory, stack *ethchain.Stack, stateObject *ethchain.StateObject) bool { + self.main.Logln("break on instr:", pc) + + return self.halting(pc, op, mem, stack, stateObject) +} + +func (self *Debugger) StepHook(pc int, op ethchain.OpCode, mem *ethchain.Memory, stack *ethchain.Stack, stateObject *ethchain.StateObject) bool { + return self.halting(pc, op, mem, stack, stateObject) +} + +func (self *Debugger) BreakPoints() []int64 { + return self.breakPoints +} + 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") |