GDBPortlib.st
author Jan Vrany <jan.vrany@labware.com>
Fri, 18 Aug 2023 14:25:54 +0100
changeset 302 fdfe1a981363
parent 295 4e7365cece13
child 309 f2481d09d58e
permissions -rw-r--r--
Compatibility: allow ports to customize semaphore / mutex creation This commit adds new port methods: `#newSemaphore` and `#newMutex`. This allows ports to return customized objects. This is needed to accomodate different implementations / behaviors of semaphores among dialects (e.g, Pharo)
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
294
7c84fcc868e2 Compatiblity: refactor `GDBPTY` to allow separate stream objects for reading and writing
Jan Vrany <jan.vrany@labware.com>
parents: 293
diff changeset
   130
        ^ GDBPTY name: name masterReadStream: master masterWriteStream: master slaveReadStream: slave slaveWriteStream: slave.
293
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'
294
7c84fcc868e2 Compatiblity: refactor `GDBPTY` to allow separate stream objects for reading and writing
Jan Vrany <jan.vrany@labware.com>
parents: 293
diff changeset
   138
7c84fcc868e2 Compatiblity: refactor `GDBPTY` to allow separate stream objects for reading and writing
Jan Vrany <jan.vrany@labware.com>
parents: 293
diff changeset
   139
    "Modified: / 02-08-2023 / 13:11:19 / Jan Vrany <jan.vrany@labware.com>"
293
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   140
!
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   141
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   142
newPipe
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   143
    "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
   144
     (in this order) as smalltalk streams."
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
    ^ NonPositionableExternalStream makePipe
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   147
! !
d1422e1ee1bd Introduce `GDBPortlib` to facilitate porting to other dialects
Jan Vrany <jan.vrany@labware.com>
parents:
diff changeset
   148
302
fdfe1a981363 Compatibility: allow ports to customize semaphore / mutex creation
Jan Vrany <jan.vrany@labware.com>
parents: 295
diff changeset
   149
!GDBPortlib methodsFor:'synchronization'!
fdfe1a981363 Compatibility: allow ports to customize semaphore / mutex creation
Jan Vrany <jan.vrany@labware.com>
parents: 295
diff changeset
   150
fdfe1a981363 Compatibility: allow ports to customize semaphore / mutex creation
Jan Vrany <jan.vrany@labware.com>
parents: 295
diff changeset
   151
newMutex
fdfe1a981363 Compatibility: allow ports to customize semaphore / mutex creation
Jan Vrany <jan.vrany@labware.com>
parents: 295
diff changeset
   152
    ^ Semaphore forMutualExclusion
fdfe1a981363 Compatibility: allow ports to customize semaphore / mutex creation
Jan Vrany <jan.vrany@labware.com>
parents: 295
diff changeset
   153
fdfe1a981363 Compatibility: allow ports to customize semaphore / mutex creation
Jan Vrany <jan.vrany@labware.com>
parents: 295
diff changeset
   154
    "Created: / 18-08-2023 / 14:17:36 / Jan Vrany <jan.vrany@labware.com>"
fdfe1a981363 Compatibility: allow ports to customize semaphore / mutex creation
Jan Vrany <jan.vrany@labware.com>
parents: 295
diff changeset
   155
!
fdfe1a981363 Compatibility: allow ports to customize semaphore / mutex creation
Jan Vrany <jan.vrany@labware.com>
parents: 295
diff changeset
   156
fdfe1a981363 Compatibility: allow ports to customize semaphore / mutex creation
Jan Vrany <jan.vrany@labware.com>
parents: 295
diff changeset
   157
newSemaphore
fdfe1a981363 Compatibility: allow ports to customize semaphore / mutex creation
Jan Vrany <jan.vrany@labware.com>
parents: 295
diff changeset
   158
    ^ Semaphore new
fdfe1a981363 Compatibility: allow ports to customize semaphore / mutex creation
Jan Vrany <jan.vrany@labware.com>
parents: 295
diff changeset
   159
fdfe1a981363 Compatibility: allow ports to customize semaphore / mutex creation
Jan Vrany <jan.vrany@labware.com>
parents: 295
diff changeset
   160
    "Created: / 18-08-2023 / 14:16:31 / Jan Vrany <jan.vrany@labware.com>"
fdfe1a981363 Compatibility: allow ports to customize semaphore / mutex creation
Jan Vrany <jan.vrany@labware.com>
parents: 295
diff changeset
   161
! !
fdfe1a981363 Compatibility: allow ports to customize semaphore / mutex creation
Jan Vrany <jan.vrany@labware.com>
parents: 295
diff changeset
   162
295
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   163
!GDBPortlib methodsFor:'user interface'!
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   164
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   165
newCLI: aGDBDebugger
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   166
    "Open GDB CLI for interactive debugging for given debugger.
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   167
     See `GDBDebugger >> #cli`."
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   168
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   169
    | app |
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   170
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   171
    (Smalltalk at: #VDBDebuggerApplication) isNil ifTrue: [ 
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   172
        PackageNotFoundError ignoreIn: [Smalltalk loadPackage: 'jv:vdb'].
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   173
    ].
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   174
    (Smalltalk at: #VDBDebuggerApplication) isNil ifTrue: [ 
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   175
        self error: 'Failed to load package ''jv:vdb'''
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   176
    ].
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   177
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   178
    app := aGDBDebugger propertyAt: #cli.
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   179
    app isNil ifTrue: [
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   180
        app := (Smalltalk at: #VDBDebuggerApplication) new.
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   181
        app debugger: aGDBDebugger.
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   182
        app layout: #layoutSingleSpec.
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   183
        app open.
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   184
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   185
        aGDBDebugger propertyAt: #cli put: app.
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   186
    ] ifFalse: [ 
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   187
        app window raise.
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   188
    ].
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   189
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   190
    "Created: / 05-08-2023 / 07:38:23 / Jan Vrany <jan.vrany@labware.com>"
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   191
! !
4e7365cece13 Add utility method `GDBDebugger >> #cli:`
Jan Vrany <jan.vrany@labware.com>
parents: 294
diff changeset
   192