GDBStXSimpleProcess.st
changeset 164 a16705f64a64
parent 163 f882d9048b54
child 185 4e1be69b39ce
--- a/GDBStXSimpleProcess.st	Wed Dec 12 16:32:44 2018 +0000
+++ b/GDBStXSimpleProcess.st	Thu Dec 13 14:53:48 2018 +0000
@@ -191,6 +191,62 @@
     "Modified: / 21-10-2018 / 08:06:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+initializeWithCommand: command
+    | inputPipe  input  outputPipe  output errorPipe error argv |
+
+    argv := (self command2argv: command) ,
+            ((Array new: 6)
+             at: 1 put: '-q';
+             at: 2 put: '-nx';
+             at: 3 put: '--interpreter';
+             at: 4 put: 'mi2';
+             at: 5 put: '-ex';
+             at: 6 put: 'set new-console on';
+             yourself).
+
+    inputPipe := NonPositionableExternalStream makePipe.
+    input := inputPipe second.
+    outputPipe := NonPositionableExternalStream makePipe.
+    output := outputPipe first.
+    errorPipe := NonPositionableExternalStream makePipe.
+    error := outputPipe first.
+    
+
+    Processor 
+        monitor:[
+            pid := OperatingSystem 
+                    exec:argv first
+                    withArguments:argv
+                    environment:OperatingSystem getEnvironment
+                    fileDescriptors: (Array
+                            with: inputPipe first fileDescriptor
+                            with: outputPipe second fileDescriptor
+                            with: errorPipe second fileDescriptor
+                        )
+                    fork:true
+                    newPgrp:false
+                    inDirectory:Filename currentDirectory
+                    showWindow: false.      
+            debuggerInput := input.
+            debuggerOutput := output.
+            debuggerError := error.
+            pid.
+        ]
+        action:[:stat | self exited:stat. ].
+    inputPipe first close.
+    outputPipe second close.
+    errorPipe second close.
+    pid isNil ifTrue:[
+        input close.
+        output close.
+        error close.
+        self error:'Failed to launch gdb'.
+    ].
+
+    "Created: / 12-12-2018 / 20:13:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 17-12-2018 / 10:51:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 release
     pid := connection := nil.
     debuggerInput notNil ifTrue:[ debuggerInput close ].