Cache thread status and update it on `=stopped` and `=running` events
authorJan Vrany <jan.vrany@fit.cvut.cz>
Wed, 12 Jul 2017 16:27:29 +0200
changeset 86 7f53d51a0a65
parent 85 6fea1000a2a5
child 87 50e80d25ea6f
Cache thread status and update it on `=stopped` and `=running` events ...rather than asking thread info each time. This saves us the need to issue `-thread-info` each time *some* threas stops/runs.
GDBDebugger.st
GDBThread.st
GDBThreadEvent.st
GDBThreadGroup.st
GDBThreadState.st
GDBThreadStateUnknown.st
Make.proto
Make.spec
abbrev.stc
bc.mak
jv_libgdbs.st
libInit.cc
tests/GDBDebuggerTestsR.st
--- a/GDBDebugger.st	Tue Jul 11 23:37:04 2017 +0200
+++ b/GDBDebugger.st	Wed Jul 12 16:27:29 2017 +0200
@@ -458,10 +458,13 @@
             ].
         ].
     ].
-    aGDBRunningEvent setThreads: threads
+    aGDBRunningEvent setThreads: threads.
+    threads do:[:thread | 
+        thread onRunningEvent: aGDBRunningEvent.
+    ].
 
     "Created: / 07-09-2014 / 23:34:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 18-03-2015 / 13:57:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-07-2017 / 13:48:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 onStoppedEvent: aGDBStoppedEvent
@@ -480,10 +483,13 @@
             ].
         ].
     ].
-    aGDBStoppedEvent setThreads: threads
+    aGDBStoppedEvent setThreads: threads.
+    threads do:[:thread | 
+        thread onStoppedEvent: aGDBStoppedEvent.
+    ].
 
     "Created: / 07-09-2014 / 23:34:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 18-03-2015 / 13:57:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-07-2017 / 13:47:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 onThreadCreatedEvent:aGDBThreadCreatedEvent 
--- a/GDBThread.st	Tue Jul 11 23:37:04 2017 +0200
+++ b/GDBThread.st	Wed Jul 12 16:27:29 2017 +0200
@@ -3,7 +3,7 @@
 "{ NameSpace: Smalltalk }"
 
 GDBDebuggerObject subclass:#GDBThread
-	instanceVariableNames:'id group info stack'
+	instanceVariableNames:'id group status info stack'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'GDB-Core'
@@ -73,9 +73,12 @@
 !
 
 status
-    ^ self info state
+    status isUnknown ifTrue:[ 
+        status := self info state
+    ].
+    ^ status
 
-    "Modified: / 08-03-2015 / 09:10:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-07-2017 / 13:36:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 targetId
@@ -113,6 +116,22 @@
     "Created: / 10-03-2015 / 00:32:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!GDBThread methodsFor:'event handling'!
+
+onRunningEvent: aGDBRunningEvent
+    self assert: (aGDBRunningEvent threads includesIdentical: self).
+    status := GDBThreadStateRunning theOneAndOnlyInstance.
+
+    "Created: / 12-07-2017 / 13:50:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+onStoppedEvent: aGDBStoppedEvent
+    self assert: (aGDBStoppedEvent threads includesIdentical: self).
+    status := GDBThreadStateStopped theOneAndOnlyInstance.
+
+    "Created: / 12-07-2017 / 13:50:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !GDBThread methodsFor:'initialization'!
 
 setGroup: aGDBThreadGroup
@@ -130,6 +149,12 @@
     "Modified: / 08-03-2015 / 09:08:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+setStatus: aGDBThreadState
+    status := aGDBThreadState
+
+    "Created: / 12-07-2017 / 13:43:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 setTerminated
 
     "Created: / 07-09-2014 / 21:37:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
--- a/GDBThreadEvent.st	Tue Jul 11 23:37:04 2017 +0200
+++ b/GDBThreadEvent.st	Wed Jul 12 16:27:29 2017 +0200
@@ -9,6 +9,7 @@
 	category:'GDB-Core-Events'
 !
 
+
 !GDBThreadEvent class methodsFor:'accessing - GDB value descriptors'!
 
 description
@@ -52,3 +53,10 @@
     "Created: / 07-09-2014 / 15:05:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!GDBThreadEvent class methodsFor:'documentation'!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
+! !
+
--- a/GDBThreadGroup.st	Tue Jul 11 23:37:04 2017 +0200
+++ b/GDBThreadGroup.st	Wed Jul 12 16:27:29 2017 +0200
@@ -132,11 +132,11 @@
     | thread |
 
     thread := self threadWithId:aGDBThreadExitedEvent threadId.
-    thread setTerminated.
+    thread setStatus: GDBThreadStateTerminated theOneAndOnlyInstance.
     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>"
+    "Modified: / 12-07-2017 / 13:42:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !GDBThreadGroup methodsFor:'initialization'!
--- a/GDBThreadState.st	Tue Jul 11 23:37:04 2017 +0200
+++ b/GDBThreadState.st	Wed Jul 12 16:27:29 2017 +0200
@@ -83,5 +83,11 @@
     ^ false
 
     "Created: / 07-09-2014 / 23:22:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+isUnknown
+    ^ false
+
+    "Created: / 12-07-2017 / 13:35:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GDBThreadStateUnknown.st	Wed Jul 12 16:27:29 2017 +0200
@@ -0,0 +1,19 @@
+"{ Package: 'jv:libgdbs' }"
+
+"{ NameSpace: Smalltalk }"
+
+GDBThreadState subclass:#GDBThreadStateUnknown
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'GDB-Core'
+!
+
+!GDBThreadStateUnknown methodsFor:'testing'!
+
+isUnknown
+    ^ true
+
+    "Created: / 12-07-2017 / 13:35:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
--- a/Make.proto	Tue Jul 11 23:37:04 2017 +0200
+++ b/Make.proto	Wed Jul 12 16:27:29 2017 +0200
@@ -166,6 +166,7 @@
 $(OUTDIR)GDBThreadStateRunning.$(O) GDBThreadStateRunning.$(C) GDBThreadStateRunning.$(H): GDBThreadStateRunning.st $(INCLUDE_TOP)/jv/libgdbs/GDBThreadState.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)GDBThreadStateStopped.$(O) GDBThreadStateStopped.$(C) GDBThreadStateStopped.$(H): GDBThreadStateStopped.st $(INCLUDE_TOP)/jv/libgdbs/GDBThreadState.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)GDBThreadStateTerminated.$(O) GDBThreadStateTerminated.$(C) GDBThreadStateTerminated.$(H): GDBThreadStateTerminated.st $(INCLUDE_TOP)/jv/libgdbs/GDBThreadState.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
+$(OUTDIR)GDBThreadStateUnknown.$(O) GDBThreadStateUnknown.$(C) GDBThreadStateUnknown.$(H): GDBThreadStateUnknown.st $(INCLUDE_TOP)/jv/libgdbs/GDBThreadState.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)GDBUnixProcess.$(O) GDBUnixProcess.$(C) GDBUnixProcess.$(H): GDBUnixProcess.st $(INCLUDE_TOP)/jv/libgdbs/GDBProcess.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)GDBVariableObject.$(O) GDBVariableObject.$(C) GDBVariableObject.$(H): GDBVariableObject.st $(INCLUDE_TOP)/jv/libgdbs/GDBObject.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
 $(OUTDIR)GDBBreakpoint.$(O) GDBBreakpoint.$(C) GDBBreakpoint.$(H): GDBBreakpoint.st $(INCLUDE_TOP)/jv/libgdbs/GDBDebuggerObject.$(H) $(INCLUDE_TOP)/jv/libgdbs/GDBObject.$(H) $(INCLUDE_TOP)/stx/libbasic/Object.$(H) $(STCHDR)
--- a/Make.spec	Tue Jul 11 23:37:04 2017 +0200
+++ b/Make.spec	Wed Jul 12 16:27:29 2017 +0200
@@ -90,6 +90,7 @@
 	GDBThreadStateRunning \
 	GDBThreadStateStopped \
 	GDBThreadStateTerminated \
+	GDBThreadStateUnknown \
 	GDBUnixProcess \
 	GDBVariableObject \
 	GDBBreakpoint \
@@ -279,6 +280,7 @@
     $(OUTDIR)GDBThreadStateRunning.$(O) \
     $(OUTDIR)GDBThreadStateStopped.$(O) \
     $(OUTDIR)GDBThreadStateTerminated.$(O) \
+    $(OUTDIR)GDBThreadStateUnknown.$(O) \
     $(OUTDIR)GDBUnixProcess.$(O) \
     $(OUTDIR)GDBVariableObject.$(O) \
     $(OUTDIR)GDBBreakpoint.$(O) \
--- a/abbrev.stc	Tue Jul 11 23:37:04 2017 +0200
+++ b/abbrev.stc	Wed Jul 12 16:27:29 2017 +0200
@@ -40,6 +40,7 @@
 GDBThreadStateRunning GDBThreadStateRunning jv:libgdbs 'GDB-Core' 1
 GDBThreadStateStopped GDBThreadStateStopped jv:libgdbs 'GDB-Core' 1
 GDBThreadStateTerminated GDBThreadStateTerminated jv:libgdbs 'GDB-Core' 1
+GDBThreadStateUnknown GDBThreadStateUnknown jv:libgdbs 'GDB-Core' 1
 GDBUnixProcess GDBUnixProcess jv:libgdbs 'GDB-Private' 0
 GDBVariableObject GDBVariableObject jv:libgdbs 'GDB-Private-Model' 0
 GDBBreakpoint GDBBreakpoint jv:libgdbs 'GDB-Core' 0
--- a/bc.mak	Tue Jul 11 23:37:04 2017 +0200
+++ b/bc.mak	Wed Jul 12 16:27:29 2017 +0200
@@ -113,6 +113,7 @@
 $(OUTDIR)GDBThreadStateRunning.$(O) GDBThreadStateRunning.$(C) GDBThreadStateRunning.$(H): GDBThreadStateRunning.st $(INCLUDE_TOP)\jv\libgdbs\GDBThreadState.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)GDBThreadStateStopped.$(O) GDBThreadStateStopped.$(C) GDBThreadStateStopped.$(H): GDBThreadStateStopped.st $(INCLUDE_TOP)\jv\libgdbs\GDBThreadState.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)GDBThreadStateTerminated.$(O) GDBThreadStateTerminated.$(C) GDBThreadStateTerminated.$(H): GDBThreadStateTerminated.st $(INCLUDE_TOP)\jv\libgdbs\GDBThreadState.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
+$(OUTDIR)GDBThreadStateUnknown.$(O) GDBThreadStateUnknown.$(C) GDBThreadStateUnknown.$(H): GDBThreadStateUnknown.st $(INCLUDE_TOP)\jv\libgdbs\GDBThreadState.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)GDBUnixProcess.$(O) GDBUnixProcess.$(C) GDBUnixProcess.$(H): GDBUnixProcess.st $(INCLUDE_TOP)\jv\libgdbs\GDBProcess.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)GDBVariableObject.$(O) GDBVariableObject.$(C) GDBVariableObject.$(H): GDBVariableObject.st $(INCLUDE_TOP)\jv\libgdbs\GDBObject.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
 $(OUTDIR)GDBBreakpoint.$(O) GDBBreakpoint.$(C) GDBBreakpoint.$(H): GDBBreakpoint.st $(INCLUDE_TOP)\jv\libgdbs\GDBDebuggerObject.$(H) $(INCLUDE_TOP)\jv\libgdbs\GDBObject.$(H) $(INCLUDE_TOP)\stx\libbasic\Object.$(H) $(STCHDR)
--- a/jv_libgdbs.st	Tue Jul 11 23:37:04 2017 +0200
+++ b/jv_libgdbs.st	Wed Jul 12 16:27:29 2017 +0200
@@ -115,6 +115,7 @@
         GDBThreadStateRunning
         GDBThreadStateStopped
         GDBThreadStateTerminated
+        GDBThreadStateUnknown
         GDBUnixProcess
         GDBVariableObject
         GDBBreakpoint
--- a/libInit.cc	Tue Jul 11 23:37:04 2017 +0200
+++ b/libInit.cc	Wed Jul 12 16:27:29 2017 +0200
@@ -55,6 +55,7 @@
 extern void _GDBThreadStateRunning_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
 extern void _GDBThreadStateStopped_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
 extern void _GDBThreadStateTerminated_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
+extern void _GDBThreadStateUnknown_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
 extern void _GDBUnixProcess_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
 extern void _GDBVariableObject_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
 extern void _GDBBreakpoint_Init(int pass, struct __vmData__ *__pRT__, OBJ snd);
@@ -253,6 +254,7 @@
     _GDBThreadStateRunning_Init(pass,__pRT__,snd);
     _GDBThreadStateStopped_Init(pass,__pRT__,snd);
     _GDBThreadStateTerminated_Init(pass,__pRT__,snd);
+    _GDBThreadStateUnknown_Init(pass,__pRT__,snd);
     _GDBUnixProcess_Init(pass,__pRT__,snd);
     _GDBVariableObject_Init(pass,__pRT__,snd);
     _GDBBreakpoint_Init(pass,__pRT__,snd);
--- a/tests/GDBDebuggerTestsR.st	Tue Jul 11 23:37:04 2017 +0200
+++ b/tests/GDBDebuggerTestsR.st	Wed Jul 12 16:27:29 2017 +0200
@@ -53,6 +53,7 @@
     self assert: inferior1 threads size == 1.
     thread1 := inferior1 threads anElement.
     self assert: thread1 stack size == 2.
+    self assert: thread1 status isStopped.
     frame1 := thread1 stack first.
     frame2 := thread1 stack second.
     self assert: frame1 variables size == 1.
@@ -74,7 +75,7 @@
     debugger send: 'quit' andWait: false.
 
     "Created: / 28-02-2015 / 00:55:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 01-06-2017 / 21:44:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-07-2017 / 13:55:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 test_03