author | Stefan Vogel <sv@exept.de> |
Thu, 16 Apr 2015 18:28:45 +0200 | |
branch | expecco_2_7_5 |
changeset 18220 | 361e98951d47 |
parent 16635 | ee5ebbb9e049 |
child 18120 | e3a375d5f6a8 |
child 19381 | ff17cf92e2c3 |
permissions | -rw-r--r-- |
1 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
308 | 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 |
" |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
12 |
"{ Package: 'stx:libbasic' }" |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
13 |
|
720 | 14 |
Object subclass:#MiniInspector |
15926 | 15 |
instanceVariableNames:'inspectedObject commandArg' |
1297 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
18 |
category:'System-Debugging-Support' |
|
1 | 19 |
! |
20 |
||
89 | 21 |
!MiniInspector class methodsFor:'documentation'! |
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
308 | 26 |
All Rights Reserved |
1 | 27 |
|
89 | 28 |
This software is furnished under a license and may be used |
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
1 | 36 |
|
89 | 37 |
documentation |
38 |
" |
|
39 |
a primitive (non graphical) inspector for use on systems without |
|
15926 | 40 |
graphics or when the real inspector dies (i.e. the UI is locked). |
41 |
Sometimes useful as a last chance to fix a broken UI / event handling. |
|
42 |
Needs a console. |
|
43 |
||
44 |
MiniInspector openOn: Display |
|
1297 | 45 |
|
46 |
[author:] |
|
16558 | 47 |
Claus Gittinger |
89 | 48 |
" |
49 |
! ! |
|
1 | 50 |
|
51 |
!MiniInspector class methodsFor:'instance creation'! |
|
52 |
||
53 |
openOn:anObject |
|
54 |
|anInspector| |
|
14938 | 55 |
|
1 | 56 |
anInspector := (self new) initializeFor:anObject. |
14938 | 57 |
anInspector enter. |
58 |
^ anInspector |
|
1 | 59 |
! ! |
60 |
||
61 |
!MiniInspector methodsFor:'private'! |
|
62 |
||
63 |
commandLoop |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
64 |
|cmd valid| |
1 | 65 |
|
16250 | 66 |
'MiniInspector on ' errorPrint. inspectedObject displayString errorPrintCR. |
67 |
'' errorPrintCR. |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
68 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
69 |
[true] whileTrue:[ |
16558 | 70 |
valid := false. |
71 |
cmd := self getCommand:'inspector> '. |
|
72 |
cmd isNil ifTrue:[ "/ EOF -> quit |
|
73 |
cmd := $q |
|
74 |
]. |
|
75 |
cmd isNumber ifTrue:[ |
|
76 |
valid := true. |
|
77 |
self inspectInstvar:cmd of:inspectedObject |
|
78 |
]. |
|
79 |
(cmd == $i) ifTrue:[ |
|
80 |
valid := true. |
|
81 |
self printInstVarsOf:inspectedObject |
|
82 |
]. |
|
83 |
(cmd == $p) ifTrue:[ |
|
84 |
valid := true. |
|
85 |
inspectedObject displayString errorPrintCR |
|
86 |
]. |
|
87 |
(cmd == $c) ifTrue:[ |
|
88 |
valid := true. |
|
89 |
inspectedObject class displayString errorPrintCR |
|
90 |
]. |
|
91 |
(cmd == $C) ifTrue:[ |
|
92 |
valid := true. |
|
93 |
MiniInspector openOn:inspectedObject class. |
|
94 |
'back in previous inspector; inspecting ' errorPrint. inspectedObject displayString errorPrintCR. |
|
95 |
]. |
|
96 |
(cmd == $d) ifTrue:[ |
|
97 |
valid := true. |
|
98 |
ObjectMemory dumpObject:inspectedObject |
|
99 |
]. |
|
100 |
(cmd == $E) ifTrue:[ |
|
101 |
valid := true. |
|
102 |
Parser evaluate:commandArg receiver:inspectedObject. |
|
103 |
]. |
|
104 |
(cmd == $e) ifTrue:[ |
|
105 |
valid := true. |
|
106 |
(Parser evaluate:commandArg receiver:inspectedObject) errorPrintCR. |
|
107 |
]. |
|
108 |
(cmd == $e) ifTrue:[ |
|
109 |
valid := true. |
|
110 |
ObjectMemory dumpObject:inspectedObject |
|
111 |
]. |
|
112 |
(cmd == $*) ifTrue:[ |
|
113 |
valid := true. |
|
114 |
inspectedObject becomeNil. |
|
115 |
^ cmd. |
|
116 |
]. |
|
117 |
(cmd == $I) ifTrue:[ |
|
118 |
valid := true. |
|
119 |
self interpreterLoopWith:inspectedObject |
|
120 |
]. |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
121 |
|
16558 | 122 |
(cmd == $q) ifTrue:[ |
123 |
^ cmd. |
|
124 |
]. |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
125 |
|
16558 | 126 |
valid ifFalse: [ |
127 |
'valid commands: |
|
15926 | 128 |
p ...... print inspected object |
129 |
c ...... print inspected objects class |
|
130 |
i ...... print instvars |
|
131 |
d ...... VM-dump inspected object |
|
5804 | 132 |
|
15926 | 133 |
I ...... interpreter |
134 |
e expr evaluate expression & print result ("E" to not print) |
|
5804 | 135 |
|
15926 | 136 |
C ...... inspect class |
137 |
<Num> .. inspect instvar num (1..) |
|
5803 | 138 |
|
15926 | 139 |
* ...... becomeNil and quit (dangerous) |
140 |
q ...... quit |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
141 |
' errorPrintCR |
16558 | 142 |
] |
1 | 143 |
]. |
1426 | 144 |
|
15926 | 145 |
"Modified: / 03-02-2014 / 10:19:46 / cg" |
1 | 146 |
! |
147 |
||
618 | 148 |
enter |
15904
7b8100b48c7a
AbortSignal -> AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents:
14938
diff
changeset
|
149 |
AbortOperationRequest handle:[:ex | |
16558 | 150 |
'** Abort Signal caught - back in previous debugLevel' printCR. |
151 |
ex restart |
|
5805 | 152 |
] do:[ |
16558 | 153 |
Error handle:[:ex | |
154 |
|yesNo| |
|
5805 | 155 |
|
16558 | 156 |
'Error while executing command: ' errorPrint. |
157 |
ex description errorPrintCR. |
|
158 |
yesNo := self getCommand:'- (i)gnore / (p)roceed / (d)ebug ? '. |
|
159 |
yesNo == $d ifTrue:[ |
|
160 |
ex reject |
|
161 |
]. |
|
162 |
yesNo == $p ifTrue:[ |
|
163 |
ex proceed |
|
164 |
]. |
|
165 |
ex restart |
|
166 |
] do:[ |
|
167 |
self commandLoop. |
|
168 |
]. |
|
169 |
]. |
|
618 | 170 |
^ nil |
171 |
! |
|
172 |
||
5805 | 173 |
getCommand:prompt |
15926 | 174 |
|cmd c num arg| |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
175 |
|
16250 | 176 |
prompt errorPrint. |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
177 |
|
16250 | 178 |
c := cmd := Character fromUser. |
179 |
c isNil ifTrue:[ |
|
16558 | 180 |
^ nil. |
16250 | 181 |
]. |
182 |
c isDigit ifTrue:[ |
|
16558 | 183 |
num := 0. |
184 |
[ |
|
185 |
num := (num * 10) + c digitValue. |
|
186 |
c := Character fromUser. |
|
187 |
] doWhile:[c notNil and:[c isDigit]]. |
|
188 |
^ num "/ numeric |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
189 |
]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
190 |
|
15926 | 191 |
c := Character fromUser. |
192 |
[c notNil and:[c isEndOfLineCharacter not and:[c isSeparator ]]] whileTrue:[ c := Character fromUser ]. |
|
193 |
arg := ''. |
|
4965 | 194 |
[c notNil and:[c isEndOfLineCharacter]] whileFalse:[ |
16558 | 195 |
arg := arg copyWith:c. |
196 |
c := Character fromUser |
|
1 | 197 |
]. |
15926 | 198 |
commandArg := arg. |
1 | 199 |
^ cmd |
15926 | 200 |
|
201 |
"Modified: / 03-02-2014 / 10:16:49 / cg" |
|
1 | 202 |
! |
203 |
||
618 | 204 |
initializeFor:anObject |
205 |
inspectedObject := anObject. |
|
206 |
^self |
|
207 |
! |
|
208 |
||
16635 | 209 |
inspect:anObject |
210 |
inspectedObject := anObject. |
|
211 |
! |
|
212 |
||
618 | 213 |
inspectInstvar:which of:anObject |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
214 |
|numInsts idx| |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
215 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
216 |
numInsts := anObject class instSize. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
217 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
218 |
which > numInsts ifTrue:[ |
16558 | 219 |
idx := which - numInsts. |
220 |
idx > anObject basicSize ifTrue:[ |
|
221 |
'invalid indexed instvar index: ' errorPrint. idx errorPrintCR |
|
222 |
] ifFalse:[ |
|
223 |
'Inspecting indexed instVar ' errorPrint. idx errorPrint. '...' errorPrintCR. |
|
224 |
MiniInspector openOn:(anObject basicAt:idx). |
|
225 |
'back in previous inspector; inspecting ' errorPrint. inspectedObject displayString errorPrintCR. |
|
226 |
] |
|
618 | 227 |
] ifFalse: [ |
16558 | 228 |
which < 0 ifTrue:[ |
229 |
'invalid instVar # (must be >= 1)' errorPrintCR |
|
230 |
] ifFalse:[ |
|
231 |
'Inspecting instVar ' errorPrint. which errorPrint. '...' errorPrintCR. |
|
232 |
MiniInspector openOn:(anObject instVarAt:which). |
|
233 |
'back in previous inspector; inspecting ' errorPrint. inspectedObject displayString errorPrintCR. |
|
234 |
]. |
|
618 | 235 |
] |
1426 | 236 |
|
237 |
"Modified: 20.5.1996 / 10:27:40 / cg" |
|
618 | 238 |
! |
239 |
||
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
240 |
interpreterLoopWith:anObject |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
241 |
|line done rslt| |
16558 | 242 |
|
16250 | 243 |
'read-eval-print loop; exit with empty line' errorPrintCR. |
244 |
'' errorPrintCR. |
|
16558 | 245 |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
246 |
done := false. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
247 |
[done] whileFalse:[ |
16558 | 248 |
'> ' errorPrint. |
249 |
||
250 |
line := Stdin nextLine. |
|
251 |
(line size == 0) ifTrue:[ |
|
252 |
done := true |
|
253 |
] ifFalse:[ |
|
254 |
rslt := Compiler |
|
255 |
evaluate:line |
|
256 |
in:nil |
|
257 |
receiver:anObject |
|
258 |
notifying:nil |
|
259 |
ifFail:[]. |
|
260 |
rslt errorPrintCR. |
|
261 |
] |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
262 |
] |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
263 |
! |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
264 |
|
1 | 265 |
printInstVarsOf:anObject |
5805 | 266 |
|n "{ Class: SmallInteger }" names | |
903 | 267 |
|
1 | 268 |
n := anObject class instSize. |
5805 | 269 |
names := anObject class allInstVarNames. |
270 |
||
16250 | 271 |
'number of instvars: ' errorPrint. n errorPrintCR. |
1 | 272 |
1 to:n do:[:i | |
16558 | 273 |
(i printStringLeftPaddedTo:2) errorPrint. |
274 |
' {' errorPrint. (names at:i) errorPrint. '}' errorPrint. |
|
275 |
': ' errorPrint. |
|
276 |
((anObject instVarAt:i) displayString contractAtEndTo:80) errorPrintCR |
|
903 | 277 |
]. |
5805 | 278 |
|
903 | 279 |
n := anObject basicSize. |
5805 | 280 |
n > 0 ifTrue:[ |
16558 | 281 |
'number of indexed instvars: ' errorPrint. n errorPrintCR. |
282 |
n > 10 ifTrue:[n := 10]. |
|
283 |
1 to:n do:[:i | |
|
284 |
' [' errorPrint. i errorPrint. ']: ' errorPrint. |
|
285 |
((anObject basicAt:i) displayString contractAtEndTo:80) errorPrintCR |
|
286 |
] |
|
903 | 287 |
]. |
1426 | 288 |
|
289 |
"Modified: 20.5.1996 / 10:27:45 / cg" |
|
618 | 290 |
! ! |
1 | 291 |
|
658 | 292 |
!MiniInspector class methodsFor:'documentation'! |
293 |
||
294 |
version |
|
16635 | 295 |
^ '$Header: /cvs/stx/stx/libbasic/MiniInspector.st,v 1.32 2014-06-25 16:30:11 cg Exp $' |
658 | 296 |
! ! |
16635 | 297 |