71 GDBRemoteProcess |
71 GDBRemoteProcess |
72 |
72 |
73 " |
73 " |
74 ! ! |
74 ! ! |
75 |
75 |
|
76 !GDBLocalProcess class methodsFor:'instance creation'! |
|
77 |
|
78 newWithCommand: command |
|
79 "Return a new local GDBLocalProcess suitable for this platform |
|
80 using `command` to launch GDB. |
|
81 |
|
82 If `command` is nil, default configured command is used |
|
83 (See GDBProcess class >> gdbExecutable) |
|
84 " |
|
85 self == GDBLocalProcess ifTrue:[ |
|
86 Smalltalk isSmalltalkX ifTrue:[ |
|
87 OperatingSystem isUNIXlike ifTrue:[ |
|
88 ^ GDBStXUnixProcess basicNew initializeWithCommand: command |
|
89 ]. |
|
90 ^ GDBStXSimpleProcess basicNew initializeWithCommand: command |
|
91 ]. |
|
92 ]. |
|
93 ^ self basicNew initializeWithCommand: command |
|
94 |
|
95 |
|
96 " |
|
97 GDBProcess new release." |
|
98 |
|
99 "Created: / 12-12-2018 / 22:19:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
100 ! ! |
|
101 |
76 !GDBLocalProcess methodsFor:'accessing'! |
102 !GDBLocalProcess methodsFor:'accessing'! |
77 |
103 |
78 id |
104 id |
79 "Return a string identification of this GDBProcess. |
105 "Return a string identification of this GDBProcess. |
80 Used for debugging purposes only." |
106 Used for debugging purposes only." |
85 "Modified: / 20-10-2018 / 06:53:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
111 "Modified: / 20-10-2018 / 06:53:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
86 ! ! |
112 ! ! |
87 |
113 |
88 !GDBLocalProcess methodsFor:'initialization & release'! |
114 !GDBLocalProcess methodsFor:'initialization & release'! |
89 |
115 |
|
116 initialize |
|
117 "Initializes itself using default gdb command" |
|
118 |
|
119 self initializeWithCommand: nil |
|
120 |
|
121 "Created: / 12-12-2018 / 20:11:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
122 "Modified: / 12-12-2018 / 22:17:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
123 ! |
|
124 |
|
125 initializeWithCommand: command |
|
126 "Initializes itself using `command` string to launch GDB. |
|
127 If `command` is nil, default configured command is used |
|
128 (See GDBProcess class >> gdbExecutable)" |
|
129 |
|
130 self subclassResponsibility |
|
131 |
|
132 "Created: / 12-12-2018 / 20:11:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
133 "Modified (comment): / 12-12-2018 / 22:18:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
134 ! |
|
135 |
90 release |
136 release |
91 (pid notNil and:[pid > 1]) ifTrue:[ |
137 (pid notNil and:[pid > 1]) ifTrue:[ |
92 OperatingSystem sendSignal:(OperatingSystem sigTERM) to: pid. |
138 OperatingSystem sendSignal:(OperatingSystem sigTERM) to: pid. |
93 ]. |
139 ]. |
94 |
140 |
95 "Created: / 20-10-2018 / 07:12:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
141 "Created: / 20-10-2018 / 07:12:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
96 ! ! |
142 ! ! |
97 |
143 |
98 !GDBLocalProcess methodsFor:'private'! |
144 !GDBLocalProcess methodsFor:'private'! |
|
145 |
|
146 command2argv: commandOrNil |
|
147 "Parse given `commandOrNil` string and return an array of tokens |
|
148 suitable for passing back to `exec()` family of functions. |
|
149 |
|
150 If `commandOrNil` is `nil`, then use default GDB command. |
|
151 On error, thrown GDBError. |
|
152 " |
|
153 |
|
154 | command argv exe | |
|
155 |
|
156 |
|
157 commandOrNil isNil ifTrue:[ |
|
158 command := self class gdbCommand. |
|
159 command isEmptyOrNil ifTrue:[ |
|
160 GDBError signal: 'GDB not found. Please set GDB command - `UserPreferences current gdbCommand:''...''`'. |
|
161 ^ nil. |
|
162 ]. |
|
163 ] ifFalse:[ |
|
164 command := commandOrNil. |
|
165 command isEmpty ifTrue:[ |
|
166 GDBError signal: 'Command is empty'. |
|
167 ^ nil. |
|
168 ]. |
|
169 ]. |
|
170 argv := GDBShellCommandParser parse: command. |
|
171 exe := argv first. |
|
172 exe asFilename exists ifFalse:[ |
|
173 "/ Try to find executable a long PATH, just as shell |
|
174 "/ would do... |
|
175 exe := OperatingSystem pathOfCommand: exe. |
|
176 exe notNil ifTrue:[ |
|
177 argv at:1 put: exe. |
|
178 ] ifFalse:[ |
|
179 GDBError signal: 'Command not found: ', argv first. |
|
180 ^ nil |
|
181 ]. |
|
182 ] ifTrue:[ |
|
183 "/ `exe` points to real file (or directory...), so |
|
184 "/ check here... |
|
185 exe := exe asFilename. |
|
186 exe isExecutable ifTrue:[ |
|
187 argv at:1 put: exe asAbsoluteFilename pathName. |
|
188 ] ifFalse:[ |
|
189 GDBError signal: 'Command not executable: ', argv first. |
|
190 ^ nil |
|
191 ]. |
|
192 ]. |
|
193 ^ argv |
|
194 |
|
195 "Created: / 17-12-2018 / 10:48:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
196 ! |
99 |
197 |
100 exited: status |
198 exited: status |
101 "Called when spawn GDB process terminates for whatever reason" |
199 "Called when spawn GDB process terminates for whatever reason" |
102 pid := nil. |
200 pid := nil. |
103 connection released: status |
201 connection released: status |