9 |
9 |
10 |
10 |
11 !GDBLauncher class methodsFor:'starting'! |
11 !GDBLauncher class methodsFor:'starting'! |
12 |
12 |
13 startGDB |
13 startGDB |
14 | inputPipe input outputPipe output args controller pid | |
14 | inputPipe input outputPipe output args controller pid inferiorOutput inferiorInput ptyTriple ptyName master slave| |
|
15 |
|
16 OperatingSystem isUNIXlike ifTrue:[ |
|
17 "Use a pseudo-tty" |
|
18 ptyTriple := OperatingSystem makePTY. |
|
19 |
|
20 ptyName := ptyTriple at:3. |
|
21 |
|
22 "/ pty at:1 is the master; |
|
23 "/ pty at:2 is the slave |
|
24 master := NonPositionableExternalStream forReadWriteToFileDescriptor:(ptyTriple at:1). |
|
25 master buffered:false. |
|
26 |
|
27 slave := NonPositionableExternalStream forReadWriteToFileDescriptor:(ptyTriple at:2). |
|
28 slave close. |
|
29 |
|
30 inferiorInput := inferiorOutput := master. |
|
31 ] ifFalse:[ |
|
32 OperatingSystem isMSWINDOWSNTlike ifTrue:[ |
|
33 self error: 'Windows are not (yet) supported' |
|
34 ] ifFalse:[ |
|
35 self error: 'Operating system not supported' |
|
36 ] |
|
37 ]. |
|
38 |
|
39 |
15 |
40 |
16 inputPipe := NonPositionableExternalStream makePipe. |
41 inputPipe := NonPositionableExternalStream makePipe. |
17 input := inputPipe second. |
42 input := inputPipe second. |
18 |
|
19 outputPipe := NonPositionableExternalStream makePipe. |
43 outputPipe := NonPositionableExternalStream makePipe. |
20 output := outputPipe first. |
44 output := outputPipe first. |
21 |
45 args := #( '/usr/bin/gdb' '--interpreter' 'mi2' ). |
22 args := #('/usr/bin/gdb' '--interpreter' 'mi2'). |
46 ptyName notNil ifTrue:[ |
23 |
47 args := args , { '-tty=', ptyName }. |
24 Processor monitor:[ |
|
25 pid := OperatingSystem exec: args first withArguments:args |
|
26 environment: OperatingSystem getEnvironment |
|
27 fileDescriptors:{inputPipe first fileDescriptor . outputPipe second fileDescriptor . outputPipe second fileDescriptor} |
|
28 fork:true |
|
29 newPgrp:false |
|
30 inDirectory:Filename currentDirectory. |
|
31 controller := GDBDriver pid: pid input: input output: output. |
|
32 pid. |
|
33 ] action:[:stat | |
|
34 controller released: stat. |
|
35 ]. |
48 ]. |
36 |
49 Processor |
|
50 monitor:[ |
|
51 pid := OperatingSystem |
|
52 exec:args first |
|
53 withArguments:args |
|
54 environment:OperatingSystem getEnvironment |
|
55 fileDescriptors:{ |
|
56 inputPipe first fileDescriptor. |
|
57 outputPipe second fileDescriptor. |
|
58 outputPipe second fileDescriptor |
|
59 } |
|
60 fork:true |
|
61 newPgrp:false |
|
62 inDirectory:Filename currentDirectory. |
|
63 controller := GDBDriver |
|
64 debuggerPid:pid |
|
65 debuggerInput:input |
|
66 debuggerOutput:output |
|
67 inferiorInput:inferiorInput |
|
68 inferiorOutput:inferiorOutput. |
|
69 pid. |
|
70 ] |
|
71 action:[:stat | controller released:stat. ]. |
37 inputPipe first close. |
72 inputPipe first close. |
38 outputPipe second close. |
73 outputPipe second close. |
39 |
74 pid isNil ifTrue:[ |
40 pid isNil ifTrue:[ |
|
41 input close. |
75 input close. |
42 output close. |
76 output close. |
43 self error: 'Failed to launch gdb'. |
77 self error:'Failed to launch gdb'. |
44 ^ self. |
78 ^ self. |
45 ]. |
79 ]. |
46 |
|
47 ^ controller |
80 ^ controller |
48 |
81 |
49 "Created: / 26-05-2014 / 21:18:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
82 "Created: / 26-05-2014 / 21:18:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
50 "Modified: / 02-06-2014 / 23:04:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
83 "Modified: / 09-06-2014 / 09:48:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
51 ! ! |
84 ! ! |
52 |
85 |
53 !GDBLauncher class methodsFor:'documentation'! |
86 !GDBLauncher class methodsFor:'documentation'! |
54 |
87 |
55 version_HG |
88 version_HG |