DebugView.st
changeset 913 6460993f73a3
parent 875 f8ee393ca634
child 923 3878260918ee
equal deleted inserted replaced
912:dae70963b64c 913:6460993f73a3
   286 
   286 
   287 defaultIcon
   287 defaultIcon
   288     ^ Image fromFile:'bitmaps/Debugger.xbm' resolution:100
   288     ^ Image fromFile:'bitmaps/Debugger.xbm' resolution:100
   289 
   289 
   290     "Created: 1.1.1970 / 01:00:00 / cg"
   290     "Created: 1.1.1970 / 01:00:00 / cg"
       
   291 ! !
       
   292 
       
   293 !DebugView class methodsFor:'misc'!
       
   294 
       
   295 interestingContextFrom:aContext
       
   296     "return an interesting contexts offset, or nil.
       
   297      This is the context initially shown in the walkback.
       
   298      We move up the calling chain, skipping all intermediate Signal
       
   299      and Exception contexts, to present the context in which the error
       
   300      actually occured.
       
   301      Just for your convenience :-)"
       
   302 
       
   303     |delta con|
       
   304 
       
   305     delta := self interestingContextIndexFrom:aContext.
       
   306     con := aContext.
       
   307     [delta > 1] whileTrue:[
       
   308         con := con sender.
       
   309         delta := delta - 1.
       
   310     ].
       
   311     ^ con
       
   312 
       
   313     "Modified: 7.1.1997 / 21:31:05 / cg"
       
   314 !
       
   315 
       
   316 interestingContextIndexFrom:aContext
       
   317     "return an interesting contexts offset, or nil.
       
   318      This is the context initially shown in the walkback.
       
   319      We move up the calling chain, skipping all intermediate Signal
       
   320      and Exception contexts, to present the context in which the error
       
   321      actually occured.
       
   322      Just for your convenience :-)"
       
   323 
       
   324     |c found offset sel prev ex|
       
   325 
       
   326     aContext isBlockContext ifTrue:[^ 1].
       
   327 
       
   328     "somewhere, at the bottom, there must be a raise ..."
       
   329 
       
   330     c := aContext.
       
   331     1 to:5 do:[:i |
       
   332         c isNil ifTrue:[^ 1 "^ nil"].
       
   333         sel := c selector.
       
   334         (sel == #raise) ifTrue:[
       
   335             (c receiver isKindOf:Exception) ifTrue:[
       
   336                 ex := c receiver.
       
   337                 offset := i.
       
   338                 found := c
       
   339             ] ifFalse:[
       
   340                 (c receiver isSignal) ifTrue:[
       
   341                     offset := i.
       
   342                     found := c
       
   343                 ]
       
   344             ]
       
   345         ].
       
   346         c := c sender.
       
   347     ].
       
   348 
       
   349     "
       
   350      if this is a noHandler exception, skip forward
       
   351      to the erronous context
       
   352     "
       
   353     ex notNil ifTrue:[
       
   354         ex signal == Signal noHandlerSignal ifTrue:[
       
   355             c := ex suspendedContext
       
   356         ]
       
   357     ].
       
   358 
       
   359     (c := found) isNil ifTrue:[
       
   360         "/ this is a kludge, but convenient.
       
   361         "/ show the place where the divisionByZero happend,
       
   362         "/ not where the signal was raised.
       
   363 
       
   364         sel := aContext selector.
       
   365         (sel == #//      
       
   366         or:[sel == #/
       
   367         or:[sel == #\\]]) ifTrue:[
       
   368             ^ 2
       
   369         ].
       
   370 
       
   371         ^ 1
       
   372     ].
       
   373 
       
   374     "
       
   375      got it; move up, skipping all intermediate Signal and
       
   376      Exception contexts
       
   377     "
       
   378     prev := nil.
       
   379     [   
       
   380         ((c receiver isSignal)
       
   381         or:[(c receiver isKindOf:Exception)])
       
   382     ] whileTrue:[
       
   383         prev := c.
       
   384         (c := c sender) isNil ifTrue:[^ offset].
       
   385         offset := offset + 1.
       
   386     ].
       
   387 
       
   388     "
       
   389      now, we are one above the raising context
       
   390     "
       
   391 
       
   392     "
       
   393      if the sender-method of the raise is one of objects error methods ...
       
   394     "
       
   395     ( #( halt halt: 
       
   396          error error: 
       
   397          doesNotUnderstand: 
       
   398          subclassResponsibility 
       
   399          primitiveFailed) includes:c selector) 
       
   400     ifTrue:[
       
   401         c selector == #doesNotUnderstand: ifTrue:[
       
   402             "
       
   403              one more up, to get to the originating context
       
   404             "
       
   405             (c := c sender) isNil ifTrue:[^ offset].
       
   406             offset := offset + 1.
       
   407         ].
       
   408         (c := c sender) isNil ifTrue:[^ offset].
       
   409         offset := offset + 1.
       
   410     ] ifFalse:[
       
   411         "
       
   412          ok, got the raise - if its a BreakPoint, look for the sender
       
   413         "
       
   414         (MessageTracer notNil and:[prev receiver == MessageTracer breakpointSignal]) ifTrue:[
       
   415             offset := offset + 1
       
   416         ].
       
   417     ].
       
   418 
       
   419     ^ offset
       
   420 
       
   421     "Modified: 26.7.1996 / 16:34:58 / cg"
       
   422     "Created: 7.1.1997 / 21:26:05 / cg"
   291 ! !
   423 ! !
   292 
   424 
   293 !DebugView methodsFor:'basic'!
   425 !DebugView methodsFor:'basic'!
   294 
   426 
   295 enter
   427 enter
   419     ] ifFalse:[
   551     ] ifFalse:[
   420         steppedContext isNil ifTrue:[
   552         steppedContext isNil ifTrue:[
   421             "
   553             "
   422              preselect a more interesting context, (where halt/raise was ...)
   554              preselect a more interesting context, (where halt/raise was ...)
   423             "
   555             "
   424             selection := self interestingContextFrom:aContext.
   556             selection := self class interestingContextIndexFrom:aContext.
   425         ] ifFalse:[
   557         ] ifFalse:[
   426             "
   558             "
   427              if we came here by a big-step, show the method where we are
   559              if we came here by a big-step, show the method where we are
   428             "
   560             "
   429             aContext == steppedContext ifTrue:[
   561             aContext == steppedContext ifTrue:[
   711         self cacheMyself.
   843         self cacheMyself.
   712     ]
   844     ]
   713 
   845 
   714     "Created: 24.11.1995 / 19:52:54 / cg"
   846     "Created: 24.11.1995 / 19:52:54 / cg"
   715     "Modified: 3.5.1996 / 23:58:16 / stefan"
   847     "Modified: 3.5.1996 / 23:58:16 / stefan"
   716     "Modified: 7.12.1996 / 13:37:23 / cg"
   848     "Modified: 7.1.1997 / 21:27:28 / cg"
   717 !
   849 !
   718 
   850 
   719 openOn:aProcess
   851 openOn:aProcess
   720     "enter the debugger on a process - 
   852     "enter the debugger on a process - 
   721      in this case, we are just inspecting the context chain of the process,
   853      in this case, we are just inspecting the context chain of the process,
  2170 
  2302 
  2171 inspectedProcess 
  2303 inspectedProcess 
  2172     ^ inspectedProcess 
  2304     ^ inspectedProcess 
  2173 !
  2305 !
  2174 
  2306 
  2175 interestingContextFrom:aContext
       
  2176     "return an interesting contexts offset, or nil.
       
  2177      This is the context initially shown in the walkback.
       
  2178      We move up the calling chain, skipping all intermediate Signal
       
  2179      and Exception contexts, to present the context in which the error
       
  2180      actually occured.
       
  2181      Just for your convenience :-)"
       
  2182 
       
  2183     |c found offset sel prev ex|
       
  2184 
       
  2185     aContext isBlockContext ifTrue:[^ 1].
       
  2186 
       
  2187     "somewhere, at the bottom, there must be a raise ..."
       
  2188 
       
  2189     c := aContext.
       
  2190     1 to:5 do:[:i |
       
  2191         c isNil ifTrue:[^ 1 "^ nil"].
       
  2192         sel := c selector.
       
  2193         (sel == #raise) ifTrue:[
       
  2194             (c receiver isKindOf:Exception) ifTrue:[
       
  2195                 ex := c receiver.
       
  2196                 offset := i.
       
  2197                 found := c
       
  2198             ] ifFalse:[
       
  2199                 (c receiver isSignal) ifTrue:[
       
  2200                     offset := i.
       
  2201                     found := c
       
  2202                 ]
       
  2203             ]
       
  2204         ].
       
  2205         c := c sender.
       
  2206     ].
       
  2207 
       
  2208     "
       
  2209      if this is a noHandler exception, skip forward
       
  2210      to the erronous context
       
  2211     "
       
  2212     ex notNil ifTrue:[
       
  2213         ex signal == Signal noHandlerSignal ifTrue:[
       
  2214             c := ex suspendedContext
       
  2215         ]
       
  2216     ].
       
  2217 
       
  2218     (c := found) isNil ifTrue:[
       
  2219         "/ this is a kludge, but convenient.
       
  2220         "/ show the place where the divisionByZero happend,
       
  2221         "/ not where the signal was raised.
       
  2222 
       
  2223         sel := aContext selector.
       
  2224         (sel == #//      
       
  2225         or:[sel == #/
       
  2226         or:[sel == #\\]]) ifTrue:[
       
  2227             ^ 2
       
  2228         ].
       
  2229         
       
  2230         ^ 1
       
  2231     ].
       
  2232 
       
  2233     "
       
  2234      got it; move up, skipping all intermediate Signal and
       
  2235      Exception contexts
       
  2236     "
       
  2237     prev := nil.
       
  2238     [   
       
  2239         ((c receiver isSignal)
       
  2240         or:[(c receiver isKindOf:Exception)])
       
  2241     ] whileTrue:[
       
  2242         prev := c.
       
  2243         (c := c sender) isNil ifTrue:[^ offset].
       
  2244         offset := offset + 1.
       
  2245     ].
       
  2246 
       
  2247     "
       
  2248      now, we are one above the raising context
       
  2249     "
       
  2250 
       
  2251     "
       
  2252      if the sender-method of the raise is one of objects error methods ...
       
  2253     "
       
  2254     ( #( halt halt: 
       
  2255          error error: 
       
  2256          doesNotUnderstand: 
       
  2257          subclassResponsibility 
       
  2258          primitiveFailed) includes:c selector) 
       
  2259     ifTrue:[
       
  2260         c selector == #doesNotUnderstand: ifTrue:[
       
  2261             "
       
  2262              one more up, to get to the originating context
       
  2263             "
       
  2264             (c := c sender) isNil ifTrue:[^ offset].
       
  2265             offset := offset + 1.
       
  2266         ].
       
  2267         (c := c sender) isNil ifTrue:[^ offset].
       
  2268         offset := offset + 1.
       
  2269     ] ifFalse:[
       
  2270         "
       
  2271          ok, got the raise - if its a BreakPoint, look for the sender
       
  2272         "
       
  2273         (MessageTracer notNil and:[prev receiver == MessageTracer breakpointSignal]) ifTrue:[
       
  2274             offset := offset + 1
       
  2275         ].
       
  2276     ].
       
  2277 
       
  2278     ^ offset
       
  2279 
       
  2280     "Created: 10.12.1995 / 13:55:21 / cg"
       
  2281     "Modified: 26.7.1996 / 16:34:58 / cg"
       
  2282 !
       
  2283 
       
  2284 interruptProcessWith:aBlock
  2307 interruptProcessWith:aBlock
  2285     "let inspected process do something, then update the context list"
  2308     "let inspected process do something, then update the context list"
  2286 
  2309 
  2287     inspectedProcess isDead ifTrue:[
  2310     inspectedProcess isDead ifTrue:[
  2288 	self showTerminated.
  2311 	self showTerminated.
  3017 ! !
  3040 ! !
  3018 
  3041 
  3019 !DebugView class methodsFor:'documentation'!
  3042 !DebugView class methodsFor:'documentation'!
  3020 
  3043 
  3021 version
  3044 version
  3022     ^ '$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.118 1996-12-19 13:41:58 cg Exp $'
  3045     ^ '$Header: /cvs/stx/stx/libtool/DebugView.st,v 1.119 1997-01-07 20:43:11 cg Exp $'
  3023 ! !
  3046 ! !