0
|
1 |
"
|
4
|
2 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
0
|
3 |
All Rights Reserved
|
|
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
|
0
|
15 |
contextView codeView
|
|
16 |
receiverInspector contextInspector
|
|
17 |
contextArray selectedContext
|
|
18 |
catchBlock grabber traceView tracing
|
7
|
19 |
bigStep steppedContextAddress canAbort
|
15
|
20 |
abortButton terminateButton continueButton
|
29
|
21 |
stepButton sendButton returnButton restartButton
|
|
22 |
exclusive inspecting nChainShown
|
|
23 |
processList'
|
|
24 |
classVariableNames:'CachedDebugger CachedExclusive'
|
0
|
25 |
poolDictionaries:''
|
|
26 |
category:'Interface-Debugger'
|
|
27 |
!
|
|
28 |
|
|
29 |
DebugView comment:'
|
4
|
30 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
0
|
31 |
All Rights Reserved
|
|
32 |
|
37
|
33 |
$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.13 1994-08-22 18:07:04 claus Exp $
|
29
|
34 |
'!
|
|
35 |
|
|
36 |
!DebugView class methodsFor:'documentation'!
|
|
37 |
|
|
38 |
copyright
|
|
39 |
"
|
|
40 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
|
41 |
All Rights Reserved
|
|
42 |
|
|
43 |
This software is furnished under a license and may be used
|
|
44 |
only in accordance with the terms of that license and with the
|
|
45 |
inclusion of the above copyright notice. This software may not
|
|
46 |
be provided or otherwise made available to, or used by, any
|
|
47 |
other person. No title to or ownership of the software is
|
|
48 |
hereby transferred.
|
|
49 |
"
|
|
50 |
!
|
0
|
51 |
|
29
|
52 |
version
|
|
53 |
"
|
37
|
54 |
$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.13 1994-08-22 18:07:04 claus Exp $
|
29
|
55 |
"
|
|
56 |
!
|
0
|
57 |
|
29
|
58 |
documentation
|
|
59 |
"
|
|
60 |
this class implements a graphical debugger interface.
|
|
61 |
The debugger usually sits on top of the faulting process,
|
|
62 |
taking over its event processing. Thus only the 'stopped' process is affected;
|
|
63 |
other processes continue to respond to events.
|
|
64 |
|
|
65 |
The one exception is when an error occurs within the dispatcher process
|
|
66 |
or in one of the eventhandler processes - in this case, the debugger
|
|
67 |
will sit on an exclusive display connection.
|
|
68 |
|
|
69 |
The whole debugging will be changed, once the required process primitives
|
|
70 |
are available, which allow control of another processes execution
|
|
71 |
(i.e. single-step, restart & return). The setup will be changed then,
|
|
72 |
to have the debugger control the debuggee (i.e. two processes)
|
35
|
73 |
|
|
74 |
See additional information in 'doc/misc/debugger.doc'.
|
29
|
75 |
"
|
|
76 |
! !
|
0
|
77 |
|
|
78 |
!DebugView class methodsFor:'instance creation'!
|
|
79 |
|
|
80 |
new
|
29
|
81 |
"return a DebugView - return a cached debugger if it already
|
0
|
82 |
exists"
|
|
83 |
|
29
|
84 |
|debugger active|
|
0
|
85 |
|
13
|
86 |
"need a blocking debugger if no processes or
|
29
|
87 |
or if its a timing/interrupt process
|
|
88 |
(because otherwise we would not get any events here ..."
|
|
89 |
|
|
90 |
active := Processor activeProcess.
|
13
|
91 |
|
29
|
92 |
(ProcessorScheduler isPureEventDriven
|
|
93 |
or:[(active priority > Processor userSchedulingPriority)
|
|
94 |
or:[active nameOrId endsWith:'dispatcher']]) ifTrue:[
|
|
95 |
CachedExclusive isNil ifTrue:[
|
|
96 |
debugger := self newExclusive
|
|
97 |
] ifFalse:[
|
|
98 |
debugger := CachedExclusive.
|
|
99 |
CachedExclusive := nil.
|
7
|
100 |
].
|
|
101 |
] ifFalse:[
|
29
|
102 |
CachedDebugger isNil ifTrue:[
|
|
103 |
debugger := super new.
|
|
104 |
debugger label:'Debugger'.
|
|
105 |
debugger icon:(Form fromFile:'Debugger.xbm' resolution:100).
|
|
106 |
] ifFalse:[
|
|
107 |
debugger := CachedDebugger.
|
|
108 |
CachedDebugger := nil.
|
|
109 |
]
|
7
|
110 |
].
|
|
111 |
^ debugger
|
0
|
112 |
!
|
|
113 |
|
13
|
114 |
newExclusive
|
|
115 |
"return a debugger for exclusive display access"
|
|
116 |
|
|
117 |
|debugger|
|
|
118 |
|
|
119 |
debugger := super on:ModalDisplay.
|
|
120 |
debugger label:'Debugger'.
|
|
121 |
debugger icon:(Form fromFile:'Debugger.xbm' resolution:100).
|
|
122 |
debugger exclusive:true.
|
|
123 |
^ debugger
|
|
124 |
!
|
|
125 |
|
0
|
126 |
newDebugger
|
|
127 |
"force creation of a new debugger"
|
|
128 |
|
29
|
129 |
CachedDebugger := nil.
|
|
130 |
CachedExclusive := nil
|
0
|
131 |
|
|
132 |
"DebugView newDebugger"
|
|
133 |
!
|
|
134 |
|
|
135 |
enterWithMessage:aString
|
|
136 |
"the standard way of entering the debugger - sent from Objects
|
|
137 |
error- and halt messages"
|
|
138 |
|
29
|
139 |
thisContext isRecursive ifTrue:[
|
|
140 |
^ MiniDebugger enterWithMessage:aString
|
|
141 |
].
|
|
142 |
^ self enter:(thisContext sender) withMessage:aString
|
|
143 |
|
|
144 |
"Debugger enterWithMessage:'hi there'"
|
|
145 |
!
|
|
146 |
|
|
147 |
enter
|
|
148 |
"another way of entering the debugger"
|
|
149 |
|
|
150 |
^ self enter:(thisContext sender) withMessage:'Debugger'
|
|
151 |
|
|
152 |
"Debugger enter"
|
|
153 |
!
|
|
154 |
|
|
155 |
enter:aContext
|
|
156 |
"enter the debugger on aContext"
|
|
157 |
|
|
158 |
^ self enter:aContext withMessage:'Debugger'
|
|
159 |
!
|
|
160 |
|
|
161 |
enter:aContext withMessage:aString
|
|
162 |
"the standard way of entering the debugger - sent from Objects
|
|
163 |
error- and halt messages"
|
|
164 |
|
|
165 |
|aDebugger|
|
0
|
166 |
|
14
|
167 |
thisContext isRecursive ifTrue:[
|
|
168 |
^ MiniDebugger enterWithMessage:'recursive error'.
|
|
169 |
].
|
|
170 |
|
0
|
171 |
StepInterruptPending := nil.
|
7
|
172 |
aDebugger := self new.
|
29
|
173 |
aDebugger label:aString , ' (' , Processor activeProcess nameOrId , ')'.
|
|
174 |
aDebugger enter:aContext.
|
0
|
175 |
^ nil
|
|
176 |
|
|
177 |
"nil halt"
|
|
178 |
!
|
|
179 |
|
29
|
180 |
openOn:aProcess
|
|
181 |
"start a debugger on aProcess
|
|
182 |
(actually not more than a good-looking inspector)"
|
15
|
183 |
|
29
|
184 |
|aDebugger label|
|
15
|
185 |
|
|
186 |
aDebugger := super new.
|
|
187 |
aDebugger icon:(Form fromFile:'Debugger.xbm' resolution:100).
|
29
|
188 |
aProcess notNil ifTrue:[
|
|
189 |
label := 'inspecting Debugger (' , aProcess nameOrId , ')'.
|
|
190 |
] ifFalse:[
|
|
191 |
label := 'no process'
|
|
192 |
].
|
|
193 |
aDebugger label:label.
|
15
|
194 |
aDebugger iconLabel:'Debugger'.
|
|
195 |
aDebugger openOn:aProcess.
|
|
196 |
^ nil
|
0
|
197 |
! !
|
|
198 |
|
|
199 |
!DebugView methodsFor:'initialization'!
|
|
200 |
|
|
201 |
initialize
|
15
|
202 |
|v panel hpanel bpanel|
|
0
|
203 |
|
|
204 |
super initialize.
|
|
205 |
|
|
206 |
font := font on:device.
|
|
207 |
|
7
|
208 |
busy := false.
|
14
|
209 |
exclusive := false.
|
29
|
210 |
inspecting := false.
|
0
|
211 |
exitAction := nil.
|
10
|
212 |
bigStep := false.
|
29
|
213 |
canContinue := false.
|
|
214 |
canAbort := false.
|
0
|
215 |
|
|
216 |
bpanel := HorizontalPanelView
|
|
217 |
origin:(0.0 @ 0.0)
|
|
218 |
extent:(1.0 @ (font height * 2))
|
|
219 |
in:self.
|
|
220 |
bpanel layout:#left.
|
|
221 |
|
7
|
222 |
terminateButton := Button
|
|
223 |
label:(resources at:'terminate')
|
20
|
224 |
action:[terminateButton turnOffWithoutRedraw. self doTerminate]
|
7
|
225 |
in:bpanel.
|
0
|
226 |
abortButton := Button
|
2
|
227 |
label:(resources at:'abort')
|
0
|
228 |
action:[abortButton turnOffWithoutRedraw. self doAbort]
|
|
229 |
in:bpanel.
|
29
|
230 |
returnButton := Button
|
|
231 |
label:(resources at:'return')
|
|
232 |
action:[returnButton turnOff. self doReturn]
|
20
|
233 |
in:bpanel.
|
|
234 |
|
|
235 |
restartButton := Button
|
|
236 |
label:(resources at:'restart')
|
|
237 |
action:[restartButton turnOff. self doRestart]
|
|
238 |
in:bpanel.
|
|
239 |
|
0
|
240 |
continueButton := Button
|
2
|
241 |
label:(resources at:'continue')
|
0
|
242 |
action:[continueButton turnOffWithoutRedraw. self doContinue]
|
|
243 |
in:bpanel.
|
|
244 |
stepButton := Button
|
2
|
245 |
label:(resources at:'step')
|
0
|
246 |
action:[stepButton turnOff. self doStep]
|
|
247 |
in:bpanel.
|
|
248 |
sendButton := Button
|
2
|
249 |
label:(resources at:'send')
|
0
|
250 |
action:[sendButton turnOff. self doSend]
|
|
251 |
in:bpanel.
|
|
252 |
|
|
253 |
panel := VariableVerticalPanel
|
|
254 |
origin:(0.0 @ bpanel height)
|
|
255 |
corner:(1.0 @ 1.0)
|
|
256 |
in:self.
|
|
257 |
|
|
258 |
v := ScrollableView for:SelectionInListView in:panel.
|
|
259 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 0.25).
|
|
260 |
|
|
261 |
contextView := v scrolledView.
|
|
262 |
contextView action:[:lineNr | self showSelection:lineNr].
|
|
263 |
|
|
264 |
v := ScrollableView for:CodeView in:panel.
|
|
265 |
v origin:(0.0 @ 0.25) corner:(1.0 @ 0.75).
|
|
266 |
|
|
267 |
codeView := v scrolledView.
|
|
268 |
|
|
269 |
hpanel := VariableHorizontalPanel in:panel.
|
|
270 |
hpanel origin:(0.0 @ 0.75) corner:(1.0 @ 1.0).
|
|
271 |
|
|
272 |
receiverInspector := InspectorView
|
|
273 |
origin:(0.0 @ 0.0) corner:(0.5 @ 1.0)
|
|
274 |
in:hpanel.
|
|
275 |
|
|
276 |
contextInspector := ContextInspectorView
|
|
277 |
origin:(0.5 @ 0.0) corner:(1.0 @ 1.0)
|
|
278 |
in:hpanel
|
|
279 |
!
|
|
280 |
|
|
281 |
initializeMiddleButtonMenu
|
|
282 |
|labels|
|
|
283 |
|
22
|
284 |
labels := resources array:#(
|
29
|
285 |
'show more'
|
|
286 |
'-'
|
22
|
287 |
"
|
|
288 |
'continue'
|
7
|
289 |
'terminate'
|
0
|
290 |
'abort'
|
|
291 |
'-'
|
|
292 |
'step'
|
|
293 |
'send'
|
22
|
294 |
'-'
|
29
|
295 |
'return'
|
|
296 |
'restart'
|
0
|
297 |
'-'
|
22
|
298 |
"
|
29
|
299 |
'remove breakpoint'
|
0
|
300 |
'-'
|
29
|
301 |
'implementors ...'
|
|
302 |
'senders ...'
|
|
303 |
'-'
|
|
304 |
'inspect context'
|
0
|
305 |
'-'
|
|
306 |
'exit smalltalk'
|
|
307 |
).
|
|
308 |
|
|
309 |
contextView
|
|
310 |
middleButtonMenu:(PopUpMenu
|
|
311 |
labels:labels
|
22
|
312 |
selectors:#(
|
29
|
313 |
doShowMore
|
|
314 |
nil
|
22
|
315 |
"
|
|
316 |
doContinue
|
7
|
317 |
doTerminate
|
0
|
318 |
doAbort
|
|
319 |
nil
|
|
320 |
doStep
|
|
321 |
doSend
|
22
|
322 |
nil
|
29
|
323 |
doReturn
|
|
324 |
doRestart
|
0
|
325 |
nil
|
22
|
326 |
"
|
29
|
327 |
doRemoveBreakpoint
|
0
|
328 |
nil
|
29
|
329 |
doImplementors
|
|
330 |
doSenders
|
|
331 |
nil
|
|
332 |
doInspectContext
|
0
|
333 |
nil
|
22
|
334 |
doExit
|
|
335 |
)
|
0
|
336 |
receiver:self
|
29
|
337 |
for:contextView).
|
0
|
338 |
!
|
|
339 |
|
|
340 |
addToCurrentProject
|
|
341 |
"ignored here"
|
|
342 |
|
|
343 |
^ self
|
|
344 |
!
|
|
345 |
|
|
346 |
createOnTop
|
|
347 |
^ false "true"
|
13
|
348 |
!
|
|
349 |
|
|
350 |
realize
|
|
351 |
super realize.
|
|
352 |
exclusive ifTrue:[
|
|
353 |
windowGroup := nil
|
|
354 |
].
|
0
|
355 |
! !
|
|
356 |
|
|
357 |
!DebugView methodsFor:'interrupt handling'!
|
|
358 |
|
|
359 |
stepInterrupt
|
29
|
360 |
|where here s isWrap method lastWrappedConAddr wrappedMethod|
|
0
|
361 |
|
29
|
362 |
"
|
|
363 |
kludge, check if we are in a wrapper methods hidden setup-sequence
|
|
364 |
"
|
|
365 |
here := thisContext. "stepInterrupt"
|
|
366 |
here := here sender. "the interrupted context"
|
|
367 |
|
|
368 |
"/ 'here in ' print.
|
|
369 |
"/ ((ObjectMemory addressOf:here) printStringRadix:16)print. '' printNL.
|
10
|
370 |
|
29
|
371 |
where := here.
|
|
372 |
isWrap := false.
|
|
373 |
wrappedMethod := nil.
|
|
374 |
5 timesRepeat:[
|
|
375 |
"/ where selector printNL.
|
|
376 |
method := where method.
|
|
377 |
(method notNil and:[method isWrapped]) ifTrue:[
|
0
|
378 |
"
|
29
|
379 |
in a wrapper method
|
0
|
380 |
"
|
29
|
381 |
wrappedMethod ~~ method ifTrue:[
|
|
382 |
wrappedMethod := method.
|
|
383 |
lastWrappedConAddr := ObjectMemory addressOf:where.
|
|
384 |
where sender receiver == method originalMethod ifFalse:[
|
|
385 |
isWrap := true.
|
|
386 |
]
|
|
387 |
] ifFalse:[
|
7
|
388 |
(ObjectMemory addressOf:where) == steppedContextAddress ifTrue:[
|
29
|
389 |
"/ 'change stepCon from: ' print.
|
|
390 |
"/ (steppedContextAddress printStringRadix:16)print.
|
|
391 |
"/ ' to: ' print.
|
|
392 |
"/ (lastWrappedConAddr printStringRadix:16)printNL.
|
|
393 |
|
|
394 |
steppedContextAddress := lastWrappedConAddr
|
|
395 |
]
|
|
396 |
]
|
|
397 |
].
|
|
398 |
where := where sender
|
|
399 |
].
|
|
400 |
|
|
401 |
isWrap ifTrue:[
|
|
402 |
"/ 'ignore wrap' printNL.
|
|
403 |
"
|
|
404 |
ignore, while in wrappers hidden setup
|
|
405 |
"
|
|
406 |
where := nil. here := nil.
|
|
407 |
ObjectMemory flushInlineCaches.
|
|
408 |
StepInterruptPending := true.
|
|
409 |
InterruptPending := true.
|
|
410 |
InStepInterrupt := nil.
|
|
411 |
^ nil
|
|
412 |
].
|
|
413 |
|
|
414 |
"
|
|
415 |
is this for a send or a step ?
|
|
416 |
"
|
|
417 |
bigStep ifTrue:[
|
|
418 |
"
|
|
419 |
a step - ignore all contexts below the interresting one
|
|
420 |
"
|
|
421 |
where := here. "the interrupted context"
|
|
422 |
(ObjectMemory addressOf:where) == steppedContextAddress ifFalse:[
|
|
423 |
where := where sender.
|
|
424 |
"/ 'look for ' print.
|
|
425 |
"/ (steppedContextAddress printStringRadix:16)print. '' printNL.
|
|
426 |
(ObjectMemory addressOf:where) == steppedContextAddress ifFalse:[
|
|
427 |
"
|
|
428 |
check if we are in a context below steppedContext
|
|
429 |
(i.e. if steppedContext can be reached from
|
|
430 |
interrupted context. Not using context-ref but its
|
|
431 |
address to avoid creation of many useless contexts.)
|
|
432 |
"
|
|
433 |
[where notNil] whileTrue:[
|
|
434 |
"/ ((ObjectMemory addressOf:where) printStringRadix:16)print. ' ' print.
|
|
435 |
"/ where selector printNL.
|
|
436 |
(ObjectMemory addressOf:where) == steppedContextAddress ifTrue:[
|
|
437 |
"/ 'found it - below' printNL.
|
|
438 |
"
|
|
439 |
found the interresting context somwehere up in the
|
|
440 |
chain. We seem to be still below the interresting one ...
|
|
441 |
"
|
|
442 |
tracing == true ifTrue:[
|
|
443 |
here printString printNewline
|
|
444 |
].
|
|
445 |
where := nil. here := nil.
|
|
446 |
"
|
|
447 |
yes, a context below
|
|
448 |
- continue and schedule another stepInterrupt.
|
|
449 |
Must flush caches since optimized methods not always
|
|
450 |
look for pending interrupts
|
|
451 |
"
|
|
452 |
ObjectMemory flushInlineCaches.
|
|
453 |
StepInterruptPending := true.
|
|
454 |
InterruptPending := true.
|
|
455 |
InStepInterrupt := nil.
|
|
456 |
^ nil
|
0
|
457 |
].
|
29
|
458 |
where := where sender
|
0
|
459 |
].
|
29
|
460 |
s := 'left stepped method'
|
|
461 |
] ifTrue:[
|
|
462 |
"/ 'found it right in sender' printNL.
|
|
463 |
s := 'after step'
|
14
|
464 |
].
|
|
465 |
] ifTrue:[
|
29
|
466 |
"/ 'found it right away' printNL.
|
14
|
467 |
s := 'after step'
|
0
|
468 |
].
|
29
|
469 |
tracing := false.
|
0
|
470 |
bigStep := false.
|
|
471 |
] ifFalse:[
|
29
|
472 |
|
|
473 |
"
|
|
474 |
a send
|
|
475 |
"
|
0
|
476 |
steppedContextAddress := nil.
|
7
|
477 |
s := 'after send'
|
0
|
478 |
].
|
7
|
479 |
|
29
|
480 |
name := Processor activeProcess nameOrId.
|
7
|
481 |
self label:(s , ' (process: ' , name , ')').
|
|
482 |
|
0
|
483 |
"release refs to context"
|
|
484 |
where := nil. here := nil.
|
29
|
485 |
self enter:thisContext sender
|
0
|
486 |
! !
|
|
487 |
|
|
488 |
!DebugView methodsFor:'basic'!
|
|
489 |
|
|
490 |
enter
|
22
|
491 |
"enter the debugger - on the sending context"
|
|
492 |
|
|
493 |
|where|
|
|
494 |
|
|
495 |
busy := true.
|
|
496 |
|
29
|
497 |
where := thisContext. "enter"
|
|
498 |
where := where sender. "the calling context"
|
22
|
499 |
where notNil ifTrue:[
|
|
500 |
(where receiver == DebugView) ifTrue:[
|
|
501 |
where := where sender
|
|
502 |
]
|
|
503 |
"where is now interrupted methods context"
|
|
504 |
].
|
|
505 |
^ self enter:where
|
|
506 |
!
|
|
507 |
|
|
508 |
enter:aContext
|
0
|
509 |
"enter the debugger - get and display the context, then start an
|
|
510 |
exclusive event loop on top of eveything else"
|
|
511 |
|
35
|
512 |
|con selection|
|
0
|
513 |
|
14
|
514 |
busy := true.
|
29
|
515 |
inspecting := false.
|
10
|
516 |
bigStep := false.
|
29
|
517 |
nChainShown := 50.
|
10
|
518 |
|
|
519 |
"if debugger is entered while a box has grabbed the
|
|
520 |
pointer, we must ungrab - otherwise X wont talk to
|
29
|
521 |
us here
|
|
522 |
"
|
0
|
523 |
ActiveGrab notNil ifTrue:[
|
|
524 |
grabber := ActiveGrab.
|
|
525 |
ActiveGrab device ungrabPointer.
|
|
526 |
ActiveGrab device synchronizeOutput.
|
|
527 |
ActiveGrab := nil
|
|
528 |
] ifFalse:[
|
|
529 |
grabber := nil
|
|
530 |
].
|
|
531 |
|
7
|
532 |
drawableId notNil ifTrue:[
|
|
533 |
"not the first time - realize at old position"
|
35
|
534 |
terminateButton turnOffWithoutRedraw.
|
|
535 |
continueButton turnOffWithoutRedraw.
|
|
536 |
abortButton turnOffWithoutRedraw.
|
|
537 |
stepButton turnOffWithoutRedraw.
|
|
538 |
sendButton turnOffWithoutRedraw.
|
7
|
539 |
self rerealize
|
|
540 |
] ifFalse:[
|
13
|
541 |
exclusive ifFalse:[
|
|
542 |
windowGroup isNil ifTrue:[
|
|
543 |
windowGroup := WindowGroup new.
|
|
544 |
windowGroup addTopView:self.
|
|
545 |
].
|
|
546 |
].
|
15
|
547 |
self realize.
|
|
548 |
self iconLabel:'Debugger'.
|
7
|
549 |
].
|
13
|
550 |
|
29
|
551 |
"
|
|
552 |
bring us to the top
|
|
553 |
"
|
0
|
554 |
self raise.
|
|
555 |
Display synchronizeOutput.
|
|
556 |
|
29
|
557 |
"
|
|
558 |
get the walkback list
|
|
559 |
"
|
22
|
560 |
self setContext:aContext.
|
0
|
561 |
|
29
|
562 |
"
|
|
563 |
and find one to show
|
|
564 |
"
|
|
565 |
steppedContextAddress isNil ifTrue:[
|
|
566 |
"
|
|
567 |
preselect a more interresting context, (where halt/raise was ...)
|
|
568 |
"
|
|
569 |
selection := self interrestingContextFrom:aContext.
|
0
|
570 |
] ifFalse:[
|
29
|
571 |
"
|
|
572 |
if we came here by a big-step, show the method where we are
|
|
573 |
"
|
|
574 |
steppedContextAddress notNil ifTrue:[
|
|
575 |
(ObjectMemory addressOf:aContext) == steppedContextAddress ifTrue:[
|
|
576 |
selection := 1
|
|
577 |
] ifFalse:[
|
|
578 |
(ObjectMemory addressOf:aContext sender) == steppedContextAddress ifTrue:[
|
|
579 |
selection := 2
|
|
580 |
]
|
22
|
581 |
]
|
0
|
582 |
]
|
|
583 |
].
|
|
584 |
|
|
585 |
selection notNil ifTrue:[
|
|
586 |
self showSelection:selection.
|
|
587 |
contextView selection:selection
|
|
588 |
].
|
|
589 |
|
35
|
590 |
canAbort := Object abortSignal isHandled.
|
|
591 |
canAbort ifTrue:[
|
15
|
592 |
abortButton enable.
|
|
593 |
contextView middleButtonMenu enable:#doAbort.
|
7
|
594 |
] ifFalse:[
|
15
|
595 |
abortButton disable.
|
|
596 |
contextView middleButtonMenu disable:#doAbort.
|
7
|
597 |
].
|
14
|
598 |
exclusive ifTrue:[
|
15
|
599 |
terminateButton disable.
|
|
600 |
contextView middleButtonMenu disable:#doTerminate.
|
14
|
601 |
] ifFalse:[
|
15
|
602 |
terminateButton enable.
|
|
603 |
contextView middleButtonMenu enable:#doTerminate.
|
14
|
604 |
].
|
7
|
605 |
|
29
|
606 |
"
|
|
607 |
enter private event handling loop
|
|
608 |
"
|
0
|
609 |
canContinue := true.
|
|
610 |
self controlLoop.
|
|
611 |
|
|
612 |
contextArray := nil.
|
29
|
613 |
receiverInspector release.
|
|
614 |
contextInspector release.
|
0
|
615 |
|
|
616 |
(exitAction == #step) ifFalse:[
|
|
617 |
self unrealize.
|
|
618 |
device synchronizeOutput.
|
29
|
619 |
(exitAction == #abort) ifTrue:[
|
|
620 |
selectedContext := nil.
|
|
621 |
InInterrupt := nil.
|
|
622 |
busy := false.
|
|
623 |
exclusive ifTrue:[CachedExclusive := self] ifFalse:[CachedDebugger := self].
|
|
624 |
Object abortSignal raise.
|
|
625 |
'abort failed' errorPrintNewline
|
|
626 |
].
|
|
627 |
(exitAction == #return) ifTrue:[
|
0
|
628 |
selectedContext notNil ifTrue:[
|
|
629 |
con := selectedContext.
|
|
630 |
selectedContext := nil.
|
|
631 |
InInterrupt := nil.
|
20
|
632 |
busy := false.
|
29
|
633 |
exclusive ifTrue:[CachedExclusive := self] ifFalse:[CachedDebugger := self].
|
0
|
634 |
con unwind.
|
29
|
635 |
'cannot return selected context' errorPrintNewline
|
0
|
636 |
]
|
|
637 |
] ifFalse:[
|
|
638 |
(exitAction == #restart) ifTrue:[
|
|
639 |
selectedContext notNil ifTrue:[
|
|
640 |
con := selectedContext.
|
|
641 |
selectedContext := nil.
|
|
642 |
InInterrupt := nil.
|
20
|
643 |
busy := false.
|
29
|
644 |
exclusive ifTrue:[CachedExclusive := self] ifFalse:[CachedDebugger := self].
|
0
|
645 |
con restart.
|
29
|
646 |
'cannot restart selected context' errorPrintNewline
|
0
|
647 |
]
|
|
648 |
] ifFalse:[
|
|
649 |
(exitAction == #terminate) ifTrue:[
|
|
650 |
selectedContext := nil.
|
|
651 |
InInterrupt := nil.
|
20
|
652 |
busy := false.
|
29
|
653 |
exclusive ifTrue:[CachedExclusive := self] ifFalse:[CachedDebugger := self].
|
13
|
654 |
Processor activeProcess terminate.
|
29
|
655 |
'cannot terminate process' errorPrintNewline
|
0
|
656 |
]
|
|
657 |
]
|
|
658 |
]
|
|
659 |
].
|
|
660 |
|
|
661 |
selectedContext := nil.
|
|
662 |
|
|
663 |
grabber notNil ifTrue:[
|
|
664 |
grabber device grabPointerIn:(grabber id).
|
|
665 |
ActiveGrab := grabber
|
|
666 |
].
|
|
667 |
|
|
668 |
(exitAction == #step) ifTrue:[
|
|
669 |
"scedule another stepInterrupt
|
|
670 |
- must flush caches since optimized methods not always
|
|
671 |
look for pending interrupts"
|
|
672 |
ObjectMemory flushInlineCaches.
|
|
673 |
|
2
|
674 |
ObjectMemory stepInterruptHandler:self.
|
0
|
675 |
StepInterruptPending := true.
|
10
|
676 |
InterruptPending := true.
|
|
677 |
InStepInterrupt := nil
|
20
|
678 |
] ifFalse:[
|
22
|
679 |
busy := false.
|
29
|
680 |
exclusive ifTrue:[CachedExclusive := self] ifFalse:[CachedDebugger := self]
|
0
|
681 |
]
|
|
682 |
!
|
|
683 |
|
15
|
684 |
openOn:aProcess
|
|
685 |
"enter the debugger on a process -
|
|
686 |
in this case, we are just inspecting the context chain of the process,
|
|
687 |
not offering continue/abort/step and send functions.
|
|
688 |
Also, we do not run on top of the debugger process, but as a separate
|
22
|
689 |
one. (think of it as an inspector showing more detail)"
|
15
|
690 |
|
|
691 |
busy := true.
|
|
692 |
bigStep := false.
|
29
|
693 |
inspecting := true.
|
|
694 |
nChainShown := 50.
|
15
|
695 |
|
20
|
696 |
"can only look into process - context chain is not active"
|
29
|
697 |
canContinue := true.
|
|
698 |
|
15
|
699 |
abortButton disable.
|
|
700 |
sendButton disable.
|
|
701 |
stepButton disable.
|
|
702 |
continueButton disable.
|
29
|
703 |
returnButton disable.
|
20
|
704 |
restartButton disable.
|
15
|
705 |
|
|
706 |
self initializeMiddleButtonMenu.
|
|
707 |
contextView middleButtonMenu disable:#doAbort.
|
|
708 |
contextView middleButtonMenu disable:#doSend.
|
|
709 |
contextView middleButtonMenu disable:#doStep.
|
|
710 |
contextView middleButtonMenu disable:#doContinue.
|
29
|
711 |
contextView middleButtonMenu disable:#doReturn.
|
15
|
712 |
contextView middleButtonMenu disable:#doRestart.
|
|
713 |
contextView middleButtonMenu disable:#doTraceStep.
|
29
|
714 |
contextView middleButtonMenu disable:#doTerminate.
|
|
715 |
contextView middleButtonMenu disable:#doRemoveBreakpoint.
|
|
716 |
contextView middleButtonMenu disable:#doImplementors.
|
|
717 |
contextView middleButtonMenu disable:#doSenders.
|
|
718 |
contextView middleButtonMenu disable:#doInspectContext.
|
15
|
719 |
|
29
|
720 |
aProcess isNil ifTrue:[
|
15
|
721 |
terminateButton disable.
|
29
|
722 |
] ifFalse:[
|
|
723 |
aProcess suspendedContext isNil ifTrue:[
|
|
724 |
terminateButton disable.
|
|
725 |
contextView middleButtonMenu disable:#doTerminate.
|
|
726 |
].
|
15
|
727 |
|
29
|
728 |
self setContext:aProcess suspendedContext.
|
|
729 |
|
|
730 |
catchBlock := [
|
|
731 |
contextArray := nil.
|
|
732 |
selectedContext := nil.
|
|
733 |
(exitAction == #terminate) ifTrue:[
|
15
|
734 |
aProcess terminate.
|
29
|
735 |
].
|
|
736 |
super destroy
|
15
|
737 |
].
|
|
738 |
].
|
29
|
739 |
self open
|
|
740 |
! !
|
|
741 |
|
|
742 |
!DebugView methodsFor:'private control loop'!
|
15
|
743 |
|
0
|
744 |
controlLoop
|
|
745 |
"this is a kludge:
|
|
746 |
start a dispatchloop which exits when
|
29
|
747 |
either continue, return or step is pressed
|
0
|
748 |
"
|
|
749 |
|
|
750 |
haveControl := true.
|
|
751 |
[haveControl] whileTrue:[
|
|
752 |
self controlLoopCatchingErrors
|
|
753 |
].
|
|
754 |
catchBlock := nil.
|
|
755 |
|
|
756 |
codeView contents:nil.
|
|
757 |
codeView acceptAction:nil.
|
|
758 |
contextView contents:nil.
|
29
|
759 |
receiverInspector release.
|
|
760 |
contextInspector release
|
0
|
761 |
!
|
|
762 |
|
|
763 |
controlLoopCatchingErrors
|
|
764 |
"setup a catch-block"
|
|
765 |
catchBlock := [^ nil].
|
|
766 |
|
13
|
767 |
exclusive ifTrue:[
|
|
768 |
"if we do not have multiple processes or its a system process
|
|
769 |
we start another dispatch loop, which exits when
|
29
|
770 |
either continue, return or step is pressed
|
13
|
771 |
or (via the catchBlock) if an error occurs.
|
|
772 |
Since our display is an extra exclusive one (ModalDisplay)
|
|
773 |
all processing for normal views stops here ...
|
|
774 |
"
|
14
|
775 |
device dispatchModalWhile:[haveControl]
|
13
|
776 |
] ifFalse:[
|
|
777 |
"we do have multiple processes -
|
|
778 |
simply enter the DebugViews-Windowgroup event loop.
|
|
779 |
effectively suspending event processing for the currently
|
|
780 |
active group.
|
|
781 |
"
|
14
|
782 |
SignalSet anySignal handle:[:ex |
|
29
|
783 |
'error within debugger ignored' errorPrintNewline.
|
14
|
784 |
ex return.
|
|
785 |
] do:[
|
29
|
786 |
windowGroup eventLoopWhile:[true]
|
14
|
787 |
]
|
13
|
788 |
]
|
29
|
789 |
! !
|
|
790 |
|
|
791 |
!DebugView methodsFor:'private'!
|
|
792 |
|
|
793 |
busy
|
|
794 |
^ busy
|
|
795 |
!
|
|
796 |
|
|
797 |
exclusive:aBoolean
|
|
798 |
exclusive := aBoolean
|
|
799 |
!
|
|
800 |
|
|
801 |
interrestingContextFrom:aContext
|
|
802 |
"return an interresting contexts offset, or nil.
|
|
803 |
Just to add a bit of comfort :-)"
|
|
804 |
|
|
805 |
|c found offset sel|
|
|
806 |
|
|
807 |
"somewhere, at the bottom, there must be a raise ..."
|
|
808 |
|
|
809 |
c := aContext.
|
|
810 |
1 to:5 do:[:i |
|
|
811 |
c isNil ifTrue:[^ 1 "^ nil"].
|
|
812 |
sel := c selector.
|
|
813 |
((sel == #raise)
|
|
814 |
or:[(sel == #raiseRequestWith:)
|
|
815 |
or:[(sel == #raiseRequestWith:errorString:)]])
|
|
816 |
ifTrue:[
|
|
817 |
offset := i.
|
|
818 |
found := c
|
|
819 |
].
|
|
820 |
c := c sender.
|
|
821 |
].
|
|
822 |
|
|
823 |
(c := found) isNil ifTrue:[^ 1 "nil"].
|
|
824 |
|
|
825 |
"
|
|
826 |
got it; move up, for the one that called the raise
|
|
827 |
"
|
|
828 |
(c := c sender) isNil ifTrue:[^ offset].
|
|
829 |
offset := offset + 1.
|
|
830 |
|
|
831 |
"
|
|
832 |
now, we are one above the raise
|
|
833 |
"
|
|
834 |
|
|
835 |
"
|
|
836 |
if raise implementation reuses raise code ...
|
|
837 |
"
|
|
838 |
[
|
|
839 |
#( raise raiseRequestWith: #raiseRequestWith:errorString: )
|
|
840 |
includes:c selector
|
|
841 |
] whileTrue:[
|
|
842 |
(c := c sender) isNil ifTrue:[^ offset].
|
|
843 |
offset := offset + 1.
|
|
844 |
].
|
|
845 |
|
|
846 |
"
|
|
847 |
if the sender of the raise is one of objects error methods ...
|
|
848 |
"
|
|
849 |
( #( halt halt:
|
|
850 |
error error:
|
|
851 |
doesNotUnderstand:
|
|
852 |
subclassResponsibility
|
|
853 |
primitiveFailed) includes:c selector)
|
|
854 |
ifTrue:[
|
|
855 |
c selector == #doesNotUnderstand: ifTrue:[
|
|
856 |
"
|
|
857 |
one more up, to get to the originating context
|
|
858 |
"
|
|
859 |
(c := c sender) isNil ifTrue:[^ offset].
|
|
860 |
offset := offset + 1.
|
|
861 |
].
|
|
862 |
(c := c sender) isNil ifTrue:[^ offset].
|
|
863 |
offset := offset + 1.
|
|
864 |
].
|
|
865 |
|
|
866 |
^ offset
|
0
|
867 |
!
|
|
868 |
|
|
869 |
setContext:aContext
|
29
|
870 |
"show calling chain from aContext in the walk-back listview"
|
|
871 |
|
|
872 |
|con text method caller caller2|
|
0
|
873 |
|
|
874 |
aContext isNil ifTrue:[
|
|
875 |
text := Array with:'** no context **'.
|
29
|
876 |
contextArray := nil.
|
|
877 |
contextView middleButtonMenu disable:#doShowMore.
|
0
|
878 |
] ifFalse:[
|
29
|
879 |
text := OrderedCollection new:nChainShown.
|
|
880 |
contextArray := OrderedCollection new:nChainShown.
|
0
|
881 |
con := aContext.
|
29
|
882 |
|
|
883 |
"
|
|
884 |
get them all
|
|
885 |
"
|
|
886 |
[con notNil and:[contextArray size <= nChainShown]] whileTrue:[
|
|
887 |
contextArray add:con.
|
|
888 |
text add:(con printString).
|
|
889 |
|
|
890 |
method := con method.
|
|
891 |
(method notNil and:[method isWrapped]) ifTrue:[
|
|
892 |
"
|
|
893 |
kludge: if its a wrapped method, then hide the wrap-call
|
|
894 |
"
|
|
895 |
caller := con sender.
|
|
896 |
(caller notNil and:[caller receiver == method originalMethod]) ifTrue:[
|
|
897 |
caller2 := caller sender.
|
|
898 |
(caller2 notNil and:[caller2 method == method]) ifTrue:[
|
|
899 |
con := caller2
|
|
900 |
]
|
|
901 |
].
|
|
902 |
caller := caller2 := nil
|
|
903 |
].
|
0
|
904 |
con := con sender
|
|
905 |
].
|
29
|
906 |
|
|
907 |
"
|
|
908 |
did we reach the end ?
|
|
909 |
"
|
|
910 |
con isNil ifTrue:[
|
|
911 |
contextView middleButtonMenu disable:#doShowMore.
|
|
912 |
|
|
913 |
"
|
|
914 |
the very last one is the startup context
|
|
915 |
(in main) - it has nil as receiver and nil as selector
|
|
916 |
"
|
|
917 |
contextArray last selector isNil ifTrue:[
|
|
918 |
contextArray removeLast.
|
|
919 |
text removeLast
|
|
920 |
]
|
|
921 |
] ifFalse:[
|
|
922 |
contextView middleButtonMenu enable:#doShowMore.
|
|
923 |
].
|
0
|
924 |
].
|
29
|
925 |
|
|
926 |
contextView setList: "list:" text.
|
|
927 |
receiverInspector release.
|
|
928 |
contextInspector release.
|
|
929 |
|
|
930 |
contextView middleButtonMenu disable:#doRemoveBreakpoint.
|
|
931 |
contextView middleButtonMenu disable:#doImplementors.
|
|
932 |
contextView middleButtonMenu disable:#doSenders.
|
0
|
933 |
! !
|
|
934 |
|
|
935 |
!DebugView methodsFor:'user interaction'!
|
|
936 |
|
|
937 |
showSelection:lineNr
|
|
938 |
"user clicked on a header line - show selected code in textView"
|
|
939 |
|
|
940 |
|con homeContext sel method code
|
7
|
941 |
implementorClass lineNrInMethod rec|
|
0
|
942 |
|
|
943 |
contextArray notNil ifTrue:[
|
|
944 |
con := contextArray at:lineNr.
|
|
945 |
lineNrInMethod := con lineNumber.
|
|
946 |
con isBlockContext ifTrue:[
|
|
947 |
homeContext := con methodHome
|
|
948 |
] ifFalse:[
|
|
949 |
homeContext := con
|
|
950 |
].
|
35
|
951 |
contextInspector inspect:con.
|
15
|
952 |
homeContext notNil ifTrue:[
|
|
953 |
sel := homeContext selector.
|
|
954 |
sel notNil ifTrue:[
|
29
|
955 |
implementorClass := homeContext searchClass whichClassImplements:sel.
|
15
|
956 |
implementorClass isNil ifTrue:[
|
|
957 |
codeView contents:'** no method - no source **'
|
|
958 |
] ifFalse:[
|
|
959 |
method := implementorClass compiledMethodAt:sel.
|
|
960 |
code := method source.
|
|
961 |
code isNil ifTrue:[
|
35
|
962 |
method sourceFileName notNil ifTrue:[
|
|
963 |
codeView contents:('** no sourcefile: ' ,
|
|
964 |
method sourceFileName ,
|
|
965 |
' **')
|
|
966 |
] ifFalse:[
|
|
967 |
codeView contents:'** no source **'
|
|
968 |
]
|
15
|
969 |
]
|
|
970 |
].
|
0
|
971 |
code isNil ifTrue:[
|
15
|
972 |
codeView acceptAction:nil.
|
|
973 |
] ifFalse:[
|
|
974 |
codeView contents:code.
|
|
975 |
(lineNrInMethod notNil and:[lineNrInMethod ~~ 0]) ifTrue:[
|
|
976 |
lineNrInMethod > codeView list size ifTrue:[
|
|
977 |
lineNrInMethod := codeView list size + 1
|
|
978 |
].
|
|
979 |
codeView selectLine:lineNrInMethod.
|
|
980 |
codeView makeSelectionVisible
|
|
981 |
].
|
29
|
982 |
codeView acceptAction:[:code | self codeAccept:code asString]
|
15
|
983 |
].
|
|
984 |
|
|
985 |
"fetch rec here - so we wont need con in doItAction"
|
|
986 |
rec := homeContext receiver.
|
|
987 |
receiverInspector inspect:rec.
|
|
988 |
codeView doItAction:[:theCode |
|
37
|
989 |
rec class compiler
|
|
990 |
evaluate:theCode
|
|
991 |
in:nil
|
|
992 |
receiver:rec
|
|
993 |
notifying:codeView
|
|
994 |
logged:true
|
|
995 |
ifFail:nil
|
0
|
996 |
]
|
29
|
997 |
]
|
0
|
998 |
].
|
|
999 |
selectedContext := homeContext
|
|
1000 |
].
|
|
1001 |
"clear out locals to prevent keeping around unneeded contexts (due to the
|
|
1002 |
block held in codeView).
|
|
1003 |
(not really needed, since stuff gets collected away sooner or later ..."
|
|
1004 |
|
|
1005 |
con := nil.
|
29
|
1006 |
homeContext := nil.
|
|
1007 |
|
|
1008 |
contextView middleButtonMenu enable:#doImplementors.
|
|
1009 |
contextView middleButtonMenu enable:#doSenders.
|
|
1010 |
contextView middleButtonMenu enable:#doInspectContext.
|
|
1011 |
|
|
1012 |
(method notNil and:[method isWrapped]) ifTrue:[
|
|
1013 |
contextView middleButtonMenu enable:#doRemoveBreakpoint.
|
|
1014 |
] ifFalse:[
|
|
1015 |
contextView middleButtonMenu disable:#doRemoveBreakpoint.
|
|
1016 |
]
|
0
|
1017 |
!
|
|
1018 |
|
|
1019 |
codeAccept:someCode
|
|
1020 |
"user wants some code to be recompiled - must unwind stack since everything above
|
|
1021 |
and including selected method cannot be continued"
|
|
1022 |
|
|
1023 |
"walk up context chain and find highest context which is either the selected context,
|
|
1024 |
or - if its a block-context - whose home is the selected context"
|
|
1025 |
|
|
1026 |
|con top sel implementorClass method newMethod|
|
|
1027 |
|
|
1028 |
codeView cursor:Cursor execute.
|
|
1029 |
|
|
1030 |
con := selectedContext.
|
|
1031 |
top := con.
|
|
1032 |
[con notNil] whileTrue:[
|
|
1033 |
(con methodHome == selectedContext) ifTrue:[
|
|
1034 |
top := con
|
|
1035 |
].
|
|
1036 |
con := con sender
|
|
1037 |
].
|
|
1038 |
"now, remove everything up to and including top from context chain"
|
|
1039 |
|
|
1040 |
"
|
|
1041 |
self setContext:(top sender).
|
|
1042 |
"
|
|
1043 |
|
|
1044 |
sel := selectedContext selector.
|
|
1045 |
implementorClass := selectedContext searchClass whichClassImplements:sel.
|
|
1046 |
method := implementorClass compiledMethodAt:sel.
|
7
|
1047 |
newMethod := implementorClass compiler compile:someCode
|
|
1048 |
forClass:implementorClass
|
|
1049 |
inCategory:(method category)
|
|
1050 |
notifying:codeView.
|
0
|
1051 |
|
|
1052 |
"if it worked, remove everything up to and including top
|
|
1053 |
from context chain"
|
|
1054 |
|
|
1055 |
(newMethod notNil and:[newMethod ~~ #Error]) ifTrue:[
|
|
1056 |
self setContext:(top sender).
|
|
1057 |
|
|
1058 |
"continue/step is no longer possible"
|
|
1059 |
canContinue := false.
|
|
1060 |
self showSelection:1.
|
29
|
1061 |
exitAction := #return
|
0
|
1062 |
].
|
|
1063 |
codeView cursor:Cursor normal
|
|
1064 |
!
|
|
1065 |
|
|
1066 |
destroy
|
35
|
1067 |
"closing the debugger implies an abort or continue"
|
0
|
1068 |
|
|
1069 |
contextView middleButtonMenu hide.
|
29
|
1070 |
receiverInspector release.
|
|
1071 |
contextInspector release.
|
|
1072 |
inspecting ifFalse:[
|
|
1073 |
canAbort ifTrue:[
|
|
1074 |
self doAbort.
|
|
1075 |
'oops, abort failed' errorPrintNewline.
|
|
1076 |
] ifFalse:[
|
|
1077 |
self doContinue
|
|
1078 |
]
|
|
1079 |
].
|
|
1080 |
super destroy
|
0
|
1081 |
!
|
|
1082 |
|
|
1083 |
doExit
|
|
1084 |
"exit from menu: immediate exit from smalltalk"
|
|
1085 |
|
|
1086 |
Smalltalk exit
|
|
1087 |
!
|
|
1088 |
|
29
|
1089 |
doRemoveBreakpoint
|
|
1090 |
"remove breakpoint on the selected contexts method - if any"
|
|
1091 |
|
|
1092 |
|implementorClass method|
|
|
1093 |
|
|
1094 |
implementorClass := selectedContext searchClass
|
|
1095 |
whichClassImplements:selectedContext selector.
|
|
1096 |
implementorClass notNil ifTrue:[
|
|
1097 |
method := implementorClass compiledMethodAt:selectedContext selector.
|
|
1098 |
(method notNil and:[method isWrapped]) ifTrue:[
|
|
1099 |
MessageTracer unwrapMethod:method
|
|
1100 |
]
|
|
1101 |
].
|
|
1102 |
contextView middleButtonMenu disable:#doRemoveBreakpoint.
|
|
1103 |
!
|
|
1104 |
|
|
1105 |
doSenders
|
|
1106 |
"open a browser on the senders"
|
22
|
1107 |
|
29
|
1108 |
selectedContext notNil ifTrue:[
|
|
1109 |
SystemBrowser browseAllCallsOn:selectedContext selector.
|
|
1110 |
]
|
|
1111 |
!
|
|
1112 |
|
|
1113 |
doImplementors
|
|
1114 |
"open a browser on the implementors"
|
|
1115 |
|
|
1116 |
selectedContext notNil ifTrue:[
|
|
1117 |
SystemBrowser browseImplementorsOf:selectedContext selector.
|
|
1118 |
]
|
|
1119 |
!
|
|
1120 |
|
|
1121 |
doShowMore
|
|
1122 |
"double number of contexts shown"
|
|
1123 |
|
|
1124 |
|oldSelection|
|
|
1125 |
|
|
1126 |
contextArray notNil ifTrue:[
|
|
1127 |
oldSelection := contextView selection.
|
|
1128 |
nChainShown := nChainShown * 2.
|
|
1129 |
self setContext:contextArray first.
|
|
1130 |
contextView selection:oldSelection.
|
|
1131 |
]
|
0
|
1132 |
!
|
|
1133 |
|
|
1134 |
doSend
|
|
1135 |
"send from menu"
|
|
1136 |
|
29
|
1137 |
inspecting ifTrue:[^ self].
|
|
1138 |
|
0
|
1139 |
canContinue ifTrue:[
|
|
1140 |
steppedContextAddress := nil.
|
|
1141 |
haveControl := false.
|
13
|
1142 |
exitAction := #step.
|
|
1143 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
1144 |
"exit private event-loop"
|
29
|
1145 |
catchBlock notNil ifTrue:[catchBlock value].
|
|
1146 |
'oops, send failed' errorPrintNewline.
|
|
1147 |
self warn:'send failed'.
|
|
1148 |
sendButton turnOff; disable.
|
13
|
1149 |
].
|
0
|
1150 |
]
|
|
1151 |
!
|
|
1152 |
|
|
1153 |
doStep
|
|
1154 |
"step from menu"
|
|
1155 |
|
29
|
1156 |
inspecting ifTrue:[^ self].
|
|
1157 |
|
0
|
1158 |
canContinue ifTrue:[
|
|
1159 |
selectedContext notNil ifTrue:[
|
7
|
1160 |
steppedContextAddress := ObjectMemory addressOf:selectedContext
|
0
|
1161 |
] ifFalse:[
|
7
|
1162 |
steppedContextAddress := ObjectMemory addressOf:(contextArray at:2)
|
0
|
1163 |
].
|
22
|
1164 |
bigStep := true.
|
0
|
1165 |
haveControl := false.
|
13
|
1166 |
exitAction := #step.
|
|
1167 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
1168 |
"exit private event-loop"
|
29
|
1169 |
catchBlock notNil ifTrue:[catchBlock value].
|
|
1170 |
'oops, step failed' errorPrintNewline.
|
|
1171 |
self warn:'step failed'.
|
|
1172 |
stepButton turnOff; disable.
|
13
|
1173 |
].
|
0
|
1174 |
]
|
|
1175 |
!
|
|
1176 |
|
|
1177 |
doTraceStep
|
22
|
1178 |
"tracestep - not implemented yet"
|
0
|
1179 |
|
|
1180 |
canContinue ifTrue:[
|
|
1181 |
tracing := true.
|
|
1182 |
self doStep
|
|
1183 |
]
|
|
1184 |
!
|
|
1185 |
|
|
1186 |
doAbort
|
|
1187 |
"abort from menu"
|
|
1188 |
|
29
|
1189 |
inspecting ifTrue:[^ self].
|
|
1190 |
|
0
|
1191 |
steppedContextAddress := nil.
|
|
1192 |
haveControl := false.
|
7
|
1193 |
exitAction := #abort.
|
13
|
1194 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
1195 |
"exit private event-loop"
|
20
|
1196 |
catchBlock notNil ifTrue:[
|
29
|
1197 |
abortButton turnOff.
|
|
1198 |
catchBlock value.
|
|
1199 |
'oops, abort failed' errorPrintNewline.
|
|
1200 |
self warn:'unwind failed'.
|
|
1201 |
abortButton disable.
|
20
|
1202 |
]
|
13
|
1203 |
].
|
7
|
1204 |
^ self.
|
|
1205 |
|
|
1206 |
"obsolete ..."
|
13
|
1207 |
Processor activeProcess id == 0 ifTrue:[
|
0
|
1208 |
"dont allow termination of main-thread"
|
|
1209 |
exitAction := #abort
|
|
1210 |
] ifFalse:[
|
|
1211 |
exitAction := #terminate
|
|
1212 |
]
|
|
1213 |
!
|
|
1214 |
|
7
|
1215 |
doTerminate
|
|
1216 |
"terminate from menu"
|
|
1217 |
|
|
1218 |
steppedContextAddress := nil.
|
|
1219 |
haveControl := false.
|
13
|
1220 |
exitAction := #terminate.
|
|
1221 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
1222 |
"exit private event-loop"
|
29
|
1223 |
catchBlock notNil ifTrue:[catchBlock value].
|
|
1224 |
inspecting ifFalse:[
|
|
1225 |
'oops, terminate failed' errorPrintNewline.
|
|
1226 |
self warn:'terminate failed'.
|
|
1227 |
].
|
|
1228 |
terminateButton turnOff; disable.
|
13
|
1229 |
].
|
7
|
1230 |
!
|
|
1231 |
|
|
1232 |
|
29
|
1233 |
doReturn
|
|
1234 |
"return from menu"
|
|
1235 |
|
|
1236 |
inspecting ifTrue:[^ self].
|
0
|
1237 |
|
|
1238 |
steppedContextAddress := nil.
|
|
1239 |
haveControl := false.
|
29
|
1240 |
exitAction := #return.
|
13
|
1241 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
1242 |
"exit private event-loop"
|
29
|
1243 |
catchBlock notNil ifTrue:[catchBlock value].
|
|
1244 |
'oops, return failed' errorPrintNewline.
|
|
1245 |
self warn:'return failed'.
|
|
1246 |
returnButton turnOff; disable.
|
13
|
1247 |
].
|
0
|
1248 |
!
|
|
1249 |
|
|
1250 |
doRestart
|
|
1251 |
"restart from menu"
|
|
1252 |
|
29
|
1253 |
inspecting ifTrue:[^ self].
|
|
1254 |
|
0
|
1255 |
steppedContextAddress := nil.
|
|
1256 |
haveControl := false.
|
13
|
1257 |
exitAction := #restart.
|
|
1258 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
1259 |
"exit private event-loop"
|
29
|
1260 |
catchBlock notNil ifTrue:[catchBlock value].
|
|
1261 |
'oops, restart failed' errorPrintNewline.
|
|
1262 |
self warn:'restart failed'.
|
|
1263 |
restartButton turnOff; disable
|
13
|
1264 |
].
|
0
|
1265 |
!
|
|
1266 |
|
|
1267 |
doTrace
|
22
|
1268 |
"tracing - not really implemented ..."
|
|
1269 |
|
0
|
1270 |
|v b|
|
|
1271 |
|
22
|
1272 |
self warn:'this function is not yet implemented'.
|
|
1273 |
|
|
1274 |
false ifTrue:[
|
0
|
1275 |
traceView isNil ifTrue:[
|
|
1276 |
v := StandardSystemView on:Display.
|
|
1277 |
v label:'Debugger-Trace'.
|
|
1278 |
v icon:icon.
|
|
1279 |
|
|
1280 |
b := Button label:'untrace' in:v.
|
|
1281 |
b origin:(0 @ 0) extent:(1.0 @ (b height)).
|
|
1282 |
b action:[
|
|
1283 |
StepInterruptPending := false.
|
|
1284 |
tracing := false.
|
|
1285 |
v unrealize.
|
|
1286 |
traceView := nil
|
|
1287 |
].
|
|
1288 |
traceView := ScrollableView for:TextCollector in:v.
|
|
1289 |
traceView origin:(0 @ (b height))
|
|
1290 |
extent:[v width @ (v height - b height)]
|
|
1291 |
].
|
|
1292 |
v realize.
|
22
|
1293 |
].
|
0
|
1294 |
tracing := true.
|
|
1295 |
!
|
|
1296 |
|
|
1297 |
doNoTrace
|
|
1298 |
traceView notNil ifTrue:[
|
|
1299 |
traceView topView destroy.
|
|
1300 |
traceView := nil.
|
22
|
1301 |
].
|
|
1302 |
tracing := false
|
0
|
1303 |
!
|
|
1304 |
|
|
1305 |
doContinue
|
|
1306 |
"continue from menu"
|
|
1307 |
|
|
1308 |
canContinue ifTrue:[
|
|
1309 |
steppedContextAddress := nil.
|
|
1310 |
tracing := false.
|
|
1311 |
haveControl := false.
|
13
|
1312 |
exitAction := #continue.
|
|
1313 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
1314 |
"exit private event-loop"
|
29
|
1315 |
catchBlock notNil ifTrue:[catchBlock value].
|
|
1316 |
'oops, continue failed' errorPrintNewline.
|
|
1317 |
self warn:'continue failed'.
|
|
1318 |
continueButton turnOff; disable
|
13
|
1319 |
].
|
15
|
1320 |
] ifFalse:[
|
29
|
1321 |
inspecting ifFalse:[
|
|
1322 |
'resuming top context' errorPrintNewline.
|
|
1323 |
self showSelection:1.
|
|
1324 |
self doReturn
|
|
1325 |
]
|
|
1326 |
]
|
|
1327 |
!
|
|
1328 |
|
|
1329 |
doInspectContext
|
|
1330 |
"launch an inspector on the currently selected context"
|
|
1331 |
|
|
1332 |
selectedContext notNil ifTrue:[
|
|
1333 |
selectedContext inspect
|
0
|
1334 |
]
|
|
1335 |
! !
|