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