144 backgroundColor: Color black; |
119 backgroundColor: Color black; |
145 cursorForegroundColor: Color white |
120 cursorForegroundColor: Color white |
146 backgroundColor: Color white. |
121 backgroundColor: Color white. |
147 |
122 |
148 "Modified: / 08-01-2018 / 19:16:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
123 "Modified: / 08-01-2018 / 19:16:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
149 ! |
|
150 |
|
151 send: aString |
|
152 [ |
|
153 pendingCommand := GDBCommand parse: aString. |
|
154 commandView readOnly: true. |
|
155 debugger send: pendingCommand. |
|
156 ] on: GDBCommandFailedError do:[ |
|
157 "/ Really, we should ignore the error here. |
|
158 1 + 1. "/ this is to trick the static analysis |
|
159 ]. |
|
160 |
|
161 "Created: / 08-01-2018 / 18:42:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
162 ! ! |
124 ! ! |
163 |
125 |
164 !VDBWindowsDebuggerConsoleApplication methodsFor:'aspects'! |
126 !VDBWindowsDebuggerConsoleApplication methodsFor:'aspects'! |
165 |
127 |
166 commandHistory |
128 consoleView |
167 commandHistory isNil ifTrue:[ |
129 consoleView isNil ifTrue:[ |
168 commandHistory := List new. |
130 consoleView := VDBWindowsDebuggerConsoleView new. |
169 ]. |
131 consoleView foregroundColor: Color white |
170 ^ commandHistory. |
132 backgroundColor: Color black; |
171 |
133 cursorForegroundColor: Color white |
172 "Modified: / 08-01-2018 / 18:43:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
134 backgroundColor: Color white. |
173 ! |
135 consoleView localEcho:true. |
174 |
136 consoleView inputTranslateCRToNL:true. |
175 commandHolder |
137 consoleView lineEditMode:true. |
176 <resource: #uiAspect> |
138 consoleView inStream:consoleInput. |
177 commandHolder isNil ifTrue:[ |
139 consoleView outStream:consoleOutput. |
178 commandHolder := ValueHolder new. |
140 consoleView startReaderProcessWhenVisible. |
179 commandHolder addDependent:self. |
141 ]. |
180 ]. |
142 ^ consoleView |
181 ^ commandHolder. |
143 |
182 |
144 "Created: / 09-06-2014 / 10:11:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
183 "Modified: / 08-01-2018 / 18:37:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
145 "Modified (format): / 10-06-2014 / 17:40:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
184 ! ! |
146 "Modified: / 04-04-2018 / 22:40:59 / jv" |
185 |
|
186 !VDBWindowsDebuggerConsoleApplication methodsFor:'change & update'! |
|
187 |
|
188 update:aspect with:param from:sender |
|
189 "Invoked when an object that I depend upon sends a change notification." |
|
190 |
|
191 "stub code automatically generated - please change as required" |
|
192 |
|
193 sender == commandHolder ifTrue:[ |
|
194 self updateAfterCommandHolderChanged. |
|
195 ^ self. |
|
196 ]. |
|
197 super update:aspect with:param from:sender |
|
198 |
|
199 "Modified: / 08-01-2018 / 18:39:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
200 ! |
|
201 |
|
202 updateAfterCommandHolderChanged |
|
203 (pendingCommand isNil and:[commandHolder value notEmptyOrNil]) ifTrue:[ |
|
204 self send: commandHolder value. |
|
205 ] |
|
206 |
|
207 "Created: / 08-01-2018 / 18:39:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
208 "Modified: / 26-03-2018 / 18:13:52 / jv" |
|
209 ! ! |
147 ! ! |
210 |
148 |
211 !VDBWindowsDebuggerConsoleApplication methodsFor:'event handling'! |
149 !VDBWindowsDebuggerConsoleApplication methodsFor:'event handling'! |
212 |
150 |
213 onCommandEvent: event |
151 onCommandEvent: event |
214 "/ event command == outstandingCommand ifTrue:[ |
152 event command == outstandingCommand ifTrue:[ |
215 "/ outstandingCommandToken := event token. |
153 outstandingCommandToken := event token. |
216 "/ ignoreNextLogStreamEvent := true. |
154 ignoreNextLogStreamEvent := true. |
217 "/ ]. |
155 ]. |
218 |
156 |
219 "Created: / 08-01-2018 / 18:51:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
157 "Created: / 06-06-2014 / 22:43:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
158 "Modified: / 11-06-2014 / 12:35:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
220 ! |
159 ! |
221 |
160 |
222 onCommandResultEvent: event |
161 onCommandResultEvent: event |
223 event result command == pendingCommand ifTrue:[ |
162 outstandingCommandToken notNil ifTrue:[ |
224 commandHolder value: ''. |
163 event token == outstandingCommandToken ifTrue:[ |
225 commandView readOnly: false. |
164 "/ Check if command ended up with an error. If so, |
226 commandView takeFocus. |
165 "/ print the error message. |
227 pendingCommand := nil. |
166 event result status == CommandStatusError ifTrue:[ |
228 ]. |
167 self showCR: ('Error: %1 ' bindWith: (event result propertyAt: #msg)). |
229 |
168 ] ifFalse:[ |
230 "Created: / 08-01-2018 / 18:52:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
169 "/ Check if the command issues is actually a MI command, |
|
170 "/ if so, print "Done" to the console since MI command don't |
|
171 "/ provide user feedback. |
|
172 outstandingCommand isMICommand ifTrue:[ |
|
173 self showCR: ('Done ( %1 , see even log for result value)' bindWith: outstandingCommand value) |
|
174 ]. |
|
175 ]. |
|
176 outstandingCommand := outstandingCommandToken := nil. |
|
177 outstandingCommandBlocker signalForAll. |
|
178 ]. |
|
179 ]. |
|
180 |
|
181 "Created: / 06-06-2014 / 22:44:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
182 "Modified: / 27-02-2015 / 13:01:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
183 ! |
|
184 |
|
185 onEventSetProcessingFinished: event |
|
186 self showPrompt. |
|
187 |
|
188 "Created: / 18-09-2014 / 23:11:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
231 ! |
189 ! |
232 |
190 |
233 onLogOutputEvent: event |
191 onLogOutputEvent: event |
234 "/ ignoreNextLogStreamEvent ifTrue:[ |
192 completing ifTrue:[ |
235 "/ ignoreNextLogStreamEvent := false. |
193 self halt. |
236 "/ ] ifFalse:[ |
194 ] ifFalse:[ |
237 self onStreamOutputEvent: event |
195 ignoreNextLogStreamEvent ifTrue:[ |
238 "/ ] |
196 ignoreNextLogStreamEvent := false. |
239 |
197 ] ifFalse:[ |
240 "Created: / 08-01-2018 / 18:52:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
198 self onStreamOutputEvent: event |
|
199 ] |
|
200 ]. |
|
201 |
|
202 "Created: / 11-06-2014 / 12:37:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
203 "Modified: / 16-09-2016 / 01:12:09 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
204 "Modified: / 04-04-2018 / 22:50:14 / jv" |
241 ! |
205 ! |
242 |
206 |
243 onStreamOutputEvent: event |
207 onStreamOutputEvent: event |
244 event value asStringCollection do:[:line | |
208 completing ifTrue:[ |
245 line notEmptyOrNil ifTrue:[ |
209 completions addAll: event value asStringCollection. |
246 consoleView showCR: line. |
210 ] ifFalse:[ |
|
211 consolePromptPrinted ifTrue:[ self showCR:'' ]. |
|
212 consolePromptPrinted := false. |
|
213 event value asStringCollection do:[:line | |
|
214 line notEmptyOrNil ifTrue:[ |
|
215 self showCR: line. |
|
216 ]. |
247 ]. |
217 ]. |
248 ]. |
218 ]. |
249 |
219 |
250 "Created: / 08-01-2018 / 18:52:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
220 "Created: / 11-06-2014 / 12:00:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
221 "Modified: / 16-09-2016 / 01:11:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
222 ! ! |
|
223 |
|
224 !VDBWindowsDebuggerConsoleApplication methodsFor:'hooks'! |
|
225 |
|
226 commonPostOpen |
|
227 consoleProcess isNil ifTrue:[ |
|
228 consoleProcess := |
|
229 [ |
|
230 [ |
|
231 | cmdLine cmd | |
|
232 self showPrompt. |
|
233 cmdLine := consoleInput nextLine asString. |
|
234 consolePromptPrinted := false. |
|
235 self showCR: cmdLine. |
|
236 cmdLine notEmptyOrNil ifTrue:[ |
|
237 cmd := (GDBMIParser on:cmdLine) parseCommand. |
|
238 cmd isCLICommand ifTrue:[ |
|
239 cmd runOnBackground: true. |
|
240 ]. |
|
241 outstandingCommand := cmd. |
|
242 debugger send:cmd andWait:false. |
|
243 outstandingCommandBlocker wait. |
|
244 ] |
|
245 ] loop. |
|
246 ] newProcess. |
|
247 consoleProcess name: 'VDB Debugger Console REPL loop'. |
|
248 consoleProcess resume. |
|
249 ]. |
|
250 |
|
251 "Created: / 10-06-2014 / 01:25:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
252 "Modified: / 16-09-2016 / 00:42:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
251 ! ! |
253 ! ! |
252 |
254 |
253 !VDBWindowsDebuggerConsoleApplication methodsFor:'initialization & release'! |
255 !VDBWindowsDebuggerConsoleApplication methodsFor:'initialization & release'! |
|
256 |
|
257 initialize |
|
258 super initialize. |
|
259 |
|
260 consoleInput := GDBInternalPipeStream new. |
|
261 consoleOutput := GDBInternalPipeStream new. |
|
262 consoleOutputLock := RecursionLock new. |
|
263 consolePrompt := '(gdb) '. |
|
264 consolePromptPrinted := false. |
|
265 outstandingCommandBlocker := Semaphore new. |
|
266 ignoreNextLogStreamEvent := false. |
|
267 completing := false. |
|
268 |
|
269 "Created: / 10-06-2014 / 01:23:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
270 "Modified: / 16-09-2016 / 00:33:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
271 "Modified: / 07-04-2018 / 23:13:27 / jv" |
|
272 ! |
|
273 |
|
274 release |
|
275 super release. |
|
276 consoleProcess terminate. |
|
277 |
|
278 "Created: / 10-06-2014 / 01:34:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
279 ! |
254 |
280 |
255 subscribe |
281 subscribe |
256 "Register for debugger events. To be overrided by subclasses" |
282 "Register for debugger events. To be overrided by subclasses" |
257 |
283 |
258 debugger announcer |
284 debugger announcer |
259 when: GDBCommandEvent send: #onCommandEvent: to: self; |
285 when: GDBCommandEvent send: #onCommandEvent: to: self; |
260 when: GDBCommandResultEvent send: #onCommandResultEvent: to: self; |
286 when: GDBCommandResultEvent send: #onCommandResultEvent: to: self; |
261 |
287 |
262 when: GDBConsoleOutputEvent send: #onStreamOutputEvent: to: self; |
288 when: GDBConsoleOutputEvent send: #onStreamOutputEvent: to: self; |
263 when: GDBTargetOutputEvent send: #onStreamOutputEvent: to: self; |
289 when: GDBTargetOutputEvent send: #onStreamOutputEvent: to: self; |
264 when: GDBLogOutputEvent send: #onLogOutputEvent: to: self. |
290 when: GDBLogOutputEvent send: #onLogOutputEvent: to: self; |
265 |
291 |
266 "Created: / 08-01-2018 / 18:50:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
292 when: GDBEventSetProcessingFinished send: #onEventSetProcessingFinished: to: self. |
|
293 |
|
294 "Created: / 06-06-2014 / 21:26:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
295 "Modified: / 18-09-2014 / 23:11:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
296 ! ! |
|
297 |
|
298 !VDBWindowsDebuggerConsoleApplication methodsFor:'private'! |
|
299 |
|
300 completeLine: aString |
|
301 | result | |
|
302 |
|
303 (debugger inferiors allSatisfy:[:inferior | inferior isRunning]) ifTrue:[ |
|
304 consoleView flash. |
|
305 ^ #() |
|
306 ]. |
|
307 |
|
308 completing := true. |
|
309 completions := OrderedCollection new. |
|
310 [ |
|
311 result := debugger send: 'complete ', aString. |
|
312 ] ensure:[ |
|
313 completing := false. |
|
314 ]. |
|
315 self halt. |
|
316 |
|
317 "Created: / 16-09-2016 / 01:09:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
318 ! ! |
|
319 |
|
320 !VDBWindowsDebuggerConsoleApplication methodsFor:'private - writing'! |
|
321 |
|
322 show: aString |
|
323 consoleOutputLock critical:[ |
|
324 consoleOutput nextPutAll: aString. |
|
325 ]. |
|
326 |
|
327 "Created: / 11-06-2014 / 08:02:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
328 "Modified: / 11-06-2014 / 11:53:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
329 ! |
|
330 |
|
331 showCR: aString |
|
332 consoleOutputLock critical:[ |
|
333 consoleOutput nextPutAll: aString. |
|
334 consoleOutput nextPut: Character nl. |
|
335 consoleOutput nextPut: Character return. |
|
336 ]. |
|
337 |
|
338 "Created: / 11-06-2014 / 08:02:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
339 "Modified: / 11-06-2014 / 11:56:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
340 ! |
|
341 |
|
342 showPrompt |
|
343 consolePromptPrinted ifFalse:[ |
|
344 self show: consolePrompt. |
|
345 consolePromptPrinted := true. |
|
346 ]. |
|
347 |
|
348 "Created: / 18-09-2014 / 23:18:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
349 "Modified: / 04-04-2018 / 23:01:24 / jv" |
267 ! ! |
350 ! ! |
268 |
351 |
269 !VDBWindowsDebuggerConsoleApplication class methodsFor:'documentation'! |
352 !VDBWindowsDebuggerConsoleApplication class methodsFor:'documentation'! |
270 |
353 |
271 version_HG |
354 version_HG |