pharo-spec / ScriptableDebugger

3 stars 12 forks source link

Skip command causes a missing value on the stack, when `storeInto` bytecodes are involved #23

Closed adri09070 closed 2 years ago

adri09070 commented 2 years ago

The current version of skipAssignment systematically pops the value that was going to be assigned, which is right.

However, when the bytecode involved in the assignment is a storeIntoXXX bytecode instead of a `popIntoXXX bytecode, the assignment value is supposed to stay as this is considered as the result of the assignment. These bytecodes are used in the case of an assignment whose result is used in the next instruction, for example:

In this case, skipAssignment pops the value, which causes an undefined behaviour, as all values on the stack are shifted as one more value was expected.

SindarinDebugger >> skipAssignmentNodeCompletely

    self context pop.
    "Pop the value to be assigned"
    "Increase the pc to go over the assignment"
    self context pc: (self context pc) + (self currentBytecode detect: [:each | each offset = self context pc ]) bytes size.
    "Execute bytecodes the debugger usually executes without stopping the execution (for example popping the return value of the just executed message send if it is not used afterwards)"
    self debugSession stepToFirstInterestingBytecodeIn:
        self debugSession interruptedProcess

To fix this, we should push a replacement value on the stack if the involved bytecode is a storeInto bytecode