24
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
951
|
12 |
"{ Package: 'stx:libbasic3' }"
|
|
13 |
|
120
|
14 |
Object subclass:#CallChain
|
236
|
15 |
instanceVariableNames:'receiver selector class isBlock rest'
|
|
16 |
classVariableNames:''
|
|
17 |
poolDictionaries:''
|
|
18 |
category:'System-Debugging-Support'
|
22
|
19 |
!
|
|
20 |
|
23
|
21 |
!CallChain class methodsFor:'documentation'!
|
|
22 |
|
24
|
23 |
copyright
|
|
24 |
"
|
|
25 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
|
26 |
All Rights Reserved
|
|
27 |
|
|
28 |
This software is furnished under a license and may be used
|
|
29 |
only in accordance with the terms of that license and with the
|
|
30 |
inclusion of the above copyright notice. This software may not
|
|
31 |
be provided or otherwise made available to, or used by, any
|
|
32 |
other person. No title to or ownership of the software is
|
|
33 |
hereby transferred.
|
|
34 |
"
|
88
|
35 |
!
|
|
36 |
|
|
37 |
documentation
|
|
38 |
"
|
|
39 |
This is is used as a companion to MessageTally.
|
|
40 |
Instances of it are used to represent a calling chain.
|
261
|
41 |
They are simply holders for some of the contexts values - no
|
|
42 |
intelligence here.
|
88
|
43 |
(MessageTally could have used the contexts themself, but these
|
|
44 |
may create more overhead)
|
236
|
45 |
|
|
46 |
[author:]
|
|
47 |
Claus Gittinger
|
|
48 |
|
|
49 |
[see also:]
|
261
|
50 |
MessageTally ProfileTree
|
236
|
51 |
MessageTracer
|
|
52 |
AbstractTime
|
88
|
53 |
"
|
23
|
54 |
! !
|
|
55 |
|
2282
|
56 |
!CallChain class methodsFor:'instance creation'!
|
|
57 |
|
|
58 |
callChainTo:aContext stopAtCallerForWhich:aBlock
|
|
59 |
"entered whenever the probed block gets interrupted;
|
|
60 |
generate a chain of callInfo objects to aContext"
|
|
61 |
|
|
62 |
"{ Pragma: +optSpeed }"
|
|
63 |
|
|
64 |
|con chain info atEnd sender home
|
|
65 |
recClass selector mthdClass|
|
|
66 |
|
|
67 |
con := aContext.
|
|
68 |
con isNil ifTrue:[^ nil].
|
|
69 |
|
|
70 |
"/ skip any intermediate contexts
|
|
71 |
[con receiver == Processor] whileTrue:[
|
|
72 |
con := con sender
|
|
73 |
].
|
|
74 |
|
|
75 |
"got it - collect info from contexts"
|
|
76 |
|
|
77 |
"walk up"
|
|
78 |
|
|
79 |
con isNil ifTrue:[^ nil].
|
|
80 |
(aBlock value:con) ifTrue:[^ nil].
|
|
81 |
|
|
82 |
atEnd := false.
|
|
83 |
|
|
84 |
[atEnd] whileFalse:[
|
|
85 |
con isNil ifTrue:[
|
|
86 |
atEnd := true
|
|
87 |
] ifFalse:[
|
|
88 |
sender := con sender.
|
|
89 |
sender isNil ifTrue:[
|
|
90 |
atEnd := true
|
|
91 |
] ifFalse:[
|
|
92 |
(aBlock value:sender) ifTrue:[
|
|
93 |
atEnd := true
|
|
94 |
"/ ] ifFalse:[
|
|
95 |
"/ (sender isBlockContext) ifTrue:[
|
|
96 |
"/ (aBlock value:sender sender) ifTrue:[
|
|
97 |
"/ atEnd := true
|
|
98 |
"/ ]
|
|
99 |
"/ ]
|
|
100 |
]
|
|
101 |
]
|
|
102 |
].
|
|
103 |
atEnd ifFalse:[
|
|
104 |
info := self basicNew.
|
|
105 |
home := con methodHome.
|
|
106 |
|
|
107 |
home isNil ifTrue:[
|
|
108 |
recClass := UndefinedObject.
|
|
109 |
selector := 'optimized'.
|
|
110 |
mthdClass := UndefinedObject.
|
|
111 |
] ifFalse:[
|
|
112 |
recClass := home receiver class.
|
|
113 |
selector := home selector.
|
|
114 |
mthdClass := home methodClass.
|
|
115 |
].
|
|
116 |
|
|
117 |
info
|
|
118 |
receiver:recClass
|
|
119 |
selector:selector
|
|
120 |
class:mthdClass
|
|
121 |
isBlock:(con isBlockContext).
|
|
122 |
info rest:chain.
|
|
123 |
chain := info.
|
|
124 |
con := sender
|
|
125 |
]
|
|
126 |
].
|
|
127 |
|
|
128 |
^ chain
|
|
129 |
|
|
130 |
"Created: / 04-07-2010 / 09:43:27 / cg"
|
|
131 |
! !
|
|
132 |
|
22
|
133 |
!CallChain methodsFor:'accessing'!
|
|
134 |
|
261
|
135 |
isBlock
|
|
136 |
"return true, if this is a callChain for a block-context"
|
|
137 |
|
88
|
138 |
^ isBlock
|
22
|
139 |
|
261
|
140 |
"Modified: 18.5.1996 / 18:52:05 / cg"
|
22
|
141 |
!
|
|
142 |
|
|
143 |
methodClass
|
261
|
144 |
"return the contexts methods class"
|
|
145 |
|
22
|
146 |
^ class
|
261
|
147 |
|
|
148 |
"Modified: 18.5.1996 / 18:54:04 / cg"
|
22
|
149 |
!
|
|
150 |
|
88
|
151 |
receiver
|
261
|
152 |
"return the contexts receiver"
|
|
153 |
|
88
|
154 |
^ receiver
|
261
|
155 |
|
|
156 |
"Modified: 18.5.1996 / 18:54:12 / cg"
|
88
|
157 |
!
|
|
158 |
|
22
|
159 |
receiver:r selector:s class:cls
|
261
|
160 |
"private tally interface - set receiver, selector and class.
|
|
161 |
the block flag is cleared."
|
|
162 |
|
22
|
163 |
receiver := r.
|
|
164 |
selector := s.
|
|
165 |
class := cls.
|
|
166 |
isBlock := false.
|
261
|
167 |
|
|
168 |
"Modified: 18.5.1996 / 18:54:42 / cg"
|
|
169 |
!
|
|
170 |
|
|
171 |
receiver:r selector:s class:cls isBlock:blk
|
|
172 |
"private tally interface - set receiver, selector, class
|
|
173 |
and the block flag."
|
|
174 |
|
|
175 |
receiver := r.
|
|
176 |
selector := s.
|
|
177 |
class := cls.
|
|
178 |
isBlock := blk.
|
|
179 |
|
|
180 |
"Created: 18.5.1996 / 18:52:34 / cg"
|
|
181 |
"Modified: 18.5.1996 / 18:54:58 / cg"
|
22
|
182 |
!
|
|
183 |
|
88
|
184 |
rest
|
261
|
185 |
"return the chains link"
|
|
186 |
|
88
|
187 |
^ rest
|
261
|
188 |
|
|
189 |
"Modified: 18.5.1996 / 18:55:24 / cg"
|
22
|
190 |
!
|
|
191 |
|
88
|
192 |
rest:r
|
261
|
193 |
"set the chains link"
|
|
194 |
|
88
|
195 |
rest := r.
|
261
|
196 |
|
|
197 |
"Modified: 18.5.1996 / 18:55:19 / cg"
|
22
|
198 |
!
|
|
199 |
|
88
|
200 |
selector
|
261
|
201 |
"return the contexts selector"
|
|
202 |
|
88
|
203 |
^ selector
|
261
|
204 |
|
|
205 |
"Modified: 18.5.1996 / 18:55:11 / cg"
|
22
|
206 |
! !
|
|
207 |
|
|
208 |
!CallChain methodsFor:'comparing'!
|
|
209 |
|
|
210 |
= someInfo
|
261
|
211 |
"return true, if the argument chain is for the same method invocation"
|
|
212 |
|
22
|
213 |
receiver == someInfo receiver ifFalse:[^ false].
|
|
214 |
selector == someInfo selector ifFalse:[^ false].
|
|
215 |
^ class == someInfo methodClass
|
261
|
216 |
|
|
217 |
"Modified: 18.5.1996 / 18:55:47 / cg"
|
951
|
218 |
!
|
|
219 |
|
|
220 |
hash
|
|
221 |
"return an integer useful for hashing on the receiver;
|
|
222 |
redefined since = is redefined here."
|
|
223 |
|
|
224 |
^ (receiver hash bitXor:selector hash) bitXor:class hash
|
22
|
225 |
! !
|
88
|
226 |
|
98
|
227 |
!CallChain class methodsFor:'documentation'!
|
|
228 |
|
|
229 |
version
|
2282
|
230 |
^ '$Header: /cvs/stx/stx/libbasic3/CallChain.st,v 1.14 2010-07-04 08:06:27 cg Exp $'
|
|
231 |
!
|
|
232 |
|
|
233 |
version_CVS
|
|
234 |
^ '$Header: /cvs/stx/stx/libbasic3/CallChain.st,v 1.14 2010-07-04 08:06:27 cg Exp $'
|
98
|
235 |
! !
|