author | Claus Gittinger <cg@exept.de> |
Tue, 17 Jun 2003 18:10:28 +0200 | |
changeset 7408 | 43bd10f2f2e6 |
parent 7093 | 60bad14d38fc |
child 7476 | 2e646cca131e |
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 |
||
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
13 |
"{ Package: 'stx:libbasic' }" |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
14 |
|
720 | 15 |
Object subclass:#MiniDebugger |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
16 |
instanceVariableNames:'tracing stepping traceBlock command commandArg commandCount |
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
17 |
enteringContext dot nesting' |
976 | 18 |
classVariableNames:'TheOneAndOnlyDebugger' |
19 |
poolDictionaries:'' |
|
20 |
category:'System-Debugging-Support' |
|
1 | 21 |
! |
22 |
||
618 | 23 |
!MiniDebugger class methodsFor:'documentation'! |
89 | 24 |
|
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1988 by Claus Gittinger |
|
159 | 28 |
All Rights Reserved |
1 | 29 |
|
89 | 30 |
This software is furnished under a license and may be used |
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
1 | 38 |
|
89 | 39 |
documentation |
40 |
" |
|
41 |
a primitive (non graphical) debugger for use on systems without |
|
42 |
graphics or when the real debugger dies (i.e. an error occurs in |
|
43 |
the graphical debugger). |
|
93 | 44 |
Also, if an interrupt occurs within the debuger, this one is called |
45 |
for. |
|
1297 | 46 |
|
47 |
[author:] |
|
48 |
Claus Gittinger |
|
89 | 49 |
" |
50 |
! ! |
|
1 | 51 |
|
618 | 52 |
!MiniDebugger class methodsFor:'instance creation'! |
53 |
||
4572 | 54 |
enter:aContext withMessage:aString mayProceed:mayProceed |
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
55 |
"enter a miniDebugger" |
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
56 |
|
4960 | 57 |
|active con| |
618 | 58 |
|
59 |
StepInterruptPending := nil. |
|
60 |
||
7093
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
61 |
Error handle:[:ex | |
3701 | 62 |
ex return |
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
63 |
] do:[ |
3701 | 64 |
thisContext isRecursive ifTrue:[ |
65 |
"/ 'recursive error in debugger ignored' errorPrintCR. |
|
66 |
^ self |
|
67 |
]. |
|
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
68 |
aString printCR. |
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
69 |
Processor notNil ifTrue:[ |
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
70 |
active := Processor activeProcess. |
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
71 |
'process: id=' print. active id print. |
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
72 |
' name=' print. active name printCR. |
4960 | 73 |
|
7093
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
74 |
'context: ' print. aContext printString printCR. |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
75 |
(con := aContext) notNil ifTrue:[ |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
76 |
con := con sender. |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
77 |
' ......: ' print. con printString printCR. |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
78 |
[con notNil] whileTrue:[ |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
79 |
con := con sender. |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
80 |
' ......: ' print. con printString printCR. |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
81 |
] |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
82 |
] |
2661
fea131f9f062
care for recursive errors in MiniDebugger
Claus Gittinger <cg@exept.de>
parents:
2118
diff
changeset
|
83 |
]. |
618 | 84 |
]. |
4209
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
85 |
|
7c1b4df9e555
care for noConsole present (WIN32 only)
Claus Gittinger <cg@exept.de>
parents:
4003
diff
changeset
|
86 |
OperatingSystem hasConsole ifFalse:[ |
7093
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
87 |
Error handle:[:ex | |
4209
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 |
|
7093
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
93 |
Error handle:[:ex | |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
94 |
'cannot raise AbortSignal - exiting ...' errorPrintCR. |
4961
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:[ |
7093
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
103 |
AbortSignal raise |
4961
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 |
|
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
124 |
"/ TheOneAndOnlyDebugger isNil ifTrue:[ |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
125 |
"/ TheOneAndOnlyDebugger := self basicNew initialize |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
126 |
"/ ]. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
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:[ |
7093
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
202 |
c selector == #enter:mayProceed: ifTrue:[ |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
203 |
nesting := nesting + 1. |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
204 |
]. |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
205 |
c := c sender. |
5802
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:[ |
|
7093
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
210 |
AbortSignal handle:[:ex | |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
211 |
'** Abort Signal cought - back in previous debugLevel' printCR. |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
212 |
] do:[ |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
213 |
Error handle:[:ex | |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
214 |
'Error while executing command: ' print. |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
215 |
ex description printCR. |
5802
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 ? '. |
7093
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
217 |
yesNo == $d ifTrue:[ |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
218 |
ex reject |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
219 |
]. |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
220 |
yesNo == $p ifTrue:[ |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
221 |
ex proceed |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
222 |
]. |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
223 |
] do:[ |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
224 |
leaveCmd := self commandLoop. |
7093
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
225 |
]. |
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
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 |
|
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
331 |
moveDotDown |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
332 |
"/ sigh - must search |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
333 |
|c| |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
334 |
|
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
335 |
c := enteringContext. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
336 |
[ c notNil and:[ c sender ~~ dot ] ] whileTrue:[ |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
337 |
c := c sender. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
338 |
]. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
339 |
c notNil ifTrue:[ |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
340 |
dot := c. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
341 |
self printDot. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
342 |
] ifFalse:[ |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
343 |
'** dot is the bottom of the calling chain' printCR. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
344 |
]. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
345 |
! |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
346 |
|
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
347 |
moveDotUp |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
348 |
dot sender notNil ifTrue:[ |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
349 |
dot := dot sender. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
350 |
self printDot. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
351 |
] ifFalse:[ |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
352 |
'** dot is the top of the calling chain' printCR. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
353 |
]. |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
354 |
! |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
355 |
|
2772 | 356 |
printBacktraceFrom:aContext |
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
357 |
|context n| |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
358 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
359 |
aContext isNil ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
360 |
'no context' errorPrintCR. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
361 |
^ self |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
362 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
363 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
364 |
context := aContext. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
365 |
n := commandCount. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
366 |
[context notNil] whileTrue: [ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
367 |
context fullPrint. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
368 |
context := context sender. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
369 |
n notNil ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
370 |
n := n - 1. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
371 |
n <= 0 ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
372 |
^ self |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
373 |
] |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
374 |
] |
2772 | 375 |
] |
376 |
! |
|
377 |
||
5942
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
378 |
printDot |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
379 |
dot fullPrint |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
380 |
! |
e3431a2c33f1
avoid statements after return
Claus Gittinger <cg@exept.de>
parents:
5921
diff
changeset
|
381 |
|
618 | 382 |
stepping |
383 |
traceBlock := nil. |
|
384 |
tracing := false. |
|
385 |
stepping := true |
|
74 | 386 |
! |
387 |
||
618 | 388 |
tracingWith:aBlockOrNil |
389 |
traceBlock := aBlockOrNil. |
|
390 |
stepping := false. |
|
391 |
tracing := true |
|
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 |
|
6938 | 451 |
(cmd == $S) ifTrue:[ |
452 |
valid := true. |
|
453 |
ObjectMemory snapShotOn:'crash.img'. |
|
454 |
]. |
|
5802
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 |
||
6938 | 492 |
(cmd == $R) ifTrue:[ |
493 |
valid := true. |
|
494 |
proc notNil ifTrue:[ |
|
495 |
proc resume. |
|
496 |
] |
|
497 |
]. |
|
498 |
||
3700 | 499 |
(cmd == $T) ifTrue:[ |
500 |
valid := true. |
|
501 |
proc notNil ifTrue:[ |
|
502 |
proc terminate. |
|
503 |
] ifFalse:[ |
|
504 |
id notNil ifTrue:[ |
|
505 |
'no process with id: ' print. id printCR. |
|
506 |
] ifFalse:[ |
|
507 |
Processor terminateActive |
|
508 |
] |
|
509 |
] |
|
510 |
]. |
|
511 |
||
6938 | 512 |
(cmd == $W) ifTrue:[ |
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
513 |
valid := true. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
514 |
proc notNil ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
515 |
'stopping process id: ' print. id printCR. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
516 |
proc stop. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
517 |
] ifFalse:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
518 |
'invalid process id: ' print. id printCR. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
519 |
] |
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 |
|
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
522 |
(cmd == $a) ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
523 |
"without id-arg, this is handled by caller" |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
524 |
proc notNil ifTrue:[ |
6938 | 525 |
'aborting process id: ' print. id printCR. |
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
526 |
valid := true. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
527 |
proc interruptWith:[AbortSignal raise] |
6938 | 528 |
] ifFalse:[ |
529 |
'aborting' printCR. |
|
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
530 |
] |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
531 |
]. |
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
532 |
|
3700 | 533 |
(cmd == $Q) ifTrue:[ |
534 |
valid := true. |
|
535 |
proc notNil ifTrue:[ |
|
536 |
proc terminateNoSignal. |
|
537 |
] ifFalse:[ |
|
538 |
id notNil ifTrue:[ |
|
539 |
'no process with id: ' print. id printCR. |
|
540 |
] ifFalse:[ |
|
541 |
Processor terminateActiveNoSignal |
|
542 |
] |
|
543 |
] |
|
544 |
]. |
|
545 |
||
546 |
(cmd == $g) ifTrue:[ |
|
547 |
valid := true. |
|
548 |
id == 3 ifTrue:[ |
|
549 |
ObjectMemory reclaimSymbols. |
|
550 |
ObjectMemory compressOldSpace. |
|
551 |
] ifFalse:[ |
|
552 |
id == 2 ifTrue:[ |
|
553 |
ObjectMemory reclaimSymbols. |
|
554 |
] ifFalse:[ |
|
555 |
ObjectMemory garbageCollect. |
|
556 |
] |
|
557 |
] |
|
558 |
]. |
|
559 |
||
560 |
(cmd == $U) ifTrue:[valid := true. MessageTracer unwrapAllMethods]. |
|
561 |
(cmd == $X) ifTrue:[valid := true. Smalltalk fatalAbort]. |
|
562 |
(cmd == $x) ifTrue:[valid := true. OperatingSystem exit]. |
|
563 |
||
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
564 |
(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
|
565 |
(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
|
566 |
(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
|
567 |
|
4470 | 568 |
"/ avoid usage print if return was typed ... |
569 |
((cmd == Character return) |
|
570 |
or:[cmd == Character linefeed]) ifTrue:[valid := true.]. |
|
571 |
||
1424 | 572 |
valid ifFalse: [ |
573 |
'valid commands: |
|
3700 | 574 |
c ..... continue |
575 |
s ..... step |
|
576 |
t ..... trace (continue with trace) |
|
3814
1227e4690753
allow aborting other threads
Claus Gittinger <cg@exept.de>
parents:
3769
diff
changeset
|
577 |
a [id]. abort (i.e. raise abort signal) in (current) process |
3700 | 578 |
T [id]. terminate (current) process |
6938 | 579 |
W [id]. stop (current) process |
580 |
R [id]. resume (current) process |
|
3700 | 581 |
Q [id]. quick terminate (current) process - no unwinds or cleanup |
582 |
||
583 |
P ..... list processes |
|
3701 | 584 |
l [id]. print context chain (of process with id) |
3700 | 585 |
b [id]. full (VM) backtrace |
586 |
B ..... backtrace of all other processes |
|
587 |
||
588 |
U ..... unwrap all traced/breakpointed methods |
|
589 |
g ..... collect all garbage |
|
4463 | 590 |
g 2.... collect all garbage & reclaim symbols |
591 |
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
|
592 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
593 |
S ..... save snapshot into crash.img |
3700 | 594 |
X ..... exit (+core) |
595 |
x ..... exit Smalltalk |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
596 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
597 |
. ..... 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
|
598 |
- ..... move dot up |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
599 |
+ ..... move dot down |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
600 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
601 |
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
|
602 |
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
|
603 |
I ..... interpreter (expression evaluator) |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
604 |
|
3700 | 605 |
' errorPrintCR |
1424 | 606 |
] |
1 | 607 |
]. |
2113
6a310e15ad58
added print-other-stacks command
Claus Gittinger <cg@exept.de>
parents:
1424
diff
changeset
|
608 |
context := nil. |
1 | 609 |
^ cmd |
1424 | 610 |
|
3701 | 611 |
"Modified: / 31.7.1998 / 17:10:23 / cg" |
1 | 612 |
! |
613 |
||
618 | 614 |
doAbort |
615 |
|con sig| |
|
616 |
||
6204
2bafef9151dd
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
5942
diff
changeset
|
617 |
(sig := AbortOperationRequest) isHandled ifTrue:[ |
1424 | 618 |
sig raise. |
619 |
'abort raise failed' errorPrintCR. |
|
618 | 620 |
]. |
621 |
||
622 |
"TEMPORARY kludge - find event handler context |
|
623 |
this will be removed, once real debugging is possible |
|
624 |
" |
|
625 |
con := self findContext:#processEvent. |
|
626 |
con isNil ifTrue:[ |
|
1424 | 627 |
con := self findContext:#dispatch. |
618 | 628 |
]. |
629 |
con notNil ifTrue:[ |
|
1424 | 630 |
"got it" |
631 |
con return. |
|
632 |
'return failed' errorPrintCR. |
|
618 | 633 |
]. |
634 |
||
1424 | 635 |
'found no context to resume' errorPrintCR. |
636 |
||
6204
2bafef9151dd
class based exceptions - abortSignal;
Claus Gittinger <cg@exept.de>
parents:
5942
diff
changeset
|
637 |
"Modified: / 16.11.2001 / 17:39:14 / cg" |
618 | 638 |
! |
639 |
||
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
640 |
getCommand:prompt |
3126
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
641 |
"/ Screen notNil ifTrue:[ |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
642 |
"/ Screen allScreens do:[:aScreen | |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
643 |
"/ aScreen ungrabPointer. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
644 |
"/ aScreen ungrabKeyboard. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
645 |
"/ ]. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
646 |
"/ ]. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
647 |
|
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
648 |
Display notNil ifTrue:[ |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
649 |
Display ungrabPointer. |
e37ccb66f1b0
onlz ungrab the main Display (remote display could be inoperable)
Claus Gittinger <cg@exept.de>
parents:
3009
diff
changeset
|
650 |
Display ungrabKeyboard. |
852
5c4a0585ba0b
ungrab pointer for every input
Claus Gittinger <cg@exept.de>
parents:
720
diff
changeset
|
651 |
]. |
5c4a0585ba0b
ungrab pointer for every input
Claus Gittinger <cg@exept.de>
parents:
720
diff
changeset
|
652 |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
653 |
(prompt |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
654 |
? (nesting == 0 ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
655 |
'MiniDebugger> ' |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
656 |
] ifFalse:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
657 |
'MiniDebugger' , nesting printString , '>' |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
658 |
])) print. |
93 | 659 |
|
976 | 660 |
UserInterruptSignal handle:[:ex | |
661 |
ex restart |
|
159 | 662 |
] do:[ |
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
663 |
|c cmd arg cnt| |
3700 | 664 |
|
976 | 665 |
cmd := Character fromUser. |
666 |
cmd isNil ifTrue:[ |
|
667 |
" |
|
668 |
mhmh end-of-file; |
|
669 |
return a 'c' (for continue); hope thats ok. |
|
670 |
" |
|
671 |
cmd := $c |
|
672 |
]. |
|
93 | 673 |
|
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
674 |
cnt := nil. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
675 |
(cmd isDigit) ifTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
676 |
cnt := 0. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
677 |
[cmd isDigit] whileTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
678 |
cnt := cnt * 10 + cmd digitValue. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
679 |
cmd := Character fromUser |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
680 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
681 |
[cmd == Character space] whileTrue:[ |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
682 |
cmd := Character fromUser |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
683 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
684 |
]. |
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
685 |
|
976 | 686 |
" |
3700 | 687 |
collect to end-of-line in arg |
976 | 688 |
" |
689 |
c := cmd. |
|
3700 | 690 |
arg := ''. |
976 | 691 |
[c isNil or:[c isEndOfLineCharacter]] whileFalse: [ |
3700 | 692 |
arg := arg copyWith:c. |
976 | 693 |
c := Character fromUser. |
694 |
]. |
|
3700 | 695 |
commandArg := arg copyFrom:2. |
696 |
command := cmd. |
|
4003
d0f97b9cd4de
added 'S' -> stopp a process
Claus Gittinger <cg@exept.de>
parents:
3814
diff
changeset
|
697 |
commandCount := cnt. |
1 | 698 |
]. |
3700 | 699 |
^ command |
976 | 700 |
|
3700 | 701 |
"Modified: / 31.7.1998 / 16:11:01 / cg" |
1 | 702 |
! |
703 |
||
704 |
interpreterLoopWith:anObject |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
705 |
|line done rslt| |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
706 |
|
1424 | 707 |
'read-eval-print loop; exit with empty line' printCR. |
3700 | 708 |
'' printCR. |
709 |
||
1 | 710 |
done := false. |
711 |
[done] whileFalse:[ |
|
3700 | 712 |
'> ' print. |
713 |
||
1424 | 714 |
line := Stdin nextLine. |
715 |
(line size == 0) ifTrue:[ |
|
716 |
done := true |
|
717 |
] ifFalse:[ |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
718 |
"/ rslt := Compiler evaluate:line |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
719 |
"/ receiver:anObject |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
720 |
"/ notifying:nil. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
721 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
722 |
rslt := Compiler |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
723 |
evaluate:line |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
724 |
in:dot |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
725 |
receiver:dot receiver |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
726 |
notifying:nil |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
727 |
ifFail:[]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
5054
diff
changeset
|
728 |
rslt printCR. |
1424 | 729 |
] |
1 | 730 |
] |
1424 | 731 |
|
3700 | 732 |
"Modified: / 31.7.1998 / 16:01:47 / cg" |
618 | 733 |
! |
734 |
||
2772 | 735 |
printAllBacktraces |
736 |
Process allInstancesDo:[:p | |
|
737 |
(p ~~ Processor activeProcess |
|
738 |
and:[p isDead not]) ifTrue:[ |
|
739 |
'---------------------------------------------------------' printCR. |
|
740 |
' proc id=' print. p id print. |
|
741 |
' name=''' print. p name print. |
|
742 |
''' createdBy: ' print. p creatorId print. |
|
743 |
' state=' print. p state print. |
|
744 |
' prio=' print. p priority printCR. |
|
745 |
'' printCR. '' printCR. |
|
746 |
||
747 |
self printBacktraceFrom:(p suspendedContext) |
|
748 |
] |
|
749 |
] |
|
750 |
! |
|
751 |
||
618 | 752 |
showProcesses |
753 |
|active| |
|
754 |
||
755 |
active := Processor activeProcess. |
|
3700 | 756 |
'current id=' print. active id print. ' name=''' print. active name print. '''' printCR. |
618 | 757 |
|
3700 | 758 |
Process allSubInstancesDo:[:p | |
759 |
'proc id=' print. (p id printStringPaddedTo:5) print. |
|
760 |
(p state printStringPaddedTo:10) print. |
|
761 |
' pri=' print. (p priority printStringPaddedTo:2) print. |
|
762 |
' creator:' print. (p creatorId printStringPaddedTo:5) print. |
|
763 |
' name=''' print. p name print. |
|
764 |
'''' printCR. |
|
618 | 765 |
] |
1424 | 766 |
|
3700 | 767 |
"Modified: / 31.7.1998 / 16:30:19 / cg" |
1 | 768 |
! ! |
618 | 769 |
|
658 | 770 |
!MiniDebugger class methodsFor:'documentation'! |
771 |
||
772 |
version |
|
7093
60bad14d38fc
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
6938
diff
changeset
|
773 |
^ '$Header: /cvs/stx/stx/libbasic/MiniDebugger.st,v 1.57 2003-03-02 20:44:27 stefan Exp $' |
658 | 774 |
! ! |