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