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