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