Catch up after API changes in GDBDebugger command API.
Use #send:andWaif: instead #send:wait:
"{ Package: 'jv:vdb' }"
"{ NameSpace: Smalltalk }"
VDBAbstractApplication subclass:#VDBDebuggerConsoleApplication
instanceVariableNames:'consoleView consoleInput consoleOutput consoleOutputLock
consoleProcess consolePromptPrinted outstandingCommand
outstandingCommandToken outstandingCommandBlocker
ignoreNextLogStreamEvent'
classVariableNames:''
poolDictionaries:'GDBCommandStatus'
category:'VDB-UI-Console'
!
!VDBDebuggerConsoleApplication class methodsFor:'interface specs'!
windowSpec
"This resource specification was automatically generated
by the UIPainter of ST/X."
"Do not manually edit this!! If it is corrupted,
the UIPainter may not be able to read the specification."
"
UIPainter new openOnClass:VDBConsoleApplication andSelector:#windowSpec
VDBConsoleApplication new openInterface:#windowSpec
VDBConsoleApplication open
"
<resource: #canvas>
^
#(FullSpec
name: windowSpec
window:
(WindowSpec
label: 'Debugger Console'
name: 'Debugger Console'
min: (Point 10 10)
bounds: (Rectangle 0 0 782 332)
)
component:
(SpecCollection
collection: (
(ArbitraryComponentSpec
name: 'Console'
layout: (LayoutFrame 0 0 0 0 0 1 0 1)
hasBorder: false
component: consoleView
)
)
)
)
"Modified: / 09-06-2014 / 09:57:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VDBDebuggerConsoleApplication methodsFor:'aspects'!
consoleView
consoleView isNil ifTrue:[
consoleView := VDBDebuggerConsoleView new.
consoleView localEcho:true.
consoleView inputTranslateCRToNL:true.
consoleView lineEditMode: true.
consoleView inStream: consoleInput.
consoleView outStream: consoleOutput.
consoleView startReaderProcessWhenVisible.
].
^ consoleView
"Created: / 09-06-2014 / 10:11:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified (format): / 10-06-2014 / 17:40:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VDBDebuggerConsoleApplication methodsFor:'event handling'!
onCommandEvent: event
event command == outstandingCommand ifTrue:[
outstandingCommandToken := event token.
ignoreNextLogStreamEvent := true.
].
"Created: / 06-06-2014 / 22:43:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 11-06-2014 / 12:35:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
onCommandResultEvent: event
outstandingCommandToken notNil ifTrue:[
event token == outstandingCommandToken ifTrue:[
"/ Check if command ended up with an error. If so,
"/ print the error message.
event result status == CommandStatusError ifTrue:[
self showCR: ('Error: %1 ' bindWith: (event result propertyAt: #msg)).
] ifFalse:[
"/ Check if the command issues is actually a MI command,
"/ if so, print "Done" to the console since MI command don't
"/ provide user feedback.
outstandingCommand isMICommand ifTrue:[
self showCR: ('Done ( %1 , see even log for result value)' bindWith: outstandingCommand value)
].
].
outstandingCommand := outstandingCommandToken := nil.
outstandingCommandBlocker signalForAll.
].
].
"Created: / 06-06-2014 / 22:44:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 27-02-2015 / 13:01:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
onEventSetProcessingFinished: event
self showPrompt.
"Created: / 18-09-2014 / 23:11:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
onLogOutputEvent: event
ignoreNextLogStreamEvent ifTrue:[
ignoreNextLogStreamEvent := false.
] ifFalse:[
self onStreamOutputEvent: event
]
"Created: / 11-06-2014 / 12:37:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
onStreamOutputEvent: event
consolePromptPrinted ifTrue:[ self showCR:'' ].
consolePromptPrinted := false.
event value asStringCollection do:[:line |
line notEmptyOrNil ifTrue:[
self showCR: line.
].
].
"Created: / 11-06-2014 / 12:00:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 18-09-2014 / 23:18:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VDBDebuggerConsoleApplication methodsFor:'hooks'!
commonPostOpen
consoleProcess isNil ifTrue:[
consoleProcess :=
[
[
| cmdLine cmd |
self showPrompt.
cmdLine := consoleInput nextLine asString.
consolePromptPrinted := false.
self showCR: cmdLine.
cmd := (GDBMIParser on:cmdLine) parseCommand.
cmd isCLICommand ifTrue:[
cmd runOnBackground: true.
].
outstandingCommand := cmd.
debugger send:cmd andWait:false.
outstandingCommandBlocker wait.
] loop.
] newProcess.
consoleProcess name: 'VDB Debugger Console REPL loop'.
consoleProcess resume.
].
"Created: / 10-06-2014 / 01:25:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 30-09-2014 / 09:38:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VDBDebuggerConsoleApplication methodsFor:'initialization & release'!
initialize
super initialize.
consoleInput := GDBInternalPipeStream new.
consoleOutput := GDBInternalPipeStream new.
consoleOutputLock := RecursionLock new.
consolePromptPrinted := false.
outstandingCommandBlocker := Semaphore new.
"Created: / 10-06-2014 / 01:23:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 18-09-2014 / 23:14:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
release
super release.
consoleProcess terminate.
"Created: / 10-06-2014 / 01:34:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
subscribe
"Register for debugger events. To be overrided by subclasses"
debugger announcer
when: GDBCommandEvent send: #onCommandEvent: to: self;
when: GDBCommandResultEvent send: #onCommandResultEvent: to: self;
when: GDBConsoleOutputEvent send: #onStreamOutputEvent: to: self;
when: GDBTargetOutputEvent send: #onStreamOutputEvent: to: self;
when: GDBLogOutputEvent send: #onLogOutputEvent: to: self;
when: GDBEventSetProcessingFinished send: #onEventSetProcessingFinished: to: self.
"Created: / 06-06-2014 / 21:26:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 18-09-2014 / 23:11:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VDBDebuggerConsoleApplication methodsFor:'private - writing'!
show: aString
consoleOutputLock critical:[
consoleOutput nextPutAll: aString.
].
"Created: / 11-06-2014 / 08:02:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 11-06-2014 / 11:53:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
showCR: aString
consoleOutputLock critical:[
consoleOutput nextPutAll: aString.
consoleOutput nextPut: Character nl.
consoleOutput nextPut: Character return.
].
"Created: / 11-06-2014 / 08:02:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 11-06-2014 / 11:56:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
showPrompt
consolePromptPrinted ifFalse:[
self show: '(gdb) '.
consolePromptPrinted := true.
].
"Created: / 18-09-2014 / 23:18:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VDBDebuggerConsoleApplication class methodsFor:'documentation'!
version_HG
^ '$Changeset: <not expanded> $'
! !