--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/GDBStXWindowsProcess.st Sat Oct 20 07:48:11 2018 +0100
@@ -0,0 +1,202 @@
+"
+jv:libgdbs - GNU Debugger Interface Library
+Copyright (C) 2015-now Jan Vrany
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+"
+"{ Package: 'jv:libgdbs' }"
+
+"{ NameSpace: Smalltalk }"
+
+GDBLocalProcess subclass:#GDBStXWindowsProcess
+ instanceVariableNames:'debuggerError errorPumpProcess'
+ classVariableNames:''
+ poolDictionaries:'GDBDebugFlags'
+ category:'GDB-Private'
+!
+
+!GDBStXWindowsProcess class methodsFor:'documentation'!
+
+copyright
+"
+jv:libgdbs - GNU Debugger Interface Library
+Copyright (C) 2015-now Jan Vrany
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+"
+!
+
+documentation
+"
+ documentation to be added.
+
+ [author:]
+ Jan Vrany <jan.vrany@fit.cvut.cz>
+
+ [instance variables:]
+
+ [class variables:]
+
+ [see also:]
+
+"
+! !
+
+!GDBStXWindowsProcess methodsFor:'error pump'!
+
+errorPumpLoop
+ [ debuggerError atEnd ] whileFalse:[
+ debuggerError readWait.
+ debuggerError atEnd ifFalse:[
+ | line |
+
+ line := debuggerError nextLine.
+ line notNil ifTrue:[
+ Logger log: line severity: #error facility: 'GDB'
+ ].
+ ].
+ ]
+
+ "Created: / 15-01-2018 / 09:31:39 / jv"
+!
+
+errorPumpStart
+ errorPumpProcess isNil ifTrue:[
+ errorPumpProcess := [
+ TraceEvents ifTrue:[
+ Logger log: 'error pump: starting' severity: #trace facility: 'GDB'
+ ].
+ self errorPumpLoop
+ ] newProcess.
+ errorPumpProcess name:('GDB Error pump (%1)' bindWith: self id).
+ errorPumpProcess priority:Processor userBackgroundPriority.
+ errorPumpProcess addExitAction:[
+ TraceEvents ifTrue:[
+ Logger log: 'error pump: terminated' severity: #trace facility: 'GDB'
+ ].
+ errorPumpProcess := nil.
+ ].
+ errorPumpProcess resume.
+ ].
+
+ "Created: / 15-01-2018 / 09:28:06 / jv"
+ "Modified: / 20-10-2018 / 06:53:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+errortPumpStop
+ | t |
+
+ t := errorPumpProcess.
+ (t notNil and:[ t isDead not]) ifTrue:[
+ errorPumpProcess := nil.
+ t terminate.
+ "/ raise its prio to make it terminate quickly
+ t priority:(Processor userSchedulingPriority + 1)
+ ].
+
+ "Created: / 15-01-2018 / 09:29:49 / jv"
+! !
+
+!GDBStXWindowsProcess methodsFor:'initialization & release'!
+
+initialize
+ | exe inputPipe input outputPipe output errorPipe error args |
+
+ exe := self class gdbExecutable.
+ (exe isNil or:[ exe asFilename isExecutable not ]) ifTrue:[
+ GDBError raiseErrorString: 'Could not find gdb, please set path to gdb using GDBProcess class >> gdbExecutable:'.
+ ^ self.
+ ].
+
+ inputPipe := NonPositionableExternalStream makePipe.
+ input := inputPipe second.
+ outputPipe := NonPositionableExternalStream makePipe.
+ output := outputPipe first.
+ errorPipe := NonPositionableExternalStream makePipe.
+ error := outputPipe first.
+
+ args := (Array new: 7)
+ at: 1 put: exe;
+ at: 2 put: '-q';
+ at: 3 put: '-nx';
+ at: 4 put: '--interpreter';
+ at: 5 put: 'mi2';
+ at: 6 put: '-ex';
+ at: 7 put: 'set new-console on';
+ yourself.
+ Processor
+ monitor:[
+ pid := OperatingSystem
+ exec:args first
+ withArguments:args
+ 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-2017 / 21:04:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 15-01-2018 / 09:35:03 / jv"
+ "Modified: / 03-10-2018 / 22:22:02 / 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>"
+! !
+
+!GDBStXWindowsProcess class methodsFor:'documentation'!
+
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
+! !
+