GDBProcess.st
changeset 95 f417138e9c48
parent 93 b1715ebf8df1
child 116 ffd185f7a357
--- a/GDBProcess.st	Mon Jan 08 19:43:49 2018 +0000
+++ b/GDBProcess.st	Thu Jan 11 23:53:06 2018 +0000
@@ -53,12 +53,16 @@
 !GDBProcess class methodsFor:'instance creation'!
 
 new
-    | class |
+    OperatingSystem isUNIXlike ifTrue:[ ^ GDBUnixProcess basicNew initialize].
+    OperatingSystem isMSWINDOWSlike ifTrue:[ ^ GDBWindowsProcess basicNew initialize].
+    GDBError raiseErrorString: 'Unssuported operating system'.
 
-    class := OperatingSystem isUNIXlike"false" ifTrue:[ GDBUnixProcess ] ifFalse: [ self ].
-    ^ class basicNew initialize.
+    "
+    GDBProcess new release.
+    "
 
     "Modified: / 16-12-2017 / 00:10:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 11-01-2018 / 23:02:11 / jv"
 ! !
 
 !GDBProcess class methodsFor:'accessing'!
@@ -128,67 +132,19 @@
 !GDBProcess methodsFor:'initialization & release'!
 
 initialize
-    | inputPipe  input  outputPipe  output  args |
-
-    inputPipe := NonPositionableExternalStream makePipe.
-    input := inputPipe second.
-    outputPipe := NonPositionableExternalStream makePipe.
-    output := outputPipe first.
-    args := (Array new:5)
-             at: 1 put: GDBExecutable ? '/usr/bin/gdb';
-             at: 2 put: '-q';
-             at: 3 put: '-nx';
-             at: 4 put: '--interpreter';
-             at: 5 put: 'mi2';
-             yourself.
+    "raise an error: must be redefined in concrete subclass(es)"
 
-    Processor 
-        monitor:[
-            pid := OperatingSystem 
-                    exec:args first
-                    withArguments:args
-                    environment:OperatingSystem getEnvironment
-                    fileDescriptors: (Array
-                            with: inputPipe first fileDescriptor
-                            with: outputPipe second fileDescriptor
-                            with: outputPipe second fileDescriptor
-                        )
-                    fork:true
-                    newPgrp:false
-                    inDirectory:Filename currentDirectory
-                    showWindow: false.      
-            debuggerInput := input.
-            debuggerOutput := output.
-            pid.
-        ]
-        action:[:stat | self exited:stat. ].
-    inputPipe first close.
-    outputPipe second close.
-    pid isNil ifTrue:[
-        input close.
-        output close.
-        self error:'Failed to launch gdb'.
-    ].
-
-    "Created: / 12-12-2017 / 21:04:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
-release
-    pid := connection := nil.
-    debuggerInput notNil ifTrue:[ debuggerInput close ].
-    debuggerOutput notNil ifTrue:[ debuggerOutput close ].
-
-    "Created: / 20-06-2014 / 21:35:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 15-12-2017 / 23:59:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    ^ self subclassResponsibility
 ! !
 
 !GDBProcess methodsFor:'private'!
 
 exited: status
+    pid := nil.
     connection released: status
 
     "Created: / 20-06-2014 / 21:35:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 31-05-2017 / 21:48:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 12-01-2018 / 21:50:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !GDBProcess class methodsFor:'documentation'!