More work on GDBThreadStatus
authorJan Vrany <jan.vrany@fit.cvut.cz>
Mon, 08 Sep 2014 23:56:17 +0100
changeset 38 c9eaa506824b
parent 37 a85f0c91f164
child 39 2b9d2f75906f
More work on GDBThreadStatus
GDBAsyncEvent.st
GDBDebugger.st
GDBExecutionEvent.st
GDBRunningEvent.st
GDBStoppedEvent.st
--- a/GDBAsyncEvent.st	Mon Sep 08 10:02:31 2014 +0100
+++ b/GDBAsyncEvent.st	Mon Sep 08 23:56:17 2014 +0100
@@ -14,16 +14,18 @@
     "Invoked at system start or when the class is dynamically loaded."
 
     EventTypeToEventClassMap := Dictionary new.
-    self allSubclassesDo:[:cls|
-        | type |    
+    Smalltalk isStandAloneApp ifTrue:[
+        self allSubclassesDo:[:cls|
+            | type |    
 
-        type := cls basicNew type.
-        type notNil ifTrue:[ 
-            EventTypeToEventClassMap at: type put: cls.
-        ].
-    ]
+            type := cls basicNew type.
+            type notNil ifTrue:[ 
+                EventTypeToEventClassMap at: type put: cls.
+            ].
+        ]
+    ].
 
-    "Modified: / 13-06-2014 / 07:11:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 08-09-2014 / 23:49:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !GDBAsyncEvent class methodsFor:'accessing'!
@@ -71,6 +73,16 @@
     "Modified: / 13-06-2014 / 07:12:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!GDBAsyncEvent class methodsFor:'accessing - GDB value descriptors'!
+
+gdbValueDescriptor
+    ^ (super gdbValueDescriptor)
+        "/define: #prop as: String;
+        yourself
+
+    "Created: / 08-09-2014 / 21:59:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !GDBAsyncEvent class methodsFor:'queries'!
 
 isAbstract
--- a/GDBDebugger.st	Mon Sep 08 10:02:31 2014 +0100
+++ b/GDBDebugger.st	Mon Sep 08 23:56:17 2014 +0100
@@ -162,14 +162,48 @@
 !
 
 onRunningEvent: aGDBRunningEvent
-    self nextInferiorStateSequnceNumber
+    | threads threadId |
+
+    threadId := aGDBRunningEvent threadId.
+    threadId = 'all' ifFalse:[ 
+        threadId := threadId asInteger.
+    ].
+    self nextInferiorStateSequnceNumber.
+    threads := Set new.
+    inferiors do:[:inferior | 
+        inferior threads do:[:thread | 
+            (threadId isString or:[thread id = threadId]) ifTrue:[ 
+                thread setStatus: GDBThreadStatusRunning theOneAndOnlyInstance.
+                threads add: thread.
+            ].
+        ].
+    ].
+    aGDBRunningEvent setThreads: threads
 
     "Created: / 07-09-2014 / 23:34:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 08-09-2014 / 23:51:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-onStoppedEvent: aGDBRunningEvent
+onStoppedEvent: aGDBStoppedEvent
+    | threads threadIds |
+
+    threadIds := aGDBStoppedEvent stoppedThreadIds.
+    threadIds = 'all' ifFalse:[ 
+        threadIds := threadIds collect:[:e | e asInteger ].
+    ].
+    threads := Set new.
+    inferiors do:[:inferior | 
+        inferior threads do:[:thread | 
+            (threadIds isString or:[threadIds includes: thread id]) ifTrue:[ 
+                thread setStatus: GDBThreadStatusStopped new.
+                threads add: thread.
+            ].
+        ].
+    ].
+    aGDBStoppedEvent setThreads: threads
 
     "Created: / 07-09-2014 / 23:34:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 08-09-2014 / 23:50:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 onThreadCreatedEvent:aGDBThreadCreatedEvent 
--- a/GDBExecutionEvent.st	Mon Sep 08 10:02:31 2014 +0100
+++ b/GDBExecutionEvent.st	Mon Sep 08 23:56:17 2014 +0100
@@ -1,12 +1,27 @@
 "{ Package: 'jv:libgdbs' }"
 
 GDBAsyncEvent subclass:#GDBExecutionEvent
-	instanceVariableNames:''
+	instanceVariableNames:'thread_id threads'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'GDB-Core-Events'
 !
 
+!GDBExecutionEvent methodsFor:'accessing'!
+
+threads
+    ^ threads
+! !
+
+!GDBExecutionEvent methodsFor:'initialization'!
+
+setThreads: aCollection
+    self assert: threads isNil.
+    threads := aCollection
+
+    "Created: / 08-09-2014 / 22:02:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !GDBExecutionEvent methodsFor:'testing'!
 
 isExecutionEvent
--- a/GDBRunningEvent.st	Mon Sep 08 10:02:31 2014 +0100
+++ b/GDBRunningEvent.st	Mon Sep 08 23:56:17 2014 +0100
@@ -7,8 +7,24 @@
 	category:'GDB-Core-Events'
 !
 
+!GDBRunningEvent class methodsFor:'accessing - GDB value descriptors'!
+
+gdbValueDescriptor
+    ^ (super gdbValueDescriptor)
+        define: #'thread_id' as: String;
+        yourself
+
+    "Created: / 08-09-2014 / 22:00:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !GDBRunningEvent methodsFor:'accessing'!
 
+threadId
+    ^ thread_id
+
+    "Created: / 08-09-2014 / 22:01:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 type
 	^  'running'
 ! !
--- a/GDBStoppedEvent.st	Mon Sep 08 10:02:31 2014 +0100
+++ b/GDBStoppedEvent.st	Mon Sep 08 23:56:17 2014 +0100
@@ -1,14 +1,37 @@
 "{ Package: 'jv:libgdbs' }"
 
 GDBExecutionEvent subclass:#GDBStoppedEvent
-	instanceVariableNames:''
+	instanceVariableNames:'stopped_threads'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'GDB-Core-Events'
 !
 
+!GDBStoppedEvent class methodsFor:'accessing - GDB value descriptors'!
+
+gdbValueDescriptor
+    ^ (super gdbValueDescriptor)
+        define: #'thread_id' as: Integer;
+        define: #'stopped_threads' as: String;
+        yourself
+
+    "Created: / 08-09-2014 / 22:13:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !GDBStoppedEvent methodsFor:'accessing'!
 
+stoppedThreadId
+    ^ thread_id
+
+    "Created: / 08-09-2014 / 22:15:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+stoppedThreadIds
+    ^ stopped_threads
+
+    "Created: / 08-09-2014 / 22:15:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 type
 	^  'stopped'
 ! !