author | Stefan Vogel <sv@exept.de> |
Mon, 22 Jun 2015 11:33:37 +0200 | |
branch | expecco_2_7_5_branch |
changeset 18499 | b132ac7c9d6a |
parent 17107 | 03c9aab4bbb3 |
child 17342 | 0cbab4ee5dc8 |
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 |
||
14 |
Method variableSubclass:#MethodWithBreakpoints |
|
15 |
instanceVariableNames:'originalMethod' |
|
16603
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
16 |
classVariableNames:'BreakpointedMethods' |
14273 | 17 |
poolDictionaries:'' |
18 |
category:'Kernel-Methods' |
|
19 |
! |
|
20 |
||
21 |
!MethodWithBreakpoints class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 2012 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 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
39 |
support for line-Breakpoints |
|
40 |
||
41 |
instances of me are created when line-breakpoints are placed. |
|
42 |
The only function I serve is to provide the originalMethod information, |
|
43 |
and an easy way to check for having a breakpoint (is breakpointed). |
|
44 |
||
45 |
[author:] |
|
46 |
Claus Gittinger |
|
47 |
||
48 |
[see also:] |
|
49 |
Tools::BreakpointService |
|
50 |
" |
|
51 |
! ! |
|
52 |
||
16603
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
53 |
!MethodWithBreakpoints class methodsFor:'instance creation'! |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
54 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
55 |
new |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
56 |
|newMethod| |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
57 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
58 |
newMethod := super new. |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
59 |
BreakpointedMethods add:newMethod. |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
60 |
^ newMethod |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
61 |
! |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
62 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
63 |
new:numLiterals |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
64 |
|newMethod| |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
65 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
66 |
newMethod := super new:numLiterals. |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
67 |
BreakpointedMethods add:newMethod. |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
68 |
^ newMethod |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
69 |
! ! |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
70 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
71 |
!MethodWithBreakpoints class methodsFor:'class initialization'! |
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 |
initialize |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
74 |
BreakpointedMethods := WeakIdentitySet new. |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
75 |
! ! |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
76 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
77 |
!MethodWithBreakpoints class methodsFor:'misc'! |
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 |
removeAllBreakpoints |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
80 |
"remove all statement breakpoints on any method in the whole system" |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
81 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
82 |
MethodWithBreakpoints allBreakpointedMethods do:[:m | m restoreOriginalMethod] |
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 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
85 |
!MethodWithBreakpoints class methodsFor:'queries'! |
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 |
allBreakpointedMethods |
16790
3d7753eeb111
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16603
diff
changeset
|
88 |
|invalidBreakpoints| |
3d7753eeb111
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16603
diff
changeset
|
89 |
|
16603
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
90 |
BreakpointedMethods isNil ifTrue:[^ #() ]. |
16790
3d7753eeb111
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16603
diff
changeset
|
91 |
invalidBreakpoints := BreakpointedMethods select:[:m | m mclass isNil]. |
17107
03c9aab4bbb3
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16790
diff
changeset
|
92 |
invalidBreakpoints do:[:each | BreakpointedMethods remove:each ifAbsent:nil]. |
16790
3d7753eeb111
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16603
diff
changeset
|
93 |
^ BreakpointedMethods asOrderedCollection |
16603
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
94 |
! ! |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
95 |
|
14273 | 96 |
!MethodWithBreakpoints methodsFor:'accessing'! |
97 |
||
98 |
originalMethod |
|
99 |
^ originalMethod |
|
100 |
! |
|
101 |
||
102 |
originalMethod:something |
|
103 |
originalMethod := something. |
|
104 |
! ! |
|
105 |
||
15928
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
106 |
!MethodWithBreakpoints methodsFor:'enumeration'! |
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
107 |
|
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
108 |
breakpointsDo:aBlock |
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
109 |
self literalsDo:[:lit | |
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
110 |
lit class == Breakpoint ifTrue:[ |
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
111 |
aBlock value:lit |
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
112 |
] |
c73eba7ee86c
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15718
diff
changeset
|
113 |
]. |
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 |
"Created: / 03-02-2014 / 10:34:45 / cg" |
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 |
|
15505
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
118 |
!MethodWithBreakpoints methodsFor:'misc'! |
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
119 |
|
16603
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
120 |
disableAllBreakpoints |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
121 |
"disable all of my breakpoints" |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
122 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
123 |
self breakpointsDo:[:bp | bp disable]. |
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 |
|
15505
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
126 |
restoreOriginalMethod |
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
127 |
"remove myself - i.e. replace by the original method |
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
128 |
(i.e. the one without line breakpoints)" |
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
129 |
|
16413
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
130 |
| cls selector original | |
15505
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
131 |
|
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
132 |
(cls := self mclass) notNil ifTrue:[ |
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
133 |
(selector := self selector) notNil ifTrue:[ |
15718
061ac6f47a57
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15505
diff
changeset
|
134 |
self breakPoint:#cg. |
16603
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
135 |
"/ disable my breakpoints, in case it is currently active |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
136 |
self disableAllBreakpoints. |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
137 |
|
16413
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
138 |
originalMethod notNil ifTrue:[ |
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
139 |
original := originalMethod |
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
140 |
] ifFalse:[ |
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
141 |
original := self programmingLanguage compilerClass |
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
142 |
compile: self source |
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
143 |
in: self mclass |
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
144 |
notifying:nil |
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
145 |
install:false |
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
146 |
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
|
147 |
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
|
148 |
original setCategory: self category . |
16413
74b15e61126e
Fixed MethodWithBreakpoints>>#restoreOriginalMethod
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
15928
diff
changeset
|
149 |
]. |
16603
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
150 |
cls basicAddSelector:selector withMethod:original. |
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
151 |
BreakpointedMethods remove:self ifAbsent:[]. |
15505
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
152 |
] |
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
153 |
] |
15718
061ac6f47a57
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15505
diff
changeset
|
154 |
|
061ac6f47a57
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
15505
diff
changeset
|
155 |
"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
|
156 |
"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
|
157 |
! ! |
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
158 |
|
14273 | 159 |
!MethodWithBreakpoints methodsFor:'queries'! |
160 |
||
161 |
isMethodWithBreakpoints |
|
162 |
^ true |
|
163 |
||
164 |
"Created: / 01-08-2012 / 17:26:59 / cg" |
|
165 |
! ! |
|
166 |
||
167 |
!MethodWithBreakpoints class methodsFor:'documentation'! |
|
168 |
||
169 |
version |
|
17107
03c9aab4bbb3
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16790
diff
changeset
|
170 |
^ '$Header: /cvs/stx/stx/libbasic/MethodWithBreakpoints.st,v 1.9 2014-11-21 19:42:04 cg Exp $' |
14273 | 171 |
! |
172 |
||
173 |
version_CVS |
|
17107
03c9aab4bbb3
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16790
diff
changeset
|
174 |
^ '$Header: /cvs/stx/stx/libbasic/MethodWithBreakpoints.st,v 1.9 2014-11-21 19:42:04 cg Exp $' |
14273 | 175 |
! ! |
15505
4c46f8a71f52
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
14273
diff
changeset
|
176 |
|
16603
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
177 |
|
f416f263fe99
class: MethodWithBreakpoints
Claus Gittinger <cg@exept.de>
parents:
16415
diff
changeset
|
178 |
MethodWithBreakpoints initialize! |