DebugView.st
changeset 3427 c1a0db432106
parent 3412 60d31568ca51
child 3429 1832276b7443
equal deleted inserted replaced
3426:5ae3f3d53865 3427:c1a0db432106
  3021     selector := actualContext selector.
  3021     selector := actualContext selector.
  3022     proto := Method methodDefinitionTemplateForSelector:selector.
  3022     proto := Method methodDefinitionTemplateForSelector:selector.
  3023 
  3023 
  3024     self 
  3024     self 
  3025         codeAccept:('%1\    self halt:''%2 is not yet implemented''.' bindWith:proto with:selector) withCRs
  3025         codeAccept:('%1\    self halt:''%2 is not yet implemented''.' bindWith:proto with:selector) withCRs
  3026         unwind:false.
  3026         unwind:false
       
  3027         onCancel:[^ self]. 
  3027 
  3028 
  3028     self doShowSelection:selectionIndex.
  3029     self doShowSelection:selectionIndex.
  3029     self doRestart
  3030     self doRestart
       
  3031 
       
  3032     "Modified: / 16.11.2001 / 13:43:10 / cg"
  3030 !
  3033 !
  3031 
  3034 
  3032 doIgnoreBreakpoints
  3035 doIgnoreBreakpoints
  3033     ignoreBreakpoints := true.
  3036     ignoreBreakpoints := true.
  3034     self initializeMiddleButtonMenu
  3037     self initializeMiddleButtonMenu
  3445 
  3448 
  3446     "Modified: / 13.1.1998 / 00:24:47 / cg"
  3449     "Modified: / 13.1.1998 / 00:24:47 / cg"
  3447 !
  3450 !
  3448 
  3451 
  3449 showDenseBacktrace
  3452 showDenseBacktrace
       
  3453     |m|
       
  3454 
       
  3455     m := contextView middleButtonMenu.
  3450     verboseBacktrace := false.
  3456     verboseBacktrace := false.
  3451     contextView middleButtonMenu labelAt:#showDenseBacktrace put:(resources string:'show verbose backtrace').
  3457     m labelAt:#showDenseBacktrace put:(resources string:'Show verbose backtrace').
  3452     contextView middleButtonMenu selectorAt:#showDenseBacktrace put:#showVerboseBacktrace.
  3458     m selectorAt:#showDenseBacktrace put:#showVerboseBacktrace.
  3453     self redisplayBacktrace.
  3459     self redisplayBacktrace.
  3454 
  3460 
  3455     "Created: 10.1.1997 / 21:33:55 / cg"
  3461     "Created: / 10.1.1997 / 21:33:55 / cg"
  3456     "Modified: 10.1.1997 / 21:37:21 / cg"
  3462     "Modified: / 16.11.2001 / 13:47:06 / cg"
  3457 !
  3463 !
  3458 
  3464 
  3459 showMore
  3465 showMore
  3460     "double number of contexts shown"
  3466     "double number of contexts shown"
  3461 
  3467 
  3466 
  3472 
  3467     "Modified: 12.1.1997 / 01:24:26 / cg"
  3473     "Modified: 12.1.1997 / 01:24:26 / cg"
  3468 !
  3474 !
  3469 
  3475 
  3470 showVerboseBacktrace
  3476 showVerboseBacktrace
       
  3477     |m|
       
  3478 
  3471     verboseBacktrace := true.
  3479     verboseBacktrace := true.
  3472     contextView middleButtonMenu labelAt:#showVerboseBacktrace put:(resources string:'dense stack backtrace').
  3480     m := contextView middleButtonMenu.
  3473     contextView middleButtonMenu selectorAt:#showVerboseBacktrace put:#showDenseBacktrace.
  3481     m labelAt:#showVerboseBacktrace put:(resources string:'Show dense backtrace').
       
  3482     m selectorAt:#showVerboseBacktrace put:#showDenseBacktrace.
  3474     self redisplayBacktrace.
  3483     self redisplayBacktrace.
  3475 
  3484 
  3476     "Modified: 10.1.1997 / 21:37:13 / cg"
  3485     "Modified: / 16.11.2001 / 13:46:43 / cg"
  3477 !
  3486 !
  3478 
  3487 
  3479 skip
  3488 skip
  3480     "skip for cursor line in selected method"
  3489     "skip for cursor line in selected method"
  3481 
  3490 
  3710                 ]
  3719                 ]
  3711             ].
  3720             ].
  3712             suspendContext notNil ifTrue:[
  3721             suspendContext notNil ifTrue:[
  3713                 con := suspendContext. suspendContext := nil
  3722                 con := suspendContext. suspendContext := nil
  3714             ].
  3723             ].
       
  3724         ].
       
  3725 
       
  3726         verboseBacktrace ~~ true ifTrue:[
       
  3727             con notNil ifTrue:[    
       
  3728                 "/ hide the halt implementation
       
  3729                 (con selector == #halt
       
  3730                 or:[con selector == #halt:]) ifTrue:[
       
  3731                     con method mclass == Object ifTrue:[
       
  3732                         con := con sender.
       
  3733                     ]
       
  3734                 ]
       
  3735             ]
  3715         ].
  3736         ].
  3716 
  3737 
  3717         "
  3738         "
  3718          get them all
  3739          get them all
  3719         "
  3740         "
  3808                  and:[((h selector == #doIt)
  3829                  and:[((h selector == #doIt)
  3809                        or:[h selector == #doIt:])
  3830                        or:[h selector == #doIt:])
  3810                  and:[h method who isNil]]]) ifTrue:[
  3831                  and:[h method who isNil]]]) ifTrue:[
  3811                     con := con sender.
  3832                     con := con sender.
  3812                     text removeLast.
  3833                     text removeLast.
  3813                     text add:(con methodHome printString)
  3834                     text add:(con methodHome printString).
  3814                 ].
  3835                 ].
  3815                 h := nil.  "/ never keep refs to contexts unless you really need them ...
  3836                 h := nil.  "/ never keep refs to contexts unless you really need them ...
  3816             ].
  3837 
  3817 
  3838 "/                "/ and also, all lazy loading intermediates
  3818             "/ and also, all lazy loading intermediates
  3839 "/
  3819 
  3840 "/                (con selector == #noByteCode 
  3820             verboseBacktrace ~~ true ifTrue:[
  3841 "/                and:[con receiver isMethod
  3821                 (con selector == #noByteCode 
  3842 "/                and:[con receiver isLazyMethod]]) ifTrue:[
  3822                 and:[con receiver isMethod
  3843 "/                    contextArray removeLast.    
  3823                 and:[con receiver isLazyMethod]]) ifTrue:[
  3844 "/                    text removeLast.
  3824                     contextArray removeLast.    
  3845 "/                    con := con sender.
  3825                     text removeLast.
  3846 "/                    count := count - 1.
  3826                     con := con sender.
  3847 "/                ]
  3827                     count := count - 1.
  3848             ].
  3828                 ]
  3849 
  3829             ].
  3850             "/ with dense backtrace, dont show below the doIt
  3830 
  3851             ( verboseBacktrace ~~ true
  3831             con := con sender
  3852             and:[ con selector == #doIt]) ifTrue:[
       
  3853                 con := nil.  
       
  3854             ] ifFalse:[
       
  3855                 con := con sender
       
  3856             ]
  3832         ].
  3857         ].
  3833 
  3858 
  3834         "
  3859         "
  3835          did we reach the end ?
  3860          did we reach the end ?
  3836         "
  3861         "
  3886         m disable:#browseReceiversClass.
  3911         m disable:#browseReceiversClass.
  3887     ].
  3912     ].
  3888     ^ true
  3913     ^ true
  3889 
  3914 
  3890     "Created: / 14.12.1995 / 19:10:31 / cg"
  3915     "Created: / 14.12.1995 / 19:10:31 / cg"
  3891     "Modified: / 30.9.1998 / 21:29:07 / cg"
  3916     "Modified: / 16.11.2001 / 13:59:41 / cg"
  3892 !
  3917 !
  3893 
  3918 
  3894 setContextSkippingInterruptContexts:aContext
  3919 setContextSkippingInterruptContexts:aContext
  3895     "show calling chain from aContext in the walk-back listview.
  3920     "show calling chain from aContext in the walk-back listview.
  3896      Ignore any non-interesting interrupt-context."
  3921      Ignore any non-interesting interrupt-context."
  4530     ].
  4555     ].
  4531 
  4556 
  4532     "Modified: / 15.11.2001 / 17:07:29 / cg"
  4557     "Modified: / 15.11.2001 / 17:07:29 / cg"
  4533 !
  4558 !
  4534 
  4559 
       
  4560 codeAccept:someCode unwind:doUnwind onCancel:cancelAction
       
  4561     "user wants some code to be recompiled - must unwind stack since everything above
       
  4562      and including selected method cannot be continued."
       
  4563 
       
  4564     "
       
  4565      actually, this is not true, since the active methods will still be
       
  4566      executed correctly - however, the code shown in the debugger is no
       
  4567      longer in sync (showing the new code) with the executed code.
       
  4568      Therefore, we hide those contexts to avoid confusion ....
       
  4569      If you dont like this behavior, remove the 'inspecting ifFalse:' check below"
       
  4570 
       
  4571     "walk up context chain and find highest context which is either the selected context,
       
  4572      or - if its a block-context - whose home is the selected context"
       
  4573 
       
  4574     |con top sel implementorClass method newMethod category|
       
  4575 
       
  4576     codeView withWaitCursorDo:[
       
  4577         "
       
  4578          find the method-home context for this one
       
  4579         "
       
  4580         con := selectedContext.
       
  4581         top := con.
       
  4582         [con notNil] whileTrue:[
       
  4583             (con methodHome == selectedContext) ifTrue:[
       
  4584                 top := con
       
  4585             ].
       
  4586             con := con sender
       
  4587         ].
       
  4588         "
       
  4589          use class&selector to find the method for the compilation
       
  4590          and compile.
       
  4591         "
       
  4592         sel := selectedContext selector.
       
  4593         implementorClass := selectedContext methodClass.
       
  4594         implementorClass notNil ifTrue:[
       
  4595             method := implementorClass compiledMethodAt:sel.
       
  4596             category := method category    
       
  4597         ] ifFalse:[
       
  4598             implementorClass := selectedContext receiver class.
       
  4599             implementorClass ~~ Object ifTrue:[
       
  4600                 implementorClass := Dialog 
       
  4601                                         request:('Define #''%1'' in which class:' bindWith:sel)
       
  4602                                         initialAnswer:implementorClass name
       
  4603                                         list:(implementorClass withAllSuperclasses collect:[:each| each name]).
       
  4604                 implementorClass size == 0 ifTrue:[
       
  4605                     ^ cancelAction value "/ cancelled
       
  4606                 ].
       
  4607                 implementorClass := Smalltalk at:implementorClass asSymbol.
       
  4608                 implementorClass isNil ifTrue:[
       
  4609                     Dialog warn:'no such class'.
       
  4610                     ^ cancelAction value "/ cancelled
       
  4611                 ].
       
  4612             ].
       
  4613             category := '* As yet uncategorized *'.
       
  4614         ].
       
  4615 
       
  4616         "/
       
  4617         "/ provide the classes nameSpace on a query;
       
  4618         "/ in case we accept while in another nameSpace context,
       
  4619         "/ (but for a class which is somewhere else)
       
  4620         "/
       
  4621         Class updateChangeFileQuerySignal answer:true
       
  4622         do:[
       
  4623             Class updateChangeListQuerySignal answer:true
       
  4624             do:[
       
  4625                 Class nameSpaceQuerySignal
       
  4626                 answer:(implementorClass nameSpace)
       
  4627                 do:[
       
  4628                     newMethod := implementorClass compilerClass
       
  4629                                      compile:someCode
       
  4630                                      forClass:implementorClass
       
  4631                                      inCategory:category
       
  4632                                      notifying:codeView.
       
  4633                 ].
       
  4634             ].
       
  4635         ].
       
  4636 
       
  4637         inspecting ifFalse:[
       
  4638             "
       
  4639              if it worked, remove everything up to and including top
       
  4640              from context chain
       
  4641             "
       
  4642             (newMethod notNil and:[newMethod ~~ #Error]) ifTrue:[
       
  4643                 codeView modified:false.
       
  4644 
       
  4645                 doUnwind ifTrue:[
       
  4646                     self setContext:(top sender).
       
  4647 
       
  4648                     "
       
  4649                      continue/step is no longer possible
       
  4650                     "
       
  4651                     canContinue := false.
       
  4652                     exitAction := #return.
       
  4653                 ].
       
  4654                 self showSelection:1.
       
  4655             ] ifFalse:[
       
  4656                 ^ cancelAction value
       
  4657             ]
       
  4658         ].
       
  4659     ].
       
  4660 
       
  4661     "Created: / 16.11.2001 / 13:42:39 / cg"
       
  4662     "Modified: / 16.11.2001 / 13:44:34 / cg"
       
  4663 !
       
  4664 
  4535 doShowSelection:lineNr
  4665 doShowSelection:lineNr
  4536     "user clicked on a header line - show selected code in textView.
  4666     "user clicked on a header line - show selected code in textView.
  4537      Also sent to autoselect an interesting context on entry."
  4667      Also sent to autoselect an interesting context on entry."
  4538 
  4668 
  4539     |breakPointSignal|
  4669     |breakPointSignal|
  4643 "/            Object errorSignal handle:[:ex |
  4773 "/            Object errorSignal handle:[:ex |
  4644 "/                'DebugView [warning]: error while accessing context' errorPrintCR.
  4774 "/                'DebugView [warning]: error while accessing context' errorPrintCR.
  4645 "/                contextInspector inspect:nil.
  4775 "/                contextInspector inspect:nil.
  4646 "/            ] do:[
  4776 "/            ] do:[
  4647                 contextInspector inspect:con.
  4777                 contextInspector inspect:con.
  4648                 contextInspector tryToSelectedKeyNamed:lastSelectionInContextInspector.
  4778                 contextInspector tryToSelectKeyNamed:lastSelectionInContextInspector.
  4649 
  4779 
  4650 "/            ].
  4780 "/            ].
  4651 
  4781 
  4652             "/ show a stack inspector sometimes
  4782             "/ show a stack inspector sometimes
  4653 
  4783 
  4880             ] ifFalse:[
  5010             ] ifFalse:[
  4881                 codeView acceptAction:[:code | self device beep]
  5011                 codeView acceptAction:[:code | self device beep]
  4882             ].
  5012             ].
  4883 
  5013 
  4884             receiverInspector inspect:rec.
  5014             receiverInspector inspect:rec.
  4885             receiverInspector tryToSelectedKeyNamed:lastSelectionInReceiverInspector.
  5015             receiverInspector tryToSelectKeyNamed:lastSelectionInReceiverInspector.
  4886 
  5016 
  4887             "
  5017             "
  4888              the one below is wrong: currently, the
  5018              the one below is wrong: currently, the
  4889              evaluator cannot handle passed contexts.
  5019              evaluator cannot handle passed contexts.
  4890              Once it does, pass con as in:-arg
  5020              Once it does, pass con as in:-arg
  4940      enable/disable some menu items
  5070      enable/disable some menu items
  4941     "
  5071     "
  4942     self updateMenuItems
  5072     self updateMenuItems
  4943 
  5073 
  4944     "Created: / 14.8.1997 / 20:15:00 / cg"
  5074     "Created: / 14.8.1997 / 20:15:00 / cg"
  4945     "Modified: / 13.11.1998 / 23:19:35 / cg"
  5075     "Modified: / 16.11.2001 / 13:49:06 / cg"
  4946 !
  5076 !
  4947 
  5077 
  4948 updateMenuItems
  5078 updateMenuItems
  4949     |m mthd cls mCls rCls|
  5079     |m mthd cls mCls rCls|
  4950 
  5080 
  4991 ! !
  5121 ! !
  4992 
  5122 
  4993 !DebugView class methodsFor:'documentation'!
  5123 !DebugView class methodsFor:'documentation'!
  4994 
  5124 
  4995 version
  5125 version
  4996     ^ '$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.292 2001-11-15 16:10:55 cg Exp $'
  5126     ^ '$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.293 2001-11-16 13:23:06 cg Exp $'
  4997 ! !
  5127 ! !
  4998 DebugView initialize!
  5128 DebugView initialize!