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