DebugView.st
changeset 52 7b48409ae088
parent 48 f007285a17ba
child 53 2fc78a0165e7
equal deleted inserted replaced
51:57c1ccc3d7e0 52:7b48409ae088
    20 			      abortButton terminateButton continueButton
    20 			      abortButton terminateButton continueButton
    21 			      stepButton sendButton returnButton restartButton
    21 			      stepButton sendButton returnButton restartButton
    22 			      exclusive inspecting nChainShown
    22 			      exclusive inspecting nChainShown
    23 			      inspectedProcess updateProcess
    23 			      inspectedProcess updateProcess
    24 			      monitorToggle'
    24 			      monitorToggle'
    25        classVariableNames:'CachedDebugger CachedExclusive'
    25        classVariableNames:'CachedDebugger CachedExclusive MoreDebuggingDetail'
    26        poolDictionaries:''
    26        poolDictionaries:''
    27        category:'Interface-Debugger'
    27        category:'Interface-Debugger'
    28 !
    28 !
    29 
    29 
    30 DebugView comment:'
    30 DebugView comment:'
    31 COPYRIGHT (c) 1989 by Claus Gittinger
    31 COPYRIGHT (c) 1989 by Claus Gittinger
    32 	      All Rights Reserved
    32 	      All Rights Reserved
    33 
    33 
    34 $Header: /cvs/stx/stx/libtool/DebugView.st,v 1.16 1994-10-28 03:30:49 claus Exp $
    34 $Header: /cvs/stx/stx/libtool/DebugView.st,v 1.17 1994-11-17 14:46:40 claus Exp $
    35 '!
    35 '!
    36 
    36 
    37 !DebugView class methodsFor:'documentation'!
    37 !DebugView class methodsFor:'documentation'!
    38 
    38 
    39 copyright
    39 copyright
    50 "
    50 "
    51 !
    51 !
    52 
    52 
    53 version
    53 version
    54 "
    54 "
    55 $Header: /cvs/stx/stx/libtool/DebugView.st,v 1.16 1994-10-28 03:30:49 claus Exp $
    55 $Header: /cvs/stx/stx/libtool/DebugView.st,v 1.17 1994-11-17 14:46:40 claus Exp $
    56 "
    56 "
    57 !
    57 !
    58 
    58 
    59 documentation
    59 documentation
    60 "
    60 "
   180 
   180 
   181 openOn:aProcess
   181 openOn:aProcess
   182     "start a  debugger on aProcess
   182     "start a  debugger on aProcess
   183      (actually not more than a good-looking inspector)"
   183      (actually not more than a good-looking inspector)"
   184 
   184 
   185     |aDebugger label|
   185     |aDebugger label nm|
   186 
   186 
   187     aDebugger := super new.
   187     aDebugger := super new.
   188     aDebugger icon:(Form fromFile:'Debugger.xbm' resolution:100).
   188     aDebugger icon:(Form fromFile:'Debugger.xbm' resolution:100).
   189     aProcess notNil ifTrue:[
   189     aProcess notNil ifTrue:[
   190 	label := 'process Debugger (' , aProcess nameOrId , ')'.
   190 	nm := aProcess name.
       
   191 	nm notNil ifTrue:[
       
   192 	    nm := (aProcess nameOrId contractTo:17) , '-' , aProcess id printString
       
   193 	] ifFalse:[
       
   194 	    nm := aProcess id printString
       
   195 	].
       
   196 	label := 'Debugger [' , nm , ']'.
   191     ] ifFalse:[
   197     ] ifFalse:[
   192 	label := 'no process'
   198 	label := 'no process'
   193     ].
   199     ].
   194     aDebugger label:label.
   200     aDebugger label:label.
   195     aDebugger iconLabel:'Debugger'.
   201     aDebugger iconLabel:'Debugger'.
   223     terminateButton := Button
   229     terminateButton := Button
   224 			label:(resources at:'terminate')
   230 			label:(resources at:'terminate')
   225 			action:[terminateButton turnOffWithoutRedraw. self doTerminate]
   231 			action:[terminateButton turnOffWithoutRedraw. self doTerminate]
   226 			in:bpanel.
   232 			in:bpanel.
   227     dummy := View extent:(20 @ 5) in:bpanel.
   233     dummy := View extent:(20 @ 5) in:bpanel.
       
   234     dummy borderWidth:0; level:0.
   228 
   235 
   229     abortButton := Button
   236     abortButton := Button
   230 			label:(resources at:'abort')
   237 			label:(resources at:'abort')
   231 			action:[abortButton turnOffWithoutRedraw. self doAbort]
   238 			action:[abortButton turnOffWithoutRedraw. self doAbort]
   232 			in:bpanel.
   239 			in:bpanel.
   239 			label:(resources at:'restart')
   246 			label:(resources at:'restart')
   240 			action:[restartButton turnOff. self doRestart]
   247 			action:[restartButton turnOff. self doRestart]
   241 			in:bpanel.
   248 			in:bpanel.
   242 
   249 
   243     dummy := View extent:(20 @ 5) in:bpanel.
   250     dummy := View extent:(20 @ 5) in:bpanel.
       
   251     dummy borderWidth:0; level:0.
   244 
   252 
   245     continueButton := Button
   253     continueButton := Button
   246 			label:(resources at:'continue')
   254 			label:(resources at:'continue')
   247 			action:[continueButton turnOffWithoutRedraw. self doContinue]
   255 			action:[continueButton turnOffWithoutRedraw. self doContinue]
   248 			in:bpanel.
   256 			in:bpanel.
   249     dummy := View extent:(20 @ 5) in:bpanel.
   257     dummy := View extent:(20 @ 5) in:bpanel.
       
   258     dummy borderWidth:0; level:0.
   250 
   259 
   251     stepButton := Button
   260     stepButton := Button
   252 			label:(resources at:'step')
   261 			label:(resources at:'step')
   253 			action:[stepButton turnOff. self doStep]
   262 			action:[stepButton turnOff. self doStep]
   254 			in:bpanel.
   263 			in:bpanel.
   383     exclusive ifTrue:[
   392     exclusive ifTrue:[
   384 	windowGroup := nil
   393 	windowGroup := nil
   385     ].
   394     ].
   386 
   395 
   387     inspectedProcess notNil ifTrue:[
   396     inspectedProcess notNil ifTrue:[
       
   397 	"
       
   398 	 set prio somewhat higher (by 2, to allow walkBack-update process
       
   399 	 to run between mine and the debugged processes prio)
       
   400 	"
   388 	Processor activeProcess 
   401 	Processor activeProcess 
   389 	    priority:(inspectedProcess priority + 2 min:16).
   402 	    priority:(inspectedProcess priority + 2 min:16).
   390     ]
   403     ]
   391 ! !
   404 ! !
   392 
   405 
   393 !DebugView methodsFor:'interrupt handling'!
   406 !DebugView methodsFor:'interrupt handling'!
   394 
   407 
   395 stepInterrupt
   408 stepInterrupt
   396     |where here s isWrap method lastWrappedConAddr wrappedMethod|
   409     |where here s isWrap method lastWrappedConAddr wrappedMethod|
   397 
   410 
   398     "
   411     Processor activeProcess ~~ inspectedProcess ifTrue:[
   399      kludge, check if we are in a wrapper methods hidden setup-sequence
   412 	'stray step interrupt' errorPrintNL.
       
   413 	^ self
       
   414     ].
       
   415 
       
   416     "
       
   417      kludge: check if we are in a wrapper methods hidden setup-sequence
   400     "
   418     "
   401     here := thisContext.        "stepInterrupt"
   419     here := thisContext.        "stepInterrupt"
   402     here := here sender.        "the interrupted context"  
   420     here := here sender.        "the interrupted context"  
   403 
   421 
   404 "/ 'here in ' print.
   422 "/ 'here in ' print.
   547 
   565 
   548     |con selection m|
   566     |con selection m|
   549 
   567 
   550     busy := true.
   568     busy := true.
   551     inspecting := false.
   569     inspecting := false.
   552     inspectedProcess := nil.
   570     inspectedProcess := Processor activeProcess.
   553     bigStep := false.
   571     bigStep := false.
   554     nChainShown := 50.
   572     nChainShown := 50.
   555 
   573 
   556     "if debugger is entered while a box has grabbed the
   574     "if debugger is entered while a box has grabbed the
   557      pointer, we must ungrab - otherwise X wont talk to
   575      pointer, we must ungrab - otherwise X wont talk to
   558      us here
   576      us here
   559     "
   577     "
   560     ActiveGrab notNil ifTrue:[
   578     (grabber := device activePointerGrab) notNil ifTrue:[
   561 	grabber := ActiveGrab.
   579 	device ungrabPointer
   562 	ActiveGrab device ungrabPointer.
       
   563 	ActiveGrab device synchronizeOutput.
       
   564 	ActiveGrab := nil
       
   565     ] ifFalse:[
       
   566 	grabber := nil
       
   567     ].
   580     ].
   568 
   581 
   569     terminateButton enable.
   582     terminateButton enable.
   570 
   583 
   571     drawableId notNil ifTrue:[
   584     drawableId notNil ifTrue:[
   573 	terminateButton turnOffWithoutRedraw.
   586 	terminateButton turnOffWithoutRedraw.
   574 	continueButton turnOffWithoutRedraw.
   587 	continueButton turnOffWithoutRedraw.
   575 	abortButton turnOffWithoutRedraw.
   588 	abortButton turnOffWithoutRedraw.
   576 	stepButton turnOffWithoutRedraw.
   589 	stepButton turnOffWithoutRedraw.
   577 	sendButton turnOffWithoutRedraw.
   590 	sendButton turnOffWithoutRedraw.
   578 	self rerealize
   591 "/        self rerealize
   579     ] ifFalse:[
   592     ] ifFalse:[
   580 	exclusive ifFalse:[
   593 	exclusive ifFalse:[
   581 	    windowGroup isNil ifTrue:[
   594 	    windowGroup isNil ifTrue:[
   582 		windowGroup := WindowGroup new.
   595 		windowGroup := WindowGroup new.
   583 		windowGroup addTopView:self.
   596 		windowGroup addTopView:self.
   584 	    ].
   597 	    ].
   585 	].
   598 	].
   586 	self realize.
   599 "/        self realize.
   587 	self iconLabel:'Debugger'.
   600 	self iconLabel:'Debugger'.
   588     ].
   601     ].
   589 
   602 
   590     "
   603 "/    "
   591      bring us to the top
   604 "/   bring us to the top
   592     "
   605 "/  "
   593     self raise.
   606 "/  self raise.
   594     Display synchronizeOutput.
   607 "/  Display synchronizeOutput.
   595 
   608 
   596     "
   609     "
   597      get the walkback list
   610      get the walkback list
   598     "
   611     "
   599     self setContext:aContext.
   612     self setContext:aContext.
   600 
   613 
   601     "
   614     "
   602      and find one to show
   615      and find one to show
   603     "
   616     "
   604     steppedContextAddress isNil ifTrue:[
   617     exitAction == #step ifTrue:[
   605 	"
   618 	selection := 1.
   606 	 preselect a more interresting context, (where halt/raise was ...)
   619 	steppedContextAddress notNil ifTrue:[
   607 	"
   620 	    "
   608 	selection := self interrestingContextFrom:aContext.
   621 	     if we came here by a big-step, show the method where we are
       
   622 	    "
       
   623 	    steppedContextAddress notNil ifTrue:[
       
   624 		(ObjectMemory addressOf:aContext) == steppedContextAddress ifTrue:[
       
   625 		    selection := 1
       
   626 		] ifFalse:[
       
   627 		    (ObjectMemory addressOf:aContext sender) == steppedContextAddress ifTrue:[
       
   628 			selection := 2
       
   629 		    ]
       
   630 		]
       
   631 	    ]
       
   632 	]
   609     ] ifFalse:[
   633     ] ifFalse:[
   610 	"
   634 	steppedContextAddress isNil ifTrue:[
   611 	 if we came here by a big-step, show the method where we are
   635 	    "
   612 	"
   636 	     preselect a more interresting context, (where halt/raise was ...)
   613 	steppedContextAddress notNil ifTrue:[
   637 	    "
   614 	    (ObjectMemory addressOf:aContext) == steppedContextAddress ifTrue:[
   638 	    selection := self interrestingContextFrom:aContext.
   615 		selection := 1
   639 	] ifFalse:[
   616 	    ] ifFalse:[
   640 	    "
   617 		(ObjectMemory addressOf:aContext sender) == steppedContextAddress ifTrue:[
   641 	     if we came here by a big-step, show the method where we are
   618 		    selection := 2
   642 	    "
       
   643 	    steppedContextAddress notNil ifTrue:[
       
   644 		(ObjectMemory addressOf:aContext) == steppedContextAddress ifTrue:[
       
   645 		    selection := 1
       
   646 		] ifFalse:[
       
   647 		    (ObjectMemory addressOf:aContext sender) == steppedContextAddress ifTrue:[
       
   648 			selection := 2
       
   649 		    ]
   619 		]
   650 		]
   620 	    ]
   651 	    ]
   621 	]
   652 	]
   622     ].
   653     ].
   623 
   654 
   643 	    terminateButton enable.
   674 	    terminateButton enable.
   644 	    m enable:#doTerminate.
   675 	    m enable:#doTerminate.
   645 	]
   676 	]
   646     ].
   677     ].
   647 
   678 
       
   679     drawableId notNil ifTrue:[
       
   680 	self rerealize
       
   681     ] ifFalse:[
       
   682 	self realize.
       
   683     ].
       
   684 
       
   685     "
       
   686      bring us to the top
       
   687     "
       
   688     self raise.
       
   689     Display synchronizeOutput.
       
   690 
   648     "
   691     "
   649      enter private event handling loop
   692      enter private event handling loop
   650     "
   693     "
   651     canContinue := true.
   694     canContinue := true.
       
   695     exitAction := nil.
       
   696 
   652     self controlLoop.
   697     self controlLoop.
   653 
   698 
   654     contextArray := nil.
   699     contextArray := nil.
   655     receiverInspector release.
   700     receiverInspector release.
   656     contextInspector release.
   701     contextInspector release.
   741     ].
   786     ].
   742 
   787 
   743     selectedContext := nil.
   788     selectedContext := nil.
   744 
   789 
   745     grabber notNil ifTrue:[
   790     grabber notNil ifTrue:[
   746 	grabber device grabPointerIn:(grabber id).
   791 	device grabPointerInView:grabber.
   747 	ActiveGrab := grabber
   792 	grabber := nil.
   748     ].
   793     ].
   749 
   794 
   750     (exitAction == #step) ifTrue:[
   795     (exitAction == #step) ifTrue:[
   751 	"scedule another stepInterrupt
   796 	"scedule another stepInterrupt
   752 	 - must flush caches since optimized methods not always
   797 	 - must flush caches since optimized methods not always
   764 !
   809 !
   765 
   810 
   766 openOn:aProcess
   811 openOn:aProcess
   767     "enter the debugger on a process - 
   812     "enter the debugger on a process - 
   768      in this case, we are just inspecting the context chain of the process,
   813      in this case, we are just inspecting the context chain of the process,
   769      not offering continue/abort/step and send functions.
   814      not running on top of the debugged process, but as a separate
   770      Also, we do not run on top of the debugger process, but as a separate
   815      one. (think of it as an inspector showing more detail, and offering
   771      one. (think of it as an inspector showing more detail)"
   816      some more control operations)"
   772 
   817 
   773     |bpanel updateButton stopButton dummy|
   818     |bpanel updateButton stopButton dummy|
   774 
   819 
   775     busy := true.
   820     busy := true.
   776     bigStep := false.
   821     bigStep := false.
   784     stopButton label:(resources at:'stop');
   829     stopButton label:(resources at:'stop');
   785 	       action:[self doStop].
   830 	       action:[self doStop].
   786     bpanel addSubView:stopButton after:continueButton.
   831     bpanel addSubView:stopButton after:continueButton.
   787 
   832 
   788     dummy := View extent:(20 @ 5) in:bpanel.
   833     dummy := View extent:(20 @ 5) in:bpanel.
       
   834     dummy borderWidth:0; level:0.
   789 
   835 
   790 "/    stepButton destroy.
   836 "/    stepButton destroy.
   791 "/    sendButton destroy.
   837 "/    sendButton destroy.
   792 
   838 
   793     updateButton := Button
   839     updateButton := Button
   823 	].
   869 	].
   824 
   870 
   825 	self setContext:aProcess suspendedContext.
   871 	self setContext:aProcess suspendedContext.
   826 
   872 
   827 	catchBlock := [
   873 	catchBlock := [
       
   874 	    catchBlock := nil.
   828 	    contextArray := nil.
   875 	    contextArray := nil.
   829 	    selectedContext := nil.
   876 	    selectedContext := nil.
   830 	    (exitAction == #terminate) ifTrue:[
   877 	    (exitAction == #terminate) ifTrue:[
   831 		aProcess terminate.
   878 		aProcess terminate.
   832 	    ].
   879 	    ].
   859     receiverInspector release.
   906     receiverInspector release.
   860     contextInspector release
   907     contextInspector release
   861 !
   908 !
   862 
   909 
   863 controlLoopCatchingErrors
   910 controlLoopCatchingErrors
   864     "setup a catch-block"
   911     "setup a self removing catch-block"
   865     catchBlock := [^ nil].
   912     catchBlock := [catchBlock := nil. ^ nil].
   866 
   913 
   867     exclusive ifTrue:[
   914     exclusive ifTrue:[
   868 	"if we do not have multiple processes or its a system process
   915 	"if we do not have multiple processes or its a system process
   869 	 we start another dispatch loop, which exits when
   916 	 we start another dispatch loop, which exits when
   870 	 either continue, return or step is pressed
   917 	 either continue, return or step is pressed
   878 	 simply enter the DebugViews-Windowgroup event loop.
   925 	 simply enter the DebugViews-Windowgroup event loop.
   879 	 effectively suspending event processing for the currently 
   926 	 effectively suspending event processing for the currently 
   880 	 active group.
   927 	 active group.
   881 	"
   928 	"
   882 	SignalSet anySignal handle:[:ex |
   929 	SignalSet anySignal handle:[:ex |
   883 	    'ignored error in debugger: ' errorPrint. 
   930 "/            (self confirm:('error in debugger: ' , ex errorString , '\\debug again ?') withCRs) 
       
   931 "/            ifTrue:[
       
   932 "/                Debugger enter:(ex suspendedContext).
       
   933 "/                ex return.
       
   934 "/            ].
       
   935 "/            'ignored error in debugger: ' errorPrint. 
   884 	    ex errorString errorPrintNL.
   936 	    ex errorString errorPrintNL.
   885 	    ex return.
   937 	    ex return.
   886 	] do:[
   938 	] do:[
   887 	    windowGroup eventLoopWhile:[true]
   939 	    windowGroup eventLoopWhile:[true]
   888 	]
   940 	].
   889     ]
   941     ].
       
   942     catchBlock := nil.
   890 ! !
   943 ! !
   891 
   944 
   892 !DebugView methodsFor:'private'!
   945 !DebugView methodsFor:'private'!
   893 
   946 
   894 busy
   947 busy
   895     ^ busy
   948     ^ busy
   896 !
   949 !
   897 
   950 
       
   951 showError:message
       
   952     codeView contents:(resources string:message).
       
   953     codeView flash
       
   954 !
       
   955 
   898 showTerminated
   956 showTerminated
   899     codeView contents:(resources string:'** process has terminated **').
   957     self showError:'** the process has terminated **'
   900     codeView flash
       
   901 !
   958 !
   902 
   959 
   903 processAction:aBlock
   960 processAction:aBlock
   904     "do something, then update the context list"
   961     "do something, then update the context list"
   905 
   962 
   925     exclusive := aBoolean
   982     exclusive := aBoolean
   926 !
   983 !
   927 
   984 
   928 interrestingContextFrom:aContext
   985 interrestingContextFrom:aContext
   929     "return an interresting contexts offset, or nil.
   986     "return an interresting contexts offset, or nil.
   930      Just to add a bit of comfort :-)"
   987      This is the context initially shown in the walkback.
   931 
   988      We move up the calling chain, skipping all intermediate Signal
   932     |c found offset sel|
   989      and Exception contexts, to present the context in which the error
       
   990      actually occured.
       
   991      Just for your convenience :-)"
       
   992 
       
   993     |c found offset sel prev|
   933 
   994 
   934     "somewhere, at the bottom, there must be a raise ..."
   995     "somewhere, at the bottom, there must be a raise ..."
   935 
   996 
   936     c := aContext.
   997     c := aContext.
   937     1 to:5 do:[:i |
   998     1 to:5 do:[:i |
   938 	c isNil ifTrue:[^ 1 "^ nil"].
   999 	c isNil ifTrue:[^ 1 "^ nil"].
   939 	sel := c selector.
  1000 	sel := c selector.
   940 	((sel == #raise) 
  1001 	(sel == #raise) ifTrue:[
   941 	or:[(sel == #raiseRequestWith:)
       
   942 	or:[(sel == #raiseRequestWith:errorString:)]]) 
       
   943 	ifTrue:[
       
   944 	    offset := i.
  1002 	    offset := i.
   945 	    found := c
  1003 	    found := c
   946 	].
  1004 	].
   947 	c := c sender.
  1005 	c := c sender.
   948     ].
  1006     ].
   949 
  1007 
   950     (c := found) isNil ifTrue:[^ 1 "nil"].
  1008     (c := found) isNil ifTrue:[^ 1].
   951 
  1009 
   952     "
  1010     "
   953      got it; move up, for the one that called the raise
  1011      got it; move up, skipping all intermediate Signal and
   954     "
  1012      Exception contexts
   955     (c := c sender) isNil ifTrue:[^ offset].
  1013     "
   956     offset := offset + 1.
  1014     prev := nil.
   957 
  1015     [   
   958     "
  1016 	((c receiver isKindOf:Signal)
   959      now, we are one above the raise
  1017 	or:[(c receiver isKindOf:Exception)])
   960     "
       
   961 
       
   962     "
       
   963      if raise implementation reuses raise code ...
       
   964     "
       
   965     [ 
       
   966 	#( raise raiseRequestWith: #raiseRequestWith:errorString: ) 
       
   967 	includes:c selector 
       
   968     ] whileTrue:[
  1018     ] whileTrue:[
       
  1019 	prev := c.
   969 	(c := c sender) isNil ifTrue:[^ offset].
  1020 	(c := c sender) isNil ifTrue:[^ offset].
   970 	offset := offset + 1.
  1021 	offset := offset + 1.
   971     ].
  1022     ].
       
  1023 
       
  1024     "
       
  1025      now, we are one above the raise
       
  1026     "
   972 
  1027 
   973     "
  1028     "
   974      if the sender of the raise is one of objects error methods ...
  1029      if the sender of the raise is one of objects error methods ...
   975     "
  1030     "
   976     ( #( halt halt: 
  1031     ( #( halt halt: 
   986 	    (c := c sender) isNil ifTrue:[^ offset].
  1041 	    (c := c sender) isNil ifTrue:[^ offset].
   987 	    offset := offset + 1.
  1042 	    offset := offset + 1.
   988 	].
  1043 	].
   989 	(c := c sender) isNil ifTrue:[^ offset].
  1044 	(c := c sender) isNil ifTrue:[^ offset].
   990 	offset := offset + 1.
  1045 	offset := offset + 1.
       
  1046     ] ifFalse:[
       
  1047 	"
       
  1048 	 ok, got the raise - if its a BreakPoint, look for the sender
       
  1049 	"
       
  1050 	prev receiver == MessageTracer breakpointSignal ifTrue:[
       
  1051 	    offset := offset + 1
       
  1052 	].
   991     ].
  1053     ].
   992 
  1054 
   993     ^ offset
  1055     ^ offset
   994 !
  1056 !
   995 
  1057 
  1019 	"
  1081 	"
  1020 	 get them all
  1082 	 get them all
  1021 	"
  1083 	"
  1022 	[con notNil and:[contextArray size <= nChainShown]] whileTrue:[
  1084 	[con notNil and:[contextArray size <= nChainShown]] whileTrue:[
  1023 	    contextArray add:con.
  1085 	    contextArray add:con.
  1024 	    (Smalltalk at:#SystemDebugging ifAbsent:[false]) ifTrue:[
  1086 	    (MoreDebuggingDetail == true) ifTrue:[
  1025 		text add:(((ObjectMemory addressOf:con) printStringRadix:16) , ' ' , con printString).
  1087 		text add:(((ObjectMemory addressOf:con) printStringRadix:16) , ' ' , con printString).
  1026 	    ] ifFalse:[
  1088 	    ] ifFalse:[
  1027 		text add:con printString.
  1089 		text add:con printString.
  1028 	    ].
  1090 	    ].
  1029 
  1091 
  1133 	homeContext notNil ifTrue:[
  1195 	homeContext notNil ifTrue:[
  1134 	    sel := homeContext selector.
  1196 	    sel := homeContext selector.
  1135 	    sel notNil ifTrue:[
  1197 	    sel notNil ifTrue:[
  1136 		implementorClass := homeContext searchClass whichClassImplements:sel.
  1198 		implementorClass := homeContext searchClass whichClassImplements:sel.
  1137 		implementorClass isNil ifTrue:[
  1199 		implementorClass isNil ifTrue:[
  1138 		    codeView contents:(resources string:'** no method - no source **')
  1200 		    self showError:'** no method - no source **'
  1139 		] ifFalse:[
  1201 		] ifFalse:[
  1140 		    method := implementorClass compiledMethodAt:sel.
  1202 		    method := implementorClass compiledMethodAt:sel.
  1141 		    code := method source.
  1203 		    code := method source.
  1142 		    code isNil ifTrue:[
  1204 		    code isNil ifTrue:[
  1143 			method sourceFilename notNil ifTrue:[
  1205 			method sourceFilename notNil ifTrue:[
  1144 			    codeView contents:(resources 
  1206 			    codeView contents:(resources 
  1145 						   string:'** no sourcefile: %1 **'
  1207 						   string:'** no sourcefile: %1 **'
  1146 						   with:method sourceFilename)
  1208 						   with:method sourceFilename).
       
  1209 			    codeView flash
  1147 			] ifFalse:[
  1210 			] ifFalse:[
  1148 			    codeView contents:(resources string:'** no source **')
  1211 			    self showError:'** no source **'
  1149 			]
  1212 			]
  1150 		    ]
  1213 		    ]
  1151 		].
  1214 		].
  1152 		code isNil ifTrue:[
  1215 		code isNil ifTrue:[
  1153 		    codeView acceptAction:nil.
  1216 		    codeView acceptAction:nil.
  1263 
  1326 
  1264 destroy
  1327 destroy
  1265     "closing the debugger implies an abort or continue"
  1328     "closing the debugger implies an abort or continue"
  1266 
  1329 
  1267     contextView middleButtonMenu hide.
  1330     contextView middleButtonMenu hide.
       
  1331 
       
  1332     "
       
  1333      we manually release all private data, since the Debugger
       
  1334      is cached for reuse - thus the memory would not be collectable
       
  1335      otherwise.
       
  1336     "
  1268     receiverInspector release.
  1337     receiverInspector release.
  1269     contextInspector release.
  1338     contextInspector release.
       
  1339     inspectedProcess := nil.
       
  1340     exitAction := nil.
       
  1341     contextArray := nil.
       
  1342     selectedContext := nil.
       
  1343     catchBlock := nil.
       
  1344     grabber := nil.
       
  1345     self autoUpdateOff.
       
  1346 
       
  1347     super destroy.
       
  1348 
  1270     inspecting ifFalse:[
  1349     inspecting ifFalse:[
  1271 	canAbort ifTrue:[
  1350 	canAbort ifTrue:[
  1272 	    self doAbort.
  1351 	    self doAbort.
  1273 	    'oops, abort failed' errorPrintNewline.
  1352 	    'oops, abort failed' errorPrintNewline.
  1274 	] ifFalse:[
  1353 	] ifFalse:[
  1275 	    self doContinue
  1354 	    self doContinue
  1276 	]
  1355 	]
  1277     ].
  1356     ].
  1278     self autoUpdateOff.
       
  1279     inspectedProcess := nil.
       
  1280     super destroy
       
  1281 !
  1357 !
  1282 
  1358 
  1283 doExit
  1359 doExit
  1284     "exit from menu: immediate exit from smalltalk"
  1360     "exit from menu: immediate exit from smalltalk"
  1285 
  1361 
  1288 
  1364 
  1289 doRemoveBreakpoint
  1365 doRemoveBreakpoint
  1290     "remove breakpoint on the selected contexts method - if any"
  1366     "remove breakpoint on the selected contexts method - if any"
  1291 
  1367 
  1292     |implementorClass method|
  1368     |implementorClass method|
       
  1369 
       
  1370     selectedContext isNil ifTrue:[
       
  1371 	^ self showError:'** select a context first **'
       
  1372     ].
  1293 
  1373 
  1294     implementorClass := selectedContext searchClass 
  1374     implementorClass := selectedContext searchClass 
  1295 			    whichClassImplements:selectedContext selector.
  1375 			    whichClassImplements:selectedContext selector.
  1296     implementorClass notNil ifTrue:[
  1376     implementorClass notNil ifTrue:[
  1297 	method := implementorClass compiledMethodAt:selectedContext selector.
  1377 	method := implementorClass compiledMethodAt:selectedContext selector.
  1309 !
  1389 !
  1310 
  1390 
  1311 doSenders
  1391 doSenders
  1312     "open a browser on the senders"
  1392     "open a browser on the senders"
  1313 
  1393 
  1314     selectedContext notNil ifTrue:[
  1394     selectedContext isNil ifTrue:[
  1315 	SystemBrowser browseAllCallsOn:selectedContext selector.
  1395 	^ self showError:'** select a context first **'
  1316     ]
  1396     ].
       
  1397     SystemBrowser browseAllCallsOn:selectedContext selector.
  1317 !
  1398 !
  1318 
  1399 
  1319 doImplementors
  1400 doImplementors
  1320     "open a browser on the implementors"
  1401     "open a browser on the implementors"
  1321 
  1402 
  1322     selectedContext notNil ifTrue:[
  1403     selectedContext isNil ifTrue:[
  1323 	SystemBrowser browseImplementorsOf:selectedContext selector.
  1404 	^ self showError:'** select a context first **'
  1324     ]
  1405     ].
       
  1406     SystemBrowser browseImplementorsOf:selectedContext selector.
  1325 !
  1407 !
  1326 
  1408 
  1327 doShowMore
  1409 doShowMore
  1328     "double number of contexts shown"
  1410     "double number of contexts shown"
  1329 
  1411 
  1330     |oldSelection|
  1412     |oldSelection con|
  1331 
  1413 
  1332     contextArray notNil ifTrue:[
  1414     contextArray notNil ifTrue:[
  1333 	oldSelection := contextView selection.
  1415 	oldSelection := contextView selection.
  1334 	nChainShown := nChainShown * 2.
  1416 	nChainShown := nChainShown * 2.
  1335 	self setContext:contextArray first.
  1417 	con := contextArray at:1.
       
  1418 	contextArray at:1 put:nil.
       
  1419 	self setContext:con.
  1336 	contextView selection:oldSelection.
  1420 	contextView selection:oldSelection.
  1337     ]
  1421     ]
  1338 !
  1422 !
  1339 
  1423 
  1340 doSend
  1424 doSend
  1398 	inspectedProcess isDead ifTrue:[
  1482 	inspectedProcess isDead ifTrue:[
  1399 	    self showTerminated.
  1483 	    self showTerminated.
  1400 	    ^ self
  1484 	    ^ self
  1401 	].
  1485 	].
  1402 	(Object abortSignal isHandledIn:inspectedProcess suspendedContext) ifFalse:[
  1486 	(Object abortSignal isHandledIn:inspectedProcess suspendedContext) ifFalse:[
  1403 	    codeView contents:(resources string:'** process no longer handles abort **')
  1487 	    self showError:'** the process does not handle the abort signal **'
  1404 	] ifTrue:[
  1488 	] ifTrue:[
  1405 	    self interruptProcessWith:[Object abortSignal raise].
  1489 	    self interruptProcessWith:[Object abortSignal raise].
  1406 	].
  1490 	].
  1407 	^ self
  1491 	^ self
  1408     ].
  1492     ].
  1421 	]
  1505 	]
  1422     ].
  1506     ].
  1423     ^ self.
  1507     ^ self.
  1424 
  1508 
  1425 "obsolete ..."
  1509 "obsolete ..."
  1426     Processor activeProcess id == 0 ifTrue:[
  1510 "/    Processor activeProcess id == 0 ifTrue:[
  1427 	"dont allow termination of main-thread"
  1511 "/        "dont allow termination of main-thread"
  1428 	exitAction := #abort
  1512 "/        exitAction := #abort
  1429     ] ifFalse:[
  1513 "/    ] ifFalse:[
  1430 	exitAction := #terminate 
  1514 "/        exitAction := #terminate 
  1431     ]
  1515 "/    ]
  1432 !
  1516 !
  1433 
  1517 
  1434 doTerminate
  1518 doTerminate
  1435     "terminate - the process has a chance for cleanup"
  1519     "terminate - the process has a chance for cleanup"
  1436 
  1520 
  1477 
  1561 
  1478 doReturn
  1562 doReturn
  1479     "return - the selected context will do a ^nil"
  1563     "return - the selected context will do a ^nil"
  1480 
  1564 
  1481     inspecting ifTrue:[
  1565     inspecting ifTrue:[
       
  1566 	selectedContext isNil ifTrue:[
       
  1567 	    ^ self showError:'** select a context first **'
       
  1568 	].
  1482 	self interruptProcessWith:[selectedContext return].
  1569 	self interruptProcessWith:[selectedContext return].
  1483 	^ self
  1570 	^ self
  1484     ].
  1571     ].
  1485 
  1572 
  1486     steppedContextAddress := nil.
  1573     steppedContextAddress := nil.
  1497 
  1584 
  1498 doRestart
  1585 doRestart
  1499     "restart - the selected context will be restarted"
  1586     "restart - the selected context will be restarted"
  1500 
  1587 
  1501     inspecting ifTrue:[
  1588     inspecting ifTrue:[
       
  1589 	selectedContext isNil ifTrue:[
       
  1590 	    ^ self showError:'** select a context first **'
       
  1591 	].
  1502 	self interruptProcessWith:[selectedContext restart].
  1592 	self interruptProcessWith:[selectedContext restart].
  1503 	^ self
  1593 	^ self
  1504     ].
  1594     ].
  1505 
  1595 
  1506     steppedContextAddress := nil.
  1596     steppedContextAddress := nil.