Skip to content

cppia: a debugger that attaches before a script loads cannot set breakpoints in it #283

Closed

Description

@dimensionscape

Checked end to end with the VS Code hxcpp debugger's server (hxcpp-debug-server 1.2.4, stock) and a host built with -debug -D scriptable -lib hxcpp-debug-server, on Windows. A breakpoint in the script comes back as -1 and the script runs straight through, interpreted and with the JIT.

The server starts with the host and attaches before any script is loaded. It reads Debugger.getFiles() once, as it attaches, so the script's files are never in its list, and it has no way to learn when they arrive: hxcpp's callback for that, __hxcpp_dbg_setOnScriptLoadedFunction (HaxeFoundation/hxcpp#1203), only exists at API level 500, so with Haxe 4 nothing tells a debugger that a script has loaded.

Our part: call the script-loaded callback at every API level, after a script loads and before it boots, and give C++ a macro to test for it, so a server that also builds against other hxcpp versions can use it. The server's part, reading its files again in the callback and setting the breakpoints that were waiting, is a change to vshaxe/hxcpp-debugger.

With both, breakpoints, stepping over and out, and locals work in a script from the debugger's protocol, in the interpreter and with the JIT, whether the breakpoint was set before the script loaded or while it ran.

Activity

  1. added this to the 6.0.0 milestone on Oct 23, 2026
  2. dimensionscape commented on Oct 23, 2026

    @dimensionscape
    MemberAuthor

    Fixed in 01db441cc7c5ec3e7e161cdd4a5e3caceb0643d8 and 4a9ac2531a71f533ac193e10e8f15e9cecf79981; the second lines up getFilesFullPath() with getFiles() once a script has loaded, which on Linux sent the breakpoints to the wrong file. The function set with __hxcpp_dbg_setOnScriptLoadedFunction now runs after each script loads and before it boots, at every API level, and HXCPP_DBG_ON_SCRIPT_LOADED is defined for C++ that needs to know it is there. Test: CppiaScriptLoaded. docs/CppiaDebugging.md covers using it. The hxcpp-debug-server side is vshaxe/hxcpp-debugger#48.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions