Skip to content

Add basics of Chrome Devtools debugger support#1552

Draft
matetokodi wants to merge 1 commit intoSamsung:masterfrom
matetokodi:devtools_protocol
Draft

Add basics of Chrome Devtools debugger support#1552
matetokodi wants to merge 1 commit intoSamsung:masterfrom
matetokodi:devtools_protocol

Conversation

@matetokodi
Copy link
Contributor

  • Use routing table for request dispatch in DebuggerHttpRouter, for handling choosing which debugger stack to use based on the http upgrade request:
    • DebuggerEscargot for the python debugger and VSCode
    • DebuggerDevtools for connecting to Chrome Devtools
  • Parse mesasges with 16bit message size
  • Reply to the first few messages chrome sends
  • Refactor Debugger:
    • Rename DebuggerRemote to DebuggerEscargot
    • DebuggerEscargot and DebuggerDevtools inherit from DebuggerTcp which inherits from Debugger

We can successfully connect to Chrome Devtools, send initial source code, and have the debugger wait for further commands from Chrome.

@matetokodi matetokodi force-pushed the devtools_protocol branch 2 times, most recently from 7092bb9 to f675030 Compare March 20, 2026 20:04

class DebuggerC : public Debugger {
public:
virtual void init(const char* options, Context* context) override {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added init override contains an empty body, which can be misleading and may hide missing initialization logic. Removing this empty override or replacing it with a comment clarifies intent and reduces confusion for future maintainers. This refactor cleans up the class definition without altering behavior, keeping the codebase lean and easier to read.

Copy link
Contributor

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice progress!

"\"location\":{"
"\"scriptId\":\"1\","
"\"lineNumber\":0,"
"\"columnNumber\":0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need these values for a pause?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they are part of the non-optional Debugger.paused event in the spec, without them chrome will not say that the debugger is paused.

@@ -0,0 +1,321 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this file is called HttpRouter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It replies to the http GET request, and handles the websocket handshake, depending on which route was requested

#define ESCARGOT_DEBUGGER_NO_STACK_TRACE_RESTORE (reinterpret_cast<ExecutionState*>(0x1))
#define ESCARGOT_DEBUGGER_MAX_VARIABLE_LENGTH 128

#define ESCARGOT_DEBUGGER_WEBSOCKET_FIN_BIT 0x80
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this is moved here? This should be low level used by the transport layer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yeah they should be in DebuggerTcp.

Initially I was going to merge Debugger and DebuggerTcp, so they ended up in Debugger, but later I decided against merging them, and they were forgotten there.

- Use routing table for request dispatch in DebuggerHttpRouter, for
  handling choosing which debugger stack to use based on the http
  upgrade request:
    - DebuggerEscargot for the python debugger and VSCode
    - DebuggerDevtools for connecting to Chrome Devtools
- Parse mesasges with 16bit message size
- Reply to the first few messages chrome sends
- Refactor Debugger:
    - Rename DebuggerRemote to DebuggerEscargot
    - DebuggerEscargot and DebuggerDevtools inherit from
      DebuggerTcp which inherits from Debugger

Co-authored-by: Roland Takacs <roland.takacs@h-lab.eu>
Signed-off-by: Máté Tokodi <mate.tokodi@szteszoftver.hu>
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