-
Notifications
You must be signed in to change notification settings - Fork 26
/
debug.go
86 lines (69 loc) · 1.99 KB
/
debug.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package interpreter
// Debugger implement to enable debugging.
// If enabled, copies of state are provided to each of the functions on
// call.
//
// Each function is called during its stage of a threads lifecycle.
// A high level overview of this lifecycle is:
//
// BeforeExecute
// for step
// BeforeStep
// BeforeExecuteOpcode
// for each stack push
// BeforeStackPush
// AfterStackPush
// end for
// for each stack pop
// BeforeStackPop
// AfterStackPop
// end for
// AfterExecuteOpcode
// if end of script
// BeforeScriptChange
// AfterScriptChange
// end if
// if bip16 and end of final script
// BeforeStackPush
// AfterStackPush
// end if
// AfterStep
// end for
// AfterExecute
// if success
// AfterSuccess
// end if
// if error
// AfterError
// end if
type Debugger interface {
BeforeExecute(*State)
AfterExecute(*State)
BeforeStep(*State)
AfterStep(*State)
BeforeExecuteOpcode(*State)
AfterExecuteOpcode(*State)
BeforeScriptChange(*State)
AfterScriptChange(*State)
AfterSuccess(*State)
AfterError(*State, error)
BeforeStackPush(*State, []byte)
AfterStackPush(*State, []byte)
BeforeStackPop(*State)
AfterStackPop(*State, []byte)
}
type nopDebugger struct{}
func (n *nopDebugger) BeforeExecute(*State) {}
func (n *nopDebugger) AfterExecute(*State) {}
func (n *nopDebugger) BeforeStep(*State) {}
func (n *nopDebugger) AfterStep(*State) {}
func (n *nopDebugger) BeforeExecuteOpcode(*State) {}
func (n *nopDebugger) AfterExecuteOpcode(*State) {}
func (n *nopDebugger) BeforeScriptChange(*State) {}
func (n *nopDebugger) AfterScriptChange(*State) {}
func (n *nopDebugger) BeforeStackPush(*State, []byte) {}
func (n *nopDebugger) AfterStackPush(*State, []byte) {}
func (n *nopDebugger) BeforeStackPop(*State) {}
func (n *nopDebugger) AfterStackPop(*State, []byte) {}
func (n *nopDebugger) AfterSuccess(*State) {}
func (n *nopDebugger) AfterError(*State, error) {}