author | Claus Gittinger <cg@exept.de> |
Wed, 12 Feb 2014 15:40:03 +0100 | |
changeset 16007 | fcc49f75d8de |
parent 15926 | 2a89ee50988c |
child 16250 | c376e523d007 |
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:] |
|
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 |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
66 |
'MiniInspector on ' print. inspectedObject displayString printCR. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
67 |
'' printCR. |
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:[ |
1426 | 70 |
valid := false. |
5805 | 71 |
cmd := self getCommand:'inspector> '. |
2775
acdd73312418
handle EOF when fetching a command.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
72 |
cmd isNil ifTrue:[ "/ EOF -> quit |
acdd73312418
handle EOF when fetching a command.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
73 |
cmd := $q |
acdd73312418
handle EOF when fetching a command.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
74 |
]. |
15926 | 75 |
cmd isNumber ifTrue:[ |
76 |
valid := true. |
|
77 |
self inspectInstvar:cmd of:inspectedObject |
|
78 |
]. |
|
1426 | 79 |
(cmd == $i) ifTrue:[ |
80 |
valid := true. |
|
81 |
self printInstVarsOf:inspectedObject |
|
82 |
]. |
|
83 |
(cmd == $p) ifTrue:[ |
|
84 |
valid := true. |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
85 |
inspectedObject displayString printCR |
1426 | 86 |
]. |
5804 | 87 |
(cmd == $c) ifTrue:[ |
88 |
valid := true. |
|
89 |
inspectedObject class displayString printCR |
|
90 |
]. |
|
91 |
(cmd == $C) ifTrue:[ |
|
92 |
valid := true. |
|
5805 | 93 |
MiniInspector openOn:inspectedObject class. |
15926 | 94 |
'back in previous inspector; inspecting ' print. inspectedObject displayString printCR. |
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) printCR. |
|
5804 | 107 |
]. |
15926 | 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. |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
119 |
self interpreterLoopWith:inspectedObject |
15926 | 120 |
]. |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
121 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
122 |
(cmd == $q) ifTrue:[ |
15926 | 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 |
|
1426 | 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 |
1426 | 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 | |
5805 | 150 |
'** Abort Signal cought - back in previous debugLevel' printCR. |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
151 |
ex restart |
5805 | 152 |
] do:[ |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
153 |
Error handle:[:ex | |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
154 |
|yesNo| |
5805 | 155 |
|
156 |
'Error while executing command: ' print. |
|
157 |
ex description printCR. |
|
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 |
]. |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
165 |
ex restart |
5805 | 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 |
|
5805 | 176 |
prompt print. |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
177 |
|
1 | 178 |
cmd := Character fromUser. |
179 |
c := cmd. |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
180 |
(c notNil and:[c isDigit]) ifTrue:[ |
10323 | 181 |
num := 0. |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
182 |
[c notNil and:[c isDigit]] whileTrue:[ |
10323 | 183 |
num := (num * 10) + c digitValue. |
184 |
c := Character fromUser. |
|
185 |
]. |
|
186 |
^ num "/ numeric |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
187 |
]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
188 |
|
15926 | 189 |
c := Character fromUser. |
190 |
[c notNil and:[c isEndOfLineCharacter not and:[c isSeparator ]]] whileTrue:[ c := Character fromUser ]. |
|
191 |
arg := ''. |
|
4965 | 192 |
[c notNil and:[c isEndOfLineCharacter]] whileFalse:[ |
15926 | 193 |
arg := arg copyWith:c. |
4965 | 194 |
c := Character fromUser |
1 | 195 |
]. |
15926 | 196 |
commandArg := arg. |
1 | 197 |
^ cmd |
15926 | 198 |
|
199 |
"Modified: / 03-02-2014 / 10:16:49 / cg" |
|
1 | 200 |
! |
201 |
||
618 | 202 |
initializeFor:anObject |
203 |
inspectedObject := anObject. |
|
204 |
^self |
|
205 |
! |
|
206 |
||
207 |
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
|
208 |
|numInsts idx| |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
209 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
210 |
numInsts := anObject class instSize. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
211 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
212 |
which > numInsts ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
213 |
idx := which - numInsts. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
214 |
idx > anObject basicSize ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
215 |
'invalid indexed instvar index: ' print. idx printCR |
1426 | 216 |
] ifFalse:[ |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
217 |
'Inspecting indexed instVar ' print. idx print. '...' printCR. |
5805 | 218 |
MiniInspector openOn:(anObject basicAt:idx). |
219 |
'back in previous inspector; inspecting ' print. inspectedObject displayString printCR. |
|
1426 | 220 |
] |
618 | 221 |
] ifFalse: [ |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
222 |
which < 0 ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
223 |
'invalid instVar # (must be >= 1)' printCR |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
224 |
] ifFalse:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
225 |
'Inspecting instVar ' print. which print. '...' printCR. |
5805 | 226 |
MiniInspector openOn:(anObject instVarAt:which). |
227 |
'back in previous inspector; inspecting ' print. inspectedObject displayString printCR. |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
228 |
]. |
618 | 229 |
] |
1426 | 230 |
|
231 |
"Modified: 20.5.1996 / 10:27:40 / cg" |
|
618 | 232 |
! |
233 |
||
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
234 |
interpreterLoopWith:anObject |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
235 |
|line done rslt| |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
236 |
|
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
237 |
'read-eval-print loop; exit with empty line' printCR. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
238 |
'' printCR. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
239 |
|
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
240 |
done := false. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
241 |
[done] whileFalse:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
242 |
'> ' print. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
243 |
|
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
244 |
line := Stdin nextLine. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
245 |
(line size == 0) ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
246 |
done := true |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
247 |
] ifFalse:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
248 |
rslt := Compiler |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
249 |
evaluate:line |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
250 |
in:nil |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
251 |
receiver:anObject |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
252 |
notifying:nil |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
253 |
ifFail:[]. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
254 |
rslt printCR. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
255 |
] |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
256 |
] |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
257 |
! |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
258 |
|
1 | 259 |
printInstVarsOf:anObject |
5805 | 260 |
|n "{ Class: SmallInteger }" names | |
903 | 261 |
|
1 | 262 |
n := anObject class instSize. |
5805 | 263 |
names := anObject class allInstVarNames. |
264 |
||
1426 | 265 |
'number of instvars: ' print. n printCR. |
1 | 266 |
1 to:n do:[:i | |
5805 | 267 |
(i printStringLeftPaddedTo:2) print. |
268 |
' {' print. (names at:i) print. '}' print. |
|
269 |
': ' print. |
|
270 |
((anObject instVarAt:i) displayString contractAtEndTo:80) printCR |
|
903 | 271 |
]. |
5805 | 272 |
|
903 | 273 |
n := anObject basicSize. |
5805 | 274 |
n > 0 ifTrue:[ |
275 |
'number of indexed instvars: ' print. n printCR. |
|
276 |
n > 10 ifTrue:[n := 10]. |
|
277 |
1 to:n do:[:i | |
|
278 |
' [' print. i print. ']: ' print. |
|
279 |
((anObject basicAt:i) displayString contractAtEndTo:80) printCR |
|
280 |
] |
|
903 | 281 |
]. |
1426 | 282 |
|
283 |
"Modified: 20.5.1996 / 10:27:45 / cg" |
|
618 | 284 |
! ! |
1 | 285 |
|
658 | 286 |
!MiniInspector class methodsFor:'documentation'! |
287 |
||
288 |
version |
|
15926 | 289 |
^ '$Header: /cvs/stx/stx/libbasic/MiniInspector.st,v 1.29 2014-02-03 09:20:49 cg Exp $' |
658 | 290 |
! ! |
14938 | 291 |