Skip to content

feat(debug): REDIS_LUA_DEBUG build flavor with in-VM Lua debugger#26

Open
fatal10110 wants to merge 1 commit into
mainfrom
feat/lua-debugger
Open

feat(debug): REDIS_LUA_DEBUG build flavor with in-VM Lua debugger#26
fatal10110 wants to merge 1 commit into
mainfrom
feat/lua-debugger

Conversation

@fatal10110

Copy link
Copy Markdown
Owner

Adds a second WASM flavor (redis_lua.debug.{mjs,wasm}) carrying a full step-debugging surface while leaving the default binary byte-for-byte unchanged:

  • Asyncify build with a single suspendable import, host_debug_request, defined in an Emscripten JS library (debug_library.js) so the paused script's Lua frames stay live while the JS host decides what to do.
  • Pure-Lua debug agent (debug_agent.lua, embedded via a generated header) owning breakpoints, step modes, stack/scopes/variables inspection and paused-frame evaluate; C owns only the combined fuel+line hook, agent lifecycle, and teardown back to the fuel-only hook.
  • eval_debug export loads the user chunk under the script SHA so debugger source identity matches; keeps debug/setfenv/getfenv and compiles ldblib.c in this flavor only.
  • Line events burn fuel too: count events landing inside the (hook- disabled) agent are swallowed by the VM, so count alone cannot kill runaway loops under the debugger.
  • JS API: load({ debug: true }), engine.evalDebug(), RedisHost. onDebugRequest, default debug asset paths; Asyncify-wrapped exports (arity 0) are treated as sret in the ABI sniffing.

Adds a second WASM flavor (redis_lua.debug.{mjs,wasm}) carrying a full
step-debugging surface while leaving the default binary byte-for-byte
unchanged:

- Asyncify build with a single suspendable import, host_debug_request,
  defined in an Emscripten JS library (debug_library.js) so the paused
  script's Lua frames stay live while the JS host decides what to do.
- Pure-Lua debug agent (debug_agent.lua, embedded via a generated header)
  owning breakpoints, step modes, stack/scopes/variables inspection and
  paused-frame evaluate; C owns only the combined fuel+line hook, agent
  lifecycle, and teardown back to the fuel-only hook.
- eval_debug export loads the user chunk under the script SHA so debugger
  source identity matches; keeps debug/setfenv/getfenv and compiles
  ldblib.c in this flavor only.
- Line events burn fuel too: count events landing inside the (hook-
  disabled) agent are swallowed by the VM, so count alone cannot kill
  runaway loops under the debugger.
- JS API: load({ debug: true }), engine.evalDebug(), RedisHost.
  onDebugRequest, default debug asset paths; Asyncify-wrapped exports
  (arity 0) are treated as sret in the ABI sniffing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant