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