Report gdb's exist status in `GDBExitEvent` in case `gdb` terminates prematurely
authorJan Vrany <jan.vrany@fit.cvut.cz>
Sun, 04 Feb 2018 21:18:15 +0000
changeset 105 1d4ca4370d05
parent 104 4add55336dfe
child 106 12c96f17fc53
Report gdb's exist status in `GDBExitEvent` in case `gdb` terminates prematurely ...for exampple, ig GDB segfaults due to a bug. Yes, that may happen, bugs are even in debuggers.
GDBConnection.st
GDBDebugger.st
GDBExitEvent.st
GDBVariableObjectExecutor.st
--- a/GDBConnection.st	Sat Feb 03 22:37:17 2018 +0000
+++ b/GDBConnection.st	Sun Feb 04 21:18:15 2018 +0000
@@ -319,6 +319,7 @@
     ].
 
     "Created: / 02-06-2014 / 22:49:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 04-02-2018 / 10:28:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 pushEventSet: aGDBEventSet
@@ -330,7 +331,7 @@
     ].
 
     "Created: / 02-06-2014 / 22:42:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 18-09-2014 / 22:50:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 04-02-2018 / 10:28:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !GDBConnection methodsFor:'initialize & release'!
@@ -369,9 +370,12 @@
 !
 
 released: status
-    self pushEvent: GDBExitEvent new.  
+    self pushEvent: (GDBExitEvent new setStatus: status; yourself).  
+    status success ifFalse:[ 
+        Logger log: ('gdb process: exited with status %1 code %2' bindWith: status status with: status code)  severity: #error facility: 'GDB'.
+    ].
     TraceProcesses ifTrue:[ 
-        Logger log: ('gdb process: exited with status %1' bindWith: status code)  severity: #trace facility: 'GDB'.
+        Logger log: ('gdb process: exited') severity: #trace facility: 'GDB'.
         Logger log: 'gdb process: waiting for event pump to finish' severity: #trace facility: 'GDB'.
     ].
     self eventPumpStop.
@@ -380,7 +384,7 @@
     inferiorPTY release.
 
     "Created: / 26-05-2014 / 21:31:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 01-06-2017 / 22:24:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 04-02-2018 / 20:29:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !GDBConnection class methodsFor:'documentation'!
--- a/GDBDebugger.st	Sat Feb 03 22:37:17 2018 +0000
+++ b/GDBDebugger.st	Sun Feb 04 21:18:15 2018 +0000
@@ -203,6 +203,7 @@
     
     | blocker result |
 
+    self assert: self isConnected.
     ^ wait ifTrue:[
         blocker := Semaphore new.
         self send: command andWithResultDo: [ :r | 
@@ -227,7 +228,7 @@
     ]
 
     "Created: / 02-06-2014 / 23:45:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 26-01-2018 / 21:52:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 04-02-2018 / 00:21:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 send:command andWaitFor:eventHandlers
@@ -274,6 +275,7 @@
     
     | commandObject |
 
+    self assert: self isConnected.
     command isString ifTrue:[
         commandObject := (GDBMIParser on:command) parseCommand.
         commandObject token:self nextCommandSequnceNumber.
@@ -289,7 +291,7 @@
         withTimeoutMs: timeout
 
     "Created: / 07-03-2015 / 11:38:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 08-03-2015 / 07:31:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (format): / 04-02-2018 / 00:20:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 send:command andWithResultDo: block
@@ -315,6 +317,7 @@
     
     | cmd  token handler1  handler2  result |
 
+    self assert: self isConnected.
     cmd := command.
     cmd isString ifTrue:[
         cmd := GDBCLICommand new value:cmd.
@@ -340,6 +343,7 @@
     ^ nil
 
     "Created: / 26-01-2018 / 21:47:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (format): / 04-02-2018 / 00:20:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !GDBDebugger methodsFor:'commands - API'!
--- a/GDBExitEvent.st	Sat Feb 03 22:37:17 2018 +0000
+++ b/GDBExitEvent.st	Sun Feb 04 21:18:15 2018 +0000
@@ -21,7 +21,7 @@
 "{ NameSpace: Smalltalk }"
 
 GDBInternalEvent subclass:#GDBExitEvent
-	instanceVariableNames:''
+	instanceVariableNames:'status'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'GDB-Core-Events'
@@ -50,3 +50,21 @@
 "
 ! !
 
+!GDBExitEvent methodsFor:'accessing'!
+
+status
+    "Return the GDB process exit status (if known)"
+
+    ^ status
+
+    "Modified (comment): / 04-02-2018 / 20:24:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!GDBExitEvent methodsFor:'initialization'!
+
+setStatus: anOSProcessStatus
+    status := anOSProcessStatus
+
+    "Created: / 04-02-2018 / 20:22:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
--- a/GDBVariableObjectExecutor.st	Sat Feb 03 22:37:17 2018 +0000
+++ b/GDBVariableObjectExecutor.st	Sun Feb 04 21:18:15 2018 +0000
@@ -53,9 +53,12 @@
 !GDBVariableObjectExecutor methodsFor:'finalization'!
 
 finalize
-    debugger send: (GDBMI_var_delete arguments: (Array with: '-c' with: name))
+    debugger isConnected ifTrue:[
+        debugger send: (GDBMI_var_delete arguments: (Array with: '-c' with: name))
+    ].
 
     "Created: / 28-01-2018 / 23:26:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 03-02-2018 / 23:31:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !GDBVariableObjectExecutor methodsFor:'initialization'!
@@ -66,3 +69,10 @@
     "Created: / 28-01-2018 / 23:25:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!GDBVariableObjectExecutor class methodsFor:'documentation'!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
+! !
+