--- a/VDBDebuggerConsoleApplication.st Tue Jun 10 21:35:16 2014 +0100
+++ b/VDBDebuggerConsoleApplication.st Wed Jun 11 23:12:20 2014 +0100
@@ -1,7 +1,9 @@
"{ Package: 'jv:vdb' }"
VDBAbstractApplication subclass:#VDBDebuggerConsoleApplication
- instanceVariableNames:'consoleView consoleInput consoleOutput consoleProcess'
+ instanceVariableNames:'consoleView consoleInput consoleOutput consoleOutputLock
+ consoleProcess outstandingCommand outstandingCommandToken
+ outstandingCommandBlocker ignoreNextLogStreamEvent'
classVariableNames:''
poolDictionaries:''
category:'VDB-UI-Console'
@@ -73,30 +75,45 @@
!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: / 10-06-2014 / 01:33:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 11-06-2014 / 11:49:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-onConsoleOutputEvent: event
- consoleOutput nextPutAll: event value.
- consoleOutput nextPut: Character return.
+onLogOutputEvent: event
+ ignoreNextLogStreamEvent ifTrue:[
+ ignoreNextLogStreamEvent := false.
+ ] ifFalse:[
+ self onStreamOutputEvent: event
+ ]
- "Created: / 06-06-2014 / 21:45:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 10-06-2014 / 01:33:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Created: / 11-06-2014 / 12:37:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
-onTargetOutputEvent: event
- consoleOutput nextPutAll: event value.
- consoleOutput nextPut: Character return.
+onStreamOutputEvent: event
+ event value asStringCollection do:[:line |
+ line notEmptyOrNil ifTrue:[
+ self showCR: line.
+ ].
+ ].
- "Created: / 06-06-2014 / 21:45:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 10-06-2014 / 01:33:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Created: / 11-06-2014 / 12:00:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!VDBDebuggerConsoleApplication methodsFor:'hooks'!
@@ -107,11 +124,11 @@
[
[
| cmd |
- consoleOutput nextPutAll:'(gdb) '.
+ self show: '(gdb) '.
cmd := consoleInput nextLine asString.
- consoleOutput nextPutLine: cmd.
- consoleOutput nextPut: Character return.
- debugger send: (GDBCLICommand new value: cmd) wait: true.
+ self showCR: cmd.
+ debugger send: (outstandingCommand := GDBCLICommand new value: cmd) wait: false.
+ outstandingCommandBlocker wait.
] loop.
] newProcess.
consoleProcess name: 'VDB Debugger Console REPL loop'.
@@ -119,7 +136,7 @@
].
"Created: / 10-06-2014 / 01:25:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
- "Modified: / 10-06-2014 / 19:55:31 / 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'!
@@ -129,8 +146,11 @@
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
@@ -147,10 +167,34 @@
when: GDBCommandEvent send: #onCommandEvent: to: self;
when: GDBCommandResultEvent send: #onCommandResultEvent: to: self;
- when: GDBConsoleOutputEvent send: #onConsoleOutputEvent: to: self;
- when: GDBTargetOutputEvent send: #onTargetOutputEvent: 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'!