author | Claus Gittinger <cg@exept.de> |
Sun, 10 Dec 1995 16:17:04 +0100 | |
changeset 269 | 6a0af2256d0b |
parent 266 | 8645fbd8fdb7 |
child 299 | 92dba0245282 |
permissions | -rw-r--r-- |
0 | 1 |
" |
4 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
45 | 3 |
All Rights Reserved |
0 | 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 |
||
13 |
StandardSystemView subclass:#DebugView |
|
73 | 14 |
instanceVariableNames:'busy haveControl exitAction canContinue contextView codeView |
266 | 15 |
receiverInspector contextInspector contextArray selectedContext |
16 |
catchBlock grabber traceView tracing bigStep skipLineNr |
|
17 |
steppedContextAddress canAbort abortButton terminateButton |
|
18 |
continueButton stepButton nextButton sendButton returnButton |
|
19 |
restartButton exclusive inspecting nChainShown inspectedProcess |
|
20 |
updateProcess stopButton updateButton monitorToggle stepping |
|
21 |
steppedContextLineno actualContext inWrap' |
|
73 | 22 |
classVariableNames:'CachedDebugger CachedExclusive OpenDebuggers MoreDebuggingDetail' |
23 |
poolDictionaries:'' |
|
24 |
category:'Interface-Debugger' |
|
0 | 25 |
! |
26 |
||
29 | 27 |
!DebugView class methodsFor:'documentation'! |
28 |
||
29 |
copyright |
|
30 |
" |
|
31 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
45 | 32 |
All Rights Reserved |
29 | 33 |
|
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
! |
|
0 | 42 |
|
29 | 43 |
documentation |
44 |
" |
|
45 |
this class implements a graphical debugger interface. |
|
46 |
The debugger usually sits on top of the faulting process, |
|
47 |
taking over its event processing. Thus only the 'stopped' process is affected; |
|
48 |
other processes continue to respond to events. |
|
49 |
||
50 |
The one exception is when an error occurs within the dispatcher process |
|
51 |
or in one of the eventhandler processes - in this case, the debugger |
|
52 |
will sit on an exclusive display connection. |
|
53 |
||
54 |
The whole debugging will be changed, once the required process primitives |
|
55 |
are available, which allow control of another processes execution |
|
56 |
(i.e. single-step, restart & return). The setup will be changed then, |
|
57 |
to have the debugger control the debuggee (i.e. two processes) |
|
35 | 58 |
|
59 |
See additional information in 'doc/misc/debugger.doc'. |
|
53 | 60 |
|
61 |
Notice: the DebugView class caches the last used debugger in a class |
|
62 |
variable. It may happen, that a malfunctioning debugger (for example, |
|
63 |
a halfway destoyed one) is kept there. You will notice this, if a |
|
64 |
debugger comes up without showing any contents. In this case, close |
|
65 |
(or destroy) the broken debugView, and execute |
|
66 |
Debugger newDebugger |
|
67 |
which removes the cached debugger and forces creation of a new one the |
|
68 |
next time. This is a temporary workaround - the debugger will be fixed to |
|
69 |
avoid this problem. |
|
29 | 70 |
" |
71 |
! ! |
|
0 | 72 |
|
243 | 73 |
!DebugView class methodsFor:'initialization'! |
74 |
||
75 |
reinitialize |
|
76 |
self newDebugger |
|
77 |
! ! |
|
78 |
||
0 | 79 |
!DebugView class methodsFor:'instance creation'! |
80 |
||
266 | 81 |
enter |
82 |
"another way of entering the debugger" |
|
73 | 83 |
|
266 | 84 |
^ self enter:(thisContext sender) withMessage:'Debugger' |
73 | 85 |
|
266 | 86 |
"Debugger enter" |
73 | 87 |
! |
88 |
||
266 | 89 |
enter:aContext |
90 |
"enter the debugger on aContext" |
|
29 | 91 |
|
266 | 92 |
^ self enter:aContext withMessage:'Debugger' |
0 | 93 |
! |
94 |
||
29 | 95 |
enter:aContext withMessage:aString |
53 | 96 |
"enter a debugger; if this is a recursive invocation, enter |
97 |
a MiniDebugger instead. |
|
98 |
This is the standard way of entering the debugger; |
|
99 |
sent from error- and halt messages." |
|
0 | 100 |
|
93 | 101 |
|active| |
102 |
||
57 | 103 |
StepInterruptPending := nil. |
104 |
||
62 | 105 |
thisContext isRecursive ifTrue:[ |
93 | 106 |
^ MiniDebugger enterWithMessage:'recursive error in debugger'. |
62 | 107 |
]. |
108 |
||
57 | 109 |
" |
110 |
well, it could be a stepping or sending debugger up there; |
|
111 |
in this case, return to it. This happens, when a stepping process |
|
112 |
runs into an error (for example, a halt). In this case, we want the |
|
113 |
stepping debugger to come up again instead of a new one. |
|
114 |
" |
|
115 |
OpenDebuggers notNil ifTrue:[ |
|
93 | 116 |
active := Processor activeProcess. |
57 | 117 |
OpenDebuggers do:[:aDebugger | |
118 |
aDebugger notNil ifTrue:[ |
|
93 | 119 |
(aDebugger inspectedProcess == active) ifTrue:[ |
57 | 120 |
"/ 'entering stepping debugger again' printNL. |
121 |
aDebugger unstep. |
|
93 | 122 |
aDebugger setLabelFor:aString in:active. |
57 | 123 |
^ aDebugger enter:aContext. |
124 |
] |
|
125 |
] |
|
126 |
] |
|
127 |
]. |
|
128 |
||
53 | 129 |
^ self enterUnconditional:aContext withMessage:aString |
130 |
! |
|
131 |
||
266 | 132 |
enterUnconditional:aContext withMessage:aString |
133 |
"enter a debugger - do not check for recursive invocation" |
|
134 |
||
135 |
|aDebugger| |
|
136 |
||
137 |
StepInterruptPending := nil. |
|
138 |
aDebugger := self new. |
|
139 |
aDebugger setLabelFor:aString in:Processor activeProcess. |
|
140 |
aDebugger enter:aContext. |
|
141 |
^ nil |
|
142 |
||
143 |
"nil halt" |
|
144 |
! |
|
145 |
||
146 |
enterWithMessage:aString |
|
147 |
"the standard way of entering the debugger - sent from Objects |
|
148 |
error- and halt messages" |
|
149 |
||
150 |
^ self enter:(thisContext sender) withMessage:aString |
|
151 |
||
152 |
"Debugger enterWithMessage:'hi there'" |
|
153 |
! |
|
154 |
||
155 |
lowSpaceCleanup |
|
156 |
"in low memory situations, give up cached debuggers" |
|
157 |
||
158 |
self newDebugger |
|
159 |
! |
|
160 |
||
161 |
new |
|
162 |
"return a new DebugView - return a cached debugger if it already |
|
163 |
exists" |
|
53 | 164 |
|
73 | 165 |
|debugger| |
14 | 166 |
|
266 | 167 |
" |
168 |
need a blocking debugger if no processes or |
|
169 |
or if its a timing/interrupt process |
|
170 |
(because otherwise we would not get any events here ... |
|
171 |
" |
|
172 |
Processor activeProcessIsSystemProcess ifTrue:[ |
|
173 |
CachedExclusive isNil ifTrue:[ |
|
174 |
debugger := self newExclusive |
|
175 |
] ifFalse:[ |
|
176 |
debugger := CachedExclusive. |
|
177 |
CachedExclusive := nil. |
|
178 |
]. |
|
179 |
] ifFalse:[ |
|
180 |
CachedDebugger isNil ifTrue:[ |
|
181 |
debugger := super new. |
|
182 |
debugger label:'Debugger'. |
|
183 |
debugger icon:(Form fromFile:'Debugger.xbm' resolution:100). |
|
184 |
] ifFalse:[ |
|
185 |
debugger := CachedDebugger. |
|
186 |
CachedDebugger := nil. |
|
187 |
] |
|
188 |
]. |
|
73 | 189 |
^ debugger |
190 |
! |
|
0 | 191 |
|
73 | 192 |
newDebugger |
193 |
"force creation of a new debugger" |
|
194 |
||
195 |
CachedDebugger := nil. |
|
196 |
CachedExclusive := nil. |
|
197 |
OpenDebuggers := nil. |
|
198 |
||
199 |
" |
|
200 |
DebugView newDebugger |
|
201 |
" |
|
0 | 202 |
! |
203 |
||
266 | 204 |
newExclusive |
205 |
"return a debugger for exclusive display access" |
|
206 |
||
207 |
|debugger| |
|
105 | 208 |
|
266 | 209 |
debugger := super new. |
210 |
debugger label:'Debugger'. |
|
211 |
debugger icon:(Form fromFile:'Debugger.xbm' resolution:100). |
|
212 |
debugger exclusive:true. |
|
213 |
^ debugger |
|
105 | 214 |
! |
215 |
||
29 | 216 |
openOn:aProcess |
217 |
"start a debugger on aProcess |
|
218 |
(actually not more than a good-looking inspector)" |
|
15 | 219 |
|
52 | 220 |
|aDebugger label nm| |
15 | 221 |
|
222 |
aDebugger := super new. |
|
223 |
aDebugger icon:(Form fromFile:'Debugger.xbm' resolution:100). |
|
29 | 224 |
aProcess notNil ifTrue:[ |
52 | 225 |
nm := aProcess name. |
226 |
nm notNil ifTrue:[ |
|
61 | 227 |
nm := (nm contractTo:17) , '-' , aProcess id printString |
52 | 228 |
] ifFalse:[ |
229 |
nm := aProcess id printString |
|
230 |
]. |
|
231 |
label := 'Debugger [' , nm , ']'. |
|
29 | 232 |
] ifFalse:[ |
45 | 233 |
label := 'no process' |
29 | 234 |
]. |
235 |
aDebugger label:label. |
|
15 | 236 |
aDebugger iconLabel:'Debugger'. |
237 |
aDebugger openOn:aProcess. |
|
238 |
^ nil |
|
126 | 239 |
! ! |
240 |
||
73 | 241 |
!DebugView methodsFor:'basic'! |
242 |
||
266 | 243 |
enter |
244 |
"enter the debugger - on the sending context" |
|
245 |
||
246 |
|where| |
|
247 |
||
248 |
busy := true. |
|
249 |
||
250 |
where := thisContext. "enter" |
|
251 |
where := where sender. "the calling context" |
|
252 |
where notNil ifTrue:[ |
|
253 |
(where receiver == DebugView) ifTrue:[ |
|
254 |
where := where sender |
|
255 |
] |
|
256 |
"where is now interrupted methods context" |
|
257 |
]. |
|
258 |
^ self enter:where |
|
259 |
! |
|
260 |
||
73 | 261 |
enter:aContext |
262 |
"enter the debugger - get and display the context, then start an |
|
263 |
exclusive event loop on top of eveything else" |
|
264 |
||
265 |
|con selection m idx retval s| |
|
266 |
||
267 |
busy := true. |
|
268 |
inspecting := false. |
|
269 |
inspectedProcess := Processor activeProcess. |
|
270 |
stepping := false. |
|
271 |
bigStep := false. |
|
272 |
nChainShown := 50. |
|
273 |
||
274 |
"if debugger is entered while a box has grabbed the |
|
275 |
pointer, we must ungrab - otherwise X wont talk to |
|
276 |
us here |
|
277 |
" |
|
278 |
(grabber := device activePointerGrab) notNil ifTrue:[ |
|
75 | 279 |
device ungrabPointer |
73 | 280 |
]. |
281 |
||
282 |
terminateButton enable. |
|
283 |
||
284 |
drawableId notNil ifTrue:[ |
|
75 | 285 |
"not the first time - realize at old position" |
286 |
terminateButton turnOffWithoutRedraw. |
|
287 |
continueButton turnOffWithoutRedraw. |
|
288 |
returnButton turnOffWithoutRedraw. |
|
289 |
restartButton turnOffWithoutRedraw. |
|
290 |
abortButton turnOffWithoutRedraw. |
|
78 | 291 |
nextButton turnOffWithoutRedraw. |
75 | 292 |
stepButton turnOffWithoutRedraw. |
293 |
sendButton turnOffWithoutRedraw. |
|
73 | 294 |
] ifFalse:[ |
132 | 295 |
self iconLabel:'Debugger'. |
296 |
]. |
|
297 |
||
210
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
298 |
windowGroup isNil ifTrue:[ |
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
299 |
windowGroup := WindowGroup new. |
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
300 |
windowGroup addTopView:self. |
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
301 |
]. |
132 | 302 |
exclusive ifFalse:[ |
303 |
"/ create a (modal) windowGroup for myself |
|
304 |
||
305 |
windowGroup setModal:true. |
|
210
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
306 |
] ifTrue:[ |
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
307 |
"/ create a windowGroup with a synchronous sensor for me |
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
308 |
|
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
309 |
windowGroup sensor:(SynchronousWindowSensor new device:device). |
73 | 310 |
]. |
210
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
311 |
windowGroup setProcess:Processor activeProcess. |
73 | 312 |
|
313 |
" |
|
314 |
get the walkback list |
|
315 |
" |
|
316 |
self setContext:aContext. |
|
317 |
||
318 |
" |
|
319 |
and find the one context to show initially |
|
320 |
- if we came here by a send (single step), its the top context; |
|
321 |
- if we came here by a step (i.e. bigStep), its the top context |
|
322 |
(for ifs and whiles) or the sender (for regular sends). |
|
323 |
- otherwise, we came here by some signal raise, and we are interrested |
|
324 |
in the context where the raise actually occured. |
|
325 |
" |
|
326 |
exitAction == #step ifTrue:[ |
|
75 | 327 |
selection := 1. |
328 |
steppedContextAddress notNil ifTrue:[ |
|
329 |
" |
|
330 |
if we came here by a big-step, show the method where we are |
|
331 |
" |
|
332 |
(ObjectMemory addressOf:aContext) == steppedContextAddress ifTrue:[ |
|
333 |
selection := 1 |
|
334 |
] ifFalse:[ |
|
335 |
(ObjectMemory addressOf:aContext sender) == steppedContextAddress ifTrue:[ |
|
336 |
selection := 2 |
|
337 |
] |
|
338 |
]. |
|
339 |
" |
|
340 |
for bigStep, we could also be in a block below the actual method ... |
|
341 |
" |
|
342 |
(aContext home notNil and:[ |
|
343 |
(ObjectMemory addressOf:aContext home) == steppedContextAddress]) ifTrue:[ |
|
344 |
selection := 1 |
|
345 |
] ifFalse:[ |
|
346 |
(aContext sender home notNil and:[ |
|
347 |
(ObjectMemory addressOf:aContext sender home) == steppedContextAddress]) ifTrue:[ |
|
348 |
selection := 2 |
|
349 |
] |
|
350 |
]. |
|
351 |
] |
|
73 | 352 |
] ifFalse:[ |
75 | 353 |
steppedContextAddress isNil ifTrue:[ |
354 |
" |
|
355 |
preselect a more interresting context, (where halt/raise was ...) |
|
356 |
" |
|
357 |
selection := self interrestingContextFrom:aContext. |
|
358 |
] ifFalse:[ |
|
359 |
" |
|
360 |
if we came here by a big-step, show the method where we are |
|
361 |
" |
|
362 |
(ObjectMemory addressOf:aContext) == steppedContextAddress ifTrue:[ |
|
363 |
selection := 1 |
|
364 |
] ifFalse:[ |
|
365 |
(ObjectMemory addressOf:aContext sender) == steppedContextAddress ifTrue:[ |
|
366 |
selection := 2 |
|
367 |
] |
|
368 |
] |
|
369 |
] |
|
73 | 370 |
]. |
371 |
||
372 |
selection notNil ifTrue:[ |
|
75 | 373 |
self showSelection:selection. |
374 |
contextView selection:selection. |
|
375 |
selection > 1 ifTrue:[ |
|
376 |
contextView scrollToLine:(selection - 1) |
|
377 |
] |
|
73 | 378 |
]. |
379 |
||
380 |
m := contextView middleButtonMenu. |
|
381 |
m notNil ifTrue:[ |
|
75 | 382 |
canAbort := inspecting or:[Object abortSignal isHandled]. |
383 |
canAbort ifTrue:[ |
|
384 |
abortButton enable. |
|
385 |
m enable:#doAbort. |
|
386 |
] ifFalse:[ |
|
387 |
abortButton disable. |
|
388 |
m disable:#doAbort. |
|
389 |
]. |
|
390 |
exclusive ifTrue:[ |
|
391 |
terminateButton disable. |
|
392 |
m disable:#doTerminate. |
|
393 |
] ifFalse:[ |
|
394 |
terminateButton enable. |
|
395 |
m enable:#doTerminate. |
|
396 |
] |
|
73 | 397 |
]. |
398 |
||
399 |
" |
|
400 |
drawableId is nil, if this is a new debugger. Then do a realize. |
|
401 |
Otherwise, its probably better to do a rerealize, which shows the |
|
402 |
view at the previous position, without a need for the user to set the |
|
403 |
position again |
|
404 |
" |
|
405 |
drawableId notNil ifTrue:[ |
|
75 | 406 |
self rerealize |
73 | 407 |
] ifFalse:[ |
75 | 408 |
self realize. |
73 | 409 |
]. |
410 |
||
210
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
411 |
exclusive ifTrue:[ |
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
412 |
self showError:' |
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
413 |
Debugging system process `' , (inspectedProcess nameOrId) printString , '''. |
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
414 |
|
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
415 |
This is a modal debugger - all event processing is stopped.. |
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
416 |
Therefore, you cannot interact with other views or |
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
417 |
open any other tools while this debugger is active. |
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
418 |
|
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
419 |
Also, there is no event processing (redraw) for other views.' |
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
420 |
]. |
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
421 |
|
73 | 422 |
" |
423 |
bring us to the top |
|
424 |
" |
|
425 |
self raise. |
|
105 | 426 |
device flush. |
73 | 427 |
|
428 |
canContinue := true. |
|
429 |
exitAction := nil. |
|
430 |
||
431 |
" |
|
432 |
enter private event handling loop. This is left (and we come back here again) |
|
433 |
when any button was pressed which requires continuation of the debuggee or |
|
434 |
closedown of the debugger. |
|
435 |
" |
|
436 |
||
132 | 437 |
[self controlLoop] valueOnUnwindDo:[ |
438 |
windowGroup notNil ifTrue:[ |
|
439 |
windowGroup setProcess:nil. |
|
440 |
]. |
|
441 |
self destroy |
|
442 |
]. |
|
73 | 443 |
|
444 |
" |
|
445 |
release all context stuff. |
|
446 |
This is required to avoid keeping references to the debuggees objects |
|
447 |
forever. (since the debugger is reused for faster startup next time) |
|
448 |
" |
|
449 |
contextArray := nil. |
|
450 |
codeView acceptAction:nil. |
|
451 |
contextView contents:nil. |
|
452 |
receiverInspector release. |
|
453 |
contextInspector release. |
|
454 |
||
455 |
(exitAction ~~ #step) ifTrue:[ |
|
75 | 456 |
self unrealize. |
105 | 457 |
device flush. |
73 | 458 |
|
75 | 459 |
(exitAction == #abort) ifTrue:[ |
460 |
self cacheMyself. |
|
461 |
" |
|
462 |
have to catch errors occuring in unwind-blocks |
|
463 |
" |
|
464 |
Object errorSignal handle:[:ex | |
|
465 |
'ignored error while unwinding: ' errorPrint. |
|
466 |
ex errorString errorPrintNL. |
|
467 |
ex proceed |
|
468 |
] do:[ |
|
469 |
Object abortSignal raise. |
|
470 |
]. |
|
471 |
'abort failed' errorPrintNL |
|
472 |
]. |
|
61 | 473 |
|
75 | 474 |
(exitAction == #return) ifTrue:[ |
475 |
selectedContext notNil ifTrue:[ |
|
476 |
" |
|
477 |
if there is a selection in the codeView, |
|
478 |
evaluate it and use the result as return value |
|
479 |
" |
|
73 | 480 |
"/ disabled for now, there is almost always a selection (the current line) |
481 |
"/ and that is syntactically incorrect ... |
|
482 |
"/ ... leading to a popup warning from the codeView |
|
483 |
"/ |
|
484 |
"/ codeView hasSelection ifTrue:[ |
|
485 |
"/ s := codeView selection asString. |
|
486 |
"/ Object errorSignal handle:[:ex | |
|
487 |
"/ 'DEBUGGER: error - returning nil' printNL. |
|
488 |
"/ retval := nil. |
|
489 |
"/ ex return |
|
490 |
"/ ] do:[ |
|
491 |
"/ retval := codeView doItAction value:s. |
|
492 |
"/ ]. |
|
493 |
"/ ]. |
|
494 |
||
75 | 495 |
con := selectedContext. |
496 |
self cacheMyself. |
|
497 |
" |
|
498 |
have to catch errors occuring in unwind-blocks |
|
499 |
" |
|
500 |
Object errorSignal handle:[:ex | |
|
501 |
'ignored error while unwinding: ' errorPrint. |
|
502 |
ex errorString errorPrintNL. |
|
503 |
ex proceed |
|
504 |
] do:[ |
|
505 |
con unwind:retval. |
|
506 |
]. |
|
507 |
'cannot return from selected context' errorPrintNL |
|
508 |
] |
|
509 |
]. |
|
73 | 510 |
|
75 | 511 |
(exitAction == #restart) ifTrue:[ |
512 |
selectedContext notNil ifTrue:[ |
|
513 |
con := selectedContext. |
|
514 |
self cacheMyself. |
|
515 |
" |
|
516 |
have to catch errors occuring in unwind-blocks |
|
517 |
" |
|
518 |
Object errorSignal handle:[:ex | |
|
519 |
'ignored error while unwinding: ' errorPrint. |
|
520 |
ex errorString errorPrintNL. |
|
521 |
ex proceed |
|
522 |
] do:[ |
|
523 |
con unwindAndRestart. |
|
524 |
]. |
|
525 |
'cannot restart selected context' errorPrintNL |
|
526 |
] |
|
527 |
]. |
|
73 | 528 |
|
75 | 529 |
(exitAction == #quickTerminate) ifTrue:[ |
530 |
self cacheMyself. |
|
531 |
Processor activeProcess terminateNoSignal |
|
532 |
]. |
|
73 | 533 |
|
75 | 534 |
(exitAction == #terminate) ifTrue:[ |
535 |
self cacheMyself. |
|
536 |
" |
|
537 |
have to catch errors occuring in unwind-blocks |
|
538 |
" |
|
539 |
Object errorSignal handle:[:ex | |
|
540 |
'ignored error while unwinding: ' errorPrint. |
|
541 |
ex errorString errorPrintNL. |
|
542 |
ex proceed |
|
543 |
] do:[ |
|
544 |
Processor activeProcess terminate. |
|
545 |
]. |
|
546 |
'cannot terminate process' errorPrintNL |
|
547 |
] |
|
73 | 548 |
]. |
549 |
||
550 |
selectedContext := actualContext := nil. |
|
551 |
||
552 |
grabber notNil ifTrue:[ |
|
75 | 553 |
device grabPointerInView:grabber. |
554 |
grabber := nil. |
|
61 | 555 |
]. |
73 | 556 |
|
557 |
(exitAction == #step) ifTrue:[ |
|
75 | 558 |
" |
559 |
schedule another stepInterrupt |
|
560 |
- must enter myself into the collection of open debuggers, |
|
561 |
in case the stepping process comes back again via a halt or signal |
|
562 |
before the step is finished. In this case, the stepping debugger should |
|
563 |
come up (instead of a new one) |
|
564 |
- must flush caches since optimized methods not always |
|
565 |
look for pending interrupts |
|
566 |
" |
|
567 |
OpenDebuggers isNil ifTrue:[ |
|
568 |
OpenDebuggers := WeakArray with:self |
|
569 |
] ifFalse:[ |
|
570 |
(OpenDebuggers includes:self) ifFalse:[ |
|
571 |
idx := OpenDebuggers identityIndexOf:nil. |
|
572 |
idx ~~ 0 ifTrue:[ |
|
573 |
OpenDebuggers at:idx put:self |
|
574 |
] ifFalse:[ |
|
575 |
OpenDebuggers := OpenDebuggers copyWith:self |
|
576 |
] |
|
577 |
] |
|
578 |
]. |
|
579 |
self label:'single stepping - please wait ...'. |
|
580 |
stepping := true. |
|
73 | 581 |
|
75 | 582 |
ObjectMemory stepInterruptHandler:self. |
583 |
ObjectMemory flushInlineCaches. |
|
584 |
StepInterruptPending := 1. |
|
585 |
InterruptPending := 1. |
|
586 |
InStepInterrupt := nil |
|
73 | 587 |
] ifFalse:[ |
75 | 588 |
OpenDebuggers notNil ifTrue:[ |
589 |
idx := OpenDebuggers identityIndexOf:self. |
|
590 |
idx ~~ 0 ifTrue:[ |
|
591 |
OpenDebuggers at:idx put:nil |
|
592 |
] |
|
593 |
]. |
|
594 |
self cacheMyself. |
|
73 | 595 |
] |
210
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
596 |
|
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
597 |
"Created: 24.11.1995 / 19:52:54 / cg" |
947f9a23b06a
better error handling in modal debugger - use new SynchronousWindowSensor
Claus Gittinger <cg@exept.de>
parents:
193
diff
changeset
|
598 |
"Modified: 24.11.1995 / 22:50:01 / cg" |
73 | 599 |
! |
600 |
||
601 |
openOn:aProcess |
|
602 |
"enter the debugger on a process - |
|
603 |
in this case, we are just inspecting the context chain of the process, |
|
604 |
not running on top of the debugged process, but as a separate |
|
605 |
one. (think of it as an inspector showing more detail, and offering |
|
606 |
some more control operations)" |
|
607 |
||
127 | 608 |
|bpanel dummy| |
73 | 609 |
|
610 |
busy := true. |
|
611 |
bigStep := false. |
|
612 |
inspecting := true. |
|
613 |
inspectedProcess := aProcess. |
|
614 |
nChainShown := 50. |
|
615 |
||
616 |
bpanel := abortButton superView. |
|
617 |
||
618 |
stopButton := Button new. |
|
619 |
stopButton label:(resources at:'stop'); |
|
620 |
action:[self doStop]. |
|
621 |
bpanel addSubView:stopButton after:continueButton. |
|
622 |
||
92 | 623 |
dummy := View extent:(10 @ 5) in:bpanel. |
73 | 624 |
dummy borderWidth:0; level:0. |
61 | 625 |
|
73 | 626 |
"/ stepButton destroy. |
627 |
"/ sendButton destroy. |
|
628 |
||
629 |
updateButton := Button |
|
630 |
label:(resources at:'update') |
|
631 |
action:[self updateContext] |
|
632 |
in:bpanel. |
|
633 |
monitorToggle := Toggle in:bpanel. |
|
634 |
monitorToggle label:(resources at:'monitor'). |
|
635 |
monitorToggle pressAction:[self autoUpdateOn]. |
|
636 |
monitorToggle releaseAction:[self autoUpdateOff]. |
|
637 |
||
638 |
"can only look into process - context chain is not active" |
|
639 |
canContinue := true. |
|
640 |
||
641 |
terminateButton enable. |
|
642 |
abortButton enable. |
|
643 |
||
644 |
sendButton disable. |
|
645 |
stepButton disable. |
|
78 | 646 |
nextButton disable. |
73 | 647 |
"/ continueButton disable. |
648 |
"/ returnButton disable. |
|
649 |
"/ restartButton disable. |
|
650 |
||
651 |
aProcess isNil ifTrue:[ |
|
652 |
terminateButton disable. |
|
653 |
abortButton disable. |
|
654 |
continueButton disable. |
|
655 |
returnButton disable. |
|
656 |
restartButton disable. |
|
657 |
] ifFalse:[ |
|
658 |
aProcess suspendedContext isNil ifTrue:[ |
|
659 |
terminateButton disable. |
|
660 |
]. |
|
661 |
||
662 |
self setContext:aProcess suspendedContext. |
|
663 |
||
664 |
catchBlock := [ |
|
665 |
catchBlock := nil. |
|
666 |
contextArray := nil. |
|
667 |
selectedContext := actualContext := nil. |
|
668 |
(exitAction == #terminate) ifTrue:[ |
|
669 |
aProcess terminate. |
|
670 |
]. |
|
671 |
(exitAction == #quickTerminate) ifTrue:[ |
|
672 |
aProcess terminateNoSignal. |
|
673 |
]. |
|
674 |
super destroy |
|
675 |
]. |
|
676 |
]. |
|
677 |
self open |
|
266 | 678 |
! ! |
679 |
||
680 |
!DebugView methodsFor:'help'! |
|
681 |
||
682 |
helpTextFor:aComponent |
|
683 |
|s| |
|
684 |
||
685 |
aComponent == abortButton ifTrue:[ |
|
686 |
s := 'HELP_ABORT' |
|
687 |
]. |
|
688 |
aComponent == terminateButton ifTrue:[ |
|
689 |
s := 'HELP_TERMINATE' |
|
690 |
]. |
|
691 |
aComponent == continueButton ifTrue:[ |
|
692 |
s := 'HELP_CONTINUE' |
|
693 |
]. |
|
694 |
aComponent == stepButton ifTrue:[ |
|
695 |
s := 'HELP_STEP' |
|
696 |
]. |
|
697 |
aComponent == nextButton ifTrue:[ |
|
698 |
s := 'HELP_NEXT' |
|
699 |
]. |
|
700 |
aComponent == stepButton ifTrue:[ |
|
701 |
s := 'HELP_STEP' |
|
702 |
]. |
|
703 |
aComponent == sendButton ifTrue:[ |
|
704 |
s := 'HELP_SEND' |
|
705 |
]. |
|
706 |
aComponent == returnButton ifTrue:[ |
|
707 |
s := 'HELP_RETURN' |
|
708 |
]. |
|
709 |
aComponent == restartButton ifTrue:[ |
|
710 |
s := 'HELP_RESTART' |
|
711 |
]. |
|
712 |
aComponent == contextView ifTrue:[ |
|
713 |
s := 'HELP_WALKBACK' |
|
714 |
]. |
|
715 |
aComponent == codeView ifTrue:[ |
|
716 |
s := 'HELP_CODEVIEW' |
|
717 |
]. |
|
718 |
aComponent == monitorToggle ifTrue:[ |
|
719 |
s := 'HELP_MONITOR' |
|
720 |
]. |
|
721 |
aComponent == updateButton ifTrue:[ |
|
722 |
s := 'HELP_UPDATE' |
|
723 |
]. |
|
724 |
aComponent == stopButton ifTrue:[ |
|
725 |
s := 'HELP_STOP' |
|
726 |
]. |
|
727 |
(aComponent isSubViewOf:receiverInspector) ifTrue:[ |
|
728 |
s := 'HELP_REC_INSP' |
|
729 |
]. |
|
730 |
(aComponent isSubViewOf:contextInspector) ifTrue:[ |
|
731 |
s := 'HELP_CON_INSP' |
|
732 |
]. |
|
733 |
||
734 |
s notNil ifTrue:[ |
|
735 |
^ resources string:s |
|
736 |
]. |
|
737 |
^ nil |
|
738 |
||
739 |
"Modified: 29.8.1995 / 23:38:54 / claus" |
|
740 |
! ! |
|
741 |
||
742 |
!DebugView methodsFor:'initialization'! |
|
743 |
||
744 |
addToCurrentProject |
|
745 |
"ignored here" |
|
746 |
||
747 |
^ self |
|
748 |
! |
|
749 |
||
750 |
createOnTop |
|
751 |
^ false "true" |
|
73 | 752 |
! |
753 |
||
266 | 754 |
initialize |
755 |
|v panel hpanel bpanel separator| |
|
756 |
||
757 |
super initialize. |
|
758 |
||
759 |
font := font on:device. |
|
760 |
||
761 |
busy := false. |
|
762 |
exclusive := false. |
|
763 |
inspecting := false. |
|
764 |
exitAction := nil. |
|
765 |
bigStep := false. |
|
766 |
canContinue := false. |
|
767 |
canAbort := false. |
|
768 |
||
769 |
bpanel := HorizontalPanelView |
|
770 |
"/ origin:(0.0 @ 0.0) |
|
771 |
"/ extent:(1.0 @ (font height * 2)) |
|
772 |
in:self. |
|
773 |
bpanel horizontalLayout:#leftSpace. |
|
774 |
bpanel verticalSpace:ViewSpacing // 2. |
|
775 |
||
776 |
terminateButton := Button |
|
777 |
label:(resources at:'terminate') |
|
778 |
action:[terminateButton turnOffWithoutRedraw. self doTerminate] |
|
779 |
in:bpanel. |
|
780 |
separator := View extent:(10 @ 5) in:bpanel. |
|
781 |
separator borderWidth:0; level:0. |
|
782 |
||
783 |
abortButton := Button |
|
784 |
label:(resources at:'abort') |
|
785 |
action:[abortButton turnOffWithoutRedraw. self doAbort] |
|
786 |
in:bpanel. |
|
787 |
returnButton := Button |
|
788 |
label:(resources at:'return') |
|
789 |
action:[returnButton turnOff. self doReturn] |
|
790 |
in:bpanel. |
|
791 |
||
792 |
restartButton := Button |
|
793 |
label:(resources at:'restart') |
|
794 |
action:[restartButton turnOff. self doRestart] |
|
795 |
in:bpanel. |
|
796 |
||
797 |
separator := View extent:(10 @ 5) in:bpanel. |
|
798 |
separator borderWidth:0; level:0. |
|
73 | 799 |
|
266 | 800 |
continueButton := Button |
801 |
label:(resources at:'continue') |
|
802 |
action:[continueButton turnOffWithoutRedraw. self doContinue] |
|
803 |
in:bpanel. |
|
804 |
||
805 |
separator := View extent:(10 @ 5) in:bpanel. |
|
806 |
separator borderWidth:0; level:0. |
|
807 |
||
808 |
nextButton := Button |
|
809 |
label:(resources at:'next') |
|
810 |
action:[stepButton turnOff. self doNext] |
|
811 |
in:bpanel. |
|
812 |
stepButton := Button |
|
813 |
label:(resources at:'step') |
|
814 |
action:[stepButton turnOff. self doStep] |
|
815 |
in:bpanel. |
|
816 |
sendButton := Button |
|
817 |
label:(resources at:'send') |
|
818 |
action:[sendButton turnOff. self doSend] |
|
819 |
in:bpanel. |
|
820 |
||
821 |
bpanel origin:(0.0 @ 0.0) |
|
822 |
extent:(1.0 @ (bpanel preferredExtent y)). |
|
73 | 823 |
|
266 | 824 |
panel := VariableVerticalPanel |
825 |
origin:(0.0 @ bpanel height) |
|
826 |
corner:(1.0 @ 1.0) |
|
827 |
in:self. |
|
828 |
||
829 |
v := ScrollableView for:SelectionInListView in:panel. |
|
830 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 0.25). |
|
831 |
||
832 |
contextView := v scrolledView. |
|
833 |
contextView action:[:lineNr | self showSelection:lineNr]. |
|
834 |
||
835 |
v := ScrollableView for:CodeView in:panel. |
|
836 |
v origin:(0.0 @ 0.25) corner:(1.0 @ 0.75). |
|
837 |
||
838 |
codeView := v scrolledView. |
|
839 |
||
840 |
hpanel := VariableHorizontalPanel in:panel. |
|
841 |
hpanel origin:(0.0 @ 0.75) corner:(1.0 @ 1.0). |
|
842 |
||
843 |
receiverInspector := InspectorView |
|
844 |
origin:(0.0 @ 0.0) corner:(0.5 @ 1.0) |
|
845 |
in:hpanel. |
|
846 |
||
847 |
contextInspector := ContextInspectorView |
|
848 |
origin:(0.5 @ 0.0) corner:(1.0 @ 1.0) |
|
849 |
in:hpanel |
|
850 |
! |
|
851 |
||
852 |
initializeMiddleButtonMenu |
|
853 |
|labels m| |
|
73 | 854 |
|
266 | 855 |
labels := resources array:#( |
856 |
'show more' |
|
857 |
'-' |
|
858 |
'skip' |
|
859 |
'-' |
|
860 |
" |
|
861 |
'continue' |
|
862 |
'terminate' |
|
863 |
'abort' |
|
864 |
'-' |
|
865 |
'step' |
|
866 |
'send' |
|
867 |
'-' |
|
868 |
'return' |
|
869 |
'restart' |
|
870 |
'-' |
|
871 |
" |
|
872 |
'remove breakpoint' |
|
873 |
'remove all trace & breakpoints' |
|
874 |
'-' |
|
875 |
'browse' |
|
876 |
'browse class' |
|
877 |
'browse class hierarchy' |
|
878 |
'browse full class protocol' |
|
879 |
'implementors' |
|
880 |
'senders' |
|
881 |
'-' |
|
882 |
'inspect context' |
|
883 |
'copy walkback text' |
|
884 |
'-' |
|
885 |
'quickTerminate' |
|
886 |
'=' |
|
887 |
'exit smalltalk (no confirmation)' |
|
888 |
). |
|
889 |
||
890 |
m := (PopUpMenu |
|
891 |
labels:labels |
|
892 |
selectors:#( |
|
893 |
showMore |
|
894 |
nil |
|
895 |
skip |
|
896 |
nil |
|
897 |
" |
|
898 |
doContinue |
|
899 |
doTerminate |
|
900 |
doAbort |
|
901 |
nil |
|
902 |
doStep |
|
903 |
doSend |
|
904 |
nil |
|
905 |
doReturn |
|
906 |
doRestart |
|
907 |
nil |
|
908 |
" |
|
909 |
removeBreakpoint |
|
910 |
removeAllBreakpoints |
|
911 |
nil |
|
912 |
browse |
|
913 |
browseClass |
|
914 |
browseClassHierarchy |
|
915 |
browseFullClassProtocol |
|
916 |
implementors |
|
917 |
senders |
|
918 |
nil |
|
919 |
inspectContext |
|
920 |
copyWalkbackText |
|
921 |
nil |
|
922 |
quickTerminate |
|
923 |
nil |
|
924 |
exit |
|
925 |
) |
|
926 |
receiver:self |
|
927 |
for:contextView). |
|
928 |
||
929 |
contextView middleButtonMenu:m. |
|
930 |
||
931 |
inspecting ifTrue:[ |
|
932 |
m notNil ifTrue:[ |
|
933 |
m disableAll:#(doTraceStep removeBreakpoint browse browseClass |
|
934 |
browseClassHierarchy browseFullClassProtocol |
|
935 |
implementors senders inspectContext skip). |
|
936 |
]. |
|
937 |
] |
|
938 |
||
939 |
"Modified: 22.11.1995 / 21:40:33 / cg" |
|
940 |
! |
|
941 |
||
942 |
realize |
|
943 |
super realize. |
|
944 |
"/ exclusive ifTrue:[ |
|
945 |
"/ windowGroup := nil |
|
946 |
"/ ]. |
|
947 |
||
948 |
inspecting ifTrue:[ |
|
949 |
inspectedProcess notNil ifTrue:[ |
|
950 |
" |
|
951 |
set prio somewhat higher (by 2, to allow walkBack-update process |
|
952 |
to run between mine and the debugged processes prio) |
|
953 |
" |
|
954 |
Processor activeProcess |
|
955 |
priority:(inspectedProcess priority + 2 min:16). |
|
73 | 956 |
] |
266 | 957 |
] |
958 |
! |
|
959 |
||
960 |
setLabelFor:aMessage in:aProcess |
|
961 |
|l nm| |
|
962 |
||
963 |
l := aMessage , ' ('. |
|
964 |
nm := aProcess name. |
|
965 |
nm notNil ifTrue:[ |
|
966 |
l := l , (nm contractTo:17) , ''. |
|
73 | 967 |
]. |
266 | 968 |
l := l , '[' , aProcess id printString , '])'. |
969 |
self label:l. |
|
0 | 970 |
! ! |
971 |
||
972 |
!DebugView methodsFor:'interrupt handling'! |
|
973 |
||
974 |
stepInterrupt |
|
57 | 975 |
|where here s isWrap method lastWrappedConAddr wrappedMethod inBlock left ignore| |
0 | 976 |
|
52 | 977 |
Processor activeProcess ~~ inspectedProcess ifTrue:[ |
978 |
'stray step interrupt' errorPrintNL. |
|
979 |
^ self |
|
980 |
]. |
|
981 |
||
29 | 982 |
" |
57 | 983 |
kludge to hide breakpoint wrappers in the context list: |
984 |
check if we are in a wrapper methods hidden setup-sequence |
|
985 |
if so, ignore the interrupt and continue single sending |
|
29 | 986 |
" |
987 |
here := thisContext. "stepInterrupt" |
|
988 |
here := here sender. "the interrupted context" |
|
989 |
||
57 | 990 |
"/ '*******' printNL. |
29 | 991 |
"/ 'here in ' print. |
992 |
"/ ((ObjectMemory addressOf:here) printStringRadix:16)print. '' printNL. |
|
10 | 993 |
|
29 | 994 |
where := here. |
995 |
isWrap := false. |
|
57 | 996 |
left := false. |
997 |
||
998 |
inWrap ifTrue:[ |
|
999 |
wrappedMethod := nil. |
|
58 | 1000 |
5 timesRepeat:[ |
29 | 1001 |
"/ where selector printNL. |
57 | 1002 |
(where notNil and:[where isBlockContext not]) ifTrue:[ |
1003 |
method := where method. |
|
1004 |
(method notNil and:[method isWrapped]) ifTrue:[ |
|
1005 |
" |
|
1006 |
in a wrapper method |
|
1007 |
" |
|
1008 |
wrappedMethod ~~ method ifTrue:[ |
|
1009 |
wrappedMethod := method. |
|
1010 |
lastWrappedConAddr := ObjectMemory addressOf:where. |
|
1011 |
where sender receiver == method originalMethod ifFalse:[ |
|
1012 |
isWrap := true. |
|
1013 |
] |
|
1014 |
] ifFalse:[ |
|
1015 |
(ObjectMemory addressOf:where) == steppedContextAddress ifTrue:[ |
|
1016 |
"/ 'change stepCon from: ' print. |
|
1017 |
"/ (steppedContextAddress printStringRadix:16)print. |
|
1018 |
"/ ' to: ' print. |
|
1019 |
"/ (lastWrappedConAddr printStringRadix:16)printNL. |
|
1020 |
||
1021 |
inWrap := false. |
|
1022 |
steppedContextAddress := lastWrappedConAddr |
|
1023 |
] |
|
56 | 1024 |
] |
57 | 1025 |
]. |
1026 |
where := where sender |
|
1027 |
] |
|
1028 |
]. |
|
29 | 1029 |
]. |
1030 |
||
1031 |
isWrap ifTrue:[ |
|
1032 |
"/ 'ignore wrap' printNL. |
|
57 | 1033 |
"/ ' ' printNL. |
45 | 1034 |
" |
1035 |
ignore, while in wrappers hidden setup |
|
1036 |
" |
|
1037 |
where := nil. here := nil. |
|
1038 |
ObjectMemory flushInlineCaches. |
|
58 | 1039 |
StepInterruptPending := 1. |
1040 |
InterruptPending := 1. |
|
45 | 1041 |
InStepInterrupt := nil. |
1042 |
^ nil |
|
29 | 1043 |
]. |
1044 |
||
57 | 1045 |
inBlock := false. |
1046 |
||
29 | 1047 |
" |
1048 |
is this for a send or a step ? |
|
1049 |
" |
|
1050 |
bigStep ifTrue:[ |
|
45 | 1051 |
" |
1052 |
a step - ignore all contexts below the interresting one |
|
1053 |
" |
|
1054 |
where := here. "the interrupted context" |
|
57 | 1055 |
|
1056 |
where home notNil ifTrue:[ |
|
1057 |
(ObjectMemory addressOf:where home) == steppedContextAddress ifTrue:[ |
|
1058 |
"/ '*block*' printNL. |
|
1059 |
inBlock := true |
|
1060 |
] |
|
1061 |
]. |
|
1062 |
||
45 | 1063 |
(ObjectMemory addressOf:where) == steppedContextAddress ifFalse:[ |
1064 |
where := where sender. |
|
57 | 1065 |
|
1066 |
where home notNil ifTrue:[ |
|
1067 |
(ObjectMemory addressOf:where home) == steppedContextAddress ifTrue:[ |
|
1068 |
"/ '*block*' printNL. |
|
1069 |
inBlock := true. |
|
1070 |
] |
|
1071 |
]. |
|
1072 |
||
1073 |
"/ 'looking for ' print. |
|
29 | 1074 |
"/ (steppedContextAddress printStringRadix:16)print. '' printNL. |
57 | 1075 |
|
45 | 1076 |
(ObjectMemory addressOf:where) == steppedContextAddress ifFalse:[ |
1077 |
" |
|
1078 |
check if we are in a context below steppedContext |
|
1079 |
(i.e. if steppedContext can be reached from |
|
1080 |
interrupted context. Not using context-ref but its |
|
1081 |
address to avoid creation of many useless contexts.) |
|
1082 |
" |
|
57 | 1083 |
inBlock ifFalse:[ |
1084 |
[where notNil] whileTrue:[ |
|
29 | 1085 |
"/ ((ObjectMemory addressOf:where) printStringRadix:16)print. ' ' print. |
1086 |
"/ where selector printNL. |
|
57 | 1087 |
(ObjectMemory addressOf:where) == steppedContextAddress ifTrue:[ |
1088 |
"/ 'found it - below; ignore' printNL. |
|
1089 |
" |
|
1090 |
found the interresting context somwehere up in the |
|
1091 |
chain. We seem to be still below the interresting one ... |
|
1092 |
" |
|
1093 |
tracing == true ifTrue:[ |
|
1094 |
here printString printNewline |
|
1095 |
]. |
|
1096 |
where := nil. here := nil. |
|
1097 |
" |
|
1098 |
yes, a context below |
|
1099 |
- continue and schedule another stepInterrupt. |
|
1100 |
Must flush caches since optimized methods not always |
|
1101 |
look for pending interrupts |
|
1102 |
" |
|
1103 |
ObjectMemory flushInlineCaches. |
|
58 | 1104 |
StepInterruptPending := 1. |
1105 |
InterruptPending := 1. |
|
57 | 1106 |
InStepInterrupt := nil. |
1107 |
^ nil |
|
45 | 1108 |
]. |
57 | 1109 |
where := where sender |
45 | 1110 |
]. |
57 | 1111 |
s := 'left stepped method'. |
1112 |
left := true. |
|
45 | 1113 |
]. |
1114 |
] ifTrue:[ |
|
29 | 1115 |
"/ 'found it right in sender' printNL. |
45 | 1116 |
s := 'after step' |
1117 |
]. |
|
1118 |
] ifTrue:[ |
|
29 | 1119 |
"/ 'found it right away' printNL. |
45 | 1120 |
s := 'after step' |
1121 |
]. |
|
0 | 1122 |
] ifFalse:[ |
57 | 1123 |
"/ ' send' printNL. |
45 | 1124 |
" |
1125 |
a send |
|
1126 |
" |
|
1127 |
steppedContextAddress := nil. |
|
1128 |
s := 'after send' |
|
0 | 1129 |
]. |
7 | 1130 |
|
57 | 1131 |
inBlock ifTrue:[ |
1132 |
"/ 'inBlock' printNL. |
|
1133 |
s := 'in block'. |
|
1134 |
]. |
|
1135 |
||
1136 |
"/ where notNil ifTrue:[ |
|
1137 |
"/ '(' print. steppedContextLineno print. ') ' print. |
|
1138 |
"/ where print. |
|
1139 |
"/ '[' print. where lineNumber print. ']' printNL. |
|
1140 |
"/ ]. |
|
1141 |
||
1142 |
ignore := false. |
|
78 | 1143 |
|
57 | 1144 |
(bigStep |
78 | 1145 |
and:[steppedContextLineno notNil |
57 | 1146 |
and:[where notNil |
78 | 1147 |
and:[where lineNumber == steppedContextLineno]]]) ifTrue:[ |
57 | 1148 |
"/ 'same line - ignored' printNL. |
1149 |
ignore := true |
|
1150 |
]. |
|
1151 |
||
1152 |
(left not |
|
1153 |
and:[skipLineNr notNil |
|
1154 |
and:[where lineNumber ~~ skipLineNr]]) ifTrue:[ |
|
1155 |
"/ 'skip (' print. skipLineNr print. ' unreached - ignored' printNL. |
|
1156 |
ignore := true |
|
1157 |
]. |
|
1158 |
||
1159 |
ignore ifTrue:[ |
|
1160 |
"/' ' printNL. |
|
1161 |
where := nil. here := nil. |
|
1162 |
" |
|
1163 |
yes, a context below |
|
1164 |
- continue and schedule another stepInterrupt. |
|
1165 |
Must flush caches since optimized methods not always |
|
1166 |
look for pending interrupts |
|
1167 |
" |
|
1168 |
ObjectMemory flushInlineCaches. |
|
58 | 1169 |
StepInterruptPending := 1. |
1170 |
InterruptPending := 1. |
|
57 | 1171 |
InStepInterrupt := nil. |
1172 |
^ nil |
|
1173 |
]. |
|
1174 |
||
1175 |
"/ ' ' printNL. |
|
1176 |
||
29 | 1177 |
name := Processor activeProcess nameOrId. |
7 | 1178 |
self label:(s , ' (process: ' , name , ')'). |
1179 |
||
57 | 1180 |
tracing := false. |
1181 |
bigStep := false. |
|
1182 |
||
0 | 1183 |
"release refs to context" |
1184 |
where := nil. here := nil. |
|
29 | 1185 |
self enter:thisContext sender |
0 | 1186 |
! ! |
1187 |
||
266 | 1188 |
!DebugView methodsFor:'menu / button actions'! |
1189 |
||
1190 |
autoUpdateOff |
|
1191 |
"stop the update process" |
|
1192 |
||
1193 |
updateProcess notNil ifTrue:[ |
|
1194 |
monitorToggle lampColor:(Color yellow). |
|
1195 |
updateProcess terminate. |
|
1196 |
updateProcess := nil |
|
1197 |
] |
|
1198 |
! |
|
1199 |
||
1200 |
autoUpdateOn |
|
1201 |
"fork a subprocess which updates the contextList in regular intervals" |
|
1202 |
||
1203 |
updateProcess isNil ifTrue:[ |
|
1204 |
updateProcess := |
|
1205 |
[ |
|
1206 |
[true] whileTrue:[ |
|
1207 |
monitorToggle showLamp ifTrue:[ |
|
1208 |
monitorToggle lampColor:(Color yellow). |
|
1209 |
] ifFalse:[ |
|
1210 |
monitorToggle activeForegroundColor:Color black. |
|
1211 |
]. |
|
1212 |
(Delay forSeconds:0.25) wait. |
|
1213 |
self updateContext. |
|
1214 |
monitorToggle showLamp ifTrue:[ |
|
1215 |
monitorToggle lampColor:(Color red). |
|
1216 |
] ifFalse:[ |
|
1217 |
monitorToggle activeForegroundColor:Color red. |
|
1218 |
]. |
|
1219 |
(Delay forSeconds:0.25) wait. |
|
1220 |
self updateContext. |
|
1221 |
] |
|
1222 |
] forkAt:(Processor activePriority - 1) |
|
1223 |
] |
|
1224 |
||
1225 |
! |
|
1226 |
||
1227 |
browse |
|
1228 |
|w| |
|
1229 |
||
1230 |
w := selectedContext method who. |
|
1231 |
SystemBrowser openInClass:(w at:1) selector:(w at:2). |
|
1232 |
||
1233 |
"Created: 22.11.1995 / 21:27:01 / cg" |
|
1234 |
! |
|
1235 |
||
1236 |
browseClass |
|
1237 |
SystemBrowser browseClass:(selectedContext method who at:1). |
|
1238 |
! |
|
1239 |
||
1240 |
browseClassHierarchy |
|
1241 |
SystemBrowser browseClassHierarchy:(selectedContext method who at:1). |
|
1242 |
! |
|
1243 |
||
1244 |
browseFullClassProtocol |
|
1245 |
SystemBrowser browseFullClassProtocol:(selectedContext method who at:1). |
|
1246 |
! |
|
1247 |
||
1248 |
copyWalkbackText |
|
1249 |
"place the contents of the walkback view into the copy-paste buffer. |
|
1250 |
This allows pasting it into some other view for printing ..." |
|
1251 |
||
1252 |
self setTextSelection:(contextArray collect:[:con | con fullPrintString]) asStringCollection |
|
1253 |
||
1254 |
"Modified: 28.8.1995 / 15:31:59 / claus" |
|
1255 |
! |
|
1256 |
||
1257 |
doAbort |
|
1258 |
"abort - send Object>>abortSignal, which is usually cought |
|
1259 |
at save places (for example: in the event loop) and returns back |
|
1260 |
from whatever the process is doing, but does not terminate it." |
|
1261 |
||
1262 |
inspecting ifTrue:[ |
|
1263 |
inspectedProcess isDead ifTrue:[ |
|
1264 |
self showTerminated. |
|
1265 |
^ self |
|
1266 |
]. |
|
1267 |
(Object abortSignal isHandledIn:inspectedProcess suspendedContext) ifFalse:[ |
|
1268 |
self showError:'** the process does not handle the abort signal **' |
|
1269 |
] ifTrue:[ |
|
1270 |
self interruptProcessWith:[Object abortSignal raise]. |
|
1271 |
]. |
|
1272 |
^ self |
|
1273 |
]. |
|
1274 |
||
1275 |
steppedContextAddress := nil. |
|
1276 |
haveControl := false. |
|
1277 |
exitAction := #abort. |
|
1278 |
ProcessorScheduler isPureEventDriven ifFalse:[ |
|
1279 |
"exit private event-loop" |
|
1280 |
catchBlock notNil ifTrue:[ |
|
1281 |
abortButton turnOff. |
|
1282 |
catchBlock value. |
|
1283 |
'DEBUGGER: oops, abort failed' errorPrintNL. |
|
1284 |
] |
|
1285 |
]. |
|
1286 |
^ self. |
|
1287 |
||
1288 |
"obsolete ..." |
|
1289 |
"/ Processor activeProcess id == 0 ifTrue:[ |
|
1290 |
"/ "dont allow termination of main-thread" |
|
1291 |
"/ exitAction := #abort |
|
1292 |
"/ ] ifFalse:[ |
|
1293 |
"/ exitAction := #terminate |
|
1294 |
"/ ] |
|
1295 |
! |
|
1296 |
||
1297 |
doContinue |
|
1298 |
"continue from menu" |
|
1299 |
||
1300 |
inspecting ifTrue:[ |
|
1301 |
self processPerform:#resume. |
|
1302 |
^ self |
|
1303 |
]. |
|
1304 |
canContinue ifTrue:[ |
|
1305 |
steppedContextAddress := nil. |
|
1306 |
tracing := false. |
|
1307 |
haveControl := false. |
|
1308 |
exitAction := #continue. |
|
1309 |
ProcessorScheduler isPureEventDriven ifFalse:[ |
|
1310 |
"exit private event-loop" |
|
1311 |
catchBlock notNil ifTrue:[catchBlock value]. |
|
1312 |
'DEBUGGER: oops, continue failed' errorPrintNL. |
|
1313 |
continueButton turnOff. |
|
1314 |
]. |
|
1315 |
] ifFalse:[ |
|
1316 |
inspecting ifFalse:[ |
|
1317 |
'resuming top context' errorPrintNL. |
|
1318 |
self showSelection:1. |
|
1319 |
self doReturn |
|
1320 |
] |
|
1321 |
] |
|
1322 |
! |
|
1323 |
||
1324 |
doNext |
|
1325 |
"skip for next source-code line" |
|
1326 |
||
1327 |
self doStep:nil |
|
1328 |
! |
|
1329 |
||
1330 |
doNoTrace |
|
1331 |
traceView notNil ifTrue:[ |
|
1332 |
traceView topView destroy. |
|
1333 |
traceView := nil. |
|
1334 |
]. |
|
1335 |
tracing := false |
|
1336 |
! |
|
1337 |
||
1338 |
doRestart |
|
1339 |
"restart - the selected context will be restarted" |
|
1340 |
||
1341 |
inspecting ifTrue:[ |
|
1342 |
selectedContext isNil ifTrue:[ |
|
1343 |
^ self showError:'** select a context first **' |
|
1344 |
]. |
|
1345 |
self interruptProcessWith:[selectedContext unwindAndRestart]. |
|
1346 |
^ self |
|
1347 |
]. |
|
1348 |
||
1349 |
steppedContextAddress := nil. |
|
1350 |
haveControl := false. |
|
1351 |
exitAction := #restart. |
|
1352 |
ProcessorScheduler isPureEventDriven ifFalse:[ |
|
1353 |
"exit private event-loop" |
|
1354 |
catchBlock notNil ifTrue:[catchBlock value]. |
|
1355 |
'DEBUGGER: oops, restart failed' errorPrintNL. |
|
1356 |
restartButton turnOff. |
|
1357 |
]. |
|
1358 |
! |
|
1359 |
||
1360 |
doReturn |
|
1361 |
"return - the selected context will do a ^nil" |
|
1362 |
||
1363 |
inspecting ifTrue:[ |
|
1364 |
selectedContext isNil ifTrue:[ |
|
1365 |
^ self showError:'** select a context first **' |
|
1366 |
]. |
|
1367 |
self interruptProcessWith:[selectedContext unwind]. |
|
1368 |
^ self |
|
1369 |
]. |
|
1370 |
||
1371 |
steppedContextAddress := nil. |
|
1372 |
haveControl := false. |
|
1373 |
exitAction := #return. |
|
1374 |
ProcessorScheduler isPureEventDriven ifFalse:[ |
|
1375 |
"exit private event-loop" |
|
1376 |
catchBlock notNil ifTrue:[catchBlock value]. |
|
1377 |
'DEBUGGER: oops, return failed' errorPrintNL. |
|
1378 |
returnButton turnOff. |
|
1379 |
]. |
|
1380 |
! |
|
1381 |
||
1382 |
doSend |
|
1383 |
"single send; reenter with next message send" |
|
1384 |
||
1385 |
inspecting ifTrue:[^ self]. |
|
1386 |
||
1387 |
canContinue ifTrue:[ |
|
1388 |
steppedContextAddress := nil. |
|
1389 |
haveControl := false. |
|
1390 |
exitAction := #step. |
|
1391 |
ProcessorScheduler isPureEventDriven ifFalse:[ |
|
1392 |
"exit private event-loop" |
|
1393 |
catchBlock notNil ifTrue:[catchBlock value]. |
|
1394 |
'DEBUGGER: oops, send failed' errorPrintNL. |
|
1395 |
sendButton turnOff. |
|
1396 |
]. |
|
1397 |
] |
|
1398 |
! |
|
1399 |
||
1400 |
doStep |
|
1401 |
"skip for next send in selected method" |
|
1402 |
||
1403 |
self doStep:-1 |
|
1404 |
! |
|
1405 |
||
1406 |
doStep:lineNr |
|
1407 |
"step until we pass lineNr (if nonNil) or to next line (if nil) |
|
1408 |
or to next send (if -1)" |
|
1409 |
||
1410 |
|con method| |
|
1411 |
||
1412 |
inspecting ifTrue:[^ self]. |
|
1413 |
||
1414 |
canContinue ifTrue:[ |
|
1415 |
selectedContext notNil ifTrue:[ |
|
1416 |
con := selectedContext. |
|
1417 |
steppedContextLineno := actualContext lineNumber. |
|
1418 |
] ifFalse:[ |
|
1419 |
con := contextArray at:2. |
|
1420 |
steppedContextLineno := con lineNumber. |
|
1421 |
]. |
|
1422 |
skipLineNr := lineNr. |
|
1423 |
||
1424 |
lineNr == -1 ifTrue:[ |
|
1425 |
steppedContextLineno := skipLineNr := nil. |
|
1426 |
]. |
|
1427 |
||
1428 |
steppedContextAddress := ObjectMemory addressOf:con. |
|
1429 |
" |
|
1430 |
if we step in a wrapped method, |
|
1431 |
prepare to skip the prolog ... |
|
1432 |
" |
|
1433 |
"/ ' step con:' print. steppedContextAddress printHex. ' ' printNL. |
|
1434 |
inWrap := false. |
|
1435 |
method := con method. |
|
1436 |
(method notNil and:[method isWrapped]) ifTrue:[ |
|
1437 |
inWrap := true |
|
1438 |
]. |
|
1439 |
||
1440 |
con := nil. |
|
1441 |
bigStep := true. |
|
1442 |
haveControl := false. |
|
1443 |
exitAction := #step. |
|
1444 |
ProcessorScheduler isPureEventDriven ifFalse:[ |
|
1445 |
"exit private event-loop" |
|
1446 |
catchBlock notNil ifTrue:[catchBlock value]. |
|
1447 |
'DEBUGGER: oops, step failed' errorPrintNL. |
|
1448 |
stepButton turnOff. |
|
1449 |
nextButton turnOff. |
|
1450 |
sendButton turnOff. |
|
1451 |
]. |
|
1452 |
] |
|
1453 |
! |
|
1454 |
||
1455 |
doStop |
|
1456 |
"stop the process (if its running, otherwise this is a no-op)" |
|
1457 |
||
1458 |
inspecting ifTrue:[ |
|
1459 |
self processPerform:#stop. |
|
1460 |
^ self |
|
1461 |
]. |
|
1462 |
! |
|
1463 |
||
1464 |
doTerminate |
|
1465 |
"terminate - the process has a chance for cleanup" |
|
1466 |
||
1467 |
inspecting ifTrue:[ |
|
1468 |
self processPerform:#terminate. |
|
1469 |
^ self |
|
1470 |
]. |
|
1471 |
||
1472 |
steppedContextAddress := nil. |
|
1473 |
haveControl := false. |
|
1474 |
exitAction := #terminate. |
|
1475 |
ProcessorScheduler isPureEventDriven ifFalse:[ |
|
1476 |
"exit private event-loop" |
|
1477 |
catchBlock notNil ifTrue:[catchBlock value]. |
|
1478 |
inspecting ifFalse:[ |
|
1479 |
'DEBUGGER: oops, terminate failed' errorPrintNL. |
|
1480 |
self warn:'terminate failed'. |
|
1481 |
]. |
|
1482 |
terminateButton turnOff. |
|
1483 |
]. |
|
1484 |
! |
|
1485 |
||
1486 |
doTrace |
|
1487 |
"tracing - not really implemented ..." |
|
1488 |
||
1489 |
self warn:'this function is not yet implemented'. |
|
1490 |
||
1491 |
"/ |v b| |
|
1492 |
"/ |
|
1493 |
"/ traceView isNil ifTrue:[ |
|
1494 |
"/ v := StandardSystemView on:Display. |
|
1495 |
"/ v label:'Debugger-Trace'. |
|
1496 |
"/ v icon:icon. |
|
1497 |
"/ |
|
1498 |
"/ b := Button label:'untrace' in:v. |
|
1499 |
"/ b origin:(0 @ 0) extent:(1.0 @ (b height)). |
|
1500 |
"/ b action:[ |
|
1501 |
"/ StepInterruptPending := nil. |
|
1502 |
"/ tracing := false. |
|
1503 |
"/ v unrealize. |
|
1504 |
"/ traceView := nil |
|
1505 |
"/ ]. |
|
1506 |
"/ traceView := ScrollableView for:TextCollector in:v. |
|
1507 |
"/ traceView origin:(0 @ (b height)) |
|
1508 |
"/ extent:[v width @ (v height - b height)] |
|
1509 |
"/ ]. |
|
1510 |
"/ v realize. |
|
1511 |
"/ |
|
1512 |
"/ tracing := true. |
|
1513 |
! |
|
1514 |
||
1515 |
doTraceStep |
|
1516 |
"tracestep - not implemented yet" |
|
1517 |
||
1518 |
canContinue ifTrue:[ |
|
1519 |
tracing := true. |
|
1520 |
self doStep |
|
1521 |
] |
|
1522 |
! |
|
1523 |
||
1524 |
exit |
|
1525 |
"exit from menu: immediate exit from smalltalk" |
|
1526 |
||
1527 |
OperatingSystem exit |
|
1528 |
! |
|
1529 |
||
1530 |
implementors |
|
1531 |
"open a browser on the implementors" |
|
1532 |
||
1533 |
selectedContext isNil ifTrue:[ |
|
1534 |
^ self showError:'** select a context first **' |
|
1535 |
]. |
|
1536 |
SystemBrowser browseImplementorsOf:selectedContext selector. |
|
1537 |
! |
|
1538 |
||
1539 |
inspectContext |
|
1540 |
"launch an inspector on the currently selected context" |
|
1541 |
||
1542 |
contextView selection notNil ifTrue:[ |
|
1543 |
(contextView selectionValue startsWith:'**') ifFalse:[ |
|
1544 |
(contextArray at:(contextView selection)) inspect. |
|
1545 |
] |
|
1546 |
] |
|
1547 |
! |
|
1548 |
||
1549 |
quickTerminate |
|
1550 |
"quick terminate - the process will get no chance for cleanup actions" |
|
1551 |
||
1552 |
inspecting ifTrue:[ |
|
1553 |
self processPerform:#terminateNoSignal. |
|
1554 |
^ self |
|
1555 |
]. |
|
1556 |
||
1557 |
steppedContextAddress := nil. |
|
1558 |
haveControl := false. |
|
1559 |
exitAction := #quickTerminate. |
|
1560 |
ProcessorScheduler isPureEventDriven ifFalse:[ |
|
1561 |
"exit private event-loop" |
|
1562 |
catchBlock notNil ifTrue:[catchBlock value]. |
|
1563 |
inspecting ifFalse:[ |
|
1564 |
'DEBUGGER: oops, terminate failed' errorPrintNL. |
|
1565 |
self warn:'terminate failed'. |
|
1566 |
]. |
|
1567 |
terminateButton turnOff. |
|
1568 |
]. |
|
1569 |
! |
|
1570 |
||
1571 |
removeAllBreakpoints |
|
1572 |
"remove all trace & breakpoints - if any" |
|
1573 |
||
1574 |
MessageTracer unwrapAllMethods |
|
1575 |
! |
|
1576 |
||
1577 |
removeBreakpoint |
|
1578 |
"remove breakpoint on the selected contexts method - if any" |
|
1579 |
||
1580 |
|implementorClass method| |
|
1581 |
||
1582 |
selectedContext isNil ifTrue:[ |
|
1583 |
^ self showError:'** select a context first **' |
|
1584 |
]. |
|
1585 |
||
1586 |
implementorClass := selectedContext methodClass. |
|
1587 |
implementorClass notNil ifTrue:[ |
|
1588 |
method := implementorClass compiledMethodAt:selectedContext selector. |
|
1589 |
(method notNil and:[method isWrapped]) ifTrue:[ |
|
1590 |
MessageTracer unwrapMethod:method |
|
1591 |
] |
|
1592 |
]. |
|
1593 |
contextView middleButtonMenu disable:#removeBreakpoint. |
|
1594 |
! |
|
1595 |
||
1596 |
senders |
|
1597 |
"open a browser on the senders" |
|
1598 |
||
1599 |
selectedContext isNil ifTrue:[ |
|
1600 |
^ self showError:'** select a context first **' |
|
1601 |
]. |
|
1602 |
SystemBrowser browseAllCallsOn:selectedContext selector. |
|
1603 |
! |
|
1604 |
||
1605 |
showMore |
|
1606 |
"double number of contexts shown" |
|
1607 |
||
1608 |
|oldSelection con| |
|
1609 |
||
1610 |
contextArray notNil ifTrue:[ |
|
1611 |
oldSelection := contextView selection. |
|
1612 |
nChainShown := nChainShown * 2. |
|
1613 |
con := contextArray at:1. |
|
1614 |
contextArray at:1 put:nil. |
|
1615 |
self setContext:con. |
|
1616 |
contextView selection:oldSelection. |
|
1617 |
] |
|
1618 |
! |
|
1619 |
||
1620 |
skip |
|
1621 |
"skip for cursor line in selected method" |
|
1622 |
||
1623 |
self doStep:codeView cursorLine. |
|
1624 |
! ! |
|
1625 |
||
1626 |
!DebugView methodsFor:'private'! |
|
1627 |
||
1628 |
busy |
|
1629 |
^ busy |
|
1630 |
! |
|
1631 |
||
1632 |
cacheMyself |
|
1633 |
"remember myself for next debug session" |
|
1634 |
||
1635 |
"caching the last debugger will make the next debugger appear |
|
1636 |
faster, since no resources have to be allocated in the display. |
|
1637 |
We have to be careful to release all refs to the debuggee, though. |
|
1638 |
Otherwise, the GC will not be able to release it" |
|
1639 |
||
1640 |
windowGroup notNil ifTrue:[ |
|
1641 |
windowGroup setProcess:nil. |
|
1642 |
]. |
|
1643 |
||
1644 |
busy := false. |
|
1645 |
codeView acceptAction:nil. |
|
1646 |
codeView doItAction:nil. |
|
1647 |
codeView contents:nil. |
|
1648 |
receiverInspector release. |
|
1649 |
contextInspector release. |
|
1650 |
inspectedProcess := nil. |
|
1651 |
exitAction := nil. |
|
1652 |
contextArray := nil. |
|
1653 |
selectedContext := actualContext := nil. |
|
1654 |
catchBlock := nil. |
|
1655 |
grabber := nil. |
|
1656 |
self autoUpdateOff. |
|
1657 |
||
1658 |
exclusive ifTrue:[CachedExclusive := self] ifFalse:[CachedDebugger := self]. |
|
1659 |
! |
|
1660 |
||
1661 |
exclusive:aBoolean |
|
1662 |
exclusive := aBoolean |
|
1663 |
! |
|
1664 |
||
1665 |
inspectedProcess |
|
1666 |
^ inspectedProcess |
|
1667 |
! |
|
1668 |
||
1669 |
interrestingContextFrom:aContext |
|
1670 |
"return an interresting contexts offset, or nil. |
|
1671 |
This is the context initially shown in the walkback. |
|
1672 |
We move up the calling chain, skipping all intermediate Signal |
|
1673 |
and Exception contexts, to present the context in which the error |
|
1674 |
actually occured. |
|
1675 |
Just for your convenience :-)" |
|
1676 |
||
1677 |
|c found offset sel prev ex| |
|
1678 |
||
1679 |
"somewhere, at the bottom, there must be a raise ..." |
|
1680 |
||
1681 |
c := aContext. |
|
1682 |
1 to:5 do:[:i | |
|
269 | 1683 |
c isNil ifTrue:[^ 1 "^ nil"]. |
1684 |
sel := c selector. |
|
1685 |
(sel == #raise) ifTrue:[ |
|
1686 |
(c receiver isKindOf:Exception) ifTrue:[ |
|
1687 |
ex := c receiver. |
|
1688 |
offset := i. |
|
1689 |
found := c |
|
1690 |
] ifFalse:[ |
|
1691 |
(c receiver isKindOf:Signal) ifTrue:[ |
|
1692 |
offset := i. |
|
1693 |
found := c |
|
1694 |
] |
|
1695 |
] |
|
1696 |
]. |
|
1697 |
c := c sender. |
|
266 | 1698 |
]. |
1699 |
||
1700 |
" |
|
1701 |
if this is a noHandler exception, skip forward |
|
1702 |
to the erronous context |
|
1703 |
" |
|
1704 |
ex notNil ifTrue:[ |
|
269 | 1705 |
ex signal == Signal noHandlerSignal ifTrue:[ |
1706 |
c := ex suspendedContext |
|
1707 |
] |
|
266 | 1708 |
]. |
1709 |
||
1710 |
(c := found) isNil ifTrue:[^ 1]. |
|
1711 |
||
1712 |
" |
|
1713 |
got it; move up, skipping all intermediate Signal and |
|
1714 |
Exception contexts |
|
1715 |
" |
|
1716 |
prev := nil. |
|
1717 |
[ |
|
269 | 1718 |
((c receiver isSignal) |
1719 |
or:[(c receiver isKindOf:Exception)]) |
|
266 | 1720 |
] whileTrue:[ |
269 | 1721 |
prev := c. |
1722 |
(c := c sender) isNil ifTrue:[^ offset]. |
|
1723 |
offset := offset + 1. |
|
266 | 1724 |
]. |
1725 |
||
1726 |
" |
|
1727 |
now, we are one above the raise |
|
1728 |
" |
|
1729 |
||
1730 |
" |
|
269 | 1731 |
if the sender-method of the raise is one of objects error methods ... |
266 | 1732 |
" |
1733 |
( #( halt halt: |
|
269 | 1734 |
error error: |
1735 |
doesNotUnderstand: |
|
1736 |
subclassResponsibility |
|
1737 |
primitiveFailed) includes:c selector) |
|
266 | 1738 |
ifTrue:[ |
269 | 1739 |
c selector == #doesNotUnderstand: ifTrue:[ |
1740 |
" |
|
1741 |
one more up, to get to the originating context |
|
1742 |
" |
|
1743 |
(c := c sender) isNil ifTrue:[^ offset]. |
|
1744 |
offset := offset + 1. |
|
1745 |
]. |
|
1746 |
(c := c sender) isNil ifTrue:[^ offset]. |
|
1747 |
offset := offset + 1. |
|
266 | 1748 |
] ifFalse:[ |
269 | 1749 |
" |
1750 |
ok, got the raise - if its a BreakPoint, look for the sender |
|
1751 |
" |
|
1752 |
(MessageTracer notNil and:[prev receiver == MessageTracer breakpointSignal]) ifTrue:[ |
|
1753 |
offset := offset + 1 |
|
1754 |
]. |
|
266 | 1755 |
]. |
1756 |
||
1757 |
^ offset |
|
269 | 1758 |
|
1759 |
"Created: 10.12.1995 / 13:55:21 / cg" |
|
266 | 1760 |
! |
1761 |
||
1762 |
interruptProcessWith:aBlock |
|
1763 |
"let inspected process do something, then update the context list" |
|
1764 |
||
1765 |
inspectedProcess isDead ifTrue:[ |
|
1766 |
self showTerminated. |
|
1767 |
^ self |
|
1768 |
]. |
|
1769 |
inspectedProcess interruptWith:aBlock. |
|
1770 |
" |
|
1771 |
give the process a chance to run, then update |
|
1772 |
" |
|
1773 |
(Delay forSeconds:0.2) wait. |
|
1774 |
self setContext:(inspectedProcess suspendedContext). |
|
1775 |
! |
|
1776 |
||
1777 |
processPerform:aMessage |
|
1778 |
"do something, then update the context list" |
|
1779 |
||
1780 |
inspectedProcess isDead ifTrue:[ |
|
1781 |
self showTerminated. |
|
1782 |
^ self |
|
1783 |
]. |
|
1784 |
inspectedProcess perform:aMessage. |
|
1785 |
" |
|
1786 |
give the process a chance to run, then update |
|
1787 |
" |
|
1788 |
(Delay forSeconds:0.2) wait. |
|
1789 |
self setContext:(inspectedProcess suspendedContext). |
|
1790 |
! |
|
1791 |
||
1792 |
setContext:aContext |
|
1793 |
"show calling chain from aContext in the walk-back listview" |
|
1794 |
||
1795 |
|con text method caller caller2 m count| |
|
1796 |
||
1797 |
(contextArray notNil and:[aContext == (contextArray at:1)]) ifTrue:[ |
|
1798 |
"no change" |
|
1799 |
^ false |
|
1800 |
]. |
|
1801 |
||
1802 |
m := contextView middleButtonMenu. |
|
1803 |
m notNil ifTrue:[ |
|
1804 |
m disable:#showMore. |
|
1805 |
]. |
|
1806 |
||
1807 |
aContext isNil ifTrue:[ |
|
1808 |
text := Array with:'** no context **'. |
|
1809 |
contextArray := nil. |
|
1810 |
] ifFalse:[ |
|
1811 |
text := OrderedCollection new:nChainShown. |
|
1812 |
contextArray := OrderedCollection new:nChainShown. |
|
1813 |
con := aContext. |
|
1814 |
||
1815 |
" |
|
1816 |
get them all |
|
1817 |
" |
|
1818 |
count := 0. |
|
1819 |
[con notNil and:[count <= nChainShown]] whileTrue:[ |
|
1820 |
contextArray add:con. count := count + 1. |
|
1821 |
(MoreDebuggingDetail == true) ifTrue:[ |
|
1822 |
text add:(((ObjectMemory addressOf:con) printStringRadix:16) , ' ' , con printString). |
|
1823 |
] ifFalse:[ |
|
1824 |
text add:con printString. |
|
1825 |
]. |
|
1826 |
||
1827 |
method := con method. |
|
1828 |
(method notNil and:[method isWrapped]) ifTrue:[ |
|
1829 |
" |
|
1830 |
kludge: if its a wrapped method, then hide the wrap-call |
|
1831 |
" |
|
1832 |
caller := con sender. |
|
1833 |
(caller notNil and:[caller receiver == method originalMethod]) ifTrue:[ |
|
1834 |
caller2 := caller sender. |
|
1835 |
(caller2 notNil and:[caller2 method == method]) ifTrue:[ |
|
1836 |
con := caller2 |
|
1837 |
] |
|
1838 |
]. |
|
1839 |
caller := caller2 := nil |
|
1840 |
]. |
|
1841 |
con := con sender |
|
1842 |
]. |
|
1843 |
||
1844 |
" |
|
1845 |
did we reach the end ? |
|
1846 |
" |
|
1847 |
(con isNil or:[con sender isNil]) ifTrue:[ |
|
1848 |
" |
|
1849 |
the very last one is the startup context |
|
1850 |
(in main) - it has nil as receiver and nil as selector |
|
1851 |
" |
|
1852 |
contextArray last selector isNil ifTrue:[ |
|
1853 |
contextArray removeLast. |
|
1854 |
text removeLast |
|
1855 |
] |
|
1856 |
] ifFalse:[ |
|
1857 |
m notNil ifTrue:[ |
|
1858 |
m enable:#showMore. |
|
1859 |
text add:(resources string:'*** more walkback follows - click here to see them ***') |
|
1860 |
]. |
|
1861 |
]. |
|
1862 |
]. |
|
1863 |
||
1864 |
contextView setList:text. |
|
1865 |
receiverInspector release. |
|
1866 |
contextInspector release. |
|
1867 |
||
1868 |
m notNil ifTrue:[ |
|
1869 |
m disable:#removeBreakpoint. |
|
1870 |
m disable:#implementors. |
|
1871 |
m disable:#senders. |
|
1872 |
m disable:#browseClass. |
|
1873 |
]. |
|
1874 |
^ true |
|
1875 |
! |
|
1876 |
||
1877 |
showError:message |
|
1878 |
codeView contents:(resources string:message). |
|
1879 |
shown ifTrue:[ |
|
1880 |
exclusive ifTrue:[ |
|
1881 |
"/ consider this a kludge: |
|
1882 |
"/ if exclusive, cannot use flash, since it suspends |
|
1883 |
"/ (but we cannot suspend here ...) |
|
1884 |
codeView redrawInverted. device flush. |
|
1885 |
OperatingSystem millisecondDelay:200. |
|
1886 |
codeView redraw |
|
1887 |
] ifFalse:[ |
|
1888 |
codeView flash |
|
1889 |
] |
|
1890 |
] |
|
1891 |
||
1892 |
"Modified: 24.11.1995 / 22:07:30 / cg" |
|
1893 |
! |
|
1894 |
||
1895 |
showTerminated |
|
1896 |
self showError:'** the process has terminated **' |
|
1897 |
! |
|
1898 |
||
1899 |
stepping |
|
1900 |
^ stepping |
|
1901 |
! |
|
1902 |
||
1903 |
unstep |
|
1904 |
stepping := false. |
|
1905 |
bigStep := false. |
|
1906 |
steppedContextAddress := nil. |
|
1907 |
exitAction := nil |
|
1908 |
! |
|
1909 |
||
1910 |
updateContext |
|
1911 |
|oldContext idx| |
|
1912 |
||
1913 |
inspectedProcess state == #dead ifTrue:[ |
|
1914 |
self showTerminated. |
|
1915 |
^ self |
|
1916 |
]. |
|
1917 |
||
1918 |
oldContext := selectedContext. |
|
1919 |
(self setContext:(inspectedProcess suspendedContext)) ifTrue:[ |
|
1920 |
oldContext notNil ifTrue:[ |
|
1921 |
contextArray notNil ifTrue:[ |
|
1922 |
idx := contextArray identityIndexOf:oldContext. |
|
1923 |
idx ~~ 0 ifTrue:[ |
|
1924 |
self showSelection:idx |
|
1925 |
] ifFalse:[ |
|
1926 |
codeView contents:('** context returned **') |
|
1927 |
] |
|
1928 |
] |
|
1929 |
] |
|
1930 |
] |
|
1931 |
! ! |
|
1932 |
||
1933 |
!DebugView methodsFor:'private control loop'! |
|
1934 |
||
1935 |
controlLoop |
|
1936 |
"this is a kludge: |
|
1937 |
start a dispatchloop which exits when |
|
1938 |
either continue, return or step is pressed |
|
1939 |
" |
|
1940 |
||
1941 |
haveControl := true. |
|
1942 |
[haveControl] whileTrue:[ |
|
1943 |
self controlLoopCatchingErrors |
|
1944 |
]. |
|
1945 |
catchBlock := nil. |
|
1946 |
! |
|
1947 |
||
1948 |
controlLoopCatchingErrors |
|
1949 |
"setup a self removing catch-block" |
|
1950 |
catchBlock := [catchBlock := nil. ^ nil]. |
|
1951 |
||
1952 |
(exclusive or:[windowGroup isNil]) ifTrue:[ |
|
1953 |
"if we do not have multiple processes or its a system process |
|
1954 |
we start another dispatch loop, which exits when |
|
1955 |
either continue, return or step is pressed |
|
1956 |
or (via the catchBlock) if an error occurs. |
|
1957 |
Since our display is an extra exclusive one, |
|
1958 |
all processing for normal views stops here ... |
|
1959 |
" |
|
1960 |
||
1961 |
WindowGroup setActiveGroup:windowGroup. |
|
1962 |
SignalSet anySignal handle:[:ex | |
|
1963 |
self showError:'*** Error in modal debugger: |
|
1964 |
||
1965 |
>>>> Signal: ' , ex signal printString , ' |
|
1966 |
>>>> In: ' , ex suspendedContext printString , ' |
|
1967 |
>>>> Message: ' , ex errorString , ' |
|
1968 |
||
1969 |
cought & ignored.'. |
|
1970 |
ex return. |
|
1971 |
] do:[ |
|
1972 |
Object userNotificationSignal handle:[:ex | |
|
1973 |
self showError:ex errorString |
|
1974 |
] do:[ |
|
1975 |
device dispatchModalWhile:[haveControl]. |
|
1976 |
] |
|
1977 |
]. |
|
1978 |
WindowGroup setActiveGroup:nil. |
|
1979 |
] ifFalse:[ |
|
1980 |
"we do have multiple processes - |
|
1981 |
simply enter the DebugViews-Windowgroup event loop. |
|
1982 |
effectively suspending event processing for the currently |
|
1983 |
active group. |
|
1984 |
" |
|
1985 |
SignalSet anySignal handle:[:ex | |
|
1986 |
|answer| |
|
1987 |
||
1988 |
self topView raiseDeiconified. |
|
1989 |
ex signal == Exception recursiveExceptionSignal ifTrue:[ |
|
1990 |
self showError:'*** Recursive error in debugger: |
|
1991 |
||
1992 |
>>>> Signal: ' , ex signal printString , ' |
|
1993 |
>>>> In: ' , ex suspendedContext printString , ' |
|
1994 |
>>>> Message: ' , ex errorString , ' |
|
1995 |
||
1996 |
cought & ignored.'. |
|
1997 |
ex return |
|
1998 |
]. |
|
1999 |
answer := Dialog |
|
2000 |
choose:('error in debugger: ' , ex errorString , '\\debug again ?') withCRs |
|
2001 |
labels:#('debug' 'proceed' 'cancel' ) |
|
2002 |
values:#(#debug #proceed #cancel) |
|
2003 |
default:#cancel. |
|
2004 |
answer == #debug ifTrue:[ |
|
2005 |
Debugger enterUnconditional:(ex suspendedContext) withMessage:'error in debugger: ' , ex errorString. |
|
2006 |
ex proceed. |
|
2007 |
]. |
|
2008 |
answer == #proceed ifTrue:[ |
|
2009 |
ex proceed. |
|
2010 |
]. |
|
2011 |
ex return. |
|
2012 |
] do:[ |
|
2013 |
windowGroup eventLoopWhile:[true] onLeave:[] |
|
2014 |
]. |
|
2015 |
]. |
|
2016 |
catchBlock := nil. |
|
2017 |
||
2018 |
"Created: 24.11.1995 / 20:33:45 / cg" |
|
2019 |
"Modified: 24.11.1995 / 22:57:41 / cg" |
|
2020 |
! ! |
|
2021 |
||
0 | 2022 |
!DebugView methodsFor:'user interaction'! |
2023 |
||
266 | 2024 |
codeAccept:someCode |
2025 |
"user wants some code to be recompiled - must unwind stack since everything above |
|
2026 |
and including selected method cannot be continued." |
|
2027 |
||
2028 |
" |
|
2029 |
actually, this is not true, since the active methods will still be |
|
2030 |
executed correctly - however, the code shown in the debugger is no |
|
2031 |
longer in sync (showing the new code) with the executed code. |
|
2032 |
Therefore, we hide those contexts to avoid confusion .... |
|
2033 |
If you dont like this behavior, remove the 'inspecting ifFalse:' check below" |
|
2034 |
||
2035 |
"walk up context chain and find highest context which is either the selected context, |
|
2036 |
or - if its a block-context - whose home is the selected context" |
|
2037 |
||
2038 |
|con top sel implementorClass method newMethod| |
|
2039 |
||
2040 |
codeView cursor:Cursor execute. |
|
2041 |
||
2042 |
" |
|
2043 |
find the method-home context for this one |
|
2044 |
" |
|
2045 |
con := selectedContext. |
|
2046 |
top := con. |
|
2047 |
[con notNil] whileTrue:[ |
|
2048 |
(con methodHome == selectedContext) ifTrue:[ |
|
2049 |
top := con |
|
2050 |
]. |
|
2051 |
con := con sender |
|
2052 |
]. |
|
2053 |
" |
|
2054 |
use class&selector to find the method for the compilation |
|
2055 |
and compile. |
|
2056 |
" |
|
2057 |
sel := selectedContext selector. |
|
2058 |
implementorClass := selectedContext methodClass. |
|
2059 |
method := implementorClass compiledMethodAt:sel. |
|
2060 |
newMethod := implementorClass compilerClass |
|
2061 |
compile:someCode |
|
2062 |
forClass:implementorClass |
|
2063 |
inCategory:(method category) |
|
2064 |
notifying:codeView. |
|
2065 |
||
2066 |
inspecting ifFalse:[ |
|
2067 |
" |
|
2068 |
if it worked, remove everything up to and including top |
|
2069 |
from context chain |
|
2070 |
" |
|
2071 |
(newMethod notNil and:[newMethod ~~ #Error]) ifTrue:[ |
|
2072 |
self setContext:(top sender). |
|
2073 |
||
2074 |
" |
|
2075 |
continue/step is no longer possible |
|
2076 |
" |
|
2077 |
canContinue := false. |
|
2078 |
self showSelection:1. |
|
2079 |
exitAction := #return |
|
2080 |
]. |
|
2081 |
]. |
|
2082 |
codeView cursor:Cursor normal |
|
2083 |
! |
|
2084 |
||
2085 |
destroy |
|
2086 |
"closing the debugger implies an abort or continue" |
|
2087 |
||
2088 |
contextView middleButtonMenu hide. |
|
2089 |
||
2090 |
" |
|
2091 |
we manually release all private data, since the Debugger |
|
2092 |
is cached for reuse - thus the memory would not be collectable |
|
2093 |
otherwise. |
|
2094 |
" |
|
2095 |
codeView acceptAction:nil. |
|
2096 |
codeView doItAction:nil. |
|
2097 |
codeView contents:nil. |
|
2098 |
catchBlock := nil. |
|
2099 |
||
2100 |
receiverInspector release. |
|
2101 |
contextInspector release. |
|
2102 |
inspectedProcess := nil. |
|
2103 |
exitAction := nil. |
|
2104 |
contextArray := nil. |
|
2105 |
selectedContext := actualContext := nil. |
|
2106 |
grabber := nil. |
|
2107 |
self autoUpdateOff. |
|
2108 |
||
2109 |
inspecting ifFalse:[ |
|
2110 |
exclusive ifTrue:[ |
|
2111 |
CachedExclusive == self ifTrue:[ |
|
2112 |
CachedExclusive := nil. |
|
2113 |
] |
|
2114 |
] ifFalse:[ |
|
2115 |
CachedDebugger == self ifTrue:[ |
|
2116 |
CachedDebugger := nil |
|
2117 |
] |
|
2118 |
]. |
|
2119 |
||
2120 |
inspecting ifFalse:[ |
|
2121 |
canAbort ifTrue:[ |
|
2122 |
self doAbort. |
|
2123 |
] ifFalse:[ |
|
2124 |
self doContinue |
|
2125 |
] |
|
2126 |
]. |
|
2127 |
]. |
|
2128 |
super destroy "/ 1.12.94 |
|
2129 |
! |
|
2130 |
||
0 | 2131 |
showSelection:lineNr |
2132 |
"user clicked on a header line - show selected code in textView" |
|
2133 |
||
56 | 2134 |
|con homeContext sel method code canAccept |
105 | 2135 |
implementorClass lineNrInMethod rec m line |
193
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2136 |
sender selSender tryVars possibleBlocks errMsg |
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2137 |
mthd cls w| |
0 | 2138 |
|
2139 |
contextArray notNil ifTrue:[ |
|
45 | 2140 |
lineNr <= contextArray size ifTrue:[ |
2141 |
con := contextArray at:lineNr. |
|
2142 |
]. |
|
2143 |
" |
|
2144 |
clicking on the '** ...'-line shows more ... |
|
2145 |
" |
|
2146 |
con isNil ifTrue:[ |
|
2147 |
line := contextView list at:lineNr. |
|
2148 |
(line startsWith:'**') ifTrue:[ |
|
73 | 2149 |
self showMore. |
45 | 2150 |
contextView selection:lineNr. |
2151 |
con := contextArray at:lineNr |
|
108 | 2152 |
]. |
2153 |
con isNil ifTrue:[^ self]. |
|
45 | 2154 |
]. |
105 | 2155 |
|
2156 |
" |
|
2157 |
give it to the (lower right) inspector |
|
2158 |
" |
|
2159 |
contextInspector inspect:con. |
|
2160 |
||
2161 |
" |
|
2162 |
get the home context |
|
2163 |
" |
|
45 | 2164 |
con isBlockContext ifTrue:[ |
2165 |
homeContext := con methodHome |
|
2166 |
] ifFalse:[ |
|
2167 |
homeContext := con |
|
2168 |
]. |
|
107 | 2169 |
con canReturn ifTrue:[ |
2170 |
returnButton enable. restartButton enable. |
|
2171 |
] ifFalse:[ |
|
2172 |
returnButton disable. restartButton disable. |
|
2173 |
]. |
|
105 | 2174 |
|
2175 |
lineNrInMethod := con lineNumber. |
|
2176 |
||
2177 |
canAccept := false. |
|
2178 |
||
55 | 2179 |
homeContext isNil ifTrue:[ |
2180 |
" |
|
2181 |
mhmh - an optimized block |
|
2182 |
should get the block here, and get the method from |
|
2183 |
that one ... |
|
105 | 2184 |
But in 2.10.x, there is no easy way to get to the block |
2185 |
since that one is not in the context. |
|
2186 |
Starting with 2.11, the new block calling scheme will fix this. |
|
55 | 2187 |
" |
105 | 2188 |
|
2189 |
"temporary kludge - peek into the sender context. |
|
2190 |
If its a do-like method and there is a single block variable |
|
2191 |
in the args or temporaries, that must be the one. |
|
2192 |
This helps in some cases. |
|
2193 |
" |
|
2194 |
(sender := con sender) notNil ifTrue:[ |
|
2195 |
tryVars := false. |
|
2196 |
(selSender := sender selector) notNil ifTrue:[ |
|
2197 |
(selSender endsWith:'do:') ifTrue:[ |
|
2198 |
tryVars := true. |
|
2199 |
] ifFalse:[ |
|
2200 |
(selSender endsWith:'Do:') ifTrue:[ |
|
2201 |
tryVars := true. |
|
2202 |
] |
|
2203 |
] |
|
2204 |
]. |
|
2205 |
tryVars ifTrue:[ |
|
2206 |
possibleBlocks := sender argsAndVars select:[:v | v isBlock]. |
|
2207 |
possibleBlocks := possibleBlocks select:[:b | b home isNil]. |
|
2208 |
possibleBlocks size == 1 ifTrue:[ |
|
2209 |
method := possibleBlocks first method. |
|
2210 |
]. |
|
2211 |
] |
|
2212 |
]. |
|
2213 |
||
55 | 2214 |
] ifFalse:[ |
105 | 2215 |
"fetch rec here - so we wont need context in doItAction" |
2216 |
rec := homeContext receiver. |
|
2217 |
||
45 | 2218 |
sel := homeContext selector. |
2219 |
sel notNil ifTrue:[ |
|
56 | 2220 |
canAccept := true. |
2221 |
||
55 | 2222 |
implementorClass := homeContext methodClass. |
45 | 2223 |
implementorClass isNil ifTrue:[ |
56 | 2224 |
" |
57 | 2225 |
special: look if this context was created by |
56 | 2226 |
valueWithReceiver kind of method invocation; |
2227 |
if so, grab the method from the sender and show it |
|
2228 |
" |
|
124 | 2229 |
((sender := con sender) notNil |
2230 |
and:[(sender selector startsWith:'valueWithReceiver:') |
|
2231 |
and:[sender receiver isMethod]]) ifTrue:[ |
|
2232 |
method := sender receiver. |
|
56 | 2233 |
code := method source. |
2234 |
canAccept := false. |
|
2235 |
] ifFalse:[ |
|
105 | 2236 |
(method := con method) notNil ifTrue:[ |
57 | 2237 |
code := method source. |
2238 |
canAccept := false. |
|
2239 |
] |
|
56 | 2240 |
] |
45 | 2241 |
] ifFalse:[ |
2242 |
method := implementorClass compiledMethodAt:sel. |
|
105 | 2243 |
]. |
2244 |
] |
|
2245 |
]. |
|
2246 |
||
2247 |
code isNil ifTrue:[ |
|
124 | 2248 |
errMsg := nil. |
105 | 2249 |
method notNil ifTrue:[ |
2250 |
code := method source. |
|
2251 |
code isNil ifTrue:[ |
|
2252 |
method sourceFilename notNil ifTrue:[ |
|
2253 |
codeView contents:(resources |
|
45 | 2254 |
string:'** no sourcefile: %1 **' |
52 | 2255 |
with:method sourceFilename). |
105 | 2256 |
codeView flash |
2257 |
] ifFalse:[ |
|
124 | 2258 |
errMsg := '** no source **' |
45 | 2259 |
] |
105 | 2260 |
] |
2261 |
] ifFalse:[ |
|
2262 |
homeContext isNil ifTrue:[ |
|
124 | 2263 |
errMsg := '** sorry; cannot show code of all optimized blocks (yet) **'. |
45 | 2264 |
] ifFalse:[ |
124 | 2265 |
errMsg := '** no method - no source **' |
105 | 2266 |
] |
124 | 2267 |
]. |
2268 |
errMsg notNil ifTrue:[ |
|
2269 |
self showError:errMsg |
|
45 | 2270 |
] |
2271 |
]. |
|
105 | 2272 |
|
2273 |
code isNil ifTrue:[ |
|
2274 |
canAccept := false. |
|
2275 |
] ifFalse:[ |
|
2276 |
codeView contents:code. |
|
2277 |
(lineNrInMethod notNil and:[lineNrInMethod ~~ 0]) ifTrue:[ |
|
110 | 2278 |
"/ lineNrInMethod > codeView list size ifTrue:[ |
2279 |
"/ lineNrInMethod := codeView list size + 1 |
|
2280 |
"/ ]. |
|
2281 |
"/ codeView selectLine:lineNrInMethod. |
|
2282 |
"/ codeView makeSelectionVisible |
|
132 | 2283 |
|
110 | 2284 |
lineNrInMethod <= codeView list size ifTrue:[ |
132 | 2285 |
(lineNrInMethod == 255 |
2286 |
and:[method notNil |
|
2287 |
and:[method code isNil]]) ifTrue:[ |
|
2288 |
"/ means: do not really know in interpreted methods |
|
2289 |
codeView selectFromLine:255 col:1 toLine:codeView list size + 1 col:0. |
|
2290 |
] ifFalse:[ |
|
2291 |
codeView selectLine:lineNrInMethod. |
|
2292 |
]. |
|
110 | 2293 |
codeView makeSelectionVisible |
2294 |
] |
|
105 | 2295 |
]. |
2296 |
]. |
|
2297 |
||
2298 |
canAccept ifTrue:[ |
|
2299 |
codeView acceptAction:[:code | self codeAccept:code asString] |
|
2300 |
] ifFalse:[ |
|
2301 |
codeView acceptAction:nil. |
|
2302 |
]. |
|
2303 |
||
45 | 2304 |
receiverInspector inspect:rec. |
105 | 2305 |
|
2306 |
" |
|
2307 |
the one below is wrong: currently, the |
|
2308 |
evaluator cannot handle passed contexts. |
|
2309 |
Once it does, pass con as in:-arg |
|
2310 |
" |
|
45 | 2311 |
codeView doItAction:[:theCode | |
100 | 2312 |
rec class evaluatorClass |
45 | 2313 |
evaluate:theCode |
105 | 2314 |
in:nil "/ *** con |
45 | 2315 |
receiver:rec |
2316 |
notifying:codeView |
|
2317 |
logged:true |
|
2318 |
ifFail:nil |
|
2319 |
]. |
|
2320 |
||
57 | 2321 |
selectedContext := homeContext. |
2322 |
actualContext := con |
|
0 | 2323 |
]. |
2324 |
||
105 | 2325 |
"clear out locals to prevent keeping around unneeded contexts |
2326 |
(due to the block held in codeView). |
|
2327 |
(not really needed, since stuff gets collected away sooner or later ... |
|
2328 |
... but this makes it a bit sooner) |
|
2329 |
" |
|
0 | 2330 |
con := nil. |
29 | 2331 |
homeContext := nil. |
2332 |
||
105 | 2333 |
" |
2334 |
enable/disable some menu items |
|
2335 |
" |
|
45 | 2336 |
m := contextView middleButtonMenu. |
193
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2337 |
(m notNil and:[selectedContext notNil]) ifTrue:[ |
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2338 |
m enableAll:#(implementors senders inspectContext skip). |
29 | 2339 |
|
45 | 2340 |
(method notNil and:[method isWrapped]) ifTrue:[ |
73 | 2341 |
m enable:#removeBreakpoint. |
45 | 2342 |
] ifFalse:[ |
73 | 2343 |
m disable:#removeBreakpoint. |
193
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2344 |
]. |
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2345 |
|
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2346 |
mthd := selectedContext method. |
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2347 |
mthd notNil ifTrue:[ |
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2348 |
w := mthd who. |
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2349 |
]. |
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2350 |
m enable:#browseClass. |
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2351 |
w notNil ifTrue:[ |
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2352 |
cls := w at:1 |
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2353 |
]. |
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2354 |
cls notNil ifTrue:[ |
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2355 |
m enableAll:#(browseClass browseClassHierarchy browseFullClassProtocol). |
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2356 |
] ifFalse:[ |
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2357 |
m disableAll:#(browseClass browseClassHierarchy browseFullClassProtocol). |
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2358 |
]. |
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2359 |
(w notNil and:[(w at:2) notNil]) ifTrue:[ |
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2360 |
m enable:#browse |
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2361 |
] ifFalse:[ |
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2362 |
m disable:#browse |
45 | 2363 |
] |
29 | 2364 |
] |
193
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2365 |
|
8d0b4658249c
added browse-menu function; disable inappropriate menu items; fixed walkback-copy
Claus Gittinger <cg@exept.de>
parents:
189
diff
changeset
|
2366 |
"Modified: 22.11.1995 / 21:43:40 / cg" |
73 | 2367 |
! ! |
2368 |
||
266 | 2369 |
!DebugView class methodsFor:'documentation'! |
78 | 2370 |
|
266 | 2371 |
version |
269 | 2372 |
^ '$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.57 1995-12-10 15:17:04 cg Exp $' |
0 | 2373 |
! ! |