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
|
7
|
14 |
instanceVariableNames:'busy haveControl exitAction canContinue
|
45
|
15 |
contextView codeView
|
|
16 |
receiverInspector contextInspector
|
|
17 |
contextArray selectedContext
|
|
18 |
catchBlock grabber traceView tracing
|
53
|
19 |
bigStep skipLineNr steppedContextAddress canAbort
|
45
|
20 |
abortButton terminateButton continueButton
|
|
21 |
stepButton sendButton returnButton restartButton
|
|
22 |
exclusive inspecting nChainShown
|
|
23 |
inspectedProcess updateProcess
|
|
24 |
monitorToggle'
|
52
|
25 |
classVariableNames:'CachedDebugger CachedExclusive MoreDebuggingDetail'
|
0
|
26 |
poolDictionaries:''
|
|
27 |
category:'Interface-Debugger'
|
|
28 |
!
|
|
29 |
|
|
30 |
DebugView comment:'
|
4
|
31 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
45
|
32 |
All Rights Reserved
|
0
|
33 |
|
56
|
34 |
$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.20 1994-11-28 21:11:09 claus Exp $
|
29
|
35 |
'!
|
|
36 |
|
|
37 |
!DebugView class methodsFor:'documentation'!
|
|
38 |
|
|
39 |
copyright
|
|
40 |
"
|
|
41 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
45
|
42 |
All Rights Reserved
|
29
|
43 |
|
|
44 |
This software is furnished under a license and may be used
|
|
45 |
only in accordance with the terms of that license and with the
|
|
46 |
inclusion of the above copyright notice. This software may not
|
|
47 |
be provided or otherwise made available to, or used by, any
|
|
48 |
other person. No title to or ownership of the software is
|
|
49 |
hereby transferred.
|
|
50 |
"
|
|
51 |
!
|
0
|
52 |
|
29
|
53 |
version
|
|
54 |
"
|
56
|
55 |
$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.20 1994-11-28 21:11:09 claus Exp $
|
29
|
56 |
"
|
|
57 |
!
|
0
|
58 |
|
29
|
59 |
documentation
|
|
60 |
"
|
|
61 |
this class implements a graphical debugger interface.
|
|
62 |
The debugger usually sits on top of the faulting process,
|
|
63 |
taking over its event processing. Thus only the 'stopped' process is affected;
|
|
64 |
other processes continue to respond to events.
|
|
65 |
|
|
66 |
The one exception is when an error occurs within the dispatcher process
|
|
67 |
or in one of the eventhandler processes - in this case, the debugger
|
|
68 |
will sit on an exclusive display connection.
|
|
69 |
|
|
70 |
The whole debugging will be changed, once the required process primitives
|
|
71 |
are available, which allow control of another processes execution
|
|
72 |
(i.e. single-step, restart & return). The setup will be changed then,
|
|
73 |
to have the debugger control the debuggee (i.e. two processes)
|
35
|
74 |
|
|
75 |
See additional information in 'doc/misc/debugger.doc'.
|
53
|
76 |
|
|
77 |
Notice: the DebugView class caches the last used debugger in a class
|
|
78 |
variable. It may happen, that a malfunctioning debugger (for example,
|
|
79 |
a halfway destoyed one) is kept there. You will notice this, if a
|
|
80 |
debugger comes up without showing any contents. In this case, close
|
|
81 |
(or destroy) the broken debugView, and execute
|
|
82 |
Debugger newDebugger
|
|
83 |
which removes the cached debugger and forces creation of a new one the
|
|
84 |
next time. This is a temporary workaround - the debugger will be fixed to
|
|
85 |
avoid this problem.
|
29
|
86 |
"
|
|
87 |
! !
|
0
|
88 |
|
|
89 |
!DebugView class methodsFor:'instance creation'!
|
|
90 |
|
|
91 |
new
|
56
|
92 |
"return a new DebugView - return a cached debugger if it already
|
0
|
93 |
exists"
|
|
94 |
|
29
|
95 |
|debugger active|
|
0
|
96 |
|
13
|
97 |
"need a blocking debugger if no processes or
|
29
|
98 |
or if its a timing/interrupt process
|
|
99 |
(because otherwise we would not get any events here ..."
|
|
100 |
|
|
101 |
active := Processor activeProcess.
|
13
|
102 |
|
29
|
103 |
(ProcessorScheduler isPureEventDriven
|
53
|
104 |
or:[(active priority >= Processor userInterruptPriority)
|
56
|
105 |
or:[active id == 0
|
|
106 |
or:[active nameOrId endsWith:'dispatcher']]]) ifTrue:[
|
45
|
107 |
CachedExclusive isNil ifTrue:[
|
|
108 |
debugger := self newExclusive
|
|
109 |
] ifFalse:[
|
|
110 |
debugger := CachedExclusive.
|
|
111 |
CachedExclusive := nil.
|
|
112 |
].
|
7
|
113 |
] ifFalse:[
|
45
|
114 |
CachedDebugger isNil ifTrue:[
|
|
115 |
debugger := super new.
|
|
116 |
debugger label:'Debugger'.
|
|
117 |
debugger icon:(Form fromFile:'Debugger.xbm' resolution:100).
|
|
118 |
] ifFalse:[
|
|
119 |
debugger := CachedDebugger.
|
|
120 |
CachedDebugger := nil.
|
|
121 |
]
|
7
|
122 |
].
|
|
123 |
^ debugger
|
0
|
124 |
!
|
|
125 |
|
13
|
126 |
newExclusive
|
|
127 |
"return a debugger for exclusive display access"
|
|
128 |
|
|
129 |
|debugger|
|
|
130 |
|
|
131 |
debugger := super on:ModalDisplay.
|
|
132 |
debugger label:'Debugger'.
|
|
133 |
debugger icon:(Form fromFile:'Debugger.xbm' resolution:100).
|
|
134 |
debugger exclusive:true.
|
|
135 |
^ debugger
|
|
136 |
!
|
|
137 |
|
0
|
138 |
newDebugger
|
|
139 |
"force creation of a new debugger"
|
|
140 |
|
29
|
141 |
CachedDebugger := nil.
|
|
142 |
CachedExclusive := nil
|
0
|
143 |
|
|
144 |
"DebugView newDebugger"
|
|
145 |
!
|
|
146 |
|
|
147 |
enterWithMessage:aString
|
|
148 |
"the standard way of entering the debugger - sent from Objects
|
|
149 |
error- and halt messages"
|
|
150 |
|
29
|
151 |
thisContext isRecursive ifTrue:[
|
45
|
152 |
^ MiniDebugger enterWithMessage:aString
|
29
|
153 |
].
|
|
154 |
^ self enter:(thisContext sender) withMessage:aString
|
|
155 |
|
|
156 |
"Debugger enterWithMessage:'hi there'"
|
|
157 |
!
|
|
158 |
|
|
159 |
enter
|
|
160 |
"another way of entering the debugger"
|
|
161 |
|
|
162 |
^ self enter:(thisContext sender) withMessage:'Debugger'
|
|
163 |
|
|
164 |
"Debugger enter"
|
|
165 |
!
|
|
166 |
|
|
167 |
enter:aContext
|
|
168 |
"enter the debugger on aContext"
|
|
169 |
|
|
170 |
^ self enter:aContext withMessage:'Debugger'
|
|
171 |
!
|
|
172 |
|
|
173 |
enter:aContext withMessage:aString
|
53
|
174 |
"enter a debugger; if this is a recursive invocation, enter
|
|
175 |
a MiniDebugger instead.
|
|
176 |
This is the standard way of entering the debugger;
|
|
177 |
sent from error- and halt messages."
|
0
|
178 |
|
14
|
179 |
thisContext isRecursive ifTrue:[
|
45
|
180 |
^ MiniDebugger enterWithMessage:'recursive error'.
|
14
|
181 |
].
|
53
|
182 |
^ self enterUnconditional:aContext withMessage:aString
|
|
183 |
!
|
|
184 |
|
|
185 |
enterUnconditional:aContext withMessage:aString
|
|
186 |
"enter a debugger - do not check for recursive invocation"
|
|
187 |
|
|
188 |
|aDebugger|
|
14
|
189 |
|
0
|
190 |
StepInterruptPending := nil.
|
7
|
191 |
aDebugger := self new.
|
29
|
192 |
aDebugger label:aString , ' (' , Processor activeProcess nameOrId , ')'.
|
|
193 |
aDebugger enter:aContext.
|
0
|
194 |
^ nil
|
|
195 |
|
|
196 |
"nil halt"
|
|
197 |
!
|
|
198 |
|
29
|
199 |
openOn:aProcess
|
|
200 |
"start a debugger on aProcess
|
|
201 |
(actually not more than a good-looking inspector)"
|
15
|
202 |
|
52
|
203 |
|aDebugger label nm|
|
15
|
204 |
|
|
205 |
aDebugger := super new.
|
|
206 |
aDebugger icon:(Form fromFile:'Debugger.xbm' resolution:100).
|
29
|
207 |
aProcess notNil ifTrue:[
|
52
|
208 |
nm := aProcess name.
|
|
209 |
nm notNil ifTrue:[
|
|
210 |
nm := (aProcess nameOrId contractTo:17) , '-' , aProcess id printString
|
|
211 |
] ifFalse:[
|
|
212 |
nm := aProcess id printString
|
|
213 |
].
|
|
214 |
label := 'Debugger [' , nm , ']'.
|
29
|
215 |
] ifFalse:[
|
45
|
216 |
label := 'no process'
|
29
|
217 |
].
|
|
218 |
aDebugger label:label.
|
15
|
219 |
aDebugger iconLabel:'Debugger'.
|
|
220 |
aDebugger openOn:aProcess.
|
|
221 |
^ nil
|
0
|
222 |
! !
|
|
223 |
|
|
224 |
!DebugView methodsFor:'initialization'!
|
|
225 |
|
|
226 |
initialize
|
45
|
227 |
|v panel hpanel bpanel dummy|
|
0
|
228 |
|
|
229 |
super initialize.
|
|
230 |
|
|
231 |
font := font on:device.
|
|
232 |
|
7
|
233 |
busy := false.
|
14
|
234 |
exclusive := false.
|
29
|
235 |
inspecting := false.
|
0
|
236 |
exitAction := nil.
|
10
|
237 |
bigStep := false.
|
29
|
238 |
canContinue := false.
|
|
239 |
canAbort := false.
|
0
|
240 |
|
|
241 |
bpanel := HorizontalPanelView
|
45
|
242 |
origin:(0.0 @ 0.0)
|
|
243 |
extent:(1.0 @ (font height * 2))
|
|
244 |
in:self.
|
0
|
245 |
bpanel layout:#left.
|
|
246 |
|
7
|
247 |
terminateButton := Button
|
45
|
248 |
label:(resources at:'terminate')
|
|
249 |
action:[terminateButton turnOffWithoutRedraw. self doTerminate]
|
|
250 |
in:bpanel.
|
|
251 |
dummy := View extent:(20 @ 5) in:bpanel.
|
52
|
252 |
dummy borderWidth:0; level:0.
|
45
|
253 |
|
0
|
254 |
abortButton := Button
|
45
|
255 |
label:(resources at:'abort')
|
|
256 |
action:[abortButton turnOffWithoutRedraw. self doAbort]
|
|
257 |
in:bpanel.
|
29
|
258 |
returnButton := Button
|
45
|
259 |
label:(resources at:'return')
|
|
260 |
action:[returnButton turnOff. self doReturn]
|
|
261 |
in:bpanel.
|
20
|
262 |
|
|
263 |
restartButton := Button
|
45
|
264 |
label:(resources at:'restart')
|
|
265 |
action:[restartButton turnOff. self doRestart]
|
|
266 |
in:bpanel.
|
|
267 |
|
|
268 |
dummy := View extent:(20 @ 5) in:bpanel.
|
52
|
269 |
dummy borderWidth:0; level:0.
|
20
|
270 |
|
0
|
271 |
continueButton := Button
|
45
|
272 |
label:(resources at:'continue')
|
|
273 |
action:[continueButton turnOffWithoutRedraw. self doContinue]
|
|
274 |
in:bpanel.
|
|
275 |
dummy := View extent:(20 @ 5) in:bpanel.
|
52
|
276 |
dummy borderWidth:0; level:0.
|
45
|
277 |
|
0
|
278 |
stepButton := Button
|
45
|
279 |
label:(resources at:'step')
|
|
280 |
action:[stepButton turnOff. self doStep]
|
|
281 |
in:bpanel.
|
0
|
282 |
sendButton := Button
|
45
|
283 |
label:(resources at:'send')
|
|
284 |
action:[sendButton turnOff. self doSend]
|
|
285 |
in:bpanel.
|
0
|
286 |
|
|
287 |
panel := VariableVerticalPanel
|
45
|
288 |
origin:(0.0 @ bpanel height)
|
|
289 |
corner:(1.0 @ 1.0)
|
|
290 |
in:self.
|
0
|
291 |
|
|
292 |
v := ScrollableView for:SelectionInListView in:panel.
|
|
293 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 0.25).
|
|
294 |
|
|
295 |
contextView := v scrolledView.
|
|
296 |
contextView action:[:lineNr | self showSelection:lineNr].
|
|
297 |
|
|
298 |
v := ScrollableView for:CodeView in:panel.
|
|
299 |
v origin:(0.0 @ 0.25) corner:(1.0 @ 0.75).
|
|
300 |
|
|
301 |
codeView := v scrolledView.
|
|
302 |
|
|
303 |
hpanel := VariableHorizontalPanel in:panel.
|
|
304 |
hpanel origin:(0.0 @ 0.75) corner:(1.0 @ 1.0).
|
|
305 |
|
|
306 |
receiverInspector := InspectorView
|
45
|
307 |
origin:(0.0 @ 0.0) corner:(0.5 @ 1.0)
|
|
308 |
in:hpanel.
|
0
|
309 |
|
|
310 |
contextInspector := ContextInspectorView
|
45
|
311 |
origin:(0.5 @ 0.0) corner:(1.0 @ 1.0)
|
|
312 |
in:hpanel
|
0
|
313 |
!
|
|
314 |
|
|
315 |
initializeMiddleButtonMenu
|
45
|
316 |
|labels m|
|
0
|
317 |
|
22
|
318 |
labels := resources array:#(
|
45
|
319 |
'show more'
|
|
320 |
'-'
|
22
|
321 |
"
|
45
|
322 |
'continue'
|
|
323 |
'terminate'
|
|
324 |
'abort'
|
|
325 |
'-'
|
|
326 |
'step'
|
|
327 |
'send'
|
|
328 |
'-'
|
|
329 |
'return'
|
|
330 |
'restart'
|
|
331 |
'-'
|
22
|
332 |
"
|
45
|
333 |
'remove breakpoint'
|
48
|
334 |
'remove all trace & breakpoints'
|
45
|
335 |
'-'
|
|
336 |
'implementors ...'
|
|
337 |
'senders ...'
|
|
338 |
'-'
|
|
339 |
'inspect context'
|
|
340 |
'-'
|
|
341 |
'quickTerminate'
|
|
342 |
'-'
|
|
343 |
'exit smalltalk'
|
|
344 |
).
|
0
|
345 |
|
45
|
346 |
m := (PopUpMenu
|
|
347 |
labels:labels
|
|
348 |
selectors:#(
|
|
349 |
doShowMore
|
|
350 |
nil
|
|
351 |
"
|
|
352 |
doContinue
|
|
353 |
doTerminate
|
|
354 |
doAbort
|
|
355 |
nil
|
|
356 |
doStep
|
|
357 |
doSend
|
|
358 |
nil
|
|
359 |
doReturn
|
|
360 |
doRestart
|
|
361 |
nil
|
22
|
362 |
"
|
45
|
363 |
doRemoveBreakpoint
|
48
|
364 |
doRemoveAllBreakpoints
|
45
|
365 |
nil
|
|
366 |
doImplementors
|
|
367 |
doSenders
|
|
368 |
nil
|
|
369 |
doInspectContext
|
|
370 |
nil
|
|
371 |
doQuickTerminate
|
|
372 |
nil
|
|
373 |
doExit
|
|
374 |
)
|
|
375 |
receiver:self
|
|
376 |
for:contextView).
|
|
377 |
|
|
378 |
contextView middleButtonMenu:m.
|
|
379 |
|
|
380 |
inspecting ifTrue:[
|
|
381 |
m notNil ifTrue:[
|
|
382 |
m disable:#doTraceStep.
|
|
383 |
m disable:#doRemoveBreakpoint.
|
|
384 |
].
|
|
385 |
]
|
0
|
386 |
!
|
|
387 |
|
46
|
388 |
reinitialize
|
|
389 |
super reinitialize.
|
|
390 |
"
|
|
391 |
this is reached, when we come up after a restart.
|
|
392 |
ST/X does not support this, since the contexts are
|
|
393 |
all dead, and processes have been recreated.
|
|
394 |
"
|
|
395 |
super destroy
|
|
396 |
!
|
|
397 |
|
0
|
398 |
addToCurrentProject
|
|
399 |
"ignored here"
|
|
400 |
|
|
401 |
^ self
|
|
402 |
!
|
|
403 |
|
|
404 |
createOnTop
|
|
405 |
^ false "true"
|
13
|
406 |
!
|
|
407 |
|
|
408 |
realize
|
|
409 |
super realize.
|
|
410 |
exclusive ifTrue:[
|
45
|
411 |
windowGroup := nil
|
13
|
412 |
].
|
45
|
413 |
|
|
414 |
inspectedProcess notNil ifTrue:[
|
52
|
415 |
"
|
|
416 |
set prio somewhat higher (by 2, to allow walkBack-update process
|
|
417 |
to run between mine and the debugged processes prio)
|
|
418 |
"
|
45
|
419 |
Processor activeProcess
|
|
420 |
priority:(inspectedProcess priority + 2 min:16).
|
|
421 |
]
|
0
|
422 |
! !
|
|
423 |
|
|
424 |
!DebugView methodsFor:'interrupt handling'!
|
|
425 |
|
|
426 |
stepInterrupt
|
29
|
427 |
|where here s isWrap method lastWrappedConAddr wrappedMethod|
|
0
|
428 |
|
52
|
429 |
Processor activeProcess ~~ inspectedProcess ifTrue:[
|
|
430 |
'stray step interrupt' errorPrintNL.
|
|
431 |
^ self
|
|
432 |
].
|
|
433 |
|
29
|
434 |
"
|
52
|
435 |
kludge: check if we are in a wrapper methods hidden setup-sequence
|
29
|
436 |
"
|
|
437 |
here := thisContext. "stepInterrupt"
|
|
438 |
here := here sender. "the interrupted context"
|
|
439 |
|
|
440 |
"/ 'here in ' print.
|
|
441 |
"/ ((ObjectMemory addressOf:here) printStringRadix:16)print. '' printNL.
|
10
|
442 |
|
29
|
443 |
where := here.
|
|
444 |
isWrap := false.
|
|
445 |
wrappedMethod := nil.
|
|
446 |
5 timesRepeat:[
|
|
447 |
"/ where selector printNL.
|
56
|
448 |
where notNil ifTrue:[
|
|
449 |
method := where method.
|
|
450 |
(method notNil and:[method isWrapped]) ifTrue:[
|
|
451 |
"
|
|
452 |
in a wrapper method
|
|
453 |
"
|
|
454 |
wrappedMethod ~~ method ifTrue:[
|
|
455 |
wrappedMethod := method.
|
|
456 |
lastWrappedConAddr := ObjectMemory addressOf:where.
|
|
457 |
where sender receiver == method originalMethod ifFalse:[
|
|
458 |
isWrap := true.
|
|
459 |
]
|
|
460 |
] ifFalse:[
|
|
461 |
(ObjectMemory addressOf:where) == steppedContextAddress ifTrue:[
|
29
|
462 |
"/ 'change stepCon from: ' print.
|
|
463 |
"/ (steppedContextAddress printStringRadix:16)print.
|
|
464 |
"/ ' to: ' print.
|
|
465 |
"/ (lastWrappedConAddr printStringRadix:16)printNL.
|
|
466 |
|
56
|
467 |
steppedContextAddress := lastWrappedConAddr
|
|
468 |
]
|
45
|
469 |
]
|
56
|
470 |
].
|
|
471 |
where := where sender
|
|
472 |
]
|
29
|
473 |
].
|
|
474 |
|
|
475 |
isWrap ifTrue:[
|
|
476 |
"/ 'ignore wrap' printNL.
|
45
|
477 |
"
|
|
478 |
ignore, while in wrappers hidden setup
|
|
479 |
"
|
|
480 |
where := nil. here := nil.
|
|
481 |
ObjectMemory flushInlineCaches.
|
|
482 |
StepInterruptPending := true.
|
|
483 |
InterruptPending := true.
|
|
484 |
InStepInterrupt := nil.
|
|
485 |
^ nil
|
29
|
486 |
].
|
|
487 |
|
|
488 |
"
|
|
489 |
is this for a send or a step ?
|
|
490 |
"
|
|
491 |
bigStep ifTrue:[
|
45
|
492 |
"
|
|
493 |
a step - ignore all contexts below the interresting one
|
|
494 |
"
|
|
495 |
where := here. "the interrupted context"
|
|
496 |
(ObjectMemory addressOf:where) == steppedContextAddress ifFalse:[
|
|
497 |
where := where sender.
|
29
|
498 |
"/ 'look for ' print.
|
|
499 |
"/ (steppedContextAddress printStringRadix:16)print. '' printNL.
|
45
|
500 |
(ObjectMemory addressOf:where) == steppedContextAddress ifFalse:[
|
|
501 |
"
|
|
502 |
check if we are in a context below steppedContext
|
|
503 |
(i.e. if steppedContext can be reached from
|
|
504 |
interrupted context. Not using context-ref but its
|
|
505 |
address to avoid creation of many useless contexts.)
|
|
506 |
"
|
|
507 |
[where notNil] whileTrue:[
|
29
|
508 |
"/ ((ObjectMemory addressOf:where) printStringRadix:16)print. ' ' print.
|
|
509 |
"/ where selector printNL.
|
45
|
510 |
(ObjectMemory addressOf:where) == steppedContextAddress ifTrue:[
|
29
|
511 |
"/ 'found it - below' printNL.
|
45
|
512 |
"
|
|
513 |
found the interresting context somwehere up in the
|
|
514 |
chain. We seem to be still below the interresting one ...
|
|
515 |
"
|
|
516 |
tracing == true ifTrue:[
|
|
517 |
here printString printNewline
|
|
518 |
].
|
|
519 |
where := nil. here := nil.
|
|
520 |
"
|
|
521 |
yes, a context below
|
|
522 |
- continue and schedule another stepInterrupt.
|
|
523 |
Must flush caches since optimized methods not always
|
|
524 |
look for pending interrupts
|
|
525 |
"
|
|
526 |
ObjectMemory flushInlineCaches.
|
|
527 |
StepInterruptPending := true.
|
|
528 |
InterruptPending := true.
|
|
529 |
InStepInterrupt := nil.
|
|
530 |
^ nil
|
|
531 |
].
|
|
532 |
where := where sender
|
|
533 |
].
|
|
534 |
s := 'left stepped method'
|
|
535 |
] ifTrue:[
|
29
|
536 |
"/ 'found it right in sender' printNL.
|
45
|
537 |
s := 'after step'
|
|
538 |
].
|
|
539 |
] ifTrue:[
|
29
|
540 |
"/ 'found it right away' printNL.
|
45
|
541 |
s := 'after step'
|
|
542 |
].
|
|
543 |
tracing := false.
|
|
544 |
bigStep := false.
|
0
|
545 |
] ifFalse:[
|
29
|
546 |
|
45
|
547 |
"
|
|
548 |
a send
|
|
549 |
"
|
|
550 |
steppedContextAddress := nil.
|
|
551 |
s := 'after send'
|
0
|
552 |
].
|
7
|
553 |
|
29
|
554 |
name := Processor activeProcess nameOrId.
|
7
|
555 |
self label:(s , ' (process: ' , name , ')').
|
|
556 |
|
0
|
557 |
"release refs to context"
|
|
558 |
where := nil. here := nil.
|
29
|
559 |
self enter:thisContext sender
|
0
|
560 |
! !
|
|
561 |
|
|
562 |
!DebugView methodsFor:'basic'!
|
|
563 |
|
|
564 |
enter
|
22
|
565 |
"enter the debugger - on the sending context"
|
|
566 |
|
|
567 |
|where|
|
|
568 |
|
|
569 |
busy := true.
|
|
570 |
|
29
|
571 |
where := thisContext. "enter"
|
|
572 |
where := where sender. "the calling context"
|
22
|
573 |
where notNil ifTrue:[
|
45
|
574 |
(where receiver == DebugView) ifTrue:[
|
|
575 |
where := where sender
|
|
576 |
]
|
|
577 |
"where is now interrupted methods context"
|
22
|
578 |
].
|
|
579 |
^ self enter:where
|
|
580 |
!
|
|
581 |
|
|
582 |
enter:aContext
|
0
|
583 |
"enter the debugger - get and display the context, then start an
|
|
584 |
exclusive event loop on top of eveything else"
|
|
585 |
|
45
|
586 |
|con selection m|
|
0
|
587 |
|
14
|
588 |
busy := true.
|
29
|
589 |
inspecting := false.
|
52
|
590 |
inspectedProcess := Processor activeProcess.
|
10
|
591 |
bigStep := false.
|
29
|
592 |
nChainShown := 50.
|
10
|
593 |
|
|
594 |
"if debugger is entered while a box has grabbed the
|
|
595 |
pointer, we must ungrab - otherwise X wont talk to
|
29
|
596 |
us here
|
|
597 |
"
|
52
|
598 |
(grabber := device activePointerGrab) notNil ifTrue:[
|
|
599 |
device ungrabPointer
|
0
|
600 |
].
|
|
601 |
|
45
|
602 |
terminateButton enable.
|
|
603 |
|
7
|
604 |
drawableId notNil ifTrue:[
|
45
|
605 |
"not the first time - realize at old position"
|
|
606 |
terminateButton turnOffWithoutRedraw.
|
|
607 |
continueButton turnOffWithoutRedraw.
|
|
608 |
abortButton turnOffWithoutRedraw.
|
|
609 |
stepButton turnOffWithoutRedraw.
|
|
610 |
sendButton turnOffWithoutRedraw.
|
52
|
611 |
"/ self rerealize
|
7
|
612 |
] ifFalse:[
|
45
|
613 |
exclusive ifFalse:[
|
|
614 |
windowGroup isNil ifTrue:[
|
|
615 |
windowGroup := WindowGroup new.
|
|
616 |
windowGroup addTopView:self.
|
|
617 |
].
|
|
618 |
].
|
52
|
619 |
"/ self realize.
|
45
|
620 |
self iconLabel:'Debugger'.
|
7
|
621 |
].
|
13
|
622 |
|
52
|
623 |
"/ "
|
|
624 |
"/ bring us to the top
|
|
625 |
"/ "
|
|
626 |
"/ self raise.
|
|
627 |
"/ Display synchronizeOutput.
|
0
|
628 |
|
29
|
629 |
"
|
|
630 |
get the walkback list
|
|
631 |
"
|
22
|
632 |
self setContext:aContext.
|
0
|
633 |
|
29
|
634 |
"
|
|
635 |
and find one to show
|
|
636 |
"
|
52
|
637 |
exitAction == #step ifTrue:[
|
|
638 |
selection := 1.
|
|
639 |
steppedContextAddress notNil ifTrue:[
|
|
640 |
"
|
|
641 |
if we came here by a big-step, show the method where we are
|
|
642 |
"
|
|
643 |
steppedContextAddress notNil ifTrue:[
|
|
644 |
(ObjectMemory addressOf:aContext) == steppedContextAddress ifTrue:[
|
|
645 |
selection := 1
|
|
646 |
] ifFalse:[
|
|
647 |
(ObjectMemory addressOf:aContext sender) == steppedContextAddress ifTrue:[
|
|
648 |
selection := 2
|
|
649 |
]
|
|
650 |
]
|
|
651 |
]
|
|
652 |
]
|
0
|
653 |
] ifFalse:[
|
52
|
654 |
steppedContextAddress isNil ifTrue:[
|
|
655 |
"
|
|
656 |
preselect a more interresting context, (where halt/raise was ...)
|
|
657 |
"
|
|
658 |
selection := self interrestingContextFrom:aContext.
|
|
659 |
] ifFalse:[
|
|
660 |
"
|
|
661 |
if we came here by a big-step, show the method where we are
|
|
662 |
"
|
|
663 |
steppedContextAddress notNil ifTrue:[
|
|
664 |
(ObjectMemory addressOf:aContext) == steppedContextAddress ifTrue:[
|
|
665 |
selection := 1
|
|
666 |
] ifFalse:[
|
|
667 |
(ObjectMemory addressOf:aContext sender) == steppedContextAddress ifTrue:[
|
|
668 |
selection := 2
|
|
669 |
]
|
45
|
670 |
]
|
|
671 |
]
|
|
672 |
]
|
0
|
673 |
].
|
|
674 |
|
|
675 |
selection notNil ifTrue:[
|
45
|
676 |
self showSelection:selection.
|
|
677 |
contextView selection:selection
|
0
|
678 |
].
|
|
679 |
|
45
|
680 |
m := contextView middleButtonMenu.
|
|
681 |
m notNil ifTrue:[
|
|
682 |
canAbort := inspecting or:[Object abortSignal isHandled].
|
|
683 |
canAbort ifTrue:[
|
|
684 |
abortButton enable.
|
|
685 |
m enable:#doAbort.
|
|
686 |
] ifFalse:[
|
|
687 |
abortButton disable.
|
|
688 |
m disable:#doAbort.
|
|
689 |
].
|
|
690 |
exclusive ifTrue:[
|
|
691 |
terminateButton disable.
|
|
692 |
m disable:#doTerminate.
|
|
693 |
] ifFalse:[
|
|
694 |
terminateButton enable.
|
|
695 |
m enable:#doTerminate.
|
|
696 |
]
|
14
|
697 |
].
|
7
|
698 |
|
52
|
699 |
drawableId notNil ifTrue:[
|
|
700 |
self rerealize
|
|
701 |
] ifFalse:[
|
|
702 |
self realize.
|
|
703 |
].
|
|
704 |
|
|
705 |
"
|
|
706 |
bring us to the top
|
|
707 |
"
|
|
708 |
self raise.
|
|
709 |
Display synchronizeOutput.
|
|
710 |
|
29
|
711 |
"
|
|
712 |
enter private event handling loop
|
|
713 |
"
|
0
|
714 |
canContinue := true.
|
52
|
715 |
exitAction := nil.
|
|
716 |
|
0
|
717 |
self controlLoop.
|
|
718 |
|
56
|
719 |
"
|
|
720 |
release all context stuff.
|
|
721 |
This is required, since the debugger is reused,
|
|
722 |
to avoid keeping references to the debuggees objects
|
|
723 |
forever.
|
|
724 |
"
|
0
|
725 |
contextArray := nil.
|
56
|
726 |
codeView contents:nil.
|
|
727 |
codeView acceptAction:nil.
|
|
728 |
contextView contents:nil.
|
29
|
729 |
receiverInspector release.
|
|
730 |
contextInspector release.
|
0
|
731 |
|
|
732 |
(exitAction == #step) ifFalse:[
|
45
|
733 |
self unrealize.
|
|
734 |
device synchronizeOutput.
|
|
735 |
(exitAction == #abort) ifTrue:[
|
|
736 |
selectedContext := nil.
|
|
737 |
busy := false.
|
|
738 |
exclusive ifTrue:[CachedExclusive := self] ifFalse:[CachedDebugger := self].
|
|
739 |
"
|
|
740 |
have to catch errors occuring in unwind-blocks
|
|
741 |
"
|
|
742 |
Object errorSignal handle:[:ex |
|
|
743 |
'ignored error while unwinding: ' errorPrint.
|
|
744 |
ex errorString errorPrintNL.
|
|
745 |
ex proceed
|
|
746 |
] do:[
|
|
747 |
Object abortSignal raise.
|
|
748 |
].
|
53
|
749 |
'abort failed' errorPrintNL
|
45
|
750 |
].
|
|
751 |
(exitAction == #return) ifTrue:[
|
|
752 |
selectedContext notNil ifTrue:[
|
|
753 |
con := selectedContext.
|
|
754 |
selectedContext := nil.
|
|
755 |
busy := false.
|
|
756 |
exclusive ifTrue:[CachedExclusive := self] ifFalse:[CachedDebugger := self].
|
|
757 |
"
|
|
758 |
have to catch errors occuring in unwind-blocks
|
|
759 |
"
|
|
760 |
Object errorSignal handle:[:ex |
|
|
761 |
'ignored error while unwinding: ' errorPrint.
|
|
762 |
ex errorString errorPrintNL.
|
|
763 |
ex proceed
|
|
764 |
] do:[
|
|
765 |
con unwind.
|
|
766 |
].
|
53
|
767 |
'cannot return selected context' errorPrintNL
|
45
|
768 |
]
|
|
769 |
] ifFalse:[
|
|
770 |
(exitAction == #restart) ifTrue:[
|
|
771 |
selectedContext notNil ifTrue:[
|
|
772 |
con := selectedContext.
|
|
773 |
selectedContext := nil.
|
|
774 |
busy := false.
|
|
775 |
exclusive ifTrue:[CachedExclusive := self] ifFalse:[CachedDebugger := self].
|
|
776 |
"
|
|
777 |
have to catch errors occuring in unwind-blocks
|
|
778 |
"
|
|
779 |
Object errorSignal handle:[:ex |
|
|
780 |
'ignored error while unwinding: ' errorPrint.
|
|
781 |
ex errorString errorPrintNL.
|
|
782 |
ex proceed
|
|
783 |
] do:[
|
|
784 |
con restart.
|
|
785 |
].
|
53
|
786 |
'cannot restart selected context' errorPrintNL
|
45
|
787 |
]
|
|
788 |
] ifFalse:[
|
|
789 |
((exitAction == #terminate) or:[exitAction == #quickTerminate]) ifTrue:[
|
|
790 |
selectedContext := nil.
|
|
791 |
busy := false.
|
|
792 |
exclusive ifTrue:[CachedExclusive := self] ifFalse:[CachedDebugger := self].
|
|
793 |
exitAction == #quickTerminate ifTrue:[
|
|
794 |
Processor activeProcess terminateNoSignal
|
|
795 |
] ifFalse:[
|
|
796 |
"
|
|
797 |
have to catch errors occuring in unwind-blocks
|
|
798 |
"
|
|
799 |
Object errorSignal handle:[:ex |
|
|
800 |
'ignored error while unwinding: ' errorPrint.
|
|
801 |
ex errorString errorPrintNL.
|
|
802 |
ex proceed
|
|
803 |
] do:[
|
|
804 |
Processor activeProcess terminate.
|
|
805 |
].
|
|
806 |
].
|
53
|
807 |
'cannot terminate process' errorPrintNL
|
45
|
808 |
]
|
|
809 |
]
|
|
810 |
]
|
0
|
811 |
].
|
|
812 |
|
|
813 |
selectedContext := nil.
|
|
814 |
|
|
815 |
grabber notNil ifTrue:[
|
52
|
816 |
device grabPointerInView:grabber.
|
|
817 |
grabber := nil.
|
0
|
818 |
].
|
|
819 |
|
|
820 |
(exitAction == #step) ifTrue:[
|
45
|
821 |
"scedule another stepInterrupt
|
|
822 |
- must flush caches since optimized methods not always
|
|
823 |
look for pending interrupts"
|
|
824 |
ObjectMemory flushInlineCaches.
|
0
|
825 |
|
45
|
826 |
ObjectMemory stepInterruptHandler:self.
|
|
827 |
StepInterruptPending := true.
|
|
828 |
InterruptPending := true.
|
|
829 |
InStepInterrupt := nil
|
20
|
830 |
] ifFalse:[
|
45
|
831 |
busy := false.
|
|
832 |
exclusive ifTrue:[CachedExclusive := self] ifFalse:[CachedDebugger := self]
|
0
|
833 |
]
|
|
834 |
!
|
|
835 |
|
15
|
836 |
openOn:aProcess
|
|
837 |
"enter the debugger on a process -
|
|
838 |
in this case, we are just inspecting the context chain of the process,
|
52
|
839 |
not running on top of the debugged process, but as a separate
|
|
840 |
one. (think of it as an inspector showing more detail, and offering
|
|
841 |
some more control operations)"
|
15
|
842 |
|
45
|
843 |
|bpanel updateButton stopButton dummy|
|
|
844 |
|
15
|
845 |
busy := true.
|
|
846 |
bigStep := false.
|
29
|
847 |
inspecting := true.
|
45
|
848 |
inspectedProcess := aProcess.
|
29
|
849 |
nChainShown := 50.
|
15
|
850 |
|
45
|
851 |
bpanel := abortButton superView.
|
|
852 |
|
|
853 |
stopButton := Button new.
|
|
854 |
stopButton label:(resources at:'stop');
|
|
855 |
action:[self doStop].
|
|
856 |
bpanel addSubView:stopButton after:continueButton.
|
|
857 |
|
|
858 |
dummy := View extent:(20 @ 5) in:bpanel.
|
52
|
859 |
dummy borderWidth:0; level:0.
|
45
|
860 |
|
|
861 |
"/ stepButton destroy.
|
|
862 |
"/ sendButton destroy.
|
|
863 |
|
|
864 |
updateButton := Button
|
|
865 |
label:(resources at:'update')
|
|
866 |
action:[self updateContext]
|
|
867 |
in:bpanel.
|
|
868 |
monitorToggle := Toggle in:bpanel.
|
|
869 |
monitorToggle label:(resources at:'monitor').
|
|
870 |
monitorToggle pressAction:[self autoUpdateOn].
|
|
871 |
monitorToggle releaseAction:[self autoUpdateOff].
|
|
872 |
|
20
|
873 |
"can only look into process - context chain is not active"
|
29
|
874 |
canContinue := true.
|
|
875 |
|
45
|
876 |
terminateButton enable.
|
|
877 |
abortButton enable.
|
|
878 |
|
15
|
879 |
sendButton disable.
|
|
880 |
stepButton disable.
|
45
|
881 |
"/ continueButton disable.
|
|
882 |
"/ returnButton disable.
|
|
883 |
"/ restartButton disable.
|
15
|
884 |
|
29
|
885 |
aProcess isNil ifTrue:[
|
45
|
886 |
terminateButton disable.
|
|
887 |
abortButton disable.
|
|
888 |
continueButton disable.
|
|
889 |
returnButton disable.
|
|
890 |
restartButton disable.
|
29
|
891 |
] ifFalse:[
|
45
|
892 |
aProcess suspendedContext isNil ifTrue:[
|
|
893 |
terminateButton disable.
|
|
894 |
].
|
15
|
895 |
|
45
|
896 |
self setContext:aProcess suspendedContext.
|
29
|
897 |
|
45
|
898 |
catchBlock := [
|
52
|
899 |
catchBlock := nil.
|
45
|
900 |
contextArray := nil.
|
|
901 |
selectedContext := nil.
|
|
902 |
(exitAction == #terminate) ifTrue:[
|
|
903 |
aProcess terminate.
|
|
904 |
].
|
|
905 |
(exitAction == #quickTerminate) ifTrue:[
|
|
906 |
aProcess terminateNoSignal.
|
|
907 |
].
|
|
908 |
super destroy
|
|
909 |
].
|
15
|
910 |
].
|
29
|
911 |
self open
|
|
912 |
! !
|
|
913 |
|
|
914 |
!DebugView methodsFor:'private control loop'!
|
15
|
915 |
|
0
|
916 |
controlLoop
|
|
917 |
"this is a kludge:
|
45
|
918 |
start a dispatchloop which exits when
|
|
919 |
either continue, return or step is pressed
|
0
|
920 |
"
|
|
921 |
|
|
922 |
haveControl := true.
|
|
923 |
[haveControl] whileTrue:[
|
45
|
924 |
self controlLoopCatchingErrors
|
0
|
925 |
].
|
|
926 |
catchBlock := nil.
|
|
927 |
!
|
|
928 |
|
|
929 |
controlLoopCatchingErrors
|
52
|
930 |
"setup a self removing catch-block"
|
|
931 |
catchBlock := [catchBlock := nil. ^ nil].
|
0
|
932 |
|
13
|
933 |
exclusive ifTrue:[
|
45
|
934 |
"if we do not have multiple processes or its a system process
|
|
935 |
we start another dispatch loop, which exits when
|
|
936 |
either continue, return or step is pressed
|
|
937 |
or (via the catchBlock) if an error occurs.
|
|
938 |
Since our display is an extra exclusive one (ModalDisplay)
|
|
939 |
all processing for normal views stops here ...
|
|
940 |
"
|
|
941 |
device dispatchModalWhile:[haveControl]
|
13
|
942 |
] ifFalse:[
|
45
|
943 |
"we do have multiple processes -
|
|
944 |
simply enter the DebugViews-Windowgroup event loop.
|
|
945 |
effectively suspending event processing for the currently
|
|
946 |
active group.
|
|
947 |
"
|
|
948 |
SignalSet anySignal handle:[:ex |
|
53
|
949 |
|answer|
|
|
950 |
|
|
951 |
answer := self confirm:('error in debugger: ' , ex errorString , '\\debug again ?') withCRs.
|
|
952 |
answer ifTrue:[
|
|
953 |
Debugger enterUnconditional:(ex suspendedContext) withMessage:'error in debugger: ' , ex errorString.
|
|
954 |
] ifFalse:[
|
|
955 |
'ignored error in debugger: ' errorPrint.
|
|
956 |
ex errorString errorPrintNL.
|
|
957 |
].
|
45
|
958 |
ex return.
|
|
959 |
] do:[
|
|
960 |
windowGroup eventLoopWhile:[true]
|
52
|
961 |
].
|
|
962 |
].
|
|
963 |
catchBlock := nil.
|
29
|
964 |
! !
|
|
965 |
|
|
966 |
!DebugView methodsFor:'private'!
|
|
967 |
|
|
968 |
busy
|
|
969 |
^ busy
|
|
970 |
!
|
|
971 |
|
52
|
972 |
showError:message
|
|
973 |
codeView contents:(resources string:message).
|
|
974 |
codeView flash
|
|
975 |
!
|
|
976 |
|
48
|
977 |
showTerminated
|
52
|
978 |
self showError:'** the process has terminated **'
|
48
|
979 |
!
|
|
980 |
|
|
981 |
processAction:aBlock
|
|
982 |
"do something, then update the context list"
|
|
983 |
|
|
984 |
inspectedProcess isDead ifTrue:[
|
|
985 |
self showTerminated.
|
|
986 |
^ self
|
|
987 |
].
|
|
988 |
inspectedProcess interruptWith:aBlock.
|
|
989 |
"
|
|
990 |
give the process a chance to run, then update
|
|
991 |
"
|
|
992 |
(Delay forSeconds:0.2) wait.
|
|
993 |
self setContext:(inspectedProcess suspendedContext).
|
|
994 |
!
|
|
995 |
|
|
996 |
interruptProcessWith:aBlock
|
|
997 |
"let inspected process do something, then update the context list"
|
|
998 |
|
|
999 |
self processAction:[inspectedProcess interruptWith:aBlock.]
|
|
1000 |
!
|
|
1001 |
|
29
|
1002 |
exclusive:aBoolean
|
|
1003 |
exclusive := aBoolean
|
|
1004 |
!
|
|
1005 |
|
|
1006 |
interrestingContextFrom:aContext
|
|
1007 |
"return an interresting contexts offset, or nil.
|
52
|
1008 |
This is the context initially shown in the walkback.
|
|
1009 |
We move up the calling chain, skipping all intermediate Signal
|
|
1010 |
and Exception contexts, to present the context in which the error
|
|
1011 |
actually occured.
|
|
1012 |
Just for your convenience :-)"
|
29
|
1013 |
|
52
|
1014 |
|c found offset sel prev|
|
29
|
1015 |
|
|
1016 |
"somewhere, at the bottom, there must be a raise ..."
|
|
1017 |
|
|
1018 |
c := aContext.
|
|
1019 |
1 to:5 do:[:i |
|
45
|
1020 |
c isNil ifTrue:[^ 1 "^ nil"].
|
|
1021 |
sel := c selector.
|
52
|
1022 |
(sel == #raise) ifTrue:[
|
45
|
1023 |
offset := i.
|
|
1024 |
found := c
|
|
1025 |
].
|
|
1026 |
c := c sender.
|
29
|
1027 |
].
|
|
1028 |
|
52
|
1029 |
(c := found) isNil ifTrue:[^ 1].
|
29
|
1030 |
|
|
1031 |
"
|
52
|
1032 |
got it; move up, skipping all intermediate Signal and
|
|
1033 |
Exception contexts
|
29
|
1034 |
"
|
52
|
1035 |
prev := nil.
|
|
1036 |
[
|
|
1037 |
((c receiver isKindOf:Signal)
|
|
1038 |
or:[(c receiver isKindOf:Exception)])
|
|
1039 |
] whileTrue:[
|
|
1040 |
prev := c.
|
|
1041 |
(c := c sender) isNil ifTrue:[^ offset].
|
|
1042 |
offset := offset + 1.
|
|
1043 |
].
|
29
|
1044 |
|
|
1045 |
"
|
|
1046 |
now, we are one above the raise
|
|
1047 |
"
|
|
1048 |
|
|
1049 |
"
|
|
1050 |
if the sender of the raise is one of objects error methods ...
|
|
1051 |
"
|
|
1052 |
( #( halt halt:
|
45
|
1053 |
error error:
|
|
1054 |
doesNotUnderstand:
|
|
1055 |
subclassResponsibility
|
|
1056 |
primitiveFailed) includes:c selector)
|
29
|
1057 |
ifTrue:[
|
45
|
1058 |
c selector == #doesNotUnderstand: ifTrue:[
|
|
1059 |
"
|
|
1060 |
one more up, to get to the originating context
|
|
1061 |
"
|
|
1062 |
(c := c sender) isNil ifTrue:[^ offset].
|
|
1063 |
offset := offset + 1.
|
|
1064 |
].
|
|
1065 |
(c := c sender) isNil ifTrue:[^ offset].
|
|
1066 |
offset := offset + 1.
|
52
|
1067 |
] ifFalse:[
|
|
1068 |
"
|
|
1069 |
ok, got the raise - if its a BreakPoint, look for the sender
|
|
1070 |
"
|
|
1071 |
prev receiver == MessageTracer breakpointSignal ifTrue:[
|
|
1072 |
offset := offset + 1
|
|
1073 |
].
|
29
|
1074 |
].
|
|
1075 |
|
|
1076 |
^ offset
|
0
|
1077 |
!
|
|
1078 |
|
|
1079 |
setContext:aContext
|
29
|
1080 |
"show calling chain from aContext in the walk-back listview"
|
|
1081 |
|
45
|
1082 |
|con text method caller caller2 m|
|
|
1083 |
|
48
|
1084 |
(contextArray notNil and:[aContext == (contextArray at:1)]) ifTrue:[
|
|
1085 |
"no change"
|
|
1086 |
^ false
|
|
1087 |
].
|
|
1088 |
|
45
|
1089 |
m := contextView middleButtonMenu.
|
|
1090 |
m notNil ifTrue:[
|
|
1091 |
m disable:#doShowMore.
|
|
1092 |
].
|
0
|
1093 |
|
|
1094 |
aContext isNil ifTrue:[
|
45
|
1095 |
text := Array with:'** no context **'.
|
|
1096 |
contextArray := nil.
|
0
|
1097 |
] ifFalse:[
|
45
|
1098 |
text := OrderedCollection new:nChainShown.
|
|
1099 |
contextArray := OrderedCollection new:nChainShown.
|
|
1100 |
con := aContext.
|
29
|
1101 |
|
45
|
1102 |
"
|
|
1103 |
get them all
|
|
1104 |
"
|
|
1105 |
[con notNil and:[contextArray size <= nChainShown]] whileTrue:[
|
|
1106 |
contextArray add:con.
|
52
|
1107 |
(MoreDebuggingDetail == true) ifTrue:[
|
45
|
1108 |
text add:(((ObjectMemory addressOf:con) printStringRadix:16) , ' ' , con printString).
|
|
1109 |
] ifFalse:[
|
|
1110 |
text add:con printString.
|
|
1111 |
].
|
29
|
1112 |
|
45
|
1113 |
method := con method.
|
|
1114 |
(method notNil and:[method isWrapped]) ifTrue:[
|
|
1115 |
"
|
|
1116 |
kludge: if its a wrapped method, then hide the wrap-call
|
|
1117 |
"
|
|
1118 |
caller := con sender.
|
|
1119 |
(caller notNil and:[caller receiver == method originalMethod]) ifTrue:[
|
|
1120 |
caller2 := caller sender.
|
|
1121 |
(caller2 notNil and:[caller2 method == method]) ifTrue:[
|
|
1122 |
con := caller2
|
|
1123 |
]
|
|
1124 |
].
|
|
1125 |
caller := caller2 := nil
|
|
1126 |
].
|
|
1127 |
con := con sender
|
|
1128 |
].
|
29
|
1129 |
|
45
|
1130 |
"
|
|
1131 |
did we reach the end ?
|
|
1132 |
"
|
|
1133 |
(con isNil or:[con sender isNil]) ifTrue:[
|
29
|
1134 |
|
45
|
1135 |
"
|
|
1136 |
the very last one is the startup context
|
|
1137 |
(in main) - it has nil as receiver and nil as selector
|
|
1138 |
"
|
|
1139 |
contextArray last selector isNil ifTrue:[
|
|
1140 |
contextArray removeLast.
|
|
1141 |
text removeLast
|
|
1142 |
]
|
|
1143 |
] ifFalse:[
|
|
1144 |
m notNil ifTrue:[
|
|
1145 |
m enable:#doShowMore.
|
|
1146 |
text add:(resources string:'*** more walkback follows - click here to see them ***')
|
|
1147 |
].
|
|
1148 |
].
|
0
|
1149 |
].
|
29
|
1150 |
|
|
1151 |
contextView setList: "list:" text.
|
|
1152 |
receiverInspector release.
|
|
1153 |
contextInspector release.
|
|
1154 |
|
45
|
1155 |
m notNil ifTrue:[
|
|
1156 |
m disable:#doRemoveBreakpoint.
|
|
1157 |
m disable:#doImplementors.
|
|
1158 |
m disable:#doSenders.
|
|
1159 |
].
|
48
|
1160 |
^ true
|
45
|
1161 |
!
|
|
1162 |
|
|
1163 |
updateContext
|
|
1164 |
|oldContext idx|
|
|
1165 |
|
48
|
1166 |
inspectedProcess state == #dead ifTrue:[
|
|
1167 |
self showTerminated.
|
|
1168 |
^ self
|
|
1169 |
].
|
|
1170 |
|
45
|
1171 |
oldContext := selectedContext.
|
48
|
1172 |
(self setContext:(inspectedProcess suspendedContext)) ifTrue:[
|
|
1173 |
oldContext notNil ifTrue:[
|
|
1174 |
contextArray notNil ifTrue:[
|
|
1175 |
idx := contextArray identityIndexOf:oldContext.
|
|
1176 |
idx ~~ 0 ifTrue:[
|
|
1177 |
self showSelection:idx
|
|
1178 |
] ifFalse:[
|
|
1179 |
codeView contents:('** context returned **')
|
|
1180 |
]
|
45
|
1181 |
]
|
|
1182 |
]
|
|
1183 |
]
|
0
|
1184 |
! !
|
|
1185 |
|
|
1186 |
!DebugView methodsFor:'user interaction'!
|
|
1187 |
|
|
1188 |
showSelection:lineNr
|
|
1189 |
"user clicked on a header line - show selected code in textView"
|
|
1190 |
|
56
|
1191 |
|con homeContext sel method code canAccept
|
45
|
1192 |
implementorClass lineNrInMethod rec m line|
|
0
|
1193 |
|
|
1194 |
contextArray notNil ifTrue:[
|
45
|
1195 |
lineNr <= contextArray size ifTrue:[
|
|
1196 |
con := contextArray at:lineNr.
|
|
1197 |
].
|
|
1198 |
"
|
|
1199 |
clicking on the '** ...'-line shows more ...
|
|
1200 |
"
|
|
1201 |
con isNil ifTrue:[
|
|
1202 |
line := contextView list at:lineNr.
|
|
1203 |
(line startsWith:'**') ifTrue:[
|
|
1204 |
self doShowMore.
|
|
1205 |
contextView selection:lineNr.
|
|
1206 |
con := contextArray at:lineNr
|
|
1207 |
]
|
|
1208 |
].
|
|
1209 |
lineNrInMethod := con lineNumber.
|
|
1210 |
con isBlockContext ifTrue:[
|
|
1211 |
homeContext := con methodHome
|
|
1212 |
] ifFalse:[
|
|
1213 |
homeContext := con
|
|
1214 |
].
|
|
1215 |
contextInspector inspect:con.
|
55
|
1216 |
homeContext isNil ifTrue:[
|
|
1217 |
"
|
|
1218 |
mhmh - an optimized block
|
|
1219 |
should get the block here, and get the method from
|
|
1220 |
that one ...
|
|
1221 |
"
|
|
1222 |
self showError:'** sorry; cannot show code of optimized blocks (yet) **'
|
|
1223 |
] ifFalse:[
|
45
|
1224 |
sel := homeContext selector.
|
|
1225 |
sel notNil ifTrue:[
|
56
|
1226 |
canAccept := true.
|
|
1227 |
|
55
|
1228 |
"/ implementorClass := homeContext searchClass whichClassImplements:sel.
|
|
1229 |
implementorClass := homeContext methodClass.
|
45
|
1230 |
implementorClass isNil ifTrue:[
|
56
|
1231 |
"
|
|
1232 |
special: look if this context was create by
|
|
1233 |
valueWithReceiver kind of method invocation;
|
|
1234 |
if so, grab the method from the sender and show it
|
|
1235 |
"
|
|
1236 |
"/ con sender selector printNL.
|
|
1237 |
(con sender notNil
|
|
1238 |
and:[(con sender selector == #valueWithReceiver:arguments:selector:search:)
|
|
1239 |
and:[con sender receiver isKindOf:Method]]) ifTrue:[
|
|
1240 |
method := con sender receiver.
|
|
1241 |
code := method source.
|
|
1242 |
canAccept := false.
|
|
1243 |
] ifFalse:[
|
|
1244 |
self showError:'** no method - no source **'
|
|
1245 |
]
|
45
|
1246 |
] ifFalse:[
|
|
1247 |
method := implementorClass compiledMethodAt:sel.
|
|
1248 |
code := method source.
|
|
1249 |
code isNil ifTrue:[
|
48
|
1250 |
method sourceFilename notNil ifTrue:[
|
45
|
1251 |
codeView contents:(resources
|
|
1252 |
string:'** no sourcefile: %1 **'
|
52
|
1253 |
with:method sourceFilename).
|
|
1254 |
codeView flash
|
45
|
1255 |
] ifFalse:[
|
52
|
1256 |
self showError:'** no source **'
|
45
|
1257 |
]
|
|
1258 |
]
|
|
1259 |
].
|
|
1260 |
code isNil ifTrue:[
|
56
|
1261 |
canAccept := false.
|
45
|
1262 |
] ifFalse:[
|
|
1263 |
codeView contents:code.
|
|
1264 |
(lineNrInMethod notNil and:[lineNrInMethod ~~ 0]) ifTrue:[
|
|
1265 |
lineNrInMethod > codeView list size ifTrue:[
|
|
1266 |
lineNrInMethod := codeView list size + 1
|
|
1267 |
].
|
|
1268 |
codeView selectLine:lineNrInMethod.
|
|
1269 |
codeView makeSelectionVisible
|
|
1270 |
].
|
56
|
1271 |
].
|
|
1272 |
|
|
1273 |
canAccept ifTrue:[
|
45
|
1274 |
codeView acceptAction:[:code | self codeAccept:code asString]
|
56
|
1275 |
] ifFalse:[
|
|
1276 |
codeView acceptAction:nil.
|
45
|
1277 |
].
|
15
|
1278 |
|
45
|
1279 |
"fetch rec here - so we wont need context in doItAction"
|
|
1280 |
rec := homeContext receiver.
|
|
1281 |
]
|
|
1282 |
].
|
|
1283 |
receiverInspector inspect:rec.
|
|
1284 |
codeView doItAction:[:theCode |
|
|
1285 |
rec class compiler
|
|
1286 |
evaluate:theCode
|
|
1287 |
in:nil
|
|
1288 |
receiver:rec
|
|
1289 |
notifying:codeView
|
|
1290 |
logged:true
|
|
1291 |
ifFail:nil
|
|
1292 |
].
|
|
1293 |
|
|
1294 |
selectedContext := homeContext
|
0
|
1295 |
].
|
|
1296 |
"clear out locals to prevent keeping around unneeded contexts (due to the
|
|
1297 |
block held in codeView).
|
|
1298 |
(not really needed, since stuff gets collected away sooner or later ..."
|
|
1299 |
|
|
1300 |
con := nil.
|
29
|
1301 |
homeContext := nil.
|
|
1302 |
|
45
|
1303 |
m := contextView middleButtonMenu.
|
|
1304 |
m notNil ifTrue:[
|
|
1305 |
m enable:#doImplementors.
|
|
1306 |
m enable:#doSenders.
|
|
1307 |
m enable:#doInspectContext.
|
29
|
1308 |
|
45
|
1309 |
(method notNil and:[method isWrapped]) ifTrue:[
|
|
1310 |
m enable:#doRemoveBreakpoint.
|
|
1311 |
] ifFalse:[
|
|
1312 |
m disable:#doRemoveBreakpoint.
|
|
1313 |
]
|
29
|
1314 |
]
|
0
|
1315 |
!
|
|
1316 |
|
|
1317 |
codeAccept:someCode
|
|
1318 |
"user wants some code to be recompiled - must unwind stack since everything above
|
48
|
1319 |
and including selected method cannot be continued."
|
|
1320 |
|
|
1321 |
"
|
|
1322 |
actually, this is not true, since the active methods will still be
|
|
1323 |
executed correctly - however, the code shown in the debugger is no
|
|
1324 |
longer in sync (showing the new code) with the executed code.
|
|
1325 |
Therefore, we hide those contexts to avoid confusion ....
|
|
1326 |
If you dont like this behavior, remove the 'inspecting ifFalse:' check below"
|
0
|
1327 |
|
|
1328 |
"walk up context chain and find highest context which is either the selected context,
|
|
1329 |
or - if its a block-context - whose home is the selected context"
|
|
1330 |
|
|
1331 |
|con top sel implementorClass method newMethod|
|
|
1332 |
|
|
1333 |
codeView cursor:Cursor execute.
|
|
1334 |
|
45
|
1335 |
"
|
|
1336 |
find the method-home context for this one
|
|
1337 |
"
|
0
|
1338 |
con := selectedContext.
|
|
1339 |
top := con.
|
|
1340 |
[con notNil] whileTrue:[
|
45
|
1341 |
(con methodHome == selectedContext) ifTrue:[
|
|
1342 |
top := con
|
|
1343 |
].
|
|
1344 |
con := con sender
|
0
|
1345 |
].
|
48
|
1346 |
"
|
|
1347 |
use class&selector to find the method for the compilation
|
|
1348 |
and compile.
|
|
1349 |
"
|
0
|
1350 |
sel := selectedContext selector.
|
55
|
1351 |
"/ implementorClass := selectedContext searchClass whichClassImplements:sel.
|
|
1352 |
implementorClass := selectedContext methodClass.
|
0
|
1353 |
method := implementorClass compiledMethodAt:sel.
|
7
|
1354 |
newMethod := implementorClass compiler compile:someCode
|
45
|
1355 |
forClass:implementorClass
|
|
1356 |
inCategory:(method category)
|
|
1357 |
notifying:codeView.
|
0
|
1358 |
|
45
|
1359 |
inspecting ifFalse:[
|
48
|
1360 |
"
|
|
1361 |
if it worked, remove everything up to and including top
|
|
1362 |
from context chain
|
|
1363 |
"
|
45
|
1364 |
(newMethod notNil and:[newMethod ~~ #Error]) ifTrue:[
|
|
1365 |
self setContext:(top sender).
|
0
|
1366 |
|
48
|
1367 |
"
|
|
1368 |
continue/step is no longer possible
|
|
1369 |
"
|
45
|
1370 |
canContinue := false.
|
|
1371 |
self showSelection:1.
|
|
1372 |
exitAction := #return
|
|
1373 |
].
|
0
|
1374 |
].
|
|
1375 |
codeView cursor:Cursor normal
|
|
1376 |
!
|
|
1377 |
|
|
1378 |
destroy
|
35
|
1379 |
"closing the debugger implies an abort or continue"
|
0
|
1380 |
|
|
1381 |
contextView middleButtonMenu hide.
|
52
|
1382 |
|
|
1383 |
"
|
|
1384 |
we manually release all private data, since the Debugger
|
|
1385 |
is cached for reuse - thus the memory would not be collectable
|
|
1386 |
otherwise.
|
|
1387 |
"
|
29
|
1388 |
receiverInspector release.
|
|
1389 |
contextInspector release.
|
52
|
1390 |
inspectedProcess := nil.
|
|
1391 |
exitAction := nil.
|
|
1392 |
contextArray := nil.
|
|
1393 |
selectedContext := nil.
|
53
|
1394 |
"/ catchBlock := nil.
|
52
|
1395 |
grabber := nil.
|
|
1396 |
self autoUpdateOff.
|
|
1397 |
|
53
|
1398 |
inspecting ifTrue:[
|
|
1399 |
super destroy.
|
|
1400 |
] ifFalse:[
|
|
1401 |
exclusive ifTrue:[
|
|
1402 |
CachedExclusive := nil.
|
|
1403 |
] ifFalse:[
|
|
1404 |
CachedDebugger := nil
|
|
1405 |
]
|
|
1406 |
].
|
52
|
1407 |
|
29
|
1408 |
inspecting ifFalse:[
|
45
|
1409 |
canAbort ifTrue:[
|
|
1410 |
self doAbort.
|
|
1411 |
] ifFalse:[
|
|
1412 |
self doContinue
|
|
1413 |
]
|
29
|
1414 |
].
|
0
|
1415 |
!
|
|
1416 |
|
|
1417 |
doExit
|
|
1418 |
"exit from menu: immediate exit from smalltalk"
|
|
1419 |
|
|
1420 |
Smalltalk exit
|
|
1421 |
!
|
|
1422 |
|
29
|
1423 |
doRemoveBreakpoint
|
|
1424 |
"remove breakpoint on the selected contexts method - if any"
|
|
1425 |
|
|
1426 |
|implementorClass method|
|
|
1427 |
|
52
|
1428 |
selectedContext isNil ifTrue:[
|
|
1429 |
^ self showError:'** select a context first **'
|
|
1430 |
].
|
|
1431 |
|
55
|
1432 |
"/ implementorClass := selectedContext searchClass
|
|
1433 |
"/ whichClassImplements:selectedContext selector.
|
|
1434 |
implementorClass := selectedContext methodClass.
|
29
|
1435 |
implementorClass notNil ifTrue:[
|
45
|
1436 |
method := implementorClass compiledMethodAt:selectedContext selector.
|
|
1437 |
(method notNil and:[method isWrapped]) ifTrue:[
|
|
1438 |
MessageTracer unwrapMethod:method
|
|
1439 |
]
|
29
|
1440 |
].
|
|
1441 |
contextView middleButtonMenu disable:#doRemoveBreakpoint.
|
|
1442 |
!
|
|
1443 |
|
48
|
1444 |
doRemoveAllBreakpoints
|
|
1445 |
"remove all trace & breakpoints - if any"
|
|
1446 |
|
|
1447 |
MessageTracer unwrapAllMethods
|
|
1448 |
!
|
|
1449 |
|
29
|
1450 |
doSenders
|
|
1451 |
"open a browser on the senders"
|
22
|
1452 |
|
52
|
1453 |
selectedContext isNil ifTrue:[
|
|
1454 |
^ self showError:'** select a context first **'
|
|
1455 |
].
|
|
1456 |
SystemBrowser browseAllCallsOn:selectedContext selector.
|
29
|
1457 |
!
|
|
1458 |
|
|
1459 |
doImplementors
|
|
1460 |
"open a browser on the implementors"
|
|
1461 |
|
52
|
1462 |
selectedContext isNil ifTrue:[
|
|
1463 |
^ self showError:'** select a context first **'
|
|
1464 |
].
|
|
1465 |
SystemBrowser browseImplementorsOf:selectedContext selector.
|
29
|
1466 |
!
|
|
1467 |
|
|
1468 |
doShowMore
|
|
1469 |
"double number of contexts shown"
|
|
1470 |
|
52
|
1471 |
|oldSelection con|
|
29
|
1472 |
|
|
1473 |
contextArray notNil ifTrue:[
|
45
|
1474 |
oldSelection := contextView selection.
|
|
1475 |
nChainShown := nChainShown * 2.
|
52
|
1476 |
con := contextArray at:1.
|
|
1477 |
contextArray at:1 put:nil.
|
|
1478 |
self setContext:con.
|
45
|
1479 |
contextView selection:oldSelection.
|
29
|
1480 |
]
|
0
|
1481 |
!
|
|
1482 |
|
|
1483 |
doSend
|
|
1484 |
"send from menu"
|
|
1485 |
|
29
|
1486 |
inspecting ifTrue:[^ self].
|
|
1487 |
|
0
|
1488 |
canContinue ifTrue:[
|
45
|
1489 |
steppedContextAddress := nil.
|
|
1490 |
haveControl := false.
|
|
1491 |
exitAction := #step.
|
|
1492 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
1493 |
"exit private event-loop"
|
|
1494 |
catchBlock notNil ifTrue:[catchBlock value].
|
53
|
1495 |
'DEBUGGER: oops, send failed' errorPrintNL.
|
|
1496 |
"/ self warn:'send failed'.
|
|
1497 |
sendButton turnOff.
|
|
1498 |
"/ sendButton disable.
|
45
|
1499 |
].
|
0
|
1500 |
]
|
|
1501 |
!
|
|
1502 |
|
53
|
1503 |
doStep:lineNr
|
0
|
1504 |
"step from menu"
|
|
1505 |
|
29
|
1506 |
inspecting ifTrue:[^ self].
|
|
1507 |
|
0
|
1508 |
canContinue ifTrue:[
|
45
|
1509 |
selectedContext notNil ifTrue:[
|
|
1510 |
steppedContextAddress := ObjectMemory addressOf:selectedContext
|
|
1511 |
] ifFalse:[
|
|
1512 |
steppedContextAddress := ObjectMemory addressOf:(contextArray at:2)
|
|
1513 |
].
|
|
1514 |
bigStep := true.
|
53
|
1515 |
skipLineNr := lineNr.
|
45
|
1516 |
haveControl := false.
|
|
1517 |
exitAction := #step.
|
|
1518 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
1519 |
"exit private event-loop"
|
|
1520 |
catchBlock notNil ifTrue:[catchBlock value].
|
53
|
1521 |
'DEBUGGER: oops, step failed' errorPrintNL.
|
|
1522 |
"/ self warn:'step failed'.
|
|
1523 |
stepButton turnOff.
|
|
1524 |
"/ stepButton disable.
|
45
|
1525 |
].
|
0
|
1526 |
]
|
|
1527 |
!
|
|
1528 |
|
53
|
1529 |
doStep
|
|
1530 |
"step from menu"
|
|
1531 |
|
|
1532 |
self doStep:nil
|
|
1533 |
!
|
|
1534 |
|
|
1535 |
doSkip
|
|
1536 |
"step from menu"
|
|
1537 |
|
|
1538 |
self doStep:codeView cursorLine.
|
|
1539 |
!
|
|
1540 |
|
0
|
1541 |
doTraceStep
|
22
|
1542 |
"tracestep - not implemented yet"
|
0
|
1543 |
|
|
1544 |
canContinue ifTrue:[
|
45
|
1545 |
tracing := true.
|
|
1546 |
self doStep
|
0
|
1547 |
]
|
|
1548 |
!
|
|
1549 |
|
|
1550 |
doAbort
|
48
|
1551 |
"abort - send Object>>abortSignal, which is usually cought
|
|
1552 |
at save places (for example: in the event loop) and returns back
|
|
1553 |
from whatever the process is doing, but does not terminate it."
|
0
|
1554 |
|
45
|
1555 |
inspecting ifTrue:[
|
48
|
1556 |
inspectedProcess isDead ifTrue:[
|
|
1557 |
self showTerminated.
|
|
1558 |
^ self
|
|
1559 |
].
|
|
1560 |
(Object abortSignal isHandledIn:inspectedProcess suspendedContext) ifFalse:[
|
52
|
1561 |
self showError:'** the process does not handle the abort signal **'
|
48
|
1562 |
] ifTrue:[
|
|
1563 |
self interruptProcessWith:[Object abortSignal raise].
|
45
|
1564 |
].
|
|
1565 |
^ self
|
|
1566 |
].
|
29
|
1567 |
|
0
|
1568 |
steppedContextAddress := nil.
|
|
1569 |
haveControl := false.
|
7
|
1570 |
exitAction := #abort.
|
13
|
1571 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
45
|
1572 |
"exit private event-loop"
|
|
1573 |
catchBlock notNil ifTrue:[
|
|
1574 |
abortButton turnOff.
|
|
1575 |
catchBlock value.
|
53
|
1576 |
'DEBUGGER: oops, abort failed' errorPrintNL.
|
|
1577 |
"/ self warn:'unwind failed'.
|
|
1578 |
"/ abortButton disable.
|
45
|
1579 |
]
|
13
|
1580 |
].
|
7
|
1581 |
^ self.
|
|
1582 |
|
|
1583 |
"obsolete ..."
|
52
|
1584 |
"/ Processor activeProcess id == 0 ifTrue:[
|
|
1585 |
"/ "dont allow termination of main-thread"
|
|
1586 |
"/ exitAction := #abort
|
|
1587 |
"/ ] ifFalse:[
|
|
1588 |
"/ exitAction := #terminate
|
|
1589 |
"/ ]
|
0
|
1590 |
!
|
|
1591 |
|
7
|
1592 |
doTerminate
|
48
|
1593 |
"terminate - the process has a chance for cleanup"
|
7
|
1594 |
|
45
|
1595 |
inspecting ifTrue:[
|
48
|
1596 |
self processAction:[inspectedProcess terminate].
|
45
|
1597 |
^ self
|
|
1598 |
].
|
|
1599 |
|
7
|
1600 |
steppedContextAddress := nil.
|
|
1601 |
haveControl := false.
|
13
|
1602 |
exitAction := #terminate.
|
|
1603 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
45
|
1604 |
"exit private event-loop"
|
|
1605 |
catchBlock notNil ifTrue:[catchBlock value].
|
|
1606 |
inspecting ifFalse:[
|
53
|
1607 |
'DEBUGGER: oops, terminate failed' errorPrintNL.
|
45
|
1608 |
self warn:'terminate failed'.
|
|
1609 |
].
|
53
|
1610 |
terminateButton turnOff.
|
|
1611 |
"/ terminateButton disable.
|
13
|
1612 |
].
|
7
|
1613 |
!
|
|
1614 |
|
45
|
1615 |
doQuickTerminate
|
48
|
1616 |
"quick terminate - the process will get no chance for cleanup actions"
|
45
|
1617 |
|
|
1618 |
inspecting ifTrue:[
|
48
|
1619 |
self processAction:[inspectedProcess terminateNoSignal].
|
45
|
1620 |
^ self
|
|
1621 |
].
|
|
1622 |
|
|
1623 |
steppedContextAddress := nil.
|
|
1624 |
haveControl := false.
|
|
1625 |
exitAction := #quickTerminate.
|
|
1626 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
1627 |
"exit private event-loop"
|
|
1628 |
catchBlock notNil ifTrue:[catchBlock value].
|
|
1629 |
inspecting ifFalse:[
|
53
|
1630 |
'DEBUGGER: oops, terminate failed' errorPrintNL.
|
45
|
1631 |
self warn:'terminate failed'.
|
|
1632 |
].
|
53
|
1633 |
terminateButton turnOff.
|
|
1634 |
"/ terminateButton disable.
|
45
|
1635 |
].
|
|
1636 |
!
|
7
|
1637 |
|
29
|
1638 |
doReturn
|
48
|
1639 |
"return - the selected context will do a ^nil"
|
29
|
1640 |
|
45
|
1641 |
inspecting ifTrue:[
|
52
|
1642 |
selectedContext isNil ifTrue:[
|
|
1643 |
^ self showError:'** select a context first **'
|
|
1644 |
].
|
48
|
1645 |
self interruptProcessWith:[selectedContext return].
|
45
|
1646 |
^ self
|
|
1647 |
].
|
0
|
1648 |
|
|
1649 |
steppedContextAddress := nil.
|
|
1650 |
haveControl := false.
|
29
|
1651 |
exitAction := #return.
|
13
|
1652 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
45
|
1653 |
"exit private event-loop"
|
|
1654 |
catchBlock notNil ifTrue:[catchBlock value].
|
53
|
1655 |
'DEBUGGER: oops, return failed' errorPrintNL.
|
|
1656 |
"/ self warn:'return failed'.
|
|
1657 |
returnButton turnOff.
|
|
1658 |
"/ returnButton disable.
|
13
|
1659 |
].
|
0
|
1660 |
!
|
|
1661 |
|
|
1662 |
doRestart
|
48
|
1663 |
"restart - the selected context will be restarted"
|
0
|
1664 |
|
45
|
1665 |
inspecting ifTrue:[
|
52
|
1666 |
selectedContext isNil ifTrue:[
|
|
1667 |
^ self showError:'** select a context first **'
|
|
1668 |
].
|
48
|
1669 |
self interruptProcessWith:[selectedContext restart].
|
45
|
1670 |
^ self
|
|
1671 |
].
|
29
|
1672 |
|
0
|
1673 |
steppedContextAddress := nil.
|
|
1674 |
haveControl := false.
|
13
|
1675 |
exitAction := #restart.
|
|
1676 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
45
|
1677 |
"exit private event-loop"
|
|
1678 |
catchBlock notNil ifTrue:[catchBlock value].
|
53
|
1679 |
'DEBUGGER: oops, restart failed' errorPrintNL.
|
|
1680 |
"/ self warn:'restart failed'.
|
|
1681 |
restartButton turnOff.
|
|
1682 |
"/ restartButton disable
|
13
|
1683 |
].
|
0
|
1684 |
!
|
|
1685 |
|
|
1686 |
doTrace
|
22
|
1687 |
"tracing - not really implemented ..."
|
|
1688 |
|
0
|
1689 |
|v b|
|
|
1690 |
|
22
|
1691 |
self warn:'this function is not yet implemented'.
|
|
1692 |
|
|
1693 |
false ifTrue:[
|
0
|
1694 |
traceView isNil ifTrue:[
|
45
|
1695 |
v := StandardSystemView on:Display.
|
|
1696 |
v label:'Debugger-Trace'.
|
|
1697 |
v icon:icon.
|
0
|
1698 |
|
45
|
1699 |
b := Button label:'untrace' in:v.
|
|
1700 |
b origin:(0 @ 0) extent:(1.0 @ (b height)).
|
|
1701 |
b action:[
|
|
1702 |
StepInterruptPending := false.
|
|
1703 |
tracing := false.
|
|
1704 |
v unrealize.
|
|
1705 |
traceView := nil
|
|
1706 |
].
|
|
1707 |
traceView := ScrollableView for:TextCollector in:v.
|
|
1708 |
traceView origin:(0 @ (b height))
|
|
1709 |
extent:[v width @ (v height - b height)]
|
0
|
1710 |
].
|
|
1711 |
v realize.
|
22
|
1712 |
].
|
0
|
1713 |
tracing := true.
|
|
1714 |
!
|
|
1715 |
|
|
1716 |
doNoTrace
|
|
1717 |
traceView notNil ifTrue:[
|
45
|
1718 |
traceView topView destroy.
|
|
1719 |
traceView := nil.
|
22
|
1720 |
].
|
|
1721 |
tracing := false
|
0
|
1722 |
!
|
|
1723 |
|
45
|
1724 |
doStop
|
|
1725 |
"stop the process (if its running, otherwise this is a no-op)"
|
|
1726 |
|
|
1727 |
inspecting ifTrue:[
|
48
|
1728 |
self processAction:[inspectedProcess suspend].
|
45
|
1729 |
^ self
|
|
1730 |
].
|
|
1731 |
!
|
|
1732 |
|
0
|
1733 |
doContinue
|
|
1734 |
"continue from menu"
|
|
1735 |
|
45
|
1736 |
inspecting ifTrue:[
|
48
|
1737 |
self processAction:[inspectedProcess resume].
|
45
|
1738 |
^ self
|
|
1739 |
].
|
0
|
1740 |
canContinue ifTrue:[
|
45
|
1741 |
steppedContextAddress := nil.
|
|
1742 |
tracing := false.
|
|
1743 |
haveControl := false.
|
|
1744 |
exitAction := #continue.
|
|
1745 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
1746 |
"exit private event-loop"
|
|
1747 |
catchBlock notNil ifTrue:[catchBlock value].
|
53
|
1748 |
'DEBUGGER: oops, continue failed' errorPrintNL.
|
|
1749 |
"/ self warn:'continue failed'.
|
|
1750 |
continueButton turnOff.
|
|
1751 |
"/ continueButton disable
|
45
|
1752 |
].
|
15
|
1753 |
] ifFalse:[
|
45
|
1754 |
inspecting ifFalse:[
|
53
|
1755 |
'resuming top context' errorPrintNL.
|
45
|
1756 |
self showSelection:1.
|
|
1757 |
self doReturn
|
|
1758 |
]
|
29
|
1759 |
]
|
|
1760 |
!
|
|
1761 |
|
|
1762 |
doInspectContext
|
|
1763 |
"launch an inspector on the currently selected context"
|
|
1764 |
|
45
|
1765 |
contextView selection notNil ifTrue:[
|
|
1766 |
(contextView selectionValue startsWith:'**') ifFalse:[
|
|
1767 |
(contextArray at:(contextView selection)) inspect.
|
|
1768 |
]
|
|
1769 |
]
|
|
1770 |
!
|
|
1771 |
|
|
1772 |
autoUpdateOff
|
48
|
1773 |
"stop the update process"
|
|
1774 |
|
45
|
1775 |
updateProcess notNil ifTrue:[
|
|
1776 |
monitorToggle lampColor:(Color yellow).
|
|
1777 |
updateProcess terminate.
|
|
1778 |
updateProcess := nil
|
0
|
1779 |
]
|
45
|
1780 |
!
|
|
1781 |
|
|
1782 |
autoUpdateOn
|
48
|
1783 |
"fork a subprocess which updates the contextList in regular intervals"
|
|
1784 |
|
45
|
1785 |
updateProcess isNil ifTrue:[
|
|
1786 |
updateProcess :=
|
|
1787 |
[
|
|
1788 |
[true] whileTrue:[
|
|
1789 |
monitorToggle showLamp ifTrue:[
|
|
1790 |
monitorToggle lampColor:(Color yellow).
|
|
1791 |
] ifFalse:[
|
|
1792 |
monitorToggle activeForegroundColor:Color black.
|
|
1793 |
].
|
|
1794 |
(Delay forSeconds:0.25) wait.
|
|
1795 |
self updateContext.
|
|
1796 |
monitorToggle showLamp ifTrue:[
|
|
1797 |
monitorToggle lampColor:(Color red).
|
|
1798 |
] ifFalse:[
|
|
1799 |
monitorToggle activeForegroundColor:Color red.
|
|
1800 |
].
|
|
1801 |
(Delay forSeconds:0.25) wait.
|
|
1802 |
self updateContext.
|
|
1803 |
]
|
|
1804 |
] forkAt:(Processor activePriority - 1)
|
|
1805 |
]
|
|
1806 |
|
0
|
1807 |
! !
|