author | Claus Gittinger <cg@exept.de> |
Wed, 19 Mar 2003 09:52:28 +0100 | |
changeset 1690 | 7428f8744d87 |
parent 1584 | 51c53d6656f4 |
child 1724 | b5bec24eeaaf |
permissions | -rw-r--r-- |
1423 | 1 |
"{ Package: 'stx:libtool2' }" |
1416 | 2 |
|
3 |
Object subclass:#SnapShotImageMemory |
|
1417 | 4 |
instanceVariableNames:'image stream msb ptrSize intSize intTag spaceInfos symbolEntries |
1416 | 5 |
globalEntries addrToObjectMapping' |
6 |
classVariableNames:'' |
|
7 |
poolDictionaries:'' |
|
8 |
category:'System-Support' |
|
9 |
! |
|
10 |
||
1417 | 11 |
Object subclass:#ImageHeader |
12 |
instanceVariableNames:'memory classRef bits byteSize' |
|
13 |
classVariableNames:'' |
|
14 |
poolDictionaries:'' |
|
15 |
privateIn:SnapShotImageMemory |
|
16 |
! |
|
17 |
||
18 |
SnapShotImageMemory::ImageHeader variableSubclass:#ImageObject |
|
1419 | 19 |
instanceVariableNames:'cachedContents' |
1416 | 20 |
classVariableNames:'' |
21 |
poolDictionaries:'' |
|
22 |
privateIn:SnapShotImageMemory |
|
23 |
! |
|
24 |
||
1448 | 25 |
SnapShotImageMemory::ImageHeader variableByteSubclass:#ImageByteObject |
26 |
instanceVariableNames:'' |
|
27 |
classVariableNames:'' |
|
28 |
poolDictionaries:'' |
|
29 |
privateIn:SnapShotImageMemory |
|
30 |
! |
|
31 |
||
1482 | 32 |
SnapShotImageMemory::ImageObject variableSubclass:#ImageMethodObject |
1552 | 33 |
instanceVariableNames:'cachedPackage cachedMClass cachedSelector' |
1482 | 34 |
classVariableNames:'' |
35 |
poolDictionaries:'' |
|
36 |
privateIn:SnapShotImageMemory |
|
37 |
! |
|
38 |
||
1416 | 39 |
SnapShotImageMemory::ImageObject variableSubclass:#ImageClassObject |
1482 | 40 |
instanceVariableNames:'cachedCategory cachedFlags cachedName' |
1416 | 41 |
classVariableNames:'' |
42 |
poolDictionaries:'' |
|
43 |
privateIn:SnapShotImageMemory |
|
44 |
! |
|
45 |
||
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
46 |
Object subclass:#SpaceInfo |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
47 |
instanceVariableNames:'start end size flags imageBase' |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
48 |
classVariableNames:'' |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
49 |
poolDictionaries:'' |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
50 |
privateIn:SnapShotImageMemory |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
51 |
! |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
52 |
|
1448 | 53 |
!SnapShotImageMemory class methodsFor:'documentation'! |
54 |
||
55 |
documentation |
|
56 |
" |
|
57 |
I represent the memory as contained in a snapshot image. |
|
58 |
||
59 |
I am not used directly; instead, via the SystemBrowsers entry: |
|
60 |
SystemBrowser openOnSnapShotImage:'/export/home/cg/work/stx/projects/smalltalk/st.img' |
|
61 |
||
62 |
[author:] |
|
63 |
Claus Gittinger |
|
64 |
||
65 |
" |
|
66 |
! ! |
|
1416 | 67 |
|
68 |
!SnapShotImageMemory class methodsFor:'instance creation'! |
|
69 |
||
70 |
for:aFilename |
|
71 |
^ self new for:aFilename |
|
72 |
! ! |
|
73 |
||
74 |
!SnapShotImageMemory class methodsFor:'private'! |
|
75 |
||
76 |
isNilOOP:anOOP |
|
77 |
^ anOOP == 0 |
|
78 |
! |
|
79 |
||
80 |
isPointerOOP:anOOP |
|
81 |
^ (anOOP bitTest:1) not |
|
82 |
! |
|
83 |
||
84 |
isSmallIntegerOOP:anOOP |
|
85 |
^ anOOP bitTest:1 |
|
86 |
! ! |
|
87 |
||
88 |
!SnapShotImageMemory methodsFor:'accessing'! |
|
89 |
||
90 |
globalEntries |
|
91 |
"return the value of the instance variable 'globalEntries' (automatically generated)" |
|
92 |
||
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
93 |
^ globalEntries |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
94 |
! |
1416 | 95 |
|
96 |
globalEntries:something |
|
97 |
"set the value of the instance variable 'globalEntries' (automatically generated)" |
|
98 |
||
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
99 |
globalEntries := something. |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
100 |
! |
1417 | 101 |
|
102 |
image |
|
103 |
||
104 |
^ image |
|
105 |
! |
|
106 |
||
107 |
image:something |
|
108 |
||
109 |
image := something. |
|
110 |
! |
|
111 |
||
112 |
ptrSize |
|
113 |
"return the value of the instance variable 'ptrSize' (automatically generated)" |
|
114 |
||
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
115 |
^ ptrSize |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
116 |
! |
1417 | 117 |
|
118 |
ptrSize:something |
|
119 |
"set the value of the instance variable 'ptrSize' (automatically generated)" |
|
120 |
||
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
121 |
ptrSize := something. |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
122 |
! ! |
1416 | 123 |
|
124 |
!SnapShotImageMemory methodsFor:'object access'! |
|
125 |
||
1417 | 126 |
fetchByteAt:addr |
127 |
|byte imgAddr| |
|
128 |
||
129 |
imgAddr := self imageAddressOf:addr. |
|
130 |
stream position:imgAddr. |
|
131 |
byte := stream next. |
|
132 |
^ byte |
|
133 |
! |
|
134 |
||
1416 | 135 |
fetchClassObjectAt:baseAddr |
1417 | 136 |
|addr classPtr size bits o classRef nInsts| |
137 |
||
138 |
(baseAddr bitAnd:3) ~~ 0 ifTrue:[self halt]. |
|
1416 | 139 |
|
140 |
o := addrToObjectMapping at:baseAddr ifAbsent:nil. |
|
141 |
o notNil ifTrue:[^ o]. |
|
142 |
||
143 |
addr := baseAddr. |
|
144 |
classPtr := self fetchPointerAt:addr. |
|
145 |
addr := addr + ptrSize. |
|
146 |
size := self fetchUnboxedIntegerAt:addr. |
|
147 |
addr := addr + ptrSize. |
|
148 |
bits := self fetchUnboxedIntegerAt:addr. |
|
149 |
addr := addr + ptrSize. |
|
150 |
||
1417 | 151 |
nInsts := (size - (intSize *3)) // intSize. |
152 |
o := ImageClassObject new:nInsts. |
|
153 |
addrToObjectMapping at:baseAddr put:o. |
|
154 |
||
155 |
(self class isPointerOOP:classPtr) ifFalse:[ |
|
156 |
self halt |
|
157 |
]. |
|
158 |
||
159 |
classRef := self fetchClassObjectAt:classPtr. |
|
160 |
||
161 |
o classRef:classRef. |
|
162 |
size > 8000 ifTrue:[self halt]. |
|
163 |
o byteSize:size. |
|
1416 | 164 |
o bits:bits. |
165 |
||
1417 | 166 |
1 to:nInsts do:[:idx | |
1416 | 167 |
o at:idx put:(self fetchUnboxedIntegerAt:addr). |
1417 | 168 |
"/ o at:idx put:(self fetchObjectAt:(self fetchUnboxedIntegerAt:addr)). |
169 |
addr := addr + ptrSize. |
|
1416 | 170 |
]. |
1417 | 171 |
o memory:self. |
1416 | 172 |
^ o |
173 |
! |
|
174 |
||
175 |
fetchObjectAt:baseAddr |
|
1482 | 176 |
|addr classPtr classRef size bits o nBytes nInsts flags indexTypeFlags imgAddr |
177 |
| |
|
1417 | 178 |
|
179 |
baseAddr == 0 ifTrue:[^ nil]. |
|
180 |
(baseAddr bitAnd:1) == 1 ifTrue:[(baseAddr bitTest:16r80000000) ifTrue:[ |
|
181 |
^ (baseAddr - 16r100000000) bitShift32:-1 |
|
182 |
] ifFalse:[ |
|
183 |
^ baseAddr bitShift32:-1 |
|
184 |
] |
|
185 |
]. |
|
186 |
(baseAddr bitAnd:3) ~~ 0 ifTrue:[self halt]. |
|
1416 | 187 |
|
188 |
o := addrToObjectMapping at:baseAddr ifAbsent:nil. |
|
189 |
o notNil ifTrue:[^ o]. |
|
190 |
||
191 |
addr := baseAddr. |
|
192 |
classPtr := self fetchPointerAt:addr. |
|
193 |
addr := addr + ptrSize. |
|
194 |
size := self fetchUnboxedIntegerAt:addr. |
|
195 |
addr := addr + ptrSize. |
|
196 |
bits := self fetchUnboxedIntegerAt:addr. |
|
197 |
addr := addr + ptrSize. |
|
198 |
||
199 |
(self class isPointerOOP:classPtr) ifFalse:[ |
|
200 |
self halt |
|
201 |
]. |
|
202 |
||
203 |
classRef := self fetchClassObjectAt:classPtr. |
|
1417 | 204 |
|
1482 | 205 |
flags := classRef flags. |
206 |
indexTypeFlags := flags bitAnd:Behavior maskIndexType. |
|
207 |
(indexTypeFlags = Behavior flagBytes) ifTrue:[ |
|
1417 | 208 |
nBytes := (size - (intSize * 3)). |
209 |
o := ImageByteObject new:nBytes. |
|
210 |
o classRef:classRef. |
|
211 |
size > 8000 ifTrue:[self halt]. |
|
212 |
o byteSize:size. |
|
213 |
o bits:bits. |
|
1416 | 214 |
|
1417 | 215 |
imgAddr := self imageAddressOf:addr. |
216 |
stream position:imgAddr. |
|
1416 | 217 |
|
1417 | 218 |
1 to:nBytes do:[:idx | |
219 |
o at:idx put:(stream next). |
|
220 |
addr := addr + 1. |
|
221 |
]. |
|
222 |
||
223 |
"/Transcript show:'#'. |
|
224 |
"/Transcript show:((ByteArray new:nBytes-1) replaceFrom:1 to:nBytes-1 with:o startingAt:1) asString. |
|
225 |
"/Transcript cr. |
|
1416 | 226 |
|
1417 | 227 |
] ifFalse:[ |
1482 | 228 |
(indexTypeFlags = Behavior flagNotIndexed) ifFalse:[ |
229 |
(indexTypeFlags ~= Behavior flagPointers) ifTrue:[ |
|
230 |
(indexTypeFlags ~= Behavior flagWeakPointers) ifTrue:[ |
|
1417 | 231 |
self halt |
232 |
] |
|
233 |
]. |
|
234 |
]. |
|
1416 | 235 |
|
1417 | 236 |
nInsts := (size - (intSize * 3)) // intSize. |
1482 | 237 |
(flags bitTest:Behavior flagBehavior) |
1417 | 238 |
"/ classRef isImageBehavior |
239 |
ifTrue:[ |
|
240 |
o := ImageClassObject new:nInsts. |
|
241 |
] ifFalse:[ |
|
1482 | 242 |
(flags bitTest:Behavior flagMethod) ifTrue:[ |
243 |
o := ImageMethodObject new:nInsts. |
|
244 |
] ifFalse:[ |
|
245 |
o := ImageObject new:nInsts. |
|
246 |
] |
|
1417 | 247 |
]. |
248 |
o classRef:classRef. |
|
249 |
size > 8000 ifTrue:[self halt]. |
|
250 |
o byteSize:size. |
|
251 |
o bits:bits. |
|
252 |
addrToObjectMapping at:baseAddr put:o. |
|
1416 | 253 |
|
1417 | 254 |
1 to:nInsts do:[:idx | |
255 |
o at:idx put:(self fetchUnboxedIntegerAt:addr). |
|
256 |
"/ o at:idx put:(self fetchObjectAt:(self fetchUnboxedIntegerAt:addr)). |
|
257 |
addr := addr + ptrSize. |
|
258 |
] |
|
259 |
]. |
|
260 |
o memory:self. |
|
261 |
^ o |
|
1416 | 262 |
! |
263 |
||
264 |
fetchPointerAt:addr |
|
265 |
^ self fetchUnboxedIntegerAt:addr |
|
266 |
! |
|
267 |
||
268 |
fetchUnboxedIntegerAt:addr |
|
1417 | 269 |
|ptr imgAddr| |
270 |
||
271 |
(addr bitAnd:3) ~~ 0 ifTrue:[self halt]. |
|
272 |
||
273 |
imgAddr := self imageAddressOf:addr. |
|
274 |
stream position:imgAddr. |
|
275 |
ptr := stream nextUnsignedLongMSB:msb. |
|
276 |
^ ptr |
|
277 |
! |
|
278 |
||
279 |
imageAddressOf:addr |
|
1416 | 280 |
spaceInfos do:[:eachSpace | |
1417 | 281 |
|byte imgAddr| |
1416 | 282 |
|
283 |
addr >= eachSpace start ifTrue:[ |
|
284 |
addr <= eachSpace end ifTrue:[ |
|
285 |
imgAddr := eachSpace imageBase + (addr - eachSpace start). |
|
1417 | 286 |
^ imgAddr |
1416 | 287 |
] |
288 |
]. |
|
289 |
]. |
|
1417 | 290 |
self halt:'image address error'. |
1416 | 291 |
! ! |
292 |
||
293 |
!SnapShotImageMemory methodsFor:'private'! |
|
294 |
||
295 |
allClassesDo:aBlock |
|
1551 | 296 |
globalEntries do:[:eachGlobal | |
1416 | 297 |
|val| |
298 |
||
1551 | 299 |
val := eachGlobal value. |
300 |
(val notNil |
|
301 |
and:[(val isKindOf:ImageHeader) |
|
302 |
and:[val isImageBehavior]]) ifTrue:[ |
|
1416 | 303 |
aBlock value:val |
1417 | 304 |
]. |
1416 | 305 |
]. |
306 |
! |
|
307 |
||
1419 | 308 |
fetchByteArrayFor:aByteArrayRef |
309 |
|nBytes| |
|
310 |
||
311 |
(aByteArrayRef isImageBytes) ifFalse:[self halt]. |
|
312 |
||
313 |
nBytes := aByteArrayRef byteSize - (intSize * 3). |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
314 |
^ ((ByteArray new:nBytes) replaceFrom:1 to:nBytes-1 with:aByteArrayRef startingAt:1). |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
315 |
! |
1419 | 316 |
|
1417 | 317 |
fetchStringFor:aStringRef |
318 |
|nBytes| |
|
319 |
||
320 |
(aStringRef isImageBytes) ifFalse:[self halt]. |
|
321 |
||
322 |
nBytes := aStringRef byteSize - (intSize * 3). |
|
323 |
^ ((ByteArray new:nBytes-1) replaceFrom:1 to:nBytes-1 with:aStringRef startingAt:1) asString. |
|
324 |
! |
|
325 |
||
1416 | 326 |
for:aFilename |
327 |
stream := aFilename asFilename readStream binary. |
|
328 |
addrToObjectMapping := IdentityDictionary new. |
|
1417 | 329 |
|
330 |
addrToObjectMapping at:(ObjectMemory addressOf:false) put:false. |
|
331 |
addrToObjectMapping at:(ObjectMemory addressOf:true) put:true. |
|
332 |
! |
|
333 |
||
334 |
printStringOfClass:aClassRef |
|
335 |
|nameSlot| |
|
336 |
||
337 |
(aClassRef isImageBehavior) ifFalse:[self halt]. |
|
338 |
((aClassRef byteSize // intSize) - 3) < Class instSize ifTrue:[self halt.]. |
|
339 |
||
340 |
nameSlot := aClassRef at:7. |
|
341 |
nameSlot isInteger ifTrue:[ |
|
342 |
nameSlot := self fetchObjectAt:nameSlot |
|
343 |
]. |
|
344 |
nameSlot isImageSymbol ifFalse:[self halt]. |
|
345 |
^ 'Class: ' , (self printStringOfSymbol:nameSlot) |
|
346 |
! |
|
347 |
||
348 |
printStringOfObject:anObjectRef |
|
349 |
|s nBytes| |
|
350 |
||
351 |
anObjectRef isNil ifTrue:[^ 'nil']. |
|
352 |
(anObjectRef isInteger) ifTrue:[^ anObjectRef printString]. |
|
353 |
(anObjectRef == true ) ifTrue:[^ anObjectRef printString]. |
|
354 |
(anObjectRef == false) ifTrue:[^ anObjectRef printString]. |
|
355 |
||
356 |
(anObjectRef isImageSymbol) ifTrue:[^ self printStringOfSymbol:anObjectRef]. |
|
357 |
(anObjectRef isImageBehavior) ifTrue:[^ self printStringOfClass:anObjectRef]. |
|
358 |
||
359 |
^ 'obj(' , anObjectRef printString , ')' |
|
360 |
! |
|
361 |
||
362 |
printStringOfString:aStringRef |
|
363 |
|nBytes| |
|
364 |
||
365 |
(aStringRef isString) ifFalse:[self halt]. |
|
366 |
^ self fetchStringFor:aStringRef. |
|
367 |
! |
|
368 |
||
369 |
printStringOfSymbol:aSymbolRef |
|
370 |
|nBytes| |
|
371 |
||
372 |
(aSymbolRef isImageSymbol) ifFalse:[self halt]. |
|
1420 | 373 |
^ self fetchStringFor:aSymbolRef. |
1417 | 374 |
"/ nBytes := aSymbolRef size - (intSize * 3). |
375 |
"/ ^ ((ByteArray new:nBytes-1) replaceFrom:1 to:nBytes-1 with:aSymbolRef startingAt:1) asString. |
|
1416 | 376 |
! |
377 |
||
378 |
readGlobalEntries |
|
1417 | 379 |
|refPointer theSymbolPtr theSymbolRef theValuePtr theValueRef pos| |
1416 | 380 |
|
381 |
globalEntries := OrderedCollection new. |
|
382 |
[ |
|
383 |
refPointer := stream nextUnsignedLongMSB:msb. |
|
1417 | 384 |
theSymbolPtr := stream nextUnsignedLongMSB:msb. |
385 |
theValuePtr := stream nextUnsignedLongMSB:msb. |
|
386 |
theSymbolPtr ~~ 0 |
|
1416 | 387 |
] whileTrue:[ |
1417 | 388 |
globalEntries add:(theSymbolPtr -> theValuePtr). |
1416 | 389 |
]. |
1417 | 390 |
globalEntries := globalEntries asArray. |
391 |
||
392 |
"/ globalEntries inspect. |
|
393 |
pos := stream position. |
|
394 |
globalEntries do:[:item | |
|
395 |
theSymbolPtr := item key. |
|
396 |
theValuePtr := item value. |
|
397 |
theSymbolRef := self fetchObjectAt:theSymbolPtr. |
|
398 |
||
399 |
"/ Transcript show:(self printStringOfSymbol:theSymbolRef). |
|
400 |
"/ Transcript show:'->'. |
|
401 |
||
402 |
theValueRef := self fetchObjectAt:theValuePtr. |
|
403 |
"/ Transcript show:(self printStringOfObject:theValueRef). |
|
404 |
"/ Transcript cr. |
|
405 |
||
406 |
item key:theSymbolRef. |
|
407 |
item value:theValueRef. |
|
408 |
]. |
|
409 |
stream position:pos. |
|
1416 | 410 |
! |
411 |
||
412 |
readHeader |
|
413 |
" |
|
414 |
(self for:'stmeas.img') readHeader |
|
415 |
" |
|
416 |
||
417 |
|order magic version timeStamp snapID last_util_addr hiText_addr flags |
|
418 |
lowData hiData charSlots charTableSlots fixMemStart fixMemEnd |
|
419 |
symMemStart symMemEnd vmDataAddr sharedMethodCode sharedBlockCode |
|
420 |
nContexts contextSpace nRegistered symbolsSeqNr nSpaces |
|
1417 | 421 |
classNameSize spaceSize| |
1416 | 422 |
|
423 |
stream next:256. "/ skip execCmd |
|
424 |
||
425 |
msb := false. |
|
426 |
order := stream nextUnsignedLongMSB:msb. |
|
427 |
order = 16r076543210 ifTrue:[ |
|
428 |
] ifFalse:[ |
|
1423 | 429 |
order = 16r10325476 ifTrue:[ |
1416 | 430 |
msb := true. |
431 |
] ifFalse:[ |
|
432 |
self error:'unhandled byteorder' |
|
433 |
]. |
|
434 |
]. |
|
435 |
magic := (stream next:8) asString. |
|
436 |
magic ~= 'ST/X-IMG' ifTrue:[ |
|
437 |
self error:'not an st/x image' |
|
438 |
]. |
|
439 |
version := stream nextUnsignedLongMSB:msb. |
|
440 |
timeStamp := stream nextUnsignedLongMSB:msb. |
|
441 |
ptrSize := stream nextByte. |
|
442 |
ptrSize ~~ 4 ifTrue:[ |
|
443 |
self error:'unhandled ptr format' |
|
444 |
]. |
|
445 |
stream next:7. "/ filler |
|
446 |
intSize := stream nextUnsignedLongMSB:msb. |
|
447 |
intSize == 9 ifTrue:[ |
|
448 |
intSize := 4. |
|
449 |
intTag := 1. |
|
450 |
] ifFalse:[ |
|
451 |
self error:'unhandled int format' |
|
452 |
]. |
|
453 |
||
454 |
snapID := stream nextUnsignedLongMSB:msb. |
|
455 |
last_util_addr := stream next:intSize. |
|
456 |
hiText_addr := stream next:intSize. |
|
457 |
flags := stream next:intSize. |
|
458 |
stream next:8. "/ info, debug & filler |
|
459 |
||
460 |
lowData := stream nextUnsignedLongMSB:msb. |
|
461 |
hiData := stream nextUnsignedLongMSB:msb. |
|
462 |
||
463 |
charSlots := stream nextUnsignedLongMSB:msb. |
|
464 |
charTableSlots := stream nextUnsignedLongMSB:msb. |
|
465 |
||
466 |
version >= 8 ifTrue:[ |
|
467 |
fixMemStart := stream nextUnsignedLongMSB:msb. |
|
468 |
fixMemEnd := stream nextUnsignedLongMSB:msb. |
|
469 |
symMemStart := stream nextUnsignedLongMSB:msb. |
|
470 |
symMemEnd := stream nextUnsignedLongMSB:msb. |
|
471 |
vmDataAddr := stream nextUnsignedLongMSB:msb. |
|
472 |
]. |
|
473 |
stream next:(128 * intSize). "/ skip sharedMethodCode ptrs |
|
474 |
stream next:(128 * intSize). "/ skip sharedBlockCode ptrs |
|
475 |
||
476 |
nContexts := stream nextUnsignedLongMSB:msb. |
|
477 |
contextSpace := stream nextUnsignedLongMSB:msb. |
|
478 |
nRegistered := stream nextUnsignedLongMSB:msb. |
|
479 |
||
480 |
version >= 8 ifTrue:[ |
|
481 |
version >= 9 ifTrue:[ |
|
482 |
symbolsSeqNr := stream nextUnsignedLongMSB:msb. |
|
483 |
stream next:(intSize * 31). |
|
484 |
] ifFalse:[ |
|
485 |
stream next:(intSize * 32). |
|
486 |
] |
|
487 |
]. |
|
488 |
||
489 |
nSpaces := stream nextUnsignedLongMSB:msb. |
|
490 |
spaceInfos := (1 to:nSpaces) collect:[:idx | SpaceInfo new]. |
|
491 |
||
492 |
1 to:nSpaces do:[:i | |
|
493 |
(spaceInfos at:i) flags:(stream nextUnsignedLongMSB:msb). |
|
494 |
]. |
|
495 |
nSpaces+1 to:32 do:[:i | stream nextUnsignedLongMSB:msb]. |
|
496 |
||
497 |
1 to:nSpaces do:[:i | |
|
498 |
(spaceInfos at:i) start:(stream nextUnsignedLongMSB:msb). |
|
499 |
]. |
|
500 |
nSpaces+1 to:32 do:[:i | stream nextUnsignedLongMSB:msb]. |
|
501 |
||
502 |
1 to:nSpaces do:[:i | |
|
503 |
(spaceInfos at:i) size:(stream nextUnsignedLongMSB:msb). |
|
504 |
]. |
|
505 |
nSpaces+1 to:32 do:[:i | stream nextUnsignedLongMSB:msb]. |
|
506 |
||
507 |
version >= 8 ifTrue:[ |
|
1417 | 508 |
stream position:(stream class zeroPosition). |
509 |
stream skip:4096. |
|
1416 | 510 |
]. |
511 |
||
512 |
1 to:nSpaces do:[:i | |
|
513 |
(spaceInfos at:i) end:((spaceInfos at:i) start + (spaceInfos at:i) size - 1). |
|
514 |
]. |
|
515 |
1 to:nSpaces do:[:i | |
|
516 |
(spaceInfos at:i) imageBase:(stream position). |
|
1417 | 517 |
spaceSize := (spaceInfos at:i) size. |
518 |
stream skip:spaceSize. |
|
1416 | 519 |
]. |
520 |
||
521 |
"/ registration |
|
522 |
||
523 |
self readRegistrationEntries. |
|
1417 | 524 |
Transcript showCR:'reading symbols...'. |
1416 | 525 |
self readSymbolEntries. |
1417 | 526 |
self readUGlobalEntries. |
527 |
Transcript showCR:'reading globals...'. |
|
1416 | 528 |
self readGlobalEntries. |
529 |
||
530 |
||
531 |
"/struct basicImageHeader { |
|
532 |
"/ char h_execCmd[256]; |
|
533 |
"/ |
|
534 |
"/ int h_orderWord; |
|
535 |
"/ char h_magic[8]; |
|
536 |
"/ int h_version; |
|
537 |
"/ int h_timeStamp; |
|
538 |
"/ char h_ptrSize; |
|
539 |
"/ char h_filler1[7]; |
|
540 |
"/ int h_intSize; |
|
541 |
"/ int h_snapID; |
|
542 |
"/ INT h_last_util_addr; |
|
543 |
"/ INT h_hiText_addr; |
|
544 |
"/ INT h_flags; |
|
545 |
"/ char h_infoPrinting; |
|
546 |
"/ char h_debugPrinting; |
|
547 |
"/ char h_filler2[6]; |
|
548 |
"/ |
|
549 |
"/ /* |
|
550 |
"/ * these are to verify compatibility of the image with |
|
551 |
"/ * myself ... |
|
552 |
"/ * this is now obsolete. |
|
553 |
"/ */ |
|
554 |
"/ INT h_lowData, h_hiData; |
|
555 |
"/ |
|
556 |
"/ /* |
|
557 |
"/ * base address of character- and characterTable slots |
|
558 |
"/ */ |
|
559 |
"/ INT h_charSlots; |
|
560 |
"/ INT h_charTableSlots; |
|
561 |
"/ |
|
562 |
"/#if HEADER_VERSION >= 8 |
|
563 |
"/ /* |
|
564 |
"/ * the fixBase (VMDATA address) |
|
565 |
"/ */ |
|
566 |
"/ INT h_fixMemStart; |
|
567 |
"/ INT h_fixMemEnd; |
|
568 |
"/ INT h_symMemStart; |
|
569 |
"/ INT h_symMemEnd; |
|
570 |
"/ |
|
571 |
"/ INT h_vmDataAddr; |
|
572 |
"/#endif |
|
573 |
"/ |
|
574 |
"/ INT h_sharedMethodCode[128]; |
|
575 |
"/ INT h_sharedBlockCode[128]; |
|
576 |
"/ |
|
577 |
"/ /* |
|
578 |
"/ * space needed to restore contexts |
|
579 |
"/ */ |
|
580 |
"/ INT h_nContexts; |
|
581 |
"/ INT h_contextSpace; |
|
582 |
"/ |
|
583 |
"/ /* |
|
584 |
"/ * number of class registration info records |
|
585 |
"/ */ |
|
586 |
"/ INT h_nRegistered; |
|
587 |
"/ |
|
588 |
"/#if HEADER_VERSION >= 8 |
|
589 |
"/ /* |
|
590 |
"/ * reserved slots, for future versions |
|
591 |
"/ * (can add additional info, without affecting position of following stuff) |
|
592 |
"/ * If you add slots, you MUST DECREMENT the fillcount. |
|
593 |
"/ */ |
|
594 |
"/# if HEADER_VERSION >= 9 |
|
595 |
"/ INT h_symbolsSeqNr; |
|
596 |
"/ INT h_reserved[31]; |
|
597 |
"/# else |
|
598 |
"/ INT h_reserved[32]; |
|
599 |
"/# endif |
|
600 |
"/#endif |
|
601 |
"/ |
|
602 |
"/ /* |
|
603 |
"/ * number of spaces, base and size of each |
|
604 |
"/ */ |
|
605 |
"/ INT h_nSpaces; |
|
606 |
"/ INT h_spaceFlags[MAXSPACES]; |
|
607 |
"/ INT h_spaceBase[MAXSPACES]; |
|
608 |
"/ INT h_spaceSize[MAXSPACES]; |
|
609 |
"/ |
|
610 |
"/ /* |
|
611 |
"/ * here come nSpaces object spaces |
|
612 |
"/ */ |
|
613 |
"/ |
|
614 |
"/ /* |
|
615 |
"/ * here comes registration info |
|
616 |
"/ */ |
|
617 |
"/ |
|
618 |
"/ /* |
|
619 |
"/ * here come nSymbols symbolEntries |
|
620 |
"/ * followed by a zero/zero entry |
|
621 |
"/ */ |
|
622 |
"/ |
|
623 |
"/ /* |
|
624 |
"/ * here come nGlobal globalEntries |
|
625 |
"/ * followed by a zero/zero entry |
|
626 |
"/ */ |
|
627 |
"/ |
|
628 |
"/ /* |
|
629 |
"/ * here come nUnnamedGlobal globalEntries |
|
630 |
"/ * followed by a zero/zero entry |
|
631 |
"/ */ |
|
632 |
"/ |
|
633 |
"/ /* |
|
634 |
"/ * here come stack contexts |
|
635 |
"/ */ |
|
636 |
"/}; |
|
637 |
! |
|
638 |
||
639 |
readRegistrationEntries |
|
640 |
|classNameSize| |
|
641 |
||
642 |
[ |
|
643 |
classNameSize := stream nextUnsignedLongMSB:msb. |
|
644 |
classNameSize ~~ 0 |
|
645 |
] whileTrue:[ |
|
646 |
|className flags moduleTimestamp signature nMethods nBlocks oldLitRefs nLitRefs |
|
647 |
oldConstTable nConsts| |
|
648 |
||
649 |
className := (stream next:classNameSize) asString. |
|
650 |
stream next. "/ 0-byte |
|
651 |
flags := stream nextUnsignedLongMSB:msb. |
|
652 |
moduleTimestamp := stream nextUnsignedLongMSB:msb. |
|
653 |
signature := stream nextUnsignedLongMSB:msb. |
|
654 |
nMethods := stream nextUnsignedLongMSB:msb. |
|
655 |
nMethods timesRepeat:[ stream nextUnsignedLongMSB:msb ]. |
|
656 |
nBlocks := stream nextUnsignedLongMSB:msb. |
|
657 |
nBlocks timesRepeat:[ stream nextUnsignedLongMSB:msb ]. |
|
658 |
oldLitRefs := stream nextUnsignedLongMSB:msb. |
|
659 |
nLitRefs := stream nextUnsignedLongMSB:msb. |
|
660 |
nLitRefs timesRepeat:[ stream nextUnsignedLongMSB:msb ]. |
|
661 |
stream nextUnsignedLongMSB:msb. "/ 0-litRef |
|
662 |
oldConstTable := stream nextUnsignedLongMSB:msb. |
|
1550 | 663 |
nConsts := stream nextLongMSB:msb. |
664 |
nConsts > 0 ifTrue:[ |
|
665 |
nConsts timesRepeat:[ stream nextUnsignedLongMSB:msb ]. |
|
666 |
] |
|
1420 | 667 |
"/ Transcript showCR:className. |
1416 | 668 |
]. |
669 |
! |
|
670 |
||
671 |
readSymbolEntries |
|
1417 | 672 |
|refPointer theSymbolPtr theSymbolRef pos| |
1416 | 673 |
|
674 |
symbolEntries := OrderedCollection new. |
|
675 |
||
676 |
[ |
|
677 |
refPointer := stream nextUnsignedLongMSB:msb. |
|
1417 | 678 |
theSymbolPtr := stream nextUnsignedLongMSB:msb. |
679 |
theSymbolPtr ~~ 0 |
|
1416 | 680 |
] whileTrue:[ |
1417 | 681 |
symbolEntries add:theSymbolPtr. |
1416 | 682 |
]. |
1417 | 683 |
symbolEntries := symbolEntries asArray. |
684 |
||
685 |
pos := stream position. |
|
686 |
symbolEntries := symbolEntries collect:[:theSymbolPtr | |
|
687 |
theSymbolRef := self fetchObjectAt:theSymbolPtr. |
|
688 |
theSymbolRef isImageSymbol ifFalse:[ |
|
689 |
self halt |
|
690 |
]. |
|
691 |
]. |
|
692 |
stream position:pos |
|
1416 | 693 |
! |
694 |
||
695 |
readUGlobalEntries |
|
696 |
|refPointer theValue| |
|
697 |
||
698 |
[ |
|
699 |
refPointer := stream nextUnsignedLongMSB:msb. |
|
700 |
theValue := stream nextUnsignedLongMSB:msb. |
|
701 |
refPointer ~~ 0 |
|
702 |
] whileTrue |
|
703 |
! ! |
|
704 |
||
1417 | 705 |
!SnapShotImageMemory::ImageHeader methodsFor:'accessing'! |
706 |
||
707 |
bits |
|
708 |
"return the value of the instance variable 'bits' (automatically generated)" |
|
709 |
||
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
710 |
^ bits |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
711 |
! |
1417 | 712 |
|
713 |
bits:something |
|
714 |
"set the value of the instance variable 'bits' (automatically generated)" |
|
715 |
||
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
716 |
bits := something. |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
717 |
! |
1417 | 718 |
|
719 |
byteSize |
|
720 |
"return the value of the instance variable 'size' (automatically generated)" |
|
721 |
||
722 |
^ byteSize |
|
723 |
! |
|
724 |
||
725 |
byteSize:something |
|
726 |
"set the value of the instance variable 'size' (automatically generated)" |
|
727 |
||
728 |
something > 8000 ifTrue:[self halt]. |
|
729 |
byteSize := something. |
|
730 |
! |
|
731 |
||
732 |
classRef |
|
733 |
"return the value of the instance variable 'classRef' (automatically generated)" |
|
734 |
||
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
735 |
^ classRef |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
736 |
! |
1417 | 737 |
|
738 |
classRef:something |
|
739 |
"set the value of the instance variable 'classRef' (automatically generated)" |
|
740 |
||
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
741 |
classRef := something. |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
742 |
! |
1417 | 743 |
|
744 |
memory |
|
745 |
"return the value of the instance variable 'memory' (automatically generated)" |
|
746 |
||
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
747 |
^ memory |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
748 |
! |
1417 | 749 |
|
750 |
memory:something |
|
751 |
"set the value of the instance variable 'memory' (automatically generated)" |
|
752 |
||
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
753 |
memory := something. |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
754 |
! ! |
1417 | 755 |
|
756 |
!SnapShotImageMemory::ImageHeader methodsFor:'queries'! |
|
757 |
||
758 |
category |
|
759 |
|categoryPtr categoryRef category| |
|
760 |
||
761 |
self isMethodOrLazyMethod ifTrue:[ |
|
762 |
categoryPtr := self at:6. |
|
763 |
categoryRef := memory fetchObjectAt:categoryPtr. |
|
764 |
category := memory fetchStringFor:categoryRef. |
|
765 |
^ category |
|
766 |
]. |
|
767 |
self halt. |
|
768 |
! |
|
769 |
||
1419 | 770 |
isBehavior |
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
771 |
^ self isImageBehavior |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
772 |
! |
1419 | 773 |
|
1417 | 774 |
isImageBehavior |
775 |
|flags| |
|
776 |
||
777 |
flags := classRef flags. |
|
778 |
^ flags bitTest:Behavior flagBehavior |
|
779 |
! |
|
780 |
||
781 |
isImageBytes |
|
782 |
|flags| |
|
783 |
||
784 |
flags := classRef flags bitAnd:Behavior maskIndexType. |
|
785 |
^ flags = Behavior flagBytes |
|
786 |
! |
|
787 |
||
788 |
isImageMethod |
|
789 |
|flags| |
|
790 |
||
791 |
flags := classRef flags. |
|
792 |
^ flags bitTest:Behavior flagMethod |
|
793 |
! |
|
794 |
||
795 |
isImageSymbol |
|
796 |
|flags| |
|
797 |
||
798 |
flags := classRef flags. |
|
799 |
^ flags bitTest:Behavior flagSymbol |
|
800 |
! |
|
801 |
||
1420 | 802 |
isJavaMethod |
803 |
|nm| |
|
804 |
||
805 |
nm := classRef name. |
|
806 |
^ (nm = 'JavaMethod' |
|
807 |
or:[ nm = 'JavaMethodWithException' |
|
808 |
or:[ nm = 'JavaMethodWithHandler' |
|
809 |
or:[ nm = 'JavaNativeMethod' ]]]) |
|
810 |
! |
|
811 |
||
1419 | 812 |
isLazyMethod |
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
813 |
^ classRef name = 'LazyMethod' |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
814 |
! |
1419 | 815 |
|
1417 | 816 |
isMeta |
817 |
^ false |
|
818 |
! |
|
819 |
||
820 |
isMethod |
|
1420 | 821 |
|cls| |
822 |
||
823 |
cls := classRef. |
|
824 |
[cls notNil] whileTrue:[ |
|
825 |
cls name = 'Method' ifTrue:[^ true]. |
|
826 |
cls := cls superclass |
|
827 |
]. |
|
828 |
^ false. |
|
1417 | 829 |
! |
830 |
||
831 |
isMethodDictionary |
|
832 |
^ classRef name = 'MethodDictionary' |
|
833 |
! |
|
834 |
||
835 |
isMethodOrLazyMethod |
|
836 |
classRef name = 'LazyMethod' ifTrue:[^ true]. |
|
1420 | 837 |
^ self isMethod |
1417 | 838 |
! |
839 |
||
840 |
isString |
|
841 |
^ classRef name = 'String' |
|
842 |
! ! |
|
843 |
||
1419 | 844 |
!SnapShotImageMemory::ImageObject methodsFor:'method protocol'! |
845 |
||
846 |
byteCode |
|
847 |
|byteCodeSlotOffset byteCodePtr byteCodeRef byteCode| |
|
848 |
||
849 |
self isMethod ifTrue:[ |
|
850 |
byteCodeSlotOffset := Method instVarOffsetOf:'byteCode'. |
|
851 |
]. |
|
852 |
byteCodeSlotOffset notNil ifTrue:[ |
|
853 |
byteCodePtr := self at:byteCodeSlotOffset. |
|
854 |
byteCodeRef := memory fetchObjectAt:byteCodePtr. |
|
855 |
byteCodeRef isNil ifTrue:[^ nil]. |
|
856 |
||
857 |
byteCode := memory fetchByteArrayFor:byteCodeRef. |
|
858 |
^ byteCode |
|
859 |
]. |
|
860 |
||
861 |
self halt. |
|
862 |
! |
|
863 |
||
864 |
comment |
|
865 |
|src comment comments parser| |
|
866 |
||
867 |
self isMethod ifTrue:[ |
|
868 |
src := self source. |
|
869 |
src isNil ifTrue:[^ nil]. |
|
870 |
||
871 |
parser := Parser for:src in:nil. |
|
872 |
parser ignoreErrors; ignoreWarnings; saveComments:true. |
|
873 |
parser parseMethodSpec. |
|
874 |
comments := parser comments. |
|
875 |
comments size ~~ 0 ifTrue:[ |
|
876 |
comment := comments first string. |
|
877 |
(comment withoutSpaces endsWith:'}') ifTrue:[ |
|
878 |
"if first comment is a pragma, take next comment" |
|
879 |
comment := comments at:2 ifAbsent:nil. |
|
880 |
comment notNil ifTrue:[ |
|
881 |
comment := comment string. |
|
882 |
]. |
|
883 |
]. |
|
1417 | 884 |
]. |
1419 | 885 |
^ comment. |
1417 | 886 |
]. |
1419 | 887 |
self isLazyMethod ifTrue:[ |
888 |
^ '' |
|
889 |
]. |
|
890 |
||
891 |
self halt. |
|
1417 | 892 |
! |
1416 | 893 |
|
1419 | 894 |
containingClass |
895 |
self isMethodOrLazyMethod ifTrue:[ |
|
896 |
^ self mclass |
|
1417 | 897 |
]. |
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
898 |
self halt. |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
899 |
! |
1419 | 900 |
|
1469 | 901 |
flags |
902 |
|flagsSlotOffset flagsPtr flags| |
|
903 |
||
904 |
self isMethod ifTrue:[ |
|
905 |
flagsSlotOffset := Method instVarOffsetOf:'flags'. |
|
906 |
]. |
|
907 |
flagsSlotOffset notNil ifTrue:[ |
|
908 |
flagsPtr := self at:flagsSlotOffset. |
|
909 |
flags := memory fetchObjectAt:flagsPtr. |
|
910 |
^ flags |
|
911 |
]. |
|
912 |
||
913 |
self halt. |
|
914 |
! |
|
915 |
||
1419 | 916 |
hasCode |
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
917 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
918 |
! |
1419 | 919 |
|
920 |
isBreakpointed |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
921 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
922 |
! |
1419 | 923 |
|
924 |
isCounting |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
925 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
926 |
! |
1419 | 927 |
|
928 |
isCountingMemoryUsage |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
929 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
930 |
! |
1419 | 931 |
|
932 |
isDynamic |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
933 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
934 |
! |
1419 | 935 |
|
936 |
isExecutable |
|
937 |
self isMethod ifTrue:[ |
|
938 |
^ false |
|
939 |
]. |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
940 |
self halt. |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
941 |
! |
1419 | 942 |
|
943 |
isIgnored |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
944 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
945 |
! |
1419 | 946 |
|
1482 | 947 |
isObsolete |
948 |
^ false |
|
949 |
! |
|
950 |
||
1419 | 951 |
isPrivate |
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
952 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
953 |
! |
1419 | 954 |
|
955 |
isProtected |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
956 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
957 |
! |
1419 | 958 |
|
959 |
isPublic |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
960 |
^ true |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
961 |
! |
1419 | 962 |
|
963 |
isTimed |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
964 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
965 |
! |
1419 | 966 |
|
967 |
isTraced |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
968 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
969 |
! |
1416 | 970 |
|
1417 | 971 |
isWrapped |
972 |
^ false |
|
1416 | 973 |
! |
974 |
||
1419 | 975 |
mclass |
976 |
|mclassSlotOffset mclassPtr mclass| |
|
977 |
||
978 |
self isMethod ifTrue:[ |
|
979 |
mclassSlotOffset := Method instVarOffsetOf:'mclass'. |
|
1420 | 980 |
] ifFalse:[ |
981 |
self isJavaMethod ifTrue:[ |
|
982 |
mclassSlotOffset := JavaMethod instVarOffsetOf:'javaClass'. |
|
983 |
] |
|
984 |
]. |
|
985 |
||
986 |
mclassSlotOffset notNil ifTrue:[ |
|
1419 | 987 |
mclassPtr := self at:mclassSlotOffset. |
988 |
mclassPtr ~~ 0 ifTrue:[ |
|
1420 | 989 |
mclassPtr isInteger ifTrue:[ |
990 |
mclass := memory fetchObjectAt:mclassPtr. |
|
991 |
self at:mclassSlotOffset put:mclass. |
|
992 |
] ifFalse:[ |
|
993 |
mclass := mclassPtr. |
|
994 |
]. |
|
1419 | 995 |
mclass isImageBehavior ifFalse:[ |
996 |
self halt |
|
997 |
]. |
|
998 |
^ mclass |
|
999 |
]. |
|
1000 |
||
1001 |
"/ search my class ... |
|
1002 |
memory image allClassesDo:[:eachClass | |
|
1003 |
eachClass theNonMetaclass methodDictionary keysAndValuesDo:[:sel :mthdRef | |
|
1004 |
mthdRef == self ifTrue:[ |
|
1005 |
self at:mclassSlotOffset put:eachClass theNonMetaclass. |
|
1006 |
^ eachClass theNonMetaclass |
|
1007 |
]. |
|
1008 |
]. |
|
1009 |
eachClass theMetaclass methodDictionary keysAndValuesDo:[:sel :mthdRef | |
|
1010 |
mthdRef == self ifTrue:[ |
|
1011 |
self at:mclassSlotOffset put:eachClass theMetaclass. |
|
1012 |
^ eachClass theMetaclass |
|
1013 |
]. |
|
1014 |
] |
|
1417 | 1015 |
]. |
1419 | 1016 |
self halt. |
1420 | 1017 |
^ nil. |
1417 | 1018 |
]. |
1420 | 1019 |
^ nil. |
1419 | 1020 |
self halt. |
1417 | 1021 |
! |
1022 |
||
1419 | 1023 |
numArgs |
1469 | 1024 |
|flags| |
1025 |
||
1026 |
flags := self flags. |
|
1027 |
^ (flags bitAnd:(Method numArgsMaskInFlags)) bitShift:(Method numArgsShiftInFlags negated) |
|
1419 | 1028 |
! |
1029 |
||
1030 |
package |
|
1031 |
|packageSlotOffset packagePtr packageRef package| |
|
1032 |
||
1033 |
self isImageBehavior ifTrue:[ |
|
1034 |
self isMeta ifTrue:[ |
|
1035 |
^ self theNonMetaclass package |
|
1036 |
]. |
|
1037 |
packageSlotOffset := Class instVarOffsetOf:'package'. |
|
1420 | 1038 |
] ifFalse:[ |
1039 |
self isMethod ifTrue:[ |
|
1040 |
packageSlotOffset := Method instVarOffsetOf:'package'. |
|
1041 |
] ifFalse:[ |
|
1042 |
self isLazyMethod ifTrue:[ |
|
1043 |
packageSlotOffset := Method instVarOffsetOf:'package'. |
|
1044 |
]. |
|
1045 |
]. |
|
1419 | 1046 |
]. |
1047 |
packageSlotOffset notNil ifTrue:[ |
|
1048 |
packagePtr := self at:packageSlotOffset. |
|
1049 |
packageRef := memory fetchObjectAt:packagePtr. |
|
1050 |
packageRef isNil ifTrue:[^ nil]. |
|
1051 |
||
1052 |
packageRef isImageSymbol ifFalse:[ |
|
1420 | 1053 |
packageRef isImageBytes ifFalse:[ |
1054 |
self halt. |
|
1055 |
]. |
|
1056 |
"/ mhmh - can be a string sometimes ... |
|
1419 | 1057 |
]. |
1058 |
package := memory fetchStringFor:packageRef. |
|
1059 |
^ package asSymbol |
|
1060 |
]. |
|
1061 |
self isMeta ifTrue:[ |
|
1062 |
self halt |
|
1063 |
]. |
|
1064 |
||
1420 | 1065 |
^ nil |
1419 | 1066 |
! |
1067 |
||
1068 |
previousVersion |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1069 |
^ nil |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1070 |
! |
1419 | 1071 |
|
1417 | 1072 |
printStringForBrowserWithSelector:selector |
1073 |
^ selector |
|
1074 |
! |
|
1075 |
||
1419 | 1076 |
privacy |
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1077 |
^ #public |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1078 |
! |
1419 | 1079 |
|
1417 | 1080 |
resources |
1081 |
^ nil |
|
1082 |
! |
|
1083 |
||
1084 |
source |
|
1482 | 1085 |
self halt:'unimplemented'. |
1416 | 1086 |
! |
1087 |
||
1419 | 1088 |
sourceFilename |
1089 |
"return the sourcefilename if source is extern; nil otherwise" |
|
1090 |
||
1486 | 1091 |
|sourcePtr sourceRef source| |
1485 | 1092 |
|
1419 | 1093 |
self isMethodOrLazyMethod ifTrue:[ |
1484 | 1094 |
self sourcePosition notNil ifTrue:[ |
1486 | 1095 |
sourcePtr := self at:(Method instVarOffsetOf:'source'). |
1096 |
sourceRef := memory fetchObjectAt:sourcePtr. |
|
1097 |
sourceRef isString ifFalse:[ |
|
1098 |
self halt. |
|
1485 | 1099 |
]. |
1486 | 1100 |
source := memory printStringOfString:sourceRef. |
1485 | 1101 |
^ source. |
1484 | 1102 |
]. |
1419 | 1103 |
^ nil |
1104 |
]. |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1105 |
self halt. |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1106 |
! |
1419 | 1107 |
|
1108 |
sourceLineNumber |
|
1109 |
self isMethodOrLazyMethod ifTrue:[ |
|
1110 |
^ 1 |
|
1111 |
]. |
|
1112 |
self halt. |
|
1113 |
! |
|
1114 |
||
1115 |
sourcePosition |
|
1116 |
|sourcePosition| |
|
1117 |
||
1118 |
self isMethodOrLazyMethod ifTrue:[ |
|
1119 |
sourcePosition := self sourcePositionValue. |
|
1120 |
sourcePosition isNil ifTrue:[^ sourcePosition]. |
|
1121 |
^ sourcePosition abs |
|
1122 |
]. |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1123 |
self halt. |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1124 |
! |
1419 | 1125 |
|
1126 |
sourcePositionValue |
|
1127 |
|sourcePosition sourcePositionPtr| |
|
1128 |
||
1129 |
self isMethodOrLazyMethod ifTrue:[ |
|
1130 |
sourcePositionPtr := self at:(Method instVarOffsetOf:'sourcePosition'). |
|
1131 |
sourcePosition := memory fetchObjectAt:sourcePositionPtr. |
|
1132 |
^ sourcePosition |
|
1133 |
]. |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1134 |
self halt. |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1135 |
! |
1419 | 1136 |
|
1417 | 1137 |
sourceStream |
1138 |
|sourcePosition source aStream fileName junk who |
|
1139 |
myClass mgr className sep dir mod package| |
|
1140 |
||
1141 |
self isMethod ifTrue:[ |
|
1142 |
sourcePosition := self at:(Method instVarOffsetOf:'sourcePosition'). |
|
1143 |
source := self at:(Method instVarOffsetOf:'source'). |
|
1144 |
source := memory fetchObjectAt:source. |
|
1145 |
source isString ifTrue:[ |
|
1146 |
source := memory printStringOfString:source. |
|
1147 |
]. |
|
1148 |
sourcePosition notNil ifTrue:[ |
|
1149 |
sourcePosition := memory fetchObjectAt:sourcePosition. |
|
1150 |
]. |
|
1151 |
||
1152 |
source isNil ifTrue:[^ nil]. |
|
1153 |
sourcePosition isNil ifTrue:[^ source readStream]. |
|
1154 |
||
1155 |
sourcePosition < 0 ifTrue:[ |
|
1156 |
aStream := source asFilename readStream. |
|
1157 |
aStream notNil ifTrue:[ |
|
1158 |
^ aStream |
|
1159 |
]. |
|
1160 |
||
1161 |
fileName := Smalltalk getSourceFileName:source. |
|
1162 |
fileName notNil ifTrue:[ |
|
1163 |
aStream := fileName asFilename readStream. |
|
1164 |
aStream notNil ifTrue:[ |
|
1165 |
^ aStream |
|
1166 |
]. |
|
1167 |
]. |
|
1168 |
]. |
|
1169 |
||
1170 |
"/ |
|
1171 |
"/ if there is no SourceManager, look in local standard places first |
|
1172 |
"/ |
|
1173 |
(mgr := Smalltalk at:#SourceCodeManager) isNil ifTrue:[ |
|
1174 |
aStream := self localSourceStream. |
|
1175 |
aStream notNil ifTrue:[ |
|
1176 |
^ aStream |
|
1177 |
]. |
|
1178 |
]. |
|
1179 |
||
1180 |
"/ |
|
1181 |
"/ nope - ask my class for the source (this also invokes the SCMgr) |
|
1182 |
"/ |
|
1183 |
myClass := self mclass. |
|
1416 | 1184 |
|
1417 | 1185 |
package := self package. |
1186 |
(package notNil and:[package ~= myClass package]) ifTrue:[ |
|
1187 |
mgr notNil ifTrue:[ |
|
1188 |
"/ try to get the source using my package information ... |
|
1189 |
sep := package indexOfAny:'/\:'. |
|
1190 |
sep ~~ 0 ifTrue:[ |
|
1191 |
mod := package copyTo:sep - 1. |
|
1192 |
dir := package copyFrom:sep + 1. |
|
1193 |
aStream := mgr streamForClass:nil fileName:source revision:nil directory:dir module:mod cache:true. |
|
1194 |
aStream notNil ifTrue:[ |
|
1195 |
^ aStream |
|
1196 |
]. |
|
1197 |
]. |
|
1198 |
]. |
|
1199 |
]. |
|
1200 |
||
1201 |
aStream := myClass sourceStreamFor:source. |
|
1202 |
aStream notNil ifTrue:[ |
|
1203 |
^ aStream |
|
1204 |
]. |
|
1205 |
||
1206 |
"/ |
|
1207 |
"/ nope - look in standard places |
|
1208 |
"/ (if there is a source-code manager - otherwise, we already did that) |
|
1209 |
"/ |
|
1210 |
mgr notNil ifTrue:[ |
|
1211 |
aStream := self localSourceStream. |
|
1212 |
aStream notNil ifTrue:[ |
|
1213 |
^ aStream |
|
1214 |
]. |
|
1215 |
]. |
|
1216 |
||
1217 |
"/ |
|