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