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