author | Claus Gittinger <cg@exept.de> |
Fri, 09 Aug 2019 12:02:21 +0200 | |
changeset 4467 | 4698a67f4800 |
parent 4456 | 698fe54bf9c6 |
child 4539 | e2f831b09a0b |
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 |
||
4456 | 139 |
|sender message| |
2795 | 140 |
|
3223 | 141 |
description isEnabled ifFalse:[^ self]. |
4456 | 142 |
|
2795 | 143 |
sender := thisContext sender. |
4362 | 144 |
(description shouldBreakIn:sender) ifTrue:[ |
4456 | 145 |
message := self breakPointMessageForContext:sender. |
4298 | 146 |
"/ to disable this breakpoint: |
147 |
"/ description disable. |
|
148 |
||
4363 | 149 |
BreakPointInterrupt basicNew |
4456 | 150 |
raiseRequestWith:self |
151 |
errorString:message |
|
4364 | 152 |
"/ not in sender, because otherwise the debugger won't |
153 |
"/ detect the break on the stack |
|
3490 | 154 |
"/ in:sender. |
2795 | 155 |
]. |
4362 | 156 |
(description shouldTraceIn:sender) ifTrue:[ |
4451 | 157 |
sender method numArgs == 0 ifTrue:[ |
4455 | 158 |
Transcript showCR:('%1 Trace: %2 [%3]' |
159 |
bindWith:Timestamp now |
|
160 |
with:sender methodPrintString |
|
4451 | 161 |
with:self line) |
162 |
] ifFalse:[ |
|
4455 | 163 |
Transcript showCR:('%1 Trace: %2 [%3] args: %4' |
164 |
bindWith:Timestamp now |
|
165 |
with:sender methodPrintString |
|
4313
e756e66cb104
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
4298
diff
changeset
|
166 |
with:self line |
e756e66cb104
#UI_ENHANCEMENT by cgexept.de
Claus Gittinger <cg@exept.de>
parents:
4298
diff
changeset
|
167 |
with:sender argsDisplayStringShort) |
4451 | 168 |
]. |
2795 | 169 |
]. |
2510 | 170 |
|
171 |
"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
|
172 |
"Modified: / 11-07-2011 / 18:17:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
4201 | 173 |
"Modified: / 21-10-2017 / 15:24:35 / cg" |
4455 | 174 |
"Modified: / 02-07-2019 / 23:49:17 / Claus Gittinger" |
4456 | 175 |
! |
176 |
||
177 |
breakPointMessageForContext:sender |
|
178 |
|mthd where lineNr message |
|
179 |
source sourceLines sourceLine prevLine nextLine| |
|
180 |
||
181 |
message := 'Breakpoint encountered at line %1 in %2'. |
|
182 |
where := '?'. |
|
183 |
||
184 |
mthd := method. |
|
185 |
mthd notNil ifTrue:[ |
|
186 |
mthd mclass isNil ifTrue:[ |
|
187 |
mthd := sender method. |
|
188 |
]. |
|
189 |
where := mthd whoString. |
|
190 |
||
191 |
(lineNr := self line) notNil ifTrue:[ |
|
192 |
(source := mthd source) notNil ifTrue:[ |
|
193 |
sourceLines := source asStringCollection. |
|
194 |
sourceLine := sourceLines at:lineNr ifAbsent:[nil]. |
|
195 |
sourceLine notNil ifTrue:[ |
|
196 |
sourceLine := (sourceLine "withoutLeadingSeparators" contractAtEndTo:60) allItalic withColor:Color darkRed. |
|
197 |
message := 'Breakpoint encountered at line %1 in %2\near:\%3'. |
|
198 |
lineNr > 1 ifTrue:[ |
|
199 |
prevLine := sourceLines at:(lineNr-1) ifAbsent:[nil]. |
|
200 |
prevLine notEmptyOrNil ifTrue:[ |
|
201 |
"/ prevLine := prevLine withoutLeadingSeparators. |
|
202 |
prevLine notEmpty ifTrue:[ |
|
203 |
prevLine := (prevLine contractAtEndTo:60) allItalic. |
|
204 |
lineNr > 2 ifTrue:[ |
|
205 |
prevLine := '...', Character cr , prevLine. |
|
206 |
]. |
|
207 |
] ifFalse:[ |
|
208 |
prevLine := '...'. |
|
209 |
]. |
|
210 |
prevLine := prevLine withColor:Color grey. |
|
211 |
message := 'Breakpoint encountered at line %1 in %2\near:\%4\%3'. |
|
212 |
]. |
|
213 |
]. |
|
214 |
lineNr < (sourceLines size) ifTrue:[ |
|
215 |
nextLine := sourceLines at:(lineNr+1) ifAbsent:[nil]. |
|
216 |
nextLine notEmptyOrNil ifTrue:[ |
|
217 |
"/ nextLine := nextLine withoutLeadingSeparators. |
|
218 |
nextLine notEmpty ifTrue:[ |
|
219 |
nextLine := (nextLine contractAtEndTo:60) allItalic. |
|
220 |
lineNr < (sourceLines size - 1) ifTrue:[ |
|
221 |
nextLine := nextLine , Character cr , '...'. |
|
222 |
]. |
|
223 |
] ifFalse:[ |
|
224 |
nextLine := '...'. |
|
225 |
]. |
|
226 |
nextLine := nextLine withColor:Color grey. |
|
227 |
||
228 |
prevLine notNil ifTrue:[ |
|
229 |
message := 'Breakpoint encountered at line %1 in %2\near:\%4\%3\%5'. |
|
230 |
] ifFalse:[ |
|
231 |
message := 'Breakpoint encountered at line %1 in %2\near:\%3\%5'. |
|
232 |
]. |
|
233 |
]. |
|
234 |
]. |
|
235 |
]. |
|
236 |
]. |
|
237 |
]. |
|
238 |
]. |
|
239 |
^ (message withCRs |
|
240 |
bindWith:self line |
|
241 |
with:where |
|
242 |
with:sourceLine |
|
243 |
with:prevLine |
|
244 |
with:nextLine) |
|
4362 | 245 |
! ! |
246 |
||
247 |
!Breakpoint methodsFor:'initialization'! |
|
248 |
||
249 |
initialize |
|
250 |
"Invoked when a new instance is created." |
|
251 |
||
252 |
"/ please change as required (and remove this comment) |
|
253 |
"/ method := nil. |
|
254 |
"/ position := nil. |
|
255 |
description := self class breakpointDescriptionClass new. |
|
256 |
"/ line := nil. |
|
257 |
||
258 |
"/ super initialize. -- commented since inherited method does nothing |
|
259 |
||
260 |
"Modified: / 21-08-2014 / 09:35:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
261 |
! ! |
|
262 |
||
263 |
!Breakpoint methodsFor:'printing & storing'! |
|
264 |
||
4424 | 265 |
inspectorValueStringInListFor:anInspector |
266 |
"returns a string to be shown in the inspector's list" |
|
267 |
||
268 |
^ self printString |
|
269 |
||
270 |
"Created: / 29-05-2019 / 15:14:52 / Claus Gittinger" |
|
271 |
! |
|
272 |
||
4362 | 273 |
printBreakpointNrInDebuggerOn:aStream |
4424 | 274 |
"to be redefined for concrete debuggers |
275 |
(some require a bpnt to be registered and use a handle or id to refer to them)" |
|
276 |
||
277 |
"Modified (comment): / 29-05-2019 / 15:11:55 / Claus Gittinger" |
|
4362 | 278 |
! |
279 |
||
280 |
printOn:aStream |
|
281 |
"append a printed representation of the receiver to the argument, aStream" |
|
282 |
||
4424 | 283 |
|info| |
284 |
||
285 |
aStream nextPutAll: 'BPNT'. |
|
4362 | 286 |
self printBreakpointNrInDebuggerOn:aStream. |
4424 | 287 |
aStream nextPutAll: ' at'. |
288 |
self printPositionOrLineNumberOn:aStream. |
|
289 |
self isEnabled ifTrue:[ |
|
290 |
description condition notNil |
|
291 |
ifTrue:[info := ' (conditional)'] |
|
292 |
ifFalse:[info := ' (enabled)'] |
|
293 |
] ifFalse:[ |
|
294 |
info :=' (disabled)' |
|
295 |
]. |
|
296 |
aStream nextPutAll:info |
|
297 |
||
298 |
"Modified: / 24-04-2013 / 20:42:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
299 |
"Modified: / 29-05-2019 / 15:21:36 / Claus Gittinger" |
|
300 |
! |
|
301 |
||
302 |
printPositionOrLineNumberOn:aStream |
|
4362 | 303 |
(position isNil and:[line isNil]) ifTrue:[ |
304 |
aStream nextPutAll: ' ???' |
|
305 |
] ifFalse:[ |
|
306 |
position notNil ifTrue:[ |
|
307 |
aStream |
|
4424 | 308 |
nextPutAll: ' position:'; |
309 |
print: position. |
|
4362 | 310 |
]. |
311 |
line notNil ifTrue:[ |
|
312 |
aStream |
|
313 |
nextPutAll: ' line:'; |
|
4424 | 314 |
print: line. |
4362 | 315 |
]. |
316 |
]. |
|
317 |
||
4424 | 318 |
"Created: / 29-05-2019 / 15:13:42 / Claus Gittinger" |
4362 | 319 |
! ! |
320 |
||
321 |
!Breakpoint methodsFor:'support'! |
|
322 |
||
323 |
beInvisible |
|
324 |
"make this breakpoint hidden (in gutter)" |
|
325 |
||
326 |
description beInvisible |
|
327 |
! |
|
328 |
||
329 |
beTracepoint |
|
330 |
"make this breakpoint a tracepoint" |
|
331 |
||
332 |
description beTracepoint |
|
333 |
||
334 |
"Created: / 27-01-2012 / 13:56:11 / cg" |
|
2510 | 335 |
! |
336 |
||
2968 | 337 |
disable |
338 |
"disable this breakpoint" |
|
339 |
||
3588 | 340 |
"/ if there is currently an ignore on this breakpoint in the debugger, remove it |
4374 | 341 |
Debugger notNil ifTrue:[ |
342 |
DebugView stopIgnoringHaltsFor:method atLineNr:line. |
|
343 |
]. |
|
2968 | 344 |
description disable |
4374 | 345 |
|
346 |
"Modified: / 02-03-2019 / 11:30:45 / Claus Gittinger" |
|
2968 | 347 |
! |
348 |
||
2510 | 349 |
toggle |
2792 | 350 |
"toggle this breakpoint" |
2510 | 351 |
|
3588 | 352 |
"/ if there is currently an ignore on this breakpoint in the debugger, remove it |
4374 | 353 |
Debugger notNil ifTrue:[ |
354 |
Debugger stopIgnoringHaltsFor:method atLineNr:line. |
|
355 |
]. |
|
2551
4470029ad63a
Breakpoint state extracted to BreakpointDescription object
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2545
diff
changeset
|
356 |
description toggle |
2510 | 357 |
|
358 |
"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
|
359 |
"Modified: / 11-07-2011 / 18:18:10 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2792 | 360 |
"Modified (comment): / 27-01-2012 / 10:41:03 / cg" |
4374 | 361 |
"Modified: / 02-03-2019 / 11:30:31 / Claus Gittinger" |
2795 | 362 |
! |
363 |
||
364 |
toggleTracing |
|
4362 | 365 |
"toggle tracing of this breakpoint" |
2795 | 366 |
|
367 |
description toggleTracing |
|
368 |
||
369 |
"Created: / 27-01-2012 / 13:56:05 / cg" |
|
4362 | 370 |
"Modified (comment): / 20-02-2019 / 10:46:54 / Claus Gittinger" |
2510 | 371 |
! ! |
372 |
||
373 |
!Breakpoint methodsFor:'testing'! |
|
374 |
||
375 |
isEnabled |
|
376 |
||
377 |
"Bad coding here, state should be full object" |
|
378 |
||
2551
4470029ad63a
Breakpoint state extracted to BreakpointDescription object
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2545
diff
changeset
|
379 |
^description isEnabled |
2510 | 380 |
|
381 |
"Created: / 28-06-2011 / 08:27:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
3202 | 382 |
! |
383 |
||
4000 | 384 |
isTracepoint |
385 |
^description isTracepoint |
|
386 |
! |
|
387 |
||
3202 | 388 |
isVisible |
389 |
^description isVisible |
|
2510 | 390 |
! ! |
391 |
||
392 |
!Breakpoint class methodsFor:'documentation'! |
|
393 |
||
2554
31516fc84824
#icon moved to stx:libtool
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2551
diff
changeset
|
394 |
version |
3683 | 395 |
^ '$Header$' |
2554
31516fc84824
#icon moved to stx:libtool
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2551
diff
changeset
|
396 |
! |
31516fc84824
#icon moved to stx:libtool
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2551
diff
changeset
|
397 |
|
2510 | 398 |
version_CVS |
3683 | 399 |
^ '$Header$' |
2510 | 400 |
! |
401 |
||
402 |
version_SVN |
|
3196 | 403 |
^ '$ Id $' |
2510 | 404 |
! ! |
3115
3208c8b4661c
Some more support for new breakpoints.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2968
diff
changeset
|
405 |