From 655f1e3b19d7844e82ea9216484f8a7a796d86c6 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Mon, 19 Jul 2021 22:25:15 -0300 Subject: [PATCH] Sends call stack to IDE when an error occurs. --- source/ide/ide_methods.bas | 7 ++++++- source/utilities/vwatch/vwatch.bm | 18 ++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 42a8cdc8d..90785e722 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -6428,6 +6428,7 @@ SUB DebugMode cmd$ = "call stack" GOSUB SendCommand + IF BypassRequestCallStack THEN GOTO ShowCallStack dummy = DarkenFGBG(0) clearStatusWindow 0 setStatusMessage 1, "Requesting call stack...", 7 @@ -6443,6 +6444,7 @@ SUB DebugMode IF cmd$ = "call stack" THEN 'display call stack callstacklist$ = value$ + ShowCallStack: retval = idecallstackbox PCOPY 3, 0: SCREEN , , 3, 0 clearStatusWindow 0 @@ -6510,6 +6512,7 @@ SUB DebugMode SELECT CASE cmd$ CASE "breakpoint", "line number" + BypassRequestCallStack = 0 l = CVL(value$) idecy = l debugnextline = l @@ -6542,10 +6545,12 @@ SUB DebugMode clearStatusWindow 1 COLOR , 4 setStatusMessage 1, "Error occurred on line" + STR$(l), 13 + BypassRequestCallStack = -1 PauseMode = -1 CASE "call stack size" 'call stack is only received without having been - 'requested when the program is about to quit + 'requested when the program is about to quit or + 'when an error just occurred callStackLength = CVL(value$) start! = TIMER DO diff --git a/source/utilities/vwatch/vwatch.bm b/source/utilities/vwatch/vwatch.bm index 1bbc5e785..04ed1f1fe 100644 --- a/source/utilities/vwatch/vwatch.bm +++ b/source/utilities/vwatch/vwatch.bm @@ -65,10 +65,7 @@ SUB vwatch (localVariables AS _OFFSET) END IF IF vwatch_linenumber = 0 THEN - cmd$ = "call stack size:" + MKL$(callStackLength) - GOSUB SendCommand - cmd$ = "call stack:" + vwatch_callstack - GOSUB SendCommand + GOSUB SendCallStack cmd$ = "quit:Program ended." GOSUB SendCommand CLOSE #ide @@ -77,6 +74,7 @@ SUB vwatch (localVariables AS _OFFSET) EXIT SUB ELSEIF vwatch_linenumber = -1 THEN 'report an error in the most recent line + GOSUB SendCallStack cmd$ = "error:" + MKL$(lastLine) GOSUB SendCommand EXIT SUB @@ -168,10 +166,7 @@ SUB vwatch (localVariables AS _OFFSET) REDIM vwatch_breakpoints(UBOUND(vwatch_breakpoints)) AS _BYTE CASE "call stack" 'send call stack history" - cmd$ = "call stack size:" + MKL$(callStackLength) - GOSUB SendCommand - cmd$ = "call stack:" + vwatch_callstack - GOSUB SendCommand + GOSUB SendCallStack CASE "local" i = CVL(value$) address = localVariables + LEN(address) * i @@ -217,6 +212,13 @@ SUB vwatch (localVariables AS _OFFSET) END IF RETURN + SendCallStack: + cmd$ = "call stack size:" + MKL$(callStackLength) + GOSUB SendCommand + cmd$ = "call stack:" + vwatch_callstack + GOSUB SendCommand + RETURN + SendCommand: cmd$ = cmd$ + endc$ PUT #ide, , cmd$