author | james |
Tue, 06 Nov 2001 16:42:51 +0100 | |
changeset 1526 | 8e62e3f56402 |
parent 1486 | d549a69ec127 |
child 1550 | 6ca23298d888 |
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 |
33 |
instanceVariableNames:'cachedPackage' |
|
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 |
|
296 |
self allGlobalKeysDo:[:eachKey | |
|
297 |
|val| |
|
298 |
||
299 |
val := self at:eachKey. |
|
300 |
val isBehavior ifTrue:[ |
|
301 |
aBlock value:val |
|
1417 | 302 |
] ifFalse:[ |
303 |
self halt. |
|
304 |
]. |
|
1416 | 305 |
]. |
306 |
! |
|
307 |
||
308 |
allGlobalKeysDo:aBlock |
|
1417 | 309 |
globalEntries isNil ifTrue:[ |
1416 | 310 |
self readHeader. |
311 |
self readGlobals. |
|
312 |
]. |
|
313 |
! |
|
314 |
||
1419 | 315 |
fetchByteArrayFor:aByteArrayRef |
316 |
|nBytes| |
|
317 |
||
318 |
(aByteArrayRef isImageBytes) ifFalse:[self halt]. |
|
319 |
||
320 |
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
|
321 |
^ ((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
|
322 |
! |
1419 | 323 |
|
1417 | 324 |
fetchStringFor:aStringRef |
325 |
|nBytes| |
|
326 |
||
327 |
(aStringRef isImageBytes) ifFalse:[self halt]. |
|
328 |
||
329 |
nBytes := aStringRef byteSize - (intSize * 3). |
|
330 |
^ ((ByteArray new:nBytes-1) replaceFrom:1 to:nBytes-1 with:aStringRef startingAt:1) asString. |
|
331 |
! |
|
332 |
||
1416 | 333 |
for:aFilename |
334 |
stream := aFilename asFilename readStream binary. |
|
335 |
addrToObjectMapping := IdentityDictionary new. |
|
1417 | 336 |
|
337 |
addrToObjectMapping at:(ObjectMemory addressOf:false) put:false. |
|
338 |
addrToObjectMapping at:(ObjectMemory addressOf:true) put:true. |
|
339 |
! |
|
340 |
||
341 |
printStringOfClass:aClassRef |
|
342 |
|nameSlot| |
|
343 |
||
344 |
(aClassRef isImageBehavior) ifFalse:[self halt]. |
|
345 |
((aClassRef byteSize // intSize) - 3) < Class instSize ifTrue:[self halt.]. |
|
346 |
||
347 |
nameSlot := aClassRef at:7. |
|
348 |
nameSlot isInteger ifTrue:[ |
|
349 |
nameSlot := self fetchObjectAt:nameSlot |
|
350 |
]. |
|
351 |
nameSlot isImageSymbol ifFalse:[self halt]. |
|
352 |
^ 'Class: ' , (self printStringOfSymbol:nameSlot) |
|
353 |
! |
|
354 |
||
355 |
printStringOfObject:anObjectRef |
|
356 |
|s nBytes| |
|
357 |
||
358 |
anObjectRef isNil ifTrue:[^ 'nil']. |
|
359 |
(anObjectRef isInteger) ifTrue:[^ anObjectRef printString]. |
|
360 |
(anObjectRef == true ) ifTrue:[^ anObjectRef printString]. |
|
361 |
(anObjectRef == false) ifTrue:[^ anObjectRef printString]. |
|
362 |
||
363 |
(anObjectRef isImageSymbol) ifTrue:[^ self printStringOfSymbol:anObjectRef]. |
|
364 |
(anObjectRef isImageBehavior) ifTrue:[^ self printStringOfClass:anObjectRef]. |
|
365 |
||
366 |
^ 'obj(' , anObjectRef printString , ')' |
|
367 |
! |
|
368 |
||
369 |
printStringOfString:aStringRef |
|
370 |
|nBytes| |
|
371 |
||
372 |
(aStringRef isString) ifFalse:[self halt]. |
|
373 |
^ self fetchStringFor:aStringRef. |
|
374 |
! |
|
375 |
||
376 |
printStringOfSymbol:aSymbolRef |
|
377 |
|nBytes| |
|
378 |
||
379 |
(aSymbolRef isImageSymbol) ifFalse:[self halt]. |
|
1420 | 380 |
^ self fetchStringFor:aSymbolRef. |
1417 | 381 |
"/ nBytes := aSymbolRef size - (intSize * 3). |
382 |
"/ ^ ((ByteArray new:nBytes-1) replaceFrom:1 to:nBytes-1 with:aSymbolRef startingAt:1) asString. |
|
1416 | 383 |
! |
384 |
||
385 |
readGlobalEntries |
|
1417 | 386 |
|refPointer theSymbolPtr theSymbolRef theValuePtr theValueRef pos| |
1416 | 387 |
|
388 |
globalEntries := OrderedCollection new. |
|
389 |
[ |
|
390 |
refPointer := stream nextUnsignedLongMSB:msb. |
|
1417 | 391 |
theSymbolPtr := stream nextUnsignedLongMSB:msb. |
392 |
theValuePtr := stream nextUnsignedLongMSB:msb. |
|
393 |
theSymbolPtr ~~ 0 |
|
1416 | 394 |
] whileTrue:[ |
1417 | 395 |
globalEntries add:(theSymbolPtr -> theValuePtr). |
1416 | 396 |
]. |
1417 | 397 |
globalEntries := globalEntries asArray. |
398 |
||
399 |
"/ globalEntries inspect. |
|
400 |
pos := stream position. |
|
401 |
globalEntries do:[:item | |
|
402 |
theSymbolPtr := item key. |
|
403 |
theValuePtr := item value. |
|
404 |
theSymbolRef := self fetchObjectAt:theSymbolPtr. |
|
405 |
||
406 |
"/ Transcript show:(self printStringOfSymbol:theSymbolRef). |
|
407 |
"/ Transcript show:'->'. |
|
408 |
||
409 |
theValueRef := self fetchObjectAt:theValuePtr. |
|
410 |
"/ Transcript show:(self printStringOfObject:theValueRef). |
|
411 |
"/ Transcript cr. |
|
412 |
||
413 |
item key:theSymbolRef. |
|
414 |
item value:theValueRef. |
|
415 |
]. |
|
416 |
stream position:pos. |
|
1416 | 417 |
! |
418 |
||
419 |
readHeader |
|
420 |
" |
|
421 |
(self for:'stmeas.img') readHeader |
|
422 |
" |
|
423 |
||
424 |
|order magic version timeStamp snapID last_util_addr hiText_addr flags |
|
425 |
lowData hiData charSlots charTableSlots fixMemStart fixMemEnd |
|
426 |
symMemStart symMemEnd vmDataAddr sharedMethodCode sharedBlockCode |
|
427 |
nContexts contextSpace nRegistered symbolsSeqNr nSpaces |
|
1417 | 428 |
classNameSize spaceSize| |
1416 | 429 |
|
430 |
stream next:256. "/ skip execCmd |
|
431 |
||
432 |
msb := false. |
|
433 |
order := stream nextUnsignedLongMSB:msb. |
|
434 |
order = 16r076543210 ifTrue:[ |
|
435 |
] ifFalse:[ |
|
1423 | 436 |
order = 16r10325476 ifTrue:[ |
1416 | 437 |
msb := true. |
438 |
] ifFalse:[ |
|
439 |
self error:'unhandled byteorder' |
|
440 |
]. |
|
441 |
]. |
|
442 |
magic := (stream next:8) asString. |
|
443 |
magic ~= 'ST/X-IMG' ifTrue:[ |
|
444 |
self error:'not an st/x image' |
|
445 |
]. |
|
446 |
version := stream nextUnsignedLongMSB:msb. |
|
447 |
timeStamp := stream nextUnsignedLongMSB:msb. |
|
448 |
ptrSize := stream nextByte. |
|
449 |
ptrSize ~~ 4 ifTrue:[ |
|
450 |
self error:'unhandled ptr format' |
|
451 |
]. |
|
452 |
stream next:7. "/ filler |
|
453 |
intSize := stream nextUnsignedLongMSB:msb. |
|
454 |
intSize == 9 ifTrue:[ |
|
455 |
intSize := 4. |
|
456 |
intTag := 1. |
|
457 |
] ifFalse:[ |
|
458 |
self error:'unhandled int format' |
|
459 |
]. |
|
460 |
||
461 |
snapID := stream nextUnsignedLongMSB:msb. |
|
462 |
last_util_addr := stream next:intSize. |
|
463 |
hiText_addr := stream next:intSize. |
|
464 |
flags := stream next:intSize. |
|
465 |
stream next:8. "/ info, debug & filler |
|
466 |
||
467 |
lowData := stream nextUnsignedLongMSB:msb. |
|
468 |
hiData := stream nextUnsignedLongMSB:msb. |
|
469 |
||
470 |
charSlots := stream nextUnsignedLongMSB:msb. |
|
471 |
charTableSlots := stream nextUnsignedLongMSB:msb. |
|
472 |
||
473 |
version >= 8 ifTrue:[ |
|
474 |
fixMemStart := stream nextUnsignedLongMSB:msb. |
|
475 |
fixMemEnd := stream nextUnsignedLongMSB:msb. |
|
476 |
symMemStart := stream nextUnsignedLongMSB:msb. |
|
477 |
symMemEnd := stream nextUnsignedLongMSB:msb. |
|
478 |
vmDataAddr := stream nextUnsignedLongMSB:msb. |
|
479 |
]. |
|
480 |
stream next:(128 * intSize). "/ skip sharedMethodCode ptrs |
|
481 |
stream next:(128 * intSize). "/ skip sharedBlockCode ptrs |
|
482 |
||
483 |
nContexts := stream nextUnsignedLongMSB:msb. |
|
484 |
contextSpace := stream nextUnsignedLongMSB:msb. |
|
485 |
nRegistered := stream nextUnsignedLongMSB:msb. |
|
486 |
||
487 |
version >= 8 ifTrue:[ |
|
488 |
version >= 9 ifTrue:[ |
|
489 |
symbolsSeqNr := stream nextUnsignedLongMSB:msb. |
|
490 |
stream next:(intSize * 31). |
|
491 |
] ifFalse:[ |
|
492 |
stream next:(intSize * 32). |
|
493 |
] |
|
494 |
]. |
|
495 |
||
496 |
nSpaces := stream nextUnsignedLongMSB:msb. |
|
497 |
spaceInfos := (1 to:nSpaces) collect:[:idx | SpaceInfo new]. |
|
498 |
||
499 |
1 to:nSpaces do:[:i | |
|
500 |
(spaceInfos at:i) flags:(stream nextUnsignedLongMSB:msb). |
|
501 |
]. |
|
502 |
nSpaces+1 to:32 do:[:i | stream nextUnsignedLongMSB:msb]. |
|
503 |
||
504 |
1 to:nSpaces do:[:i | |
|
505 |
(spaceInfos at:i) start:(stream nextUnsignedLongMSB:msb). |
|
506 |
]. |
|
507 |
nSpaces+1 to:32 do:[:i | stream nextUnsignedLongMSB:msb]. |
|
508 |
||
509 |
1 to:nSpaces do:[:i | |
|
510 |
(spaceInfos at:i) size:(stream nextUnsignedLongMSB:msb). |
|
511 |
]. |
|
512 |
nSpaces+1 to:32 do:[:i | stream nextUnsignedLongMSB:msb]. |
|
513 |
||
514 |
version >= 8 ifTrue:[ |
|
1417 | 515 |
stream position:(stream class zeroPosition). |
516 |
stream skip:4096. |
|
1416 | 517 |
]. |
518 |
||
519 |
1 to:nSpaces do:[:i | |
|
520 |
(spaceInfos at:i) end:((spaceInfos at:i) start + (spaceInfos at:i) size - 1). |
|
521 |
]. |
|
522 |
1 to:nSpaces do:[:i | |
|
523 |
(spaceInfos at:i) imageBase:(stream position). |
|
1417 | 524 |
spaceSize := (spaceInfos at:i) size. |
525 |
stream skip:spaceSize. |
|
1416 | 526 |
]. |
527 |
||
528 |
"/ registration |
|
529 |
||
530 |
self readRegistrationEntries. |
|
1417 | 531 |
Transcript showCR:'reading symbols...'. |
1416 | 532 |
self readSymbolEntries. |
1417 | 533 |
self readUGlobalEntries. |
534 |
Transcript showCR:'reading globals...'. |
|
1416 | 535 |
self readGlobalEntries. |
536 |
||
537 |
||
538 |
"/struct basicImageHeader { |
|
539 |
"/ char h_execCmd[256]; |
|
540 |
"/ |
|
541 |
"/ int h_orderWord; |
|
542 |
"/ char h_magic[8]; |
|
543 |
"/ int h_version; |
|
544 |
"/ int h_timeStamp; |
|
545 |
"/ char h_ptrSize; |
|
546 |
"/ char h_filler1[7]; |
|
547 |
"/ int h_intSize; |
|
548 |
"/ int h_snapID; |
|
549 |
"/ INT h_last_util_addr; |
|
550 |
"/ INT h_hiText_addr; |
|
551 |
"/ INT h_flags; |
|
552 |
"/ char h_infoPrinting; |
|
553 |
"/ char h_debugPrinting; |
|
554 |
"/ char h_filler2[6]; |
|
555 |
"/ |
|
556 |
"/ /* |
|
557 |
"/ * these are to verify compatibility of the image with |
|
558 |
"/ * myself ... |
|
559 |
"/ * this is now obsolete. |
|
560 |
"/ */ |
|
561 |
"/ INT h_lowData, h_hiData; |
|
562 |
"/ |
|
563 |
"/ /* |
|
564 |
"/ * base address of character- and characterTable slots |
|
565 |
"/ */ |
|
566 |
"/ INT h_charSlots; |
|
567 |
"/ INT h_charTableSlots; |
|
568 |
"/ |
|
569 |
"/#if HEADER_VERSION >= 8 |
|
570 |
"/ /* |
|
571 |
"/ * the fixBase (VMDATA address) |
|
572 |
"/ */ |
|
573 |
"/ INT h_fixMemStart; |
|
574 |
"/ INT h_fixMemEnd; |
|
575 |
"/ INT h_symMemStart; |
|
576 |
"/ INT h_symMemEnd; |
|
577 |
"/ |
|
578 |
"/ INT h_vmDataAddr; |
|
579 |
"/#endif |
|
580 |
"/ |
|
581 |
"/ INT h_sharedMethodCode[128]; |
|
582 |
"/ INT h_sharedBlockCode[128]; |
|
583 |
"/ |
|
584 |
"/ /* |
|
585 |
"/ * space needed to restore contexts |
|
586 |
"/ */ |
|
587 |
"/ INT h_nContexts; |
|
588 |
"/ INT h_contextSpace; |
|
589 |
"/ |
|
590 |
"/ /* |
|
591 |
"/ * number of class registration info records |
|
592 |
"/ */ |
|
593 |
"/ INT h_nRegistered; |
|
594 |
"/ |
|
595 |
"/#if HEADER_VERSION >= 8 |
|
596 |
"/ /* |
|
597 |
"/ * reserved slots, for future versions |
|
598 |
"/ * (can add additional info, without affecting position of following stuff) |
|
599 |
"/ * If you add slots, you MUST DECREMENT the fillcount. |
|
600 |
"/ */ |
|
601 |
"/# if HEADER_VERSION >= 9 |
|
602 |
"/ INT h_symbolsSeqNr; |
|
603 |
"/ INT h_reserved[31]; |
|
604 |
"/# else |
|
605 |
"/ INT h_reserved[32]; |
|
606 |
"/# endif |
|
607 |
"/#endif |
|
608 |
"/ |
|
609 |
"/ /* |
|
610 |
"/ * number of spaces, base and size of each |
|
611 |
"/ */ |
|
612 |
"/ INT h_nSpaces; |
|
613 |
"/ INT h_spaceFlags[MAXSPACES]; |
|
614 |
"/ INT h_spaceBase[MAXSPACES]; |
|
615 |
"/ INT h_spaceSize[MAXSPACES]; |
|
616 |
"/ |
|
617 |
"/ /* |
|
618 |
"/ * here come nSpaces object spaces |
|
619 |
"/ */ |
|
620 |
"/ |
|
621 |
"/ /* |
|
622 |
"/ * here comes registration info |
|
623 |
"/ */ |
|
624 |
"/ |
|
625 |
"/ /* |
|
626 |
"/ * here come nSymbols symbolEntries |
|
627 |
"/ * followed by a zero/zero entry |
|
628 |
"/ */ |
|
629 |
"/ |
|
630 |
"/ /* |
|
631 |
"/ * here come nGlobal globalEntries |
|
632 |
"/ * followed by a zero/zero entry |
|
633 |
"/ */ |
|
634 |
"/ |
|
635 |
"/ /* |
|
636 |
"/ * here come nUnnamedGlobal globalEntries |
|
637 |
"/ * followed by a zero/zero entry |
|
638 |
"/ */ |
|
639 |
"/ |
|
640 |
"/ /* |
|
641 |
"/ * here come stack contexts |
|
642 |
"/ */ |
|
643 |
"/}; |
|
644 |
! |
|
645 |
||
646 |
readRegistrationEntries |
|
647 |
|classNameSize| |
|
648 |
||
649 |
[ |
|
650 |
classNameSize := stream nextUnsignedLongMSB:msb. |
|
651 |
classNameSize ~~ 0 |
|
652 |
] whileTrue:[ |
|
653 |
|className flags moduleTimestamp signature nMethods nBlocks oldLitRefs nLitRefs |
|
654 |
oldConstTable nConsts| |
|
655 |
||
656 |
className := (stream next:classNameSize) asString. |
|
657 |
stream next. "/ 0-byte |
|
658 |
flags := stream nextUnsignedLongMSB:msb. |
|
659 |
moduleTimestamp := stream nextUnsignedLongMSB:msb. |
|
660 |
signature := stream nextUnsignedLongMSB:msb. |
|
661 |
nMethods := stream nextUnsignedLongMSB:msb. |
|
662 |
nMethods timesRepeat:[ stream nextUnsignedLongMSB:msb ]. |
|
663 |
nBlocks := stream nextUnsignedLongMSB:msb. |
|
664 |
nBlocks timesRepeat:[ stream nextUnsignedLongMSB:msb ]. |
|
665 |
oldLitRefs := stream nextUnsignedLongMSB:msb. |
|
666 |
nLitRefs := stream nextUnsignedLongMSB:msb. |
|
667 |
nLitRefs timesRepeat:[ stream nextUnsignedLongMSB:msb ]. |
|
668 |
stream nextUnsignedLongMSB:msb. "/ 0-litRef |
|
669 |
oldConstTable := stream nextUnsignedLongMSB:msb. |
|
670 |
nConsts := stream nextUnsignedLongMSB:msb. |
|
671 |
nConsts timesRepeat:[ stream nextUnsignedLongMSB:msb ]. |
|
672 |
||
1420 | 673 |
"/ Transcript showCR:className. |
1416 | 674 |
]. |
675 |
! |
|
676 |
||
677 |
readSymbolEntries |
|
1417 | 678 |
|refPointer theSymbolPtr theSymbolRef pos| |
1416 | 679 |
|
680 |
symbolEntries := OrderedCollection new. |
|
681 |
||
682 |
[ |
|
683 |
refPointer := stream nextUnsignedLongMSB:msb. |
|
1417 | 684 |
theSymbolPtr := stream nextUnsignedLongMSB:msb. |
685 |
theSymbolPtr ~~ 0 |
|
1416 | 686 |
] whileTrue:[ |
1417 | 687 |
symbolEntries add:theSymbolPtr. |
1416 | 688 |
]. |
1417 | 689 |
symbolEntries := symbolEntries asArray. |
690 |
||
691 |
pos := stream position. |
|
692 |
symbolEntries := symbolEntries collect:[:theSymbolPtr | |
|
693 |
theSymbolRef := self fetchObjectAt:theSymbolPtr. |
|
694 |
theSymbolRef isImageSymbol ifFalse:[ |
|
695 |
self halt |
|
696 |
]. |
|
697 |
]. |
|
698 |
stream position:pos |
|
1416 | 699 |
! |
700 |
||
701 |
readUGlobalEntries |
|
702 |
|refPointer theValue| |
|
703 |
||
704 |
[ |
|
705 |
refPointer := stream nextUnsignedLongMSB:msb. |
|
706 |
theValue := stream nextUnsignedLongMSB:msb. |
|
707 |
refPointer ~~ 0 |
|
708 |
] whileTrue |
|
709 |
! ! |
|
710 |
||
1417 | 711 |
!SnapShotImageMemory::ImageHeader methodsFor:'accessing'! |
712 |
||
713 |
bits |
|
714 |
"return 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 |
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 |
bits:something |
|
720 |
"set the value of the instance variable 'bits' (automatically generated)" |
|
721 |
||
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
722 |
bits := something. |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
723 |
! |
1417 | 724 |
|
725 |
byteSize |
|
726 |
"return the value of the instance variable 'size' (automatically generated)" |
|
727 |
||
728 |
^ byteSize |
|
729 |
! |
|
730 |
||
731 |
byteSize:something |
|
732 |
"set the value of the instance variable 'size' (automatically generated)" |
|
733 |
||
734 |
something > 8000 ifTrue:[self halt]. |
|
735 |
byteSize := something. |
|
736 |
! |
|
737 |
||
738 |
classRef |
|
739 |
"return 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 |
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 |
classRef:something |
|
745 |
"set the value of the instance variable 'classRef' (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 |
classRef := something. |
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 |
|
751 |
"return 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 |
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 |
memory:something |
|
757 |
"set the value of the instance variable 'memory' (automatically generated)" |
|
758 |
||
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
759 |
memory := something. |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
760 |
! ! |
1417 | 761 |
|
762 |
!SnapShotImageMemory::ImageHeader methodsFor:'queries'! |
|
763 |
||
764 |
category |
|
765 |
|categoryPtr categoryRef category| |
|
766 |
||
767 |
self isMethodOrLazyMethod ifTrue:[ |
|
768 |
categoryPtr := self at:6. |
|
769 |
categoryRef := memory fetchObjectAt:categoryPtr. |
|
770 |
category := memory fetchStringFor:categoryRef. |
|
771 |
^ category |
|
772 |
]. |
|
773 |
self halt. |
|
774 |
! |
|
775 |
||
1419 | 776 |
isBehavior |
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
777 |
^ self isImageBehavior |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
778 |
! |
1419 | 779 |
|
1417 | 780 |
isImageBehavior |
781 |
|flags| |
|
782 |
||
783 |
flags := classRef flags. |
|
784 |
^ flags bitTest:Behavior flagBehavior |
|
785 |
! |
|
786 |
||
787 |
isImageBytes |
|
788 |
|flags| |
|
789 |
||
790 |
flags := classRef flags bitAnd:Behavior maskIndexType. |
|
791 |
^ flags = Behavior flagBytes |
|
792 |
! |
|
793 |
||
794 |
isImageMethod |
|
795 |
|flags| |
|
796 |
||
797 |
flags := classRef flags. |
|
798 |
^ flags bitTest:Behavior flagMethod |
|
799 |
! |
|
800 |
||
801 |
isImageSymbol |
|
802 |
|flags| |
|
803 |
||
804 |
flags := classRef flags. |
|
805 |
^ flags bitTest:Behavior flagSymbol |
|
806 |
! |
|
807 |
||
1420 | 808 |
isJavaMethod |
809 |
|nm| |
|
810 |
||
811 |
nm := classRef name. |
|
812 |
^ (nm = 'JavaMethod' |
|
813 |
or:[ nm = 'JavaMethodWithException' |
|
814 |
or:[ nm = 'JavaMethodWithHandler' |
|
815 |
or:[ nm = 'JavaNativeMethod' ]]]) |
|
816 |
! |
|
817 |
||
1419 | 818 |
isLazyMethod |
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
819 |
^ classRef name = 'LazyMethod' |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
820 |
! |
1419 | 821 |
|
1417 | 822 |
isMeta |
823 |
^ false |
|
824 |
! |
|
825 |
||
826 |
isMethod |
|
1420 | 827 |
|cls| |
828 |
||
829 |
cls := classRef. |
|
830 |
[cls notNil] whileTrue:[ |
|
831 |
cls name = 'Method' ifTrue:[^ true]. |
|
832 |
cls := cls superclass |
|
833 |
]. |
|
834 |
^ false. |
|
1417 | 835 |
! |
836 |
||
837 |
isMethodDictionary |
|
838 |
^ classRef name = 'MethodDictionary' |
|
839 |
! |
|
840 |
||
841 |
isMethodOrLazyMethod |
|
842 |
classRef name = 'LazyMethod' ifTrue:[^ true]. |
|
1420 | 843 |
^ self isMethod |
1417 | 844 |
! |
845 |
||
846 |
isString |
|
847 |
^ classRef name = 'String' |
|
848 |
! ! |
|
849 |
||
1419 | 850 |
!SnapShotImageMemory::ImageObject methodsFor:'method protocol'! |
851 |
||
852 |
byteCode |
|
853 |
|byteCodeSlotOffset byteCodePtr byteCodeRef byteCode| |
|
854 |
||
855 |
self isMethod ifTrue:[ |
|
856 |
byteCodeSlotOffset := Method instVarOffsetOf:'byteCode'. |
|
857 |
]. |
|
858 |
byteCodeSlotOffset notNil ifTrue:[ |
|
859 |
byteCodePtr := self at:byteCodeSlotOffset. |
|
860 |
byteCodeRef := memory fetchObjectAt:byteCodePtr. |
|
861 |
byteCodeRef isNil ifTrue:[^ nil]. |
|
862 |
||
863 |
byteCode := memory fetchByteArrayFor:byteCodeRef. |
|
864 |
^ byteCode |
|
865 |
]. |
|
866 |
||
867 |
self halt. |
|
868 |
! |
|
869 |
||
870 |
comment |
|
871 |
|src comment comments parser| |
|
872 |
||
873 |
self isMethod ifTrue:[ |
|
874 |
src := self source. |
|
875 |
src isNil ifTrue:[^ nil]. |
|
876 |
||
877 |
parser := Parser for:src in:nil. |
|
878 |
parser ignoreErrors; ignoreWarnings; saveComments:true. |
|
879 |
parser parseMethodSpec. |
|
880 |
comments := parser comments. |
|
881 |
comments size ~~ 0 ifTrue:[ |
|
882 |
comment := comments first string. |
|
883 |
(comment withoutSpaces endsWith:'}') ifTrue:[ |
|
884 |
"if first comment is a pragma, take next comment" |
|
885 |
comment := comments at:2 ifAbsent:nil. |
|
886 |
comment notNil ifTrue:[ |
|
887 |
comment := comment string. |
|
888 |
]. |
|
889 |
]. |
|
1417 | 890 |
]. |
1419 | 891 |
^ comment. |
1417 | 892 |
]. |
1419 | 893 |
self isLazyMethod ifTrue:[ |
894 |
^ '' |
|
895 |
]. |
|
896 |
||
897 |
self halt. |
|
1417 | 898 |
! |
1416 | 899 |
|
1419 | 900 |
containingClass |
901 |
self isMethodOrLazyMethod ifTrue:[ |
|
902 |
^ self mclass |
|
1417 | 903 |
]. |
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
904 |
self halt. |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
905 |
! |
1419 | 906 |
|
1469 | 907 |
flags |
908 |
|flagsSlotOffset flagsPtr flags| |
|
909 |
||
910 |
self isMethod ifTrue:[ |
|
911 |
flagsSlotOffset := Method instVarOffsetOf:'flags'. |
|
912 |
]. |
|
913 |
flagsSlotOffset notNil ifTrue:[ |
|
914 |
flagsPtr := self at:flagsSlotOffset. |
|
915 |
flags := memory fetchObjectAt:flagsPtr. |
|
916 |
^ flags |
|
917 |
]. |
|
918 |
||
919 |
self halt. |
|
920 |
! |
|
921 |
||
1419 | 922 |
hasCode |
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
923 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
924 |
! |
1419 | 925 |
|
926 |
isBreakpointed |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
927 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
928 |
! |
1419 | 929 |
|
930 |
isCounting |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
931 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
932 |
! |
1419 | 933 |
|
934 |
isCountingMemoryUsage |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
935 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
936 |
! |
1419 | 937 |
|
938 |
isDynamic |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
939 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
940 |
! |
1419 | 941 |
|
942 |
isExecutable |
|
943 |
self isMethod ifTrue:[ |
|
944 |
^ false |
|
945 |
]. |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
946 |
self halt. |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
947 |
! |
1419 | 948 |
|
949 |
isIgnored |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
950 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
951 |
! |
1419 | 952 |
|
1482 | 953 |
isObsolete |
954 |
^ false |
|
955 |
! |
|
956 |
||
1419 | 957 |
isPrivate |
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
958 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
959 |
! |
1419 | 960 |
|
961 |
isProtected |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
962 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
963 |
! |
1419 | 964 |
|
965 |
isPublic |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
966 |
^ true |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
967 |
! |
1419 | 968 |
|
969 |
isTimed |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
970 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
971 |
! |
1419 | 972 |
|
973 |
isTraced |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
974 |
^ false |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
975 |
! |
1416 | 976 |
|
1417 | 977 |
isWrapped |
978 |
^ false |
|
1416 | 979 |
! |
980 |
||
1419 | 981 |
mclass |
982 |
|mclassSlotOffset mclassPtr mclass| |
|
983 |
||
984 |
self isMethod ifTrue:[ |
|
985 |
mclassSlotOffset := Method instVarOffsetOf:'mclass'. |
|
1420 | 986 |
] ifFalse:[ |
987 |
self isJavaMethod ifTrue:[ |
|
988 |
mclassSlotOffset := JavaMethod instVarOffsetOf:'javaClass'. |
|
989 |
] |
|
990 |
]. |
|
991 |
||
992 |
mclassSlotOffset notNil ifTrue:[ |
|
1419 | 993 |
mclassPtr := self at:mclassSlotOffset. |
994 |
mclassPtr ~~ 0 ifTrue:[ |
|
1420 | 995 |
mclassPtr isInteger ifTrue:[ |
996 |
mclass := memory fetchObjectAt:mclassPtr. |
|
997 |
self at:mclassSlotOffset put:mclass. |
|
998 |
] ifFalse:[ |
|
999 |
mclass := mclassPtr. |
|
1000 |
]. |
|
1419 | 1001 |
mclass isImageBehavior ifFalse:[ |
1002 |
self halt |
|
1003 |
]. |
|
1004 |
^ mclass |
|
1005 |
]. |
|
1006 |
||
1007 |
"/ search my class ... |
|
1008 |
memory image allClassesDo:[:eachClass | |
|
1009 |
eachClass theNonMetaclass methodDictionary keysAndValuesDo:[:sel :mthdRef | |
|
1010 |
mthdRef == self ifTrue:[ |
|
1011 |
self at:mclassSlotOffset put:eachClass theNonMetaclass. |
|
1012 |
^ eachClass theNonMetaclass |
|
1013 |
]. |
|
1014 |
]. |
|
1015 |
eachClass theMetaclass methodDictionary keysAndValuesDo:[:sel :mthdRef | |
|
1016 |
mthdRef == self ifTrue:[ |
|
1017 |
self at:mclassSlotOffset put:eachClass theMetaclass. |
|
1018 |
^ eachClass theMetaclass |
|
1019 |
]. |
|
1020 |
] |
|
1417 | 1021 |
]. |
1419 | 1022 |
self halt. |
1420 | 1023 |
^ nil. |
1417 | 1024 |
]. |
1420 | 1025 |
^ nil. |
1419 | 1026 |
self halt. |
1417 | 1027 |
! |
1028 |
||
1419 | 1029 |
numArgs |
1469 | 1030 |
|flags| |
1031 |
||
1032 |
flags := self flags. |
|
1033 |
^ (flags bitAnd:(Method numArgsMaskInFlags)) bitShift:(Method numArgsShiftInFlags negated) |
|
1419 | 1034 |
! |
1035 |
||
1036 |
package |
|
1037 |
|packageSlotOffset packagePtr packageRef package| |
|
1038 |
||
1039 |
self isImageBehavior ifTrue:[ |
|
1040 |
self isMeta ifTrue:[ |
|
1041 |
^ self theNonMetaclass package |
|
1042 |
]. |
|
1043 |
packageSlotOffset := Class instVarOffsetOf:'package'. |
|
1420 | 1044 |
] ifFalse:[ |
1045 |
self isMethod ifTrue:[ |
|
1046 |
packageSlotOffset := Method instVarOffsetOf:'package'. |
|
1047 |
] ifFalse:[ |
|
1048 |
self isLazyMethod ifTrue:[ |
|
1049 |
packageSlotOffset := Method instVarOffsetOf:'package'. |
|
1050 |
]. |
|
1051 |
]. |
|
1419 | 1052 |
]. |
1053 |
packageSlotOffset notNil ifTrue:[ |
|
1054 |
packagePtr := self at:packageSlotOffset. |
|
1055 |
packageRef := memory fetchObjectAt:packagePtr. |
|
1056 |
packageRef isNil ifTrue:[^ nil]. |
|
1057 |
||
1058 |
packageRef isImageSymbol ifFalse:[ |
|
1420 | 1059 |
packageRef isImageBytes ifFalse:[ |
1060 |
self halt. |
|
1061 |
]. |
|
1062 |
"/ mhmh - can be a string sometimes ... |
|
1419 | 1063 |
]. |
1064 |
package := memory fetchStringFor:packageRef. |
|
1065 |
^ package asSymbol |
|
1066 |
]. |
|
1067 |
self isMeta ifTrue:[ |
|
1068 |
self halt |
|
1069 |
]. |
|
1070 |
||
1420 | 1071 |
^ nil |
1419 | 1072 |
! |
1073 |
||
1074 |
previousVersion |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1075 |
^ nil |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1076 |
! |
1419 | 1077 |
|
1417 | 1078 |
printStringForBrowserWithSelector:selector |
1079 |
^ selector |
|
1080 |
! |
|
1081 |
||
1419 | 1082 |
privacy |
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1083 |
^ #public |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1084 |
! |
1419 | 1085 |
|
1417 | 1086 |
resources |
1087 |
^ nil |
|
1088 |
! |
|
1089 |
||
1090 |
source |
|
1482 | 1091 |
self halt:'unimplemented'. |
1416 | 1092 |
! |
1093 |
||
1419 | 1094 |
sourceFilename |
1095 |
"return the sourcefilename if source is extern; nil otherwise" |
|
1096 |
||
1486 | 1097 |
|sourcePtr sourceRef source| |
1485 | 1098 |
|
1419 | 1099 |
self isMethodOrLazyMethod ifTrue:[ |
1484 | 1100 |
self sourcePosition notNil ifTrue:[ |
1486 | 1101 |
sourcePtr := self at:(Method instVarOffsetOf:'source'). |
1102 |
sourceRef := memory fetchObjectAt:sourcePtr. |
|
1103 |
sourceRef isString ifFalse:[ |
|
1104 |
self halt. |
|
1485 | 1105 |
]. |
1486 | 1106 |
source := memory printStringOfString:sourceRef. |
1485 | 1107 |
^ source. |
1484 | 1108 |
]. |
1419 | 1109 |
^ nil |
1110 |
]. |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1111 |
self halt. |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1112 |
! |
1419 | 1113 |
|
1114 |
sourceLineNumber |
|
1115 |
self isMethodOrLazyMethod ifTrue:[ |
|
1116 |
^ 1 |
|
1117 |
]. |
|
1118 |
self halt. |
|
1119 |
! |
|
1120 |
||
1121 |
sourcePosition |
|
1122 |
|sourcePosition| |
|
1123 |
||
1124 |
self isMethodOrLazyMethod ifTrue:[ |
|
1125 |
sourcePosition := self sourcePositionValue. |
|
1126 |
sourcePosition isNil ifTrue:[^ sourcePosition]. |
|
1127 |
^ sourcePosition abs |
|
1128 |
]. |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1129 |
self halt. |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1130 |
! |
1419 | 1131 |
|
1132 |
sourcePositionValue |
|
1133 |
|sourcePosition sourcePositionPtr| |
|
1134 |
||
1135 |
self isMethodOrLazyMethod ifTrue:[ |
|
1136 |
sourcePositionPtr := self at:(Method instVarOffsetOf:'sourcePosition'). |
|
1137 |
sourcePosition := memory fetchObjectAt:sourcePositionPtr. |
|
1138 |
^ sourcePosition |
|
1139 |
]. |
|
1440
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1140 |
self halt. |
f3eda2f72399
local source string was missing (if cvs access is not avaialable)
Claus Gittinger <cg@exept.de>
parents:
1423
diff
changeset
|
1141 |
! |
1419 | 1142 |
|
1417 | 1143 |
sourceStream |
1144 |
|sourcePosition source aStream fileName junk who |
|
1145 |
myClass mgr className sep dir mod package| |
|
1146 |
||
1147 |
self isMethod ifTrue:[ |
|
1148 |
sourcePosition := self at:(Method instVarOffsetOf:'sourcePosition'). |
|
1149 |
source := self at:(Method instVarOffsetOf:'source'). |
|
1150 |
source := memory fetchObjectAt:source. |
|
1151 |
source isString ifTrue:[ |
|
1152 |
source := memory printStringOfString:source. |
|
1153 |
]. |
|
1154 |
sourcePosition notNil ifTrue:[ |
|
1155 |
sourcePosition := memory fetchObjectAt:sourcePosition. |
|
1156 |
]. |
|
1157 |
||
1158 |
source isNil ifTrue:[^ nil]. |
|
1159 |
sourcePosition isNil ifTrue:[^ source readStream]. |
|
1160 |
||
1161 |
sourcePosition < 0 ifTrue:[ |
|
1162 |
aStream := source asFilename readStream. |
|
1163 |
aStream notNil ifTrue:[ |
|
1164 |
^ aStream |
|
1165 |
]. |
|
1166 |
||
1167 |
fileName := Smalltalk getSourceFileName:source. |
|
1168 |
fileName notNil ifTrue:[ |
|
1169 |
aStream := fileName asFilename readStream. |
|
1170 |
aStream notNil ifTrue:[ |
|
1171 |
^ aStream |
|
1172 |
]. |
|
1173 |
]. |
|
1174 |
]. |
|
1175 |
||
1176 |
"/ |
|
1177 |
"/ if there is no SourceManager, look in local standard places first |
|
1178 |
"/ |
|
1179 |
(mgr := Smalltalk at:#SourceCodeManager) isNil ifTrue:[ |
|
1180 |
aStream := self localSourceStream. |
|
1181 |
aStream notNil ifTrue:[ |
|
1182 |
^ aStream |
|
1183 |
]. |
|
1184 |
]. |
|
1185 |
||
1186 |
"/ |
|
1187 |
"/ nope - ask my class for the source (this also invokes the SCMgr) |
|
1188 |
"/ |
|
1189 |
myClass := self mclass. |
|
1416 | 1190 |
|
1417 | 1191 |
package := self package. |
1192 |
(package notNil and:[package ~= myClass package]) ifTrue:[ |
|
1193 |
mgr notNil ifTrue:[ |
|
1194 |
"/ try to get the source using my package information ... |
|
1195 |
sep := package indexOfAny:'/\:'. |
|
1196 |
sep ~~ 0 ifTrue:[ |
|
1197 |
mod := package copyTo:sep - 1. |
|
1198 |
dir := package copyFrom:sep + 1. |
|
1199 |
aStream := mgr streamForClass:nil fileName:source revision:nil directory:dir module:mod cache:true. |
|
1200 |
aStream notNil ifTrue:[ |
|
1201 |
^ aStream |
|
1202 |
]. |
|
1203 |
]. |
|
1204 |
]. |
|
1205 |
]. |
|
1206 |
||
1207 |
aStream := myClass sourceStreamFor:source. |
|
1208 |
aStream notNil ifTrue:[ |
|
1209 |
^ aStream |
|
1210 |
]. |
|
1211 |
||
1212 |
"/ |
|
1213 |
"/ nope - look in standard places |
|
1214 |
"/ (if there is a source-code manager - otherwise, we already did that) |
|
1215 |
"/ |
|
1216 |
mgr notNil ifTrue:[ |
|
1217 |
aStream := self localSourceStream. |
|
1218 |
aStream notNil ifTrue:[ |
|
1219 |
^ aStream |
|