From 7ba11565a5980a304258c0c8370d5ccff6fd7542 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Fri, 3 Sep 2021 00:03:28 -0300 Subject: [PATCH 1/9] Adds GetBytes so it's easier to add data to the packet ($DEBUG). --- internal/c/qbx.cpp | 8 +- internal/support/vwatch/vwatch.bm | 120 ++++++++++++++++-------------- 2 files changed, 69 insertions(+), 59 deletions(-) diff --git a/internal/c/qbx.cpp b/internal/c/qbx.cpp index fba71478f..08062bc35 100755 --- a/internal/c/qbx.cpp +++ b/internal/c/qbx.cpp @@ -941,12 +941,12 @@ inline int16 func_abs(int16 d){return abs(d);} inline int32 func_abs(int32 d){return abs(d);} inline int64 func_abs(int64 d){return llabs(d);} -ptrszint check_lbound(ptrszint *array) { - return func_lbound((ptrszint*)(*array),1,1); +ptrszint check_lbound(ptrszint *array,int32 index, int32 num_indexes) { + return func_lbound((ptrszint*)(*array),index,num_indexes); } -ptrszint check_ubound(ptrszint *array) { - return func_ubound((ptrszint*)(*array),1,1); +ptrszint check_ubound(ptrszint *array,int32 index, int32 num_indexes) { + return func_ubound((ptrszint*)(*array),index,num_indexes); } inline ptrszint array_check(uptrszint index,uptrszint limit){ diff --git a/internal/support/vwatch/vwatch.bm b/internal/support/vwatch/vwatch.bm index 8bb7c50b2..0d3314ab8 100644 --- a/internal/support/vwatch/vwatch.bm +++ b/internal/support/vwatch/vwatch.bm @@ -3,16 +3,17 @@ $CHECKING:OFF SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) STATIC AS LONG vw_ideHost, vw_breakpointCount, vw_skipCount, vw_timeout, vw_startLevel, vw_lastLine STATIC AS LONG vw_runToLine, vw_arrayIndex, vw_originalVarLineNumber - STATIC AS _BYTE vw_pauseMode, vw_stepOver, vw_bypass, vw_setNextLine, vw_hwndsent - STATIC AS _OFFSET vw_idehwnd + STATIC AS _BYTE vw_pauseMode, vw_stepOver, vw_bypass, vw_setNextLine, vw_hwndSent + STATIC AS _OFFSET vw_ideHwnd STATIC vw_buffer$ - DIM AS LONG vw_i, vw_tempIndex, vw_localIndex, vw_varSize, vw_cmdsize - DIM AS LONG vw_arrayelementsize, vw_element, vw_elementoffset, vw_storage - DIM AS _OFFSET vw_address, vw_lbound, vw_ubound + DIM AS LONG vw_i, vw_tempIndex, vw_localIndex, vw_varSize, vw_cmdSize + DIM AS LONG vw_arrayElementSize, vw_element, vw_elementOffset, vw_storage + DIM AS LONG vw_arrayDimension, vw_arrayTotalDimensions + DIM AS _OFFSET vw_address, vw_lBound, vw_uBound DIM AS _MEM vw_m, vw_m2 - DIM AS _BYTE vw_isarray, vw_isUDT + DIM AS _BYTE vw_isArray, vw_isUDT DIM vw_start!, vw_temp$, vw_cmd$, vw_value$, vw_k&, vw_buf$, vw_scope$, vw_varType$ - DIM vw_dummy%& + DIM vw_prevValue$, vw_getBytes&, vw_getBytesPosition&, vw_valueBytes$, vw_dummy%& DECLARE LIBRARY SUB vwatch_stoptimers ALIAS stop_timers @@ -20,8 +21,8 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) SUB unlockvWatchHandle SUB set_qbs_size (target AS _OFFSET, BYVAL length&) FUNCTION stop_program_state& - FUNCTION check_lbound%& (array AS _OFFSET) - FUNCTION check_ubound%& (array AS _OFFSET) + FUNCTION check_lbound%& (array AS _OFFSET, BYVAL index AS LONG, BYVAL num_indexes AS LONG) + FUNCTION check_ubound%& (array AS _OFFSET, BYVAL index AS LONG, BYVAL num_indexes AS LONG) END DECLARE $IF WIN THEN @@ -44,7 +45,7 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) vw_cmd$ = "me:" + COMMAND$(0) GOSUB SendCommand IF _WINDOWHANDLE THEN - vw_hwndsent = -1 + vw_hwndSent = -1 vw_cmd$ = "hwnd:" + _MK$(_OFFSET, _WINDOWHANDLE) GOSUB SendCommand END IF @@ -76,7 +77,7 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) vwatch_breakpoints(CVL(vw_temp$)) = -1 NEXT CASE "hwnd" - vw_idehwnd = _CV(_OFFSET, vw_value$) + vw_ideHwnd = _CV(_OFFSET, vw_value$) CASE "skip count" vw_skipCount = CVL(vw_value$) CASE "skip list" @@ -102,9 +103,9 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) LOOP END IF - IF vw_hwndsent = 0 THEN + IF vw_hwndSent = 0 THEN IF _WINDOWHANDLE > 0 THEN - vw_hwndsent = -1 + vw_hwndSent = -1 vw_cmd$ = "hwnd:" + _MK$(_OFFSET, _WINDOWHANDLE) GOSUB SendCommand END IF @@ -204,7 +205,7 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) GOSUB SendCommand $IF WIN THEN - vw_i = SetForegroundWindow&(vw_idehwnd) + vw_i = SetForegroundWindow&(vw_ideHwnd) $END IF DO 'main loop @@ -256,23 +257,23 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) 'send call stack history GOSUB SendCallStack CASE "get global var", "get local var" - vw_tempIndex = CVL(LEFT$(vw_value$, 4)) - vw_isarray = _CV(_BYTE, MID$(vw_value$, 5, 1)) - vw_originalVarLineNumber = CVL(MID$(vw_value$, 6, 4)) - vw_localIndex = CVL(MID$(vw_value$, 10, 4)) - vw_arrayIndex = CVL(MID$(vw_value$, 14, 4)) - vw_arrayelementsize = CVL(MID$(vw_value$, 18, 4)) - vw_element = CVL(MID$(vw_value$, 22, 4)) - vw_elementoffset = CVL(MID$(vw_value$, 26, 4)) - vw_varSize = CVL(MID$(vw_value$, 30, 4)) + vw_getBytes& = 4: GOSUB GetBytes: vw_tempIndex = CVL(vw_valueBytes$) + vw_getBytes& = 1: GOSUB GetBytes: vw_isArray = _CV(_BYTE, vw_valueBytes$) + vw_getBytes& = 4: GOSUB GetBytes: vw_originalVarLineNumber = CVL(vw_valueBytes$) + vw_getBytes& = 4: GOSUB GetBytes: vw_localIndex = CVL(vw_valueBytes$) + vw_getBytes& = 4: GOSUB GetBytes: vw_arrayIndex = CVL(vw_valueBytes$) + vw_getBytes& = 4: GOSUB GetBytes: vw_arrayElementSize = CVL(vw_valueBytes$) + vw_getBytes& = 4: GOSUB GetBytes: vw_element = CVL(vw_valueBytes$) + vw_getBytes& = 4: GOSUB GetBytes: vw_elementOffset = CVL(vw_valueBytes$) + vw_getBytes& = 4: GOSUB GetBytes: vw_varSize = CVL(vw_valueBytes$) IF vw_varSize = 0 THEN GOTO cmdProcessingDone - vw_storage = CVL(MID$(vw_value$, 34, 4)) - vw_i = CVI(MID$(vw_value$, 38, 2)) + vw_getBytes& = 4: GOSUB GetBytes: vw_storage = CVL(vw_valueBytes$) + vw_getBytes& = 2: GOSUB GetBytes: vw_i = CVI(vw_valueBytes$) IF vw_i THEN - vw_scope$ = MID$(vw_value$, 40, vw_i) + vw_getBytes& = vw_i: GOSUB GetBytes: vw_scope$ = vw_valueBytes$ END IF - vw_i = CVI(MID$(vw_value$, 40 + vw_i, 2)) - vw_varType$ = RIGHT$(vw_value$, vw_i) + vw_getBytes& = 2: GOSUB GetBytes: vw_i = CVI(vw_valueBytes$) + vw_getBytes& = vw_i: GOSUB GetBytes: vw_varType$ = vw_valueBytes$ IF vw_cmd$ = "get global var" THEN vw_address = _OFFSET(globalVariables) + LEN(vw_address) * vw_localIndex @@ -287,15 +288,15 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) vw_address = _MEMGET(vw_m, vw_address, _OFFSET) 'first resolve pass vw_address = _MEMGET(vw_m, vw_address, _OFFSET) 'second resolve pass - IF vw_isarray THEN + IF vw_isArray THEN IF vw_originalVarLineNumber > 0 THEN 'prevent fetching array data before DIM line IF vwatch_linenumber <= vw_originalVarLineNumber THEN GOTO cmdProcessingDone END IF - vw_lbound = check_lbound%&(vw_address) - vw_ubound = check_ubound%&(vw_address) + vw_lBound = check_lbound%&(vw_address, vw_arrayDimension, vw_arrayTotalDimensions) + vw_uBound = check_ubound%&(vw_address, vw_arrayDimension, vw_arrayTotalDimensions) - IF vw_arrayIndex < vw_lbound OR vw_arrayIndex > vw_ubound THEN + IF vw_arrayIndex < vw_lBound OR vw_arrayIndex > vw_uBound THEN GOTO cmdProcessingDone END IF @@ -319,24 +320,24 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) vw_varSize = LEN(vw_dummy%&) END IF 'this is where we calculate the actual array index position in memory - IF vw_arrayelementsize = 0 THEN - vw_address = vw_address + ((vw_arrayIndex - vw_lbound) * vw_varSize) + IF vw_arrayElementSize = 0 THEN + vw_address = vw_address + ((vw_arrayIndex - vw_lBound) * vw_varSize) ELSE - vw_address = vw_address + ((vw_arrayIndex - vw_lbound) * vw_arrayelementsize) + vw_address = vw_address + ((vw_arrayIndex - vw_lBound) * vw_arrayElementSize) END IF END IF 'vw_address now points to the actual data - vw_address = vw_address + vw_elementoffset + vw_address = vw_address + vw_elementOffset vw_buf$ = SPACE$(vw_varSize) vw_m = _MEM(vw_address, vw_varSize) vw_m2 = _MEM(_OFFSET(vw_buf$), vw_varSize) _MEMCOPY vw_m, vw_m.OFFSET, vw_m.SIZE TO vw_m2, vw_m2.OFFSET - IF INSTR(vw_varType$, "STRING *") > 0 AND (vw_isarray <> 0 OR vw_element > 0) THEN + IF INSTR(vw_varType$, "STRING *") > 0 AND (vw_isArray <> 0 OR vw_element > 0) THEN 'actual data already fetched; nothing else to do ELSEIF INSTR(vw_varType$, "STRING") > 0 THEN - IF vw_isarray <> 0 OR vw_element > 0 THEN + IF vw_isArray <> 0 OR vw_element > 0 THEN 'First pass vw_varSize = LEN(vw_dummy%&) vw_buf$ = SPACE$(vw_varSize) @@ -377,11 +378,11 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) GOSUB SendCommand CASE "set global address", "set local address" vw_localIndex = CVL(LEFT$(vw_value$, 4)) - vw_isarray = (CVL(MID$(vw_value$, 5, 4)) <> 0) + vw_isArray = (CVL(MID$(vw_value$, 5, 4)) <> 0) vw_arrayIndex = CVL(MID$(vw_value$, 9, 4)) vw_isUDT = (CVL(MID$(vw_value$, 13, 4)) <> 0) - vw_elementoffset = CVL(MID$(vw_value$, 17, 4)) - vw_arrayelementsize = CVL(MID$(vw_value$, 21, 4)) + vw_elementOffset = CVL(MID$(vw_value$, 17, 4)) + vw_arrayElementSize = CVL(MID$(vw_value$, 21, 4)) vw_varSize = CVL(MID$(vw_value$, 25, 4)) vw_i = CVI(MID$(vw_value$, 29, 2)) vw_varType$ = MID$(vw_value$, 31, vw_i) @@ -397,11 +398,11 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) vw_address = _MEMGET(vw_m, vw_address, _OFFSET) 'second resolve pass '-------- - IF vw_isarray THEN - vw_lbound = check_lbound%&(vw_address) - vw_ubound = check_ubound%&(vw_address) + IF vw_isArray THEN + vw_lBound = check_lbound%&(vw_address, vw_arrayDimension, vw_arrayTotalDimensions) + vw_uBound = check_ubound%&(vw_address, vw_arrayDimension, vw_arrayTotalDimensions) - IF vw_arrayIndex < vw_lbound OR vw_arrayIndex > vw_ubound THEN + IF vw_arrayIndex < vw_lBound OR vw_arrayIndex > vw_uBound THEN GOTO cmdProcessingDone END IF @@ -426,10 +427,10 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) END IF 'this is where we calculate the actual array index position in memory - IF vw_arrayelementsize = 0 THEN - vw_address = vw_address + ((vw_arrayIndex - vw_lbound) * vw_varSize) + IF vw_arrayElementSize = 0 THEN + vw_address = vw_address + ((vw_arrayIndex - vw_lBound) * vw_varSize) ELSE - vw_address = vw_address + ((vw_arrayIndex - vw_lbound) * vw_arrayelementsize) + vw_address = vw_address + ((vw_arrayIndex - vw_lBound) * vw_arrayElementSize) END IF ELSE IF vw_isUDT = 0 THEN @@ -458,12 +459,12 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) END IF 'if it's a UDT, move the pointer to this element's offset - vw_address = vw_address + vw_elementoffset + vw_address = vw_address + vw_elementOffset - IF INSTR(vw_varType$, "STRING *") > 0 AND (vw_isarray <> 0 OR vw_isUDT <> 0) THEN + IF INSTR(vw_varType$, "STRING *") > 0 AND (vw_isArray <> 0 OR vw_isUDT <> 0) THEN vw_value$ = LEFT$(vw_value$ + SPACE$(vw_varSize), vw_varSize) ELSEIF INSTR(vw_varType$, "STRING") > 0 THEN - IF vw_isarray <> 0 OR vw_isUDT <> 0 THEN + IF vw_isArray <> 0 OR vw_isUDT <> 0 THEN 'First pass vw_varSize = LEN(vw_dummy%&) vw_buf$ = SPACE$(vw_varSize) @@ -523,10 +524,10 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) GET #vw_ideHost, , vw_temp$ vw_buffer$ = vw_buffer$ + vw_temp$ - IF LEN(vw_buffer$) >= 4 THEN vw_cmdsize = CVL(LEFT$(vw_buffer$, 4)) ELSE vw_cmdsize = 0 - IF vw_cmdsize > 0 AND LEN(vw_buffer$) >= vw_cmdsize THEN - vw_cmd$ = MID$(vw_buffer$, 5, vw_cmdsize) - vw_buffer$ = MID$(vw_buffer$, 5 + vw_cmdsize) + IF LEN(vw_buffer$) >= 4 THEN vw_cmdSize = CVL(LEFT$(vw_buffer$, 4)) ELSE vw_cmdSize = 0 + IF vw_cmdSize > 0 AND LEN(vw_buffer$) >= vw_cmdSize THEN + vw_cmd$ = MID$(vw_buffer$, 5, vw_cmdSize) + vw_buffer$ = MID$(vw_buffer$, 5 + vw_cmdSize) IF INSTR(vw_cmd$, ":") THEN vw_value$ = MID$(vw_cmd$, INSTR(vw_cmd$, ":") + 1) @@ -559,4 +560,13 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) PUT #vw_ideHost, , vw_cmd$ vw_cmd$ = "" RETURN + + GetBytes: + IF vw_value$ <> vw_prevValue$ THEN + vw_prevValue$ = vw_value$ + vw_getBytesPosition& = 1 + END IF + vw_valueBytes$ = MID$(vw_value$, vw_getBytesPosition&, vw_getBytes&) + vw_getBytesPosition& = vw_getBytesPosition& + vw_getBytes& + RETURN END SUB From a37e3801d8675ae16ef8f42ab06622dea8d1e5c3 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Wed, 8 Sep 2021 22:47:31 -0300 Subject: [PATCH 2/9] Adds support to watching arrays with multiple dimensions. --- internal/support/vwatch/vwatch.bm | 37 +++++-- source/ide/ide_methods.bas | 177 +++++++++++++++++++++++------- 2 files changed, 163 insertions(+), 51 deletions(-) diff --git a/internal/support/vwatch/vwatch.bm b/internal/support/vwatch/vwatch.bm index 0d3314ab8..36efc6bed 100644 --- a/internal/support/vwatch/vwatch.bm +++ b/internal/support/vwatch/vwatch.bm @@ -2,18 +2,19 @@ $CHECKING:OFF SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) STATIC AS LONG vw_ideHost, vw_breakpointCount, vw_skipCount, vw_timeout, vw_startLevel, vw_lastLine - STATIC AS LONG vw_runToLine, vw_arrayIndex, vw_originalVarLineNumber + STATIC AS LONG vw_runToLine, vw_originalVarLineNumber STATIC AS _BYTE vw_pauseMode, vw_stepOver, vw_bypass, vw_setNextLine, vw_hwndSent STATIC AS _OFFSET vw_ideHwnd STATIC vw_buffer$ DIM AS LONG vw_i, vw_tempIndex, vw_localIndex, vw_varSize, vw_cmdSize - DIM AS LONG vw_arrayElementSize, vw_element, vw_elementOffset, vw_storage - DIM AS LONG vw_arrayDimension, vw_arrayTotalDimensions + DIM AS LONG vw_arrayElementSize, vw_element, vw_elementOffset, vw_storage, vw_blockSize + DIM AS LONG vw_arrayDimension, vw_arrayTotalDimensions, vw_arrayIndex, vw_realArrayIndex DIM AS _OFFSET vw_address, vw_lBound, vw_uBound DIM AS _MEM vw_m, vw_m2 DIM AS _BYTE vw_isArray, vw_isUDT DIM vw_start!, vw_temp$, vw_cmd$, vw_value$, vw_k&, vw_buf$, vw_scope$, vw_varType$ DIM vw_prevValue$, vw_getBytes&, vw_getBytesPosition&, vw_valueBytes$, vw_dummy%& + DIM vw_arrayIndexes$ DECLARE LIBRARY SUB vwatch_stoptimers ALIAS stop_timers @@ -261,7 +262,9 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) vw_getBytes& = 1: GOSUB GetBytes: vw_isArray = _CV(_BYTE, vw_valueBytes$) vw_getBytes& = 4: GOSUB GetBytes: vw_originalVarLineNumber = CVL(vw_valueBytes$) vw_getBytes& = 4: GOSUB GetBytes: vw_localIndex = CVL(vw_valueBytes$) - vw_getBytes& = 4: GOSUB GetBytes: vw_arrayIndex = CVL(vw_valueBytes$) + vw_getBytes& = 4: GOSUB GetBytes: vw_arrayTotalDimensions = CVL(vw_valueBytes$) + vw_getBytes& = vw_arrayTotalDimensions: GOSUB GetBytes: vw_arrayIndexes$ = vw_valueBytes$ + vw_arrayTotalDimensions = vw_arrayTotalDimensions \ 4 vw_getBytes& = 4: GOSUB GetBytes: vw_arrayElementSize = CVL(vw_valueBytes$) vw_getBytes& = 4: GOSUB GetBytes: vw_element = CVL(vw_valueBytes$) vw_getBytes& = 4: GOSUB GetBytes: vw_elementOffset = CVL(vw_valueBytes$) @@ -293,12 +296,22 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) 'prevent fetching array data before DIM line IF vwatch_linenumber <= vw_originalVarLineNumber THEN GOTO cmdProcessingDone END IF - vw_lBound = check_lbound%&(vw_address, vw_arrayDimension, vw_arrayTotalDimensions) - vw_uBound = check_ubound%&(vw_address, vw_arrayDimension, vw_arrayTotalDimensions) - IF vw_arrayIndex < vw_lBound OR vw_arrayIndex > vw_uBound THEN - GOTO cmdProcessingDone - END IF + vw_realArrayIndex = 0 + vw_blockSize = 1 + + FOR vw_arrayDimension = 1 TO vw_arrayTotalDimensions + vw_lBound = check_lbound%&(vw_address, vw_arrayDimension, vw_arrayTotalDimensions) + vw_uBound = check_ubound%&(vw_address, vw_arrayDimension, vw_arrayTotalDimensions) + vw_arrayIndex = CVL(MID$(vw_arrayIndexes$, vw_arrayDimension * 4 - 3, 4)) + IF vw_arrayIndex < vw_lBound OR vw_arrayIndex > vw_uBound THEN + GOTO cmdProcessingDone + END IF + + vw_arrayIndex = (vw_arrayIndex - VAL(STR$(vw_lBound))) * vw_blockSize + vw_realArrayIndex = vw_realArrayIndex + vw_arrayIndex + vw_blockSize = vw_blockSize * VAL(STR$(vw_uBound - vw_lBound + 1)) + NEXT 'get the address of where this array's data is stored vw_buf$ = SPACE$(LEN(vw_dummy%&)) @@ -321,9 +334,9 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) END IF 'this is where we calculate the actual array index position in memory IF vw_arrayElementSize = 0 THEN - vw_address = vw_address + ((vw_arrayIndex - vw_lBound) * vw_varSize) + vw_address = vw_address + (vw_realArrayIndex * vw_varSize) ELSE - vw_address = vw_address + ((vw_arrayIndex - vw_lBound) * vw_arrayElementSize) + vw_address = vw_address + (vw_realArrayIndex * vw_arrayElementSize) END IF END IF @@ -538,6 +551,7 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) ELSE vw_cmd$ = "": vw_value$ = "" END IF + vw_prevValue$ = "" RETURN SendCallStack: @@ -566,6 +580,7 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) vw_prevValue$ = vw_value$ vw_getBytesPosition& = 1 END IF + IF vw_getBytes& = 0 THEN vw_valueBytes$ = "": RETURN vw_valueBytes$ = MID$(vw_value$, vw_getBytesPosition&, vw_getBytes&) vw_getBytesPosition& = vw_getBytesPosition& + vw_getBytes& RETURN diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 60ccafa3f..c158d42b2 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -7399,14 +7399,20 @@ SUB DebugMode 'request variables addresses IF LEN(variableWatchList$) THEN requestVariableValues: - temp$ = MID$(variableWatchList$, 9) - DO WHILE LEN(temp$) - tempIndex& = CVL(LEFT$(temp$, 4)) - tempArrayIndex& = CVL(MID$(temp$, 5, 4)) - tempElement& = CVL(MID$(temp$, 9, 4)) - tempElementOffset& = CVL(MID$(temp$, 13, 4)) - tempStorage& = CVL(MID$(temp$, 17, 4)) - temp$ = MID$(temp$, 25) + temp$ = GetBytes$("", 0) 'reset buffer + temp$ = MID$(variableWatchList$, 9) 'skip longest var name and total visible vars + DO + temp2$ = GetBytes$(temp$, 4) + IF temp2$ <> MKL$(-1) THEN EXIT DO 'no more variables in list + tempIndex& = CVL(GetBytes$(temp$, 4)) + tempArrayIndexes$ = GetBytes$(temp$, 4) + i = CVL(tempArrayIndexes$) + IF i > 0 THEN + tempArrayIndexes$ = tempArrayIndexes$ + GetBytes$(temp$, i) + END IF + tempElement& = CVL(GetBytes$(temp$, 4)) + tempElementOffset& = CVL(GetBytes$(temp$, 4)) + tempStorage& = CVL(GetBytes$(temp$, 4)) IF LEN(usedVariableList(tempIndex&).subfunc) = 0 THEN cmd$ = "get global var:" ELSE @@ -7418,7 +7424,7 @@ SUB DebugMode cmd$ = cmd$ + _MK$(_BYTE, usedVariableList(tempIndex&).isarray) cmd$ = cmd$ + MKL$(usedVariableList(tempIndex&).linenumber) cmd$ = cmd$ + MKL$(usedVariableList(tempIndex&).localIndex) - cmd$ = cmd$ + MKL$(tempArrayIndex&) + cmd$ = cmd$ + tempArrayIndexes$ cmd$ = cmd$ + MKL$(usedVariableList(tempIndex&).arrayElementSize) cmd$ = cmd$ + MKL$(tempElement&) IF tempElement& THEN @@ -7662,7 +7668,7 @@ SUB showvWatchPanel (this AS vWatchPanelType, currentScope$, totalVisibleVariabl 'new setup previousVariableWatchList$ = variableWatchList$ longestVarName = CVL(LEFT$(variableWatchList$, 4)) - totalVisibleVariables = (LEN(variableWatchList$) - 4) \ 20 + totalVisibleVariables = CVL(MID$(variableWatchList$, 5, 4)) this.h = totalVisibleVariables + 2 IF this.h > idewy - 10 THEN this.h = idewy - 10 IF this.h < 5 THEN this.h = 5 @@ -7697,14 +7703,18 @@ SUB showvWatchPanel (this AS vWatchPanelType, currentScope$, totalVisibleVariabl i = 0 this.contentWidth = 0 IF this.hPos = 0 THEN this.hPos = 1 + temp$ = GetBytes$("", 0) 'reset buffer temp$ = MID$(variableWatchList$, 9) - DO WHILE LEN(temp$) - tempIndex& = CVL(LEFT$(temp$, 4)) - tempArrayIndex& = CVL(MID$(temp$, 5, 4)) - tempElement& = CVL(MID$(temp$, 9, 4)) - tempElementOffset& = CVL(MID$(temp$, 13, 4)) - tempStorage& = CVL(MID$(temp$, 17, 4)) - temp$ = MID$(temp$, 25) + DO + temp2$ = GetBytes$(temp$, 4) + IF temp2$ <> MKL$(-1) THEN EXIT DO 'no more variables in list + tempIndex& = CVL(GetBytes$(temp$, 4)) + tempTotalArrayIndexes& = CVL(GetBytes$(temp$, 4)) + tempArrayIndexes$ = GetBytes$(temp$, tempTotalArrayIndexes&) + tempElement& = CVL(GetBytes$(temp$, 4)) + tempElementOffset& = CVL(GetBytes$(temp$, 4)) + tempStorage& = CVL(GetBytes$(temp$, 4)) + i = i + 1 IF this.firstVisible > i AND WatchListToConsole = 0 THEN _CONTINUE y = y + 1 @@ -7712,8 +7722,13 @@ SUB showvWatchPanel (this AS vWatchPanelType, currentScope$, totalVisibleVariabl thisName$ = usedVariableList(tempIndex&).name IF usedVariableList(tempIndex&).isarray THEN - thisName$ = LEFT$(thisName$, LEN(thisName$) - 1) + _ - LTRIM$(STR$(tempArrayIndex&)) + ")" + thisName$ = LEFT$(thisName$, LEN(thisName$) - 1) + tempTotalArrayIndexes& = tempTotalArrayIndexes& \ 4 + FOR j = 1 TO tempTotalArrayIndexes& + thisName$ = thisName$ + LTRIM$(STR$(CVL(MID$(tempArrayIndexes$, j * 4 - 3, 4)))) + IF j < tempTotalArrayIndexes& THEN thisName$ = thisName$ + ", " + NEXT + thisName$ = thisName$ + ")" END IF IF tempElement& THEN tempElementList$ = MID$(usedVariableList(tempIndex&).elements, 5) @@ -8199,12 +8214,13 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction) variableWatchList$ = "" longestVarName = 0 nextvWatchDataSlot = 0 + totalVisibleVariables = 0 FOR y = 1 TO totalVariablesCreated IF usedVariableList(y).includedLine THEN _CONTINUE 'don't deal with variables in $INCLUDEs IF usedVariableList(y).watch THEN thisLen = LEN(usedVariableList(y).name) IF usedVariableList(y).isarray THEN - thisLen = thisLen + LEN(STR$(CVL(RIGHT$(usedVariableList(y).indexes, 4)))) - 1 + thisLen = thisLen + LEN(usedVariableList(y).watchRange) END IF IF LEN(usedVariableList(y).elements) THEN @@ -8213,28 +8229,39 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction) IF thisLen > longestVarName THEN longestVarName = thisLen - IF variableWatchList$ = "" THEN variableWatchList$ = SPACE$(4) + IF variableWatchList$ = "" THEN variableWatchList$ = SPACE$(8) MID$(variableWatchList$, 1, 4) = MKL$(longestVarName) END IF IF usedVariableList(y).isarray <> 0 AND LEN(usedVariableList(y).elements) = 0 THEN 'array of native data type - temp$ = usedVariableList(y).indexes - DO WHILE LEN(temp$) + temp$ = GetBytes$("", 0) + temp$ = expandArray$(usedVariableList(y).indexes, "") + DO + temp2$ = GetBytes$(temp$, 4) + IF LEN(temp2$) <> 4 THEN EXIT DO 'no more items + length = CVL(temp2$) + temp2$ = MKL$(length) + GetBytes$(temp$, length) nextvWatchDataSlot = nextvWatchDataSlot + 1 WHILE nextvWatchDataSlot > UBOUND(vWatchReceivedData$) REDIM _PRESERVE vWatchReceivedData$(1 TO UBOUND(vWatchReceivedData$) + 999) WEND - variableWatchList$ = variableWatchList$ + MKL$(-1) + MKL$(y) + LEFT$(temp$, 4) + MKL$(0) + MKL$(0) + MKL$(nextvWatchDataSlot) + variableWatchList$ = variableWatchList$ + MKL$(-1) + MKL$(y) + temp2$ + MKL$(0) + MKL$(0) + MKL$(nextvWatchDataSlot) + totalVisibleVariables = totalVisibleVariables + 1 usedVariableList(y).storage = usedVariableList(y).storage + MKL$(nextvWatchDataSlot) vWatchReceivedData$(nextvWatchDataSlot) = "" - temp$ = MID$(temp$, 5) LOOP ELSEIF usedVariableList(y).isarray <> 0 AND LEN(usedVariableList(y).elements) > 0 THEN 'array of UDT - temp$ = usedVariableList(y).indexes - DO WHILE LEN(temp$) - thisTempElement$ = MKL$(-1) + MKL$(y) + LEFT$(temp$, 4) + temp$ = GetBytes$("", 0) + temp$ = expandArray$(usedVariableList(y).indexes, "") + DO + temp2$ = GetBytes$(temp$, 4) + IF LEN(temp2$) <> 4 THEN EXIT DO 'no more items + length = CVL(temp2$) + temp2$ = MKL$(length) + GetBytes$(temp$, length) + + thisTempElement$ = MKL$(-1) + MKL$(y) + temp2$ thisElementList$ = MID$(usedVariableList(y).elements, 5) i = 0 DO @@ -8248,10 +8275,10 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction) WEND tempElementOffset& = CVL(MID$(usedVariableList(y).elementOffset, i * 4 - 3, 4)) variableWatchList$ = variableWatchList$ + thisTempElement$ + MKL$(i) + MKL$(tempElementOffset&) + MKL$(nextvWatchDataSlot) + totalVisibleVariables = totalVisibleVariables + 1 usedVariableList(y).storage = usedVariableList(y).storage + MKL$(nextvWatchDataSlot) vWatchReceivedData$(nextvWatchDataSlot) = "" LOOP - temp$ = MID$(temp$, 5) LOOP ELSEIF usedVariableList(y).isarray = 0 AND LEN(usedVariableList(y).elements) > 0 THEN 'single variable of UDT @@ -8269,6 +8296,7 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction) WEND tempElementOffset& = CVL(MID$(usedVariableList(y).elementOffset, i * 4 - 3, 4)) variableWatchList$ = variableWatchList$ + thisTempElement$ + MKL$(i) + MKL$(tempElementOffset&) + MKL$(nextvWatchDataSlot) + totalVisibleVariables = totalVisibleVariables + 1 usedVariableList(y).storage = usedVariableList(y).storage + MKL$(nextvWatchDataSlot) vWatchReceivedData$(nextvWatchDataSlot) = "" LOOP @@ -8279,10 +8307,12 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction) REDIM _PRESERVE vWatchReceivedData$(1 TO UBOUND(vWatchReceivedData$) + 999) WEND variableWatchList$ = variableWatchList$ + MKL$(-1) + MKL$(y) + MKL$(0) + MKL$(0) + MKL$(0) + MKL$(nextvWatchDataSlot) + totalVisibleVariables = totalVisibleVariables + 1 usedVariableList(y).storage = MKL$(nextvWatchDataSlot) END IF END IF NEXT + IF LEN(variableWatchList$) THEN MID$(variableWatchList$, 5, 4) = MKL$(totalVisibleVariables) IF mousedown THEN DO GetInput @@ -8322,17 +8352,38 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction) IF LEN(usedVariableList(varDlgList(y).index).indexes) THEN temp$ = usedVariableList(varDlgList(y).index).watchRange END IF - - v$ = ideinputbox$("Watch Array", "#Indexes to watch", temp$, "01234567890,-", 45, 0, ok) + setArrayRange2: + v$ = ideinputbox$("Watch Array", "#Indexes" + tempPrompt$, temp$, "01234567890,-; TOto", 45, 0, ok) IF ok THEN IF LEN(v$) > 0 THEN - temp$ = parseRange$(v$) - usedVariableList(varDlgList(y).index).indexes = temp$ - temp$ = formatRange$(temp$) - usedVariableList(varDlgList(y).index).watchRange = temp$ - ELSE + v$ = UCASE$(v$) + v$ = StrReplace$(v$, " TO ", "-") + WHILE RIGHT$(v$, 1) = ",": v$ = LEFT$(v$, LEN(v$) - 1): WEND + temp$ = lineformat$(v$) + i = countelements(temp$) + IF i <> ABS(ids(usedVariableList(varDlgList(y).index).id).arrayelements) THEN + result = idemessagebox("Error", "Array has" + STR$(ABS(ids(usedVariableList(varDlgList(y).index).id).arrayelements)) + " dimension(s).", "#OK") + temp$ = v$ + GOTO setArrayRange2 + END IF usedVariableList(varDlgList(y).index).indexes = "" usedVariableList(varDlgList(y).index).watchRange = "" + WHILE i + foundComma = INSTR(v$, ",") + IF foundComma THEN + temp$ = LEFT$(v$, foundComma - 1) + v$ = MID$(v$, foundComma + 1) + ELSE + temp$ = v$ + END IF + temp$ = parseRange$(temp$) + usedVariableList(varDlgList(y).index).indexes = usedVariableList(varDlgList(y).index).indexes + MKL$(LEN(temp$)) + temp$ + temp$ = formatRange$(temp$) + usedVariableList(varDlgList(y).index).watchRange = usedVariableList(varDlgList(y).index).watchRange + temp$ + i = i - 1 + IF i THEN usedVariableList(varDlgList(y).index).watchRange = usedVariableList(varDlgList(y).index).watchRange + "," + WEND + ELSE usedVariableList(varDlgList(y).index).watch = 0 GOSUB buildList idetxt(o(varListBox).txt) = l$ @@ -8344,6 +8395,7 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction) usedVariableList(varDlgList(y).index).watch = 0 GOTO unWatch END IF + END IF varType$ = usedVariableList(varDlgList(y).index).varType @@ -9064,10 +9116,10 @@ FUNCTION formatRange$(__text$) v2 = v ELSE IF v2 = -1 THEN - a2$ = a2$ + LTRIM$(STR$(v1)) + "," + a2$ = a2$ + LTRIM$(STR$(v1)) + ";" v1 = v ELSE - a2$ = a2$ + LTRIM$(STR$(v1)) + "-" + LTRIM$(STR$(v2)) + "," + a2$ = a2$ + LTRIM$(STR$(v1)) + "-" + LTRIM$(STR$(v2)) + ";" v1 = v v2 = -1 END IF @@ -9079,6 +9131,37 @@ FUNCTION formatRange$(__text$) formatRange$ = a2$ END FUNCTION +FUNCTION expandArray$ (__indexes$, __path$) + STATIC thisLevel AS LONG, returnValue$ + + IF thisLevel = 0 THEN + returnValue$ = "" + END IF + + thisLevel = thisLevel + 1 + + totalIndexes = CVL(LEFT$(__indexes$, 4)) + indexes$ = MID$(__indexes$, 5, totalIndexes) + remainingIndexes$ = MID$(__indexes$, 5 + totalIndexes) + totalIndexes = totalIndexes \ 4 + + FOR i = 1 TO totalIndexes + temp$ = __path$ + MID$(indexes$, i * 4 - 3, 4) + IF LEN(remainingIndexes$) THEN + temp$ = expandArray$(remainingIndexes$, temp$) + END IF + IF LEN(temp$) THEN + returnValue$ = returnValue$ + MKL$(LEN(temp$)) + temp$ + END IF + NEXT + + thisLevel = thisLevel - 1 + + IF thisLevel = 0 THEN + expandArray$ = returnValue$ + END IF +END FUNCTION + FUNCTION parseRange$(__text$) '__text$ must contain a valid numeric string (####), 'a valid interval (####-####) or comma-separated values. @@ -9090,7 +9173,7 @@ FUNCTION parseRange$(__text$) DIM zeroIncluded AS _BYTE Filter$ = _TRIM$(__text$) - j = INSTR(Filter$, "-") + INSTR(Filter$, ",") + j = INSTR(Filter$, "-") + INSTR(Filter$, ";") temp$ = SPACE$(1000) IF j = 0 THEN 'Single number passed @@ -9102,7 +9185,7 @@ FUNCTION parseRange$(__text$) FOR j = 1 TO LEN(Filter$) v = ASC(Filter$, j) SELECT CASE v - CASE 44 'comma + CASE 59 '; Reading = 1 GOSUB parseIt CASE 45 'hyphen @@ -18658,3 +18741,17 @@ SUB printWrapStatus (x AS INTEGER, y AS INTEGER, initialX AS INTEGER, __text$) RETURN END SUB +FUNCTION GetBytes$(__value$, numberOfBytes&) + STATIC prevValue$, getBytesPosition& + + value$ = __value$ + IF value$ <> prevValue$ THEN + prevValue$ = value$ + getBytesPosition& = 1 + END IF + + IF numberOfBytes& = 0 THEN EXIT FUNCTION + + GetBytes$ = MID$(value$, getBytesPosition&, numberOfBytes&) + getBytesPosition& = getBytesPosition& + numberOfBytes& +END FUNCTION From 3f64648fc8cc776b9b5e0ced16aee2d170083292 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Wed, 8 Sep 2021 23:24:10 -0300 Subject: [PATCH 3/9] Fixes Watch Panel items alignment. --- source/ide/ide_methods.bas | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index c158d42b2..764880dc4 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -7705,6 +7705,7 @@ SUB showvWatchPanel (this AS vWatchPanelType, currentScope$, totalVisibleVariabl IF this.hPos = 0 THEN this.hPos = 1 temp$ = GetBytes$("", 0) 'reset buffer temp$ = MID$(variableWatchList$, 9) + actualLongestVarName = 0 DO temp2$ = GetBytes$(temp$, 4) IF temp2$ <> MKL$(-1) THEN EXIT DO 'no more variables in list @@ -7734,6 +7735,7 @@ SUB showvWatchPanel (this AS vWatchPanelType, currentScope$, totalVisibleVariabl tempElementList$ = MID$(usedVariableList(tempIndex&).elements, 5) thisName$ = thisName$ + getelement$(tempElementList$, tempElement&) END IF + IF LEN(thisName$) > actualLongestVarName THEN actualLongestVarName = LEN(thisName$) item$ = thisName$ + SPACE$(longestVarName - LEN(thisName$)) + " = " IF usedVariableList(tempIndex&).subfunc = currentScope$ OR usedVariableList(tempIndex&).subfunc = "" THEN IF tempElement& THEN @@ -7760,6 +7762,7 @@ SUB showvWatchPanel (this AS vWatchPanelType, currentScope$, totalVisibleVariabl _ECHO item$ END IF LOOP + longestVarName = actualLongestVarName 'if these are different, next time it'll be fixed IF WatchListToConsole = 0 THEN IF totalVisibleVariables > this.h - 2 THEN From e561ab900268c696185b726e9afaf175c4177111 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Wed, 8 Sep 2021 23:41:13 -0300 Subject: [PATCH 4/9] Fixes vscrollbar not showing in Watch Panel. --- source/ide/ide_methods.bas | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 764880dc4..4bb35b787 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -7658,9 +7658,9 @@ Function map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!) map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange! End Function -SUB showvWatchPanel (this AS vWatchPanelType, currentScope$, totalVisibleVariables, action as _BYTE) +SUB showvWatchPanel (this AS vWatchPanelType, currentScope$, __totalVisibleVariables, action as _BYTE) STATIC previousVariableWatchList$ - STATIC longestVarName + STATIC longestVarName, totalVisibleVariables IF action = 1 THEN previousVariableWatchList$ = "": EXIT SUB 'reset @@ -7673,6 +7673,7 @@ SUB showvWatchPanel (this AS vWatchPanelType, currentScope$, totalVisibleVariabl IF this.h > idewy - 10 THEN this.h = idewy - 10 IF this.h < 5 THEN this.h = 5 END IF + __totalVisibleVariables = totalVisibleVariables 'pass back total visible variables fg = 0: bg = 7 From 133805181e1317a9e01f35a1d7c057e7db98a482 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Thu, 9 Sep 2021 00:00:02 -0300 Subject: [PATCH 5/9] Fixes vscrollbar not scrolling in Watch Panel. --- source/ide/ide_methods.bas | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 4bb35b787..b7d05b59f 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -6407,7 +6407,7 @@ SUB DebugMode debugClient& = 0 debuggeepid = 0 - showvWatchPanel vWatchPanel, "", 0, 1 + showvWatchPanel vWatchPanel, "", 1 IF LEN(variableWatchList$) = 0 THEN totalVisibleVariables = 0 vWatchPanel.h = 5 @@ -7598,7 +7598,8 @@ SUB DebugMode IF PauseMode <> 0 AND LEN(variableWatchList$) > 0 THEN IF WatchListToConsole THEN _CONSOLE ON - showvWatchPanel vWatchPanel, currentSub$, totalVisibleVariables, 0 + totalVisibleVariables = CVL(MID$(variableWatchList$, 5, 4)) + showvWatchPanel vWatchPanel, currentSub$, 0 END IF PCOPY 3, 0 @@ -7658,7 +7659,7 @@ Function map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!) map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange! End Function -SUB showvWatchPanel (this AS vWatchPanelType, currentScope$, __totalVisibleVariables, action as _BYTE) +SUB showvWatchPanel (this AS vWatchPanelType, currentScope$, action as _BYTE) STATIC previousVariableWatchList$ STATIC longestVarName, totalVisibleVariables @@ -7673,7 +7674,6 @@ SUB showvWatchPanel (this AS vWatchPanelType, currentScope$, __totalVisibleVaria IF this.h > idewy - 10 THEN this.h = idewy - 10 IF this.h < 5 THEN this.h = 5 END IF - __totalVisibleVariables = totalVisibleVariables 'pass back total visible variables fg = 0: bg = 7 From 908a5b179fdb649beb126b7ff11063590b46670e Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Thu, 9 Sep 2021 00:26:51 -0300 Subject: [PATCH 6/9] Removes fix046$ from variable names before displaying them. --- source/qb64.bas | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/qb64.bas b/source/qb64.bas index d47324e61..b2d78418c 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -25997,6 +25997,12 @@ SUB manageVariableList (__name$, __cname$, localIndex AS LONG, action AS _BYTE) usedVariableList(i).varType = id2fulltypename$ usedVariableList(i).cname = cname$ usedVariableList(i).localIndex = localIndex + + 'remove eventual instances of fix046$ in name$ + DO WHILE INSTR(name$, fix046$) + x = INSTR(name$, fix046$): name$ = LEFT$(name$, x - 1) + "." + RIGHT$(name$, LEN(name$) - x + 1 - LEN(fix046$)) + LOOP + IF LEN(RTRIM$(id.musthave)) > 0 THEN usedVariableList(i).name = name$ + RTRIM$(id.musthave) ELSE From 357178652bb1a689a53da3e2cd89edbac65f9f9e Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Thu, 9 Sep 2021 00:35:51 -0300 Subject: [PATCH 7/9] Calls _KEYCLEAR before moving on with the debuggee. In order to prevent unwanted keypresses eventually entered while in pause mode. --- internal/support/vwatch/vwatch.bm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/support/vwatch/vwatch.bm b/internal/support/vwatch/vwatch.bm index 36efc6bed..3327132d2 100644 --- a/internal/support/vwatch/vwatch.bm +++ b/internal/support/vwatch/vwatch.bm @@ -215,13 +215,13 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) CASE "run" vw_pauseMode = 0 vw_stepOver = 0 - vwatch_starttimers + _KEYCLEAR: vwatch_starttimers EXIT SUB CASE "run to line" vw_pauseMode = 0 vw_stepOver = 0 vw_runToLine = CVL(vw_value$) - vwatch_starttimers + _KEYCLEAR: vwatch_starttimers EXIT SUB CASE "step" vw_pauseMode = -1 @@ -231,19 +231,19 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) vw_pauseMode = -1 vw_stepOver = -1 vw_startLevel = vwatch_sublevel - vwatch_starttimers + _KEYCLEAR: vwatch_starttimers EXIT SUB CASE "step out" vw_pauseMode = -1 vw_stepOver = -1 vw_startLevel = vwatch_sublevel - 1 - vwatch_starttimers + _KEYCLEAR: vwatch_starttimers EXIT SUB CASE "free" unlockvWatchHandle: CLOSE #vw_ideHost vw_ideHost = 0 vw_bypass = -1 - vwatch_starttimers + _KEYCLEAR: vwatch_starttimers EXIT SUB CASE "set breakpoint" vwatch_breakpoints(CVL(vw_value$)) = -1 @@ -516,6 +516,7 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) _LIMIT 100 LOOP + _KEYCLEAR vwatch_starttimers EXIT SUB From 17a116b19dec70c464c81469afb2d86adf6e3fa0 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Thu, 9 Sep 2021 20:34:04 -0300 Subject: [PATCH 8/9] Adapts "Send Value" to work with multiple array dimensions. --- internal/support/vwatch/vwatch.bm | 56 +++++++++++++--------- source/ide/ide_methods.bas | 78 ++++++++++++++++++++++--------- 2 files changed, 88 insertions(+), 46 deletions(-) diff --git a/internal/support/vwatch/vwatch.bm b/internal/support/vwatch/vwatch.bm index 3327132d2..e6c6990fb 100644 --- a/internal/support/vwatch/vwatch.bm +++ b/internal/support/vwatch/vwatch.bm @@ -390,17 +390,19 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) vw_cmd$ = "address read:" + MKL$(vw_tempIndex) + MKL$(vw_arrayIndex) + MKL$(vw_element) + MKL$(vw_storage) + vw_buf$ GOSUB SendCommand CASE "set global address", "set local address" - vw_localIndex = CVL(LEFT$(vw_value$, 4)) - vw_isArray = (CVL(MID$(vw_value$, 5, 4)) <> 0) - vw_arrayIndex = CVL(MID$(vw_value$, 9, 4)) - vw_isUDT = (CVL(MID$(vw_value$, 13, 4)) <> 0) - vw_elementOffset = CVL(MID$(vw_value$, 17, 4)) - vw_arrayElementSize = CVL(MID$(vw_value$, 21, 4)) - vw_varSize = CVL(MID$(vw_value$, 25, 4)) - vw_i = CVI(MID$(vw_value$, 29, 2)) - vw_varType$ = MID$(vw_value$, 31, vw_i) - vw_i = CVI(MID$(vw_value$, 31 + vw_i, 2)) - vw_value$ = RIGHT$(vw_value$, vw_i) + vw_getBytes& = 4: GOSUB GetBytes: vw_localIndex = CVL(vw_valueBytes$) + vw_getBytes& = 4: GOSUB GetBytes: vw_isArray = (CVL(vw_valueBytes$) <> 0) + vw_getBytes& = 4: GOSUB GetBytes: vw_arrayTotalDimensions = CVL(vw_valueBytes$) + vw_getBytes& = vw_arrayTotalDimensions: GOSUB GetBytes: vw_arrayIndexes$ = vw_valueBytes$ + vw_arrayTotalDimensions = vw_arrayTotalDimensions \ 4 + vw_getBytes& = 4: GOSUB GetBytes: vw_isUDT = (CVL(vw_valueBytes$) <> 0) + vw_getBytes& = 4: GOSUB GetBytes: vw_elementOffset = CVL(vw_valueBytes$) + vw_getBytes& = 4: GOSUB GetBytes: vw_arrayElementSize = CVL(vw_valueBytes$) + vw_getBytes& = 4: GOSUB GetBytes: vw_varSize = CVL(vw_valueBytes$) + vw_getBytes& = 2: GOSUB GetBytes: vw_i = CVI(vw_valueBytes$) + vw_getBytes& = vw_i: GOSUB GetBytes: vw_varType$ = vw_valueBytes$ + vw_getBytes& = 2: GOSUB GetBytes: vw_i = CVI(vw_valueBytes$) + vw_getBytes& = vw_i: GOSUB GetBytes: vw_value$ = vw_valueBytes$ IF vw_cmd$ = "set global address" THEN vw_address = _OFFSET(globalVariables) + LEN(vw_address) * vw_localIndex @@ -412,12 +414,24 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) '-------- IF vw_isArray THEN - vw_lBound = check_lbound%&(vw_address, vw_arrayDimension, vw_arrayTotalDimensions) - vw_uBound = check_ubound%&(vw_address, vw_arrayDimension, vw_arrayTotalDimensions) - IF vw_arrayIndex < vw_lBound OR vw_arrayIndex > vw_uBound THEN - GOTO cmdProcessingDone - END IF + vw_realArrayIndex = 0 + vw_blockSize = 1 + + FOR vw_arrayDimension = 1 TO vw_arrayTotalDimensions + vw_lBound = check_lbound%&(vw_address, vw_arrayDimension, vw_arrayTotalDimensions) + vw_uBound = check_ubound%&(vw_address, vw_arrayDimension, vw_arrayTotalDimensions) + + vw_arrayIndex = CVL(MID$(vw_arrayIndexes$, vw_arrayDimension * 4 - 3, 4)) + + IF vw_arrayIndex < vw_lBound OR vw_arrayIndex > vw_uBound THEN + GOTO cmdProcessingDone + END IF + + vw_arrayIndex = (vw_arrayIndex - VAL(STR$(vw_lBound))) * vw_blockSize + vw_realArrayIndex = vw_realArrayIndex + vw_arrayIndex + vw_blockSize = vw_blockSize * VAL(STR$(vw_uBound - vw_lBound + 1)) + NEXT 'get the address of where this array's data is stored vw_buf$ = SPACE$(LEN(vw_dummy%&)) @@ -441,9 +455,9 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) 'this is where we calculate the actual array index position in memory IF vw_arrayElementSize = 0 THEN - vw_address = vw_address + ((vw_arrayIndex - vw_lBound) * vw_varSize) + vw_address = vw_address + (vw_realArrayIndex * vw_varSize) ELSE - vw_address = vw_address + ((vw_arrayIndex - vw_lBound) * vw_arrayElementSize) + vw_address = vw_address + (vw_realArrayIndex * vw_arrayElementSize) END IF ELSE IF vw_isUDT = 0 THEN @@ -552,7 +566,7 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) ELSE vw_cmd$ = "": vw_value$ = "" END IF - vw_prevValue$ = "" + vw_getBytesPosition& = 1 RETURN SendCallStack: @@ -577,10 +591,6 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) RETURN GetBytes: - IF vw_value$ <> vw_prevValue$ THEN - vw_prevValue$ = vw_value$ - vw_getBytesPosition& = 1 - END IF IF vw_getBytes& = 0 THEN vw_valueBytes$ = "": RETURN vw_valueBytes$ = MID$(vw_value$, vw_getBytesPosition&, vw_getBytes&) vw_getBytesPosition& = vw_getBytesPosition& + vw_getBytes& diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index b7d05b59f..f4fe34cb1 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -7063,24 +7063,28 @@ SUB DebugMode estabilishingScope = -1 ELSE requestVariableWatch: + hidePanel = -1 + GOSUB UpdateDisplay selectVar = 1 filter$ = "" DO result$ = idevariablewatchbox$(currentSub$, filter$, selectVar, returnAction) IF returnAction = 1 THEN + temp$ = GetBytes$("", 0) 'reset buffer 'set address - tempIndex& = CVL(LEFT$(result$, 4)) - result$ = MID$(result$, 5) - tempHeader$ = LEFT$(result$, 24) - tempIsArray& = CVL(MID$(result$, 5, 4)) - tempArrayIndex& = CVL(MID$(result$, 9, 4)) - tempIsUDT& = CVL(MID$(result$, 13, 4)) - tempElementOffset& = CVL(MID$(result$, 17, 4)) - tempStorage& = CVL(MID$(result$, 25, 4)) - i = CVI(MID$(result$, 29, 2)) - varType$ = MID$(result$, 31, i) - i = CVI(MID$(result$, 31 + i, 2)) - value$ = RIGHT$(result$, i) + tempIndex& = CVL(GetBytes$(result$, 4)) + tempLocalIndex& = CVL(GetBytes$(result$, 4)) + tempIsArray& = CVL(GetBytes$(result$, 4)) + tempArrayIndex& = CVL(GetBytes$(result$, 4)) + tempArrayIndexes$ = MKL$(tempArrayIndex&) + GetBytes$(result$, tempArrayIndex&) + tempIsUDT& = CVL(GetBytes$(result$, 4)) + tempElementOffset& = CVL(GetBytes$(result$, 4)) + tempArrayElementSize& = CVL(GetBytes$(result$, 4)) + tempStorage& = CVL(GetBytes$(result$, 4)) + i = CVI(GetBytes$(result$, 2)) + varType$ = GetBytes$(result$, i) + i = CVI(GetBytes$(result$, 2)) + value$ = GetBytes$(result$, i) IF LEN(usedVariableList(tempIndex&).subfunc) = 0 THEN cmd$ = "set global address:" @@ -7160,7 +7164,12 @@ SUB DebugMode END IF END SELECT - cmd$ = cmd$ + tempHeader$ + cmd$ = cmd$ + MKL$(tempLocalIndex&) + cmd$ = cmd$ + MKL$(tempIsArray&) + cmd$ = cmd$ + tempArrayIndexes$ + cmd$ = cmd$ + MKL$(tempIsUDT&) + cmd$ = cmd$ + MKL$(tempElementOffset&) + cmd$ = cmd$ + MKL$(tempArrayElementSize&) cmd$ = cmd$ + MKL$(varSize&) cmd$ = cmd$ + MKI$(LEN(varType$)) + varType$ cmd$ = cmd$ + MKI$(LEN(value$)) + value$ @@ -7172,6 +7181,7 @@ SUB DebugMode PCOPY 3, 0: SCREEN , , 3, 0 WHILE _MOUSEINPUT: WEND + hidePanel = -1 GOSUB UpdateDisplay ELSEIF returnAction = 2 THEN PCOPY 3, 0: SCREEN , , 3, 0 @@ -7599,7 +7609,8 @@ SUB DebugMode IF PauseMode <> 0 AND LEN(variableWatchList$) > 0 THEN IF WatchListToConsole THEN _CONSOLE ON totalVisibleVariables = CVL(MID$(variableWatchList$, 5, 4)) - showvWatchPanel vWatchPanel, currentSub$, 0 + IF hidePanel = 0 THEN showvWatchPanel vWatchPanel, currentSub$, 0 + hidePanel = 0 END IF PCOPY 3, 0 @@ -8030,14 +8041,35 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction) IF usedVariableList(tempIndex&).subfunc = currentScope$ OR usedVariableList(tempIndex&).subfunc = "" THEN 'scope is valid tempArrayIndex& = 0 + tempArrayIndexes$ = MKL$(0) tempStorage& = 0 tempIsUDT& = 0 tempElementOffset$ = MKL$(0) IF usedVariableList(tempIndex&).isarray THEN - v$ = ideinputbox$("Change Value", "#Index to change", temp$, "01234567890", 45, 0, ok) + setArrayRange3: + v$ = ideinputbox$("Change Value", "#Index to change", temp$, "01234567890,", 45, 0, ok) IF ok THEN IF LEN(v$) > 0 THEN - tempArrayIndex& = VAL(v$) + WHILE RIGHT$(v$, 1) = ",": v$ = LEFT$(v$, LEN(v$) - 1): WEND + temp$ = lineformat$(v$) + i = countelements(temp$) + IF i <> ABS(ids(usedVariableList(tempIndex&).id).arrayelements) THEN + result = idemessagebox("Error", "Array has" + STR$(ABS(ids(usedVariableList(tempIndex&).id).arrayelements)) + " dimension(s).", "#OK") + temp$ = v$ + GOTO setArrayRange3 + END IF + tempArrayIndexes$ = MKL$(i * 4) + WHILE i + foundComma = INSTR(v$, ",") + IF foundComma THEN + temp$ = LEFT$(v$, foundComma - 1) + v$ = MID$(v$, foundComma + 1) + ELSE + temp$ = v$ + END IF + tempArrayIndexes$ = tempArrayIndexes$ + MKL$(VAL(temp$)) + i = i - 1 + WEND ELSE _CONTINUE END IF @@ -8162,14 +8194,14 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction) storageSlot& = 0 IF LEN(usedVariableList(tempIndex&).storage) = 4 THEN storageSlot& = CVL(usedVariableList(tempIndex&).storage) - ELSE - i = 5 + ELSEIF LEN(usedVariableList(tempIndex&).storage) > 4 THEN + i = 4 DO - i = INSTR(i + 1, variableWatchList$, MKL$(-1) + MKL$(tempIndex&) + MKL$(tempArrayIndex&)) + i = INSTR(i + 1, variableWatchList$, MKL$(-1) + MKL$(tempIndex&) + tempArrayIndexes$) IF i = 0 THEN EXIT DO - IF MID$(variableWatchList$, i + 16, 4) = tempElementOffset$ THEN + IF MID$(variableWatchList$, i + 8 + LEN(tempArrayIndexes$), 4) = tempElementOffset$ THEN 'we found where this element's value is being stored - storageSlot& = CVL(MID$(variableWatchList$, i + 20, 4)) + storageSlot& = CVL(MID$(variableWatchList$, i + 16 + LEN(tempArrayIndexes$), 4)) EXIT DO END IF LOOP @@ -8189,7 +8221,7 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction) temp$ = temp$ + MKL$(tempIndex&) temp$ = temp$ + MKL$(usedVariableList(tempIndex&).localindex) temp$ = temp$ + MKL$(usedVariableList(tempIndex&).isarray <> 0) - temp$ = temp$ + MKL$(tempArrayIndex&) + temp$ = temp$ + tempArrayIndexes$ temp$ = temp$ + MKL$(tempIsUDT&) temp$ = temp$ + tempElementOffset$ temp$ = temp$ + MKL$(usedVariableList(tempIndex&).arrayElementSize) @@ -8239,7 +8271,7 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction) IF usedVariableList(y).isarray <> 0 AND LEN(usedVariableList(y).elements) = 0 THEN 'array of native data type - temp$ = GetBytes$("", 0) + temp$ = GetBytes$("", 0) 'reset buffer temp$ = expandArray$(usedVariableList(y).indexes, "") DO temp2$ = GetBytes$(temp$, 4) From 8d58dff8629c909eb98ffba5d4a8dd8fae4f1f92 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Thu, 9 Sep 2021 21:29:34 -0300 Subject: [PATCH 9/9] Shows `` at Watch list dialog for UDTs. --- source/ide/ide_methods.bas | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index f4fe34cb1..f95e5b349 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -7186,6 +7186,7 @@ SUB DebugMode ELSEIF returnAction = 2 THEN PCOPY 3, 0: SCREEN , , 3, 0 WHILE _MOUSEINPUT: WEND + hidePanel = -1 GOSUB UpdateDisplay _CONTINUE ELSE @@ -8055,7 +8056,7 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction) i = countelements(temp$) IF i <> ABS(ids(usedVariableList(tempIndex&).id).arrayelements) THEN result = idemessagebox("Error", "Array has" + STR$(ABS(ids(usedVariableList(tempIndex&).id).arrayelements)) + " dimension(s).", "#OK") - temp$ = v$ + temp$ = _TRIM$(v$) GOTO setArrayRange3 END IF tempArrayIndexes$ = MKL$(i * 4) @@ -8399,7 +8400,7 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction) i = countelements(temp$) IF i <> ABS(ids(usedVariableList(varDlgList(y).index).id).arrayelements) THEN result = idemessagebox("Error", "Array has" + STR$(ABS(ids(usedVariableList(varDlgList(y).index).id).arrayelements)) + " dimension(s).", "#OK") - temp$ = v$ + temp$ = _TRIM$(v$) GOTO setArrayRange2 END IF usedVariableList(varDlgList(y).index).indexes = "" @@ -8681,7 +8682,7 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction) item$ = usedVariableList(x).name + usedVariableList(x).varType + thisScope$ IF IdeDebugMode > 0 AND usedVariableList(x).isarray = 0 AND LEN(usedVariableList(x).elements) = 0 AND LEN(usedVariableList(x).storage) = 4 THEN 'single var - item$ = item$ + vWatchReceivedData$(CVL(usedVariableList(x).storage)) + item$ = item$ + StrReplace$(vWatchReceivedData$(CVL(usedVariableList(x).storage)), CHR$(0), " ") END IF IF multiSearch(item$, searchTerm$) = 0 THEN _CONTINUE 'skip variable if no field matches the search @@ -8754,6 +8755,7 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction) LOOP IF LEN(usedVariableList(x).storage) THEN l$ = l$ + "}" ELSEIF usedVariableList(x).isarray = 0 AND LEN(usedVariableList(x).elements) = 0 THEN + 'simple variable IF LEN(usedVariableList(x).storage) = 4 THEN storageSlot& = CVL(usedVariableList(x).storage) l$ = l$ + " = " + CHR$(16) + CHR$(variableNameColor) @@ -8761,6 +8763,9 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction) l$ = l$ + StrReplace$(vWatchReceivedData$(storageSlot&), CHR$(0), " ") IF thisIsAString THEN l$ = l$ + CHR$(34) END IF + ELSE + l$ = l$ + " = " + CHR$(16) + CHR$(variableNameColor) + l$ = l$ + "" END IF END IF ELSE