author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 03 Oct 2016 12:44:41 +0100 | |
branch | jv |
changeset 20578 | 39641ba8d6e0 |
parent 19948 | be658f466bca |
parent 20501 | b9160741f140 |
child 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 |
|
13740 | 49 |
MiniDebugger enter |
50 |
||
20500 | 51 |
Attention: |
52 |
all printing is done via lowLevelErrorPrint, |
|
53 |
to ensure that output is to stderr, even if a logger is present, or |
|
54 |
Stderr has been set to some other stream (Transcript). |
|
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:[ |
20496 | 99 |
"/ 'recursive lowLevelError in debugger ignored' lowLevelErrorPrintCR. |
19389 | 100 |
^ self |
101 |
]. |
|
14798 | 102 |
|
20496 | 103 |
aString lowLevelErrorPrintCR. |
19389 | 104 |
Processor notNil ifTrue:[ |
105 |
active := Processor activeProcess. |
|
20496 | 106 |
'process: id=' lowLevelErrorPrint. active id lowLevelErrorPrint. |
107 |
' name=' lowLevelErrorPrint. active name lowLevelErrorPrintCR. |
|
4960 | 108 |
|
20496 | 109 |
'context: ' lowLevelErrorPrint. aContext printString lowLevelErrorPrintCR. |
19389 | 110 |
(con := aContext) notNil ifTrue:[ |
111 |
con := con sender. |
|
20496 | 112 |
' ......: ' lowLevelErrorPrint. con printString lowLevelErrorPrintCR. |
19389 | 113 |
[con notNil] whileTrue:[ |
114 |
sender := con sender. |
|
115 |
(sender notNil and:[sender selector == con selector]) ifTrue:[ |
|
20496 | 116 |
' ......: ' lowLevelErrorPrint. sender printString lowLevelErrorPrintCR. |
117 |
' ......: [** intermediate recursive contexts skipped **]' lowLevelErrorPrintCR. |
|
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. |
|
20496 | 126 |
' ......: ' lowLevelErrorPrint. con printString lowLevelErrorPrintCR. |
19389 | 127 |
] |
128 |
] |
|
129 |
]. |
|
130 |
NotFirstTimeEntered ~~ true ifTrue:[ |
|
131 |
NotFirstTimeEntered := true. |
|
20496 | 132 |
'Type "c" to proceed, "?" for help' lowLevelErrorPrintCR. |
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:[ |
|
20496 | 140 |
self warn:('Unexpected lowLevelError:\' , 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 | |
20496 | 144 |
'cannot raise Abort - exiting ...' lowLevelErrorPrintCR. |
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 |
|
20496 | 231 |
self trace:aBlock with:[:where | where lowLevelErrorPrintCR] |
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 | |
20496 | 288 |
'** Abort caught - back in previous debugLevel' lowLevelErrorPrintCR. |
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" |
|
20496 | 293 |
'Error while processing lowLevelError in MiniDebugger (Stdout closed?):' lowLevelErrorPrintCR. |
294 |
ex description lowLevelErrorPrintCR. |
|
19148 | 295 |
OperatingSystem exit:10. |
296 |
] do:[ |
|
20496 | 297 |
'Error while executing MiniDebugger command: ' lowLevelErrorPrint. |
298 |
ex description lowLevelErrorPrintCR. |
|
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:[ |
|
378 |
'stepInterrupt: no context' lowLevelErrorPrintCR |
|
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:[ |
|
387 |
'traceInterrupt: no context' lowLevelErrorPrintCR |
|
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:[ |
20496 | 473 |
'** dot is the bottom of the calling chain' lowLevelErrorPrintCR. |
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 |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
478 |
dot sender notNil ifTrue:[ |
20496 | 479 |
dot := dot sender. |
480 |
"/ dot fullPrint. |
|
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
481 |
] ifFalse:[ |
20496 | 482 |
'** dot is the top of the calling chain' lowLevelErrorPrintCR. |
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
483 |
]. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
484 |
! |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
485 |
|
2772 | 486 |
printBacktraceFrom:aContext |
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
487 |
|context n| |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
488 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
489 |
aContext isNil ifTrue:[ |
20496 | 490 |
'no context' lowLevelErrorPrintCR. |
491 |
^ self |
|
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
492 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
493 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
494 |
context := aContext. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
495 |
n := commandCount. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
496 |
[context notNil] whileTrue: [ |
20496 | 497 |
self printContext:context. |
498 |
context := context sender. |
|
499 |
n notNil ifTrue:[ |
|
500 |
n := n - 1. |
|
501 |
n <= 0 ifTrue:[ |
|
502 |
^ self |
|
503 |
] |
|
504 |
] |
|
2772 | 505 |
] |
506 |
! |
|
507 |
||
20496 | 508 |
printContext:aContext |
509 |
"print the receiver, selector and args of the context" |
|
510 |
||
511 |
"/ aContext fullPrint. |
|
512 |
||
513 |
aContext receiverPrintString lowLevelErrorPrint. ' ' lowLevelErrorPrint. |
|
20499 | 514 |
aContext selector asString lowLevelErrorPrint. |
20496 | 515 |
aContext argumentCount ~~ 0 ifTrue: [ |
516 |
' ' lowLevelErrorPrint. aContext argsDisplayString lowLevelErrorPrint |
|
517 |
]. |
|
20498 | 518 |
' [' lowLevelErrorPrint. |
20499 | 519 |
aContext lineNumber asString lowLevelErrorPrint. |
20498 | 520 |
']' lowLevelErrorPrintCR |
20496 | 521 |
! |
522 |
||
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
523 |
printDot |
20496 | 524 |
self printContext:dot. |
20498 | 525 |
' receiver: ' lowLevelErrorPrint. dot receiver printString lowLevelErrorPrintCR. |
20496 | 526 |
' selector: ' lowLevelErrorPrint. dot selector lowLevelErrorPrintCR. |
527 |
' args: ' lowLevelErrorPrintCR. |
|
8717 | 528 |
dot args keysAndValuesDo:[:idx :eachArg | |
20498 | 529 |
' ' lowLevelErrorPrint. idx printString lowLevelErrorPrint. |
530 |
': ' lowLevelErrorPrint. eachArg printString lowLevelErrorPrintCR. |
|
8717 | 531 |
]. |
20496 | 532 |
' vars: ' lowLevelErrorPrintCR. |
8717 | 533 |
dot vars keysAndValuesDo:[:idx :eachVar | |
20498 | 534 |
' ' lowLevelErrorPrint. idx printString lowLevelErrorPrint. |
535 |
': ' lowLevelErrorPrint. eachVar printString lowLevelErrorPrintCR. |
|
8717 | 536 |
]. |
537 |
! |
|
538 |
||
539 |
printDotsMethodSource |
|
14737 | 540 |
self printDotsMethodSource:false |
541 |
! |
|
542 |
||
543 |
printDotsMethodSource:full |
|
544 |
|home mthd src pcLineNr startLnr stopLnr| |
|
8717 | 545 |
|
546 |
home := dot methodHome. |
|
547 |
mthd := home method. |
|
548 |
mthd isNil ifTrue:[ |
|
20496 | 549 |
'** no source **' lowLevelErrorPrintCR. |
550 |
^ self. |
|
8717 | 551 |
]. |
552 |
src := mthd source. |
|
553 |
src isNil ifTrue:[ |
|
20496 | 554 |
'** no source **' lowLevelErrorPrintCR. |
555 |
^ self. |
|
8717 | 556 |
]. |
14737 | 557 |
pcLineNr := dot lineNumber. |
558 |
||
8717 | 559 |
src := src asCollectionOfLines. |
14737 | 560 |
full ifTrue:[ |
20496 | 561 |
startLnr := 1. |
562 |
stopLnr := src size. |
|
14737 | 563 |
] ifFalse:[ |
20496 | 564 |
startLnr := pcLineNr-10 max:1. |
565 |
stopLnr := pcLineNr+10 min:src size. |
|
14737 | 566 |
]. |
567 |
startLnr to:stopLnr do:[:lNr | |
|
20496 | 568 |
lNr == pcLineNr ifTrue:[ |
569 |
'>> ' lowLevelErrorPrint. |
|
570 |
] ifFalse:[ |
|
571 |
' ' lowLevelErrorPrint. |
|
572 |
]. |
|
573 |
(lNr printStringLeftPaddedTo:3) lowLevelErrorPrint. ' ' lowLevelErrorPrint. |
|
20498 | 574 |
(src at:lNr) asString lowLevelErrorPrintCR. |
8717 | 575 |
] |
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
576 |
! |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
577 |
|
618 | 578 |
stepping |
579 |
traceBlock := nil. |
|
580 |
tracing := false. |
|
581 |
stepping := true |
|
74 | 582 |
! |
583 |
||
618 | 584 |
tracingWith:aBlockOrNil |
585 |
traceBlock := aBlockOrNil. |
|
586 |
stepping := false. |
|
587 |
tracing := true |
|
588 |
! ! |
|
589 |
||
590 |
!MiniDebugger methodsFor:'user commands'! |
|
591 |
||
1 | 592 |
commandLoop |
16557 | 593 |
"read-eval commands, until one of the continue, abort or single step commands is entered; |
13740 | 594 |
return the last command character" |
595 |
||
596 |
|cmd done| |
|
1 | 597 |
|
598 |
done := false. |
|
599 |
[done] whileFalse:[ |
|
16557 | 600 |
cmd := self getCommand:nil. |
601 |
cmd isNil ifTrue:[ "/ EOF is treated like continue command |
|
602 |
cmd := $c |
|
603 |
]. |
|
604 |
done := self doCommand:cmd. |
|
1 | 605 |
]. |
606 |
^ cmd |
|
1424 | 607 |
|
13740 | 608 |
"Modified (comment): / 29-09-2011 / 09:02:24 / cg" |
1 | 609 |
! |
610 |
||
618 | 611 |
doAbort |
612 |
|con sig| |
|
613 |
||
6204
2bafef9151dd
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
5942
diff
changeset
|
614 |
(sig := AbortOperationRequest) isHandled ifTrue:[ |
20496 | 615 |
sig raise. |
616 |
'abort raise failed' lowLevelErrorPrintCR. |
|
618 | 617 |
]. |
618 |
||
619 |
"TEMPORARY kludge - find event handler context |
|
620 |
this will be removed, once real debugging is possible |
|
621 |
" |
|
622 |
con := self findContext:#processEvent. |
|
623 |
con isNil ifTrue:[ |
|
20496 | 624 |
con := self findContext:#dispatch. |
618 | 625 |
]. |
626 |
con notNil ifTrue:[ |
|
20496 | 627 |
"got it" |
628 |
con return. |
|
629 |
'return failed' lowLevelErrorPrintCR. |
|
618 | 630 |
]. |
631 |
||
20496 | 632 |
'found no context to resume' lowLevelErrorPrintCR. |
1424 | 633 |
|
6204
2bafef9151dd
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
5942
diff
changeset
|
634 |
"Modified: / 16.11.2001 / 17:39:14 / cg" |
618 | 635 |
! |
636 |
||
13740 | 637 |
doCommand:cmd |
16557 | 638 |
"a single command; |
14797 | 639 |
return true, if command loop should be finished" |
13740 | 640 |
|
14797 | 641 |
|id proc bool| |
13740 | 642 |
|
15860 | 643 |
commandArg notEmptyOrNil ifTrue:[ |
19145 | 644 |
id := Number readFrom:commandArg onError:nil. |
645 |
id notNil ifTrue:[ |
|
646 |
proc := Process allSubInstances detect:[:p | p id == id] ifNone:nil. |
|
647 |
proc == Processor activeProcess ifTrue:[ |
|
648 |
id := proc := nil |
|
649 |
] |
|
650 |
] ifFalse:[ |
|
651 |
commandArg = '-' ifTrue:[ |
|
652 |
bool := false |
|
653 |
] ifFalse:[ |
|
654 |
commandArg = '+' ifTrue:[ |
|
655 |
bool := true |
|
656 |
] |
|
657 |
] |
|
658 |
] |
|
13740 | 659 |
]. |
660 |
||
14737 | 661 |
(cmd == $w) ifTrue:[ |
19145 | 662 |
proc notNil ifTrue:[ |
20496 | 663 |
'-------- walkback of process ' lowLevelErrorPrint. id lowLevelErrorPrint. ' -------' lowLevelErrorPrintCR. |
19145 | 664 |
self printBacktraceFrom:(proc suspendedContext) |
665 |
] ifFalse:[ |
|
666 |
id notNil ifTrue:[ |
|
20496 | 667 |
'no process with id: ' lowLevelErrorPrint. id lowLevelErrorPrintCR. |
19145 | 668 |
] ifFalse:[ |
20496 | 669 |
'-------- walkback of current process -------' lowLevelErrorPrintCR. |
19145 | 670 |
self printBacktraceFrom:(self getContext) |
671 |
] |
|
672 |
]. |
|
673 |
^ false |
|
13740 | 674 |
]. |
675 |
||
676 |
(cmd == $b) ifTrue:[ |
|
19145 | 677 |
proc notNil ifTrue:[ |
20496 | 678 |
'-------- VM walkback of process ' lowLevelErrorPrint. id lowLevelErrorPrint. ' -------' lowLevelErrorPrintCR. |
19389 | 679 |
(Processor activeProcess environmentAt:#Stderr ifAbsent:Stderr) == Stderr ifTrue:[ |
680 |
ObjectMemory printStackBacktraceFrom:(proc suspendedContext) |
|
681 |
] ifFalse:[ |
|
682 |
self printBacktraceFrom:(proc suspendedContext) |
|
683 |
"/ proc suspendedContext fullPrintAllOn:(Processor activeProcess environmentAt:#Stderr) |
|
684 |
]. |
|
19145 | 685 |
] ifFalse:[ |
686 |
id notNil ifTrue:[ |
|
20496 | 687 |
'no process with id: ' lowLevelErrorPrint. id lowLevelErrorPrintCR. |
19145 | 688 |
] ifFalse:[ |
20496 | 689 |
'-------- VM walkback of current process -------' lowLevelErrorPrintCR. |
19389 | 690 |
(Processor activeProcess environmentAt:#Stderr ifAbsent:Stderr) == Stderr ifTrue:[ |
691 |
ObjectMemory printStackBacktrace |
|
692 |
] ifFalse:[ |
|
693 |
"/ self printBacktraceFrom:(self getContext) |
|
694 |
thisContext fullPrintAllOn:(Processor activeProcess environmentAt:#Stderr) |
|
695 |
] |
|
19145 | 696 |
] |
697 |
]. |
|
698 |
^ false |
|
13740 | 699 |
]. |
700 |
||
701 |
(cmd == $S) ifTrue:[ |
|
20496 | 702 |
'saving "crash.img"...' lowLevelErrorPrint. |
19145 | 703 |
ObjectMemory writeCrashImage. |
20496 | 704 |
'done.' lowLevelErrorPrintCR. |
19145 | 705 |
^ false |
13740 | 706 |
]. |
15859 | 707 |
(cmd == $C) ifTrue:[ |
19145 | 708 |
|changesFilename| |
15859 | 709 |
|
19145 | 710 |
changesFilename := Timestamp now |
711 |
printStringFormat:'changes_%(year)-%(month)-%(day)__%h:%m:%s.chg'. |
|
712 |
OperatingSystem isMSWINDOWSlike ifTrue:[ changesFilename replaceAll:$: with:$_ ]. |
|
15861 | 713 |
|
19145 | 714 |
ChangeSet current fileOutAs: changesFilename. |
20496 | 715 |
('saved session changes to "',changesFilename,'".') lowLevelErrorPrintCR. |
19145 | 716 |
^ false |
15859 | 717 |
]. |
13740 | 718 |
|
719 |
(cmd == $B) ifTrue:[ |
|
19145 | 720 |
self printAllBacktraces. |
721 |
^ false |
|
13740 | 722 |
]. |
723 |
||
724 |
(cmd == $P) ifTrue:[ |
|
19145 | 725 |
self showProcesses:#all. |
726 |
^ false |
|
14797 | 727 |
]. |
728 |
(cmd == $p) ifTrue:[ |
|
19145 | 729 |
self showProcesses:#live. |
730 |
^ false |
|
13740 | 731 |
]. |
732 |
||
733 |
(cmd == $r) ifTrue:[ |
|
20496 | 734 |
dot receiver lowLevelErrorPrintCR. |
19145 | 735 |
^ false |
13740 | 736 |
]. |
737 |
||
738 |
(cmd == $i) ifTrue:[ |
|
19389 | 739 |
|inspectedObject| |
740 |
||
19145 | 741 |
(commandArg ? '') withoutSeparators notEmpty ifTrue:[ |
19389 | 742 |
inspectedObject := (Parser evaluate:commandArg). |
19145 | 743 |
] ifFalse:[ |
19389 | 744 |
inspectedObject := (dot receiver). |
19145 | 745 |
]. |
19389 | 746 |
MiniInspector openOn:inspectedObject input:inputStream. |
19145 | 747 |
^ false |
13740 | 748 |
]. |
749 |
||
750 |
(cmd == $I) ifTrue:[ |
|
19145 | 751 |
self interpreterLoopWith:nil. |
752 |
^ false |
|
13740 | 753 |
]. |
15705 | 754 |
(cmd == $E) ifTrue:[ |
19145 | 755 |
Parser evaluate:commandArg. |
756 |
^ false |
|
13740 | 757 |
]. |
15705 | 758 |
(cmd == $e) ifTrue:[ |
20496 | 759 |
(Parser evaluate:commandArg) lowLevelErrorPrintCR. |
19145 | 760 |
^ false |
15691 | 761 |
]. |
13740 | 762 |
|
763 |
(cmd == $c) ifTrue:[^ true]. |
|
764 |
(cmd == $s) ifTrue:[^ true]. |
|
765 |
(cmd == $t) ifTrue:[^ true]. |
|
766 |
(cmd == $a) ifTrue:[^ true]. |
|
767 |
||
768 |
(cmd == $u) ifTrue:[ |
|
19145 | 769 |
stepping := false. |
770 |
tracing := false. |
|
771 |
Processor activeProcess vmTrace:false. |
|
772 |
^ false |
|
13740 | 773 |
]. |
774 |
||
14797 | 775 |
(cmd == $h) ifTrue:[ |
19145 | 776 |
(bool notNil) ifTrue:[ |
777 |
Smalltalk ignoreHalt:bool not. |
|
778 |
]. |
|
20496 | 779 |
'halts are ' lowLevelErrorPrint. (Smalltalk ignoreHalt ifTrue:['disabled'] ifFalse:['enabled']) lowLevelErrorPrintCR. |
19145 | 780 |
^ false |
14797 | 781 |
]. |
782 |
||
13740 | 783 |
(cmd == $R) ifTrue:[ |
19145 | 784 |
proc notNil ifTrue:[ |
785 |
proc resume. |
|
786 |
]. |
|
787 |
^ false |
|
13740 | 788 |
]. |
789 |
||
790 |
(cmd == $T) ifTrue:[ |
|
19145 | 791 |
proc notNil ifTrue:[ |
792 |
proc terminate. |
|
793 |
] ifFalse:[ |
|
794 |
id notNil ifTrue:[ |
|
20496 | 795 |
'no process with id: ' lowLevelErrorPrint. id lowLevelErrorPrintCR. |
19145 | 796 |
] ifFalse:[ |
797 |
Processor terminateActive |
|
798 |
] |
|
799 |
]. |
|
800 |
^ false |
|
13740 | 801 |
]. |
802 |
||
803 |
(cmd == $W) ifTrue:[ |
|
19145 | 804 |
proc notNil ifTrue:[ |
20496 | 805 |
'stopping process id: ' lowLevelErrorPrint. id lowLevelErrorPrintCR. |
19145 | 806 |
proc stop. |
807 |
] ifFalse:[ |
|
20496 | 808 |
'invalid process id: ' lowLevelErrorPrint. id lowLevelErrorPrintCR. |
19145 | 809 |
]. |
810 |
^ false |
|
13740 | 811 |
]. |
812 |
||
813 |
(cmd == $a) ifTrue:[ |
|
19145 | 814 |
"without id-arg, this is handled by caller" |
815 |
proc notNil ifTrue:[ |
|
20496 | 816 |
'aborting process id: ' lowLevelErrorPrint. id lowLevelErrorPrintCR. |
19145 | 817 |
proc interruptWith:[AbortOperationRequest raise] |
818 |
] ifFalse:[ |
|
20496 | 819 |
'aborting' lowLevelErrorPrintCR. |
19145 | 820 |
]. |
821 |
^ false |
|
13740 | 822 |
]. |
823 |
||
824 |
(cmd == $Q) ifTrue:[ |
|
19145 | 825 |
proc notNil ifTrue:[ |
826 |
proc terminateNoSignal. |
|
827 |
] ifFalse:[ |
|
828 |
id notNil ifTrue:[ |
|
20496 | 829 |
'no process with id: ' lowLevelErrorPrint. id lowLevelErrorPrintCR. |
19145 | 830 |
] ifFalse:[ |
831 |
Processor terminateActiveNoSignal |
|
832 |
] |
|
833 |
]. |
|
834 |
^ false |
|
13740 | 835 |
]. |
836 |
||
837 |
(cmd == $g) ifTrue:[ |
|
19145 | 838 |
self garbageCollectCommand:id. |
839 |
^ false |
|
13740 | 840 |
]. |
841 |
||
842 |
(cmd == $U) ifTrue:[ |
|
19145 | 843 |
MessageTracer unwrapAllMethods. |
844 |
^ false |
|
13740 | 845 |
]. |
15929 | 846 |
(cmd == $D) ifTrue:[ |
19145 | 847 |
Breakpoint disableAllBreakpoints. |
848 |
^ false |
|
15929 | 849 |
]. |
13740 | 850 |
(cmd == $X) ifTrue:[ |
19145 | 851 |
Smalltalk fatalAbort. |
852 |
"/ not reached |
|
853 |
^ false |
|
13740 | 854 |
]. |
855 |
(cmd == $x) ifTrue:[ |
|
19145 | 856 |
OperatingSystem exit. |
857 |
"/ not reached |
|
858 |
^ false |
|
859 |
]. |
|
19146 | 860 |
(cmd == $Y) ifTrue:[ |
19925 | 861 |
Display := nil. |
19147 | 862 |
Smalltalk openDisplay. |
863 |
NewLauncher open. |
|
864 |
^ true |
|
13740 | 865 |
]. |
866 |
||
867 |
(cmd == $.) ifTrue:[self printDot. ^ false ]. |
|
14737 | 868 |
(cmd == $l) ifTrue:[self printDotsMethodSource:false. ^ false ]. |
869 |
(cmd == $L) ifTrue:[self printDotsMethodSource:true. ^ false ]. |
|
870 |
(cmd == $-) ifTrue:[self moveDotUp. self printDot. ^ false ]. |
|
871 |
(cmd == $+) ifTrue:[self moveDotDown. self printDot. ^ false ]. |
|
15195 | 872 |
(cmd == $?) ifTrue:[ |
19145 | 873 |
commandArg notEmpty ifTrue:[ |
874 |
self helpOn:commandArg. ^ false |
|
875 |
] |
|
15195 | 876 |
]. |
13740 | 877 |
|
878 |
"/ avoid usage print if return was typed ... |
|
879 |
((cmd == Character return) |
|
880 |
or:[cmd == Character linefeed]) ifTrue:[^ false]. |
|
881 |
||
882 |
self showValidCommandHelp. |
|
883 |
^ false. |
|
884 |
||
885 |
"Created: / 29-09-2011 / 08:58:47 / cg" |
|
886 |
! |
|
887 |
||
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
888 |
getCommand:prompt |
3126
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
889 |
"/ Screen notNil ifTrue:[ |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
890 |
"/ Screen allScreens do:[:aScreen | |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
891 |
"/ aScreen ungrabPointer. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
892 |
"/ aScreen ungrabKeyboard. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
893 |
"/ ]. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
894 |
"/ ]. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
895 |
|
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
896 |
Display notNil ifTrue:[ |
19389 | 897 |
Display ungrabPointer. |
898 |
Display ungrabKeyboard. |
|
852
5c4a0585ba0b
ungrab pointer for every input
Claus Gittinger <cg@exept.de>
parents:
720
diff
changeset
|
899 |
]. |
5c4a0585ba0b
ungrab pointer for every input
Claus Gittinger <cg@exept.de>
parents:
720
diff
changeset
|
900 |
|
8840 | 901 |
(prompt |
19389 | 902 |
? (nesting == 0 ifTrue:[ |
903 |
'MiniDebugger> ' |
|
904 |
] ifFalse:[ |
|
905 |
'MiniDebugger' , nesting printString , '>' |
|
20496 | 906 |
])) lowLevelErrorPrint. |
93 | 907 |
|
7706 | 908 |
UserInterrupt handle:[:ex | |
19389 | 909 |
ex restart |
159 | 910 |
] do:[ |
19389 | 911 |
|c cmd arg cnt| |
3700 | 912 |
|
19389 | 913 |
cmd := self getCharacter. |
914 |
cmd isNil ifTrue:[ |
|
20496 | 915 |
'<EOF>' lowLevelErrorPrintCR. |
19389 | 916 |
" |
917 |
mhmh end-of-file; |
|
20420 | 918 |
return a 'c' (for continue); hope that's ok. |
19389 | 919 |
" |
920 |
cmd := $c |
|
921 |
]. |
|
93 | 922 |
|
19389 | 923 |
cnt := nil. |
924 |
(cmd isDigit) ifTrue:[ |
|
925 |
cnt := 0. |
|
926 |
[ |
|
927 |
cnt := (cnt * 10) + cmd digitValue. |
|
928 |
cmd := self getCharacter |
|
929 |
] doWhile:[cmd notNil and:[cmd isDigit]]. |
|
930 |
[cmd notNil and:[cmd == Character space]] whileTrue:[ |
|
931 |
cmd := self getCharacter |
|
932 |
]. |
|
20496 | 933 |
cmd isNil ifTrue:[ '<EOF>' lowLevelErrorPrintCR ]. |
19389 | 934 |
]. |
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
935 |
|
19389 | 936 |
" |
937 |
collect to end-of-line in arg |
|
938 |
" |
|
939 |
c := cmd. |
|
940 |
arg := ''. |
|
941 |
[c isNil or:[c isEndOfLineCharacter]] whileFalse: [ |
|
942 |
arg := arg copyWith:c. |
|
943 |
c := self getCharacter. |
|
20496 | 944 |
c isNil ifTrue:[ '<EOF>' lowLevelErrorPrintCR ]. |
19389 | 945 |
]. |
946 |
commandArg := (arg copyFrom:2) withoutSeparators. |
|
947 |
command := cmd. |
|
948 |
commandCount := cnt. |
|
1 | 949 |
]. |
3700 | 950 |
^ command |
976 | 951 |
|
3700 | 952 |
"Modified: / 31.7.1998 / 16:11:01 / cg" |
1 | 953 |
! |
954 |
||
15195 | 955 |
helpOn:commandArg |
956 |
|args className sym val match showMethod| |
|
957 |
||
958 |
commandArg withoutSeparators isEmpty ifTrue:[ |
|
20496 | 959 |
'usage: H className [methodPattern]' lowLevelErrorPrintCR. |
960 |
^self |
|
15195 | 961 |
]. |
962 |
args := commandArg asCollectionOfWords. |
|
963 |
className := args first. |
|
16557 | 964 |
|
15195 | 965 |
(sym := className asSymbolIfInterned) isNil ifTrue:[ |
20496 | 966 |
'no such class' lowLevelErrorPrintCR. |
967 |
^ self. |
|
15195 | 968 |
]. |
20496 | 969 |
val := Smalltalk at:sym ifAbsent:['no such class' lowLevelErrorPrintCR. ^ self.]. |
15195 | 970 |
val isBehavior ifFalse:[ |
20496 | 971 |
'not a class: ' lowLevelErrorPrint. className lowLevelErrorPrintCR. |
972 |
val := val class. |
|
973 |
'showing help for ' lowLevelErrorPrint. val name lowLevelErrorPrintCR. |
|
15195 | 974 |
]. |
975 |
args size > 1 ifTrue:[ |
|
20496 | 976 |
match := args at:2 |
15195 | 977 |
] ifFalse:[ |
20496 | 978 |
match := '*' |
15195 | 979 |
]. |
980 |
||
16557 | 981 |
showMethod := |
20496 | 982 |
[:sel :cls | |
983 |
|mthd| |
|
15195 | 984 |
|
20496 | 985 |
((match includesMatchCharacters and:[ sel matches:match caseSensitive:false]) |
986 |
or:[ sel asLowercase startsWith:match asLowercase ]) ifTrue:[ |
|
987 |
mthd := cls compiledMethodAt:sel. |
|
988 |
mthd category ~= 'documentation' ifTrue:[ |
|
989 |
sel lowLevelErrorPrintCR. |
|
990 |
(mthd comment ? '') asStringCollection do:[:l | |
|
991 |
' ' lowLevelErrorPrint. l withoutSeparators lowLevelErrorPrintCR. |
|
992 |
]. |
|
993 |
'' lowLevelErrorPrintCR |
|
994 |
]. |
|
995 |
]. |
|
996 |
]. |
|
15195 | 997 |
|
998 |
val theMetaclass selectors copy sort do:[:sel | |
|
20496 | 999 |
showMethod value:sel value:val theMetaclass |
15195 | 1000 |
]. |
1001 |
val theNonMetaclass selectors copy sort do:[:sel | |
|
20496 | 1002 |
showMethod value:sel value:val theNonMetaclass |
15195 | 1003 |
]. |
1004 |
! |
|
1005 |
||
1 | 1006 |
interpreterLoopWith:anObject |
16079 | 1007 |
'MinDebugger read-eval-print loop; exit with "#exit"; help with "?"' printCR. |
16557 | 1008 |
ReadEvalPrintLoop new |
19389 | 1009 |
doChunkFormat:false; |
1010 |
error:(Processor activeProcess stderr); |
|
1011 |
prompt:'mDBG > '; |
|
1012 |
readEvalPrintLoop. |
|
3700 | 1013 |
|
10630 | 1014 |
"/ |line done rslt| |
1015 |
"/ |
|
1016 |
"/ 'read-eval-print loop; exit with empty line' printCR. |
|
1017 |
"/ '' printCR. |
|
1018 |
"/ |
|
1019 |
"/ done := false. |
|
1020 |
"/ [done] whileFalse:[ |
|
1021 |
"/ '> ' print. |
|
1022 |
"/ |
|
1023 |
"/ line := Stdin nextLine. |
|
1024 |
"/ (line size == 0) ifTrue:[ |
|
1025 |
"/ done := true |
|
1026 |
"/ ] ifFalse:[ |
|
1027 |
"/ "/ rslt := Compiler evaluate:line |
|
1028 |
"/ "/ receiver:anObject |
|
1029 |
"/ "/ notifying:nil. |
|
1030 |
"/ |
|
1031 |
"/ rslt := Compiler |
|
1032 |
"/ evaluate:line |
|
1033 |
"/ in:dot |
|
1034 |
"/ receiver:dot receiver |
|
1035 |
"/ notifying:self "/ nil |
|
1036 |
"/ ifFail:[]. |
|
1037 |
"/ rslt printCR. |
|
1038 |
"/ ] |
|
1039 |
"/ ] |
|
1424 | 1040 |
|
3700 | 1041 |
"Modified: / 31.7.1998 / 16:01:47 / cg" |
618 | 1042 |
! |
1043 |
||
2772 | 1044 |
printAllBacktraces |
1045 |
Process allInstancesDo:[:p | |
|
20496 | 1046 |
(p isActive not |
1047 |
and:[p isDead not]) ifTrue:[ |
|
1048 |
'---------------------------------------------------------' lowLevelErrorPrintCR. |
|
20499 | 1049 |
' proc id=' lowLevelErrorPrint. p id asString lowLevelErrorPrint. |
1050 |
' name=''' lowLevelErrorPrint. p name asString lowLevelErrorPrint. |
|
1051 |
''' createdBy: ' lowLevelErrorPrint. p creatorId asString lowLevelErrorPrint. |
|
1052 |
' state=' lowLevelErrorPrint. p state asString lowLevelErrorPrint. |
|
1053 |
' prio=' lowLevelErrorPrint. p priority asString lowLevelErrorPrintCR. |
|
20496 | 1054 |
'' lowLevelErrorPrintCR. '' lowLevelErrorPrintCR. |
2772 | 1055 |
|
20496 | 1056 |
self printBacktraceFrom:(p suspendedContext) |
1057 |
] |
|
2772 | 1058 |
] |
1059 |
! |
|
1060 |
||
618 | 1061 |
showProcesses |
14797 | 1062 |
self showProcesses:#all |
1063 |
! |
|
1064 |
||
1065 |
showProcesses:how |
|
618 | 1066 |
|active| |
1067 |
||
1068 |
active := Processor activeProcess. |
|
20497 | 1069 |
'current id=' lowLevelErrorPrint. |
1070 |
active id printString lowLevelErrorPrint. |
|
1071 |
' name=''' lowLevelErrorPrint. active name lowLevelErrorPrint. '''' lowLevelErrorPrintCR. |
|
618 | 1072 |
|
16094 | 1073 |
(Process allSubInstances sort:[:a :b | (a id ? -1)<(b id ? -1)]) do:[:p | |
20496 | 1074 |
|doShow| |
14797 | 1075 |
|
20496 | 1076 |
doShow := (how == #all). |
1077 |
doShow := doShow or:[ (how == #dead) and:[ p isDead ]]. |
|
1078 |
doShow := doShow or:[ (how ~~ #dead) and:[ p isDead not ]]. |
|
1079 |
doShow ifTrue:[ |
|
1080 |
'proc id=' lowLevelErrorPrint. (p id printStringPaddedTo:6) lowLevelErrorPrint. |
|
1081 |
(p state printStringPaddedTo:10) lowLevelErrorPrint. |
|
1082 |
' pri=' lowLevelErrorPrint. (p priority printStringPaddedTo:2) lowLevelErrorPrint. |
|
1083 |
' creator:' lowLevelErrorPrint. (p creatorId printStringPaddedTo:5) lowLevelErrorPrint. |
|
1084 |
' group:' lowLevelErrorPrint. (p processGroupId printStringPaddedTo:5) lowLevelErrorPrint. |
|
1085 |
' sys:' lowLevelErrorPrint. (p isSystemProcess ifTrue:'y' ifFalse:'n') lowLevelErrorPrint. |
|
1086 |
' ui:' lowLevelErrorPrint. (p isGUIProcess ifTrue:'y' ifFalse:'n') lowLevelErrorPrint. |
|
1087 |
' name=''' lowLevelErrorPrint. p name lowLevelErrorPrint. |
|
1088 |
'''' lowLevelErrorPrintCR. |
|
1089 |
] |
|
618 | 1090 |
] |
1424 | 1091 |
|
3700 | 1092 |
"Modified: / 31.7.1998 / 16:30:19 / cg" |
7701 | 1093 |
! |
1094 |
||
1095 |
showValidCommandHelp |
|
19144 | 1096 |
'valid commands: |
16095 | 1097 |
c ........ continue |
1098 |
s ........ step |
|
1099 |
t ........ trace (continue with trace) |
|
1100 |
a [id] ... abort (i.e. raise abort signal) in (current) process |
|
1101 |
T [id] ... terminate (current) process |
|
1102 |
W [id] ... stop (current) process |
|
1103 |
R [id] ... resume (current) process |
|
1104 |
Q [id] ... quick terminate (current) process - no unwinds or cleanup |
|
7701 | 1105 |
|
16095 | 1106 |
p ........ list processes ("P" for full list) |
1107 |
w [id] ... walkback (of current/process with id) |
|
16557 | 1108 |
b [id] ... full (VM) backtrace with more detail |
16095 | 1109 |
B ........ backtrace of all other processes |
7701 | 1110 |
|
16095 | 1111 |
U ........ unwrap all traced/breakpointed methods |
1112 |
D ........ disable all line breakpoints |
|
1113 |
h [-/+] .. disable/enable halts |
|
1114 |
g ........ collect all garbage |
|
1115 |
g 2 ...... collect all garbage & reclaim symbols |
|
1116 |
g 3 ...... collect all garbage, reclaim symbols and compress |
|
7701 | 1117 |
|
16095 | 1118 |
S ........ save snapshot into "crash.img" |
1119 |
C ........ save session changes to a separate change file |
|
1120 |
x ........ exit Smalltalk ("X" to exit with core dump) |
|
19149 | 1121 |
Y ........ reopen display, reopen launcher |
7701 | 1122 |
|
16095 | 1123 |
. ........ print dot (the current context) |
1124 |
- ........ move dot up (sender) |
|
1125 |
+ ........ move dot down (called context) |
|
1126 |
l ........ list dot''s method source around PC ("L" for full list) |
|
7701 | 1127 |
|
16095 | 1128 |
r ........ receiver (in dot) printString |
1129 |
i [expr] . inspect expression (or receiver in dot) |
|
1130 |
I ........ interpreter (expression evaluator) |
|
19144 | 1131 |
e expr ... evaluate expression & print result ("E" to not print) |
1132 |
? c [p] .. help on class c (selectors matching p) |
|
20496 | 1133 |
' lowLevelErrorPrintCR. |
7701 | 1134 |
|
14798 | 1135 |
(XWorkstation notNil and:[ Screen default isKindOf:XWorkstation ]) ifTrue:[ |
1136 |
' To repair a broken X-Connection, enter an interpreter (enter "I") and evaluate: |
|
7701 | 1137 |
Display := XWorkstation new. |
14798 | 1138 |
Display initializeFor:''localhost:0''. |
7701 | 1139 |
Display startDispatch. |
1140 |
NewLauncher openOnDevice:Display. |
|
16095 | 1141 |
#exit |
14798 | 1142 |
then enter "c" to continue; a NewLauncher should pop up soon. |
20496 | 1143 |
' lowLevelErrorPrintCR |
14798 | 1144 |
] |
15859 | 1145 |
|
15930 | 1146 |
"Modified: / 03-02-2014 / 10:38:36 / cg" |
1 | 1147 |
! ! |
618 | 1148 |
|
658 | 1149 |
!MiniDebugger class methodsFor:'documentation'! |
1150 |
||
1151 |
version |
|
18681 | 1152 |
^ '$Header$' |
13113 | 1153 |
! |
1154 |
||
1155 |
version_CVS |
|
18681 | 1156 |
^ '$Header$' |
658 | 1157 |
! ! |
16626 | 1158 |