author | Claus Gittinger <cg@exept.de> |
Fri, 23 Aug 2013 19:28:01 +0200 | |
changeset 15691 | 80911ed523c0 |
parent 15195 | e92dd9929b4f |
child 15705 | 4e118b084e01 |
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' |
14798 | 17 |
classVariableNames:'TheOneAndOnlyDebugger 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 |
|
42 |
the graphical debugger). |
|
93 | 43 |
Also, if an interrupt occurs within the debuger, this one is called |
44 |
for. |
|
1297 | 45 |
|
13740 | 46 |
MiniDebugger enter |
47 |
||
1297 | 48 |
[author:] |
13740 | 49 |
Claus Gittinger |
89 | 50 |
" |
51 |
! ! |
|
1 | 52 |
|
618 | 53 |
!MiniDebugger class methodsFor:'instance creation'! |
54 |
||
11534 | 55 |
enter |
56 |
"enter a miniDebugger" |
|
57 |
||
58 |
^ self |
|
59 |
enter:thisContext sender |
|
60 |
withMessage:'MiniDebugger' |
|
61 |
mayProceed:true |
|
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 | |
14798 | 72 |
ex return |
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
73 |
] do:[ |
14798 | 74 |
thisContext isRecursive ifTrue:[ |
75 |
"/ 'recursive error in debugger ignored' errorPrintCR. |
|
76 |
^ self |
|
77 |
]. |
|
78 |
||
79 |
aString printCR. |
|
80 |
Processor notNil ifTrue:[ |
|
81 |
active := Processor activeProcess. |
|
82 |
'process: id=' print. active id print. |
|
83 |
' name=' print. active name printCR. |
|
4960 | 84 |
|
14798 | 85 |
'context: ' print. aContext printString printCR. |
86 |
(con := aContext) notNil ifTrue:[ |
|
87 |
con := con sender. |
|
88 |
' ......: ' print. con printString printCR. |
|
89 |
[con notNil] whileTrue:[ |
|
90 |
sender := con sender. |
|
91 |
(sender notNil and:[sender selector == con selector]) ifTrue:[ |
|
92 |
' ......: ' print. sender printString printCR. |
|
93 |
' ......: [** intermediate recursive contexts skipped **]' printCR. |
|
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 |
' ......: ' print. con printString printCR. |
|
103 |
] |
|
104 |
] |
|
105 |
]. |
|
106 |
NotFirstTimeEntered ~~ true ifTrue:[ |
|
107 |
NotFirstTimeEntered := true. |
|
108 |
'Type "c" to proceed, "?" for help' printCR. |
|
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:[ |
14798 | 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 |
|
14798 | 119 |
Error handle:[:ex | |
120 |
'cannot raise Abort - exiting ...' errorPrintCR. |
|
121 |
Smalltalk exit. |
|
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:[ |
14798 | 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:[ |
14798 | 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 |
|
143 |
enter:ex returnableSuspendedContext |
|
15122
7fc1cae5a632
use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents:
14964
diff
changeset
|
144 |
withMessage:(ex creator name,': ',ex descriptionForDebugger) |
11235 | 145 |
mayProceed:(ex mayProceed). |
146 |
! |
|
147 |
||
4572 | 148 |
enterWithMessage:aString mayProceed:mayProceed |
149 |
"enter a miniDebugger" |
|
150 |
||
11235 | 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 |
|
1424 | 202 |
self trace:aBlock with:[:where | where printCR] |
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:[ |
10374 | 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:[ |
|
10374 | 245 |
AbortOperationRequest handle:[:ex | |
246 |
'** Abort cought - back in previous debugLevel' printCR. |
|
247 |
] do:[ |
|
248 |
Error handle:[:ex | |
|
13740 | 249 |
'Error while executing MiniDebugger command: ' print. |
10374 | 250 |
ex description printCR. |
251 |
yesNo := self getCommand:'- (i)gnore / (p)roceed / (d)ebug / b(acktrace) ? '. |
|
252 |
yesNo == $d ifTrue:[ |
|
253 |
MiniDebugger enterWithMessage:'Debugging debugger' mayProceed:true. |
|
254 |
ex proceed |
|
255 |
]. |
|
256 |
yesNo == $p ifTrue:[ |
|
257 |
ex proceed |
|
258 |
]. |
|
259 |
yesNo == $b ifTrue:[ |
|
260 |
ex suspendedContext fullPrintAll. |
|
261 |
ex proceed |
|
262 |
]. |
|
263 |
] do:[ |
|
264 |
[ |
|
265 |
leaveCmd := self commandLoop. |
|
266 |
] valueUnpreemptively. |
|
267 |
]. |
|
268 |
]. |
|
1 | 269 |
|
10374 | 270 |
(leaveCmd == $s) ifTrue: [ |
271 |
self stepping. |
|
272 |
ObjectMemory flushInlineCaches. |
|
273 |
ObjectMemory stepInterruptHandler:self. |
|
274 |
stillHere := false. |
|
275 |
StepInterruptPending := 1. |
|
276 |
InterruptPending := 1 |
|
277 |
]. |
|
278 |
(leaveCmd == $t) ifTrue: [ |
|
279 |
traceBlock := [:where | where fullPrint]. |
|
280 |
ObjectMemory flushInlineCaches. |
|
281 |
ObjectMemory stepInterruptHandler:self. |
|
282 |
stillHere := false. |
|
283 |
StepInterruptPending := 1. |
|
284 |
InterruptPending := 1 |
|
285 |
]. |
|
286 |
(leaveCmd == $c) ifTrue: [ |
|
287 |
traceBlock := nil. |
|
15195 | 288 |
ObjectMemory flushInlineCaches. |
289 |
ObjectMemory stepInterruptHandler:nil. |
|
10374 | 290 |
stillHere := false. |
291 |
stepping := false. |
|
292 |
tracing := false. |
|
293 |
StepInterruptPending := nil. |
|
294 |
InterruptPending := nil |
|
295 |
]. |
|
296 |
(leaveCmd == $a) ifTrue: [ |
|
297 |
"abort" |
|
15195 | 298 |
ObjectMemory flushInlineCaches. |
299 |
ObjectMemory stepInterruptHandler:nil. |
|
10374 | 300 |
stepping := false. |
301 |
tracing := false. |
|
302 |
StepInterruptPending := nil. |
|
303 |
InterruptPending := nil. |
|
304 |
self doAbort. |
|
305 |
stillHere := true. |
|
306 |
"failed abort" |
|
307 |
]. |
|
1 | 308 |
]. |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
309 |
enteringContext := dot := nil. |
1 | 310 |
^ nil |
3769 | 311 |
|
13740 | 312 |
"Modified (comment): / 29-09-2011 / 09:05:57 / cg" |
618 | 313 |
! |
314 |
||
315 |
stepInterrupt |
|
13740 | 316 |
"entry via single stepinterrupt" |
317 |
||
618 | 318 |
|where| |
319 |
||
320 |
where := thisContext. "where is stepInterrupt context" |
|
321 |
where notNil ifTrue:[ |
|
13740 | 322 |
where := where sender "where is now interrupted methods context" |
618 | 323 |
]. |
324 |
stepping ifTrue:[ |
|
13740 | 325 |
where notNil ifTrue:[ |
326 |
where fullPrint |
|
327 |
] ifFalse:[ |
|
328 |
'stepInterrupt: no context' errorPrintCR |
|
329 |
]. |
|
330 |
self enter:where mayProceed:true |
|
618 | 331 |
] ifFalse:[ |
13740 | 332 |
where notNil ifTrue:[ |
333 |
traceBlock notNil ifTrue:[ |
|
334 |
traceBlock value:where |
|
335 |
] |
|
336 |
] ifFalse:[ |
|
337 |
'traceInterrupt: no context' errorPrintCR |
|
338 |
]. |
|
339 |
ObjectMemory flushInlineCaches. |
|
340 |
StepInterruptPending := 1. |
|
341 |
InterruptPending := 1 |
|
618 | 342 |
] |
1424 | 343 |
|
13740 | 344 |
"Modified: / 20-05-1996 / 10:23:11 / cg" |
345 |
"Modified (comment): / 29-09-2011 / 09:06:29 / cg" |
|
346 |
! ! |
|
347 |
||
348 |
!MiniDebugger methodsFor:'initialization'! |
|
349 |
||
350 |
initialize |
|
351 |
traceBlock := nil. |
|
352 |
tracing := false. |
|
353 |
stepping := false |
|
1 | 354 |
! ! |
355 |
||
618 | 356 |
!MiniDebugger methodsFor:'private'! |
74 | 357 |
|
618 | 358 |
findContext:aSelector |
359 |
|con| |
|
74 | 360 |
|
618 | 361 |
con := thisContext sender. |
362 |
[con notNil] whileTrue:[ |
|
363 |
(con isBlockContext not and:[con selector == aSelector]) ifTrue:[ |
|
364 |
"got it" |
|
365 |
^ con |
|
366 |
]. |
|
367 |
con := con sender |
|
74 | 368 |
]. |
618 | 369 |
^ nil |
74 | 370 |
! |
371 |
||
7701 | 372 |
garbageCollectCommand:id |
373 |
id == 3 ifTrue:[ |
|
8840 | 374 |
ObjectMemory reclaimSymbols. |
375 |
ObjectMemory compressOldSpace. |
|
7701 | 376 |
] ifFalse:[ |
8840 | 377 |
id == 2 ifTrue:[ |
378 |
ObjectMemory reclaimSymbols. |
|
379 |
] ifFalse:[ |
|
380 |
ObjectMemory garbageCollect. |
|
381 |
] |
|
7701 | 382 |
] |
383 |
! |
|
384 |
||
618 | 385 |
getContext |
386 |
|backtrace| |
|
13740 | 387 |
|
618 | 388 |
backtrace := thisContext. |
389 |
(backtrace notNil) ifTrue: [ |
|
13740 | 390 |
[backtrace selector ~~ #commandLoop] whileTrue:[ |
391 |
backtrace := backtrace sender. |
|
392 |
]. |
|
393 |
"remove Debugger commandLoop frame" |
|
394 |
backtrace := backtrace sender. |
|
395 |
"remove Debugger enter frame" |
|
396 |
backtrace := backtrace sender |
|
618 | 397 |
]. |
398 |
^ backtrace |
|
13740 | 399 |
|
400 |
"Modified: / 29-09-2011 / 09:00:14 / cg" |
|
618 | 401 |
! |
74 | 402 |
|
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
403 |
moveDotDown |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
404 |
"/ sigh - must search |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
405 |
|c| |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
406 |
|
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
407 |
c := enteringContext. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
408 |
[ c notNil and:[ c sender ~~ dot ] ] whileTrue:[ |
14737 | 409 |
c := c sender. |
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
410 |
]. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
411 |
c notNil ifTrue:[ |
14737 | 412 |
dot := c. |
413 |
"/ dot fullPrint. |
|
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
414 |
] ifFalse:[ |
14737 | 415 |
'** dot is the bottom of the calling chain' printCR. |
5942
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 |
! |
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 |
moveDotUp |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
420 |
dot sender notNil ifTrue:[ |
14737 | 421 |
dot := dot sender. |
422 |
"/ dot fullPrint. |
|
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
423 |
] ifFalse:[ |
14737 | 424 |
'** dot is the top of the calling chain' printCR. |
5942
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 |
|
2772 | 428 |
printBacktraceFrom:aContext |
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
429 |
|context n| |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
430 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
431 |
aContext isNil ifTrue:[ |
8840 | 432 |
'no context' errorPrintCR. |
433 |
^ self |
|
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
434 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
435 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
436 |
context := aContext. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
437 |
n := commandCount. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
438 |
[context notNil] whileTrue: [ |
8840 | 439 |
context fullPrint. |
440 |
context := context sender. |
|
441 |
n notNil ifTrue:[ |
|
442 |
n := n - 1. |
|
443 |
n <= 0 ifTrue:[ |
|
444 |
^ self |
|
445 |
] |
|
446 |
] |
|
2772 | 447 |
] |
448 |
! |
|
449 |
||
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
450 |
printDot |
8717 | 451 |
dot fullPrint. |
14737 | 452 |
' receiver: ' print. dot receiver printCR. |
453 |
' selector: ' print. dot selector printCR. |
|
454 |
' args: ' printCR. |
|
8717 | 455 |
dot args keysAndValuesDo:[:idx :eachArg | |
14737 | 456 |
' ' print. idx print. ': ' print. eachArg printCR. |
8717 | 457 |
]. |
14737 | 458 |
' vars: ' printCR. |
8717 | 459 |
dot vars keysAndValuesDo:[:idx :eachVar | |
14737 | 460 |
' ' print. idx print. ': ' print. eachVar printCR. |
8717 | 461 |
]. |
462 |
! |
|
463 |
||
464 |
printDotsMethodSource |
|
14737 | 465 |
self printDotsMethodSource:false |
466 |
! |
|
467 |
||
468 |
printDotsMethodSource:full |
|
469 |
|home mthd src pcLineNr startLnr stopLnr| |
|
8717 | 470 |
|
471 |
home := dot methodHome. |
|
472 |
mthd := home method. |
|
473 |
mthd isNil ifTrue:[ |
|
14737 | 474 |
'** no source **' printCR. |
475 |
^ self. |
|
8717 | 476 |
]. |
477 |
src := mthd source. |
|
478 |
src isNil ifTrue:[ |
|
14737 | 479 |
'** no source **' printCR. |
480 |
^ self. |
|
8717 | 481 |
]. |
14737 | 482 |
pcLineNr := dot lineNumber. |
483 |
||
8717 | 484 |
src := src asCollectionOfLines. |
14737 | 485 |
full ifTrue:[ |
486 |
startLnr := 1. |
|
487 |
stopLnr := src size. |
|
488 |
] ifFalse:[ |
|
489 |
startLnr := pcLineNr-10 max:1. |
|
490 |
stopLnr := pcLineNr+10 min:src size. |
|
491 |
]. |
|
492 |
startLnr to:stopLnr do:[:lNr | |
|
493 |
lNr == pcLineNr ifTrue:[ |
|
494 |
'>> ' print. |
|
495 |
] ifFalse:[ |
|
496 |
' ' print. |
|
497 |
]. |
|
498 |
(lNr printStringLeftPaddedTo:3) print. ' ' print. |
|
499 |
(src at:lNr) printCR. |
|
8717 | 500 |
] |
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
501 |
! |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
502 |
|
618 | 503 |
stepping |
504 |
traceBlock := nil. |
|
505 |
tracing := false. |
|
506 |
stepping := true |
|
74 | 507 |
! |
508 |
||
618 | 509 |
tracingWith:aBlockOrNil |
510 |
traceBlock := aBlockOrNil. |
|
511 |
stepping := false. |
|
512 |
tracing := true |
|
513 |
! ! |
|
514 |
||
515 |
!MiniDebugger methodsFor:'user commands'! |
|
516 |
||
1 | 517 |
commandLoop |
13740 | 518 |
"read-eval commands, until one of the continue, abort or single step commands is entered; |
519 |
return the last command character" |
|
520 |
||
521 |
|cmd done| |
|
1 | 522 |
|
523 |
done := false. |
|
524 |
[done] whileFalse:[ |
|
10017 | 525 |
cmd := self getCommand:nil. |
13740 | 526 |
cmd isNil ifTrue:[ "/ EOF is treated like continue command |
10017 | 527 |
cmd := $c |
528 |
]. |
|
13740 | 529 |
done := self doCommand:cmd. |
1 | 530 |
]. |
531 |
^ cmd |
|
1424 | 532 |
|
13740 | 533 |
"Modified (comment): / 29-09-2011 / 09:02:24 / cg" |
1 | 534 |
! |
535 |
||
618 | 536 |
doAbort |
537 |
|con sig| |
|
538 |
||
6204
2bafef9151dd
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
5942
diff
changeset
|
539 |
(sig := AbortOperationRequest) isHandled ifTrue:[ |
8840 | 540 |
sig raise. |
541 |
'abort raise failed' errorPrintCR. |
|
618 | 542 |
]. |
543 |
||
544 |
"TEMPORARY kludge - find event handler context |
|
545 |
this will be removed, once real debugging is possible |
|
546 |
" |
|
547 |
con := self findContext:#processEvent. |
|
548 |
con isNil ifTrue:[ |
|
8840 | 549 |
con := self findContext:#dispatch. |
618 | 550 |
]. |
551 |
con notNil ifTrue:[ |
|
8840 | 552 |
"got it" |
553 |
con return. |
|
554 |
'return failed' errorPrintCR. |
|
618 | 555 |
]. |
556 |
||
1424 | 557 |
'found no context to resume' errorPrintCR. |
558 |
||
6204
2bafef9151dd
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
5942
diff
changeset
|
559 |
"Modified: / 16.11.2001 / 17:39:14 / cg" |
618 | 560 |
! |
561 |
||
13740 | 562 |
doCommand:cmd |
14797 | 563 |
"a single command; |
564 |
return true, if command loop should be finished" |
|
13740 | 565 |
|
14797 | 566 |
|id proc bool| |
13740 | 567 |
|
568 |
commandArg notEmpty ifTrue:[ |
|
569 |
id := Number readFrom:commandArg onError:nil. |
|
570 |
id notNil ifTrue:[ |
|
571 |
proc := Process allSubInstances detect:[:p | p id == id] ifNone:nil. |
|
572 |
proc == Processor activeProcess ifTrue:[ |
|
573 |
id := proc := nil |
|
574 |
] |
|
14797 | 575 |
] ifFalse:[ |
576 |
commandArg = '-' ifTrue:[ |
|
577 |
bool := false |
|
578 |
] ifFalse:[ |
|
579 |
commandArg = '+' ifTrue:[ |
|
580 |
bool := true |
|
581 |
] |
|
582 |
] |
|
13740 | 583 |
] |
584 |
]. |
|
585 |
||
14737 | 586 |
(cmd == $w) ifTrue:[ |
13740 | 587 |
proc notNil ifTrue:[ |
588 |
'-------- walkback of process ' print. id print. ' -------' printCR. |
|
589 |
self printBacktraceFrom:(proc suspendedContext) |
|
590 |
] ifFalse:[ |
|
591 |
id notNil ifTrue:[ |
|
592 |
'no process with id: ' print. id printCR. |
|
593 |
] ifFalse:[ |
|
594 |
'-------- walkback of current process -------' printCR. |
|
595 |
self printBacktraceFrom:(self getContext) |
|
596 |
] |
|
597 |
]. |
|
598 |
^ false |
|
599 |
]. |
|
600 |
||
601 |
(cmd == $b) ifTrue:[ |
|
602 |
proc notNil ifTrue:[ |
|
603 |
'-------- VM walkback of process ' print. id print. ' -------' printCR. |
|
604 |
ObjectMemory printStackBacktraceFrom:(proc suspendedContext) |
|
605 |
] ifFalse:[ |
|
606 |
id notNil ifTrue:[ |
|
607 |
'no process with id: ' print. id printCR. |
|
608 |
] ifFalse:[ |
|
609 |
'-------- VM walkback of current process -------' printCR. |
|
610 |
ObjectMemory printStackBacktrace |
|
611 |
] |
|
612 |
]. |
|
613 |
^ false |
|
614 |
]. |
|
615 |
||
616 |
(cmd == $S) ifTrue:[ |
|
617 |
'saving "crash.img"...' print. |
|
618 |
ObjectMemory writeCrashImage. |
|
619 |
'done.' printCR. |
|
620 |
^ false |
|
621 |
]. |
|
622 |
||
623 |
(cmd == $B) ifTrue:[ |
|
624 |
self printAllBacktraces. |
|
625 |
^ false |
|
626 |
]. |
|
627 |
||
628 |
(cmd == $P) ifTrue:[ |
|
14797 | 629 |
self showProcesses:#all. |
630 |
^ false |
|
631 |
]. |
|
632 |
(cmd == $p) ifTrue:[ |
|
633 |
self showProcesses:#live. |
|
13740 | 634 |
^ false |
635 |
]. |
|
636 |
||
637 |
(cmd == $r) ifTrue:[ |
|
638 |
dot receiver printCR. |
|
639 |
^ false |
|
640 |
]. |
|
641 |
||
642 |
(cmd == $i) ifTrue:[ |
|
643 |
MiniInspector openOn:(dot receiver). |
|
644 |
^ false |
|
645 |
]. |
|
646 |
||
647 |
(cmd == $I) ifTrue:[ |
|
648 |
self interpreterLoopWith:nil. |
|
649 |
^ false |
|
650 |
]. |
|
651 |
(cmd == $e) ifTrue:[ |
|
652 |
Parser evaluate:commandArg. |
|
653 |
^ false |
|
654 |
]. |
|
15691 | 655 |
(cmd == $E) ifTrue:[ |
656 |
(Parser evaluate:commandArg) printCR. |
|
657 |
^ false |
|
658 |
]. |
|
13740 | 659 |
|
660 |
(cmd == $c) ifTrue:[^ true]. |
|
661 |
(cmd == $s) ifTrue:[^ true]. |
|
662 |
(cmd == $t) ifTrue:[^ true]. |
|
663 |
(cmd == $a) ifTrue:[^ true]. |
|
664 |
||
665 |
(cmd == $u) ifTrue:[ |
|
666 |
stepping := false. |
|
667 |
tracing := false. |
|
668 |
Processor activeProcess vmTrace:false. |
|
669 |
^ false |
|
670 |
]. |
|
671 |
||
14797 | 672 |
(cmd == $h) ifTrue:[ |
673 |
(bool notNil) ifTrue:[ |
|
674 |
Smalltalk ignoreHalt:bool not. |
|
675 |
]. |
|
676 |
'halts are ' print. (Smalltalk ignoreHalt ifTrue:['disabled'] ifFalse:['enabled']) printCR. |
|
677 |
^ false |
|
678 |
]. |
|
679 |
||
13740 | 680 |
(cmd == $R) ifTrue:[ |
681 |
proc notNil ifTrue:[ |
|
682 |
proc resume. |
|
683 |
]. |
|
684 |
^ false |
|
685 |
]. |
|
686 |
||
687 |
(cmd == $T) ifTrue:[ |
|
688 |
proc notNil ifTrue:[ |
|
689 |
proc terminate. |
|
690 |
] ifFalse:[ |
|
691 |
id notNil ifTrue:[ |
|
692 |
'no process with id: ' print. id printCR. |
|
693 |
] ifFalse:[ |
|
694 |
Processor terminateActive |
|
695 |
] |
|
696 |
]. |
|
697 |
^ false |
|
698 |
]. |
|
699 |
||
700 |
(cmd == $W) ifTrue:[ |
|
701 |
proc notNil ifTrue:[ |
|
702 |
'stopping process id: ' print. id printCR. |
|
703 |
proc stop. |
|
704 |
] ifFalse:[ |
|
705 |
'invalid process id: ' print. id printCR. |
|
706 |
]. |
|
707 |
^ false |
|
708 |
]. |
|
709 |
||
710 |
(cmd == $a) ifTrue:[ |
|
711 |
"without id-arg, this is handled by caller" |
|
712 |
proc notNil ifTrue:[ |
|
713 |
'aborting process id: ' print. id printCR. |
|
714 |
proc interruptWith:[AbortOperationRequest raise] |
|
715 |
] ifFalse:[ |
|
716 |
'aborting' printCR. |
|
717 |
]. |
|
718 |
^ false |
|
719 |
]. |
|
720 |
||
721 |
(cmd == $Q) ifTrue:[ |
|
722 |
proc notNil ifTrue:[ |
|
723 |
proc terminateNoSignal. |
|
724 |
] ifFalse:[ |
|
725 |
id notNil ifTrue:[ |
|
726 |
'no process with id: ' print. id printCR. |
|
727 |
] ifFalse:[ |
|
728 |
Processor terminateActiveNoSignal |
|
729 |
] |
|
730 |
]. |
|
731 |
^ false |
|
732 |
]. |
|
733 |
||
734 |
(cmd == $g) ifTrue:[ |
|
735 |
self garbageCollectCommand:id. |
|
736 |
^ false |
|
737 |
]. |
|
738 |
||
739 |
(cmd == $U) ifTrue:[ |
|
740 |
MessageTracer unwrapAllMethods. |
|
741 |
^ false |
|
742 |
]. |
|
743 |
(cmd == $X) ifTrue:[ |
|
744 |
Smalltalk fatalAbort. |
|
745 |
"/ not reached |
|
746 |
^ false |
|
747 |
]. |
|
748 |
(cmd == $x) ifTrue:[ |
|
749 |
OperatingSystem exit. |
|
750 |
"/ not reached |
|
751 |
^ false |
|
752 |
]. |
|
753 |
||
754 |
(cmd == $.) ifTrue:[self printDot. ^ false ]. |
|
14737 | 755 |
(cmd == $l) ifTrue:[self printDotsMethodSource:false. ^ false ]. |
756 |
(cmd == $L) ifTrue:[self printDotsMethodSource:true. ^ false ]. |
|
757 |
(cmd == $-) ifTrue:[self moveDotUp. self printDot. ^ false ]. |
|
758 |
(cmd == $+) ifTrue:[self moveDotDown. self printDot. ^ false ]. |
|
15195 | 759 |
(cmd == $?) ifTrue:[ |
760 |
commandArg notEmpty ifTrue:[ |
|
761 |
self helpOn:commandArg. ^ false |
|
762 |
] |
|
763 |
]. |
|
13740 | 764 |
|
765 |
"/ avoid usage print if return was typed ... |
|
766 |
((cmd == Character return) |
|
767 |
or:[cmd == Character linefeed]) ifTrue:[^ false]. |
|
768 |
||
769 |
self showValidCommandHelp. |
|
770 |
^ false. |
|
771 |
||
772 |
"Modified: / 29-09-2006 / 12:23:18 / cg" |
|
773 |
"Created: / 29-09-2011 / 08:58:47 / cg" |
|
774 |
! |
|
775 |
||
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
776 |
getCommand:prompt |
3126
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
777 |
"/ Screen notNil ifTrue:[ |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
778 |
"/ Screen allScreens do:[:aScreen | |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
779 |
"/ aScreen ungrabPointer. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
780 |
"/ aScreen ungrabKeyboard. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
781 |
"/ ]. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
782 |
"/ ]. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
783 |
|
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
784 |
Display notNil ifTrue:[ |
10322 | 785 |
Display ungrabPointer. |
786 |
Display ungrabKeyboard. |
|
852
5c4a0585ba0b
ungrab pointer for every input
Claus Gittinger <cg@exept.de>
parents:
720
diff
changeset
|
787 |
]. |
5c4a0585ba0b
ungrab pointer for every input
Claus Gittinger <cg@exept.de>
parents:
720
diff
changeset
|
788 |
|
8840 | 789 |
(prompt |
10322 | 790 |
? (nesting == 0 ifTrue:[ |
791 |
'MiniDebugger> ' |
|
792 |
] ifFalse:[ |
|
793 |
'MiniDebugger' , nesting printString , '>' |
|
794 |
])) print. |
|
93 | 795 |
|
7706 | 796 |
UserInterrupt handle:[:ex | |
10322 | 797 |
ex restart |
159 | 798 |
] do:[ |
10322 | 799 |
|c cmd arg cnt| |
3700 | 800 |
|
10322 | 801 |
cmd := Character fromUser. |
802 |
cmd isNil ifTrue:[ |
|
803 |
" |
|
804 |
mhmh end-of-file; |
|
805 |
return a 'c' (for continue); hope thats ok. |
|
806 |
" |
|
807 |
cmd := $c |
|
808 |
]. |
|
93 | 809 |
|
10322 | 810 |
cnt := nil. |
811 |
(cmd isDigit) ifTrue:[ |
|
812 |
cnt := 0. |
|
813 |
[cmd isDigit] whileTrue:[ |
|
814 |
cnt := (cnt * 10) + cmd digitValue. |
|
815 |
cmd := Character fromUser |
|
816 |
]. |
|
817 |
[cmd == Character space] whileTrue:[ |
|
818 |
cmd := Character fromUser |
|
819 |
]. |
|
820 |
]. |
|
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
821 |
|
10322 | 822 |
" |
823 |
collect to end-of-line in arg |
|
824 |
" |
|
825 |
c := cmd. |
|
826 |
arg := ''. |
|
827 |
[c isNil or:[c isEndOfLineCharacter]] whileFalse: [ |
|
828 |
arg := arg copyWith:c. |
|
829 |
c := Character fromUser. |
|
830 |
]. |
|
14797 | 831 |
commandArg := (arg copyFrom:2) withoutSeparators. |
10322 | 832 |
command := cmd. |
833 |
commandCount := cnt. |
|
1 | 834 |
]. |
3700 | 835 |
^ command |
976 | 836 |
|
3700 | 837 |
"Modified: / 31.7.1998 / 16:11:01 / cg" |
1 | 838 |
! |
839 |
||
15195 | 840 |
helpOn:commandArg |
841 |
|args className sym val match showMethod| |
|
842 |
||
843 |
commandArg withoutSeparators isEmpty ifTrue:[ |
|
844 |
'usage: H className [methodPattern]' printCR. |
|
845 |
^self |
|
846 |
]. |
|
847 |
args := commandArg asCollectionOfWords. |
|
848 |
className := args first. |
|
849 |
||
850 |
(sym := className asSymbolIfInterned) isNil ifTrue:[ |
|
851 |
'no such class' printCR. |
|
852 |
^ self. |
|
853 |
]. |
|
854 |
val := Smalltalk at:sym ifAbsent:['no such class' printCR. ^ self.]. |
|
855 |
val isBehavior ifFalse:[ |
|
856 |
'not a class: ' print. className printCR. |
|
857 |
val := val class. |
|
858 |
'showing help for ' print. val name printCR. |
|
859 |
]. |
|
860 |
args size > 1 ifTrue:[ |
|
861 |
match := args at:2 |
|
862 |
] ifFalse:[ |
|
863 |
match := '*' |
|
864 |
]. |
|
865 |
||
866 |
showMethod := |
|
867 |
[:sel :cls | |
|
868 |
|mthd| |
|
869 |
||
870 |
((match includesMatchCharacters and:[ sel matches:match ignoreCase:true]) |
|
871 |
or:[ sel asLowercase startsWith:match asLowercase ]) ifTrue:[ |
|
872 |
mthd := cls compiledMethodAt:sel. |
|
873 |
mthd category ~= 'documentation' ifTrue:[ |
|
874 |
sel printCR. |
|
875 |
(mthd comment ? '') asStringCollection do:[:l | |
|
876 |
' ' print. l withoutSeparators printCR. |
|
877 |
]. |
|
878 |
'' printCR |
|
879 |
]. |
|
880 |
]. |
|
881 |
]. |
|
882 |
||
883 |
val theMetaclass selectors copy sort do:[:sel | |
|
884 |
showMethod value:sel value:val theMetaclass |
|
885 |
]. |
|
886 |
val theNonMetaclass selectors copy sort do:[:sel | |
|
887 |
showMethod value:sel value:val theNonMetaclass |
|
888 |
]. |
|
889 |
! |
|
890 |
||
1 | 891 |
interpreterLoopWith:anObject |
10630 | 892 |
'read-eval-print loop; exit with "#exit"; help with "?"' printCR. |
11060
b6e5aa5d7887
ReadEvalPrintLoop writev help texts to Stderr
Stefan Vogel <sv@exept.de>
parents:
10634
diff
changeset
|
893 |
(ReadEvalPrintLoop new doChunkFormat:false; error:Stderr; prompt:'> ')readEvalPrintLoop. |
3700 | 894 |
|
10630 | 895 |
"/ |line done rslt| |
896 |
"/ |
|
897 |
"/ 'read-eval-print loop; exit with empty line' printCR. |
|
898 |
"/ '' printCR. |
|
899 |
"/ |
|
900 |
"/ done := false. |
|
901 |
"/ [done] whileFalse:[ |
|
902 |
"/ '> ' print. |
|
903 |
"/ |
|
904 |
"/ line := Stdin nextLine. |
|
905 |
"/ (line size == 0) ifTrue:[ |
|
906 |
"/ done := true |
|
907 |
"/ ] ifFalse:[ |
|
908 |
"/ "/ rslt := Compiler evaluate:line |
|
909 |
"/ "/ receiver:anObject |
|
910 |
"/ "/ notifying:nil. |
|
911 |
"/ |
|
912 |
"/ rslt := Compiler |
|
913 |
"/ evaluate:line |
|
914 |
"/ in:dot |
|
915 |
"/ receiver:dot receiver |
|
916 |
"/ notifying:self "/ nil |
|
917 |
"/ ifFail:[]. |
|
918 |
"/ rslt printCR. |
|
919 |
"/ ] |
|
920 |
"/ ] |
|
1424 | 921 |
|
3700 | 922 |
"Modified: / 31.7.1998 / 16:01:47 / cg" |
618 | 923 |
! |
924 |
||
2772 | 925 |
printAllBacktraces |
926 |
Process allInstancesDo:[:p | |
|
10554
d55478de663b
changed #printAllBacktraces us #isActiveProcesses
Stefan Vogel <sv@exept.de>
parents:
10374
diff
changeset
|
927 |
(p isActive not |
d55478de663b
changed #printAllBacktraces us #isActiveProcesses
Stefan Vogel <sv@exept.de>
parents:
10374
diff
changeset
|
928 |
and:[p isDead not]) ifTrue:[ |
d55478de663b
changed #printAllBacktraces us #isActiveProcesses
Stefan Vogel <sv@exept.de>
parents:
10374
diff
changeset
|
929 |
'---------------------------------------------------------' printCR. |
d55478de663b
changed #printAllBacktraces us #isActiveProcesses
Stefan Vogel <sv@exept.de>
parents:
10374
diff
changeset
|
930 |
' proc id=' print. p id print. |
d55478de663b
changed #printAllBacktraces us #isActiveProcesses
Stefan Vogel <sv@exept.de>
parents:
10374
diff
changeset
|
931 |
' name=''' print. p name print. |
d55478de663b
changed #printAllBacktraces us #isActiveProcesses
Stefan Vogel <sv@exept.de>
parents:
10374
diff
changeset
|
932 |
''' createdBy: ' print. p creatorId print. |
d55478de663b
changed #printAllBacktraces us #isActiveProcesses
Stefan Vogel <sv@exept.de>
parents:
10374
diff
changeset
|
933 |
' state=' print. p state print. |
d55478de663b
changed #printAllBacktraces us #isActiveProcesses
Stefan Vogel <sv@exept.de>
parents:
10374
diff
changeset
|
934 |
' prio=' print. p priority printCR. |
d55478de663b
changed #printAllBacktraces us #isActiveProcesses
Stefan Vogel <sv@exept.de>
parents:
10374
diff
changeset
|
935 |
'' printCR. '' printCR. |
2772 | 936 |
|
10554
d55478de663b
changed #printAllBacktraces us #isActiveProcesses
Stefan Vogel <sv@exept.de>
parents:
10374
diff
changeset
|
937 |
self printBacktraceFrom:(p suspendedContext) |
d55478de663b
changed #printAllBacktraces us #isActiveProcesses
Stefan Vogel <sv@exept.de>
parents:
10374
diff
changeset
|
938 |
] |
2772 | 939 |
] |
940 |
! |
|
941 |
||
618 | 942 |
showProcesses |
14797 | 943 |
self showProcesses:#all |
944 |
! |
|
945 |
||
946 |
showProcesses:how |
|
618 | 947 |
|active| |
948 |
||
949 |
active := Processor activeProcess. |
|
3700 | 950 |
'current id=' print. active id print. ' name=''' print. active name print. '''' printCR. |
618 | 951 |
|
3700 | 952 |
Process allSubInstancesDo:[:p | |
14797 | 953 |
|doShow| |
954 |
||
955 |
doShow := (how == #all). |
|
956 |
doShow := doShow or:[ (how == #dead) and:[ p isDead ]]. |
|
957 |
doShow := doShow or:[ (how ~~ #dead) and:[ p isDead not ]]. |
|
958 |
doShow ifTrue:[ |
|
959 |
'proc id=' print. (p id printStringPaddedTo:5) print. |
|
960 |
(p state printStringPaddedTo:10) print. |
|
961 |
' pri=' print. (p priority printStringPaddedTo:2) print. |
|
962 |
' creator:' print. (p creatorId printStringPaddedTo:5) print. |
|
963 |
' name=''' print. p name print. |
|
964 |
'''' printCR. |
|
965 |
] |
|
618 | 966 |
] |
1424 | 967 |
|
3700 | 968 |
"Modified: / 31.7.1998 / 16:30:19 / cg" |
7701 | 969 |
! |
970 |
||
971 |
showValidCommandHelp |
|
13113 | 972 |
'valid commands: |
14797 | 973 |
c ...... continue |
974 |
s ...... step |
|
975 |
t ...... trace (continue with trace) |
|
976 |
a [id] abort (i.e. raise abort signal) in (current) process |
|
977 |
T [id] terminate (current) process |
|
978 |
W [id] stop (current) process |
|
979 |
R [id] resume (current) process |
|
980 |
Q [id] quick terminate (current) process - no unwinds or cleanup |
|
7701 | 981 |
|
14797 | 982 |
p ...... list processes ("P" for full list) |
983 |
w [id] walkback (of process with id) |
|
984 |
b [id] full (VM) backtrace (more detail) |
|
985 |
B ...... backtrace of all other processes |
|
7701 | 986 |
|
14797 | 987 |
U ...... unwrap all traced/breakpointed methods |
988 |
h [-/+] disable/enable halts |
|
989 |
g ...... collect all garbage |
|
990 |
g 2 .... collect all garbage & reclaim symbols |
|
991 |
g 3 .... collect all garbage, reclaim symbols and compress |
|
7701 | 992 |
|
14797 | 993 |
S ...... save snapshot into crash.img |
994 |
x ...... exit Smalltalk ("X" to exit with core dump) |
|
7701 | 995 |
|
14797 | 996 |
. ...... print dot (the current context) |
997 |
- ...... move dot up (sender) |
|
998 |
+ ...... move dot down (called context) |
|
999 |
l ...... list dot''s method source around PC ("L" for full list) |
|
7701 | 1000 |
|
14797 | 1001 |
r ...... receiver (in dot) printString |
1002 |
i ...... inspect receiver (in dot) |
|
1003 |
I ...... interpreter (expression evaluator) |
|
1004 |
e expr evaluate expression |
|
15195 | 1005 |
? c [p] help on class c (selectors matching p) |
14798 | 1006 |
' errorPrintCR. |
7701 | 1007 |
|
14798 | 1008 |
(XWorkstation notNil and:[ Screen default isKindOf:XWorkstation ]) ifTrue:[ |
1009 |
' To repair a broken X-Connection, enter an interpreter (enter "I") and evaluate: |
|
7701 | 1010 |
Display := XWorkstation new. |
14798 | 1011 |
Display initializeFor:''localhost:0''. |
7701 | 1012 |
Display startDispatch. |
1013 |
NewLauncher openOnDevice:Display. |
|
1014 |
<empty line> |
|
14798 | 1015 |
then enter "c" to continue; a NewLauncher should pop up soon. |
7701 | 1016 |
' errorPrintCR |
14798 | 1017 |
] |
1 | 1018 |
! ! |
618 | 1019 |
|
658 | 1020 |
!MiniDebugger class methodsFor:'documentation'! |
1021 |
||
1022 |
version |
|
15691 | 1023 |
^ '$Header: /cvs/stx/stx/libbasic/MiniDebugger.st,v 1.86 2013-08-23 17:28:01 cg Exp $' |
13113 | 1024 |
! |
1025 |
||
1026 |
version_CVS |
|
15691 | 1027 |
^ '$Header: /cvs/stx/stx/libbasic/MiniDebugger.st,v 1.86 2013-08-23 17:28:01 cg Exp $' |
658 | 1028 |
! ! |
14737 | 1029 |