author | Claus Gittinger <cg@exept.de> |
Fri, 12 Jan 2007 21:58:11 +0100 | |
changeset 10323 | edd5e199ddd5 |
parent 7092 | 630807cd320f |
child 14938 | bb6698374550 |
child 17711 | 39faaaf888b4 |
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 |
1297 | 15 |
instanceVariableNames:'inspectedObject' |
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 |
|
40 |
graphics or when the real inspector dies. |
|
1297 | 41 |
|
42 |
[author:] |
|
43 |
Claus Gittinger |
|
89 | 44 |
" |
45 |
! ! |
|
1 | 46 |
|
47 |
!MiniInspector class methodsFor:'instance creation'! |
|
48 |
||
49 |
openOn:anObject |
|
50 |
|anInspector| |
|
51 |
anInspector := (self new) initializeFor:anObject. |
|
52 |
anInspector enter |
|
53 |
! ! |
|
54 |
||
55 |
!MiniInspector methodsFor:'private'! |
|
56 |
||
57 |
commandLoop |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
58 |
|cmd valid| |
1 | 59 |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
60 |
'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
|
61 |
'' printCR. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
62 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
63 |
[true] whileTrue:[ |
1426 | 64 |
valid := false. |
5805 | 65 |
cmd := self getCommand:'inspector> '. |
2775
acdd73312418
handle EOF when fetching a command.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
66 |
cmd isNil ifTrue:[ "/ EOF -> quit |
acdd73312418
handle EOF when fetching a command.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
67 |
cmd := $q |
acdd73312418
handle EOF when fetching a command.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
68 |
]. |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
69 |
cmd isNumber ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
70 |
valid := true. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
71 |
self inspectInstvar:cmd of:inspectedObject |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
72 |
]. |
1426 | 73 |
(cmd == $i) ifTrue:[ |
74 |
valid := true. |
|
75 |
self printInstVarsOf:inspectedObject |
|
76 |
]. |
|
77 |
(cmd == $p) ifTrue:[ |
|
78 |
valid := true. |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
79 |
inspectedObject displayString printCR |
1426 | 80 |
]. |
5804 | 81 |
(cmd == $c) ifTrue:[ |
82 |
valid := true. |
|
83 |
inspectedObject class displayString printCR |
|
84 |
]. |
|
85 |
(cmd == $C) ifTrue:[ |
|
86 |
valid := true. |
|
5805 | 87 |
MiniInspector openOn:inspectedObject class. |
88 |
'back in previous inspector; inspecting ' print. inspectedObject displayString printCR. |
|
5804 | 89 |
]. |
5803 | 90 |
(cmd == $d) ifTrue:[ |
91 |
valid := true. |
|
92 |
ObjectMemory dumpObject:inspectedObject |
|
93 |
]. |
|
94 |
(cmd == $*) ifTrue:[ |
|
95 |
valid := true. |
|
96 |
inspectedObject becomeNil. |
|
97 |
^ cmd. |
|
98 |
]. |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
99 |
(cmd == $I) ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
100 |
valid := true. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
101 |
self interpreterLoopWith:inspectedObject |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
102 |
]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
103 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
104 |
(cmd == $q) ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
105 |
^ cmd. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
106 |
]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
107 |
|
1426 | 108 |
valid ifFalse: [ |
109 |
'valid commands: |
|
5803 | 110 |
p .... print inspected object |
5804 | 111 |
c .... print inspected objects class |
112 |
i .... print instvars |
|
5803 | 113 |
d .... VM-dump inspected object |
5804 | 114 |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
115 |
I .... interpreter |
5804 | 116 |
|
117 |
C .... inspect class |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
118 |
<Num> .... inspect instvar num (1..) |
5803 | 119 |
|
120 |
* .... becomeNil and quit (dangerous) |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
121 |
q .... quit |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
122 |
' errorPrintCR |
1426 | 123 |
] |
1 | 124 |
]. |
1426 | 125 |
|
2775
acdd73312418
handle EOF when fetching a command.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
126 |
"Modified: 24.7.1997 / 10:00:24 / cg" |
1 | 127 |
! |
128 |
||
618 | 129 |
enter |
5805 | 130 |
AbortSignal handle:[:ex | |
131 |
'** Abort Signal cought - back in previous debugLevel' printCR. |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
132 |
ex restart |
5805 | 133 |
] do:[ |
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
134 |
Error handle:[:ex | |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
135 |
|yesNo| |
5805 | 136 |
|
137 |
'Error while executing command: ' print. |
|
138 |
ex description printCR. |
|
139 |
yesNo := self getCommand:'- (i)gnore / (p)roceed / (d)ebug ? '. |
|
140 |
yesNo == $d ifTrue:[ |
|
141 |
ex reject |
|
142 |
]. |
|
143 |
yesNo == $p ifTrue:[ |
|
144 |
ex proceed |
|
145 |
]. |
|
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
146 |
ex restart |
5805 | 147 |
] do:[ |
148 |
self commandLoop. |
|
149 |
]. |
|
150 |
]. |
|
618 | 151 |
^ nil |
152 |
! |
|
153 |
||
5805 | 154 |
getCommand:prompt |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
155 |
|cmd c num| |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
156 |
|
5805 | 157 |
prompt print. |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
158 |
|
1 | 159 |
cmd := Character fromUser. |
160 |
c := cmd. |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
161 |
(c notNil and:[c isDigit]) ifTrue:[ |
10323 | 162 |
num := 0. |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
163 |
[c notNil and:[c isDigit]] whileTrue:[ |
10323 | 164 |
num := (num * 10) + c digitValue. |
165 |
c := Character fromUser. |
|
166 |
]. |
|
167 |
^ num "/ numeric |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
168 |
]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
169 |
|
4965 | 170 |
[c notNil and:[c isEndOfLineCharacter]] whileFalse:[ |
171 |
c := Character fromUser |
|
1 | 172 |
]. |
173 |
^ cmd |
|
174 |
! |
|
175 |
||
618 | 176 |
initializeFor:anObject |
177 |
inspectedObject := anObject. |
|
178 |
^self |
|
179 |
! |
|
180 |
||
181 |
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
|
182 |
|numInsts idx| |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
183 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
184 |
numInsts := anObject class instSize. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
185 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
186 |
which > numInsts ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
187 |
idx := which - numInsts. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
188 |
idx > anObject basicSize ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
189 |
'invalid indexed instvar index: ' print. idx printCR |
1426 | 190 |
] ifFalse:[ |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
191 |
'Inspecting indexed instVar ' print. idx print. '...' printCR. |
5805 | 192 |
MiniInspector openOn:(anObject basicAt:idx). |
193 |
'back in previous inspector; inspecting ' print. inspectedObject displayString printCR. |
|
1426 | 194 |
] |
618 | 195 |
] ifFalse: [ |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
196 |
which < 0 ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
197 |
'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
|
198 |
] ifFalse:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
199 |
'Inspecting instVar ' print. which print. '...' printCR. |
5805 | 200 |
MiniInspector openOn:(anObject instVarAt:which). |
201 |
'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
|
202 |
]. |
618 | 203 |
] |
1426 | 204 |
|
205 |
"Modified: 20.5.1996 / 10:27:40 / cg" |
|
618 | 206 |
! |
207 |
||
7092
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
208 |
interpreterLoopWith:anObject |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
209 |
|line done rslt| |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
210 |
|
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
211 |
'read-eval-print loop; exit with empty line' printCR. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
212 |
'' printCR. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
213 |
|
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
214 |
done := false. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
215 |
[done] whileFalse:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
216 |
'> ' print. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
217 |
|
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
218 |
line := Stdin nextLine. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
219 |
(line size == 0) ifTrue:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
220 |
done := true |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
221 |
] ifFalse:[ |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
222 |
rslt := Compiler |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
223 |
evaluate:line |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
224 |
in:nil |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
225 |
receiver:anObject |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
226 |
notifying:nil |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
227 |
ifFail:[]. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
228 |
rslt printCR. |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
229 |
] |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
230 |
] |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
231 |
! |
630807cd320f
Convert Object>>errorSignal -> Error
Stefan Vogel <sv@exept.de>
parents:
5805
diff
changeset
|
232 |
|
1 | 233 |
printInstVarsOf:anObject |
5805 | 234 |
|n "{ Class: SmallInteger }" names | |
903 | 235 |
|
1 | 236 |
n := anObject class instSize. |
5805 | 237 |
names := anObject class allInstVarNames. |
238 |
||
1426 | 239 |
'number of instvars: ' print. n printCR. |
1 | 240 |
1 to:n do:[:i | |
5805 | 241 |
(i printStringLeftPaddedTo:2) print. |
242 |
' {' print. (names at:i) print. '}' print. |
|
243 |
': ' print. |
|
244 |
((anObject instVarAt:i) displayString contractAtEndTo:80) printCR |
|
903 | 245 |
]. |
5805 | 246 |
|
903 | 247 |
n := anObject basicSize. |
5805 | 248 |
n > 0 ifTrue:[ |
249 |
'number of indexed instvars: ' print. n printCR. |
|
250 |
n > 10 ifTrue:[n := 10]. |
|
251 |
1 to:n do:[:i | |
|
252 |
' [' print. i print. ']: ' print. |
|
253 |
((anObject basicAt:i) displayString contractAtEndTo:80) printCR |
|
254 |
] |
|
903 | 255 |
]. |
1426 | 256 |
|
257 |
"Modified: 20.5.1996 / 10:27:45 / cg" |
|
618 | 258 |
! ! |
1 | 259 |
|
658 | 260 |
!MiniInspector class methodsFor:'documentation'! |
261 |
||
262 |
version |
|
10323 | 263 |
^ '$Header: /cvs/stx/stx/libbasic/MiniInspector.st,v 1.26 2007-01-12 20:58:11 cg Exp $' |
658 | 264 |
! ! |