Skip to content

Commit baf7bd8

Browse files
committed
Debugger: add dedicated message for VSCode watch
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
1 parent af4c67a commit baf7bd8

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

src/debugger/Debugger.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ void DebuggerRemote::parseCompleted(String* source, String* srcName, size_t orig
189189

190190
sendType(ESCARGOT_MESSAGE_PARSE_DONE);
191191

192-
if (enabled() && pendingWait()) {
192+
if (enabled() && pendingWait() && !m_watchEval) {
193193
waitForResolvingPendingBreakpoints();
194194
}
195195
}
@@ -371,7 +371,7 @@ bool DebuggerRemote::doEval(ExecutionState* state, Optional<ByteCodeBlock*> byte
371371
}
372372

373373
String* str;
374-
if (type == ESCARGOT_MESSAGE_EVAL_8BIT || type == ESCARGOT_MESSAGE_EVAL_WITHOUT_STOP_8BIT) {
374+
if (type == ESCARGOT_MESSAGE_EVAL_8BIT || type == ESCARGOT_MESSAGE_EVAL_WITHOUT_STOP_8BIT || type == ESCARGOT_MESSAGE_WATCH_8BIT) {
375375
str = new Latin1String(data, size);
376376
} else if (type == ESCARGOT_MESSAGE_EVAL_16BIT || type == ESCARGOT_MESSAGE_EVAL_WITHOUT_STOP_16BIT) {
377377
str = new UTF16String((char16_t*)data, size / 2);
@@ -923,6 +923,16 @@ bool DebuggerRemote::processEvents(ExecutionState* state, Optional<ByteCodeBlock
923923
m_stopState = stopState;
924924
return false;
925925
}
926+
case ESCARGOT_MESSAGE_WATCH_8BIT_START: {
927+
if ((length <= 1 + sizeof(uint32_t)) || m_stopState != ESCARGOT_DEBUGGER_IN_WAIT_MODE) {
928+
break;
929+
}
930+
m_watchEval = true;
931+
ASSERT(byteCodeBlock.hasValue());
932+
const bool res = doEval(state, byteCodeBlock, buffer, length);
933+
m_watchEval = false;
934+
return res;
935+
}
926936
case ESCARGOT_MESSAGE_EVAL_8BIT_START:
927937
case ESCARGOT_MESSAGE_EVAL_16BIT_START: {
928938
if ((length <= 1 + sizeof(uint32_t)) || m_stopState != ESCARGOT_DEBUGGER_IN_WAIT_MODE) {

src/debugger/Debugger.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ class DebuggerRemote : public Debugger {
301301
ESCARGOT_DEBUGGER_PENDING_CONFIG = 23,
302302
ESCARGOT_DEBUGGER_PENDING_RESUME = 24,
303303
ESCARGOT_DEBUGGER_WAIT_BEFORE_EXIT = 25,
304+
ESCARGOT_DEBUGGER_STOP = 26,
305+
ESCARGOT_MESSAGE_WATCH_8BIT_START = 27,
306+
ESCARGOT_MESSAGE_WATCH_8BIT = 28,
304307
};
305308

306309
// Environment record types
@@ -431,6 +434,7 @@ class DebuggerRemote : public Debugger {
431434
bool m_exitClient : 1;
432435
bool m_pendingWait : 1;
433436
bool m_waitForResume : 1;
437+
bool m_watchEval : 1;
434438
String* m_clientSourceData;
435439
String* m_clientSourceName;
436440

tools/debugger/debugger_core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@
101101
ESCARGOT_DEBUGGER_PENDING_CONFIG = 23
102102
ESCARGOT_DEBUGGER_PENDING_RESUME = 24
103103
ESCARGOT_DEBUGGER_WAIT_BEFORE_EXIT = 25
104+
ESCARGOT_DEBUGGER_STOP = 26
105+
ESCARGOT_MESSAGE_WATCH_8BIT_START = 27
106+
ESCARGOT_MESSAGE_WATCH_8BIT = 28
104107

105108

106109
# Environment record types
@@ -588,7 +591,7 @@ def send_client_source(self):
588591
self._exec_command(ESCARGOT_DEBUGGER_THERE_WAS_NO_SOURCE)
589592
return
590593
path = self.client_sources.pop(0)
591-
if not path.endswith('.js'):
594+
if not path.endswith('.js') and not path.endswith('.mjs'):
592595
sys.exit("Error: Javascript file expected!")
593596
with open(path, 'r') as src_file:
594597
content = path + '\0'+ src_file.read()

0 commit comments

Comments
 (0)