-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbreakpoint.go
178 lines (138 loc) · 3.84 KB
/
breakpoint.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// Copyright 2013 Chris McGee <[email protected]>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package gdblib
import (
"strconv"
)
type BreakListResult struct {
BreakPointTable BreakPointTable
}
type BreakPointTable struct {
Nr_rows string `json:"nr_rows"`
Nr_cols string `json:"nr_cols"`
Hdr []BreakPointHeaderElement `json:"hdr"`
Body []BreakPoint `json:"body"`
}
type BreakPointHeaderElement struct {
Width string `json:"width"`
Alignment string `json:"alignment"`
Col_name string `json:"col_name"`
Colhdr string `json:"colhdr"`
}
type BreakPoint struct {
Number string `json:"number"`
Type string `json:"type"`
FullName string `json:"fullname"`
Disp string `json:"disp"`
Enabled string `json:"enabled"`
Addr string `json:"addr"`
Func string `json:"func"`
File string `json:"file"`
Line string `json:"line"`
ThreadGroups []string `json:"thread-groups"`
Times string `json:"times"`
}
func (gdb *GDB) BreakList() (breakList *BreakListResult, _ error) {
descriptor := cmdDescr{forceInterrupt: true}
descriptor.cmd = "-break-list"
descriptor.response = make(chan cmdResultRecord)
gdb.input <- descriptor
result := <-descriptor.response
resultObj := BreakListResult{}
err := parseResult(result, &resultObj)
if err != nil {
return nil, err
}
return &resultObj, nil
}
type BreakInsertParms struct {
Temporary bool
Hardware bool
Force bool
Disabled bool
Tracepoint bool
Condition string
IgnoreCount int64
ThreadId string
Location string
}
type BreakInsertResult struct {
BreakPoint BreakPoint `json:"bkpt"`
}
func (gdb *GDB) BreakInsert(parms BreakInsertParms) (*BreakInsertResult, error) {
descriptor := cmdDescr{forceInterrupt: true}
descriptor.cmd = "-break-insert"
if parms.Temporary {
descriptor.cmd = descriptor.cmd + " -t"
}
if parms.Hardware {
descriptor.cmd = descriptor.cmd + " -h"
}
if parms.Force {
descriptor.cmd = descriptor.cmd + " -f"
}
if parms.Disabled {
descriptor.cmd = descriptor.cmd + " -d"
}
if parms.Tracepoint {
descriptor.cmd = descriptor.cmd + " -a"
}
if parms.Condition != "" {
descriptor.cmd = descriptor.cmd + " -c " + parms.Condition
}
if parms.IgnoreCount > 0 {
descriptor.cmd = descriptor.cmd + " -i " + strconv.FormatInt(parms.IgnoreCount, 10)
}
if parms.ThreadId != "" {
descriptor.cmd = descriptor.cmd + " -p " + parms.ThreadId
}
if parms.Location != "" {
descriptor.cmd = descriptor.cmd + " " + parms.Location
}
descriptor.response = make(chan cmdResultRecord)
gdb.input <- descriptor
result := <-descriptor.response
resultObj := BreakInsertResult{}
err := parseResult(result, &resultObj)
if err != nil {
return nil, err
}
return &resultObj, nil
}
type BreakEnableParms struct {
Breakpoints []string
}
func (gdb *GDB) BreakEnable(parms BreakEnableParms) (_ error) {
descriptor := cmdDescr{forceInterrupt: true}
descriptor.cmd = "-break-enable"
for _, id := range parms.Breakpoints {
descriptor.cmd = descriptor.cmd + " " + id
}
descriptor.response = make(chan cmdResultRecord)
gdb.input <- descriptor
result := <-descriptor.response
err := parseResult(result, nil)
if err != nil {
return err
}
return nil
}
type BreakDisableParms struct {
Breakpoints []string
}
func (gdb *GDB) BreakDisable(parms BreakDisableParms) (_ error) {
descriptor := cmdDescr{forceInterrupt: true}
descriptor.cmd = "-break-disable"
for _, id := range parms.Breakpoints {
descriptor.cmd = descriptor.cmd + " " + id
}
descriptor.response = make(chan cmdResultRecord)
gdb.input <- descriptor
result := <-descriptor.response
err := parseResult(result, nil)
if err != nil {
return err
}
return nil
}