Skip to content

Debugger: add dedicated message for VSCode watch#1542

Open
matetokodi wants to merge 1 commit intoSamsung:masterfrom
matetokodi:fix_debugger_multiple_watches
Open

Debugger: add dedicated message for VSCode watch#1542
matetokodi wants to merge 1 commit intoSamsung:masterfrom
matetokodi:fix_debugger_multiple_watches

Conversation

@matetokodi
Copy link
Contributor

@matetokodi matetokodi commented Feb 12, 2026

Processing VSCode watches skips waitForResolvingPendingBreakpoints (previously having multiple watches in VSC would call this when processing the first watch, which would process pending messages while trying to wait for break point changes while in eval mode (not in waiting mode) and cause and Invalid message error and the closure of the debgger connection when hitting the second watch message)

Allow '*.mjs' files in the python debugger

In combination with: Samsung/escargot-vscode-extension#28

sendType(ESCARGOT_MESSAGE_PARSE_DONE);

if (enabled() && pendingWait()) {
if (enabled() && pendingWait() && !m_watchEval) {

Choose a reason for hiding this comment

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

The condition uses !m_watchEval without any prior check that m_watchEval has been initialized. If m_watchEval is an uninitialized member, reading it causes undefined behavior and can lead to unpredictable skipping of the breakpoint wait. Ensure m_watchEval is initialized (e.g., in the constructor) before this check or guard the access with a safe default value.

if ((length <= 1 + sizeof(uint32_t)) || m_stopState != ESCARGOT_DEBUGGER_IN_WAIT_MODE) {
break;
}
m_watchEval = true;

Choose a reason for hiding this comment

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

The assignment to m_watchEval = true is not reset if doEval throws, leaving the debugger in an inconsistent state. Wrap the call in a try/finally or use a guard to reset m_watchEval to false on all exit paths.

@matetokodi matetokodi force-pushed the fix_debugger_multiple_watches branch from baf7bd8 to 61f6c4b Compare February 12, 2026 22:34
}

m_stopState = ESCARGOT_DEBUGGER_IN_WAIT_MODE;
if (m_watchEval) {

Choose a reason for hiding this comment

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

Replace the if (m_watchEval) { m_watchEval = false; } block with a direct assignment m_watchEval = false;. This removes an unnecessary branch, simplifying control flow. Setting the flag to false when it is already false has no effect, so the change is semantics‑preserving. The refactor improves readability and maintainability without altering behavior.

m_stopState = stopState;
return false;
}
case ESCARGOT_MESSAGE_WATCH_8BIT_START:

Choose a reason for hiding this comment

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

The added case ESCARGOT_MESSAGE_WATCH_8BIT_START: label has no associated code block, causing the watch message to fall through to the next case and be handled as an eval. This logic error means watch evaluations are not performed correctly. Add the original block or remove the case to prevent unintended eval handling.

Processing VSCode watches skips waitForResolvingPendingBreakpoints
(previously having multiple watches in VSC would call this when
processing the first watch, which would process pending messages while
trying to wait for break point changes while in eval mode (not in
waiting mode) and cause and Invalid message error and the closure of the
debgger connection when hitting the second watch message)

Allow '*.mjs' files in the python debugger

Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
@matetokodi matetokodi force-pushed the fix_debugger_multiple_watches branch from 61f6c4b to 81b6907 Compare February 12, 2026 22:43
@ksh8281
Copy link
Contributor

ksh8281 commented Feb 13, 2026

Can you make testcase?

ESCARGOT_DEBUGGER_WAIT_BEFORE_EXIT = 25
ESCARGOT_DEBUGGER_STOP = 26
ESCARGOT_MESSAGE_WATCH_8BIT_START = 27
ESCARGOT_MESSAGE_WATCH_8BIT = 28
Copy link
Contributor

Choose a reason for hiding this comment

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

I think 16 bit variants needs to be added as well

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.

3 participants