author | Claus Gittinger <cg@exept.de> |
Tue, 21 Aug 2001 14:11:41 +0200 | |
changeset 5920 | b691be894985 |
parent 5919 | 49c864ba1275 |
child 5921 | 1c57ce7ad684 |
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 |
" |
|
12 |
||
720 | 13 |
Object subclass:#MiniDebugger |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
14 |
instanceVariableNames:'tracing stepping traceBlock command commandArg commandCount |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
15 |
enteringContext dot nesting' |
976 | 16 |
classVariableNames:'TheOneAndOnlyDebugger' |
17 |
poolDictionaries:'' |
|
18 |
category:'System-Debugging-Support' |
|
1 | 19 |
! |
20 |
||
618 | 21 |
!MiniDebugger class methodsFor:'documentation'! |
89 | 22 |
|
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
159 | 26 |
All Rights Reserved |
1 | 27 |
|
89 | 28 |
This software is furnished under a license and may be used |
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
1 | 36 |
|
89 | 37 |
documentation |
38 |
" |
|
39 |
a primitive (non graphical) debugger for use on systems without |
|
40 |
graphics or when the real debugger dies (i.e. an error occurs in |
|
41 |
the graphical debugger). |
|
93 | 42 |
Also, if an interrupt occurs within the debuger, this one is called |
43 |
for. |
|
1297 | 44 |
|
45 |
[author:] |
|
46 |
Claus Gittinger |
|
89 | 47 |
" |
48 |
! ! |
|
1 | 49 |
|
618 | 50 |
!MiniDebugger class methodsFor:'instance creation'! |
51 |
||
4572 | 52 |
enter:aContext withMessage:aString mayProceed:mayProceed |
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
53 |
"enter a miniDebugger" |
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
54 |
|
4960 | 55 |
|active con| |
618 | 56 |
|
57 |
StepInterruptPending := nil. |
|
58 |
||
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
59 |
Object errorSignal handle:[:ex | |
3701 | 60 |
ex return |
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
61 |
] do:[ |
3701 | 62 |
thisContext isRecursive ifTrue:[ |
63 |
"/ 'recursive error in debugger ignored' errorPrintCR. |
|
64 |
^ self |
|
65 |
]. |
|
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
66 |
aString printCR. |
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
67 |
Processor notNil ifTrue:[ |
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
68 |
active := Processor activeProcess. |
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
69 |
'process: id=' print. active id print. |
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
70 |
' name=' print. active name printCR. |
4960 | 71 |
|
72 |
'context: ' print. aContext printString printCR. |
|
73 |
(con := aContext) notNil ifTrue:[ |
|
74 |
con := con sender. |
|
75 |
' ......: ' print. con printString printCR. |
|
76 |
[con notNil] whileTrue:[ |
|
77 |
con := con sender. |
|
78 |
' ......: ' print. con printString printCR. |
|
79 |
] |
|
80 |
] |
|
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
81 |
]. |
618 | 82 |
]. |
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
83 |
|
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
84 |
OperatingSystem hasConsole ifFalse:[ |
5920 | 85 |
thisContext isRecursive ifTrue:[Smalltalk exit]. |
86 |
||
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
87 |
Object errorSignal handle:[:ex | |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
88 |
ex return |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
89 |
] do:[ |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
90 |
self warn:('Unexpected error:\' , aString , '\\No MiniDebugger functionality available') withCRs . |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
91 |
]. |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
92 |
|
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
93 |
Object errorSignal handle:[:ex | |
4961
5419c9a32316
abort after unproceedable error
Stefan Vogel <sv@exept.de>
parents:
4960
diff
changeset
|
94 |
'cannot raise AbortSignal - exiting ...' errorPrintCR. |
5419c9a32316
abort after unproceedable error
Stefan Vogel <sv@exept.de>
parents:
4960
diff
changeset
|
95 |
Smalltalk exit. |
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
96 |
] do:[ |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
97 |
AbortSignal raise. |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
98 |
] |
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
99 |
] ifTrue:[ |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
100 |
self new enter:aContext mayProceed:mayProceed. |
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
101 |
]. |
4961
5419c9a32316
abort after unproceedable error
Stefan Vogel <sv@exept.de>
parents:
4960
diff
changeset
|
102 |
mayProceed ifFalse:[ |
5419c9a32316
abort after unproceedable error
Stefan Vogel <sv@exept.de>
parents:
4960
diff
changeset
|
103 |
AbortSignal raise |
5419c9a32316
abort after unproceedable error
Stefan Vogel <sv@exept.de>
parents:
4960
diff
changeset
|
104 |
]. |
618 | 105 |
^ nil |
1424 | 106 |
|
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
107 |
"Modified: / 19.5.1999 / 18:14:33 / cg" |
618 | 108 |
! |
1 | 109 |
|
4572 | 110 |
enterWithMessage:aString mayProceed:mayProceed |
111 |
"enter a miniDebugger" |
|
112 |
||
113 |
self enter:thisContext sender withMessage:aString mayProceed:mayProceed |
|
114 |
||
115 |
"Modified: / 19.5.1999 / 18:14:33 / cg" |
|
116 |
! |
|
117 |
||
1 | 118 |
new |
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
119 |
"redefined to make certain that there is only one miniDebugger |
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
120 |
in the system" |
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
121 |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
122 |
^ self basicNew initialize. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
123 |
|
33 | 124 |
TheOneAndOnlyDebugger isNil ifTrue:[ |
1424 | 125 |
TheOneAndOnlyDebugger := self basicNew initialize |
1 | 126 |
]. |
33 | 127 |
^ TheOneAndOnlyDebugger |
1424 | 128 |
|
3700 | 129 |
" |
130 |
TheOneAndOnlyDebugger := nil |
|
131 |
" |
|
132 |
||
3701 | 133 |
"Modified: / 31.7.1998 / 17:08:07 / cg" |
1 | 134 |
! |
135 |
||
4966 | 136 |
openOn:aProcess |
137 |
"enter a miniDebugger" |
|
138 |
||
5054 | 139 |
self |
140 |
enter:thisContext sender |
|
141 |
withMessage:'MiniDebugger [info]: Attention - process debugging not possible.' |
|
142 |
mayProceed:true |
|
4966 | 143 |
|
144 |
"Modified: / 19.5.1999 / 18:14:33 / cg" |
|
145 |
! |
|
146 |
||
1 | 147 |
singleStep:aBlock |
148 |
|aDebugger| |
|
149 |
||
150 |
aDebugger := self new stepping. |
|
241 | 151 |
ObjectMemory stepInterruptHandler:aDebugger. |
2 | 152 |
ObjectMemory flushInlineCaches. |
241 | 153 |
StepInterruptPending := 1. |
154 |
InterruptPending := 1. |
|
1 | 155 |
aBlock value. |
2 | 156 |
StepInterruptPending := nil. |
157 |
ObjectMemory stepInterruptHandler:nil |
|
1 | 158 |
! |
159 |
||
160 |
trace:aBlock |
|
1424 | 161 |
self trace:aBlock with:[:where | where printCR] |
162 |
||
163 |
"Modified: 20.5.1996 / 10:27:37 / cg" |
|
1 | 164 |
! |
165 |
||
166 |
trace:aBlock on:aStream |
|
167 |
self trace:aBlock with:[:where | where printString printOn:aStream. |
|
159 | 168 |
aStream cr] |
1 | 169 |
! |
170 |
||
171 |
trace:aBlock with:aTraceBlock |
|
172 |
|aDebugger| |
|
173 |
||
174 |
aDebugger := self new tracingWith:aTraceBlock. |
|
241 | 175 |
ObjectMemory stepInterruptHandler:aDebugger. |
1 | 176 |
ObjectMemory flushInlineCaches. |
241 | 177 |
StepInterruptPending := 1. |
178 |
InterruptPending := 1. |
|
1 | 179 |
aBlock value. |
2 | 180 |
ObjectMemory stepInterruptHandler:nil. |
1 | 181 |
StepInterruptPending := nil. |
182 |
^ nil |
|
183 |
! ! |
|
184 |
||
618 | 185 |
!MiniDebugger methodsFor:'initialization'! |
1 | 186 |
|
187 |
initialize |
|
188 |
traceBlock := nil. |
|
189 |
tracing := false. |
|
190 |
stepping := false |
|
191 |
! ! |
|
192 |
||
618 | 193 |
!MiniDebugger methodsFor:'interrupt handling'! |
1 | 194 |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
195 |
enter:aContext mayProceed:mayProceed |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
196 |
|c leaveCmd stillHere yesNo| |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
197 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
198 |
enteringContext := dot := aContext. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
199 |
nesting := 0. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
200 |
c := aContext. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
201 |
[c notNil] whileTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
202 |
c selector == #enter:mayProceed: ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
203 |
nesting := nesting + 1. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
204 |
]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
205 |
c := c sender. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
206 |
]. |
74 | 207 |
|
208 |
stillHere := true. |
|
209 |
[stillHere] whileTrue:[ |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
210 |
AbortSignal handle:[:ex | |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
211 |
'** Abort Signal cought - back in previous debugLevel' printCR. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
212 |
] do:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
213 |
Object errorSignal handle:[:ex | |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
214 |
'Error while executing command: ' print. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
215 |
ex description printCR. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
216 |
yesNo := self getCommand:'- (i)gnore / (p)roceed / (d)ebug ? '. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
217 |
yesNo == $d ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
218 |
ex reject |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
219 |
]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
220 |
yesNo == $p ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
221 |
ex proceed |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
222 |
]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
223 |
] do:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
224 |
leaveCmd := self commandLoop. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
225 |
]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
226 |
]. |
1 | 227 |
|
3769 | 228 |
(leaveCmd == $s) ifTrue: [ |
229 |
self stepping. |
|
230 |
ObjectMemory flushInlineCaches. |
|
231 |
ObjectMemory stepInterruptHandler:self. |
|
232 |
stillHere := false. |
|
233 |
StepInterruptPending := 1. |
|
234 |
InterruptPending := 1 |
|
235 |
]. |
|
236 |
(leaveCmd == $t) ifTrue: [ |
|
237 |
traceBlock := [:where | where fullPrint]. |
|
238 |
ObjectMemory flushInlineCaches. |
|
239 |
ObjectMemory stepInterruptHandler:self. |
|
240 |
stillHere := false. |
|
241 |
StepInterruptPending := 1. |
|
242 |
InterruptPending := 1 |
|
243 |
]. |
|
244 |
(leaveCmd == $c) ifTrue: [ |
|
245 |
traceBlock := nil. |
|
246 |
stillHere := false. |
|
247 |
stepping := false. |
|
248 |
tracing := false. |
|
249 |
StepInterruptPending := nil. |
|
250 |
InterruptPending := nil |
|
251 |
]. |
|
252 |
(leaveCmd == $a) ifTrue: [ |
|
253 |
"abort" |
|
254 |
stepping := false. |
|
255 |
tracing := false. |
|
256 |
StepInterruptPending := nil. |
|
257 |
InterruptPending := nil. |
|
258 |
self doAbort. |
|
259 |
stillHere := true. |
|
260 |
"failed abort" |
|
261 |
]. |
|
1 | 262 |
]. |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
263 |
enteringContext := dot := nil. |
1 | 264 |
^ nil |
3769 | 265 |
|
266 |
"Modified: / 18.8.1998 / 18:10:29 / cg" |
|
618 | 267 |
! |
268 |
||
269 |
stepInterrupt |
|
270 |
|where| |
|
271 |
||
272 |
where := thisContext. "where is stepInterrupt context" |
|
273 |
where notNil ifTrue:[ |
|
1424 | 274 |
where := where sender "where is now interrupted methods context" |
618 | 275 |
]. |
276 |
stepping ifTrue:[ |
|
1424 | 277 |
where notNil ifTrue:[ |
278 |
where fullPrint |
|
279 |
] ifFalse:[ |
|
280 |
'stepInterrupt: no context' errorPrintCR |
|
281 |
]. |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
282 |
self enter:where mayProceed:true |
618 | 283 |
] ifFalse:[ |
1424 | 284 |
where notNil ifTrue:[ |
285 |
traceBlock notNil ifTrue:[ |
|
286 |
traceBlock value:where |
|
287 |
] |
|
288 |
] ifFalse:[ |
|
289 |
'traceInterrupt: no context' errorPrintCR |
|
290 |
]. |
|
291 |
ObjectMemory flushInlineCaches. |
|
292 |
StepInterruptPending := 1. |
|
293 |
InterruptPending := 1 |
|
618 | 294 |
] |
1424 | 295 |
|
296 |
"Modified: 20.5.1996 / 10:23:11 / cg" |
|
1 | 297 |
! ! |
298 |
||
618 | 299 |
!MiniDebugger methodsFor:'private'! |
74 | 300 |
|
618 | 301 |
findContext:aSelector |
302 |
|con| |
|
74 | 303 |
|
618 | 304 |
con := thisContext sender. |
305 |
[con notNil] whileTrue:[ |
|
306 |
(con isBlockContext not and:[con selector == aSelector]) ifTrue:[ |
|
307 |
"got it" |
|
308 |
^ con |
|
309 |
]. |
|
310 |
con := con sender |
|
74 | 311 |
]. |
618 | 312 |
^ nil |
74 | 313 |
! |
314 |
||
618 | 315 |
getContext |
316 |
|backtrace| |
|
317 |
backtrace := thisContext. |
|
318 |
(backtrace notNil) ifTrue: [ |
|
319 |
"remove Context getContext frame" |
|
320 |
backtrace := backtrace sender. |
|
321 |
"remove Debugger showContext frame" |
|
322 |
backtrace := backtrace sender. |
|
323 |
"remove Debugger commandLoop frame" |
|
324 |
backtrace := backtrace sender. |
|
325 |
"remove Debugger enter frame" |
|
326 |
backtrace := backtrace sender |
|
327 |
]. |
|
328 |
^ backtrace |
|
329 |
! |
|
74 | 330 |
|
2772 | 331 |
printBacktraceFrom:aContext |
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
332 |
|context n| |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
333 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
334 |
aContext isNil ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
335 |
'no context' errorPrintCR. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
336 |
^ self |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
337 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
338 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
339 |
context := aContext. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
340 |
n := commandCount. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
341 |
[context notNil] whileTrue: [ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
342 |
context fullPrint. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
343 |
context := context sender. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
344 |
n notNil ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
345 |
n := n - 1. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
346 |
n <= 0 ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
347 |
^ self |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
348 |
] |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
349 |
] |
2772 | 350 |
] |
351 |
! |
|
352 |
||
618 | 353 |
stepping |
354 |
traceBlock := nil. |
|
355 |
tracing := false. |
|
356 |
stepping := true |
|
74 | 357 |
! |
358 |
||
618 | 359 |
tracingWith:aBlockOrNil |
360 |
traceBlock := aBlockOrNil. |
|
361 |
stepping := false. |
|
362 |
tracing := true |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
363 |
! |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
364 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
365 |
printDot |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
366 |
dot fullPrint |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
367 |
! |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
368 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
369 |
moveDotUp |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
370 |
dot sender notNil ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
371 |
dot := dot sender. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
372 |
self printDot. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
373 |
] ifFalse:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
374 |
'** dot is the top of the calling chain' printCR. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
375 |
]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
376 |
! |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
377 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
378 |
moveDotDown |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
379 |
"/ sigh - must search |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
380 |
|c| |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
381 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
382 |
c := enteringContext. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
383 |
[ c notNil and:[ c sender ~~ dot ] ] whileTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
384 |
c := c sender. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
385 |
]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
386 |
c notNil ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
387 |
dot := c. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
388 |
self printDot. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
389 |
] ifFalse:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
390 |
'** dot is the bottom of the calling chain' printCR. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
391 |
]. |
618 | 392 |
! ! |
393 |
||
394 |
!MiniDebugger methodsFor:'user commands'! |
|
395 |
||
1 | 396 |
commandLoop |
3700 | 397 |
|cmd done valid context id proc| |
1 | 398 |
|
399 |
done := false. |
|
400 |
[done] whileFalse:[ |
|
1424 | 401 |
valid := false. |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
402 |
cmd := self getCommand:nil. |
2772 | 403 |
cmd isNil ifTrue:[ "/ EOF -> continue |
404 |
cmd := $c |
|
405 |
]. |
|
3700 | 406 |
|
407 |
commandArg notEmpty ifTrue:[ |
|
408 |
id := Number readFrom:commandArg onError:nil. |
|
409 |
||
410 |
id notNil ifTrue:[ |
|
411 |
proc := Process allSubInstances detect:[:p | p id == id] ifNone:nil. |
|
3701 | 412 |
proc == Processor activeProcess ifTrue:[ |
413 |
id := proc := nil |
|
414 |
] |
|
3700 | 415 |
] |
416 |
]. |
|
417 |
||
3701 | 418 |
(cmd == $l) ifTrue:[ |
1424 | 419 |
valid := true. |
3700 | 420 |
proc notNil ifTrue:[ |
421 |
'-------- walkback of process ' print. id print. ' -------' printCR. |
|
422 |
self printBacktraceFrom:(proc suspendedContext) |
|
423 |
] ifFalse:[ |
|
424 |
id notNil ifTrue:[ |
|
425 |
'no process with id: ' print. id printCR. |
|
426 |
] ifFalse:[ |
|
427 |
context isNil ifTrue: [ |
|
428 |
context := self getContext |
|
429 |
]. |
|
430 |
'-------- walkback of current process -------' printCR. |
|
431 |
self printBacktraceFrom:context |
|
432 |
] |
|
1424 | 433 |
]. |
434 |
]. |
|
3700 | 435 |
|
1424 | 436 |
(cmd == $b) ifTrue:[ |
437 |
valid := true. |
|
3700 | 438 |
proc notNil ifTrue:[ |
439 |
'-------- VM walkback of process ' print. id print. ' -------' printCR. |
|
440 |
ObjectMemory printStackBacktraceFrom:(proc suspendedContext) |
|
441 |
] ifFalse:[ |
|
442 |
id notNil ifTrue:[ |
|
443 |
'no process with id: ' print. id printCR. |
|
444 |
] ifFalse:[ |
|
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
445 |
'-------- VM walkback of current process -------' printCR. |
3700 | 446 |
ObjectMemory printStackBacktrace |
447 |
] |
|
448 |
] |
|
1424 | 449 |
]. |
3700 | 450 |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
451 |
(cmd == $S) ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
452 |
valid := true. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
453 |
ObjectMemory snapShotOn:'crash.img'. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
454 |
]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
455 |
|
2113
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
456 |
(cmd == $B) ifTrue:[ |
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
457 |
valid := true. |
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
458 |
self printAllBacktraces |
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
459 |
]. |
3700 | 460 |
|
1424 | 461 |
(cmd == $P) ifTrue:[ |
462 |
valid := true. |
|
463 |
self showProcesses. |
|
464 |
]. |
|
3700 | 465 |
|
1424 | 466 |
(cmd == $r) ifTrue:[ |
467 |
valid := true. |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
468 |
dot receiver printCR |
1424 | 469 |
]. |
3700 | 470 |
|
1424 | 471 |
(cmd == $i) ifTrue:[ |
472 |
valid := true. |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
473 |
MiniInspector openOn:(dot receiver) |
1424 | 474 |
]. |
3700 | 475 |
|
1424 | 476 |
(cmd == $I) ifTrue:[ |
477 |
valid := true. |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
478 |
self interpreterLoopWith:nil |
1424 | 479 |
]. |
480 |
context := nil. |
|
3009 | 481 |
|
1424 | 482 |
(cmd == $c) ifTrue:[valid := true. done := true]. |
483 |
(cmd == $s) ifTrue:[valid := true. done := true]. |
|
484 |
(cmd == $t) ifTrue:[valid := true. done := true]. |
|
485 |
(cmd == $a) ifTrue:[valid := true. done := true]. |
|
3700 | 486 |
(cmd == $u) ifTrue:[ |
487 |
stepping := false. |
|
488 |
tracing := false. |
|
489 |
Processor activeProcess vmTrace:false. |
|
490 |
]. |
|
491 |
||
492 |
(cmd == $T) ifTrue:[ |
|
493 |
valid := true. |
|
494 |
proc notNil ifTrue:[ |
|
495 |
proc terminate. |
|
496 |
] ifFalse:[ |
|
497 |
id notNil ifTrue:[ |
|
498 |
'no process with id: ' print. id printCR. |
|
499 |
] ifFalse:[ |
|
500 |
Processor terminateActive |
|
501 |
] |
|
502 |
] |
|
503 |
]. |
|
504 |
||
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
505 |
(cmd == $S) ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
506 |
valid := true. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
507 |
proc notNil ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
508 |
'stopping process id: ' print. id printCR. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
509 |
proc stop. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
510 |
] ifFalse:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
511 |
'invalid process id: ' print. id printCR. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
512 |
] |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
513 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
514 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
515 |
(cmd == $a) ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
516 |
"without id-arg, this is handled by caller" |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
517 |
proc notNil ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
518 |
valid := true. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
519 |
proc interruptWith:[AbortSignal raise] |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
520 |
] |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
521 |
]. |
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
522 |
|
3700 | 523 |
(cmd == $Q) ifTrue:[ |
524 |
valid := true. |
|
525 |
proc notNil ifTrue:[ |
|
526 |
proc terminateNoSignal. |
|
527 |
] ifFalse:[ |
|
528 |
id notNil ifTrue:[ |
|
529 |
'no process with id: ' print. id printCR. |
|
530 |
] ifFalse:[ |
|
531 |
Processor terminateActiveNoSignal |
|
532 |
] |
|
533 |
] |
|
534 |
]. |
|
535 |
||
536 |
(cmd == $g) ifTrue:[ |
|
537 |
valid := true. |
|
538 |
id == 3 ifTrue:[ |
|
539 |
ObjectMemory reclaimSymbols. |
|
540 |
ObjectMemory compressOldSpace. |
|
541 |
] ifFalse:[ |
|
542 |
id == 2 ifTrue:[ |
|
543 |
ObjectMemory reclaimSymbols. |
|
544 |
] ifFalse:[ |
|
545 |
ObjectMemory garbageCollect. |
|
546 |
] |
|
547 |
] |
|
548 |
]. |
|
549 |
||
550 |
(cmd == $U) ifTrue:[valid := true. MessageTracer unwrapAllMethods]. |
|
551 |
(cmd == $X) ifTrue:[valid := true. Smalltalk fatalAbort]. |
|
552 |
(cmd == $x) ifTrue:[valid := true. OperatingSystem exit]. |
|
553 |
||
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
554 |
(cmd == $.) ifTrue:[valid := true. self printDot ]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
555 |
(cmd == $-) ifTrue:[valid := true. self moveDotUp ]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
556 |
(cmd == $+) ifTrue:[valid := true. self moveDotDown ]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
557 |
|
4470 | 558 |
"/ avoid usage print if return was typed ... |
559 |
((cmd == Character return) |
|
560 |
or:[cmd == Character linefeed]) ifTrue:[valid := true.]. |
|
561 |
||
1424 | 562 |
valid ifFalse: [ |
563 |
'valid commands: |
|
3700 | 564 |
c ..... continue |
565 |
s ..... step |
|
566 |
t ..... trace (continue with trace) |
|
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
567 |
a [id]. abort (i.e. raise abort signal) in (current) process |
3700 | 568 |
T [id]. terminate (current) process |
569 |
Q [id]. quick terminate (current) process - no unwinds or cleanup |
|
570 |
||
571 |
P ..... list processes |
|
3701 | 572 |
l [id]. print context chain (of process with id) |
3700 | 573 |
b [id]. full (VM) backtrace |
574 |
B ..... backtrace of all other processes |
|
575 |
||
576 |
U ..... unwrap all traced/breakpointed methods |
|
577 |
g ..... collect all garbage |
|
4463 | 578 |
g 2.... collect all garbage & reclaim symbols |
579 |
g 3.... collect all garbage, reclaim symbols and compress |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
580 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
581 |
S ..... save snapshot into crash.img |
3700 | 582 |
X ..... exit (+core) |
583 |
x ..... exit Smalltalk |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
584 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
585 |
. ..... print dot (the current context) |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
586 |
- ..... move dot up |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
587 |
+ ..... move dot down |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
588 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
589 |
r ..... receiver (in dot) printString |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
590 |
i ..... inspect receiver (in dot) |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
591 |
I ..... interpreter (expression evaluator) |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
592 |
|
3700 | 593 |
' errorPrintCR |
1424 | 594 |
] |
1 | 595 |
]. |
2113
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
596 |
context := nil. |
1 | 597 |
^ cmd |
1424 | 598 |
|
3701 | 599 |
"Modified: / 31.7.1998 / 17:10:23 / cg" |
1 | 600 |
! |
601 |
||
618 | 602 |
doAbort |
603 |
|con sig| |
|
604 |
||
605 |
(sig := Object abortSignal) isHandled ifTrue:[ |
|
1424 | 606 |
sig raise. |
607 |
'abort raise failed' errorPrintCR. |
|
618 | 608 |
]. |
609 |
||
610 |
"TEMPORARY kludge - find event handler context |
|
611 |
this will be removed, once real debugging is possible |
|
612 |
" |
|
613 |
con := self findContext:#processEvent. |
|
614 |
con isNil ifTrue:[ |
|
1424 | 615 |
con := self findContext:#dispatch. |
618 | 616 |
]. |
617 |
con notNil ifTrue:[ |
|
1424 | 618 |
"got it" |
619 |
con return. |
|
620 |
'return failed' errorPrintCR. |
|
618 | 621 |
]. |
622 |
||
1424 | 623 |
'found no context to resume' errorPrintCR. |
624 |
||
625 |
"Modified: 20.5.1996 / 10:23:00 / cg" |
|
618 | 626 |
! |
627 |
||
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
628 |
getCommand:prompt |
3126
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
629 |
"/ Screen notNil ifTrue:[ |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
630 |
"/ Screen allScreens do:[:aScreen | |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
631 |
"/ aScreen ungrabPointer. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
632 |
"/ aScreen ungrabKeyboard. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
633 |
"/ ]. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
634 |
"/ ]. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
635 |
|
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
636 |
Display notNil ifTrue:[ |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
637 |
Display ungrabPointer. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
638 |
Display ungrabKeyboard. |
852
5c4a0585ba0b
ungrab pointer for every input
Claus Gittinger <cg@exept.de>
parents:
720
diff
changeset
|
639 |
]. |
5c4a0585ba0b
ungrab pointer for every input
Claus Gittinger <cg@exept.de>
parents:
720
diff
changeset
|
640 |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
641 |
(prompt |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
642 |
? (nesting == 0 ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
643 |
'MiniDebugger> ' |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
644 |
] ifFalse:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
645 |
'MiniDebugger' , nesting printString , '>' |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
646 |
])) print. |
93 | 647 |
|
976 | 648 |
UserInterruptSignal handle:[:ex | |
649 |
ex restart |
|
159 | 650 |
] do:[ |
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
651 |
|c cmd arg cnt| |
3700 | 652 |
|
976 | 653 |
cmd := Character fromUser. |
654 |
cmd isNil ifTrue:[ |
|
655 |
" |
|
656 |
mhmh end-of-file; |
|
657 |
return a 'c' (for continue); hope thats ok. |
|
658 |
" |
|
659 |
cmd := $c |
|
660 |
]. |
|
93 | 661 |
|
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
662 |
cnt := nil. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
663 |
(cmd isDigit) ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
664 |
cnt := 0. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
665 |
[cmd isDigit] whileTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
666 |
cnt := cnt * 10 + cmd digitValue. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
667 |
cmd := Character fromUser |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
668 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
669 |
[cmd == Character space] whileTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
670 |
cmd := Character fromUser |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
671 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
672 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
673 |
|
976 | 674 |
" |
3700 | 675 |
collect to end-of-line in arg |
976 | 676 |
" |
677 |
c := cmd. |
|
3700 | 678 |
arg := ''. |
976 | 679 |
[c isNil or:[c isEndOfLineCharacter]] whileFalse: [ |
3700 | 680 |
arg := arg copyWith:c. |
976 | 681 |
c := Character fromUser. |
682 |
]. |
|
3700 | 683 |
commandArg := arg copyFrom:2. |
684 |
command := cmd. |
|
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
685 |
commandCount := cnt. |
1 | 686 |
]. |
3700 | 687 |
^ command |
976 | 688 |
|
3700 | 689 |
"Modified: / 31.7.1998 / 16:11:01 / cg" |
1 | 690 |
! |
691 |
||
692 |
interpreterLoopWith:anObject |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
693 |
|line done rslt| |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
694 |
|
1424 | 695 |
'read-eval-print loop; exit with empty line' printCR. |
3700 | 696 |
'' printCR. |
697 |
||
1 | 698 |
done := false. |
699 |
[done] whileFalse:[ |
|
3700 | 700 |
'> ' print. |
701 |
||
1424 | 702 |
line := Stdin nextLine. |
703 |
(line size == 0) ifTrue:[ |
|
704 |
done := true |
|
705 |
] ifFalse:[ |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
706 |
"/ rslt := Compiler evaluate:line |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
707 |
"/ receiver:anObject |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
708 |
"/ notifying:nil. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
709 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
710 |
rslt := Compiler |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
711 |
evaluate:line |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
712 |
in:dot |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
713 |
receiver:dot receiver |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
714 |
notifying:nil |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
715 |
ifFail:[]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
716 |
rslt printCR. |
1424 | 717 |
] |
1 | 718 |
] |
1424 | 719 |
|
3700 | 720 |
"Modified: / 31.7.1998 / 16:01:47 / cg" |
618 | 721 |
! |
722 |
||
2772 | 723 |
printAllBacktraces |
724 |
Process allInstancesDo:[:p | |
|
725 |
(p ~~ Processor activeProcess |
|
726 |
and:[p isDead not]) ifTrue:[ |
|
727 |
'---------------------------------------------------------' printCR. |
|
728 |
' proc id=' print. p id print. |
|
729 |
' name=''' print. p name print. |
|
730 |
''' createdBy: ' print. p creatorId print. |
|
731 |
' state=' print. p state print. |
|
732 |
' prio=' print. p priority printCR. |
|
733 |
'' printCR. '' printCR. |
|
734 |
||
735 |
self printBacktraceFrom:(p suspendedContext) |
|
736 |
] |
|
737 |
] |
|
738 |
! |
|
739 |
||
618 | 740 |
showProcesses |
741 |
|active| |
|
742 |
||
743 |
active := Processor activeProcess. |
|
3700 | 744 |
'current id=' print. active id print. ' name=''' print. active name print. '''' printCR. |
618 | 745 |
|
3700 | 746 |
Process allSubInstancesDo:[:p | |
747 |
'proc id=' print. (p id printStringPaddedTo:5) print. |
|
748 |
(p state printStringPaddedTo:10) print. |
|
749 |
' pri=' print. (p priority printStringPaddedTo:2) print. |
|
750 |
' creator:' print. (p creatorId printStringPaddedTo:5) print. |
|
751 |
' name=''' print. p name print. |
|
752 |
'''' printCR. |
|
618 | 753 |
] |
1424 | 754 |
|
3700 | 755 |
"Modified: / 31.7.1998 / 16:30:19 / cg" |
1 | 756 |
! ! |
618 | 757 |
|
658 | 758 |
!MiniDebugger class methodsFor:'documentation'! |
759 |
||
760 |
version |
|
5920 | 761 |
^ '$Header: /cvs/stx/stx/libbasic/MiniDebugger.st,v 1.52 2001-08-21 12:11:41 cg Exp $' |
658 | 762 |
! ! |