GDBStXUnixProcess.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 25 Apr 2019 16:25:29 +0100
changeset 187 cb419023190f
parent 185 4e1be69b39ce
child 189 ce3e5dab2e60
permissions -rw-r--r--
Fix `GDBBreakpoint` description to support new-style breakpoint record ...which includes new field `locations` that contains all locations for a multi-location breakpoint. Previous versions printed more than one breakpoint on `=breakpoint-*` events (which was not valid MI syntax as documented). With this fix, `stx:libgdbs` supports both, the old and new records.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
91
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
     1
"
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
     2
jv:libgdbs - GNU Debugger Interface Library
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
     3
Copyright (C) 2015-now Jan Vrany
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
     4
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
     5
This library is free software; you can redistribute it and/or
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
     6
modify it under the terms of the GNU Lesser General Public
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
     7
License as published by the Free Software Foundation; either
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
     8
version 2.1 of the License. 
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
     9
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    10
This library is distributed in the hope that it will be useful,
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    11
but WITHOUT ANY WARRANTY; without even the implied warranty of
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    13
Lesser General Public License for more details.
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    14
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    15
You should have received a copy of the GNU Lesser General Public
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    16
License along with this library; if not, write to the Free Software
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    18
"
23
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
"{ Package: 'jv:libgdbs' }"
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
58
531c7f5d6558 Allow for setting path to GDB executable via classvar in GDBUnixProcess.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 25
diff changeset
    21
"{ NameSpace: Smalltalk }"
531c7f5d6558 Allow for setting path to GDB executable via classvar in GDBUnixProcess.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 25
diff changeset
    22
152
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    23
GDBLocalProcess subclass:#GDBStXUnixProcess
79
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    24
	instanceVariableNames:'debuggerPTY consolePTY'
93
b1715ebf8df1 Resurected old `GDBProcess` implementation using pipes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
    25
	classVariableNames:''
23
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    26
	poolDictionaries:''
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    27
	category:'GDB-Private'
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
!
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
152
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    30
!GDBStXUnixProcess class methodsFor:'documentation'!
91
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    31
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    32
copyright
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    33
"
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    34
jv:libgdbs - GNU Debugger Interface Library
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    35
Copyright (C) 2015-now Jan Vrany
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    36
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    37
This library is free software; you can redistribute it and/or
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    38
modify it under the terms of the GNU Lesser General Public
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    39
License as published by the Free Software Foundation; either
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    40
version 2.1 of the License. 
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    41
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    42
This library is distributed in the hope that it will be useful,
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    43
but WITHOUT ANY WARRANTY; without even the implied warranty of
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    44
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    45
Lesser General Public License for more details.
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    46
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    47
You should have received a copy of the GNU Lesser General Public
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    48
License along with this library; if not, write to the Free Software
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    49
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    50
"
152
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    51
!
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    52
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    53
documentation
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    54
"
163
f882d9048b54 Renamed `GDBStXWindowsProcess` to `GDBStXSimpleProcess`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 155
diff changeset
    55
    GDBStXUnixProcess is a Smalltalk/X specific implementation of GDB process
f882d9048b54 Renamed `GDBStXWindowsProcess` to `GDBStXSimpleProcess`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 155
diff changeset
    56
    that uses two PTYs to communicate with GDB - one for MI channel, another 
f882d9048b54 Renamed `GDBStXWindowsProcess` to `GDBStXSimpleProcess`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 155
diff changeset
    57
    for CLI channel. In this case, the CLI interface is driven by GDB itself
f882d9048b54 Renamed `GDBStXWindowsProcess` to `GDBStXSimpleProcess`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 155
diff changeset
    58
    (as opposite to be emulated as in case of GDBStXSimpleProcess).
152
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    59
163
f882d9048b54 Renamed `GDBStXWindowsProcess` to `GDBStXSimpleProcess`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 155
diff changeset
    60
    On UNIX platforms running GDB locally, this is preferred implementation
f882d9048b54 Renamed `GDBStXWindowsProcess` to `GDBStXSimpleProcess`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 155
diff changeset
    61
    to use.
152
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    62
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    63
    [author:]
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    64
        Jan Vrany <jan.vrany@fit.cvut.cz>
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    65
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    66
    [instance variables:]
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    67
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    68
    [class variables:]
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    69
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    70
    [see also:]
163
f882d9048b54 Renamed `GDBStXWindowsProcess` to `GDBStXSimpleProcess`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 155
diff changeset
    71
        GDBRemoteProcess
f882d9048b54 Renamed `GDBStXWindowsProcess` to `GDBStXSimpleProcess`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 155
diff changeset
    72
        GDBStXSimpleProcess
152
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    73
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    74
"
91
472a4841a8b6 License this package under 'GNU Lesser General Public License'
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 90
diff changeset
    75
! !
58
531c7f5d6558 Allow for setting path to GDB executable via classvar in GDBUnixProcess.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 25
diff changeset
    76
152
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    77
!GDBStXUnixProcess methodsFor:'accessing'!
79
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    78
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    79
consoleInput
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    80
    ^ consolePTY master
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    81
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    82
    "Created: / 02-06-2017 / 23:36:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    83
!
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    84
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    85
consoleOutput
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    86
    ^ consolePTY master
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    87
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    88
    "Created: / 02-06-2017 / 23:36:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
116
ffd185f7a357 Fix: initialize debugger features early during initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 93
diff changeset
    89
!
ffd185f7a357 Fix: initialize debugger features early during initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 93
diff changeset
    90
ffd185f7a357 Fix: initialize debugger features early during initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 93
diff changeset
    91
nativeTargetFeatures
ffd185f7a357 Fix: initialize debugger features early during initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 93
diff changeset
    92
    ^ #('async')
ffd185f7a357 Fix: initialize debugger features early during initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 93
diff changeset
    93
ffd185f7a357 Fix: initialize debugger features early during initialization
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 93
diff changeset
    94
    "Created: / 09-04-2018 / 15:40:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
79
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    95
! !
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
    96
152
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
    97
!GDBStXUnixProcess methodsFor:'initialization & release'!
23
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    98
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
initialize
149
0db2ccc6da7b Refactor configuration and autodetection of gdb executable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 138
diff changeset
   100
    | exe conpty dbgpty args |
0db2ccc6da7b Refactor configuration and autodetection of gdb executable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 138
diff changeset
   101
0db2ccc6da7b Refactor configuration and autodetection of gdb executable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 138
diff changeset
   102
    exe := self class gdbExecutable.
0db2ccc6da7b Refactor configuration and autodetection of gdb executable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 138
diff changeset
   103
    (exe isNil or:[ exe asFilename isExecutable not ]) ifTrue:[ 
153
dd55019f1d86 Partability: use ANSI `#signal:` to raise an exception
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 152
diff changeset
   104
        GDBError signal: 'Could not find gdb, please set path to gdb using GDBProcess class >> gdbExecutable:'.
149
0db2ccc6da7b Refactor configuration and autodetection of gdb executable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 138
diff changeset
   105
        ^ self.
0db2ccc6da7b Refactor configuration and autodetection of gdb executable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 138
diff changeset
   106
    ].
79
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   107
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   108
    conpty := GDBPTY new.
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   109
    dbgpty := GDBPTY new.
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   110
    dbgpty setLocalEcho: false.
90
6046abc9ddf4 Replaced Squek computed arrays by more verbose `Array with:...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   111
    dbgpty setOutputCRLF: false.
79
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   112
134
3abcf54431c1 Do not show GDB version on command console
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 116
diff changeset
   113
    args := (Array new: 6)
149
0db2ccc6da7b Refactor configuration and autodetection of gdb executable
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 138
diff changeset
   114
                at: 1 put: exe;
90
6046abc9ddf4 Replaced Squek computed arrays by more verbose `Array with:...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   115
                at: 2 put: '-q';
6046abc9ddf4 Replaced Squek computed arrays by more verbose `Array with:...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   116
                at: 3 put: '-ex';
6046abc9ddf4 Replaced Squek computed arrays by more verbose `Array with:...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   117
                at: 4 put: 'new-ui mi ', dbgpty name;
6046abc9ddf4 Replaced Squek computed arrays by more verbose `Array with:...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   118
                at: 5 put: '-ex';
6046abc9ddf4 Replaced Squek computed arrays by more verbose `Array with:...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   119
                at: 6 put: 'set pagination off';
6046abc9ddf4 Replaced Squek computed arrays by more verbose `Array with:...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   120
                yourself.
6046abc9ddf4 Replaced Squek computed arrays by more verbose `Array with:...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   121
    Processor
23
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   122
        monitor:[
90
6046abc9ddf4 Replaced Squek computed arrays by more verbose `Array with:...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   123
            pid := OperatingSystem
23
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   124
                    exec:args first
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   125
                    withArguments:args
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   126
                    environment:OperatingSystem getEnvironment
155
773093e3c3b4 Portability: do not use Squeak computed arrays
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   127
                    fileDescriptors: (Array 
773093e3c3b4 Portability: do not use Squeak computed arrays
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   128
                            with: conpty slave fileDescriptor
773093e3c3b4 Portability: do not use Squeak computed arrays
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   129
                            with: conpty slave fileDescriptor
773093e3c3b4 Portability: do not use Squeak computed arrays
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   130
                            with: conpty slave fileDescriptor)                    
23
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   131
                    fork:true
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   132
                    newPgrp:false
79
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   133
                    inDirectory:Filename currentDirectory
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   134
                    showWindow: false.
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   135
            consolePTY := conpty.
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   136
            debuggerPTY := dbgpty.
93
b1715ebf8df1 Resurected old `GDBProcess` implementation using pipes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   137
            debuggerInput := debuggerOutput := debuggerPTY master.
23
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   138
            pid.
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   139
        ]
79
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   140
        action:[:stat | self exited:stat ].
23
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   141
    pid isNil ifTrue:[
79
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   142
        conpty close.
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   143
        dbgpty close.
23
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   144
        self error:'Failed to launch gdb'.
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   145
    ].
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   146
155
773093e3c3b4 Portability: do not use Squeak computed arrays
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 153
diff changeset
   147
    "Modified: / 29-10-2018 / 12:58:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
79
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   148
!
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   149
185
4e1be69b39ce API: add `GDBDebugger >> process`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 167
diff changeset
   150
initializeWithCommand: aString
164
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   151
    | conpty dbgpty argv |
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   152
185
4e1be69b39ce API: add `GDBDebugger >> process`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 167
diff changeset
   153
    command := aString.
164
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   154
    conpty := GDBPTY new.
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   155
    dbgpty := GDBPTY new.
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   156
    dbgpty setLocalEcho: false.
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   157
    dbgpty setOutputCRLF: false.     
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   158
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   159
    argv := ((self command2argv: command)) ,
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   160
            ((Array new: 5)
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   161
                at: 1 put: '-q';
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   162
                at: 2 put: '-ex';
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   163
                at: 3 put: 'new-ui mi ', dbgpty name;
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   164
                at: 4 put: '-ex';
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   165
                at: 5 put: 'set pagination off';
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   166
                yourself).
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   167
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   168
    Processor
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   169
        monitor:[
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   170
            pid := OperatingSystem
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   171
                    exec:argv first
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   172
                    withArguments:argv
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   173
                    environment:OperatingSystem getEnvironment
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   174
                    fileDescriptors: (Array 
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   175
                            with: conpty slave fileDescriptor
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   176
                            with: conpty slave fileDescriptor
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   177
                            with: conpty slave fileDescriptor)                    
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   178
                    fork:true
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   179
                    newPgrp:false
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   180
                    inDirectory:Filename currentDirectory
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   181
                    showWindow: false.
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   182
            consolePTY := conpty.
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   183
            debuggerPTY := dbgpty.
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   184
            debuggerInput := debuggerOutput := debuggerPTY master.
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   185
            pid.
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   186
        ]
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   187
        action:[:stat | self exited:stat ].
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   188
    pid isNil ifTrue:[
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   189
        conpty close.
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   190
        dbgpty close.
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   191
        self error:'Failed to launch gdb'.
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   192
    ].
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   193
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   194
    "Created: / 12-12-2018 / 20:13:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
185
4e1be69b39ce API: add `GDBDebugger >> process`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 167
diff changeset
   195
    "Modified: / 27-03-2019 / 08:32:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
164
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   196
!
a16705f64a64 Add support for arbitrary (shell) command to launch GDB.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 163
diff changeset
   197
79
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   198
release
90
6046abc9ddf4 Replaced Squek computed arrays by more verbose `Array with:...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   199
    debuggerPTY notNil ifTrue:[
79
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   200
        debuggerPTY release.
93
b1715ebf8df1 Resurected old `GDBProcess` implementation using pipes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   201
        debuggerInput := debuggerOutput := nil
79
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   202
    ].
90
6046abc9ddf4 Replaced Squek computed arrays by more verbose `Array with:...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   203
    consolePTY notNil ifTrue:[
79
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   204
        consolePTY release.
90
6046abc9ddf4 Replaced Squek computed arrays by more verbose `Array with:...`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 79
diff changeset
   205
    ].
79
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   206
    super release
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   207
303c4edc75ad `GDBProcess` refatored to have console interpreter on STDIN/STDOUT
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 78
diff changeset
   208
    "Created: / 02-06-2017 / 23:33:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
93
b1715ebf8df1 Resurected old `GDBProcess` implementation using pipes
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 91
diff changeset
   209
    "Modified: / 15-12-2017 / 23:59:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
23
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   210
! !
a7eb888c81b5 Introduced GDBProcess - a class encapsulating gdb OS process.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   211
167
6da3d808c7cc Use inferior PTY only if supported
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 164
diff changeset
   212
!GDBStXUnixProcess methodsFor:'queries'!
6da3d808c7cc Use inferior PTY only if supported
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 164
diff changeset
   213
6da3d808c7cc Use inferior PTY only if supported
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 164
diff changeset
   214
canUsePTY
6da3d808c7cc Use inferior PTY only if supported
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 164
diff changeset
   215
    "Return true if PTYs can be used with this process, false otherwise"
6da3d808c7cc Use inferior PTY only if supported
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 164
diff changeset
   216
6da3d808c7cc Use inferior PTY only if supported
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 164
diff changeset
   217
    ^ true
6da3d808c7cc Use inferior PTY only if supported
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 164
diff changeset
   218
6da3d808c7cc Use inferior PTY only if supported
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 164
diff changeset
   219
    "Created: / 16-01-2019 / 23:02:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
6da3d808c7cc Use inferior PTY only if supported
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 164
diff changeset
   220
! !
6da3d808c7cc Use inferior PTY only if supported
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 164
diff changeset
   221
152
fab425b52c21 Refactor `GDBProcess` hierarchy to improve portability
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 149
diff changeset
   222
!GDBStXUnixProcess class methodsFor:'documentation'!
58
531c7f5d6558 Allow for setting path to GDB executable via classvar in GDBUnixProcess.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 25
diff changeset
   223
531c7f5d6558 Allow for setting path to GDB executable via classvar in GDBUnixProcess.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 25
diff changeset
   224
version_HG
531c7f5d6558 Allow for setting path to GDB executable via classvar in GDBUnixProcess.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 25
diff changeset
   225
531c7f5d6558 Allow for setting path to GDB executable via classvar in GDBUnixProcess.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 25
diff changeset
   226
    ^ '$Changeset: <not expanded> $'
531c7f5d6558 Allow for setting path to GDB executable via classvar in GDBUnixProcess.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 25
diff changeset
   227
! !
531c7f5d6558 Allow for setting path to GDB executable via classvar in GDBUnixProcess.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 25
diff changeset
   228