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