Skip to content

Commit

Permalink
Support for breakpoint debugging (#371 / EW-7264)
Browse files Browse the repository at this point in the history
This change places the InspectorService in a separate thread that
manages communication with over the websocket to the inspector.

The change also adds support for runMessageLoopOnPause() and
quitMessageLoopOnPause() to support breakpoints and debugger
break statements.

There is also refactoring of the CDP message handling code so it can
be called with or without the isolate lock held.

This requires workerd to run with the command-line flag -i to turn
on inspector support.

This change only works for single service configurations. Support for
multi service configurations to follow.

To try this out using samples/helloworld as an example:

1) Edit "samples/helloworld/worker.js" and add a debugger statement
   to the handle(request) method.
2) Open workerd in VSCode, select 'workerd with inspector enabled (dbg)'
   as the Run and Debug Target panel. Hit F5 to run and select
   `samples/helloworld/config.capnp` as the config to use.
3) Open devtools in Chrome using either:
   * https://devtools.devprod.cloudflare.dev/js_app?ws=localhost:9229/main
   * chrome:://inspect
4) On the command-line run, `curl http://localhost:8080/`
5) Devtools should break into the running worker.

Bug: #371
Test: manual
Test: existing internal ew tests do not break
  • Loading branch information
ohodson committed Jul 5, 2023
1 parent 1e8b83f commit c57a978
Show file tree
Hide file tree
Showing 4 changed files with 532 additions and 304 deletions.
Loading

0 comments on commit c57a978

Please sign in to comment.