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