31 ^ connection eventAnnouncer. |
31 ^ connection eventAnnouncer. |
32 |
32 |
33 "Created: / 02-06-2014 / 23:06:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
33 "Created: / 02-06-2014 / 23:06:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
34 ! |
34 ! |
35 |
35 |
|
36 executable: aStringOrFilename |
|
37 "Sets the executable to debug. |
|
38 API equivalent to CLI command: |
|
39 |
|
40 (gdb) exec-file <aStringOrFilename> |
|
41 " |
|
42 self send: (GDBMI_file_exec_and_symbols arguments: { aStringOrFilename asString }) wait: false. |
|
43 |
|
44 "Created: / 28-02-2015 / 00:19:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
45 ! |
|
46 |
36 inferiorForId: id |
47 inferiorForId: id |
37 ^ inferiors ? #() detect:[:e | e id = id ] ifNone:[ |
48 ^ inferiors ? #() detect:[:e | e id = id ] ifNone:[ |
38 self error: ('No inferior (thread group) with id ''%1'' found!!' bindWith: id) |
49 self error: ('No inferior (thread group) with id ''%1'' found!!' bindWith: id) |
39 ]. |
50 ]. |
40 |
51 |
105 "Created: / 02-06-2014 / 23:48:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
116 "Created: / 02-06-2014 / 23:48:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
106 ! ! |
117 ! ! |
107 |
118 |
108 !GDBDebugger methodsFor:'commands'! |
119 !GDBDebugger methodsFor:'commands'! |
109 |
120 |
110 send: aGDBCommand |
121 send: command |
111 ^ self send: aGDBCommand wait: true. |
122 "Execute given `command` and wait until it finishes. |
|
123 Command can be either an instance of GDBCommand or |
|
124 a String. If String, it is assumed to be a CLI command |
|
125 string. |
|
126 " |
|
127 ^ self send: command wait: true. |
112 |
128 |
113 "Created: / 03-06-2014 / 00:10:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
129 "Created: / 03-06-2014 / 00:10:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
114 ! |
130 "Modified (comment): / 28-02-2015 / 00:40:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
115 |
131 ! |
116 send: aGDBCommand wait: aBoolean |
132 |
117 "Sends given command to GDB. If `aBoolean` is true, wait for |
133 send: command wait: wait |
|
134 "Sends given `command` to GDB. If `aBoolean` is true, wait for |
118 command to finish. Otherwise, return immediately." |
135 command to finish. Otherwise, return immediately." |
119 |
136 |
120 | token blocker handler1 handler2 result | |
137 | cmd token blocker handler1 handler2 result | |
121 |
138 |
122 (aBoolean and:[Processor activeProcess == connection eventDispatchProcess]) ifTrue:[ |
139 cmd := command. |
|
140 cmd isString ifTrue:[ |
|
141 cmd := GDBCLICommand new value: cmd. |
|
142 ]. |
|
143 (wait and:[Processor activeProcess == connection eventDispatchProcess]) ifTrue:[ |
123 self error: 'Cannot send commands from within event dispatching process. Would deadlock'. |
144 self error: 'Cannot send commands from within event dispatching process. Would deadlock'. |
124 ]. |
145 ]. |
125 |
146 |
126 token := self nextCommandSequnceNumber. |
147 token := self nextCommandSequnceNumber. |
127 aGDBCommand token: token. |
148 cmd token: token. |
128 ^ aBoolean ifTrue:[ |
149 ^ wait ifTrue:[ |
129 handler1 := [ :ev | |
150 handler1 := [ :ev | |
130 ev token == token ifTrue:[ |
151 ev token == token ifTrue:[ |
131 connection eventAnnouncer unsubscribe: handler1. |
152 connection eventAnnouncer unsubscribe: handler1. |
132 result := ev result. |
153 result := ev result. |
133 connection eventAnnouncerInternal when: GDBEventSetProcessingFinished do: handler2. |
154 connection eventAnnouncerInternal when: GDBEventSetProcessingFinished do: handler2. |
136 connection eventAnnouncerInternal unsubscribe: handler2. |
157 connection eventAnnouncerInternal unsubscribe: handler2. |
137 blocker signal. |
158 blocker signal. |
138 ]. |
159 ]. |
139 blocker := Semaphore new. |
160 blocker := Semaphore new. |
140 connection eventAnnouncer when: GDBCommandResultEvent do: handler1. |
161 connection eventAnnouncer when: GDBCommandResultEvent do: handler1. |
141 connection pushEvent: (GDBCommandEvent new command: aGDBCommand). |
162 connection pushEvent: (GDBCommandEvent new command: cmd). |
142 blocker wait. |
163 blocker wait. |
143 result. |
164 result. |
144 ] ifFalse:[ |
165 ] ifFalse:[ |
145 connection pushEvent: (GDBCommandEvent new command: aGDBCommand). |
166 connection pushEvent: (GDBCommandEvent new command: cmd). |
146 nil. |
167 nil. |
147 ] |
168 ] |
148 |
169 |
149 "Created: / 02-06-2014 / 23:45:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
170 "Created: / 02-06-2014 / 23:45:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
150 "Modified: / 24-09-2014 / 09:25:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
171 "Modified: / 28-02-2015 / 00:42:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
151 ! ! |
172 ! ! |
152 |
173 |
153 !GDBDebugger methodsFor:'event handling'! |
174 !GDBDebugger methodsFor:'event handling'! |
154 |
175 |
155 onCommandEvent:aGDBCommandEvent |
176 onCommandEvent:aGDBCommandEvent |