Remove threads from thread group when threadgroup terminates.
authorJan Vrany <jan.vrany@fit.cvut.cz>
Mon, 22 Sep 2014 09:59:28 +0100
changeset 43 22236b6d1d9a
parent 42 499dc5d38707
child 44 e78460ac5d58
Remove threads from thread group when threadgroup terminates.
GDBFrame.st
GDBThread.st
GDBThreadGroup.st
GDBThreadGroupAddedEvent.st
GDBThreadStatusRunning.st
GDBThreadStatusStopped.st
GDBThreadStatusTerminated.st
libgdbs.rc
tests/tests.rc
--- a/GDBFrame.st	Thu Sep 18 23:09:57 2014 +0100
+++ b/GDBFrame.st	Mon Sep 22 09:59:28 2014 +0100
@@ -1,7 +1,7 @@
 "{ Package: 'jv:libgdbs' }"
 
 GDBDebuggerObject subclass:#GDBFrame
-	instanceVariableNames:'level addr func file fullname line from'
+	instanceVariableNames:'thread level addr func file fullname line from'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'GDB-Core'
@@ -51,6 +51,10 @@
 
 line
     ^ line
+!
+
+thread
+    ^ thread
 ! !
 
 !GDBFrame methodsFor:'printing & storing'!
--- a/GDBThread.st	Thu Sep 18 23:09:57 2014 +0100
+++ b/GDBThread.st	Mon Sep 22 09:59:28 2014 +0100
@@ -31,6 +31,10 @@
 
 !GDBThread methodsFor:'accessing'!
 
+group
+    ^ group
+!
+
 id
     ^ id
 
@@ -41,17 +45,20 @@
     self ensureIsStopped.
     stack isNil ifTrue:[
         stack := GDBTransientDataHolder debugger: debugger factory:[ 
-            | result depth |
+            | result depth frames |
             result := debugger send: (GDBMI_stack_info_depth new arguments: { '--thread' . id . 100 }).
             depth := result propertyAt: #depth.
             result := debugger send: (GDBMI_stack_list_frames new arguments: { '--thread' . id . 0 . depth - 1 }).
-            result propertyAt: #stack.
+            frames := result propertyAt: #stack.
+            frames do:[:each | each propertyAt: #thread put: self ].
+            frames
+
         ].
     ].
     ^ stack value
 
     "Created: / 09-09-2014 / 00:02:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 17-09-2014 / 22:12:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 22-09-2014 / 00:19:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 status
@@ -93,6 +100,22 @@
     "Modified: / 07-09-2014 / 23:21:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!GDBThread methodsFor:'printing & storing'!
+
+printOn:aStream
+    "append a printed representation if the receiver to the argument, aStream"
+
+    aStream nextPutAll:'thread  '.
+    id printOn:aStream.
+"/    aStream nextPutAll:'in group '.
+"/    group id printOn:aStream.
+    aStream nextPutAll:' ['.
+    status printOn:aStream.
+    aStream nextPutAll:']'.
+
+    "Modified: / 22-09-2014 / 00:59:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !GDBThread methodsFor:'private'!
 
 ensureIsStopped
@@ -109,6 +132,12 @@
 
 !GDBThread methodsFor:'testing'!
 
+isDead
+    ^ status isTerminated
+
+    "Created: / 22-09-2014 / 00:54:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 isRunning
     ^ status isRunning
 
--- a/GDBThreadGroup.st	Thu Sep 18 23:09:57 2014 +0100
+++ b/GDBThreadGroup.st	Mon Sep 22 09:59:28 2014 +0100
@@ -43,11 +43,12 @@
 !
 
 threadWithId: tid
-    ^ threads ? #() detect:[:e | e id = tid ] ifNone:[
+    ^ threads ? #() detect:[:e | e isDead not and:[ e id = tid ] ] ifNone:[
         self error: ('No thread with id ''%1'' found!!' bindWith: tid)        
     ].
 
     "Created: / 07-09-2014 / 21:37:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 22-09-2014 / 01:23:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 threads
@@ -83,17 +84,20 @@
 
     thread := self threadWithId:aGDBThreadExitedEvent threadId.
     thread setTerminated.
-    aGDBThreadExitedEvent setThread:thread
+    aGDBThreadExitedEvent setThread:thread.
 
     "Created: / 07-09-2014 / 21:25:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 22-09-2014 / 00:50:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !GDBThreadGroup methodsFor:'initialization'!
 
 setExitCode: anInteger
     exit_code := anInteger.
+    threads removeAll
 
     "Created: / 06-09-2014 / 02:33:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 22-09-2014 / 01:23:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 setId: aString
@@ -110,6 +114,19 @@
     "Modified: / 07-09-2014 / 12:34:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!GDBThreadGroup methodsFor:'printing & storing'!
+
+printOn:aStream
+    "append a printed representation if the receiver to the argument, aStream"
+
+    aStream nextPutAll:'thread group '.
+    id printOn:aStream.
+    aStream nextPutAll:' pid '.
+    pid printOn:aStream.
+
+    "Modified: / 22-09-2014 / 01:00:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !GDBThreadGroup methodsFor:'private'!
 
 threadAdd: aGDBThread
--- a/GDBThreadGroupAddedEvent.st	Thu Sep 18 23:09:57 2014 +0100
+++ b/GDBThreadGroupAddedEvent.st	Mon Sep 22 09:59:28 2014 +0100
@@ -7,9 +7,17 @@
 	category:'GDB-Core-Events'
 !
 
+
 !GDBThreadGroupAddedEvent methodsFor:'accessing'!
 
 type
 	^  'thread-group-added'
 ! !
 
+!GDBThreadGroupAddedEvent class methodsFor:'documentation'!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
+! !
+
--- a/GDBThreadStatusRunning.st	Thu Sep 18 23:09:57 2014 +0100
+++ b/GDBThreadStatusRunning.st	Mon Sep 22 09:59:28 2014 +0100
@@ -41,6 +41,16 @@
     ^ theOneAndOnlyInstance.
 ! !
 
+!GDBThreadStatusRunning methodsFor:'printing & storing'!
+
+printOn:aStream
+    "append a printed representation if the receiver to the argument, aStream"
+
+    aStream nextPutAll: 'running'
+
+    "Modified: / 22-09-2014 / 00:58:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !GDBThreadStatusRunning methodsFor:'testing'!
 
 isRunning
--- a/GDBThreadStatusStopped.st	Thu Sep 18 23:09:57 2014 +0100
+++ b/GDBThreadStatusStopped.st	Mon Sep 22 09:59:28 2014 +0100
@@ -7,6 +7,16 @@
 	category:'GDB-Core'
 !
 
+!GDBThreadStatusStopped methodsFor:'printing & storing'!
+
+printOn:aStream
+    "append a printed representation if the receiver to the argument, aStream"
+
+    aStream nextPutAll: 'stopped'
+
+    "Modified: / 22-09-2014 / 00:58:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !GDBThreadStatusStopped methodsFor:'testing'!
 
 isStopped
--- a/GDBThreadStatusTerminated.st	Thu Sep 18 23:09:57 2014 +0100
+++ b/GDBThreadStatusTerminated.st	Mon Sep 22 09:59:28 2014 +0100
@@ -41,6 +41,16 @@
     ^ theOneAndOnlyInstance.
 ! !
 
+!GDBThreadStatusTerminated methodsFor:'printing & storing'!
+
+printOn:aStream
+    "append a printed representation if the receiver to the argument, aStream"
+
+    aStream nextPutAll: 'dead'
+
+    "Modified: / 22-09-2014 / 00:58:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !GDBThreadStatusTerminated methodsFor:'testing'!
 
 isTerminated
--- a/libgdbs.rc	Thu Sep 18 23:09:57 2014 +0100
+++ b/libgdbs.rc	Mon Sep 22 09:59:28 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", "Thu, 18 Sep 2014 08:28:22 GMT\0"
+      VALUE "ProductDate", "Mon, 22 Sep 2014 08:58:09 GMT\0"
     END
 
   END
--- a/tests/tests.rc	Thu Sep 18 23:09:57 2014 +0100
+++ b/tests/tests.rc	Mon Sep 22 09:59:28 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", "Thu, 18 Sep 2014 08:28:24 GMT\0"
+      VALUE "ProductDate", "Mon, 22 Sep 2014 08:58:11 GMT\0"
     END
 
   END