Fixed fixed synchronization for debugger console view.
"{ Package: 'jv:vdb' }"
VDBAbstractApplication subclass:#VDBDebuggerConsoleApplication
instanceVariableNames:'consoleView consoleInput consoleOutput consoleOutputLock
consoleProcess outstandingCommand outstandingCommandToken
outstandingCommandBlocker ignoreNextLogStreamEvent'
classVariableNames:''
poolDictionaries:''
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:[
outstandingCommand := outstandingCommandToken := nil.
outstandingCommandBlocker signalForAll.
].
].
"Created: / 06-06-2014 / 22:44:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 11-06-2014 / 11:49:33 / 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
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>"
! !
!VDBDebuggerConsoleApplication methodsFor:'hooks'!
commonPostOpen
consoleProcess isNil ifTrue:[
consoleProcess :=
[
[
| cmd |
self show: '(gdb) '.
cmd := consoleInput nextLine asString.
self showCR: cmd.
debugger send: (outstandingCommand := GDBCLICommand new value: cmd) wait: 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: / 11-06-2014 / 11:57:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VDBDebuggerConsoleApplication methodsFor:'initialization & release'!
initialize
super initialize.
consoleInput := VDBInternalPipeStream new.
consoleOutput := VDBInternalPipeStream new.
consoleOutputLock := RecursionLock new.
outstandingCommandBlocker := Semaphore new.
"Created: / 10-06-2014 / 01:23:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 11-06-2014 / 11:46:50 / 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.
"Created: / 06-06-2014 / 21:26:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 11-06-2014 / 12:38:02 / 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>"
! !
!VDBDebuggerConsoleApplication class methodsFor:'documentation'!
version_HG
^ '$Changeset: <not expanded> $'
! !