From b54de08aa336287a9fc6c51240d1b5deb97ed61d Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Wed, 14 Jul 2021 21:56:17 -0300 Subject: [PATCH] Implements Step Over for $DEBUG mode Using Shift+F8 when stepping line by line when on a line of code that contains a SUB/FUNCTION call, the sub-procedure lines will be run without entering the block of code, and execution will resume in the next line of code after the SUB/FUNCTION call. --- source/ide/ide_methods.bas | 44 ++++++++++++++++++++++++++++++++------ source/qb64.bas | 6 ++++++ source/utilities/vwatch.bi | 3 ++- source/utilities/vwatch.bm | 30 +++++++++++++++++++------- 4 files changed, 68 insertions(+), 15 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 3bc9fecc6..68e17fdc2 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -6114,13 +6114,28 @@ SUB DebugMode clearStatusWindow 1 setStatusMessage 1, "$DEBUG MODE: Set focus to the IDE to control execution", 15 + noFocusMessage = -1 DO 'main loop IF _WINDOWHASFOCUS THEN + IF _KEYDOWN(100304) OR _KEYDOWN(100303) THEN 'SHIFT + IF shiftDown = 0 THEN + stepOverMsg$ = " Over" + noFocusMessage = -1 + END IF + shiftDown = -1 + ELSE + IF shiftDown THEN + stepOverMsg$ = "" + noFocusMessage = -1 + END IF + shiftDown = 0 + END IF + IF noFocusMessage THEN clearStatusWindow 1 - setStatusMessage 1, "$DEBUG MODE: ", 15 + setStatusMessage 1, "$DEBUG MODE: ", 15 noFocusMessage = 0 END IF ELSE @@ -6149,11 +6164,28 @@ SUB DebugMode setStatusMessage 2, "Running...", 10 dummy = DarkenFGBG(1) CASE 16896 'F8 - IF PauseMode = 0 THEN cmd$ = "break" ELSE cmd$ = "step" - PauseMode = -1 - GOSUB SendCommand - clearStatusWindow 2 - setStatusMessage 2, "Paused.", 2 + IF PauseMode = 0 THEN + cmd$ = "break" + PauseMode = -1 + GOSUB SendCommand + clearStatusWindow 2 + setStatusMessage 2, "Paused.", 2 + ELSE + IF shiftDown THEN + cmd$ = "step over" + PauseMode = 0 + GOSUB SendCommand + clearStatusWindow 2 + setStatusMessage 2, "Running...", 10 + dummy = DarkenFGBG(1) + ELSE + cmd$ = "step" + PauseMode = -1 + GOSUB SendCommand + clearStatusWindow 2 + setStatusMessage 2, "Paused.", 2 + END IF + END IF CASE 17152 'F9 IF PauseMode THEN IdeBreakpoints(l) = NOT IdeBreakpoints(l) diff --git a/source/qb64.bas b/source/qb64.bas index 85b67bc42..a7a342d37 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -5112,6 +5112,9 @@ DO PRINT #12, "uint8 *tmp_mem_static_pointer=mem_static_pointer;" PRINT #12, "uint32 tmp_cmem_sp=cmem_sp;" PRINT #12, "#include " + CHR$(34) + "data" + str2$(subfuncn) + ".txt" + CHR$(34) + IF vWatchOn THEN + PRINT #12, "*__LONG_VWATCH_SUBLEVEL=*__LONG_VWATCH_SUBLEVEL+ 1 ;" + END IF 'create new _MEM lock for this scope PRINT #12, "mem_lock *sf_mem_lock;" 'MUST not be static for recursion reasons @@ -5252,6 +5255,9 @@ DO staticarraylist = "": staticarraylistn = 0 'remove previously listed arrays dimstatic = 0 PRINT #12, "exit_subfunc:;" + IF vWatchOn THEN + PRINT #12, "*__LONG_VWATCH_SUBLEVEL=*__LONG_VWATCH_SUBLEVEL- 1 ;" + END IF 'release _MEM lock for this scope PRINT #12, "free_mem_lock(sf_mem_lock);" diff --git a/source/utilities/vwatch.bi b/source/utilities/vwatch.bi index 090efae65..b5821561e 100644 --- a/source/utilities/vwatch.bi +++ b/source/utilities/vwatch.bi @@ -1,7 +1,8 @@ $CHECKING:OFF -DIM SHARED vwatch_linenumber AS LONG +DIM SHARED AS LONG vwatch_linenumber, vwatch_sublevel REDIM SHARED vwatch_breakpoints(0) AS _BYTE 'next lines are just to avoid "unused variable" warnings: vwatch_linenumber = 0 +vwatch_sublevel = 0 vwatch_breakpoints(0) = 0 $CHECKING:ON diff --git a/source/utilities/vwatch.bm b/source/utilities/vwatch.bm index 5d8813899..1222e1e08 100644 --- a/source/utilities/vwatch.bm +++ b/source/utilities/vwatch.bm @@ -1,8 +1,8 @@ $CHECKING:OFF SUB vwatch (linenumber AS LONG) - STATIC AS LONG ide, breakpointCount, timeout - STATIC AS _BYTE PauseMode, bypass + STATIC AS LONG ide, breakpointCount, timeout, startLevel + STATIC AS _BYTE pauseMode, stepOver, bypass STATIC buffer$, endc$ DIM AS LONG i DIM start!, temp$, cmd$, value$, k& @@ -47,19 +47,26 @@ SUB vwatch (linenumber AS LONG) NEXT CASE "run" IF vwatch_breakpoints(linenumber) THEN EXIT DO - PauseMode = 0 + pauseMode = 0 EXIT SUB CASE "break" - PauseMode = -1 + pauseMode = -1 EXIT DO END SELECT LOOP END IF GOSUB GetCommand - IF cmd$ = "break" THEN PauseMode = -1: cmd$ = "" + IF cmd$ = "break" THEN pauseMode = -1: stepOver = 0: cmd$ = "" - IF vwatch_breakpoints(linenumber) = 0 AND PauseMode = 0 THEN + IF stepOver = -1 AND vwatch_sublevel > startLevel AND vwatch_breakpoints(linenumber) = 0 THEN + EXIT SUB + ELSEIF stepOver = -1 AND vwatch_sublevel = startLevel THEN + stepOver = 0 + pauseMode = -1 + END IF + + IF vwatch_breakpoints(linenumber) = 0 AND pauseMode = 0 THEN EXIT SUB END IF @@ -71,10 +78,17 @@ SUB vwatch (linenumber AS LONG) DO 'main loop SELECT CASE cmd$ CASE "run" - PauseMode = 0 + pauseMode = 0 + stepOver = 0 EXIT SUB CASE "step" - PauseMode = -1 + pauseMode = -1 + stepOver = 0 + EXIT SUB + CASE "step over" + pauseMode = -1 + stepOver = -1 + startLevel = vwatch_sublevel EXIT SUB CASE "free" CLOSE #ide