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
|
13
|
20 |
abortButton
|
|
21 |
exclusive'
|
7
|
22 |
classVariableNames:'cachedDebugger theOneAndOnlyNotifier'
|
0
|
23 |
poolDictionaries:''
|
|
24 |
category:'Interface-Debugger'
|
|
25 |
!
|
|
26 |
|
|
27 |
DebugView comment:'
|
|
28 |
|
4
|
29 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
0
|
30 |
All Rights Reserved
|
|
31 |
|
|
32 |
this class implements a graphical debugger interface.
|
13
|
33 |
The debugger usually sits on top of the faulting process,
|
|
34 |
stopping it from further event processing.
|
|
35 |
The exception is when an error occurs within the dispatcher process
|
|
36 |
or in one of the eventhandler processes - in this case, the debugger
|
|
37 |
will sit on an exclusive display connection.
|
0
|
38 |
|
13
|
39 |
$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.6 1993-12-19 23:44:27 claus Exp $
|
0
|
40 |
|
|
41 |
written spring/summer 89 by claus
|
|
42 |
'!
|
|
43 |
|
|
44 |
!DebugView class methodsFor:'instance creation'!
|
|
45 |
|
|
46 |
new
|
|
47 |
"return a DebugView - return the standard debugger if it already
|
|
48 |
exists"
|
|
49 |
|
|
50 |
|debugger|
|
|
51 |
|
13
|
52 |
"need a blocking debugger if no processes or
|
|
53 |
or if its a timing/interrupt process (because otherwise we would not get any
|
|
54 |
events here ..."
|
|
55 |
|
7
|
56 |
ProcessorScheduler isPureEventDriven ifTrue:[
|
|
57 |
cachedDebugger isNil ifTrue:[
|
13
|
58 |
cachedDebugger := self newExclusive
|
7
|
59 |
].
|
|
60 |
^ cachedDebugger
|
|
61 |
].
|
13
|
62 |
(Processor activeProcess priority > Processor userSchedulingPriority) ifTrue:[
|
|
63 |
^ self newExclusive
|
|
64 |
].
|
|
65 |
|
7
|
66 |
(cachedDebugger isNil or:[cachedDebugger busy]) ifTrue:[
|
|
67 |
debugger := super new.
|
0
|
68 |
debugger label:'Debugger'.
|
|
69 |
debugger icon:(Form fromFile:'Debugger.xbm' resolution:100).
|
7
|
70 |
] ifFalse:[
|
|
71 |
debugger := cachedDebugger
|
0
|
72 |
].
|
7
|
73 |
cachedDebugger isNil ifTrue:[
|
|
74 |
cachedDebugger := debugger
|
|
75 |
].
|
|
76 |
^ debugger
|
0
|
77 |
!
|
|
78 |
|
13
|
79 |
newExclusive
|
|
80 |
"return a debugger for exclusive display access"
|
|
81 |
|
|
82 |
|debugger|
|
|
83 |
|
|
84 |
debugger := super on:ModalDisplay.
|
|
85 |
debugger label:'Debugger'.
|
|
86 |
debugger icon:(Form fromFile:'Debugger.xbm' resolution:100).
|
|
87 |
debugger exclusive:true.
|
|
88 |
^ debugger
|
|
89 |
!
|
|
90 |
|
0
|
91 |
newDebugger
|
|
92 |
"force creation of a new debugger"
|
|
93 |
|
7
|
94 |
cachedDebugger := nil
|
0
|
95 |
|
|
96 |
"DebugView newDebugger"
|
|
97 |
!
|
|
98 |
|
|
99 |
enterWithMessage:aString
|
|
100 |
"the standard way of entering the debugger - sent from Objects
|
|
101 |
error- and halt messages"
|
|
102 |
|
7
|
103 |
|aDebugger name|
|
0
|
104 |
|
|
105 |
StepInterruptPending := nil.
|
7
|
106 |
aDebugger := self new.
|
13
|
107 |
name := Processor activeProcess nameOrId.
|
7
|
108 |
aDebugger label:aString , ' (process: ' , name , ')'.
|
0
|
109 |
aDebugger enter.
|
|
110 |
^ nil
|
|
111 |
|
|
112 |
"nil halt"
|
|
113 |
!
|
|
114 |
|
|
115 |
enter
|
|
116 |
"another way of entering the debugger"
|
|
117 |
|
7
|
118 |
|aDebugger name|
|
0
|
119 |
|
|
120 |
StepInterruptPending := nil.
|
7
|
121 |
aDebugger := self new.
|
13
|
122 |
name := Processor activeProcess nameOrId.
|
7
|
123 |
aDebugger label:'Debugger (process: ' , name , ')'.
|
0
|
124 |
aDebugger enter.
|
|
125 |
^ nil
|
|
126 |
|
|
127 |
"Debugger enter"
|
|
128 |
! !
|
|
129 |
|
|
130 |
!DebugView methodsFor:'initialization'!
|
|
131 |
|
|
132 |
initialize
|
7
|
133 |
|v panel hpanel bpanel terminateButton continueButton stepButton sendButton|
|
0
|
134 |
|
|
135 |
super initialize.
|
|
136 |
|
|
137 |
font := font on:device.
|
|
138 |
|
7
|
139 |
busy := false.
|
0
|
140 |
exitAction := nil.
|
10
|
141 |
bigStep := false.
|
0
|
142 |
|
|
143 |
bpanel := HorizontalPanelView
|
|
144 |
origin:(0.0 @ 0.0)
|
|
145 |
extent:(1.0 @ (font height * 2))
|
|
146 |
in:self.
|
|
147 |
bpanel layout:#left.
|
|
148 |
|
7
|
149 |
terminateButton := Button
|
|
150 |
label:(resources at:'terminate')
|
|
151 |
action:[abortButton turnOffWithoutRedraw. self doTerminate]
|
|
152 |
in:bpanel.
|
0
|
153 |
abortButton := Button
|
2
|
154 |
label:(resources at:'abort')
|
0
|
155 |
action:[abortButton turnOffWithoutRedraw. self doAbort]
|
|
156 |
in:bpanel.
|
|
157 |
continueButton := Button
|
2
|
158 |
label:(resources at:'continue')
|
0
|
159 |
action:[continueButton turnOffWithoutRedraw. self doContinue]
|
|
160 |
in:bpanel.
|
|
161 |
stepButton := Button
|
2
|
162 |
label:(resources at:'step')
|
0
|
163 |
action:[stepButton turnOff. self doStep]
|
|
164 |
in:bpanel.
|
|
165 |
sendButton := Button
|
2
|
166 |
label:(resources at:'send')
|
0
|
167 |
action:[sendButton turnOff. self doSend]
|
|
168 |
in:bpanel.
|
|
169 |
|
|
170 |
panel := VariableVerticalPanel
|
|
171 |
origin:(0.0 @ bpanel height)
|
|
172 |
corner:(1.0 @ 1.0)
|
|
173 |
in:self.
|
|
174 |
|
|
175 |
v := ScrollableView for:SelectionInListView in:panel.
|
|
176 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 0.25).
|
|
177 |
|
|
178 |
contextView := v scrolledView.
|
|
179 |
contextView action:[:lineNr | self showSelection:lineNr].
|
|
180 |
|
|
181 |
v := ScrollableView for:CodeView in:panel.
|
|
182 |
v origin:(0.0 @ 0.25) corner:(1.0 @ 0.75).
|
|
183 |
|
|
184 |
codeView := v scrolledView.
|
|
185 |
|
|
186 |
hpanel := VariableHorizontalPanel in:panel.
|
|
187 |
hpanel origin:(0.0 @ 0.75) corner:(1.0 @ 1.0).
|
|
188 |
|
|
189 |
receiverInspector := InspectorView
|
|
190 |
origin:(0.0 @ 0.0) corner:(0.5 @ 1.0)
|
|
191 |
in:hpanel.
|
|
192 |
|
|
193 |
contextInspector := ContextInspectorView
|
|
194 |
origin:(0.5 @ 0.0) corner:(1.0 @ 1.0)
|
|
195 |
in:hpanel
|
|
196 |
!
|
|
197 |
|
|
198 |
initializeMiddleButtonMenu
|
|
199 |
|labels|
|
|
200 |
|
2
|
201 |
labels := resources array:#('continue'
|
7
|
202 |
'terminate'
|
0
|
203 |
'abort'
|
|
204 |
'-'
|
|
205 |
'step'
|
|
206 |
'trace step'
|
|
207 |
'send'
|
|
208 |
"
|
|
209 |
'trace'
|
|
210 |
'untrace'
|
|
211 |
"
|
|
212 |
'-'
|
|
213 |
'resume'
|
|
214 |
'restart'
|
|
215 |
'-'
|
|
216 |
"
|
|
217 |
'breakpoints'
|
|
218 |
'-'
|
|
219 |
"
|
|
220 |
'exit smalltalk'
|
|
221 |
).
|
|
222 |
|
|
223 |
contextView
|
|
224 |
middleButtonMenu:(PopUpMenu
|
|
225 |
labels:labels
|
|
226 |
selectors:#(doContinue
|
7
|
227 |
doTerminate
|
0
|
228 |
doAbort
|
|
229 |
nil
|
|
230 |
doStep
|
|
231 |
doTraceStep
|
|
232 |
doSend
|
|
233 |
"
|
|
234 |
doTrace
|
|
235 |
doNoTrace
|
|
236 |
"
|
|
237 |
nil
|
|
238 |
doResume
|
|
239 |
doRestart
|
|
240 |
nil
|
|
241 |
"
|
|
242 |
doBreakpoints
|
|
243 |
nil
|
|
244 |
"
|
|
245 |
doExit)
|
|
246 |
receiver:self
|
|
247 |
for:contextView)
|
|
248 |
|
|
249 |
!
|
|
250 |
|
|
251 |
addToCurrentProject
|
|
252 |
"ignored here"
|
|
253 |
|
|
254 |
^ self
|
|
255 |
!
|
|
256 |
|
|
257 |
createOnTop
|
|
258 |
^ false "true"
|
13
|
259 |
!
|
|
260 |
|
|
261 |
realize
|
|
262 |
super realize.
|
|
263 |
exclusive ifTrue:[
|
|
264 |
windowGroup := nil
|
|
265 |
].
|
0
|
266 |
! !
|
|
267 |
|
|
268 |
!DebugView methodsFor:'error handling'!
|
|
269 |
|
|
270 |
catch:aSymbol with:someArgument for:anObject
|
|
271 |
"this one is sent when an error occurs while in the debugger -
|
|
272 |
we dont want another debugger to come up - do we ?"
|
|
273 |
|
|
274 |
anObject class name print.
|
|
275 |
' ' print.
|
|
276 |
aSymbol print. '(' print. someArgument print.
|
|
277 |
') within debugger cought' printNewline.
|
|
278 |
(aSymbol == #halt:) ifFalse:[
|
|
279 |
catchBlock value
|
|
280 |
].
|
|
281 |
^ nil
|
|
282 |
! !
|
|
283 |
|
|
284 |
!DebugView methodsFor:'interrupt handling'!
|
|
285 |
|
|
286 |
stepInterrupt
|
7
|
287 |
|where here s|
|
0
|
288 |
|
10
|
289 |
"is this for a send or a step ?"
|
|
290 |
|
0
|
291 |
bigStep ifTrue:[
|
10
|
292 |
where := thisContext.
|
0
|
293 |
where := where sender.
|
|
294 |
where := where sender.
|
|
295 |
here := where.
|
7
|
296 |
(ObjectMemory addressOf:where) == steppedContextAddress ifFalse:[
|
0
|
297 |
"
|
|
298 |
check if we are in a context below steppedContext
|
|
299 |
(i.e. if steppedContext can be reached from
|
|
300 |
interrupted context. Not using context-ref but its
|
|
301 |
address to avoid creation of many useless contexts..)
|
|
302 |
"
|
|
303 |
|
|
304 |
[where notNil] whileTrue:[
|
7
|
305 |
(ObjectMemory addressOf:where) == steppedContextAddress ifTrue:[
|
0
|
306 |
tracing ifTrue:[
|
|
307 |
here printString printNewline
|
|
308 |
].
|
|
309 |
where := nil. here := nil.
|
|
310 |
"yes - continue"
|
|
311 |
"scedule another stepInterrupt
|
|
312 |
- must flush caches since optimized methods not always
|
|
313 |
look for pending interrupts"
|
|
314 |
ObjectMemory flushInlineCaches.
|
|
315 |
StepInterruptPending := true.
|
|
316 |
InterruptPending := true.
|
10
|
317 |
InStepInterrupt := nil.
|
0
|
318 |
^ nil
|
|
319 |
].
|
|
320 |
where := where sender
|
|
321 |
]
|
|
322 |
].
|
|
323 |
bigStep := false.
|
|
324 |
tracing := false.
|
7
|
325 |
s := 'after step'
|
0
|
326 |
] ifFalse:[
|
|
327 |
steppedContextAddress := nil.
|
7
|
328 |
s := 'after send'
|
0
|
329 |
].
|
7
|
330 |
|
13
|
331 |
name := Processor activeProcess name.
|
7
|
332 |
name isNil ifTrue:[
|
13
|
333 |
name := Processor activeProcess id printString.
|
7
|
334 |
].
|
|
335 |
self label:(s , ' (process: ' , name , ')').
|
|
336 |
|
0
|
337 |
"release refs to context"
|
|
338 |
where := nil. here := nil.
|
|
339 |
self enter
|
|
340 |
! !
|
|
341 |
|
|
342 |
!DebugView methodsFor:'basic'!
|
|
343 |
|
7
|
344 |
busy
|
|
345 |
^ busy
|
|
346 |
!
|
|
347 |
|
13
|
348 |
exclusive:aBoolean
|
|
349 |
exclusive := aBoolean
|
|
350 |
!
|
|
351 |
|
0
|
352 |
enter
|
|
353 |
"enter the debugger - get and display the context, then start an
|
|
354 |
exclusive event loop on top of eveything else"
|
|
355 |
|
|
356 |
|where con oldRecursionLimit selection|
|
|
357 |
|
|
358 |
oldRecursionLimit := RecursionLimit.
|
|
359 |
RecursionLimit := nil.
|
10
|
360 |
bigStep := false.
|
|
361 |
|
|
362 |
"if debugger is entered while a box has grabbed the
|
|
363 |
pointer, we must ungrab - otherwise X wont talk to
|
|
364 |
us here"
|
0
|
365 |
|
|
366 |
ActiveGrab notNil ifTrue:[
|
|
367 |
grabber := ActiveGrab.
|
|
368 |
ActiveGrab device ungrabPointer.
|
|
369 |
ActiveGrab device synchronizeOutput.
|
|
370 |
ActiveGrab := nil
|
|
371 |
] ifFalse:[
|
|
372 |
grabber := nil
|
|
373 |
].
|
|
374 |
|
7
|
375 |
drawableId notNil ifTrue:[
|
|
376 |
"not the first time - realize at old position"
|
|
377 |
self rerealize
|
|
378 |
] ifFalse:[
|
13
|
379 |
exclusive ifFalse:[
|
|
380 |
windowGroup isNil ifTrue:[
|
|
381 |
windowGroup := WindowGroup new.
|
|
382 |
windowGroup addTopView:self.
|
|
383 |
].
|
|
384 |
].
|
|
385 |
self realize
|
7
|
386 |
].
|
13
|
387 |
|
0
|
388 |
self raise.
|
|
389 |
Display synchronizeOutput.
|
|
390 |
|
|
391 |
where := thisContext.
|
10
|
392 |
where := where sender.
|
0
|
393 |
where notNil ifTrue:[
|
|
394 |
(where receiver == DebugView) ifTrue:[
|
|
395 |
where := where sender
|
|
396 |
]
|
|
397 |
"where is now interrupted methods context"
|
|
398 |
].
|
|
399 |
self setContext:where.
|
|
400 |
|
|
401 |
"select context, where halt was ..."
|
|
402 |
( #(halt error raise) includes:where sender selector) ifTrue:[
|
|
403 |
selection := 3
|
|
404 |
] ifFalse:[
|
|
405 |
( #(halt: error:) includes:where selector) ifTrue:[
|
|
406 |
selection := 2
|
|
407 |
]
|
|
408 |
].
|
|
409 |
|
|
410 |
where := nil.
|
|
411 |
|
|
412 |
"if we came here by a big-step, show the method where we are"
|
|
413 |
steppedContextAddress notNil ifTrue:[
|
|
414 |
selection := 3
|
|
415 |
].
|
|
416 |
|
|
417 |
selection notNil ifTrue:[
|
|
418 |
self showSelection:selection.
|
|
419 |
contextView selection:selection
|
|
420 |
].
|
|
421 |
|
7
|
422 |
canAbort := false.
|
|
423 |
1 to:contextArray size do:[:index |
|
|
424 |
(#(doIt printIt inspectIt)
|
|
425 |
includes:(contextArray at:index) selector) ifTrue:[
|
|
426 |
canAbort := true
|
|
427 |
]
|
|
428 |
].
|
|
429 |
canAbort ifTrue:[
|
|
430 |
abortButton enable
|
|
431 |
] ifFalse:[
|
|
432 |
abortButton disable
|
|
433 |
].
|
|
434 |
|
0
|
435 |
canContinue := true.
|
|
436 |
self controlLoop.
|
|
437 |
|
7
|
438 |
"kludge: look for a doIt, printIt or inspectIt frame for abort"
|
|
439 |
(canAbort and:[exitAction == #abort]) ifTrue:[
|
0
|
440 |
selectedContext := nil.
|
|
441 |
1 to:contextArray size do:[:index |
|
|
442 |
(#(doIt printIt inspectIt)
|
|
443 |
includes:(contextArray at:index) selector) ifTrue:[
|
|
444 |
selectedContext := contextArray at:index
|
|
445 |
]
|
|
446 |
].
|
|
447 |
exitAction := #resume
|
|
448 |
].
|
|
449 |
|
|
450 |
contextArray := nil.
|
|
451 |
|
|
452 |
(exitAction == #step) ifFalse:[
|
|
453 |
self unrealize.
|
|
454 |
device synchronizeOutput.
|
|
455 |
(exitAction == #resume) ifTrue:[
|
|
456 |
selectedContext notNil ifTrue:[
|
|
457 |
con := selectedContext.
|
|
458 |
selectedContext := nil.
|
|
459 |
ErrorActive := false.
|
|
460 |
InInterrupt := nil.
|
|
461 |
RecursionLimit := oldRecursionLimit.
|
|
462 |
con unwind.
|
|
463 |
'cannot resume selected context' printNewline
|
|
464 |
]
|
|
465 |
] ifFalse:[
|
|
466 |
(exitAction == #restart) ifTrue:[
|
|
467 |
selectedContext notNil ifTrue:[
|
|
468 |
con := selectedContext.
|
|
469 |
selectedContext := nil.
|
|
470 |
ErrorActive := false.
|
|
471 |
InInterrupt := nil.
|
|
472 |
RecursionLimit := oldRecursionLimit.
|
|
473 |
con restart.
|
|
474 |
'cannot restart selected context' printNewline
|
|
475 |
]
|
|
476 |
] ifFalse:[
|
|
477 |
(exitAction == #terminate) ifTrue:[
|
|
478 |
selectedContext := nil.
|
|
479 |
ErrorActive := false.
|
|
480 |
InInterrupt := nil.
|
|
481 |
RecursionLimit := oldRecursionLimit.
|
13
|
482 |
Processor activeProcess terminate.
|
0
|
483 |
'cannot terminate process' printNewline
|
|
484 |
]
|
|
485 |
]
|
|
486 |
]
|
|
487 |
].
|
|
488 |
|
|
489 |
selectedContext := nil.
|
|
490 |
|
|
491 |
grabber notNil ifTrue:[
|
|
492 |
grabber device grabPointerIn:(grabber id).
|
|
493 |
ActiveGrab := grabber
|
|
494 |
].
|
|
495 |
|
|
496 |
RecursionLimit := oldRecursionLimit.
|
|
497 |
(exitAction == #step) ifTrue:[
|
|
498 |
"scedule another stepInterrupt
|
|
499 |
- must flush caches since optimized methods not always
|
|
500 |
look for pending interrupts"
|
|
501 |
ObjectMemory flushInlineCaches.
|
|
502 |
|
2
|
503 |
ObjectMemory stepInterruptHandler:self.
|
0
|
504 |
StepInterruptPending := true.
|
10
|
505 |
InterruptPending := true.
|
|
506 |
InStepInterrupt := nil
|
0
|
507 |
]
|
|
508 |
!
|
|
509 |
|
|
510 |
controlLoop
|
|
511 |
"this is a kludge:
|
|
512 |
start a dispatchloop which exits when
|
|
513 |
either continue, resume or step is pressed
|
|
514 |
"
|
|
515 |
|
|
516 |
Smalltalk at:#ErrorHandler put:self.
|
|
517 |
haveControl := true.
|
|
518 |
[haveControl] whileTrue:[
|
|
519 |
self controlLoopCatchingErrors
|
|
520 |
].
|
|
521 |
catchBlock := nil.
|
|
522 |
Smalltalk at:#ErrorHandler put:nil.
|
|
523 |
|
|
524 |
codeView contents:nil.
|
|
525 |
codeView acceptAction:nil.
|
|
526 |
contextView contents:nil.
|
|
527 |
receiverInspector noChoice.
|
|
528 |
contextInspector noChoice
|
|
529 |
!
|
|
530 |
|
|
531 |
controlLoopCatchingErrors
|
|
532 |
"setup a catch-block"
|
|
533 |
catchBlock := [^ nil].
|
|
534 |
|
13
|
535 |
exclusive ifTrue:[
|
|
536 |
"if we do not have multiple processes or its a system process
|
|
537 |
we start another dispatch loop, which exits when
|
|
538 |
either continue, resume or step is pressed
|
|
539 |
or (via the catchBlock) if an error occurs.
|
|
540 |
Since our display is an extra exclusive one (ModalDisplay)
|
|
541 |
all processing for normal views stops here ...
|
|
542 |
"
|
|
543 |
device dispatchWhile:[haveControl]
|
|
544 |
] ifFalse:[
|
|
545 |
"we do have multiple processes -
|
|
546 |
simply enter the DebugViews-Windowgroup event loop.
|
|
547 |
effectively suspending event processing for the currently
|
|
548 |
active group.
|
|
549 |
"
|
|
550 |
self windowGroup eventLoop
|
|
551 |
]
|
0
|
552 |
!
|
|
553 |
|
|
554 |
setContext:aContext
|
|
555 |
|con text
|
|
556 |
index "{ Class: SmallInteger }" |
|
|
557 |
|
|
558 |
aContext isNil ifTrue:[
|
|
559 |
text := Array with:'** no context **'.
|
|
560 |
contextArray := nil
|
|
561 |
] ifFalse:[
|
|
562 |
con := aContext.
|
|
563 |
index := 0.
|
|
564 |
[con notNil] whileTrue:[
|
|
565 |
index := index + 1.
|
|
566 |
con := con sender
|
|
567 |
].
|
|
568 |
text := Array new:index.
|
|
569 |
contextArray := Array new:index.
|
|
570 |
con := aContext.
|
|
571 |
index := 1.
|
|
572 |
[con notNil] whileTrue:[
|
|
573 |
contextArray at:index put:con.
|
|
574 |
text at:index put:(con printString).
|
|
575 |
index := index + 1.
|
|
576 |
con := con sender
|
|
577 |
]
|
|
578 |
].
|
|
579 |
contextView list:text.
|
|
580 |
receiverInspector noChoice.
|
|
581 |
contextInspector noChoice
|
|
582 |
! !
|
|
583 |
|
|
584 |
!DebugView methodsFor:'user interaction'!
|
|
585 |
|
|
586 |
showSelection:lineNr
|
|
587 |
"user clicked on a header line - show selected code in textView"
|
|
588 |
|
|
589 |
|con homeContext sel method code
|
7
|
590 |
implementorClass lineNrInMethod rec|
|
0
|
591 |
|
|
592 |
contextArray notNil ifTrue:[
|
|
593 |
con := contextArray at:lineNr.
|
|
594 |
lineNrInMethod := con lineNumber.
|
|
595 |
con isBlockContext ifTrue:[
|
|
596 |
homeContext := con methodHome
|
|
597 |
] ifFalse:[
|
|
598 |
homeContext := con
|
|
599 |
].
|
|
600 |
sel := homeContext selector.
|
|
601 |
sel notNil ifTrue:[
|
|
602 |
implementorClass := homeContext searchClass
|
|
603 |
whichClassImplements:sel.
|
|
604 |
implementorClass isNil ifTrue:[
|
|
605 |
codeView contents:'** no method - no source **'
|
|
606 |
] ifFalse:[
|
|
607 |
method := implementorClass compiledMethodAt:sel.
|
|
608 |
code := method source.
|
|
609 |
code isNil ifTrue:[
|
|
610 |
codeView contents:'** no source **'
|
|
611 |
]
|
|
612 |
].
|
|
613 |
code isNil ifTrue:[
|
|
614 |
codeView acceptAction:nil.
|
|
615 |
contextInspector noChoice
|
|
616 |
] ifFalse:[
|
|
617 |
codeView contents:code.
|
|
618 |
(lineNrInMethod ~~ 0) ifTrue:[
|
|
619 |
lineNrInMethod > codeView list size ifTrue:[
|
|
620 |
lineNrInMethod := codeView list size + 1
|
|
621 |
].
|
|
622 |
codeView selectLine:lineNrInMethod.
|
|
623 |
codeView makeSelectionVisible
|
|
624 |
].
|
|
625 |
codeView acceptAction:[:code | self codeAccept:code]
|
|
626 |
].
|
|
627 |
contextInspector inspect:con.
|
7
|
628 |
|
|
629 |
"fetch rec here - so we wont need con in doItAction"
|
|
630 |
rec := homeContext receiver.
|
|
631 |
receiverInspector inspect:rec.
|
|
632 |
codeView doItAction:[:theCode |
|
|
633 |
rec class compiler evaluate:theCode
|
|
634 |
receiver:rec
|
|
635 |
notifying:codeView
|
|
636 |
]
|
0
|
637 |
].
|
|
638 |
selectedContext := homeContext
|
|
639 |
].
|
|
640 |
"clear out locals to prevent keeping around unneeded contexts (due to the
|
|
641 |
block held in codeView).
|
|
642 |
(not really needed, since stuff gets collected away sooner or later ..."
|
|
643 |
|
|
644 |
con := nil.
|
|
645 |
homeContext := nil
|
|
646 |
!
|
|
647 |
|
|
648 |
codeAccept:someCode
|
|
649 |
"user wants some code to be recompiled - must unwind stack since everything above
|
|
650 |
and including selected method cannot be continued"
|
|
651 |
|
|
652 |
"walk up context chain and find highest context which is either the selected context,
|
|
653 |
or - if its a block-context - whose home is the selected context"
|
|
654 |
|
|
655 |
|con top sel implementorClass method newMethod|
|
|
656 |
|
|
657 |
codeView cursor:Cursor execute.
|
|
658 |
|
|
659 |
con := selectedContext.
|
|
660 |
top := con.
|
|
661 |
[con notNil] whileTrue:[
|
|
662 |
(con methodHome == selectedContext) ifTrue:[
|
|
663 |
top := con
|
|
664 |
].
|
|
665 |
con := con sender
|
|
666 |
].
|
|
667 |
"now, remove everything up to and including top from context chain"
|
|
668 |
|
|
669 |
"
|
|
670 |
self setContext:(top sender).
|
|
671 |
"
|
|
672 |
|
|
673 |
sel := selectedContext selector.
|
|
674 |
implementorClass := selectedContext searchClass whichClassImplements:sel.
|
|
675 |
method := implementorClass compiledMethodAt:sel.
|
7
|
676 |
newMethod := implementorClass compiler compile:someCode
|
|
677 |
forClass:implementorClass
|
|
678 |
inCategory:(method category)
|
|
679 |
notifying:codeView.
|
0
|
680 |
|
|
681 |
"if it worked, remove everything up to and including top
|
|
682 |
from context chain"
|
|
683 |
|
|
684 |
(newMethod notNil and:[newMethod ~~ #Error]) ifTrue:[
|
|
685 |
self setContext:(top sender).
|
|
686 |
|
|
687 |
"continue/step is no longer possible"
|
|
688 |
canContinue := false.
|
|
689 |
self showSelection:1.
|
|
690 |
exitAction := #resume
|
|
691 |
].
|
|
692 |
codeView cursor:Cursor normal
|
|
693 |
!
|
|
694 |
|
|
695 |
destroy
|
|
696 |
"closing the debugger implies an abort"
|
|
697 |
|
|
698 |
contextView middleButtonMenu hide.
|
|
699 |
receiverInspector noChoice.
|
|
700 |
contextInspector noChoice.
|
|
701 |
self doAbort
|
|
702 |
!
|
|
703 |
|
|
704 |
doExit
|
|
705 |
"exit from menu: immediate exit from smalltalk"
|
|
706 |
|
|
707 |
Smalltalk exit
|
|
708 |
!
|
|
709 |
|
|
710 |
doBreakpoints
|
|
711 |
^ self
|
|
712 |
!
|
|
713 |
|
|
714 |
doSend
|
|
715 |
"send from menu"
|
|
716 |
|
|
717 |
canContinue ifTrue:[
|
|
718 |
steppedContextAddress := nil.
|
|
719 |
haveControl := false.
|
13
|
720 |
exitAction := #step.
|
|
721 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
722 |
"exit private event-loop"
|
|
723 |
catchBlock value
|
|
724 |
].
|
0
|
725 |
]
|
|
726 |
!
|
|
727 |
|
|
728 |
doStep
|
|
729 |
"step from menu"
|
|
730 |
|
|
731 |
canContinue ifTrue:[
|
|
732 |
selectedContext notNil ifTrue:[
|
|
733 |
bigStep := true.
|
7
|
734 |
steppedContextAddress := ObjectMemory addressOf:selectedContext
|
0
|
735 |
] ifFalse:[
|
|
736 |
bigStep := true.
|
7
|
737 |
steppedContextAddress := ObjectMemory addressOf:(contextArray at:2)
|
0
|
738 |
].
|
|
739 |
haveControl := false.
|
13
|
740 |
exitAction := #step.
|
|
741 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
742 |
"exit private event-loop"
|
|
743 |
catchBlock value
|
|
744 |
].
|
0
|
745 |
]
|
|
746 |
!
|
|
747 |
|
|
748 |
doTraceStep
|
|
749 |
"tracestep from menu"
|
|
750 |
|
|
751 |
canContinue ifTrue:[
|
|
752 |
tracing := true.
|
|
753 |
self doStep
|
|
754 |
]
|
|
755 |
!
|
|
756 |
|
|
757 |
doAbort
|
|
758 |
"abort from menu"
|
|
759 |
|
|
760 |
steppedContextAddress := nil.
|
|
761 |
haveControl := false.
|
7
|
762 |
exitAction := #abort.
|
13
|
763 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
764 |
"exit private event-loop"
|
|
765 |
catchBlock value
|
|
766 |
].
|
7
|
767 |
^ self.
|
|
768 |
|
|
769 |
"obsolete ..."
|
13
|
770 |
Processor activeProcess id == 0 ifTrue:[
|
0
|
771 |
"dont allow termination of main-thread"
|
|
772 |
exitAction := #abort
|
|
773 |
] ifFalse:[
|
|
774 |
exitAction := #terminate
|
|
775 |
]
|
|
776 |
!
|
|
777 |
|
7
|
778 |
doTerminate
|
|
779 |
"terminate from menu"
|
|
780 |
|
|
781 |
steppedContextAddress := nil.
|
|
782 |
haveControl := false.
|
13
|
783 |
exitAction := #terminate.
|
|
784 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
785 |
"exit private event-loop"
|
|
786 |
catchBlock value
|
|
787 |
].
|
7
|
788 |
!
|
|
789 |
|
|
790 |
|
0
|
791 |
doResume
|
|
792 |
"resume from menu"
|
|
793 |
|
|
794 |
steppedContextAddress := nil.
|
|
795 |
haveControl := false.
|
13
|
796 |
exitAction := #resume.
|
|
797 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
798 |
"exit private event-loop"
|
|
799 |
catchBlock value
|
|
800 |
].
|
0
|
801 |
!
|
|
802 |
|
|
803 |
doRestart
|
|
804 |
"restart from menu"
|
|
805 |
|
|
806 |
steppedContextAddress := nil.
|
|
807 |
haveControl := false.
|
13
|
808 |
exitAction := #restart.
|
|
809 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
810 |
"exit private event-loop"
|
|
811 |
catchBlock value
|
|
812 |
].
|
0
|
813 |
!
|
|
814 |
|
|
815 |
doTrace
|
|
816 |
|v b|
|
|
817 |
|
|
818 |
traceView isNil ifTrue:[
|
|
819 |
v := StandardSystemView on:Display.
|
|
820 |
v label:'Debugger-Trace'.
|
|
821 |
v icon:icon.
|
|
822 |
|
|
823 |
b := Button label:'untrace' in:v.
|
|
824 |
b origin:(0 @ 0) extent:(1.0 @ (b height)).
|
|
825 |
b action:[
|
|
826 |
StepInterruptPending := false.
|
|
827 |
tracing := false.
|
|
828 |
v unrealize.
|
|
829 |
traceView := nil
|
|
830 |
].
|
|
831 |
traceView := ScrollableView for:TextCollector in:v.
|
|
832 |
traceView origin:(0 @ (b height))
|
|
833 |
extent:[v width @ (v height - b height)]
|
|
834 |
].
|
|
835 |
v realize.
|
|
836 |
tracing := true.
|
|
837 |
self doStep
|
|
838 |
!
|
|
839 |
|
|
840 |
doNoTrace
|
|
841 |
traceView notNil ifTrue:[
|
|
842 |
traceView topView destroy.
|
|
843 |
traceView := nil.
|
|
844 |
tracing := false
|
|
845 |
]
|
|
846 |
!
|
|
847 |
|
|
848 |
doContinue
|
|
849 |
"continue from menu"
|
|
850 |
|
|
851 |
canContinue ifTrue:[
|
|
852 |
steppedContextAddress := nil.
|
|
853 |
tracing := false.
|
|
854 |
haveControl := false.
|
13
|
855 |
exitAction := #continue.
|
|
856 |
ProcessorScheduler isPureEventDriven ifFalse:[
|
|
857 |
"exit private event-loop"
|
|
858 |
catchBlock value
|
|
859 |
].
|
0
|
860 |
]
|
|
861 |
! !
|