DebugView.st
changeset 1394 7765db9114ff
parent 1388 d127d4379a60
child 1398 d3f02207f847
equal deleted inserted replaced
1393:3aac5b288ef1 1394:7765db9114ff
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice.   This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
       
    12 
       
    13 'From Smalltalk/X, Version:3.3.1 on 14-jan-1998 at 12:11:31 am'                 !
    12 
    14 
    13 StandardSystemView subclass:#DebugView
    15 StandardSystemView subclass:#DebugView
    14 	instanceVariableNames:'busy haveControl exitAction canContinue contextView codeView
    16 	instanceVariableNames:'busy haveControl exitAction canContinue contextView codeView
    15 		receiverInspector contextInspector contextArray selectedContext
    17 		receiverInspector contextInspector contextArray selectedContext
    16 		catchBlock grabber traceView tracing bigStep skipLineNr
    18 		catchBlock grabber traceView tracing bigStep skipLineNr
   938 		].
   940 		].
   939 	    ].
   941 	    ].
   940 
   942 
   941 	    ObjectMemory flushInlineCaches.
   943 	    ObjectMemory flushInlineCaches.
   942 
   944 
       
   945 	    enteredByInterrupt printCR.
   943 	    enteredByInterrupt ifTrue:[
   946 	    enteredByInterrupt ifTrue:[
   944 		"/ dont want to step through all intermediate
   947 		"/ dont want to step through all intermediate
   945 		"/ (scheduler-) contexts; place a return-trap on the
   948 		"/ (scheduler-) contexts; place a return-trap on the
   946 		"/ one right below the interesting one
   949 		"/ one right below the interesting one
   947 
   950 
   972 	self cacheMyself.
   975 	self cacheMyself.
   973     ]
   976     ]
   974 
   977 
   975     "Modified: / 17.4.1997 / 13:01:32 / stefan"
   978     "Modified: / 17.4.1997 / 13:01:32 / stefan"
   976     "Created: / 30.10.1997 / 21:08:18 / cg"
   979     "Created: / 30.10.1997 / 21:08:18 / cg"
   977     "Modified: / 30.10.1997 / 21:31:49 / cg"
   980     "Modified: / 13.1.1998 / 15:28:53 / cg"
   978 !
   981 !
   979 
   982 
   980 openOn:aProcess
   983 openOn:aProcess
   981     "enter the debugger on a process - 
   984     "enter the debugger on a process - 
   982      in this case, we are just inspecting the context chain of the process,
   985      in this case, we are just inspecting the context chain of the process,
  1479 
  1482 
  1480 stepInterrupt
  1483 stepInterrupt
  1481     DebuggingDebugger == true ifTrue:[
  1484     DebuggingDebugger == true ifTrue:[
  1482 	'stepIRQ' printCR.
  1485 	'stepIRQ' printCR.
  1483     ].
  1486     ].
       
  1487     Processor yield.
  1484     ^ self stepOrNext
  1488     ^ self stepOrNext
  1485 
  1489 
  1486     "Modified: 14.10.1996 / 13:30:56 / cg"
  1490     "Modified: / 13.1.1998 / 21:14:11 / cg"
  1487 !
  1491 !
  1488 
  1492 
  1489 stepOrNext
  1493 stepOrNext
  1490     |where here s isWrap method lastWrappedConAddr wrappedMethod 
  1494     |where here s isWrap method lastWrappedConAddr wrappedMethod 
  1491      inBlock left ignore contextBelow lastWrappedContext
  1495      inBlock left ignore contextBelow lastWrappedContext
  2291 	 prepare to skip the prolog ...
  2295 	 prepare to skip the prolog ...
  2292 	"
  2296 	"
  2293 
  2297 
  2294 	inWrap := false.
  2298 	inWrap := false.
  2295 	method := con method.
  2299 	method := con method.
  2296 	(method notNil and:[method isWrapped]) ifTrue:[
  2300 	(method notNil 
       
  2301 	and:[method isWrapped
       
  2302 	and:[method originalMethod ~~ method]]) ifTrue:[
  2297 	    inWrap := true
  2303 	    inWrap := true
  2298 	].
  2304 	].
  2299 
  2305 
  2300 	lineNr == #return ifTrue:[
  2306 	lineNr == #return ifTrue:[
  2301 	    Processor activeProcess forceInterruptOnReturnOf:con.
  2307 	    Processor activeProcess forceInterruptOnReturnOf:con.
  2312 	"/ not reached
  2318 	"/ not reached
  2313 	'DebugView [warning]: step failed' errorPrintCR.
  2319 	'DebugView [warning]: step failed' errorPrintCR.
  2314 	stepButton turnOff. nextButton turnOff. sendButton turnOff.
  2320 	stepButton turnOff. nextButton turnOff. sendButton turnOff.
  2315     ]
  2321     ]
  2316 
  2322 
  2317     "Modified: 6.3.1997 / 21:11:38 / cg"
  2323     "Modified: / 13.1.1998 / 15:34:14 / cg"
  2318 !
  2324 !
  2319 
  2325 
  2320 doStop
  2326 doStop
  2321     "stop the process (if its running, otherwise this is a no-op)"
  2327     "stop the process (if its running, otherwise this is a no-op)"
  2322 
  2328 
  2471     ].
  2477     ].
  2472 
  2478 
  2473     implementorClass := selectedContext methodClass. 
  2479     implementorClass := selectedContext methodClass. 
  2474     implementorClass notNil ifTrue:[
  2480     implementorClass notNil ifTrue:[
  2475 	method := implementorClass compiledMethodAt:selectedContext selector.
  2481 	method := implementorClass compiledMethodAt:selectedContext selector.
  2476 	(method notNil and:[method isWrapped]) ifTrue:[
  2482 	(method notNil and:[method isBreakpointed]) ifTrue:[
  2477 	    MessageTracer unwrapMethod:method
  2483 	    method clearBreakPoint
  2478 	]
  2484 	]
  2479     ].
  2485     ].
  2480     contextView middleButtonMenu disable:#removeBreakpoint.
  2486     contextView middleButtonMenu disable:#removeBreakpoint.
  2481 
  2487 
  2482     "Modified: 21.9.1997 / 11:38:32 / cg"
  2488     "Modified: / 13.1.1998 / 00:24:47 / cg"
  2483 !
  2489 !
  2484 
  2490 
  2485 senders
  2491 senders
  2486     "open a browser on the senders"
  2492     "open a browser on the senders"
  2487 
  2493 
  2582     (Delay forSeconds:0.2) wait.
  2588     (Delay forSeconds:0.2) wait.
  2583     self setContext:(inspectedProcess suspendedContext).
  2589     self setContext:(inspectedProcess suspendedContext).
  2584 !
  2590 !
  2585 
  2591 
  2586 redisplayBacktrace
  2592 redisplayBacktrace
       
  2593     "force redisplay of the walkBack list; invoked when the
       
  2594      verbose-flag setting is changed"
       
  2595 
  2587     |oldSelection oldContext con idx|
  2596     |oldSelection oldContext con idx|
  2588 
  2597 
  2589     contextArray notNil ifTrue:[
  2598     contextArray notNil ifTrue:[
  2590 	self withWaitCursorDo:[
  2599 	self withWaitCursorDo:[
  2591 	    oldSelection := contextView selection.
  2600 	    oldSelection := contextView selection.
  2593 		oldContext := contextArray at:oldSelection ifAbsent:nil.
  2602 		oldContext := contextArray at:oldSelection ifAbsent:nil.
  2594 	    ].
  2603 	    ].
  2595 
  2604 
  2596 	    con := firstContext.
  2605 	    con := firstContext.
  2597 "/            con := contextArray at:1.
  2606 "/            con := contextArray at:1.
  2598 	    contextArray at:1 put:nil.
  2607 	    "/ force redeisplay, even if same by changing the first entry
       
  2608 	    contextArray size > 0 ifTrue:[
       
  2609 		contextArray at:1 put:nil.
       
  2610 	    ].
  2599 	    self setContext:con.
  2611 	    self setContext:con.
  2600 
  2612 
  2601 	    oldContext isNil ifTrue:[
  2613 	    oldContext isNil ifTrue:[
  2602 		idx := oldSelection
  2614 		idx := oldSelection
  2603 	    ] ifFalse:[
  2615 	    ] ifFalse:[
  2608 		self showSelection:idx
  2620 		self showSelection:idx
  2609 	    ]
  2621 	    ]
  2610 	]
  2622 	]
  2611     ]
  2623     ]
  2612 
  2624 
  2613     "Created: 10.1.1997 / 21:36:46 / cg"
  2625     "Created: / 10.1.1997 / 21:36:46 / cg"
  2614     "Modified: 12.1.1997 / 01:24:17 / cg"
  2626     "Modified: / 15.1.1998 / 19:45:09 / cg"
  2615 !
  2627 !
  2616 
  2628 
  2617 setContext:aContext
  2629 setContext:aContext
  2618     "show calling chain from aContext in the walk-back listview"
  2630     "show calling chain from aContext in the walk-back listview"
  2619 
  2631 
  2625 setContext:aContext releaseInspectors:releaseInspectors
  2637 setContext:aContext releaseInspectors:releaseInspectors
  2626     "show calling chain from aContext in the walk-back listview"
  2638     "show calling chain from aContext in the walk-back listview"
  2627 
  2639 
  2628     |con text method caller caller2 m count showIt c suspendContext nm h|
  2640     |con text method caller caller2 m count showIt c suspendContext nm h|
  2629 
  2641 
  2630     (contextArray notNil and:[aContext == (contextArray at:1)]) ifTrue:[
  2642     (contextArray size > 0 and:[aContext == (contextArray at:1)]) ifTrue:[
  2631 	"no change"
  2643 	"no change"
  2632 	^ false
  2644 	^ false
  2633     ].
  2645     ].
  2634 
  2646 
  2635     firstContext := aContext.
  2647     firstContext := aContext.
  2788 	m disable:#browseClass.
  2800 	m disable:#browseClass.
  2789     ].
  2801     ].
  2790     ^ true
  2802     ^ true
  2791 
  2803 
  2792     "Created: / 14.12.1995 / 19:10:31 / cg"
  2804     "Created: / 14.12.1995 / 19:10:31 / cg"
  2793     "Modified: / 30.10.1997 / 22:17:18 / cg"
  2805     "Modified: / 15.1.1998 / 19:45:35 / cg"
  2794 !
  2806 !
  2795 
  2807 
  2796 setContextSkippingInterruptContexts:aContext
  2808 setContextSkippingInterruptContexts:aContext
  2797     "show calling chain from aContext in the walk-back listview.
  2809     "show calling chain from aContext in the walk-back listview.
  2798      Ignore any non-interesting interrupt-context."
  2810      Ignore any non-interesting interrupt-context."
  2836 !
  2848 !
  2837 
  2849 
  2838 showingContext:aContext
  2850 showingContext:aContext
  2839     "return false, if this context is to be skipped.
  2851     "return false, if this context is to be skipped.
  2840      Here, we hide some wellKnown methods, which are usually
  2852      Here, we hide some wellKnown methods, which are usually
  2841      not too interesting; the set of methods which are suppressed
  2853      not too interesting; 
  2842      is my (claus's) own choice."
  2854      the set of methods which are suppressed is my (claus's) own choice."
  2843 
  2855 
  2844     |sel rec mClass 
  2856     |sel rec mClass 
  2845      sender senderReceiver senderSelector senderReceiverClass|
  2857      sender senderReceiver senderSelector senderReceiverClass|
  2846 
  2858 
  2847     verboseBacktrace ifTrue:[^ true].
  2859     verboseBacktrace ifTrue:[^ true].
  2920 "/        (senderSelector == #answer:do:) ifTrue:[
  2932 "/        (senderSelector == #answer:do:) ifTrue:[
  2921 "/            senderReceiverClass == QuerySignal ifTrue:[
  2933 "/            senderReceiverClass == QuerySignal ifTrue:[
  2922 "/                ^ false
  2934 "/                ^ false
  2923 "/            ]
  2935 "/            ]
  2924 "/        ]
  2936 "/        ]
       
  2937 
       
  2938 	aContext home notNil ifTrue:[
       
  2939 	    (aContext home receiver isMemberOf:Semaphore) ifTrue:[
       
  2940 		(aContext home selector == #wait) ifTrue:[^ false]
       
  2941 	    ]
       
  2942 	]
  2925     ].
  2943     ].
  2926 
  2944 
  2927     ((mClass == Signal) 
  2945     ((mClass == Signal) 
  2928     or:[(mClass == QuerySignal)
  2946     or:[(mClass == QuerySignal)
  2929     or:[mClass == SignalSet]]
  2947     or:[mClass == SignalSet]]
  2930     ) ifTrue:[
  2948     ) ifTrue:[
  2931 	sel == #handle:do: ifTrue:[^ false].
  2949 	sel == #handle:do: ifTrue:[^ false].
       
  2950 	sel == #raise ifTrue:[^ false].
  2932     ].
  2951     ].
  2933     (mClass == QuerySignal) ifTrue:[
  2952     (mClass == QuerySignal) ifTrue:[
  2934 	sel == #answer:do: ifTrue:[^ false].
  2953 	sel == #answer:do: ifTrue:[^ false].
  2935     ].
  2954     ].
  2936 
  2955     (mClass == Exception) ifTrue:[
       
  2956 	sel == #doRaise ifTrue:[^ false].
       
  2957 	sel == #doCallHandler: ifTrue:[^ false].
       
  2958 	sel == #raise ifTrue:[
       
  2959 	    senderReceiverClass == Signal ifTrue:[^ false].
       
  2960 	]
       
  2961     ].
       
  2962     (mClass == Context) ifTrue:[
       
  2963 	sel == #unwind ifTrue:[^ false].
       
  2964 	sel == #unwind: ifTrue:[^ false].
       
  2965     ].
       
  2966     (mClass == ProcessorScheduler) ifTrue:[
       
  2967 	sel == #interruptActive ifTrue:[^ false].
       
  2968 	sel == #threadSwitch: ifTrue:[^ false].
       
  2969 	sel == #suspend: ifTrue:[^ false].
       
  2970     ].
       
  2971     mClass == Process ifTrue:[
       
  2972 	sel == #suspendWithState: ifTrue:[^ false].
       
  2973     ].
  2937     ^ true.
  2974     ^ true.
  2938 
  2975 
  2939     "Created: / 10.1.1997 / 21:01:39 / cg"
  2976     "Created: / 10.1.1997 / 21:01:39 / cg"
  2940     "Modified: / 7.1.1998 / 11:04:01 / cg"
  2977     "Modified: / 15.1.1998 / 19:47:36 / cg"
  2941 !
  2978 !
  2942 
  2979 
  2943 stepping 
  2980 stepping 
  2944     ^ stepping 
  2981     ^ stepping 
  2945 !
  2982 !
  3433 	    codeSet := false.
  3470 	    codeSet := false.
  3434 
  3471 
  3435 	    "
  3472 	    "
  3436 	     give it to the (lower right) inspector
  3473 	     give it to the (lower right) inspector
  3437 	    "
  3474 	    "
  3438 	    contextInspector inspect:con.
  3475 "/            Object errorSignal handle:[:ex |
       
  3476 "/                'DebugView [warning]: error while accessing context' errorPrintCR.
       
  3477 "/                contextInspector inspect:nil.
       
  3478 "/            ] do:[
       
  3479 		contextInspector inspect:con.
       
  3480 "/            ].
  3439 
  3481 
  3440 	    "/ show a stack inspector sometimes
  3482 	    "/ show a stack inspector sometimes
  3441 
  3483 
  3442 	    con hasStackToShow ifTrue:[
  3484 	    con hasStackToShow ifTrue:[
  3443 		stackInspector isNil ifTrue:[
  3485 		stackInspector isNil ifTrue:[
  3697 	] ifFalse:[
  3739 	] ifFalse:[
  3698 	    m disableAll:#(browse browseClass browseClassHierarchy browseFullClassProtocol).
  3740 	    m disableAll:#(browse browseClass browseClassHierarchy browseFullClassProtocol).
  3699 	].
  3741 	].
  3700     ]
  3742     ]
  3701 
  3743 
  3702     "Created: 14.8.1997 / 20:15:00 / cg"
  3744     "Created: / 14.8.1997 / 20:15:00 / cg"
  3703     "Modified: 19.10.1997 / 01:20:58 / cg"
  3745     "Modified: / 13.1.1998 / 15:36:32 / cg"
  3704 ! !
  3746 ! !
  3705 
  3747 
  3706 !DebugView class methodsFor:'documentation'!
  3748 !DebugView class methodsFor:'documentation'!
  3707 
  3749 
  3708 version
  3750 version
  3709     ^ '$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.182 1998-01-12 13:30:13 cg Exp $'
  3751     ^ '$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.183 1998-01-16 15:24:11 cg Exp $'
  3710 ! !
  3752 ! !
  3711 DebugView initialize!
  3753 DebugView initialize!