GDBUnixProcess.st
changeset 79 303c4edc75ad
parent 78 c24e7d8bc881
child 90 6046abc9ddf4
equal deleted inserted replaced
78:c24e7d8bc881 79:303c4edc75ad
     1 "{ Package: 'jv:libgdbs' }"
     1 "{ Package: 'jv:libgdbs' }"
     2 
     2 
     3 "{ NameSpace: Smalltalk }"
     3 "{ NameSpace: Smalltalk }"
     4 
     4 
     5 GDBProcess subclass:#GDBUnixProcess
     5 GDBProcess subclass:#GDBUnixProcess
     6 	instanceVariableNames:''
     6 	instanceVariableNames:'debuggerPTY consolePTY'
     7 	classVariableNames:'GDBExecutable'
     7 	classVariableNames:'GDBExecutable'
     8 	poolDictionaries:''
     8 	poolDictionaries:''
     9 	category:'GDB-Private'
     9 	category:'GDB-Private'
    10 !
    10 !
    11 
    11 
    22     GDBExecutable := aString
    22     GDBExecutable := aString
    23 
    23 
    24     "Created: / 01-03-2015 / 08:07:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    24     "Created: / 01-03-2015 / 08:07:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    25 ! !
    25 ! !
    26 
    26 
    27 !GDBUnixProcess methodsFor:'initialization'!
    27 !GDBUnixProcess methodsFor:'accessing'!
       
    28 
       
    29 consoleInput
       
    30     ^ consolePTY master
       
    31 
       
    32     "Created: / 02-06-2017 / 23:36:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    33 !
       
    34 
       
    35 consoleOutput
       
    36     ^ consolePTY master
       
    37 
       
    38     "Created: / 02-06-2017 / 23:36:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    39 !
       
    40 
       
    41 debuggerInput
       
    42     ^ debuggerPTY master
       
    43 
       
    44     "Modified: / 26-05-2017 / 11:33:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    45 !
       
    46 
       
    47 debuggerOutput
       
    48     ^ debuggerPTY master
       
    49 
       
    50     "Modified: / 26-05-2017 / 11:34:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    51 ! !
       
    52 
       
    53 !GDBUnixProcess methodsFor:'initialization & release'!
    28 
    54 
    29 initialize
    55 initialize
    30     | inputPipe  input  outputPipe  output  args |
    56     | conpty dbgpty args |
    31 
    57 
    32     inputPipe := NonPositionableExternalStream makePipe.
    58     conpty := GDBPTY new.
    33     input := inputPipe second.
    59 
    34     outputPipe := NonPositionableExternalStream makePipe.
    60     dbgpty := GDBPTY new.
    35     output := outputPipe first.
    61     dbgpty setLocalEcho: false.
    36     args := { GDBExecutable ? '/usr/bin/gdb' . '-q' . '-nx' . '--interpreter' . 'mi2' }.
    62     dbgpty setOutputCRLF: false.  
       
    63 
       
    64     args := { GDBExecutable ? '/usr/bin/gdb' . '-q' . '-ex' . 'new-ui mi ', dbgpty name . '-ex' . 'set pagination off' . '-ex' . 'show version'}.
    37     Processor 
    65     Processor 
    38         monitor:[
    66         monitor:[
    39             pid := OperatingSystem 
    67             pid := OperatingSystem 
    40                     exec:args first
    68                     exec:args first
    41                     withArguments:args
    69                     withArguments:args
    42                     environment:OperatingSystem getEnvironment
    70                     environment:OperatingSystem getEnvironment
    43                     fileDescriptors:{
    71                     fileDescriptors:{
    44                             inputPipe first fileDescriptor.
    72                             conpty slave fileDescriptor.
    45                             outputPipe second fileDescriptor.
    73                             conpty slave fileDescriptor.
    46                             outputPipe second fileDescriptor
    74                             conpty slave fileDescriptor
    47                         }
    75                         }
    48                     fork:true
    76                     fork:true
    49                     newPgrp:false
    77                     newPgrp:false
    50                     inDirectory:Filename currentDirectory.
    78                     inDirectory:Filename currentDirectory
    51             debuggerInput := input.
    79                     showWindow: false.
    52             debuggerOutput := output.
    80             consolePTY := conpty.
       
    81             debuggerPTY := dbgpty.
    53             pid.
    82             pid.
    54         ]
    83         ]
    55         action:[:stat | self exited:stat. ].
    84         action:[:stat | self exited:stat ].
    56     inputPipe first close.
       
    57     outputPipe second close.
       
    58     pid isNil ifTrue:[
    85     pid isNil ifTrue:[
    59         input close.
    86         conpty close.
    60         output close.
    87         dbgpty close.
    61         self error:'Failed to launch gdb'.
    88         self error:'Failed to launch gdb'.
    62     ].
    89     ].
    63 
    90 
    64     "Modified: / 01-03-2015 / 08:06:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    91     "Modified: / 02-06-2017 / 08:18:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
    92 !
       
    93 
       
    94 release
       
    95     debuggerPTY notNil ifTrue:[ 
       
    96         debuggerPTY release.
       
    97     ].
       
    98     consolePTY notNil ifTrue:[ 
       
    99         consolePTY release.
       
   100     ]. 
       
   101     super release
       
   102 
       
   103     "Created: / 02-06-2017 / 23:33:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    65 ! !
   104 ! !
    66 
   105 
    67 !GDBUnixProcess class methodsFor:'documentation'!
   106 !GDBUnixProcess class methodsFor:'documentation'!
    68 
   107 
    69 version_HG
   108 version_HG