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