Fix synchronization issue in `GDBThreadGroup >> onThreadSelectedEvent:`
authorJan Vrany <jan.vrany@fit.cvut.cz>
Wed, 16 Jan 2019 23:42:24 +0000
changeset 168 822cd61a882e
parent 167 6da3d808c7cc
child 169 a3d1f59e3bfd
Fix synchronization issue in `GDBThreadGroup >> onThreadSelectedEvent:` ...which may be invoked when thread is actually still / already running. This check is bit ugly and strictly speaking not correct (meaning race-free). For now, it would do. We need to think on how to deal with that better on a general level.
GDBThreadGroup.st
--- a/GDBThreadGroup.st	Wed Jan 16 23:38:20 2019 +0000
+++ b/GDBThreadGroup.st	Wed Jan 16 23:42:24 2019 +0000
@@ -211,14 +211,17 @@
 !
 
 onThreadSelectedEvent: aGDBThreadSelectedEvent
-    | thread |
+    | thread frame |
 
     thread := self threadWithId:aGDBThreadSelectedEvent threadId.
-    aGDBThreadSelectedEvent 
-        setThread: thread;
-        setFrame: (thread stack at: (aGDBThreadSelectedEvent frame level + 1))
+    aGDBThreadSelectedEvent setThread: thread.
+    "/ Be carefull, thread may be rinning!!
+    (thread isStopped and:[(frame := aGDBThreadSelectedEvent frame) notNil]) ifTrue:[ 
+        aGDBThreadSelectedEvent setFrame: (thread stack at: (frame level + 1))
+    ].
 
     "Created: / 29-07-2018 / 22:21:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 16-01-2019 / 23:25:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !GDBThreadGroup methodsFor:'initialization'!