From 231e28c79bf008a98b1b25298f90c46f7bc9bb18 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Thu, 22 Jul 2021 00:18:34 -0300 Subject: [PATCH] Adds method to allow closing the connection with the IDE. In order to allow $DEBUG to work with programs that call CLEAR, the connection handle used to connect to the IDE is locked by default and cannot be CLOSEd. With this change, the debuggee itself can now unlock the handle and close the link. --- internal/c/libqb.cpp | 8 ++++++++ internal/c/qbx.cpp | 3 +++ source/qb64.bas | 9 +++++++++ source/utilities/vwatch/vwatch.bm | 11 ++++++----- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/internal/c/libqb.cpp b/internal/c/libqb.cpp index c08a01dc3..50a7ed15b 100644 --- a/internal/c/libqb.cpp +++ b/internal/c/libqb.cpp @@ -5397,6 +5397,14 @@ extern uint32 error_retry; void sub__echo(qbs *message); +void unlockvWatchHandle() { + if (vwatch>0) vwatch=-1; +} + +int32 vWatchHandle() { + return vwatch; +} + void sub__assert(int32 expression, qbs *assert_message, int32 passed) { if (asserts==0) return; if (expression==0) { diff --git a/internal/c/qbx.cpp b/internal/c/qbx.cpp index 15cf2e41d..be453c5e6 100755 --- a/internal/c/qbx.cpp +++ b/internal/c/qbx.cpp @@ -12,6 +12,9 @@ extern void sub__consolefont(qbs* FontName, int FontSize); extern void sub__console_cursor(int32 visible, int32 cursorsize, int32 passed); extern int32 func__getconsoleinput(); +extern void unlockvWatchHandle(); +extern int32 vWatchHandle(); + #ifdef DEPENDENCY_ZLIB #include qbs *func__deflate(qbs *text); diff --git a/source/qb64.bas b/source/qb64.bas index 0beb8be2d..12277c429 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -8768,7 +8768,16 @@ DO END IF END IF + IF firstelement$ = "CHAIN" THEN + IF vWatchOn THEN + addWarning linenumber, inclevel, inclinenumber(inclevel), incname$(inclevel), "Feature incompatible with $DEBUG MODE", "CHAIN" + END IF + END IF + IF firstelement$ = "RUN" THEN 'RUN + IF vWatchOn THEN + addWarning linenumber, inclevel, inclinenumber(inclevel), incname$(inclevel), "Feature incompatible with $DEBUG MODE", "RUN" + END IF l$ = SCase$("Run") IF n = 1 THEN 'no parameters diff --git a/source/utilities/vwatch/vwatch.bm b/source/utilities/vwatch/vwatch.bm index 3ffced1e4..59dc05577 100644 --- a/source/utilities/vwatch/vwatch.bm +++ b/source/utilities/vwatch/vwatch.bm @@ -13,6 +13,7 @@ SUB vwatch (localVariables AS _OFFSET) DECLARE LIBRARY SUB vwatch_stoptimers ALIAS stop_timers SUB vwatch_starttimers ALIAS start_timers + SUB unlockvWatchHandle END DECLARE IF bypass THEN EXIT SUB @@ -35,7 +36,7 @@ SUB vwatch (localVariables AS _OFFSET) SELECT CASE cmd$ CASE "vwatch" IF value$ <> "ok" THEN - CLOSE #ideHost + unlockvWatchHandle: CLOSE #ideHost bypass = -1 EXIT SUB END IF @@ -48,7 +49,7 @@ SUB vwatch (localVariables AS _OFFSET) IF LEN(value$) \ 4 <> breakpointCount THEN cmd$ = "quit:Communication error." GOSUB SendCommand - CLOSE #ideHost + unlockvWatchHandle: CLOSE #ideHost bypass = -1 EXIT SUB END IF @@ -62,7 +63,7 @@ SUB vwatch (localVariables AS _OFFSET) IF LEN(value$) \ 4 <> skipCount THEN cmd$ = "quit:Communication error." GOSUB SendCommand - CLOSE #ideHost + unlockvWatchHandle: CLOSE #ideHost bypass = -1 EXIT SUB END IF @@ -85,7 +86,7 @@ SUB vwatch (localVariables AS _OFFSET) GOSUB SendCallStack cmd$ = "quit:Program ended." GOSUB SendCommand - CLOSE #ideHost + unlockvWatchHandle: CLOSE #ideHost bypass = -1 ideHost = 0 EXIT SUB @@ -193,7 +194,7 @@ SUB vwatch (localVariables AS _OFFSET) vwatch_starttimers EXIT SUB CASE "free" - CLOSE #ideHost + unlockvWatchHandle: CLOSE #ideHost ideHost = 0 bypass = -1 vwatch_starttimers