pharo-spec / ScriptableDebugger

3 stars 12 forks source link

stepToReturn command doesn't step to non-local returns (in block) #21

Closed adri09070 closed 2 years ago

adri09070 commented 2 years ago

In SindarinDebugger, the stepToReturn command doesn't step to returns in blocks, as its implementation uses stepOver:

stepToReturn

    [ 
    self context instructionStream willReturn or: [ self hasSignalledUnhandledException ] ] 
        whileFalse: [ self debugSession stepOver ]

Thus, in SindarinDebuggerTest, the testStepToNonLocalreturn is red:

testStepToNonLocalReturn
    | dbg |
    self skipOnPharoCITestingEnvironment.   
    dbg := SindarinDebugger debug: [ self helperMethodNonLocalReturn ].
    dbg stepToMethodEntry.
    dbg stepToReturn.

    self assert: dbg node isReturn.
    self assert: dbg topStack equals: 42

It could be fixed with a version doing stepOver (necessary to stop on exception signals, while skipping halts) and doing stepInto only when we are on a message node that has a block node that is defined in the same lexical context as the context in which we want to step to return.