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