author | Claus Gittinger <cg@exept.de> |
Thu, 11 Mar 1999 00:14:46 +0100 | |
changeset 4042 | 526c79cadbf8 |
parent 4003 | d0f97b9cd4de |
child 4209 | 7c1b4df9e555 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1988 by Claus Gittinger |
159 | 3 |
All Rights Reserved |
1 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
720 | 13 |
Object subclass:#MiniDebugger |
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
14 |
instanceVariableNames:'tracing stepping traceBlock command commandArg commandCount' |
976 | 15 |
classVariableNames:'TheOneAndOnlyDebugger' |
16 |
poolDictionaries:'' |
|
17 |
category:'System-Debugging-Support' |
|
1 | 18 |
! |
19 |
||
618 | 20 |
!MiniDebugger class methodsFor:'documentation'! |
89 | 21 |
|
22 |
copyright |
|
23 |
" |
|
24 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
159 | 25 |
All Rights Reserved |
1 | 26 |
|
89 | 27 |
This software is furnished under a license and may be used |
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
1 | 35 |
|
89 | 36 |
documentation |
37 |
" |
|
38 |
a primitive (non graphical) debugger for use on systems without |
|
39 |
graphics or when the real debugger dies (i.e. an error occurs in |
|
40 |
the graphical debugger). |
|
93 | 41 |
Also, if an interrupt occurs within the debuger, this one is called |
42 |
for. |
|
1297 | 43 |
|
44 |
[author:] |
|
45 |
Claus Gittinger |
|
89 | 46 |
" |
47 |
! ! |
|
1 | 48 |
|
618 | 49 |
!MiniDebugger class methodsFor:'instance creation'! |
50 |
||
51 |
enter |
|
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
52 |
"enter a miniDebugger" |
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
53 |
|
618 | 54 |
^ self enterWithMessage:'MiniDebugger' |
55 |
! |
|
56 |
||
57 |
enter:aContext |
|
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
58 |
"enter a miniDebugger - for protocol compatibility with the GUI-debugger" |
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
59 |
|
618 | 60 |
^ self enterWithMessage:'MiniDebugger' |
61 |
! |
|
62 |
||
63 |
enter:aContext withMessage:aString |
|
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
64 |
"enter a miniDebugger - for protocol compatibility with the GUI-debugger" |
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
65 |
|
618 | 66 |
^ self enterWithMessage:aString |
67 |
! |
|
68 |
||
69 |
enterWithMessage:aString |
|
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
70 |
"enter a miniDebugger" |
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
71 |
|
618 | 72 |
|active| |
73 |
||
74 |
StepInterruptPending := nil. |
|
75 |
||
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
76 |
Object errorSignal handle:[:ex | |
3701 | 77 |
ex return |
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
78 |
] do:[ |
3701 | 79 |
thisContext isRecursive ifTrue:[ |
80 |
"/ 'recursive error in debugger ignored' errorPrintCR. |
|
81 |
^ self |
|
82 |
]. |
|
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
83 |
aString printCR. |
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
84 |
Processor notNil ifTrue:[ |
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
85 |
active := Processor activeProcess. |
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
86 |
'process: id=' print. active id print. |
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
87 |
' name=' print. active name printCR. |
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
88 |
]. |
618 | 89 |
]. |
90 |
self new enter. |
|
91 |
^ nil |
|
1424 | 92 |
|
93 |
"Modified: 20.5.1996 / 10:28:31 / cg" |
|
618 | 94 |
! |
1 | 95 |
|
96 |
new |
|
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
97 |
"redefined to make certain that there is only one miniDebugger |
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
98 |
in the system" |
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
99 |
|
33 | 100 |
TheOneAndOnlyDebugger isNil ifTrue:[ |
1424 | 101 |
TheOneAndOnlyDebugger := self basicNew initialize |
1 | 102 |
]. |
33 | 103 |
^ TheOneAndOnlyDebugger |
1424 | 104 |
|
3700 | 105 |
" |
106 |
TheOneAndOnlyDebugger := nil |
|
107 |
" |
|
108 |
||
3701 | 109 |
"Modified: / 31.7.1998 / 17:08:07 / cg" |
1 | 110 |
! |
111 |
||
112 |
singleStep:aBlock |
|
113 |
|aDebugger| |
|
114 |
||
115 |
aDebugger := self new stepping. |
|
241 | 116 |
ObjectMemory stepInterruptHandler:aDebugger. |
2 | 117 |
ObjectMemory flushInlineCaches. |
241 | 118 |
StepInterruptPending := 1. |
119 |
InterruptPending := 1. |
|
1 | 120 |
aBlock value. |
2 | 121 |
StepInterruptPending := nil. |
122 |
ObjectMemory stepInterruptHandler:nil |
|
1 | 123 |
! |
124 |
||
125 |
trace:aBlock |
|
1424 | 126 |
self trace:aBlock with:[:where | where printCR] |
127 |
||
128 |
"Modified: 20.5.1996 / 10:27:37 / cg" |
|
1 | 129 |
! |
130 |
||
131 |
trace:aBlock on:aStream |
|
132 |
self trace:aBlock with:[:where | where printString printOn:aStream. |
|
159 | 133 |
aStream cr] |
1 | 134 |
! |
135 |
||
136 |
trace:aBlock with:aTraceBlock |
|
137 |
|aDebugger| |
|
138 |
||
139 |
aDebugger := self new tracingWith:aTraceBlock. |
|
241 | 140 |
ObjectMemory stepInterruptHandler:aDebugger. |
1 | 141 |
ObjectMemory flushInlineCaches. |
241 | 142 |
StepInterruptPending := 1. |
143 |
InterruptPending := 1. |
|
1 | 144 |
aBlock value. |
2 | 145 |
ObjectMemory stepInterruptHandler:nil. |
1 | 146 |
StepInterruptPending := nil. |
147 |
^ nil |
|
148 |
! ! |
|
149 |
||
618 | 150 |
!MiniDebugger methodsFor:'initialization'! |
1 | 151 |
|
152 |
initialize |
|
153 |
traceBlock := nil. |
|
154 |
tracing := false. |
|
155 |
stepping := false |
|
156 |
! ! |
|
157 |
||
618 | 158 |
!MiniDebugger methodsFor:'interrupt handling'! |
1 | 159 |
|
160 |
enter |
|
159 | 161 |
|leaveCmd stillHere| |
74 | 162 |
|
163 |
stillHere := true. |
|
164 |
[stillHere] whileTrue:[ |
|
3769 | 165 |
leaveCmd := self commandLoop. |
1 | 166 |
|
3769 | 167 |
(leaveCmd == $s) ifTrue: [ |
168 |
self stepping. |
|
169 |
ObjectMemory flushInlineCaches. |
|
170 |
ObjectMemory stepInterruptHandler:self. |
|
171 |
stillHere := false. |
|
172 |
StepInterruptPending := 1. |
|
173 |
InterruptPending := 1 |
|
174 |
]. |
|
175 |
(leaveCmd == $t) ifTrue: [ |
|
176 |
traceBlock := [:where | where fullPrint]. |
|
177 |
ObjectMemory flushInlineCaches. |
|
178 |
ObjectMemory stepInterruptHandler:self. |
|
179 |
stillHere := false. |
|
180 |
StepInterruptPending := 1. |
|
181 |
InterruptPending := 1 |
|
182 |
]. |
|
183 |
(leaveCmd == $c) ifTrue: [ |
|
184 |
traceBlock := nil. |
|
185 |
stillHere := false. |
|
186 |
stepping := false. |
|
187 |
tracing := false. |
|
188 |
StepInterruptPending := nil. |
|
189 |
InterruptPending := nil |
|
190 |
]. |
|
191 |
(leaveCmd == $a) ifTrue: [ |
|
192 |
"abort" |
|
193 |
stepping := false. |
|
194 |
tracing := false. |
|
195 |
StepInterruptPending := nil. |
|
196 |
InterruptPending := nil. |
|
197 |
self doAbort. |
|
198 |
stillHere := true. |
|
199 |
"failed abort" |
|
200 |
]. |
|
1 | 201 |
]. |
202 |
^ nil |
|
3769 | 203 |
|
204 |
"Modified: / 18.8.1998 / 18:10:29 / cg" |
|
618 | 205 |
! |
206 |
||
207 |
stepInterrupt |
|
208 |
|where| |
|
209 |
||
210 |
where := thisContext. "where is stepInterrupt context" |
|
211 |
where notNil ifTrue:[ |
|
1424 | 212 |
where := where sender "where is now interrupted methods context" |
618 | 213 |
]. |
214 |
stepping ifTrue:[ |
|
1424 | 215 |
where notNil ifTrue:[ |
216 |
where fullPrint |
|
217 |
] ifFalse:[ |
|
218 |
'stepInterrupt: no context' errorPrintCR |
|
219 |
]. |
|
220 |
self enter |
|
618 | 221 |
] ifFalse:[ |
1424 | 222 |
where notNil ifTrue:[ |
223 |
traceBlock notNil ifTrue:[ |
|
224 |
traceBlock value:where |
|
225 |
] |
|
226 |
] ifFalse:[ |
|
227 |
'traceInterrupt: no context' errorPrintCR |
|
228 |
]. |
|
229 |
ObjectMemory flushInlineCaches. |
|
230 |
StepInterruptPending := 1. |
|
231 |
InterruptPending := 1 |
|
618 | 232 |
] |
1424 | 233 |
|
234 |
"Modified: 20.5.1996 / 10:23:11 / cg" |
|
1 | 235 |
! ! |
236 |
||
618 | 237 |
!MiniDebugger methodsFor:'private'! |
74 | 238 |
|
618 | 239 |
findContext:aSelector |
240 |
|con| |
|
74 | 241 |
|
618 | 242 |
con := thisContext sender. |
243 |
[con notNil] whileTrue:[ |
|
244 |
(con isBlockContext not and:[con selector == aSelector]) ifTrue:[ |
|
245 |
"got it" |
|
246 |
^ con |
|
247 |
]. |
|
248 |
con := con sender |
|
74 | 249 |
]. |
618 | 250 |
^ nil |
74 | 251 |
! |
252 |
||
618 | 253 |
getContext |
254 |
|backtrace| |
|
255 |
backtrace := thisContext. |
|
256 |
(backtrace notNil) ifTrue: [ |
|
257 |
"remove Context getContext frame" |
|
258 |
backtrace := backtrace sender. |
|
259 |
"remove Debugger showContext frame" |
|
260 |
backtrace := backtrace sender. |
|
261 |
"remove Debugger commandLoop frame" |
|
262 |
backtrace := backtrace sender. |
|
263 |
"remove Debugger enter frame" |
|
264 |
backtrace := backtrace sender |
|
265 |
]. |
|
266 |
^ backtrace |
|
267 |
! |
|
74 | 268 |
|
2772 | 269 |
printBacktraceFrom:aContext |
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
270 |
|context n| |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
271 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
272 |
aContext isNil ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
273 |
'no context' errorPrintCR. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
274 |
^ self |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
275 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
276 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
277 |
context := aContext. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
278 |
n := commandCount. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
279 |
[context notNil] whileTrue: [ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
280 |
context fullPrint. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
281 |
context := context sender. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
282 |
n notNil ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
283 |
n := n - 1. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
284 |
n <= 0 ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
285 |
^ self |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
286 |
] |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
287 |
] |
2772 | 288 |
] |
289 |
! |
|
290 |
||
618 | 291 |
stepping |
292 |
traceBlock := nil. |
|
293 |
tracing := false. |
|
294 |
stepping := true |
|
74 | 295 |
! |
296 |
||
618 | 297 |
tracingWith:aBlockOrNil |
298 |
traceBlock := aBlockOrNil. |
|
299 |
stepping := false. |
|
300 |
tracing := true |
|
301 |
! ! |
|
302 |
||
303 |
!MiniDebugger methodsFor:'user commands'! |
|
304 |
||
1 | 305 |
commandLoop |
3700 | 306 |
|cmd done valid context id proc| |
1 | 307 |
|
308 |
done := false. |
|
309 |
[done] whileFalse:[ |
|
1424 | 310 |
valid := false. |
311 |
cmd := self getCommand. |
|
2772 | 312 |
cmd isNil ifTrue:[ "/ EOF -> continue |
313 |
cmd := $c |
|
314 |
]. |
|
3700 | 315 |
|
316 |
commandArg notEmpty ifTrue:[ |
|
317 |
id := Number readFrom:commandArg onError:nil. |
|
318 |
||
319 |
id notNil ifTrue:[ |
|
320 |
proc := Process allSubInstances detect:[:p | p id == id] ifNone:nil. |
|
3701 | 321 |
proc == Processor activeProcess ifTrue:[ |
322 |
id := proc := nil |
|
323 |
] |
|
3700 | 324 |
] |
325 |
]. |
|
326 |
||
3701 | 327 |
(cmd == $l) ifTrue:[ |
1424 | 328 |
valid := true. |
3700 | 329 |
proc notNil ifTrue:[ |
330 |
'-------- walkback of process ' print. id print. ' -------' printCR. |
|
331 |
self printBacktraceFrom:(proc suspendedContext) |
|
332 |
] ifFalse:[ |
|
333 |
id notNil ifTrue:[ |
|
334 |
'no process with id: ' print. id printCR. |
|
335 |
] ifFalse:[ |
|
336 |
context isNil ifTrue: [ |
|
337 |
context := self getContext |
|
338 |
]. |
|
339 |
'-------- walkback of current process -------' printCR. |
|
340 |
self printBacktraceFrom:context |
|
341 |
] |
|
1424 | 342 |
]. |
343 |
]. |
|
3700 | 344 |
|
1424 | 345 |
(cmd == $b) ifTrue:[ |
346 |
valid := true. |
|
3700 | 347 |
proc notNil ifTrue:[ |
348 |
'-------- VM walkback of process ' print. id print. ' -------' printCR. |
|
349 |
ObjectMemory printStackBacktraceFrom:(proc suspendedContext) |
|
350 |
] ifFalse:[ |
|
351 |
id notNil ifTrue:[ |
|
352 |
'no process with id: ' print. id printCR. |
|
353 |
] ifFalse:[ |
|
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
354 |
'-------- VM walkback of current process -------' printCR. |
3700 | 355 |
ObjectMemory printStackBacktrace |
356 |
] |
|
357 |
] |
|
1424 | 358 |
]. |
3700 | 359 |
|
2113
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
360 |
(cmd == $B) ifTrue:[ |
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
361 |
valid := true. |
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
362 |
self printAllBacktraces |
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
363 |
]. |
3700 | 364 |
|
1424 | 365 |
(cmd == $P) ifTrue:[ |
366 |
valid := true. |
|
367 |
self showProcesses. |
|
368 |
]. |
|
3700 | 369 |
|
1424 | 370 |
(cmd == $r) ifTrue:[ |
371 |
valid := true. |
|
372 |
context isNil ifTrue: [ |
|
373 |
context := self getContext |
|
374 |
]. |
|
375 |
context notNil ifTrue:[ |
|
376 |
"remove Debugger stepinterrupt/halt frame" |
|
377 |
context sender receiver printCR |
|
378 |
] ifFalse:[ |
|
379 |
'no context - dont know receiver' errorPrintCR |
|
380 |
] |
|
381 |
]. |
|
3700 | 382 |
|
1424 | 383 |
(cmd == $R) ifTrue:[ |
384 |
valid := true. |
|
385 |
context isNil ifTrue: [ |
|
386 |
context := self getContext |
|
387 |
]. |
|
388 |
context notNil ifTrue:[ |
|
389 |
"remove Debugger stepinterrupt/halt frame" |
|
390 |
context sender receiver storeOn:Stdout |
|
391 |
] ifFalse:[ |
|
392 |
'no context - dont know receiver' errorPrintCR |
|
393 |
] |
|
394 |
]. |
|
3700 | 395 |
|
1424 | 396 |
(cmd == $i) ifTrue:[ |
397 |
valid := true. |
|
398 |
context isNil ifTrue: [ |
|
399 |
context := self getContext |
|
400 |
]. |
|
401 |
context notNil ifTrue:[ |
|
402 |
"remove Debugger stepinterrupt/halt frame" |
|
403 |
MiniInspector openOn:(context sender receiver) |
|
404 |
] ifFalse:[ |
|
405 |
'no context - dont know receiver' errorPrintCR |
|
406 |
] |
|
407 |
]. |
|
3700 | 408 |
|
1424 | 409 |
(cmd == $I) ifTrue:[ |
410 |
valid := true. |
|
411 |
context isNil ifTrue: [ |
|
412 |
context := self getContext |
|
413 |
]. |
|
216 | 414 |
"/ context notNil ifTrue:[ |
415 |
"/ "remove Debugger stepinterrupt/halt frame" |
|
416 |
"/ self interpreterLoopWith:(context sender receiver) |
|
417 |
"/ ] ifFalse:[ |
|
1424 | 418 |
"/ 'no context - dont know receiver' errorPrintCR. |
419 |
self interpreterLoopWith:nil |
|
216 | 420 |
"/ ] |
1424 | 421 |
]. |
422 |
context := nil. |
|
3009 | 423 |
|
1424 | 424 |
(cmd == $c) ifTrue:[valid := true. done := true]. |
425 |
(cmd == $s) ifTrue:[valid := true. done := true]. |
|
426 |
(cmd == $t) ifTrue:[valid := true. done := true]. |
|
427 |
(cmd == $a) ifTrue:[valid := true. done := true]. |
|
3700 | 428 |
(cmd == $u) ifTrue:[ |
429 |
stepping := false. |
|
430 |
tracing := false. |
|
431 |
Processor activeProcess vmTrace:false. |
|
432 |
]. |
|
433 |
||
434 |
(cmd == $T) ifTrue:[ |
|
435 |
valid := true. |
|
436 |
proc notNil ifTrue:[ |
|
437 |
proc terminate. |
|
438 |
] ifFalse:[ |
|
439 |
id notNil ifTrue:[ |
|
440 |
'no process with id: ' print. id printCR. |
|
441 |
] ifFalse:[ |
|
442 |
Processor terminateActive |
|
443 |
] |
|
444 |
] |
|
445 |
]. |
|
446 |
||
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
447 |
(cmd == $S) ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
448 |
valid := true. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
449 |
proc notNil ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
450 |
'stopping process id: ' print. id printCR. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
451 |
proc stop. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
452 |
] ifFalse:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
453 |
'invalid process id: ' print. id printCR. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
454 |
] |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
455 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
456 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
457 |
(cmd == $a) ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
458 |
"without id-arg, this is handled by caller" |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
459 |
proc notNil ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
460 |
valid := true. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
461 |
proc interruptWith:[AbortSignal raise] |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
462 |
] |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
463 |
]. |
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
464 |
|
3700 | 465 |
(cmd == $Q) ifTrue:[ |
466 |
valid := true. |
|
467 |
proc notNil ifTrue:[ |
|
468 |
proc terminateNoSignal. |
|
469 |
] ifFalse:[ |
|
470 |
id notNil ifTrue:[ |
|
471 |
'no process with id: ' print. id printCR. |
|
472 |
] ifFalse:[ |
|
473 |
Processor terminateActiveNoSignal |
|
474 |
] |
|
475 |
] |
|
476 |
]. |
|
477 |
||
478 |
(cmd == $g) ifTrue:[ |
|
479 |
valid := true. |
|
480 |
id == 3 ifTrue:[ |
|
481 |
ObjectMemory reclaimSymbols. |
|
482 |
ObjectMemory compressOldSpace. |
|
483 |
] ifFalse:[ |
|
484 |
id == 2 ifTrue:[ |
|
485 |
ObjectMemory reclaimSymbols. |
|
486 |
] ifFalse:[ |
|
487 |
ObjectMemory garbageCollect. |
|
488 |
] |
|
489 |
] |
|
490 |
]. |
|
491 |
||
492 |
(cmd == $U) ifTrue:[valid := true. MessageTracer unwrapAllMethods]. |
|
493 |
(cmd == $X) ifTrue:[valid := true. Smalltalk fatalAbort]. |
|
494 |
(cmd == $x) ifTrue:[valid := true. OperatingSystem exit]. |
|
495 |
||
1424 | 496 |
valid ifFalse: [ |
497 |
'valid commands: |
|
3700 | 498 |
c ..... continue |
499 |
s ..... step |
|
500 |
t ..... trace (continue with trace) |
|
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
501 |
a [id]. abort (i.e. raise abort signal) in (current) process |
3700 | 502 |
T [id]. terminate (current) process |
503 |
Q [id]. quick terminate (current) process - no unwinds or cleanup |
|
504 |
||
505 |
P ..... list processes |
|
3701 | 506 |
l [id]. print context chain (of process with id) |
3700 | 507 |
b [id]. full (VM) backtrace |
508 |
B ..... backtrace of all other processes |
|
509 |
||
510 |
r ..... receiver printString |
|
511 |
R ..... Receiver storeString |
|
512 |
i ..... inspect (enter MiniInspector on current receiver) |
|
513 |
I ..... interpreter (expression evaluator) |
|
514 |
U ..... unwrap all traced/breakpointed methods |
|
515 |
g ..... collect all garbage |
|
516 |
g 2.... collect all garbage & reclaim sumbols |
|
517 |
g 3.... collect all garbage, reclaim sumbols and compress |
|
518 |
X ..... exit (+core) |
|
519 |
x ..... exit Smalltalk |
|
520 |
' errorPrintCR |
|
1424 | 521 |
] |
1 | 522 |
]. |
2113
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
523 |
context := nil. |
1 | 524 |
^ cmd |
1424 | 525 |
|
3701 | 526 |
"Modified: / 31.7.1998 / 17:10:23 / cg" |
1 | 527 |
! |
528 |
||
618 | 529 |
doAbort |
530 |
|con sig| |
|
531 |
||
532 |
(sig := Object abortSignal) isHandled ifTrue:[ |
|
1424 | 533 |
sig raise. |
534 |
'abort raise failed' errorPrintCR. |
|
618 | 535 |
]. |
536 |
||
537 |
"TEMPORARY kludge - find event handler context |
|
538 |
this will be removed, once real debugging is possible |
|
539 |
" |
|
540 |
con := self findContext:#processEvent. |
|
541 |
con isNil ifTrue:[ |
|
1424 | 542 |
con := self findContext:#dispatch. |
618 | 543 |
]. |
544 |
con notNil ifTrue:[ |
|
1424 | 545 |
"got it" |
546 |
con return. |
|
547 |
'return failed' errorPrintCR. |
|
618 | 548 |
]. |
549 |
||
1424 | 550 |
'found no context to resume' errorPrintCR. |
551 |
||
552 |
"Modified: 20.5.1996 / 10:23:00 / cg" |
|
618 | 553 |
! |
554 |
||
1 | 555 |
getCommand |
93 | 556 |
|
2852
b92953bbb7ef
ungrab all screens in case of an error
Claus Gittinger <cg@exept.de>
parents:
2772
diff
changeset
|
557 |
"/ Display notNil ifTrue:[ |
b92953bbb7ef
ungrab all screens in case of an error
Claus Gittinger <cg@exept.de>
parents:
2772
diff
changeset
|
558 |
"/ Display ungrabPointer. |
b92953bbb7ef
ungrab all screens in case of an error
Claus Gittinger <cg@exept.de>
parents:
2772
diff
changeset
|
559 |
"/ Display ungrabKeyboard. |
b92953bbb7ef
ungrab all screens in case of an error
Claus Gittinger <cg@exept.de>
parents:
2772
diff
changeset
|
560 |
"/ ]. |
3126
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
561 |
|
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
562 |
"/ Screen notNil ifTrue:[ |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
563 |
"/ Screen allScreens do:[:aScreen | |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
564 |
"/ aScreen ungrabPointer. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
565 |
"/ aScreen ungrabKeyboard. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
566 |
"/ ]. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
567 |
"/ ]. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
568 |
|
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
569 |
Display notNil ifTrue:[ |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
570 |
Display ungrabPointer. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
571 |
Display ungrabKeyboard. |
852
5c4a0585ba0b
ungrab pointer for every input
Claus Gittinger <cg@exept.de>
parents:
720
diff
changeset
|
572 |
]. |
5c4a0585ba0b
ungrab pointer for every input
Claus Gittinger <cg@exept.de>
parents:
720
diff
changeset
|
573 |
|
1 | 574 |
'MiniDebugger> ' print. |
93 | 575 |
|
976 | 576 |
UserInterruptSignal handle:[:ex | |
577 |
ex restart |
|
159 | 578 |
] do:[ |
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
579 |
|c cmd arg cnt| |
3700 | 580 |
|
976 | 581 |
cmd := Character fromUser. |
582 |
cmd isNil ifTrue:[ |
|
583 |
" |
|
584 |
mhmh end-of-file; |
|
585 |
return a 'c' (for continue); hope thats ok. |
|
586 |
" |
|
587 |
cmd := $c |
|
588 |
]. |
|
93 | 589 |
|
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
590 |
cnt := nil. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
591 |
(cmd isDigit) ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
592 |
cnt := 0. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
593 |
[cmd isDigit] whileTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
594 |
cnt := cnt * 10 + cmd digitValue. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
595 |
cmd := Character fromUser |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
596 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
597 |
[cmd == Character space] whileTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
598 |
cmd := Character fromUser |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
599 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
600 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
601 |
|
976 | 602 |
" |
3700 | 603 |
collect to end-of-line in arg |
976 | 604 |
" |
605 |
c := cmd. |
|
3700 | 606 |
arg := ''. |
976 | 607 |
[c isNil or:[c isEndOfLineCharacter]] whileFalse: [ |
3700 | 608 |
arg := arg copyWith:c. |
976 | 609 |
c := Character fromUser. |
610 |
]. |
|
3700 | 611 |
commandArg := arg copyFrom:2. |
612 |
command := cmd. |
|
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
613 |
commandCount := cnt. |
1 | 614 |
]. |
3700 | 615 |
^ command |
976 | 616 |
|
3700 | 617 |
"Modified: / 31.7.1998 / 16:11:01 / cg" |
1 | 618 |
! |
619 |
||
620 |
interpreterLoopWith:anObject |
|
621 |
|line done| |
|
1424 | 622 |
'read-eval-print loop; exit with empty line' printCR. |
3700 | 623 |
'' printCR. |
624 |
||
1 | 625 |
done := false. |
626 |
[done] whileFalse:[ |
|
3700 | 627 |
'> ' print. |
628 |
||
1424 | 629 |
line := Stdin nextLine. |
630 |
(line size == 0) ifTrue:[ |
|
631 |
done := true |
|
632 |
] ifFalse:[ |
|
633 |
(Compiler evaluate:line |
|
634 |
receiver:anObject |
|
635 |
notifying:nil) printCR |
|
636 |
] |
|
1 | 637 |
] |
1424 | 638 |
|
3700 | 639 |
"Modified: / 31.7.1998 / 16:01:47 / cg" |
618 | 640 |
! |
641 |
||
2772 | 642 |
printAllBacktraces |
643 |
Process allInstancesDo:[:p | |
|
644 |
(p ~~ Processor activeProcess |
|
645 |
and:[p isDead not]) ifTrue:[ |
|
646 |
'---------------------------------------------------------' printCR. |
|
647 |
' proc id=' print. p id print. |
|
648 |
' name=''' print. p name print. |
|
649 |
''' createdBy: ' print. p creatorId print. |
|
650 |
' state=' print. p state print. |
|
651 |
' prio=' print. p priority printCR. |
|
652 |
'' printCR. '' printCR. |
|
653 |
||
654 |
self printBacktraceFrom:(p suspendedContext) |
|
655 |
] |
|
656 |
] |
|
657 |
! |
|
658 |
||
618 | 659 |
showProcesses |
660 |
|active| |
|
661 |
||
662 |
active := Processor activeProcess. |
|
3700 | 663 |
'current id=' print. active id print. ' name=''' print. active name print. '''' printCR. |
618 | 664 |
|
3700 | 665 |
Process allSubInstancesDo:[:p | |
666 |
'proc id=' print. (p id printStringPaddedTo:5) print. |
|
667 |
(p state printStringPaddedTo:10) print. |
|
668 |
' pri=' print. (p priority printStringPaddedTo:2) print. |
|
669 |
' creator:' print. (p creatorId printStringPaddedTo:5) print. |
|
670 |
' name=''' print. p name print. |
|
671 |
'''' printCR. |
|
618 | 672 |
] |
1424 | 673 |
|
3700 | 674 |
"Modified: / 31.7.1998 / 16:30:19 / cg" |
1 | 675 |
! ! |
618 | 676 |
|
658 | 677 |
!MiniDebugger class methodsFor:'documentation'! |
678 |
||
679 |
version |
|
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
680 |
^ '$Header: /cvs/stx/stx/libbasic/MiniDebugger.st,v 1.40 1999-02-25 20:17:04 cg Exp $' |
658 | 681 |
! ! |