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