author | Claus Gittinger <cg@exept.de> |
Tue, 27 Sep 2016 12:51:11 +0200 | |
changeset 20439 | a68d67522347 |
parent 20420 | 79810aad4d09 |
child 20496 | 0c25051acebd |
permissions | -rw-r--r-- |
20420 | 1 |
"{ Encoding: utf8 }" |
2 |
||
1 | 3 |
" |
5 | 4 |
COPYRIGHT (c) 1988 by Claus Gittinger |
159 | 5 |
All Rights Reserved |
1 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
14 |
"{ Package: 'stx:libbasic' }" |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
15 |
|
19144 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
720 | 18 |
Object subclass:#MiniDebugger |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
19 |
instanceVariableNames:'tracing stepping traceBlock command commandArg commandCount |
19389 | 20 |
enteringContext dot nesting inputStream' |
16626 | 21 |
classVariableNames:'NotFirstTimeEntered' |
976 | 22 |
poolDictionaries:'' |
23 |
category:'System-Debugging-Support' |
|
1 | 24 |
! |
25 |
||
618 | 26 |
!MiniDebugger class methodsFor:'documentation'! |
89 | 27 |
|
28 |
copyright |
|
29 |
" |
|
30 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
159 | 31 |
All Rights Reserved |
1 | 32 |
|
89 | 33 |
This software is furnished under a license and may be used |
34 |
only in accordance with the terms of that license and with the |
|
35 |
inclusion of the above copyright notice. This software may not |
|
36 |
be provided or otherwise made available to, or used by, any |
|
37 |
other person. No title to or ownership of the software is |
|
38 |
hereby transferred. |
|
39 |
" |
|
40 |
! |
|
1 | 41 |
|
89 | 42 |
documentation |
43 |
" |
|
44 |
a primitive (non graphical) debugger for use on systems without |
|
45 |
graphics or when the real debugger dies (i.e. an error occurs in |
|
15927 | 46 |
the graphical debugger or the UI/event handler is broken). |
47 |
Also, if an interrupt occurs within the debuger, this one is called for. |
|
48 |
Needs a console. |
|
1297 | 49 |
|
13740 | 50 |
MiniDebugger enter |
51 |
||
1297 | 52 |
[author:] |
16557 | 53 |
Claus Gittinger |
89 | 54 |
" |
55 |
! ! |
|
1 | 56 |
|
618 | 57 |
!MiniDebugger class methodsFor:'instance creation'! |
58 |
||
11534 | 59 |
enter |
60 |
"enter a miniDebugger" |
|
61 |
||
16557 | 62 |
^ self |
19389 | 63 |
enter:thisContext sender |
64 |
withMessage:'MiniDebugger' |
|
65 |
mayProceed:true |
|
66 |
input:nil |
|
11534 | 67 |
! |
68 |
||
4572 | 69 |
enter:aContext withMessage:aString mayProceed:mayProceed |
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 |
|
19389 | 72 |
^ self |
73 |
enter:aContext |
|
74 |
withMessage:aString |
|
75 |
mayProceed:mayProceed |
|
76 |
input:nil |
|
77 |
! |
|
78 |
||
79 |
enter:aContext withMessage:aString mayProceed:mayProceed input:inputStreamOrNil |
|
80 |
"enter a miniDebugger" |
|
81 |
||
7839
d6d9fac8b4db
skip recursive contexts when shwing backtrace
Claus Gittinger <cg@exept.de>
parents:
7706
diff
changeset
|
82 |
|active con sender| |
618 | 83 |
|
84 |
StepInterruptPending := nil. |
|
85 |
||
7093
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
86 |
Error handle:[:ex | |
19389 | 87 |
ex return |
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
88 |
] do:[ |
19389 | 89 |
thisContext isRecursive ifTrue:[ |
90 |
"/ 'recursive error in debugger ignored' errorPrintCR. |
|
91 |
^ self |
|
92 |
]. |
|
14798 | 93 |
|
19389 | 94 |
aString errorPrintCR. |
95 |
Processor notNil ifTrue:[ |
|
96 |
active := Processor activeProcess. |
|
97 |
'process: id=' errorPrint. active id errorPrint. |
|
98 |
' name=' errorPrint. active name errorPrintCR. |
|
4960 | 99 |
|
19389 | 100 |
'context: ' errorPrint. aContext printString errorPrintCR. |
101 |
(con := aContext) notNil ifTrue:[ |
|
102 |
con := con sender. |
|
103 |
' ......: ' errorPrint. con printString errorPrintCR. |
|
104 |
[con notNil] whileTrue:[ |
|
105 |
sender := con sender. |
|
106 |
(sender notNil and:[sender selector == con selector]) ifTrue:[ |
|
107 |
' ......: ' errorPrint. sender printString errorPrintCR. |
|
108 |
' ......: [** intermediate recursive contexts skipped **]' errorPrintCR. |
|
109 |
[sender notNil |
|
110 |
and:[sender selector == con selector |
|
111 |
and:[sender method == con method]]] whileTrue:[ |
|
112 |
con := sender. |
|
113 |
sender := con sender. |
|
114 |
]. |
|
115 |
]. |
|
116 |
con := sender. |
|
117 |
' ......: ' errorPrint. con printString errorPrintCR. |
|
118 |
] |
|
119 |
] |
|
120 |
]. |
|
121 |
NotFirstTimeEntered ~~ true ifTrue:[ |
|
122 |
NotFirstTimeEntered := true. |
|
123 |
'Type "c" to proceed, "?" for help' errorPrintCR. |
|
124 |
]. |
|
618 | 125 |
]. |
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
126 |
|
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
127 |
OperatingSystem hasConsole ifFalse:[ |
19389 | 128 |
Error handle:[:ex | |
129 |
ex return |
|
130 |
] do:[ |
|
131 |
self warn:('Unexpected error:\' , aString , '\\No MiniDebugger functionality available') withCRs . |
|
132 |
]. |
|
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
133 |
|
19389 | 134 |
Error handle:[:ex | |
135 |
'cannot raise Abort - exiting ...' errorPrintCR. |
|
136 |
OperatingSystem exit:10. |
|
137 |
] do:[ |
|
138 |
AbortOperationRequest raise. |
|
139 |
] |
|
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
140 |
] ifTrue:[ |
19389 | 141 |
self new |
142 |
inputStream:inputStreamOrNil; |
|
143 |
enter:aContext mayProceed:mayProceed. |
|
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
144 |
]. |
4961
5419c9a32316
abort after unproceedable error
Stefan Vogel <sv@exept.de>
parents:
4960
diff
changeset
|
145 |
mayProceed ifFalse:[ |
19389 | 146 |
AbortOperationRequest raise |
4961
5419c9a32316
abort after unproceedable error
Stefan Vogel <sv@exept.de>
parents:
4960
diff
changeset
|
147 |
]. |
618 | 148 |
^ nil |
1424 | 149 |
|
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
150 |
"Modified: / 19.5.1999 / 18:14:33 / cg" |
618 | 151 |
! |
1 | 152 |
|
11235 | 153 |
enterException:ex |
154 |
"enter a debugger; if this is a recursive invocation, enter |
|
155 |
a MiniDebugger instead. |
|
156 |
This is the standard way of entering the debugger; |
|
157 |
sent from error- and halt messages." |
|
158 |
||
159 |
^ self |
|
19389 | 160 |
enter:ex returnableSuspendedContext |
161 |
withMessage:(ex creator name,': ',ex descriptionForDebugger) |
|
162 |
mayProceed:(ex mayProceed) |
|
163 |
input:nil |
|
11235 | 164 |
! |
165 |
||
4572 | 166 |
enterWithMessage:aString mayProceed:mayProceed |
167 |
"enter a miniDebugger" |
|
168 |
||
16557 | 169 |
^ self |
19389 | 170 |
enter:thisContext sender |
171 |
withMessage:aString |
|
172 |
mayProceed:mayProceed |
|
173 |
input:nil |
|
4572 | 174 |
|
175 |
"Modified: / 19.5.1999 / 18:14:33 / cg" |
|
176 |
! |
|
177 |
||
1 | 178 |
new |
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
179 |
"redefined to make certain that there is only one miniDebugger |
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
180 |
in the system" |
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
181 |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
182 |
^ self basicNew initialize. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
183 |
|
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
184 |
"/ TheOneAndOnlyDebugger isNil ifTrue:[ |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
185 |
"/ TheOneAndOnlyDebugger := self basicNew initialize |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
186 |
"/ ]. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
187 |
"/ ^ TheOneAndOnlyDebugger |
1424 | 188 |
|
3700 | 189 |
" |
190 |
TheOneAndOnlyDebugger := nil |
|
191 |
" |
|
192 |
||
3701 | 193 |
"Modified: / 31.7.1998 / 17:08:07 / cg" |
1 | 194 |
! |
195 |
||
4966 | 196 |
openOn:aProcess |
197 |
"enter a miniDebugger" |
|
198 |
||
8840 | 199 |
^ self |
19389 | 200 |
enter:thisContext sender |
201 |
withMessage:'MiniDebugger [info]: Attention - process debugging not possible.' |
|
202 |
mayProceed:true |
|
203 |
input:nil |
|
4966 | 204 |
|
205 |
"Modified: / 19.5.1999 / 18:14:33 / cg" |
|
206 |
! |
|
207 |
||
1 | 208 |
singleStep:aBlock |
209 |
|aDebugger| |
|
210 |
||
211 |
aDebugger := self new stepping. |
|
241 | 212 |
ObjectMemory stepInterruptHandler:aDebugger. |
2 | 213 |
ObjectMemory flushInlineCaches. |
241 | 214 |
StepInterruptPending := 1. |
215 |
InterruptPending := 1. |
|
1 | 216 |
aBlock value. |
2 | 217 |
StepInterruptPending := nil. |
218 |
ObjectMemory stepInterruptHandler:nil |
|
1 | 219 |
! |
220 |
||
221 |
trace:aBlock |
|
16249 | 222 |
self trace:aBlock with:[:where | where errorPrintCR] |
1424 | 223 |
|
224 |
"Modified: 20.5.1996 / 10:27:37 / cg" |
|
1 | 225 |
! |
226 |
||
227 |
trace:aBlock on:aStream |
|
228 |
self trace:aBlock with:[:where | where printString printOn:aStream. |
|
159 | 229 |
aStream cr] |
1 | 230 |
! |
231 |
||
232 |
trace:aBlock with:aTraceBlock |
|
233 |
|aDebugger| |
|
234 |
||
235 |
aDebugger := self new tracingWith:aTraceBlock. |
|
241 | 236 |
ObjectMemory stepInterruptHandler:aDebugger. |
1 | 237 |
ObjectMemory flushInlineCaches. |
241 | 238 |
StepInterruptPending := 1. |
239 |
InterruptPending := 1. |
|
1 | 240 |
aBlock value. |
2 | 241 |
ObjectMemory stepInterruptHandler:nil. |
1 | 242 |
StepInterruptPending := nil. |
243 |
^ nil |
|
244 |
! ! |
|
245 |
||
19389 | 246 |
!MiniDebugger methodsFor:'accessing'! |
247 |
||
248 |
inputStream:aStream |
|
249 |
"if non-nil, the debugger will read its input from there. |
|
250 |
This allows for a miniDebugger to be used in a telnet stream (scripting)" |
|
251 |
||
252 |
inputStream := aStream. |
|
253 |
! ! |
|
254 |
||
13740 | 255 |
!MiniDebugger methodsFor:'entering'! |
1 | 256 |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
257 |
enter:aContext mayProceed:mayProceed |
13740 | 258 |
"regular entry, via unhandled exception" |
259 |
||
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
260 |
|c leaveCmd stillHere yesNo| |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
261 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
262 |
enteringContext := dot := aContext. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
263 |
nesting := 0. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
264 |
c := aContext. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
265 |
[c notNil] whileTrue:[ |
19148 | 266 |
c selector == #enter:mayProceed: ifTrue:[ |
267 |
nesting := nesting + 1. |
|
268 |
]. |
|
269 |
c := c sender. |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
270 |
]. |
74 | 271 |
|
272 |
stillHere := true. |
|
273 |
[stillHere] whileTrue:[ |
|
19148 | 274 |
AbortOperationRequest handle:[:ex | |
275 |
'** Abort caught - back in previous debugLevel' errorPrintCR. |
|
276 |
] do:[ |
|
277 |
Error handle:[:ex | |
|
278 |
StreamError handle:[:ex| |
|
279 |
"You won't see this probably - but you will see it when doing a syscall trace" |
|
280 |
'Error while processing error in MiniDebugger (Stdout closed?):' errorPrintCR. |
|
281 |
ex description errorPrintCR. |
|
282 |
OperatingSystem exit:10. |
|
283 |
] do:[ |
|
284 |
'Error while executing MiniDebugger command: ' errorPrint. |
|
285 |
ex description errorPrintCR. |
|
286 |
yesNo := self getCommand:'- (i)gnore / (p)roceed / (d)ebug / b(acktrace) ? '. |
|
287 |
yesNo == $d ifTrue:[ |
|
288 |
MiniDebugger enterWithMessage:'Debugging debugger' mayProceed:true. |
|
289 |
ex proceed |
|
290 |
]. |
|
291 |
yesNo == $p ifTrue:[ |
|
292 |
ex proceed |
|
293 |
]. |
|
294 |
yesNo == $b ifTrue:[ |
|
295 |
ex suspendedContext fullPrintAll. |
|
296 |
ex proceed |
|
297 |
]. |
|
298 |
]. |
|
299 |
] do:[ |
|
300 |
[ |
|
301 |
leaveCmd := self commandLoop. |
|
302 |
] valueUnpreemptively. |
|
303 |
]. |
|
304 |
]. |
|
1 | 305 |
|
19148 | 306 |
(leaveCmd == $s) ifTrue: [ |
307 |
self stepping. |
|
308 |
ObjectMemory flushInlineCaches. |
|
309 |
ObjectMemory stepInterruptHandler:self. |
|
310 |
stillHere := false. |
|
311 |
StepInterruptPending := 1. |
|
312 |
InterruptPending := 1 |
|
313 |
]. |
|
314 |
(leaveCmd == $t) ifTrue: [ |
|
315 |
traceBlock := [:where | where fullPrint]. |
|
316 |
ObjectMemory flushInlineCaches. |
|
317 |
ObjectMemory stepInterruptHandler:self. |
|
318 |
stillHere := false. |
|
319 |
StepInterruptPending := 1. |
|
320 |
InterruptPending := 1 |
|
321 |
]. |
|
322 |
(leaveCmd == $c) ifTrue: [ |
|
323 |
traceBlock := nil. |
|
324 |
ObjectMemory flushInlineCaches. |
|
325 |
ObjectMemory stepInterruptHandler:nil. |
|
326 |
stillHere := false. |
|
327 |
stepping := false. |
|
328 |
tracing := false. |
|
329 |
StepInterruptPending := nil. |
|
330 |
InterruptPending := nil |
|
331 |
]. |
|
332 |
((leaveCmd == $a) or:[(leaveCmd == $Y)]) ifTrue: [ |
|
333 |
"abort" |
|
334 |
traceBlock := nil. |
|
335 |
ObjectMemory flushInlineCaches. |
|
336 |
ObjectMemory stepInterruptHandler:nil. |
|
337 |
stepping := false. |
|
338 |
tracing := false. |
|
339 |
StepInterruptPending := nil. |
|
340 |
InterruptPending := nil. |
|
341 |
self doAbort. |
|
342 |
stillHere := true. |
|
343 |
"failed abort" |
|
344 |
]. |
|
1 | 345 |
]. |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
346 |
enteringContext := dot := nil. |
1 | 347 |
^ nil |
3769 | 348 |
|
13740 | 349 |
"Modified (comment): / 29-09-2011 / 09:05:57 / cg" |
618 | 350 |
! |
351 |
||
352 |
stepInterrupt |
|
13740 | 353 |
"entry via single stepinterrupt" |
354 |
||
618 | 355 |
|where| |
356 |
||
357 |
where := thisContext. "where is stepInterrupt context" |
|
358 |
where notNil ifTrue:[ |
|
16557 | 359 |
where := where sender "where is now interrupted methods context" |
618 | 360 |
]. |
361 |
stepping ifTrue:[ |
|
16557 | 362 |
where notNil ifTrue:[ |
363 |
where fullPrint |
|
364 |
] ifFalse:[ |
|
365 |
'stepInterrupt: no context' errorPrintCR |
|
366 |
]. |
|
367 |
self enter:where mayProceed:true |
|
618 | 368 |
] ifFalse:[ |
16557 | 369 |
where notNil ifTrue:[ |
370 |
traceBlock notNil ifTrue:[ |
|
371 |
traceBlock value:where |
|
372 |
] |
|
373 |
] ifFalse:[ |
|
374 |
'traceInterrupt: no context' errorPrintCR |
|
375 |
]. |
|
376 |
ObjectMemory flushInlineCaches. |
|
377 |
StepInterruptPending := 1. |
|
378 |
InterruptPending := 1 |
|
618 | 379 |
] |
1424 | 380 |
|
13740 | 381 |
"Modified: / 20-05-1996 / 10:23:11 / cg" |
382 |
"Modified (comment): / 29-09-2011 / 09:06:29 / cg" |
|
383 |
! ! |
|
384 |
||
385 |
!MiniDebugger methodsFor:'initialization'! |
|
386 |
||
387 |
initialize |
|
388 |
traceBlock := nil. |
|
389 |
tracing := false. |
|
390 |
stepping := false |
|
1 | 391 |
! ! |
392 |
||
618 | 393 |
!MiniDebugger methodsFor:'private'! |
74 | 394 |
|
618 | 395 |
findContext:aSelector |
396 |
|con| |
|
74 | 397 |
|
618 | 398 |
con := thisContext sender. |
399 |
[con notNil] whileTrue:[ |
|
400 |
(con isBlockContext not and:[con selector == aSelector]) ifTrue:[ |
|
401 |
"got it" |
|
402 |
^ con |
|
403 |
]. |
|
404 |
con := con sender |
|
74 | 405 |
]. |
618 | 406 |
^ nil |
74 | 407 |
! |
408 |
||
7701 | 409 |
garbageCollectCommand:id |
410 |
id == 3 ifTrue:[ |
|
8840 | 411 |
ObjectMemory reclaimSymbols. |
412 |
ObjectMemory compressOldSpace. |
|
7701 | 413 |
] ifFalse:[ |
8840 | 414 |
id == 2 ifTrue:[ |
415 |
ObjectMemory reclaimSymbols. |
|
416 |
] ifFalse:[ |
|
417 |
ObjectMemory garbageCollect. |
|
418 |
] |
|
7701 | 419 |
] |
420 |
! |
|
421 |
||
19389 | 422 |
getCharacter |
423 |
inputStream isNil ifTrue:[ |
|
424 |
"/ globally blocking |
|
425 |
^ Character fromUser |
|
426 |
]. |
|
427 |
^ inputStream next |
|
428 |
! |
|
429 |
||
618 | 430 |
getContext |
431 |
|backtrace| |
|
13740 | 432 |
|
618 | 433 |
backtrace := thisContext. |
434 |
(backtrace notNil) ifTrue: [ |
|
16557 | 435 |
[backtrace selector ~~ #commandLoop] whileTrue:[ |
436 |
backtrace := backtrace sender. |
|
437 |
]. |
|
438 |
"remove Debugger commandLoop frame" |
|
439 |
backtrace := backtrace sender. |
|
440 |
"remove Debugger enter frame" |
|
441 |
backtrace := backtrace sender |
|
618 | 442 |
]. |
443 |
^ backtrace |
|
13740 | 444 |
|
445 |
"Modified: / 29-09-2011 / 09:00:14 / cg" |
|
618 | 446 |
! |
74 | 447 |
|
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
448 |
moveDotDown |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
449 |
"/ sigh - must search |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
450 |
|c| |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
451 |
|
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
452 |
c := enteringContext. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
453 |
[ c notNil and:[ c sender ~~ dot ] ] whileTrue:[ |
16557 | 454 |
c := c sender. |
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
455 |
]. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
456 |
c notNil ifTrue:[ |
16557 | 457 |
dot := c. |
458 |
"/ dot fullPrint. |
|
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
459 |
] ifFalse:[ |
16557 | 460 |
'** dot is the bottom of the calling chain' errorPrintCR. |
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
461 |
]. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
462 |
! |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
463 |
|
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
464 |
moveDotUp |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
465 |
dot sender notNil ifTrue:[ |
16557 | 466 |
dot := dot sender. |
467 |
"/ dot fullPrint. |
|
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
468 |
] ifFalse:[ |
16557 | 469 |
'** dot is the top of the calling chain' errorPrintCR. |
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
470 |
]. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
471 |
! |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
472 |
|
2772 | 473 |
printBacktraceFrom:aContext |
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
474 |
|context n| |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
475 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
476 |
aContext isNil ifTrue:[ |
8840 | 477 |
'no context' errorPrintCR. |
478 |
^ self |
|
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
479 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
480 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
481 |
context := aContext. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
482 |
n := commandCount. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
483 |
[context notNil] whileTrue: [ |
8840 | 484 |
context fullPrint. |
485 |
context := context sender. |
|
486 |
n notNil ifTrue:[ |
|
487 |
n := n - 1. |
|
488 |
n <= 0 ifTrue:[ |
|
489 |
^ self |
|
490 |
] |
|
491 |
] |
|
2772 | 492 |
] |
493 |
! |
|
494 |
||
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
495 |
printDot |
8717 | 496 |
dot fullPrint. |
16249 | 497 |
' receiver: ' errorPrint. dot receiver errorPrintCR. |
498 |
' selector: ' errorPrint. dot selector errorPrintCR. |
|
499 |
' args: ' errorPrintCR. |
|
8717 | 500 |
dot args keysAndValuesDo:[:idx :eachArg | |
16557 | 501 |
' ' errorPrint. idx errorPrint. ': ' errorPrint. eachArg errorPrintCR. |
8717 | 502 |
]. |
16249 | 503 |
' vars: ' errorPrintCR. |
8717 | 504 |
dot vars keysAndValuesDo:[:idx :eachVar | |
16557 | 505 |
' ' errorPrint. idx errorPrint. ': ' errorPrint. eachVar errorPrintCR. |
8717 | 506 |
]. |
507 |
! |
|
508 |
||
509 |
printDotsMethodSource |
|
14737 | 510 |
self printDotsMethodSource:false |
511 |
! |
|
512 |
||
513 |
printDotsMethodSource:full |
|
514 |
|home mthd src pcLineNr startLnr stopLnr| |
|
8717 | 515 |
|
516 |
home := dot methodHome. |
|
517 |
mthd := home method. |
|
518 |
mthd isNil ifTrue:[ |
|
16557 | 519 |
'** no source **' errorPrintCR. |
520 |
^ self. |
|
8717 | 521 |
]. |
522 |
src := mthd source. |
|
523 |
src isNil ifTrue:[ |
|
16557 | 524 |
'** no source **' errorPrintCR. |
525 |
^ self. |
|
8717 | 526 |
]. |
14737 | 527 |
pcLineNr := dot lineNumber. |
528 |
||
8717 | 529 |
src := src asCollectionOfLines. |
14737 | 530 |
full ifTrue:[ |
16557 | 531 |
startLnr := 1. |
532 |
stopLnr := src size. |
|
14737 | 533 |
] ifFalse:[ |
16557 | 534 |
startLnr := pcLineNr-10 max:1. |
535 |
stopLnr := pcLineNr+10 min:src size. |
|
14737 | 536 |
]. |
537 |
startLnr to:stopLnr do:[:lNr | |
|
16557 | 538 |
lNr == pcLineNr ifTrue:[ |
539 |
'>> ' errorPrint. |
|
540 |
] ifFalse:[ |
|
541 |
' ' errorPrint. |
|
542 |
]. |
|
543 |
(lNr printStringLeftPaddedTo:3) errorPrint. ' ' errorPrint. |
|
544 |
(src at:lNr) errorPrintCR. |
|
8717 | 545 |
] |
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
546 |
! |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
547 |
|
618 | 548 |
stepping |
549 |
traceBlock := nil. |
|
550 |
tracing := false. |
|
551 |
stepping := true |
|
74 | 552 |
! |
553 |
||
618 | 554 |
tracingWith:aBlockOrNil |
555 |
traceBlock := aBlockOrNil. |
|
556 |
stepping := false. |
|
557 |
tracing := true |
|
558 |
! ! |
|
559 |
||
560 |
!MiniDebugger methodsFor:'user commands'! |
|
561 |
||
1 | 562 |
commandLoop |
16557 | 563 |
"read-eval commands, until one of the continue, abort or single step commands is entered; |
13740 | 564 |
return the last command character" |
565 |
||
566 |
|cmd done| |
|
1 | 567 |
|
568 |
done := false. |
|
569 |
[done] whileFalse:[ |
|
16557 | 570 |
cmd := self getCommand:nil. |
571 |
cmd isNil ifTrue:[ "/ EOF is treated like continue command |
|
572 |
cmd := $c |
|
573 |
]. |
|
574 |
done := self doCommand:cmd. |
|
1 | 575 |
]. |
576 |
^ cmd |
|
1424 | 577 |
|
13740 | 578 |
"Modified (comment): / 29-09-2011 / 09:02:24 / cg" |
1 | 579 |
! |
580 |
||
618 | 581 |
doAbort |
582 |
|con sig| |
|
583 |
||
6204
2bafef9151dd
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
5942
diff
changeset
|
584 |
(sig := AbortOperationRequest) isHandled ifTrue:[ |
8840 | 585 |
sig raise. |
586 |
'abort raise failed' errorPrintCR. |
|
618 | 587 |
]. |
588 |
||
589 |
"TEMPORARY kludge - find event handler context |
|
590 |
this will be removed, once real debugging is possible |
|
591 |
" |
|
592 |
con := self findContext:#processEvent. |
|
593 |
con isNil ifTrue:[ |
|
8840 | 594 |
con := self findContext:#dispatch. |
618 | 595 |
]. |
596 |
con notNil ifTrue:[ |
|
8840 | 597 |
"got it" |
598 |
con return. |
|
599 |
'return failed' errorPrintCR. |
|
618 | 600 |
]. |
601 |
||
1424 | 602 |
'found no context to resume' errorPrintCR. |
603 |
||
6204
2bafef9151dd
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
5942
diff
changeset
|
604 |
"Modified: / 16.11.2001 / 17:39:14 / cg" |
618 | 605 |
! |
606 |
||
13740 | 607 |
doCommand:cmd |
16557 | 608 |
"a single command; |
14797 | 609 |
return true, if command loop should be finished" |
13740 | 610 |
|
14797 | 611 |
|id proc bool| |
13740 | 612 |
|
15860 | 613 |
commandArg notEmptyOrNil ifTrue:[ |
19145 | 614 |
id := Number readFrom:commandArg onError:nil. |
615 |
id notNil ifTrue:[ |
|
616 |
proc := Process allSubInstances detect:[:p | p id == id] ifNone:nil. |
|
617 |
proc == Processor activeProcess ifTrue:[ |
|
618 |
id := proc := nil |
|
619 |
] |
|
620 |
] ifFalse:[ |
|
621 |
commandArg = '-' ifTrue:[ |
|
622 |
bool := false |
|
623 |
] ifFalse:[ |
|
624 |
commandArg = '+' ifTrue:[ |
|
625 |
bool := true |
|
626 |
] |
|
627 |
] |
|
628 |
] |
|
13740 | 629 |
]. |
630 |
||
14737 | 631 |
(cmd == $w) ifTrue:[ |
19145 | 632 |
proc notNil ifTrue:[ |
633 |
'-------- walkback of process ' errorPrint. id errorPrint. ' -------' errorPrintCR. |
|
634 |
self printBacktraceFrom:(proc suspendedContext) |
|
635 |
] ifFalse:[ |
|
636 |
id notNil ifTrue:[ |
|
637 |
'no process with id: ' errorPrint. id errorPrintCR. |
|
638 |
] ifFalse:[ |
|
639 |
'-------- walkback of current process -------' errorPrintCR. |
|
640 |
self printBacktraceFrom:(self getContext) |
|
641 |
] |
|
642 |
]. |
|
643 |
^ false |
|
13740 | 644 |
]. |
645 |
||
646 |
(cmd == $b) ifTrue:[ |
|
19145 | 647 |
proc notNil ifTrue:[ |
648 |
'-------- VM walkback of process ' errorPrint. id errorPrint. ' -------' errorPrintCR. |
|
19389 | 649 |
(Processor activeProcess environmentAt:#Stderr ifAbsent:Stderr) == Stderr ifTrue:[ |
650 |
ObjectMemory printStackBacktraceFrom:(proc suspendedContext) |
|
651 |
] ifFalse:[ |
|
652 |
self printBacktraceFrom:(proc suspendedContext) |
|
653 |
"/ proc suspendedContext fullPrintAllOn:(Processor activeProcess environmentAt:#Stderr) |
|
654 |
]. |
|
19145 | 655 |
] ifFalse:[ |
656 |
id notNil ifTrue:[ |
|
657 |
'no process with id: ' errorPrint. id errorPrintCR. |
|
658 |
] ifFalse:[ |
|
659 |
'-------- VM walkback of current process -------' errorPrintCR. |
|
19389 | 660 |
(Processor activeProcess environmentAt:#Stderr ifAbsent:Stderr) == Stderr ifTrue:[ |
661 |
ObjectMemory printStackBacktrace |
|
662 |
] ifFalse:[ |
|
663 |
"/ self printBacktraceFrom:(self getContext) |
|
664 |
thisContext fullPrintAllOn:(Processor activeProcess environmentAt:#Stderr) |
|
665 |
] |
|
19145 | 666 |
] |
667 |
]. |
|
668 |
^ false |
|
13740 | 669 |
]. |
670 |
||
671 |
(cmd == $S) ifTrue:[ |
|
19145 | 672 |
'saving "crash.img"...' errorPrint. |
673 |
ObjectMemory writeCrashImage. |
|
674 |
'done.' errorPrintCR. |
|
675 |
^ false |
|
13740 | 676 |
]. |
15859 | 677 |
(cmd == $C) ifTrue:[ |
19145 | 678 |
|changesFilename| |
15859 | 679 |
|
19145 | 680 |
changesFilename := Timestamp now |
681 |
printStringFormat:'changes_%(year)-%(month)-%(day)__%h:%m:%s.chg'. |
|
682 |
OperatingSystem isMSWINDOWSlike ifTrue:[ changesFilename replaceAll:$: with:$_ ]. |
|
15861 | 683 |
|
19145 | 684 |
ChangeSet current fileOutAs: changesFilename. |
685 |
('saved session changes to "',changesFilename,'".') errorPrintCR. |
|
686 |
^ false |
|
15859 | 687 |
]. |
13740 | 688 |
|
689 |
(cmd == $B) ifTrue:[ |
|
19145 | 690 |
self printAllBacktraces. |
691 |
^ false |
|
13740 | 692 |
]. |
693 |
||
694 |
(cmd == $P) ifTrue:[ |
|
19145 | 695 |
self showProcesses:#all. |
696 |
^ false |
|
14797 | 697 |
]. |
698 |
(cmd == $p) ifTrue:[ |
|
19145 | 699 |
self showProcesses:#live. |
700 |
^ false |
|
13740 | 701 |
]. |
702 |
||
703 |
(cmd == $r) ifTrue:[ |
|
19145 | 704 |
dot receiver errorPrintCR. |
705 |
^ false |
|
13740 | 706 |
]. |
707 |
||
708 |
(cmd == $i) ifTrue:[ |
|
19389 | 709 |
|inspectedObject| |
710 |
||
19145 | 711 |
(commandArg ? '') withoutSeparators notEmpty ifTrue:[ |
19389 | 712 |
inspectedObject := (Parser evaluate:commandArg). |
19145 | 713 |
] ifFalse:[ |
19389 | 714 |
inspectedObject := (dot receiver). |
19145 | 715 |
]. |
19389 | 716 |
MiniInspector openOn:inspectedObject input:inputStream. |
19145 | 717 |
^ false |
13740 | 718 |
]. |
719 |
||
720 |
(cmd == $I) ifTrue:[ |
|
19145 | 721 |
self interpreterLoopWith:nil. |
722 |
^ false |
|
13740 | 723 |
]. |
15705 | 724 |
(cmd == $E) ifTrue:[ |
19145 | 725 |
Parser evaluate:commandArg. |
726 |
^ false |
|
13740 | 727 |
]. |
15705 | 728 |
(cmd == $e) ifTrue:[ |
19145 | 729 |
(Parser evaluate:commandArg) errorPrintCR. |
730 |
^ false |
|
15691 | 731 |
]. |
13740 | 732 |
|
733 |
(cmd == $c) ifTrue:[^ true]. |
|
734 |
(cmd == $s) ifTrue:[^ true]. |
|
735 |
(cmd == $t) ifTrue:[^ true]. |
|
736 |
(cmd == $a) ifTrue:[^ true]. |
|
737 |
||
738 |
(cmd == $u) ifTrue:[ |
|
19145 | 739 |
stepping := false. |
740 |
tracing := false. |
|
741 |
Processor activeProcess vmTrace:false. |
|
742 |
^ false |
|
13740 | 743 |
]. |
744 |
||
14797 | 745 |
(cmd == $h) ifTrue:[ |
19145 | 746 |
(bool notNil) ifTrue:[ |
747 |
Smalltalk ignoreHalt:bool not. |
|
748 |
]. |
|
749 |
'halts are ' errorPrint. (Smalltalk ignoreHalt ifTrue:['disabled'] ifFalse:['enabled']) errorPrintCR. |
|
750 |
^ false |
|
14797 | 751 |
]. |
752 |
||
13740 | 753 |
(cmd == $R) ifTrue:[ |
19145 | 754 |
proc notNil ifTrue:[ |
755 |
proc resume. |
|
756 |
]. |
|
757 |
^ false |
|
13740 | 758 |
]. |
759 |
||
760 |
(cmd == $T) ifTrue:[ |
|
19145 | 761 |
proc notNil ifTrue:[ |
762 |
proc terminate. |
|
763 |
] ifFalse:[ |
|
764 |
id notNil ifTrue:[ |
|
765 |
'no process with id: ' errorPrint. id errorPrintCR. |
|
766 |
] ifFalse:[ |
|
767 |
Processor terminateActive |
|
768 |
] |
|
769 |
]. |
|
770 |
^ false |
|
13740 | 771 |
]. |
772 |
||
773 |
(cmd == $W) ifTrue:[ |
|
19145 | 774 |
proc notNil ifTrue:[ |
775 |
'stopping process id: ' errorPrint. id errorPrintCR. |
|
776 |
proc stop. |
|
777 |
] ifFalse:[ |
|
778 |
'invalid process id: ' errorPrint. id errorPrintCR. |
|
779 |
]. |
|
780 |
^ false |
|
13740 | 781 |
]. |
782 |
||
783 |
(cmd == $a) ifTrue:[ |
|
19145 | 784 |
"without id-arg, this is handled by caller" |
785 |
proc notNil ifTrue:[ |
|
786 |
'aborting process id: ' errorPrint. id errorPrintCR. |
|
787 |
proc interruptWith:[AbortOperationRequest raise] |
|
788 |
] ifFalse:[ |
|
789 |
'aborting' errorPrintCR. |
|
790 |
]. |
|
791 |
^ false |
|
13740 | 792 |
]. |
793 |
||
794 |
(cmd == $Q) ifTrue:[ |
|
19145 | 795 |
proc notNil ifTrue:[ |
796 |
proc terminateNoSignal. |
|
797 |
] ifFalse:[ |
|
798 |
id notNil ifTrue:[ |
|
799 |
'no process with id: ' errorPrint. id errorPrintCR. |
|
800 |
] ifFalse:[ |
|
801 |
Processor terminateActiveNoSignal |
|
802 |
] |
|
803 |
]. |
|
804 |
^ false |
|
13740 | 805 |
]. |
806 |
||
807 |
(cmd == $g) ifTrue:[ |
|
19145 | 808 |
self garbageCollectCommand:id. |
809 |
^ false |
|
13740 | 810 |
]. |
811 |
||
812 |
(cmd == $U) ifTrue:[ |
|
19145 | 813 |
MessageTracer unwrapAllMethods. |
814 |
^ false |
|
13740 | 815 |
]. |
15929 | 816 |
(cmd == $D) ifTrue:[ |
19145 | 817 |
Breakpoint disableAllBreakpoints. |
818 |
^ false |
|
15929 | 819 |
]. |
13740 | 820 |
(cmd == $X) ifTrue:[ |
19145 | 821 |
Smalltalk fatalAbort. |
822 |
"/ not reached |
|
823 |
^ false |
|
13740 | 824 |
]. |
825 |
(cmd == $x) ifTrue:[ |
|
19145 | 826 |
OperatingSystem exit. |
827 |
"/ not reached |
|
828 |
^ false |
|
829 |
]. |
|
19146 | 830 |
(cmd == $Y) ifTrue:[ |
19925 | 831 |
Display := nil. |
19147 | 832 |
Smalltalk openDisplay. |
833 |
NewLauncher open. |
|
834 |
^ true |
|
13740 | 835 |
]. |
836 |
||
837 |
(cmd == $.) ifTrue:[self printDot. ^ false ]. |
|
14737 | 838 |
(cmd == $l) ifTrue:[self printDotsMethodSource:false. ^ false ]. |
839 |
(cmd == $L) ifTrue:[self printDotsMethodSource:true. ^ false ]. |
|
840 |
(cmd == $-) ifTrue:[self moveDotUp. self printDot. ^ false ]. |
|
841 |
(cmd == $+) ifTrue:[self moveDotDown. self printDot. ^ false ]. |
|
15195 | 842 |
(cmd == $?) ifTrue:[ |
19145 | 843 |
commandArg notEmpty ifTrue:[ |
844 |
self helpOn:commandArg. ^ false |
|
845 |
] |
|
15195 | 846 |
]. |
13740 | 847 |
|
848 |
"/ avoid usage print if return was typed ... |
|
849 |
((cmd == Character return) |
|
850 |
or:[cmd == Character linefeed]) ifTrue:[^ false]. |
|
851 |
||
852 |
self showValidCommandHelp. |
|
853 |
^ false. |
|
854 |
||
855 |
"Created: / 29-09-2011 / 08:58:47 / cg" |
|
856 |
! |
|
857 |
||
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
858 |
getCommand:prompt |
3126
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
859 |
"/ Screen notNil ifTrue:[ |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
860 |
"/ Screen allScreens do:[:aScreen | |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
861 |
"/ aScreen ungrabPointer. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
862 |
"/ aScreen ungrabKeyboard. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
863 |
"/ ]. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
864 |
"/ ]. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
865 |
|
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
866 |
Display notNil ifTrue:[ |
19389 | 867 |
Display ungrabPointer. |
868 |
Display ungrabKeyboard. |
|
852
5c4a0585ba0b
ungrab pointer for every input
Claus Gittinger <cg@exept.de>
parents:
720
diff
changeset
|
869 |
]. |
5c4a0585ba0b
ungrab pointer for every input
Claus Gittinger <cg@exept.de>
parents:
720
diff
changeset
|
870 |
|
8840 | 871 |
(prompt |
19389 | 872 |
? (nesting == 0 ifTrue:[ |
873 |
'MiniDebugger> ' |
|
874 |
] ifFalse:[ |
|
875 |
'MiniDebugger' , nesting printString , '>' |
|
876 |
])) errorPrint. |
|
93 | 877 |
|
7706 | 878 |
UserInterrupt handle:[:ex | |
19389 | 879 |
ex restart |
159 | 880 |
] do:[ |
19389 | 881 |
|c cmd arg cnt| |
3700 | 882 |
|
19389 | 883 |
cmd := self getCharacter. |
884 |
cmd isNil ifTrue:[ |
|
885 |
'<EOF>' errorPrintCR. |
|
886 |
" |
|
887 |
mhmh end-of-file; |
|
20420 | 888 |
return a 'c' (for continue); hope that's ok. |
19389 | 889 |
" |
890 |
cmd := $c |
|
891 |
]. |
|
93 | 892 |
|
19389 | 893 |
cnt := nil. |
894 |
(cmd isDigit) ifTrue:[ |
|
895 |
cnt := 0. |
|
896 |
[ |
|
897 |
cnt := (cnt * 10) + cmd digitValue. |
|
898 |
cmd := self getCharacter |
|
899 |
] doWhile:[cmd notNil and:[cmd isDigit]]. |
|
900 |
[cmd notNil and:[cmd == Character space]] whileTrue:[ |
|
901 |
cmd := self getCharacter |
|
902 |
]. |
|
903 |
cmd isNil ifTrue:[ '<EOF>' errorPrintCR ]. |
|
904 |
]. |
|
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
905 |
|
19389 | 906 |
" |
907 |
collect to end-of-line in arg |
|
908 |
" |
|
909 |
c := cmd. |
|
910 |
arg := ''. |
|
911 |
[c isNil or:[c isEndOfLineCharacter]] whileFalse: [ |
|
912 |
arg := arg copyWith:c. |
|
913 |
c := self getCharacter. |
|
914 |
c isNil ifTrue:[ '<EOF>' errorPrintCR ]. |
|
915 |
]. |
|
916 |
commandArg := (arg copyFrom:2) withoutSeparators. |
|
917 |
command := cmd. |
|
918 |
commandCount := cnt. |
|
1 | 919 |
]. |
3700 | 920 |
^ command |
976 | 921 |
|
3700 | 922 |
"Modified: / 31.7.1998 / 16:11:01 / cg" |
1 | 923 |
! |
924 |
||
15195 | 925 |
helpOn:commandArg |
926 |
|args className sym val match showMethod| |
|
927 |
||
928 |
commandArg withoutSeparators isEmpty ifTrue:[ |
|
16557 | 929 |
'usage: H className [methodPattern]' errorPrintCR. |
930 |
^self |
|
15195 | 931 |
]. |
932 |
args := commandArg asCollectionOfWords. |
|
933 |
className := args first. |
|
16557 | 934 |
|
15195 | 935 |
(sym := className asSymbolIfInterned) isNil ifTrue:[ |
16557 | 936 |
'no such class' errorPrintCR. |
937 |
^ self. |
|
15195 | 938 |
]. |
16249 | 939 |
val := Smalltalk at:sym ifAbsent:['no such class' errorPrintCR. ^ self.]. |
15195 | 940 |
val isBehavior ifFalse:[ |
16557 | 941 |
'not a class: ' errorPrint. className errorPrintCR. |
942 |
val := val class. |
|
943 |
'showing help for ' errorPrint. val name errorPrintCR. |
|
15195 | 944 |
]. |
945 |
args size > 1 ifTrue:[ |
|
16557 | 946 |
match := args at:2 |
15195 | 947 |
] ifFalse:[ |
16557 | 948 |
match := '*' |
15195 | 949 |
]. |
950 |
||
16557 | 951 |
showMethod := |
952 |
[:sel :cls | |
|
953 |
|mthd| |
|
15195 | 954 |
|
16557 | 955 |
((match includesMatchCharacters and:[ sel matches:match caseSensitive:false]) |
956 |
or:[ sel asLowercase startsWith:match asLowercase ]) ifTrue:[ |
|
957 |
mthd := cls compiledMethodAt:sel. |
|
958 |
mthd category ~= 'documentation' ifTrue:[ |
|
959 |
sel errorPrintCR. |
|
960 |
(mthd comment ? '') asStringCollection do:[:l | |
|
961 |
' ' errorPrint. l withoutSeparators errorPrintCR. |
|
962 |
]. |
|
963 |
'' errorPrintCR |
|
964 |
]. |
|
965 |
]. |
|
966 |
]. |
|
15195 | 967 |
|
968 |
val theMetaclass selectors copy sort do:[:sel | |
|
16557 | 969 |
showMethod value:sel value:val theMetaclass |
15195 | 970 |
]. |
971 |
val theNonMetaclass selectors copy sort do:[:sel | |
|
16557 | 972 |
showMethod value:sel value:val theNonMetaclass |
15195 | 973 |
]. |
974 |
! |
|
975 |
||
1 | 976 |
interpreterLoopWith:anObject |
16079 | 977 |
'MinDebugger read-eval-print loop; exit with "#exit"; help with "?"' printCR. |
16557 | 978 |
ReadEvalPrintLoop new |
19389 | 979 |
doChunkFormat:false; |
980 |
error:(Processor activeProcess stderr); |
|
981 |
prompt:'mDBG > '; |
|
982 |
readEvalPrintLoop. |
|
3700 | 983 |
|
10630 | 984 |
"/ |line done rslt| |
985 |
"/ |
|
986 |
"/ 'read-eval-print loop; exit with empty line' printCR. |
|
987 |
"/ '' printCR. |
|
988 |
"/ |
|
989 |
"/ done := false. |
|
990 |
"/ [done] whileFalse:[ |
|
991 |
"/ '> ' print. |
|
992 |
"/ |
|
993 |
"/ line := Stdin nextLine. |
|
994 |
"/ (line size == 0) ifTrue:[ |
|
995 |
"/ done := true |
|
996 |
"/ ] ifFalse:[ |
|
997 |
"/ "/ rslt := Compiler evaluate:line |
|
998 |
"/ "/ receiver:anObject |
|
999 |
"/ "/ notifying:nil. |
|
1000 |
"/ |
|
1001 |
"/ rslt := Compiler |
|
1002 |
"/ evaluate:line |
|
1003 |
"/ in:dot |
|
1004 |
"/ receiver:dot receiver |
|
1005 |
"/ notifying:self "/ nil |
|
1006 |
"/ ifFail:[]. |
|
1007 |
"/ rslt printCR. |
|
1008 |
"/ ] |
|
1009 |
"/ ] |
|
1424 | 1010 |
|
3700 | 1011 |
"Modified: / 31.7.1998 / 16:01:47 / cg" |
618 | 1012 |
! |
1013 |
||
2772 | 1014 |
printAllBacktraces |
1015 |
Process allInstancesDo:[:p | |
|
16557 | 1016 |
(p isActive not |
1017 |
and:[p isDead not]) ifTrue:[ |
|
1018 |
'---------------------------------------------------------' errorPrintCR. |
|
1019 |
' proc id=' errorPrint. p id errorPrint. |
|
1020 |
' name=''' errorPrint. p name errorPrint. |
|
1021 |
''' createdBy: ' errorPrint. p creatorId errorPrint. |
|
1022 |
' state=' errorPrint. p state errorPrint. |
|
1023 |
' prio=' errorPrint. p priority errorPrintCR. |
|
1024 |
'' errorPrintCR. '' errorPrintCR. |
|
2772 | 1025 |
|
16557 | 1026 |
self printBacktraceFrom:(p suspendedContext) |
1027 |
] |
|
2772 | 1028 |
] |
1029 |
! |
|
1030 |
||
618 | 1031 |
showProcesses |
14797 | 1032 |
self showProcesses:#all |
1033 |
! |
|
1034 |
||
1035 |
showProcesses:how |
|
618 | 1036 |
|active| |
1037 |
||
1038 |
active := Processor activeProcess. |
|
16249 | 1039 |
'current id=' errorPrint. active id errorPrint. ' name=''' errorPrint. active name errorPrint. '''' errorPrintCR. |
618 | 1040 |
|
16094 | 1041 |
(Process allSubInstances sort:[:a :b | (a id ? -1)<(b id ? -1)]) do:[:p | |
16557 | 1042 |
|doShow| |
14797 | 1043 |
|
16557 | 1044 |
doShow := (how == #all). |
1045 |
doShow := doShow or:[ (how == #dead) and:[ p isDead ]]. |
|
1046 |
doShow := doShow or:[ (how ~~ #dead) and:[ p isDead not ]]. |
|
1047 |
doShow ifTrue:[ |
|
1048 |
'proc id=' errorPrint. (p id printStringPaddedTo:6) errorPrint. |
|
1049 |
(p state printStringPaddedTo:10) errorPrint. |
|
1050 |
' pri=' errorPrint. (p priority printStringPaddedTo:2) errorPrint. |
|
1051 |
' creator:' errorPrint. (p creatorId printStringPaddedTo:5) errorPrint. |
|
1052 |
' group:' errorPrint. (p processGroupId printStringPaddedTo:5) errorPrint. |
|
1053 |
' sys:' errorPrint. (p isSystemProcess ifTrue:'y' ifFalse:'n') errorPrint. |
|
1054 |
' ui:' errorPrint. (p isGUIProcess ifTrue:'y' ifFalse:'n') errorPrint. |
|
1055 |
' name=''' errorPrint. p name errorPrint. |
|
1056 |
'''' errorPrintCR. |
|
1057 |
] |
|
618 | 1058 |
] |
1424 | 1059 |
|
3700 | 1060 |
"Modified: / 31.7.1998 / 16:30:19 / cg" |
7701 | 1061 |
! |
1062 |
||
1063 |
showValidCommandHelp |
|
19144 | 1064 |
'valid commands: |
16095 | 1065 |
c ........ continue |
1066 |
s ........ step |
|
1067 |
t ........ trace (continue with trace) |
|
1068 |
a [id] ... abort (i.e. raise abort signal) in (current) process |
|
1069 |
T [id] ... terminate (current) process |
|
1070 |
W [id] ... stop (current) process |
|
1071 |
R [id] ... resume (current) process |
|
1072 |
Q [id] ... quick terminate (current) process - no unwinds or cleanup |
|
7701 | 1073 |
|
16095 | 1074 |
p ........ list processes ("P" for full list) |
1075 |
w [id] ... walkback (of current/process with id) |
|
16557 | 1076 |
b [id] ... full (VM) backtrace with more detail |
16095 | 1077 |
B ........ backtrace of all other processes |
7701 | 1078 |
|
16095 | 1079 |
U ........ unwrap all traced/breakpointed methods |
1080 |
D ........ disable all line breakpoints |
|
1081 |
h [-/+] .. disable/enable halts |
|
1082 |
g ........ collect all garbage |
|
1083 |
g 2 ...... collect all garbage & reclaim symbols |
|
1084 |
g 3 ...... collect all garbage, reclaim symbols and compress |
|
7701 | 1085 |
|
16095 | 1086 |
S ........ save snapshot into "crash.img" |
1087 |
C ........ save session changes to a separate change file |
|
1088 |
x ........ exit Smalltalk ("X" to exit with core dump) |
|
19149 | 1089 |
Y ........ reopen display, reopen launcher |
7701 | 1090 |
|
16095 | 1091 |
. ........ print dot (the current context) |
1092 |
- ........ move dot up (sender) |
|
1093 |
+ ........ move dot down (called context) |
|
1094 |
l ........ list dot''s method source around PC ("L" for full list) |
|
7701 | 1095 |
|
16095 | 1096 |
r ........ receiver (in dot) printString |
1097 |
i [expr] . inspect expression (or receiver in dot) |
|
1098 |
I ........ interpreter (expression evaluator) |
|
19144 | 1099 |
e expr ... evaluate expression & print result ("E" to not print) |
1100 |
? c [p] .. help on class c (selectors matching p) |
|
14798 | 1101 |
' errorPrintCR. |
7701 | 1102 |
|
14798 | 1103 |
(XWorkstation notNil and:[ Screen default isKindOf:XWorkstation ]) ifTrue:[ |
1104 |
' To repair a broken X-Connection, enter an interpreter (enter "I") and evaluate: |
|
7701 | 1105 |
Display := XWorkstation new. |
14798 | 1106 |
Display initializeFor:''localhost:0''. |
7701 | 1107 |
Display startDispatch. |
1108 |
NewLauncher openOnDevice:Display. |
|
16095 | 1109 |
#exit |
14798 | 1110 |
then enter "c" to continue; a NewLauncher should pop up soon. |
7701 | 1111 |
' errorPrintCR |
14798 | 1112 |
] |
15859 | 1113 |
|
15930 | 1114 |
"Modified: / 03-02-2014 / 10:38:36 / cg" |
1 | 1115 |
! ! |
618 | 1116 |
|
658 | 1117 |
!MiniDebugger class methodsFor:'documentation'! |
1118 |
||
1119 |
version |
|
18681 | 1120 |
^ '$Header$' |
13113 | 1121 |
! |
1122 |
||
1123 |
version_CVS |
|
18681 | 1124 |
^ '$Header$' |
658 | 1125 |
! ! |
16626 | 1126 |