1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-26 17:10:38 +00:00

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.
This commit is contained in:
FellippeHeitor 2021-07-14 21:56:17 -03:00
parent 6d374bebcd
commit b54de08aa3
4 changed files with 68 additions and 15 deletions

View file

@ -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: <F5=Continue> <F8=Step> <F9=Toggle Breakpoint> <ESC=Abort>", 15
setStatusMessage 1, "$DEBUG MODE: <F5=Continue> <F8=Step" + stepOverMsg$ + "> <F9=Toggle Breakpoint> <ESC=Abort>", 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)

View file

@ -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);"

View file

@ -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

View file

@ -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