tode
tode copied to clipboard
[Enhancement] Select better stack frame for exceptions
A number of Smalltalk implementations handle the signalling of some exceptions better by trimming the (shown) stack to the frame 'signalling' the exception. There is no need to show the exception handling frames in many common cases.
For example, when Pharo (3.0) detects a Halt, it shows the frame sending the #halt message as the top of the stack.
VA Smalltalk does similar, especially with MNU errors (which they call DNU).
GBS for VA Smalltalk looks for the following selectors: (#pause #_doesNotUnderstand:args:envId:reason: #doesNotUnderstand: #halt #halt: #breakpointEncountered: #primitiveFailed #error:)
The list is used in the following way to select a "better" stack frame:
"The debugger has already selected a client frame, if it found one
it preferred or left it nil otherwise. If we have server contexts on
top, find a preferred frame there."
top := stack first.
(top isKindOf: GbxActivation)
ifTrue:
[priority := 999999.
stackSearchSelectors := self serverStackSearchSelectors.
1 to: stack size
do:
[:idx |
| pri frame |
frame := stack at: idx.
pri := stackSearchSelectors indexOf: frame gbxSelector.
(pri > 0
and: [(frame isKindOf: GbxActivation)
and: [pri < priority
and: [frame isExecutingBlock not
and: [frame isBottomOfStack not]]]])
ifTrue:
[stack size > idx ifTrue: [top := stack at: idx + 1].
priority := pri]].
self selectedFrame: top].
It looks for the frame with one of the special selectors and selects the next one down if it can. Otherwise, it continues with the top of the stack for its choice.
(Well, so much for the "code" markup. Just run it through a formatter and you'll be able to read it.)