GDBPortlib.st
author Jan Vrany <jan.vrany@labware.com>
Mon, 24 Jul 2023 23:15:14 +0100
changeset 293 d1422e1ee1bd
child 294 7c84fcc868e2
permissions -rw-r--r--
Introduce `GDBPortlib` to facilitate porting to other dialects This commit introduces `GDBPortlib` in order to allow port to other Smalltalk dialects, e.g, Pharo. Dialect specific code should go there. For now, this includes creation of pipes and PTYs and spawning processes. Since now we use `GDBPortlib`s to encapsulate dialect-specific code, (what used to be) `GDBStXSimpleProcess` and `GDBStXUnixProcess` are no longer Smalltalk/X specific. Therefore they have been renamed to `GDBSimpleProcess` and `GDBUnixProcess`
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
293
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
     1
"
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
     2
COPYRIGHT (c) 2023 LabWare
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
     3
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
     4
jv:libgdbs - GNU Debugger Interface Library
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
     5
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
     6
Permission is hereby granted, free of charge, to any person obtaining a copy
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
     7
of this software and associated documentation files (the 'Software'), to deal
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
     8
in the Software without restriction, including without limitation the rights
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
     9
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    10
copies of the Software, and to permit persons to whom the Software is
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    11
furnished to do so, subject to the following conditions:
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    12
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    13
The above copyright notice and this permission notice shall be included in all
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    14
copies or substantial portions of the Software.
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    15
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    16
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    19
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    20
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    21
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    22
SOFTWARE.
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    23
"
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    24
"{ Package: 'jv:libgdbs' }"
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    25
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    26
"{ NameSpace: Smalltalk }"
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    27
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    28
Object subclass:#GDBPortlib
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    29
	instanceVariableNames:''
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    30
	classVariableNames:'Current'
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    31
	poolDictionaries:''
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    32
	category:'GDB-Internal-Portlib'
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    33
!
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    34
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    35
!GDBPortlib class methodsFor:'documentation'!
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    36
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    37
copyright
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    38
"
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    39
COPYRIGHT (c) 2023 LabWare
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    40
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    41
jv:libgdbs - GNU Debugger Interface Library
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    42
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    43
Permission is hereby granted, free of charge, to any person obtaining a copy
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    44
of this software and associated documentation files (the 'Software'), to deal
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    45
in the Software without restriction, including without limitation the rights
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    46
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    47
copies of the Software, and to permit persons to whom the Software is
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    48
furnished to do so, subject to the following conditions:
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    49
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    50
The above copyright notice and this permission notice shall be included in all
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    51
copies or substantial portions of the Software.
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    52
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    53
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    54
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    55
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    56
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    57
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    58
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    59
SOFTWARE.
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    60
"
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    61
! !
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    62
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    63
!GDBPortlib class methodsFor:'instance creation'!
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    64
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    65
new
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    66
    self shouldNotImplement. "Use #current instead"
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    67
! !
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    68
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    69
!GDBPortlib class methodsFor:'accessing'!
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    70
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    71
current
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    72
    Current isNil ifTrue: [ 
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    73
        Current := self basicNew initialize 
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    74
    ].
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    75
    ^ Current
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    76
! !
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    77
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    78
!GDBPortlib methodsFor:'processes'!
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    79
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    80
spawn: argv stdin: stdin stdout: stdout stderr: stderr exit: action 
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    81
    | pid |
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    82
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    83
    OperatingSystem isMSWINDOWSlike ifTrue: [
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    84
        (OperatingSystem getEnvironment: 'HOME') isNil ifTrue: [
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    85
            OperatingSystem setEnvironment: 'HOME' to: Filename homeDirectory pathName
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    86
        ].
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    87
    ].
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    88
    Processor 
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    89
        monitor: [
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    90
            pid := OperatingSystem 
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    91
                    exec: argv first
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    92
                    withArguments: argv
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    93
                    environment: OperatingSystem getEnvironment
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    94
                    fileDescriptors: (Array 
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    95
                            with: stdin fileDescriptor
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    96
                            with: stdout fileDescriptor
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    97
                            with: stderr fileDescriptor)
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    98
                    fork: true
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
    99
                    newPgrp: false
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   100
                    inDirectory: Filename currentDirectory
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   101
                    showWindow: false.
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   102
        ]
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   103
        action: action.
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   104
    ^ pid
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   105
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   106
    "Modified: / 24-07-2023 / 22:58:57 / Jan Vrany <jan.vrany@labware.com>"
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   107
! !
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   108
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   109
!GDBPortlib methodsFor:'streams'!
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   110
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   111
newPTY
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   112
    "Allocate a PTY and return it as an instance of GDBPTY"
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   113
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   114
    | triplet name master slave |    
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   115
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   116
    OperatingSystem isUNIXlike ifTrue:[ 
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   117
        "Use a pseudo-tty"
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   118
        triplet := OperatingSystem makePTY.
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   119
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   120
        name := triplet at:3.
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   121
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   122
        "/ pty at:1 is the master;
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   123
        "/ pty at:2 is the slave
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   124
        master := NonPositionableExternalStream forReadWriteToFileDescriptor:(triplet at:1).
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   125
        master buffered:false.
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   126
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   127
        slave := NonPositionableExternalStream forReadWriteToFileDescriptor:(triplet at:2).
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   128
        slave buffered:false.
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   129
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   130
        ^ GDBPTY name: name master: master slave: slave.
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   131
    ].
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   132
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   133
    OperatingSystem isMSWINDOWSlike ifTrue:[ 
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   134
        ^ self error: 'Windows are not (yet) supported'
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   135
    ].
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   136
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   137
    self error: 'Operating system not supported'
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   138
!
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   139
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   140
newPipe
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   141
    "Create a pipe an return an array with pipe's read end and write end
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   142
     (in this order) as smalltalk streams."
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   143
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   144
    ^ NonPositionableExternalStream makePipe
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   145
! !
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   146