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