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