author | Claus Gittinger <cg@exept.de> |
Thu, 27 Jun 2019 16:34:40 +0200 | |
changeset 24379 | 852be153b0ec |
parent 23741 | 4311c7105e0e |
child 24787 | da4c7b37af78 |
permissions | -rw-r--r-- |
14273 | 1 |
" |
2 |
COPYRIGHT (c) 2012 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 |
" |
|
12 |
"{ Package: 'stx:libbasic' }" |
|
13 |
||
17342
0cbab4ee5dc8
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
17107
diff
changeset
|
14 |
"{ NameSpace: Smalltalk }" |
0cbab4ee5dc8
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
17107
diff
changeset
|
15 |
|
14273 | 16 |
Method variableSubclass:#MethodWithBreakpoints |
17 |
instanceVariableNames:'originalMethod' |
|
16603
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
18 |
classVariableNames:'BreakpointedMethods' |
14273 | 19 |
poolDictionaries:'' |
20 |
category:'Kernel-Methods' |
|
21 |
! |
|
22 |
||
23 |
!MethodWithBreakpoints class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 2012 by Claus Gittinger |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
39 |
documentation |
|
40 |
" |
|
41 |
support for line-Breakpoints |
|
42 |
||
43 |
instances of me are created when line-breakpoints are placed. |
|
44 |
The only function I serve is to provide the originalMethod information, |
|
45 |
and an easy way to check for having a breakpoint (is breakpointed). |
|
46 |
||
47 |
[author:] |
|
48 |
Claus Gittinger |
|
49 |
||
50 |
[see also:] |
|
51 |
Tools::BreakpointService |
|
52 |
" |
|
53 |
! ! |
|
54 |
||
16603
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
55 |
!MethodWithBreakpoints class methodsFor:'instance creation'! |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
56 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
57 |
new |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
58 |
|newMethod| |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
59 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
60 |
newMethod := super new. |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
61 |
BreakpointedMethods add:newMethod. |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
62 |
^ newMethod |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
63 |
! |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
64 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
65 |
new:numLiterals |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
66 |
|newMethod| |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
67 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
68 |
newMethod := super new:numLiterals. |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
69 |
BreakpointedMethods add:newMethod. |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
70 |
^ newMethod |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
71 |
! ! |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
72 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
73 |
!MethodWithBreakpoints class methodsFor:'class initialization'! |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
74 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
75 |
initialize |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
76 |
BreakpointedMethods := WeakIdentitySet new. |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
77 |
! ! |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
78 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
79 |
!MethodWithBreakpoints class methodsFor:'misc'! |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
80 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
81 |
removeAllBreakpoints |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
82 |
"remove all statement breakpoints on any method in the whole system" |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
83 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
84 |
MethodWithBreakpoints allBreakpointedMethods do:[:m | m restoreOriginalMethod] |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
85 |
! ! |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
86 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
87 |
!MethodWithBreakpoints class methodsFor:'queries'! |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
88 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
89 |
allBreakpointedMethods |
16790
3d7753eeb111
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16603
diff
changeset
|
90 |
|invalidBreakpoints| |
3d7753eeb111
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16603
diff
changeset
|
91 |
|
16603
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
92 |
BreakpointedMethods isNil ifTrue:[^ #() ]. |
16790
3d7753eeb111
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16603
diff
changeset
|
93 |
invalidBreakpoints := BreakpointedMethods select:[:m | m mclass isNil]. |
17107
03c9aab4bbb3
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16790
diff
changeset
|
94 |
invalidBreakpoints do:[:each | BreakpointedMethods remove:each ifAbsent:nil]. |
16790
3d7753eeb111
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16603
diff
changeset
|
95 |
^ BreakpointedMethods asOrderedCollection |
16603
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
96 |
! ! |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
97 |
|
14273 | 98 |
!MethodWithBreakpoints methodsFor:'accessing'! |
99 |
||
100 |
originalMethod |
|
101 |
^ originalMethod |
|
102 |
! |
|
103 |
||
104 |
originalMethod:something |
|
105 |
originalMethod := something. |
|
106 |
! ! |
|
107 |
||
15928
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
108 |
!MethodWithBreakpoints methodsFor:'enumeration'! |
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
109 |
|
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
110 |
breakpointsDo:aBlock |
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
111 |
self literalsDo:[:lit | |
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
112 |
lit class == Breakpoint ifTrue:[ |
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
113 |
aBlock value:lit |
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
114 |
] |
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
115 |
]. |
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
116 |
|
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
117 |
"Created: / 03-02-2014 / 10:34:45 / cg" |
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
118 |
! ! |
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
119 |
|
15505
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
120 |
!MethodWithBreakpoints methodsFor:'misc'! |
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
121 |
|
16603
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
122 |
disableAllBreakpoints |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
123 |
"disable all of my breakpoints" |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
124 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
125 |
self breakpointsDo:[:bp | bp disable]. |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
126 |
! |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
127 |
|
19851 | 128 |
disableBreakpointInLine:lineNr |
129 |
"disable one of my breakpoints" |
|
130 |
||
131 |
self breakpointsDo:[:bp | |
|
132 |
bp line == lineNr ifTrue:[ |
|
133 |
bp disable |
|
134 |
]. |
|
135 |
]. |
|
136 |
! |
|
137 |
||
15505
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
138 |
restoreOriginalMethod |
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
139 |
"remove myself - i.e. replace by the original method |
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
140 |
(i.e. the one without line breakpoints)" |
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
141 |
|
16413
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
142 |
| cls selector original | |
15505
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
143 |
|
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
144 |
(cls := self mclass) notNil ifTrue:[ |
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
145 |
(selector := self selector) notNil ifTrue:[ |
15718
061ac6f47a57
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15505
diff
changeset
|
146 |
self breakPoint:#cg. |
16603
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
147 |
"/ disable my breakpoints, in case it is currently active |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
148 |
self disableAllBreakpoints. |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
149 |
|
16413
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
150 |
originalMethod notNil ifTrue:[ |
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
151 |
original := originalMethod |
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
152 |
] ifFalse:[ |
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
153 |
original := self programmingLanguage compilerClass |
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
154 |
compile: self source |
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
155 |
in: self mclass |
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
156 |
notifying:nil |
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
157 |
install:false |
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
158 |
ifFail:[ self error:'Failed to recompile method' ]. |
16415
8edd95b72ac5
Oops, when creating new method for restore, preserve package and category.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16413
diff
changeset
|
159 |
original setPackage: self package. |
8edd95b72ac5
Oops, when creating new method for restore, preserve package and category.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16413
diff
changeset
|
160 |
original setCategory: self category . |
16413
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
161 |
]. |
16603
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
162 |
cls basicAddSelector:selector withMethod:original. |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
163 |
BreakpointedMethods remove:self ifAbsent:[]. |
15505
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
164 |
] |
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
165 |
] |
15718
061ac6f47a57
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15505
diff
changeset
|
166 |
|
061ac6f47a57
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15505
diff
changeset
|
167 |
"Modified: / 29-08-2013 / 01:17:05 / cg" |
16415
8edd95b72ac5
Oops, when creating new method for restore, preserve package and category.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
16413
diff
changeset
|
168 |
"Modified: / 10-05-2014 / 11:03:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
15505
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
169 |
! ! |
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
170 |
|
14273 | 171 |
!MethodWithBreakpoints methodsFor:'queries'! |
172 |
||
17342
0cbab4ee5dc8
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
17107
diff
changeset
|
173 |
hasEnabledBreakpoints |
0cbab4ee5dc8
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
17107
diff
changeset
|
174 |
"true if any of my breakpoints is actually enabled" |
0cbab4ee5dc8
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
17107
diff
changeset
|
175 |
|
0cbab4ee5dc8
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
17107
diff
changeset
|
176 |
self breakpointsDo:[:any | |
20530 | 177 |
any isEnabled ifTrue:[ |
178 |
any isTracepoint ifFalse:[ ^ true]. |
|
179 |
]. |
|
180 |
]. |
|
181 |
^ false. |
|
182 |
! |
|
183 |
||
184 |
hasEnabledTracepoints |
|
185 |
"true if any of my tracepoints is actually enabled" |
|
186 |
||
187 |
self breakpointsDo:[:any | |
|
188 |
any isEnabled ifTrue:[ |
|
189 |
any isTracepoint ifTrue:[ |
|
190 |
^ true |
|
191 |
]. |
|
192 |
]. |
|
17342
0cbab4ee5dc8
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
17107
diff
changeset
|
193 |
]. |
0cbab4ee5dc8
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
17107
diff
changeset
|
194 |
^ false. |
23741 | 195 |
! ! |
196 |
||
197 |
!MethodWithBreakpoints methodsFor:'testing'! |
|
17342
0cbab4ee5dc8
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
17107
diff
changeset
|
198 |
|
14273 | 199 |
isMethodWithBreakpoints |
200 |
^ true |
|
201 |
||
202 |
"Created: / 01-08-2012 / 17:26:59 / cg" |
|
203 |
! ! |
|
204 |
||
205 |
!MethodWithBreakpoints class methodsFor:'documentation'! |
|
206 |
||
207 |
version |
|
19851 | 208 |
^ '$Header$' |
14273 | 209 |
! |
210 |
||
211 |
version_CVS |
|
19851 | 212 |
^ '$Header$' |
14273 | 213 |
! ! |
15505
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
214 |
|
16603
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
215 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
216 |
MethodWithBreakpoints initialize! |