GDBPTY.st
author Jan Vrany <jan.vrany@labware.com>
Fri, 08 Sep 2023 12:40:22 +0100
changeset 317 7f63737e0374
parent 294 7c84fcc868e2
permissions -rw-r--r--
Fix `GDBMIDebugger` after rename of `GDBStXUnixProcess` to `GDBUnixProcess` ...in commit d1422e1ee.

"
jv:libgdbs - GNU Debugger Interface Library
Copyright (C) 2015-now Jan Vrany
Copyright (C) 2022-2023 LabWare

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"
"{ Package: 'jv:libgdbs' }"

"{ NameSpace: Smalltalk }"

Object subclass:#GDBPTY
	instanceVariableNames:'name masterReadStream masterWriteStream slaveReadStream
		slaveWriteStream'
	classVariableNames:''
	poolDictionaries:'TTYConstants'
	category:'GDB-Internal'
!

!GDBPTY class methodsFor:'documentation'!

copyright
"
jv:libgdbs - GNU Debugger Interface Library
Copyright (C) 2015-now Jan Vrany
Copyright (C) 2022-2023 LabWare

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"
! !

!GDBPTY class methodsFor:'instance creation'!

name: name masterReadStream: masterRS masterWriteStream: masterWS slaveReadStream: slaveRS slaveWriteStream: slaveWS
    ^ self basicNew initializeWithName: name masterReadStream: masterRS masterWriteStream: masterWS slaveReadStream: slaveRS slaveWriteStream: slaveWS

    "Created: / 02-08-2023 / 13:10:57 / Jan Vrany <jan.vrany@labware.com>"
!

new
    self shouldNotImplement. "Use `GDBPortlib current newPTY`"

    "Modified: / 11-01-2018 / 22:59:14 / jv"
    "Modified: / 24-07-2023 / 22:43:06 / Jan Vrany <jan.vrany@labware.com>"
! !

!GDBPTY methodsFor:'accessing'!

masterReadStream
    "Return stream to read from PTY's master"

    ^ masterReadStream
!

masterWriteStream
    "Return stream to write to PTY's master"

    ^ masterWriteStream
!

name
    ^ name
!

slaveReadStream
    "Return stream to read from PTY's slave"

    ^ slaveReadStream
!

slaveWriteStream
    "Return stream to write to PTY's slave"

    ^ slaveWriteStream
! !

!GDBPTY methodsFor:'initialization & release'!

initializeWithName: nameArg masterReadStream: masterRS masterWriteStream: masterWS slaveReadStream: slaveRS slaveWriteStream: slaveWS
    self assert: masterRS fileDescriptor = masterWS fileDescriptor.
    self assert: slaveRS fileDescriptor = slaveWS fileDescriptor.

    name := nameArg.

    masterReadStream := masterRS.
    masterWriteStream := masterWS.

    slaveReadStream := slaveRS.
    slaveWriteStream := slaveWS.

    "Created: / 02-08-2023 / 13:10:23 / Jan Vrany <jan.vrany@labware.com>"
!

release
    name := nil.
    masterReadStream notNil ifTrue:[ 
        masterReadStream close.
        masterReadStream := nil.
        masterWriteStream := nil.
    ].
    slaveReadStream notNil ifTrue:[ 
        slaveReadStream close.
        slaveReadStream := nil.
        slaveWriteStream := nil.
    ].

    "Created: / 09-06-2014 / 18:25:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 02-08-2023 / 13:29:06 / Jan Vrany <jan.vrany@labware.com>"
! !

!GDBPTY methodsFor:'printing & storing'!

printOn:aStream
    "append a printed representation of the receiver to the argument, aStream"

    super printOn:aStream.
    aStream nextPutAll:'('.
    name printOn:aStream.
    aStream nextPutAll:')'.

    "Modified: / 31-05-2017 / 20:13:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!GDBPTY methodsFor:'setup'!

setLocalEcho: aBoolean
     self masterReadStream setLocalEcho: aBoolean

    "Created: / 31-05-2017 / 20:19:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 02-08-2023 / 13:05:45 / Jan Vrany <jan.vrany@labware.com>"
!

setOutputCRLF: aBoolean
    self masterReadStream setOutputCRLF: aBoolean

    "Created: / 31-05-2017 / 20:20:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 02-08-2023 / 13:05:30 / Jan Vrany <jan.vrany@labware.com>"
! !

!GDBPTY class methodsFor:'documentation'!

version_HG

    ^ '$Changeset: <not expanded> $'
! !