DebugView.st
changeset 936 34f8d67c4932
parent 935 7c75379de9ec
child 937 e1520a0db57e
equal deleted inserted replaced
935:7c75379de9ec 936:34f8d67c4932
    17 		steppedContextAddress canAbort abortButton terminateButton
    17 		steppedContextAddress canAbort abortButton terminateButton
    18 		continueButton stepButton nextButton sendButton returnButton
    18 		continueButton stepButton nextButton sendButton returnButton
    19 		restartButton exclusive inspecting nChainShown inspectedProcess
    19 		restartButton exclusive inspecting nChainShown inspectedProcess
    20 		updateProcess stopButton updateButton monitorToggle stepping
    20 		updateProcess stopButton updateButton monitorToggle stepping
    21 		steppedContextLineno stepForReturn actualContext inWrap
    21 		steppedContextLineno stepForReturn actualContext inWrap
    22 		stackInspector steppedContext wrapperContext'
    22 		stackInspector steppedContext wrapperContext verboseBacktrace'
    23 	classVariableNames:'CachedDebugger CachedExclusive OpenDebuggers MoreDebuggingDetail
    23 	classVariableNames:'CachedDebugger CachedExclusive OpenDebuggers MoreDebuggingDetail
    24 		DebuggingDebugger'
    24 		DebuggingDebugger'
    25 	poolDictionaries:''
    25 	poolDictionaries:''
    26 	category:'Interface-Debugger'
    26 	category:'Interface-Debugger'
    27 !
    27 !
  1034 
  1034 
  1035     super initialize.
  1035     super initialize.
  1036 
  1036 
  1037     font := font on:device.
  1037     font := font on:device.
  1038 
  1038 
       
  1039     verboseBacktrace := false.
       
  1040 
  1039     busy := false.
  1041     busy := false.
  1040     exclusive := false.
  1042     exclusive := false.
  1041     inspecting := false.
  1043     inspecting := false.
  1042     exitAction := nil.
  1044     exitAction := nil.
  1043     bigStep := false.
  1045     bigStep := false.
  1127     contextInspector := ContextInspectorView
  1129     contextInspector := ContextInspectorView
  1128                                 origin:(0.5 @ 0.0) corner:(1.0 @ 1.0)
  1130                                 origin:(0.5 @ 0.0) corner:(1.0 @ 1.0)
  1129                                     in:hpanel.
  1131                                     in:hpanel.
  1130     contextInspector label:'context'.
  1132     contextInspector label:'context'.
  1131 
  1133 
  1132     "Modified: 22.10.1996 / 15:50:01 / cg"
  1134     "Modified: 10.1.1997 / 21:05:52 / cg"
  1133 !
  1135 !
  1134 
  1136 
  1135 initializeMiddleButtonMenu
  1137 initializeMiddleButtonMenu
  1136     |labels selectors m|
  1138     |labels selectors m|
  1137 
  1139 
  1138     exclusive ifTrue:[
  1140     exclusive ifTrue:[
  1139         labels := resources array:#(
  1141         labels := resources array:#(
  1140                                     'show more'
  1142                                     'show more'
       
  1143                                     'show verbose backtrace'
  1141                                     '-'
  1144                                     '-'
  1142                                     'remove breakpoint'
  1145                                     'remove breakpoint'
  1143                                     'remove all trace & breakpoints'
  1146                                     'remove all trace & breakpoints'
  1144                                     '-'
  1147                                     '-'
  1145                                     'copy walkback text'
  1148                                     'copy walkback text'
  1148                                     '='
  1151                                     '='
  1149                                     'exit smalltalk (no confirmation)'
  1152                                     'exit smalltalk (no confirmation)'
  1150                                   ).
  1153                                   ).
  1151         selectors := #(
  1154         selectors := #(
  1152                                  showMore
  1155                                  showMore
       
  1156                                  showVerboseBacktrace
  1153                                  nil
  1157                                  nil
  1154                                  removeBreakpoint
  1158                                  removeBreakpoint
  1155                                  removeAllBreakpoints
  1159                                  removeAllBreakpoints
  1156                                  nil
  1160                                  nil
  1157                                  copyWalkbackText
  1161                                  copyWalkbackText
  1161                                  exit
  1165                                  exit
  1162                       )
  1166                       )
  1163     ] ifFalse:[
  1167     ] ifFalse:[
  1164         labels := resources array:#(
  1168         labels := resources array:#(
  1165                                     'show more'
  1169                                     'show more'
       
  1170                                     'show verbose backtrace'
  1166                                     '-'
  1171                                     '-'
  1167                                     'skip'
  1172                                     'skip'
  1168                                     'step out'
  1173                                     'step out'
  1169                                     '-'
  1174                                     '-'
  1170 "
  1175 "
  1197                                     'exit smalltalk (no confirmation)'
  1202                                     'exit smalltalk (no confirmation)'
  1198                               ).
  1203                               ).
  1199 
  1204 
  1200         selectors := #(
  1205         selectors := #(
  1201                                          showMore
  1206                                          showMore
       
  1207                                          showVerboseBacktrace
  1202                                          nil
  1208                                          nil
  1203                                          skip
  1209                                          skip
  1204                                          skipForReturn
  1210                                          skipForReturn
  1205                                          nil
  1211                                          nil
  1206 "
  1212 "
  1233                                          exit
  1239                                          exit
  1234         ).
  1240         ).
  1235     ].
  1241     ].
  1236 
  1242 
  1237     m := PopUpMenu 
  1243     m := PopUpMenu 
  1238                 labels:labels
  1244                 labels:(resources array:labels)
  1239              selectors:selectors
  1245              selectors:selectors
  1240               receiver:self
  1246               receiver:self
  1241                    for:contextView.
  1247                    for:contextView.
       
  1248 
       
  1249     verboseBacktrace ifTrue:[
       
  1250         m labelAt:#showVerboseBacktrace put:(resources string:'show dense backtrace').
       
  1251         m selectorAt:#showVerboseBacktrace put:#showDenseBacktrace
       
  1252     ].
  1242 
  1253 
  1243     contextView middleButtonMenu:m. 
  1254     contextView middleButtonMenu:m. 
  1244 
  1255 
  1245     inspecting ifTrue:[
  1256     inspecting ifTrue:[
  1246         m notNil ifTrue:[
  1257         m notNil ifTrue:[
  1248                            browseClassHierarchy browseFullClassProtocol
  1259                            browseClassHierarchy browseFullClassProtocol
  1249                            implementors senders inspectContext skip doStepOut).
  1260                            implementors senders inspectContext skip doStepOut).
  1250         ].
  1261         ].
  1251     ]
  1262     ]
  1252 
  1263 
  1253     "Modified: 14.10.1996 / 13:21:26 / cg"
  1264     "Modified: 10.1.1997 / 21:35:36 / cg"
  1254 !
  1265 !
  1255 
  1266 
  1256 realize
  1267 realize
  1257     super realize.
  1268     super realize.
  1258 "/    exclusive ifTrue:[
  1269 "/    exclusive ifTrue:[
  2189     terminateButton turnOff.
  2200     terminateButton turnOff.
  2190 
  2201 
  2191     "Modified: 10.1.1997 / 17:42:10 / cg"
  2202     "Modified: 10.1.1997 / 17:42:10 / cg"
  2192 !
  2203 !
  2193 
  2204 
       
  2205 redisplayBacktrace
       
  2206     |oldSelection con|
       
  2207 
       
  2208     contextArray notNil ifTrue:[
       
  2209         oldSelection := contextView selection.
       
  2210         con := contextArray at:1.
       
  2211         contextArray at:1 put:nil.
       
  2212         self setContext:con.
       
  2213         contextView setSelection:oldSelection.
       
  2214     ]
       
  2215 
       
  2216     "Modified: 25.5.1996 / 12:26:55 / cg"
       
  2217     "Created: 10.1.1997 / 21:36:46 / cg"
       
  2218 !
       
  2219 
  2194 removeAllBreakpoints
  2220 removeAllBreakpoints
  2195     "remove all trace & breakpoints - if any"
  2221     "remove all trace & breakpoints - if any"
  2196 
  2222 
  2197     MessageTracer unwrapAllMethods
  2223     MessageTracer unwrapAllMethods
  2198 !
  2224 !
  2223 	^ self showError:'** select a context first **'
  2249 	^ self showError:'** select a context first **'
  2224     ].
  2250     ].
  2225     SystemBrowser browseAllCallsOn:selectedContext selector.
  2251     SystemBrowser browseAllCallsOn:selectedContext selector.
  2226 !
  2252 !
  2227 
  2253 
       
  2254 showDenseBacktrace
       
  2255     verboseBacktrace := false.
       
  2256     contextView middleButtonMenu labelAt:#showDenseBacktrace put:(resources string:'show verbose backtrace').
       
  2257     contextView middleButtonMenu selectorAt:#showDenseBacktrace put:#showVerboseBacktrace.
       
  2258     self redisplayBacktrace.
       
  2259 
       
  2260     "Created: 10.1.1997 / 21:33:55 / cg"
       
  2261     "Modified: 10.1.1997 / 21:37:21 / cg"
       
  2262 !
       
  2263 
  2228 showMore
  2264 showMore
  2229     "double number of contexts shown"
  2265     "double number of contexts shown"
  2230 
  2266 
  2231     |oldSelection con|
       
  2232 
       
  2233     contextArray notNil ifTrue:[
  2267     contextArray notNil ifTrue:[
  2234         oldSelection := contextView selection.
       
  2235         nChainShown := nChainShown * 2.
  2268         nChainShown := nChainShown * 2.
  2236         con := contextArray at:1.
  2269         self redisplayBacktrace.
  2237         contextArray at:1 put:nil.
       
  2238         self setContext:con.
       
  2239         contextView setSelection:oldSelection.
       
  2240     ]
  2270     ]
  2241 
  2271 
  2242     "Modified: 25.5.1996 / 12:26:55 / cg"
  2272     "Modified: 10.1.1997 / 21:37:04 / cg"
       
  2273 !
       
  2274 
       
  2275 showVerboseBacktrace
       
  2276     verboseBacktrace := true.
       
  2277     contextView middleButtonMenu labelAt:#showVerboseBacktrace put:(resources string:'dense stack backtrace').
       
  2278     contextView middleButtonMenu selectorAt:#showVerboseBacktrace put:#showDenseBacktrace.
       
  2279     self redisplayBacktrace.
       
  2280 
       
  2281     "Modified: 10.1.1997 / 21:37:13 / cg"
  2243 !
  2282 !
  2244 
  2283 
  2245 skip
  2284 skip
  2246     "skip for cursor line in selected method"
  2285     "skip for cursor line in selected method"
  2247 
  2286 
  2343 !
  2382 !
  2344 
  2383 
  2345 setContext:aContext releaseInspectors:releaseInspectors
  2384 setContext:aContext releaseInspectors:releaseInspectors
  2346     "show calling chain from aContext in the walk-back listview"
  2385     "show calling chain from aContext in the walk-back listview"
  2347 
  2386 
  2348     |con text method caller caller2 m count|
  2387     |con text method caller caller2 m count showIt|
  2349 
  2388 
  2350     (contextArray notNil and:[aContext == (contextArray at:1)]) ifTrue:[
  2389     (contextArray notNil and:[aContext == (contextArray at:1)]) ifTrue:[
  2351 	"no change"
  2390         "no change"
  2352 	^ false
  2391         ^ false
  2353     ].
  2392     ].
  2354 
  2393 
  2355     m := contextView middleButtonMenu.
  2394     m := contextView middleButtonMenu.
  2356     m notNil ifTrue:[
  2395     m notNil ifTrue:[
  2357 	m disable:#showMore.
  2396         m disable:#showMore.
  2358     ].
  2397     ].
  2359 
  2398 
  2360     aContext isNil ifTrue:[
  2399     aContext isNil ifTrue:[
  2361 	text := Array with:'** no context **'.
  2400         text := Array with:'** no context **'.
  2362 	contextArray := nil.
  2401         contextArray := nil.
  2363     ] ifFalse:[
  2402     ] ifFalse:[
  2364 	text := OrderedCollection new:nChainShown.
  2403         text := OrderedCollection new:nChainShown.
  2365 	contextArray := OrderedCollection new:nChainShown.
  2404         contextArray := OrderedCollection new:nChainShown.
  2366 	con := aContext.
  2405         con := aContext.
  2367 
  2406 
  2368 	"
  2407         "
  2369 	 get them all
  2408          get them all
  2370 	"
  2409         "
  2371 	count := 0.
  2410         count := 0.
  2372 	[con notNil and:[count <= nChainShown]] whileTrue:[
  2411         [con notNil and:[count <= nChainShown]] whileTrue:[
  2373 	    contextArray add:con. count := count + 1.
  2412             (self showingContext:con) ifTrue:[
  2374 	    (MoreDebuggingDetail == true) ifTrue:[
  2413                 contextArray add:con. count := count + 1.
  2375 		text add:(((ObjectMemory addressOf:con) printStringRadix:16) , ' ' , con printString).
  2414 
  2376 	    ] ifFalse:[
  2415                 (MoreDebuggingDetail == true) ifTrue:[
  2377 		text add:con printString.
  2416                     text add:(((ObjectMemory addressOf:con) printStringRadix:16) , ' ' , con printString).
  2378 	    ].
  2417                 ] ifFalse:[
  2379 
  2418                     text add:con printString.
  2380 	    method := con method.
  2419                 ].
  2381 	    (method notNil and:[method isWrapped]) ifTrue:[
  2420             ].
  2382 		"
  2421 
  2383 		 kludge: if its a wrapped method, then hide the wrap-call
  2422             method := con method.
  2384 		"
  2423             (method notNil and:[method isWrapped]) ifTrue:[
  2385 		caller := con sender.
  2424                 "
  2386 		(caller notNil and:[caller receiver == method originalMethod]) ifTrue:[
  2425                  kludge: if its a wrapped method, then hide the wrap-call
  2387 		    caller2 := caller sender.
  2426                 "
  2388 		    (caller2 notNil and:[caller2 method == method]) ifTrue:[
  2427                 caller := con sender.
  2389 			con := caller2
  2428                 (caller notNil and:[caller receiver == method originalMethod]) ifTrue:[
  2390 		    ]
  2429                     caller2 := caller sender.
  2391 		].
  2430                     (caller2 notNil and:[caller2 method == method]) ifTrue:[
  2392 		caller := caller2 := nil
  2431                         con := caller2
  2393 	    ].
  2432                     ]
  2394 	    con := con sender
  2433                 ].
  2395 	].
  2434                 caller := caller2 := nil
  2396 
  2435             ].
  2397 	"
  2436             con := con sender
  2398 	 did we reach the end ?
  2437         ].
  2399 	"
  2438 
  2400 	(con isNil or:[con sender isNil]) ifTrue:[
  2439         "
  2401 	    "
  2440          did we reach the end ?
  2402 	     the very last one is the startup context
  2441         "
  2403 	     (in main) - it has nil as receiver and nil as selector
  2442         (con isNil or:[con sender isNil]) ifTrue:[
  2404 	    "
  2443             "
  2405 	    contextArray last selector isNil ifTrue:[
  2444              the very last one is the startup context
  2406 		contextArray removeLast.
  2445              (in main) - it has nil as receiver and nil as selector
  2407 		text removeLast
  2446             "
  2408 	    ]
  2447             contextArray last selector isNil ifTrue:[
  2409 	] ifFalse:[
  2448                 contextArray removeLast.
  2410 	    m notNil ifTrue:[
  2449                 text removeLast
  2411 		m enable:#showMore.
  2450             ]
  2412 		text add:(resources string:'*** more walkback follows - click here to see them ***')
  2451         ] ifFalse:[
  2413 	    ].
  2452             m notNil ifTrue:[
  2414 	].
  2453                 m enable:#showMore.
       
  2454                 text add:(resources string:'*** more walkback follows - click here to see them ***')
       
  2455             ].
       
  2456         ].
  2415     ].
  2457     ].
  2416 
  2458 
  2417     contextView setList:text.
  2459     contextView setList:text.
  2418     releaseInspectors ifTrue:[
  2460     releaseInspectors ifTrue:[
  2419 	receiverInspector release.
  2461         receiverInspector release.
  2420 	contextInspector release.
  2462         contextInspector release.
  2421     ].
  2463     ].
  2422 
  2464 
  2423     m notNil ifTrue:[
  2465     m notNil ifTrue:[
  2424 	m disable:#removeBreakpoint.
  2466         m disable:#removeBreakpoint.
  2425 	m disable:#implementors.
  2467         m disable:#implementors.
  2426 	m disable:#senders.
  2468         m disable:#senders.
  2427 	m disable:#browseClass.
  2469         m disable:#browseClass.
  2428     ].
  2470     ].
  2429     ^ true
  2471     ^ true
  2430 
  2472 
  2431     "Created: 14.12.1995 / 19:10:31 / cg"
  2473     "Created: 14.12.1995 / 19:10:31 / cg"
       
  2474     "Modified: 10.1.1997 / 21:01:57 / cg"
  2432 !
  2475 !
  2433 
  2476 
  2434 setContextSkippingInterruptContexts:aContext
  2477 setContextSkippingInterruptContexts:aContext
  2435     "show calling chain from aContext in the walk-back listview.
  2478     "show calling chain from aContext in the walk-back listview.
  2436      Ignore any non-interresting interrupt-context."
  2479      Ignore any non-interresting interrupt-context."
  2469     "Modified: 24.11.1995 / 22:07:30 / cg"
  2512     "Modified: 24.11.1995 / 22:07:30 / cg"
  2470 !
  2513 !
  2471 
  2514 
  2472 showTerminated
  2515 showTerminated
  2473     self showError:'** the process has terminated **'
  2516     self showError:'** the process has terminated **'
       
  2517 !
       
  2518 
       
  2519 showingContext:aContext
       
  2520     "return false, if this context is to be skipped"
       
  2521 
       
  2522     |sel rec|
       
  2523 
       
  2524     verboseBacktrace ifTrue:[^ true].
       
  2525 
       
  2526     rec := aContext receiver.
       
  2527     sel := aContext selector.
       
  2528 
       
  2529     (rec isMemberOf:Block) ifTrue:[
       
  2530         sel == #valueNowOrOnUnwindDo: ifTrue:[^ false].
       
  2531         sel == #valueOnUnwindDo: ifTrue:[^ false].
       
  2532 
       
  2533         sel == #value ifTrue:[^ false].
       
  2534         sel == #value: ifTrue:[^ false].
       
  2535         sel == #value:value: ifTrue:[^ false].
       
  2536         sel == #value:value:value: ifTrue:[^ false].
       
  2537         sel == #value:value:value:value: ifTrue:[^ false].
       
  2538         sel == #value:value:value:value:Value: ifTrue:[^ false].
       
  2539         sel == #value:value:value:value:value:value: ifTrue:[^ false].
       
  2540     ].
       
  2541 
       
  2542 "/    aContext isBlockContext ifTrue:[
       
  2543 "/        sel == #value ifTrue:[^ false].
       
  2544 "/        sel == #value: ifTrue:[^ false].
       
  2545 "/        sel == #value:value: ifTrue:[^ false].
       
  2546 "/        sel == #value:value:value: ifTrue:[^ false].
       
  2547 "/        sel == #value:value:value:value: ifTrue:[^ false].
       
  2548 "/        sel == #value:value:value:value:Value: ifTrue:[^ false].
       
  2549 "/        sel == #value:value:value:value:value:value: ifTrue:[^ false].
       
  2550 "/    ].
       
  2551 
       
  2552     ((rec isMemberOf:Signal) 
       
  2553     or:[(rec isMemberOf:QuerySignal)
       
  2554     or:[rec isMemberOf:SignalSet]]
       
  2555     ) ifTrue:[
       
  2556         sel == #handle:do: ifTrue:[^ false].
       
  2557     ].
       
  2558 
       
  2559     ^ true.
       
  2560 
       
  2561     "Created: 10.1.1997 / 21:01:39 / cg"
       
  2562     "Modified: 10.1.1997 / 21:11:32 / cg"
  2474 !
  2563 !
  2475 
  2564 
  2476 stepping 
  2565 stepping 
  2477     ^ stepping 
  2566     ^ stepping 
  2478 !
  2567 !
  2886                         "
  2975                         "
  2887                          special: look if this context was created by
  2976                          special: look if this context was created by
  2888                          valueWithReceiver kind of method invocation;
  2977                          valueWithReceiver kind of method invocation;
  2889                          if so, grab the method from the sender and show it
  2978                          if so, grab the method from the sender and show it
  2890                         "
  2979                         "
  2891                         ((sender := con sender) notNil
  2980                         ((sender := homeContext sender) notNil
  2892                         and:[(sender selector startsWith:'valueWithReceiver:')
  2981                         and:[(sender selector startsWith:'valueWithReceiver:')
  2893                         and:[sender receiver isMethod]]) ifTrue:[
  2982                         and:[sender receiver isMethod]]) ifTrue:[
  2894                             method := sender receiver.
  2983                             method := sender receiver.
  2895                             self sensor shiftDown ifTrue:[
  2984                             self sensor shiftDown ifTrue:[
  2896                                 code := method decompiledSource
  2985                                 code := method decompiledSource
  3034         ] ifFalse:[
  3123         ] ifFalse:[
  3035             m disableAll:#(browse browseClass browseClassHierarchy browseFullClassProtocol).
  3124             m disableAll:#(browse browseClass browseClassHierarchy browseFullClassProtocol).
  3036         ].
  3125         ].
  3037     ]
  3126     ]
  3038 
  3127 
  3039     "Modified: 1.11.1996 / 16:35:59 / cg"
  3128     "Modified: 10.1.1997 / 21:29:48 / cg"
  3040 ! !
  3129 ! !
  3041 
  3130 
  3042 !DebugView class methodsFor:'documentation'!
  3131 !DebugView class methodsFor:'documentation'!
  3043 
  3132 
  3044 version
  3133 version
  3045     ^ '$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.122 1997-01-10 18:05:11 cg Exp $'
  3134     ^ '$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.123 1997-01-10 20:50:11 cg Exp $'
  3046 ! !
  3135 ! !