More work on GDB process simulator.
--- a/GDBSimulatorProcess.st Tue Jun 24 00:55:57 2014 +0100
+++ b/GDBSimulatorProcess.st Tue Jun 24 09:23:18 2014 +0100
@@ -1,7 +1,7 @@
"{ Package: 'jv:libgdbs' }"
GDBProcess subclass:#GDBSimulatorProcess
- instanceVariableNames:''
+ instanceVariableNames:'record thread'
classVariableNames:''
poolDictionaries:''
category:'GDB-Private'
@@ -17,3 +17,91 @@
"Modified: / 20-06-2014 / 22:18:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
+!GDBSimulatorProcess methodsFor:'processing'!
+
+process: commandOrResponse
+ | commandLine |
+
+ "Process response..."
+ commandOrResponse isResponse ifTrue:[
+ debuggerOutput nextPutAll: commandOrResponse string.
+ ^ false.
+ ].
+ "Process command"
+ commandLine := debuggerInput nextLine.
+ commandLine ~= commandOrResponse string ifTrue:[
+ | commandLineStream token command |
+
+ commandLineStream := commandLine readStream.
+ commandLineStream peek isDigit ifTrue:[
+ token := 0.
+ [ commandLineStream peek isDigit ] whileTrue:[
+ token := (token * 10) + (commandLineStream next codePoint - $0 codePoint)
+ ]
+ ].
+ command := commandLineStream upToEnd.
+ token notNil ifTrue:[
+ debuggerOutput nextPutAll: token printString.
+ ].
+
+ command = '-gdb-exit' ifTrue:[
+ debuggerOutput nextPutLine: '^exit'.
+ ^ true "/ We're done
+ ] ifFalse:[
+ debuggerOutput nextPutLine:'^error,msg="Unexpected command for this simulation"'
+ ].
+
+ ].
+ ^ false
+
+ "Created: / 24-06-2014 / 08:50:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+processLoop
+ | done events |
+
+ done := false.
+ events := record readStream.
+ [ done or:[ events atEnd ] ] whileFalse:[
+ done := self process: events next.
+
+ ].
+
+ "Created: / 24-06-2014 / 08:48:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!GDBSimulatorProcess methodsFor:'start & stop'!
+
+record
+ ^ record
+!
+
+record:aGDBSessionRecord
+ record := aGDBSessionRecord.
+ self start.
+
+ "Modified: / 24-06-2014 / 00:58:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+start
+ self stop.
+
+ thread := [
+ self processLoop.
+ ] newProcess.
+ thread addExitAction: [ thread := nil ].
+ thread resume.
+
+ "Created: / 24-06-2014 / 00:58:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 24-06-2014 / 08:48:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+stop
+ (thread notNil and:[ thread isDead not ]) ifTrue:[
+ thread terminate.
+ thread := nil.
+ ]
+
+ "Created: / 24-06-2014 / 01:02:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
--- a/GDBSimulatorResource.st Tue Jun 24 00:55:57 2014 +0100
+++ b/GDBSimulatorResource.st Tue Jun 24 09:23:18 2014 +0100
@@ -7,7 +7,7 @@
category:'GDB-Resources'
!
-!GDBSimulatorResource methodsFor:'recorded sessions'!
+!GDBSimulatorResource class methodsFor:'recorded sessions'!
session_factorial_01
--- a/libgdbs.rc Tue Jun 24 00:55:57 2014 +0100
+++ b/libgdbs.rc Tue Jun 24 09:23:18 2014 +0100
@@ -25,7 +25,7 @@
VALUE "LegalCopyright", "My CopyRight or CopyLeft\0"
VALUE "ProductName", "LibraryName\0"
VALUE "ProductVersion", "6.2.4.0\0"
- VALUE "ProductDate", "Mon, 23 Jun 2014 23:52:53 GMT\0"
+ VALUE "ProductDate", "Tue, 24 Jun 2014 08:22:06 GMT\0"
END
END
--- a/tests/GDBDebuggerTests.st Tue Jun 24 00:55:57 2014 +0100
+++ b/tests/GDBDebuggerTests.st Tue Jun 24 09:23:18 2014 +0100
@@ -27,7 +27,7 @@
!GDBDebuggerTests methodsFor:'tests - basic'!
-test_exit_01
+test_basic_01
| debugger timeouted |
debugger := GDBDebugger new.
@@ -40,6 +40,16 @@
self assert: timeouted not.
self assert: debugger isConnected not.
- "Created: / 20-06-2014 / 22:00:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Created: / 24-06-2014 / 09:06:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+test_basic_02
+ | simulator debugger |
+
+ simulator := GDBSimulatorProcess new record: GDBSimulatorResource session_factorial_01.
+ debugger := GDBDebugger newWithProcess: simulator.
+ simulator start.
+
+ "Created: / 24-06-2014 / 09:09:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
--- a/tests/tests.rc Tue Jun 24 00:55:57 2014 +0100
+++ b/tests/tests.rc Tue Jun 24 09:23:18 2014 +0100
@@ -25,7 +25,7 @@
VALUE "LegalCopyright", "My CopyRight or CopyLeft\0"
VALUE "ProductName", "LibraryName\0"
VALUE "ProductVersion", "6.2.4.0\0"
- VALUE "ProductDate", "Mon, 23 Jun 2014 23:52:55 GMT\0"
+ VALUE "ProductDate", "Tue, 24 Jun 2014 08:22:08 GMT\0"
END
END