Skip to content

Cppia debugger reads a function's variables from the wrong frame base #248

Closed

Description

@dimensionscape

Upstream: HaxeFoundation/hxcpp#1426 by @robknopf (open PR).

With HXCPP_STACK_SCRIPTABLE, the debugger reads a cppia function's this and locals from inStack - stackSize in ScriptCallable::getScriptableVariables, getScriptableValue and setScriptableValue (src/hx/cppia/CppiaFunction.cpp). That isn't where the frame starts: a call sets ctx->frame before this and the arguments are pushed, the function's StackLayout already counts them, and runFunction then allocates the whole layout again before CPPIA_STACK_FRAME pushes the hx::StackFrame. So the frame sits at frame + sizeof(hx::Object *) + argBytes + stackSize, and inStack - stackSize lands on the first argument (or the first local), not on this. The debugger then shows and sets the wrong variables.

libhxcpp still has the three inStack - stackSize reads. Port the upstream fix with a debugger test that reads this, an argument and a local of a cppia function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions