Skip to content

js: Bring debugging abilities up to the level of the browser - #11397

Open
AtkinsSJ wants to merge 10 commits into
LadybirdBrowser:masterfrom
AtkinsSJ:extra-debugging-in-js-app
Open

js: Bring debugging abilities up to the level of the browser#11397
AtkinsSJ wants to merge 10 commits into
LadybirdBrowser:masterfrom
AtkinsSJ:extra-debugging-in-js-app

Conversation

@AtkinsSJ

Copy link
Copy Markdown
Member

Extends js's debugging abilities with the functionality added in #11128. The current list is:

backtrace (bt)
break (b) [file:]<line>[:column] [condition]
breakpoints
continue (c)
delete <id>
help
print (p) <expression>
set pause-on-exceptions <none|unhandled|all>
show pause-on-exceptions
step-into (step, s)
step-out (finish, fin)
step-over (next, n)

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7a036e99-ebd4-4bb7-aa3b-e84941060e7d

📥 Commits

Reviewing files that changed from the base of the PR and between f0cfe7d and dd13608.

📒 Files selected for processing (16)
  • Tests/LibJS/CMakeLists.txt
  • Tests/LibJS/Debugger/expected/basic.txt
  • Tests/LibJS/Debugger/expected/conditional-breakpoints.txt
  • Tests/LibJS/Debugger/expected/pause-on-exceptions.txt
  • Tests/LibJS/Debugger/expected/stepping.txt
  • Tests/LibJS/Debugger/input/basic.commands
  • Tests/LibJS/Debugger/input/basic.js
  • Tests/LibJS/Debugger/input/conditional-breakpoints.commands
  • Tests/LibJS/Debugger/input/conditional-breakpoints.js
  • Tests/LibJS/Debugger/input/pause-on-exceptions.args
  • Tests/LibJS/Debugger/input/pause-on-exceptions.commands
  • Tests/LibJS/Debugger/input/pause-on-exceptions.js
  • Tests/LibJS/Debugger/input/stepping.commands
  • Tests/LibJS/Debugger/input/stepping.js
  • Tests/LibJS/Debugger/output/.gitignore
  • Tests/LibJS/test-js-debugger.py

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The debugger now supports frame evaluation without updating original bindings. The js debugger uses named commands and aliases for breakpoints, stepping, backtraces, expression printing, and pause-on-exception settings. Breakpoints can have conditions. The CLI accepts --pause-on-exceptions. C++ and Python tests cover frame evaluation, command output, stepping, exception pauses, and conditional breakpoints.

Sequence Diagram(s)

sequenceDiagram
  participant js_REPL as js debugger REPL
  participant Debugger
  participant PausedFrame
  js_REPL->>Debugger: set breakpoint and condition
  Debugger->>PausedFrame: pause at breakpoint
  js_REPL->>PausedFrame: evaluate condition
  PausedFrame-->>js_REPL: return condition result
  js_REPL->>Debugger: continue or display pause
Loading

Merge Risk: ⚪ Minimal · up to dd136

This PR adds opt-in local JavaScript debugging features without introducing a concrete merge-blocking risk; it is merge-ready after normal checks and review.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description directly summarizes the new debugger commands and aliases implemented in the changeset, including breakpoints, expression evaluation, exception handling, and stepping.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread Tests/LibJS/test-js-debugger.py Outdated
Debugger input is read by a dedicated prompt and cannot be confused with
JavaScript input. Use conventional command names without the unnecessary
dot prefix.
Use one GenericLexer for both the command name and its arguments. Leave
the cursor positioned after the name so every command continues parsing
from it without command-specific substring offsets.
This exercises the debugger functionality of the `js` utility. It
generally follows the same form as test-js-ast and test-js-bytecode,
but we have multiple input files per test:

- `input/foo.js`: The JS file to execute in the debugger.
- `input/foo.commands`: The debugger commands to execute, one per line.
- `input/foo.args`: An optional file with any extra command-line args to
  pass to the `js` binary to run this test.
- `expected/foo.txt` is then the contents of stdout and stderr.

The basic test added here does not use an `.args` file, but later, we'll
use it to exercise the `--pause-on-exceptions` argument.
Accept c for continue and b for break. These familiar aliases reduce
typing without making the full JavaScript-oriented command names less
clear.
Allow debugger sessions to pause on no exceptions, unhandled
exceptions, or all exceptions. Expose the policy through both a
command-line option and set and show debugger commands.
Print paused execution frames from newest to oldest with function names
and available source locations. Accept bt as the familiar short form.
Allow paused-frame evaluation without writing temporary local and
argument binding changes back into that frame. Preserve the existing
mutating behavior by default.
Add print and p commands that evaluate expressions in the current
paused frame. Use non-mutating evaluation so inspection does not alter
local variables or arguments.
Expose step-over, step-into, and step-out through command names that
describe their behavior directly. Also accept the corresponding GDB
commands and abbreviations for users familiar with them.
Accept an optional JavaScript condition after each breakpoint location
and show it when listing breakpoints. Evaluate conditions in the paused
frame and resume automatically when no breakpoint should stop.
@AtkinsSJ
AtkinsSJ force-pushed the extra-debugging-in-js-app branch from f0cfe7d to dd13608 Compare August 28, 2026 10:47
@AtkinsSJ

Copy link
Copy Markdown
Member Author

Rebased, and modified how test-js-debugger works. Each test case is now split into files like with the similar js tests:

  • input/foo.js: The JS file to execute in the debugger.
  • input/foo.commands: The debugger commands to execute, one per line.
  • input/foo.args: An optional file with any extra command-line args to pass to the js binary to run this test.
  • expected/foo.txt is then the contents of stdout and stderr.

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.

2 participants