author | Claus Gittinger <cg@exept.de> |
Thu, 08 Feb 2001 16:38:16 +0100 | |
changeset 5804 | 33282793d66d |
parent 5803 | a478ecef08c2 |
child 5805 | 007549d68d4b |
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. |
64 |
cmd := self getCommand. |
|
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. |
|
86 |
MiniInspector openOn:inspectedObject class |
|
87 |
]. |
|
5803 | 88 |
(cmd == $d) ifTrue:[ |
89 |
valid := true. |
|
90 |
ObjectMemory dumpObject:inspectedObject |
|
91 |
]. |
|
92 |
(cmd == $*) ifTrue:[ |
|
93 |
valid := true. |
|
94 |
inspectedObject becomeNil. |
|
95 |
^ cmd. |
|
96 |
]. |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
97 |
(cmd == $I) ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
98 |
valid := true. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
99 |
self interpreterLoopWith:inspectedObject |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
100 |
]. |
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 |
(cmd == $q) ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
103 |
^ cmd. |
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 |
|
1426 | 106 |
valid ifFalse: [ |
107 |
'valid commands: |
|
5803 | 108 |
p .... print inspected object |
5804 | 109 |
c .... print inspected objects class |
110 |
i .... print instvars |
|
5803 | 111 |
d .... VM-dump inspected object |
5804 | 112 |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
113 |
I .... interpreter |
5804 | 114 |
|
115 |
C .... inspect class |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
116 |
<Num> .... inspect instvar num (1..) |
5803 | 117 |
|
118 |
* .... 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
|
119 |
q .... quit |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
120 |
' errorPrintCR |
1426 | 121 |
] |
1 | 122 |
]. |
1426 | 123 |
|
2775
acdd73312418
handle EOF when fetching a command.
Claus Gittinger <cg@exept.de>
parents:
1426
diff
changeset
|
124 |
"Modified: 24.7.1997 / 10:00:24 / cg" |
1 | 125 |
! |
126 |
||
618 | 127 |
enter |
128 |
self commandLoop. |
|
129 |
^ nil |
|
130 |
! |
|
131 |
||
1 | 132 |
getCommand |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
133 |
|cmd c num| |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
134 |
|
1 | 135 |
'inspector> ' print. |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
136 |
|
1 | 137 |
cmd := Character fromUser. |
138 |
c := cmd. |
|
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
139 |
(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
|
140 |
num := 0. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
141 |
[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
|
142 |
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
|
143 |
c := Character fromUser. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
144 |
]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
145 |
^ num "/ numeric |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
146 |
]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
147 |
|
4965 | 148 |
[c notNil and:[c isEndOfLineCharacter]] whileFalse:[ |
149 |
c := Character fromUser |
|
1 | 150 |
]. |
151 |
^ cmd |
|
152 |
! |
|
153 |
||
618 | 154 |
initializeFor:anObject |
155 |
inspectedObject := anObject. |
|
156 |
^self |
|
157 |
! |
|
158 |
||
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
159 |
interpreterLoopWith:anObject |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
160 |
|line done rslt| |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
161 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
162 |
'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
|
163 |
'' printCR. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
164 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
165 |
done := false. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
166 |
[done] whileFalse:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
167 |
'> ' print. |
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 |
line := Stdin nextLine. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
170 |
(line size == 0) ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
171 |
done := true |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
172 |
] ifFalse:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
173 |
rslt := Compiler |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
174 |
evaluate:line |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
175 |
in:nil |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
176 |
receiver:anObject |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
177 |
notifying:nil |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
178 |
ifFail:[]. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
179 |
rslt printCR. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
180 |
] |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
181 |
] |
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 |
|
618 | 184 |
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
|
185 |
|numInsts idx| |
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 |
numInsts := anObject class instSize. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
188 |
|
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
189 |
which > numInsts ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
190 |
idx := which - numInsts. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
191 |
idx > anObject basicSize ifTrue:[ |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
192 |
'invalid indexed instvar index: ' print. idx printCR |
1426 | 193 |
] ifFalse:[ |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
194 |
'Inspecting indexed instVar ' print. idx print. '...' printCR. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
195 |
MiniInspector openOn:(anObject basicAt:idx) |
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. |
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
202 |
MiniInspector openOn:(anObject instVarAt:which) |
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 |
||
1 | 209 |
printInstVarsOf:anObject |
903 | 210 |
|n "{ Class: SmallInteger }" | |
211 |
||
1 | 212 |
n := anObject class instSize. |
1426 | 213 |
'number of instvars: ' print. n printCR. |
1 | 214 |
1 to:n do:[:i | |
1426 | 215 |
' ' print. i print. ': ' print. |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
216 |
(anObject instVarAt:i) displayString printCR |
903 | 217 |
]. |
218 |
n := anObject basicSize. |
|
1426 | 219 |
'number of indexed instvars: ' print. n printCR. |
903 | 220 |
n > 10 ifTrue:[n := 10]. |
221 |
1 to:n do:[:i | |
|
1426 | 222 |
' [' print. i print. ']: ' print. |
5802
93748287026d
better Mini- debugging tools (+/- context in debugger); interpreter in inspector.
Claus Gittinger <cg@exept.de>
parents:
4965
diff
changeset
|
223 |
(anObject basicAt:i) displayString printCR |
903 | 224 |
]. |
1426 | 225 |
|
226 |
"Modified: 20.5.1996 / 10:27:45 / cg" |
|
618 | 227 |
! ! |
1 | 228 |
|
658 | 229 |
!MiniInspector class methodsFor:'documentation'! |
230 |
||
231 |
version |
|
5804 | 232 |
^ '$Header: /cvs/stx/stx/libbasic/MiniInspector.st,v 1.23 2001-02-08 15:38:16 cg Exp $' |
658 | 233 |
! ! |