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

On error, report back to the IDE. ($DEBUG)

This commit is contained in:
Fellippe Heitor 2021-07-16 23:18:46 -03:00
parent 78fb2ff1b9
commit ae887507c2
5 changed files with 47 additions and 21 deletions

View file

@ -1364,6 +1364,7 @@ extern uint32 qbevent;
extern int32 console;
extern int32 screen_hide_startup;
extern int32 asserts;
extern int32 vwatch;
//...
int64 exit_code=0;

View file

@ -706,6 +706,7 @@ double error_erl=0;
uint32 qbs_tmp_list_nexti=1;
uint32 error_occurred=0;
uint32 new_error=0;
uint32 bkp_new_error=0;
qbs* nothingstring;
uint32 qbevent=0;
uint8 suspend_program=0;

View file

@ -700,6 +700,7 @@ FUNCTION ide2 (ignore)
SELECT CASE IdeDebugMode
CASE 1
IdeDebugMode = 0
idefocusline = 0
END SELECT
COLOR 0, 7: _PRINTSTRING (1, 1), menubar$
IF idesubwindow <> 0 THEN _RESIZE OFF ELSE _RESIZE ON
@ -6285,6 +6286,7 @@ SUB DebugMode
CASE "breakpoint", "line number"
l = CVL(value$)
idecy = l
idefocusline = 0
ideshowtext
clearStatusWindow 1
IF cmd$ = "breakpoint" THEN
@ -6297,18 +6299,22 @@ SUB DebugMode
CLOSE #client&
dummy = DarkenFGBG(0)
clearStatusWindow 0
setStatusMessage 1, "Debug session aborted.", 7
setStatusMessage 1, "Debug session aborted.", 15
IF LEN(value$) THEN
setStatusMessage 2, value$, 7
END IF
WHILE _MOUSEINPUT: WEND
_KEYCLEAR
EXIT SUB
CASE "error"
clearStatusWindow 0
setStatusMessage 1, "Debug session aborted.", 7
IF value$ = "" THEN
setStatusMessage 2, "Communication error.", 2
ELSE
setStatusMessage 2, LEFT$(value$, idewx - 2), 2
END IF
l = CVL(value$)
idecy = l
idefocusline = l
ideshowtext
clearStatusWindow 1
COLOR , 4
setStatusMessage 1, "Error occurred on line" + STR$(l), 13
PauseMode = -1
END SELECT
_LIMIT 100
@ -8567,7 +8573,7 @@ SUB ideshowtext
GOSUB ShowLineNumber
IF l = idefocusline AND idecy <> l THEN
IF (l = idefocusline AND idecy <> l AND IdeDebugMode = 0) OR (l = idefocusline AND idecy = l AND IdeDebugMode <> 0) THEN
COLOR 7, 4 'Line with error gets a red background
ELSEIF idecy = l OR (l >= idecy_multilinestart AND l <= idecy_multilineend) THEN
IF HideCurrentLineHighlight = 0 AND IdeSystem = 1 THEN COLOR 7, 6 'Highlight the current line

View file

@ -26,7 +26,9 @@ REDIM SHARED PL(1000) AS INTEGER 'Priority Level
REDIM SHARED PP_TypeMod(0) AS STRING, PP_ConvertedMod(0) AS STRING 'Prepass Name Conversion variables.
Set_OrderOfOperations
DIM SHARED vWatchOn, vWatchRecompileAttempts, vWatchDesiredState
DIM SHARED vWatchOn, vWatchRecompileAttempts, vWatchDesiredState, vWatchErrorCall$
vWatchErrorCall$ = "if(new_error){bkp_new_error=new_error;new_error=0;*__LONG_VWATCH_LINENUMBER=-1; SUB_VWATCH((ptrszint*)vwatch_local_vars);new_error=bkp_new_error;};"
DIM SHARED qb64prefix_set_recompileAttempts, qb64prefix_set_desiredState
DIM SHARED opex_recompileAttempts, opex_desiredState
DIM SHARED opexarray_recompileAttempts, opexarray_desiredState
@ -3423,7 +3425,8 @@ DO
inclinenump$ = inclinenump$ + "," + CHR$(34) + thisincname$ + CHR$(34)
END IF
IF NoChecks = 0 THEN
PRINT #12, "if(qbevent){evnt(" + str2$(linenumber) + inclinenump$ + ");r=0;}"
IF vWatchOn THEN temp$ = vWatchErrorCall$ ELSE temp$ = ""
PRINT #12, "if(qbevent){" + temp$ + "evnt(" + str2$(linenumber) + inclinenump$ + ");r=0;}"
END IF
IF n = 1 THEN GOTO finishednonexec
entireline$ = getelements(entireline$, 2, n): u$ = UCASE$(entireline$): n = n - 1
@ -3483,7 +3486,8 @@ DO
inclinenump$ = inclinenump$ + "," + CHR$(34) + thisincname$ + CHR$(34)
END IF
IF NoChecks = 0 THEN
PRINT #12, "if(qbevent){evnt(" + str2$(linenumber) + inclinenump$ + ");r=0;}"
IF vWatchOn THEN temp$ = vWatchErrorCall$ ELSE temp$ = ""
PRINT #12, "if(qbevent){" + temp$ + "evnt(" + str2$(linenumber) + inclinenump$ + ");r=0;}"
END IF
entireline$ = RIGHT$(entireline$, LEN(entireline$) - x3): u$ = UCASE$(entireline$)
n = numelements(entireline$): IF n = 0 THEN GOTO finishednonexec
@ -8782,7 +8786,8 @@ DO
thisincname$ = MID$(incname$(inclevel), LEN(thisincname$) + 1)
inclinenump$ = inclinenump$ + "," + CHR$(34) + thisincname$ + CHR$(34)
END IF
PRINT #12, "if(qbevent){evnt(" + str2$(linenumber) + inclinenump$ + ");}" 'non-resumable error check (cannot exit without handling errors)
IF vWatchOn THEN temp$ = vWatchErrorCall$ ELSE temp$ = ""
PRINT #12, "if(qbevent){" + temp$ + "evnt(" + str2$(linenumber) + inclinenump$ + ");}" 'non-resumable error check (cannot exit without handling errors)
PRINT #12, "exit_code=" + e$ + ";"
l$ = l$ + sp + l2$
END IF
@ -8805,7 +8810,8 @@ DO
thisincname$ = MID$(incname$(inclevel), LEN(thisincname$) + 1)
inclinenump$ = inclinenump$ + "," + CHR$(34) + thisincname$ + CHR$(34)
END IF
PRINT #12, "if(qbevent){evnt(" + str2$(linenumber) + inclinenump$ + ");}" 'non-resumable error check (cannot exit without handling errors)
IF vWatchOn = 1 AND NoChecks = 0 THEN temp$ = vWatchErrorCall$ ELSE temp$ = ""
PRINT #12, "if(qbevent){" + temp$ + "evnt(" + str2$(linenumber) + inclinenump$ + ");}" 'non-resumable error check (cannot exit without handling errors)
PRINT #12, "exit_code=" + e$ + ";"
l$ = l$ + sp + l2$
END IF
@ -11086,11 +11092,12 @@ DO
inclinenump$ = inclinenump$ + "," + CHR$(34) + thisincname$ + CHR$(34)
END IF
IF NoChecks = 0 THEN
IF vWatchOn THEN temp$ = vWatchErrorCall$ ELSE temp$ = ""
IF dynscope THEN
dynscope = 0
PRINT #12, "if(qbevent){evnt(" + str2$(linenumber) + inclinenump$ + ");if(r)goto S_" + str2$(statementn) + ";}"
PRINT #12, "if(qbevent){" + temp$ + "evnt(" + str2$(linenumber) + inclinenump$ + ");if(r)goto S_" + str2$(statementn) + ";}"
ELSE
PRINT #12, "if(!qbevent)break;evnt(" + str2$(linenumber) + inclinenump$ + ");}while(r);"
PRINT #12, "if(!qbevent)break;" + temp$ + "evnt(" + str2$(linenumber) + inclinenump$ + ");}while(r);"
END IF
END IF
@ -11609,6 +11616,12 @@ ELSE
PRINT #18, "int32 asserts=0;"
END IF
IF vWatchOn THEN
PRINT #18, "int32 vwatch=1;"
ELSE
PRINT #18, "int32 vwatch=0;"
END IF
fh = FREEFILE
OPEN tmpdir$ + "dyninfo.txt" FOR APPEND AS #fh
IF Resize THEN

View file

@ -42,7 +42,7 @@ SUB vwatch (localVariables AS _OFFSET)
breakpointCount = CVL(value$)
CASE "breakpoint list"
IF LEN(value$) \ 4 <> breakpointCount THEN
cmd$ = "error"
cmd$ = "quit:Communication error."
GOSUB SendCommand
CLOSE #ide
bypass = -1
@ -63,18 +63,23 @@ SUB vwatch (localVariables AS _OFFSET)
LOOP
END IF
IF vwatch_linenumber = lastLine THEN EXIT SUB
lastLine = vwatch_linenumber
IF vwatch_linenumber = 0 THEN
cmd$ = "quit"
cmd$ = "quit:Program ended."
GOSUB SendCommand
CLOSE #ide
bypass = -1
ide = 0
EXIT SUB
ELSEIF vwatch_linenumber = -1 THEN
'report an error in the most recent line
cmd$ = "error:" + MKL$(lastLine)
GOSUB SendCommand
EXIT SUB
END IF
IF vwatch_linenumber = lastLine THEN EXIT SUB
lastLine = vwatch_linenumber
GOSUB GetCommand
SELECT CASE cmd$
CASE "break"