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