author | Claus Gittinger <cg@exept.de> |
Sun, 26 May 2019 11:33:51 +0200 | |
changeset 4421 | 3e423ef3465e |
parent 4392 | 25bfac45b97c |
child 4424 | 426e55dae825 |
permissions | -rw-r--r-- |
2510 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
3129
7b4542cc9a9e
Added support for new breakpoint implementation. Backward compatible.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3128
diff
changeset
|
3 |
All Rights Reserved |
2510 | 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:libcomp' }" |
|
13 |
||
3588 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
2510 | 16 |
Object subclass:#Breakpoint |
3509
96499f5b060d
Removed code for not-yet-finished new breakpoint support.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3491
diff
changeset
|
17 |
instanceVariableNames:'position description line isReached method' |
3149 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'System-Compiler-Debugging' |
|
2510 | 21 |
! |
22 |
||
23 |
!Breakpoint class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
3129
7b4542cc9a9e
Added support for new breakpoint implementation. Backward compatible.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3128
diff
changeset
|
28 |
All Rights Reserved |
2510 | 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 |
" |
|
3347 | 37 |
! |
38 |
||
39 |
documentation |
|
40 |
" |
|
41 |
statement breakpoint support. |
|
42 |
Instances of me are placed into a (bytecode-) compiled method's |
|
4362 | 43 |
literal array and are sent #break messages when a statement |
3347 | 44 |
with a breakpoint is about to be executed. |
4362 | 45 |
The actual control is via the breakpoint's description, |
46 |
which contains further constraints about when the breakpoint should stop and enter the debugger |
|
47 |
(for example: constraints on the reciever, the thread, the count, etc.) |
|
3347 | 48 |
" |
2510 | 49 |
! ! |
50 |
||
51 |
!Breakpoint class methodsFor:'instance creation'! |
|
52 |
||
53 |
new |
|
54 |
"return an initialized instance" |
|
55 |
||
56 |
^ self basicNew initialize. |
|
57 |
! ! |
|
58 |
||
3973 | 59 |
!Breakpoint class methodsFor:'queries'! |
60 |
||
61 |
breakpointDescriptionClass |
|
62 |
"redefinable in subclasses" |
|
63 |
||
64 |
^ BreakpointDescription |
|
65 |
! ! |
|
66 |
||
3354 | 67 |
!Breakpoint class methodsFor:'utilities'! |
68 |
||
69 |
disableAllBreakpoints |
|
3491 | 70 |
MethodWithBreakpoints allBreakpointedMethods do:[:m | |
71 |
m disableAllBreakpoints |
|
3354 | 72 |
] |
73 |
||
74 |
"Created: / 03-02-2014 / 10:35:55 / cg" |
|
75 |
! ! |
|
76 |
||
2510 | 77 |
!Breakpoint methodsFor:'accessing'! |
78 |
||
2551
4470029ad63a
Breakpoint state extracted to BreakpointDescription object
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2545
diff
changeset
|
79 |
description |
4470029ad63a
Breakpoint state extracted to BreakpointDescription object
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2545
diff
changeset
|
80 |
^ description |
2510 | 81 |
! |
82 |
||
2551
4470029ad63a
Breakpoint state extracted to BreakpointDescription object
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2545
diff
changeset
|
83 |
description:aBreakpointDescription |
4470029ad63a
Breakpoint state extracted to BreakpointDescription object
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2545
diff
changeset
|
84 |
description := aBreakpointDescription. |
2510 | 85 |
! |
86 |
||
2541 | 87 |
isReached |
88 |
^ isReached |
|
89 |
! |
|
90 |
||
91 |
isReached:aBoolean |
|
92 |
isReached := aBoolean. |
|
93 |
! |
|
94 |
||
2510 | 95 |
line |
3884 | 96 |
"the lineNr" |
97 |
||
2510 | 98 |
^ line |
99 |
! |
|
100 |
||
3465 | 101 |
line:lineArg |
102 |
self assert:lineArg >= 0. |
|
103 |
line := lineArg. |
|
2510 | 104 |
! |
105 |
||
3588 | 106 |
method:something |
107 |
method := something. |
|
108 |
! |
|
109 |
||
2510 | 110 |
position |
111 |
^ position |
|
112 |
! |
|
113 |
||
2894 | 114 |
position:anInteger |
115 |
position := anInteger. |
|
116 |
||
117 |
"Modified (format): / 02-08-2012 / 09:26:03 / cg" |
|
118 |
! |
|
119 |
||
120 |
position:positionArg line:lineArg |
|
121 |
position := positionArg. |
|
122 |
line := lineArg. |
|
3465 | 123 |
self assert:lineArg >= 0. |
2894 | 124 |
|
125 |
"Created: / 02-08-2012 / 09:26:27 / cg" |
|
2510 | 126 |
! ! |
127 |
||
4362 | 128 |
!Breakpoint methodsFor:'hitting'! |
2795 | 129 |
|
2510 | 130 |
break |
4362 | 131 |
"invoked by the breakPoint's code (see BreakPointNode), |
132 |
which is compiled into the code as: |
|
133 |
pushLit <theBreakpoint> |
|
134 |
send0 #break |
|
135 |
" |
|
2510 | 136 |
|
137 |
<resource: #skipInDebuggersWalkBack> |
|
138 |
||
4201 | 139 |
|sender mthd where lineNr message |
140 |
source sourceLines sourceLine prevLine nextLine| |
|
2795 | 141 |
|
3223 | 142 |
description isEnabled ifFalse:[^ self]. |
2795 | 143 |
sender := thisContext sender. |
4362 | 144 |
(description shouldBreakIn:sender) ifTrue:[ |
4136 | 145 |
message := 'Breakpoint encountered at line %1 in %2'. |
146 |
where := '?'. |
|
147 |
||
3631 | 148 |
mthd := method. |
3683 | 149 |
mthd notNil ifTrue:[ |
150 |
mthd mclass isNil ifTrue:[ |
|
151 |
mthd := sender method. |
|
152 |
]. |
|
4136 | 153 |
where := mthd whoString. |
4082 | 154 |
|
4136 | 155 |
(lineNr := self line) notNil ifTrue:[ |
156 |
(source := mthd source) notNil ifTrue:[ |
|
4201 | 157 |
sourceLines := source asStringCollection. |
158 |
sourceLine := sourceLines at:lineNr ifAbsent:[nil]. |
|
4136 | 159 |
sourceLine notNil ifTrue:[ |
4392 | 160 |
sourceLine := (sourceLine "withoutLeadingSeparators" contractAtEndTo:60) allItalic withColor:Color darkRed. |
4363 | 161 |
message := 'Breakpoint encountered at line %1 in %2\near:\%3'. |
4201 | 162 |
lineNr > 1 ifTrue:[ |
163 |
prevLine := sourceLines at:(lineNr-1) ifAbsent:[nil]. |
|
164 |
prevLine notEmptyOrNil ifTrue:[ |
|
4363 | 165 |
"/ prevLine := prevLine withoutLeadingSeparators. |
4201 | 166 |
prevLine notEmpty ifTrue:[ |
167 |
prevLine := (prevLine contractAtEndTo:60) allItalic. |
|
4363 | 168 |
lineNr > 2 ifTrue:[ |
169 |
prevLine := '...', Character cr , prevLine. |
|
170 |
]. |
|
4201 | 171 |
] ifFalse:[ |
172 |
prevLine := '...'. |
|
173 |
]. |
|
174 |
prevLine := prevLine withColor:Color grey. |
|
4363 | 175 |
message := 'Breakpoint encountered at line %1 in %2\near:\%4\%3'. |
4201 | 176 |
]. |
177 |
]. |
|
178 |
lineNr < (sourceLines size) ifTrue:[ |
|
179 |
nextLine := sourceLines at:(lineNr+1) ifAbsent:[nil]. |
|
180 |
nextLine notEmptyOrNil ifTrue:[ |
|
4363 | 181 |
"/ nextLine := nextLine withoutLeadingSeparators. |
4201 | 182 |
nextLine notEmpty ifTrue:[ |
4363 | 183 |
nextLine := (nextLine contractAtEndTo:60) allItalic. |
184 |
lineNr < (sourceLines size - 1) ifTrue:[ |
|
185 |
nextLine := nextLine , Character cr , '...'. |
|
186 |
]. |
|
4201 | 187 |
] ifFalse:[ |
188 |
nextLine := '...'. |
|
189 |
]. |
|
190 |
nextLine := nextLine withColor:Color grey. |
|
191 |
||
192 |
prevLine notNil ifTrue:[ |
|
4363 | 193 |
message := 'Breakpoint encountered at line %1 in %2\near:\%4\%3\%5'. |
4201 | 194 |
] ifFalse:[ |
4363 | 195 |
message := 'Breakpoint encountered at line %1 in %2\near:\%3\%5'. |
4201 | 196 |
]. |
197 |
]. |
|
198 |
]. |
|
4136 | 199 |
]. |
4082 | 200 |
]. |
201 |
]. |
|
4136 | 202 |
]. |
4298 | 203 |
"/ to disable this breakpoint: |
204 |
"/ description disable. |
|
205 |
||
4363 | 206 |
BreakPointInterrupt basicNew |
207 |
raiseRequestWith:self |
|
4201 | 208 |
errorString:(message withCRs |
209 |
bindWith:self line |
|
210 |
with:where |
|
211 |
with:sourceLine |
|
212 |
with:prevLine |
|
213 |
with:nextLine) |
|
4364 | 214 |
"/ not in sender, because otherwise the debugger won't |
215 |
"/ detect the break on the stack |
|
3490 | 216 |
"/ in:sender. |
2795 | 217 |
]. |
4362 | 218 |
(description shouldTraceIn:sender) ifTrue:[ |
2797 | 219 |
Transcript |
220 |
show:Timestamp now; |
|
4313
e756e66cb104
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
4298
diff
changeset
|
221 |
showCR:(' Trace %1 [%2] args: %3' |
e756e66cb104
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
4298
diff
changeset
|
222 |
bindWith:sender methodPrintString |
e756e66cb104
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
4298
diff
changeset
|
223 |
with:self line |
e756e66cb104
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
4298
diff
changeset
|
224 |
with:sender argsDisplayStringShort) |
2795 | 225 |
]. |
2510 | 226 |
|
227 |
"Created: / 15-06-2011 / 12:48:40 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2551
4470029ad63a
Breakpoint state extracted to BreakpointDescription object
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2545
diff
changeset
|
228 |
"Modified: / 11-07-2011 / 18:17:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4201 | 229 |
"Modified: / 21-10-2017 / 15:24:35 / cg" |
4392 | 230 |
"Modified: / 13-03-2019 / 21:16:22 / Claus Gittinger" |
4362 | 231 |
! ! |
232 |
||
233 |
!Breakpoint methodsFor:'initialization'! |
|
234 |
||
235 |
initialize |
|
236 |
"Invoked when a new instance is created." |
|
237 |
||
238 |
"/ please change as required (and remove this comment) |
|
239 |
"/ method := nil. |
|
240 |
"/ position := nil. |
|
241 |
description := self class breakpointDescriptionClass new. |
|
242 |
"/ line := nil. |
|
243 |
||
244 |
"/ super initialize. -- commented since inherited method does nothing |
|
245 |
||
246 |
"Modified: / 21-08-2014 / 09:35:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
247 |
! ! |
|
248 |
||
249 |
!Breakpoint methodsFor:'printing & storing'! |
|
250 |
||
251 |
printBreakpointNrInDebuggerOn:aStream |
|
252 |
"to be redefined for concrete debuggers" |
|
253 |
! |
|
254 |
||
255 |
printOn:aStream |
|
256 |
"append a printed representation of the receiver to the argument, aStream" |
|
257 |
||
258 |
aStream nextPutAll: 'BPNT '. |
|
4363 | 259 |
aStream nextPutAll:(self isEnabled ifTrue:['(enabled) '] ifFalse:['(disabled) ']). |
4362 | 260 |
self printBreakpointNrInDebuggerOn:aStream. |
261 |
aStream nextPutAll: 'at'. |
|
262 |
(position isNil and:[line isNil]) ifTrue:[ |
|
263 |
aStream nextPutAll: ' ???' |
|
264 |
] ifFalse:[ |
|
265 |
position notNil ifTrue:[ |
|
266 |
aStream |
|
267 |
nextPutAll: ' source position:'; |
|
268 |
nextPutAll: position printString. |
|
269 |
]. |
|
270 |
line notNil ifTrue:[ |
|
271 |
aStream |
|
272 |
nextPutAll: ' line:'; |
|
273 |
nextPutAll: line printString. |
|
274 |
]. |
|
275 |
]. |
|
276 |
||
277 |
"Modified: / 24-04-2013 / 20:42:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
4363 | 278 |
"Modified: / 20-02-2019 / 15:50:37 / Claus Gittinger" |
4362 | 279 |
! ! |
280 |
||
281 |
!Breakpoint methodsFor:'support'! |
|
282 |
||
283 |
beInvisible |
|
284 |
"make this breakpoint hidden (in gutter)" |
|
285 |
||
286 |
description beInvisible |
|
287 |
! |
|
288 |
||
289 |
beTracepoint |
|
290 |
"make this breakpoint a tracepoint" |
|
291 |
||
292 |
description beTracepoint |
|
293 |
||
294 |
"Created: / 27-01-2012 / 13:56:11 / cg" |
|
2510 | 295 |
! |
296 |
||
2968 | 297 |
disable |
298 |
"disable this breakpoint" |
|
299 |
||
3588 | 300 |
"/ if there is currently an ignore on this breakpoint in the debugger, remove it |
4374 | 301 |
Debugger notNil ifTrue:[ |
302 |
DebugView stopIgnoringHaltsFor:method atLineNr:line. |
|
303 |
]. |
|
2968 | 304 |
description disable |
4374 | 305 |
|
306 |
"Modified: / 02-03-2019 / 11:30:45 / Claus Gittinger" |
|
2968 | 307 |
! |
308 |
||
2510 | 309 |
toggle |
2792 | 310 |
"toggle this breakpoint" |
2510 | 311 |
|
3588 | 312 |
"/ if there is currently an ignore on this breakpoint in the debugger, remove it |
4374 | 313 |
Debugger notNil ifTrue:[ |
314 |
Debugger stopIgnoringHaltsFor:method atLineNr:line. |
|
315 |
]. |
|
2551
4470029ad63a
Breakpoint state extracted to BreakpointDescription object
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2545
diff
changeset
|
316 |
description toggle |
2510 | 317 |
|
318 |
"Created: / 17-06-2011 / 13:40:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2551
4470029ad63a
Breakpoint state extracted to BreakpointDescription object
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2545
diff
changeset
|
319 |
"Modified: / 11-07-2011 / 18:18:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2792 | 320 |
"Modified (comment): / 27-01-2012 / 10:41:03 / cg" |
4374 | 321 |
"Modified: / 02-03-2019 / 11:30:31 / Claus Gittinger" |
2795 | 322 |
! |
323 |
||
324 |
toggleTracing |
|
4362 | 325 |
"toggle tracing of this breakpoint" |
2795 | 326 |
|
327 |
description toggleTracing |
|
328 |
||
329 |
"Created: / 27-01-2012 / 13:56:05 / cg" |
|
4362 | 330 |
"Modified (comment): / 20-02-2019 / 10:46:54 / Claus Gittinger" |
2510 | 331 |
! ! |
332 |
||
333 |
!Breakpoint methodsFor:'testing'! |
|
334 |
||
335 |
isEnabled |
|
336 |
||
337 |
"Bad coding here, state should be full object" |
|
338 |
||
2551
4470029ad63a
Breakpoint state extracted to BreakpointDescription object
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2545
diff
changeset
|
339 |
^description isEnabled |
2510 | 340 |
|
341 |
"Created: / 28-06-2011 / 08:27:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3202 | 342 |
! |
343 |
||
4000 | 344 |
isTracepoint |
345 |
^description isTracepoint |
|
346 |
! |
|
347 |
||
3202 | 348 |
isVisible |
349 |
^description isVisible |
|
2510 | 350 |
! ! |
351 |
||
352 |
!Breakpoint class methodsFor:'documentation'! |
|
353 |
||
2554
31516fc84824
#icon moved to stx:libtool
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2551
diff
changeset
|
354 |
version |
3683 | 355 |
^ '$Header$' |
2554
31516fc84824
#icon moved to stx:libtool
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2551
diff
changeset
|
356 |
! |
31516fc84824
#icon moved to stx:libtool
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2551
diff
changeset
|
357 |
|
2510 | 358 |
version_CVS |
3683 | 359 |
^ '$Header$' |
2510 | 360 |
! |
361 |
||
362 |
version_SVN |
|
3196 | 363 |
^ '$ Id $' |
2510 | 364 |
! ! |
3115
3208c8b4661c
Some more support for new breakpoints.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2968
diff
changeset
|
365 |