From eeff3207d6d349df5d3e24ebcd2a3bd1834cccff Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Mon, 16 Aug 2021 01:32:07 -0300 Subject: [PATCH] Preliminary work to watch arrays (native types). Strings not working yet. --- internal/support/vwatch/vwatch.bm | 16 +-- source/ide/ide_global.bas | 1 + source/ide/ide_methods.bas | 158 ++++++++++++++++++------------ source/qb64.bas | 3 +- 4 files changed, 108 insertions(+), 70 deletions(-) diff --git a/internal/support/vwatch/vwatch.bm b/internal/support/vwatch/vwatch.bm index f42e2262c..c6d2fbbf4 100644 --- a/internal/support/vwatch/vwatch.bm +++ b/internal/support/vwatch/vwatch.bm @@ -2,7 +2,7 @@ $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 + STATIC AS LONG vw_runToLine, vw_arrayIndex STATIC AS _BYTE vw_pauseMode, vw_stepOver, vw_bypass, vw_setNextLine, vw_hwndsent STATIC AS _OFFSET vw_idehwnd STATIC vw_buffer$ @@ -249,7 +249,8 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) CASE "global var", "local var" vw_tempIndex = CVL(LEFT$(vw_value$, 4)) vw_localIndex = CVL(MID$(vw_value$, 5, 4)) - vw_scope$ = MID$(vw_value$, 9) + vw_arrayIndex = CVL(MID$(vw_value$, 9, 4)) + vw_scope$ = MID$(vw_value$, 13) IF vw_cmd$ = "global var" THEN vw_address = _OFFSET(globalVariables) + LEN(vw_address) * vw_localIndex ELSE @@ -261,18 +262,19 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) END IF vw_address = _MEMGET(vw_m, vw_address, _OFFSET) 'first resolve pass vw_address = _MEMGET(vw_m, vw_address, _OFFSET) 'second resolve pass - vw_cmd$ = vw_cmd$ + ":" + MKL$(vw_tempIndex) + _MK$(_OFFSET, vw_address) + vw_cmd$ = vw_cmd$ + ":" + MKL$(vw_tempIndex) + MKL$(vw_arrayIndex) + _MK$(_OFFSET, vw_address) GOSUB SendCommand CASE "get address" vw_tempIndex = CVL(LEFT$(vw_value$, 4)) - vw_sequence = CVI(MID$(vw_value$, 5, 2)) - vw_varSize = CVL(MID$(vw_value$, 7, 4)) - vw_address = _CV(_OFFSET, MID$(vw_value$, 11, LEN(vw_address))) + vw_arrayIndex = CVL(MID$(vw_value$, 5, 4)) + vw_sequence = CVI(MID$(vw_value$, 9, 2)) + vw_varSize = CVL(MID$(vw_value$, 11, 4)) + vw_address = _CV(_OFFSET, MID$(vw_value$, 15, LEN(vw_address))) 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 - vw_cmd$ = "address read:" + MKL$(vw_tempIndex) + MKI$(vw_sequence) + vw_buf$ + vw_cmd$ = "address read:" + MKL$(vw_tempIndex) + MKL$(vw_arrayIndex) + MKI$(vw_sequence) + vw_buf$ GOSUB SendCommand CASE "set global address", "set local address" vw_localIndex = CVL(LEFT$(vw_value$, 4)) diff --git a/source/ide/ide_global.bas b/source/ide/ide_global.bas index bcad331b5..b63ff18f4 100644 --- a/source/ide/ide_global.bas +++ b/source/ide/ide_global.bas @@ -12,6 +12,7 @@ DIM SHARED IdeInfo AS STRING DIM SHARED IdeContextHelpSF AS _BYTE DIM SHARED host&, debugClient&, hostport$, variableWatchList$ +DIM SHARED vWatchArrayReceivedData$(1 TO 1000), nextvWatchArraySlot DIM SHARED startPausedPending AS _BYTE DIM SHARED IdeSystem AS LONG diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 609153e9c..3c86d28ce 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -1140,6 +1140,7 @@ FUNCTION ide2 (ignore) IF idelayoutallow THEN idelayoutallow = idelayoutallow - 1 + variableWatchList$ = "" idecurrentlinelayouti = 0 'invalidate idefocusline = 0 idechangemade = 0 @@ -7387,7 +7388,7 @@ SUB DebugMode cmd$ = "local var:" END IF IF LEN(cmd$) THEN - cmd$ = cmd$ + MKL$(tempIndex&) + MKL$(usedVariableList(tempIndex&).localIndex) + usedVariableList(tempIndex&).subfunc + cmd$ = cmd$ + MKL$(tempIndex&) + MKL$(usedVariableList(tempIndex&).localIndex) + MKL$(tempArrayIndex&) + usedVariableList(tempIndex&).subfunc GOSUB SendCommand END IF LOOP @@ -7396,71 +7397,74 @@ SUB DebugMode debuggeehwnd = _CV(_OFFSET, value$) CASE "global var", "local var" tempIndex& = CVL(LEFT$(value$, 4)) - address%& = _CV(_OFFSET, MID$(value$, 5)) + tempArrayIndex& = CVL(MID$(value$, 5, 4)) + address%& = _CV(_OFFSET, MID$(value$, 9)) usedVariableList(tempIndex&).baseAddress = address%& - varType$ = usedVariableList(tempIndex&).varType - IF usedVariableList(tempIndex&).isarray THEN - 'TODO - ELSE - IF INSTR(varType$, "STRING *") THEN varType$ = "STRING" - SELECT CASE varType$ - CASE "_BYTE", "_UNSIGNED _BYTE", "BYTE", "UNSIGNED BYTE": varSize& = LEN(dummy%%) - CASE "INTEGER", "_UNSIGNED INTEGER", "UNSIGNED INTEGER": varSize& = LEN(dummy%) - CASE "LONG", "_UNSIGNED LONG", "UNSIGNED LONG": varSize& = LEN(dummy&) - CASE "_INTEGER64", "_UNSIGNED _INTEGER64", "INTEGER64", "UNSIGNED INTEGER64": varSize& = LEN(dummy&&) - CASE "SINGLE": varSize& = LEN(dummy!) - CASE "DOUBLE": varSize& = LEN(dummy#) - CASE "_FLOAT", "FLOAT": varSize& = LEN(dummy##) - CASE "_OFFSET", "_UNSIGNED _OFFSET", "OFFSET", "UNSIGNED OFFSET": varSize& = LEN(dummy%&) - CASE "STRING": varSize& = LEN(dummy%&) + LEN(dummy&) - END SELECT - cmd$ = "get address:" + MKL$(tempIndex&) + MKI$(1) + MKL$(varSize&) + _MK$(_OFFSET, address%&) - GOSUB SendCommand - END IF + GOSUB GetVarSize + IF usedVariableList(tempIndex&).isarray THEN varSize& = LEN(dummy%&) + cmd$ = "get address:" + MKL$(tempIndex&) + MKL$(tempArrayIndex&) + MKI$(1) + MKL$(varSize&) + _MK$(_OFFSET, address%&) + GOSUB SendCommand CASE "address read" tempIndex& = CVL(LEFT$(value$, 4)) - sequence% = CVI(MID$(value$, 5, 2)) - recvData$ = MID$(value$, 7) + tempArrayIndex& = CVL(MID$(value$, 5, 4)) + sequence% = CVI(MID$(value$, 9, 2)) + recvData$ = MID$(value$, 11) + GOSUB GetVarSize IF usedVariableList(tempIndex&).isarray THEN - 'TODO - ELSE - varType$ = usedVariableList(tempIndex&).varType - IF INSTR(varType$, "STRING *") THEN varType$ = "STRING" - SELECT CASE varType$ - CASE "_BYTE", "BYTE": recvData$ = STR$(_CV(_BYTE, recvData$)) - CASE "_UNSIGNED _BYTE", "UNSIGNED BYTE": recvData$ = STR$(_CV(_UNSIGNED _BYTE, recvData$)) - CASE "INTEGER": recvData$ = STR$(_CV(INTEGER, recvData$)) - CASE "_UNSIGNED INTEGER", "UNSIGNED INTEGER": recvData$ = STR$(_CV(_UNSIGNED INTEGER, recvData$)) - CASE "LONG": recvData$ = STR$(_CV(LONG, recvData$)) - CASE "_UNSIGNED LONG", "UNSIGNED LONG": recvData$ = STR$(_CV(_UNSIGNED LONG, recvData$)) - CASE "_INTEGER64", "INTEGER64": recvData$ = STR$(_CV(_INTEGER64, recvData$)) - CASE "_UNSIGNED _INTEGER64", "UNSIGNED INTEGER64": recvData$ = STR$(_CV(_UNSIGNED _INTEGER64, recvData$)) - CASE "SINGLE": recvData$ = STR$(_CV(SINGLE, recvData$)) - CASE "DOUBLE": recvData$ = STR$(_CV(DOUBLE, recvData$)) - CASE "_FLOAT", "FLOAT": recvData$ = STR$(_CV(_FLOAT, recvData$)) - CASE "_OFFSET", "OFFSET": recvData$ = STR$(_CV(_OFFSET, recvData$)) - CASE "_UNSIGNED _OFFSET", "UNSIGNED OFFSET": recvData$ = STR$(_CV(_UNSIGNED _OFFSET, recvData$)) - CASE "STRING" - IF sequence% = 1 THEN - IF LEN(dummy%&) = 8 THEN - address%& = _CV(_INTEGER64, LEFT$(recvData$, 8)) 'Pointer to data - usedVariableList(tempIndex&).address = address%& - strLength& = CVL(MID$(recvData$, 9)) - usedVariableList(tempIndex&).strLength = strLength& - ELSE - address%& = _CV(LONG, LEFT$(recvData$, 4)) 'Pointer to data - usedVariableList(tempIndex&).address = address%& - strLength& = CVL(MID$(recvData$, 5)) - usedVariableList(tempIndex&).strLength = strLength& - END IF - cmd$ = "get address:" + MKL$(tempIndex&) + MKI$(2) + MKL$(strLength&) + _MK$(_OFFSET, address%&) - GOSUB SendCommand - GOTO vwatch_string_seq1_done - END IF - END SELECT - usedVariableList(tempIndex&).mostRecentValue = recvData$ - vwatch_string_seq1_done: + IF sequence% = 1 THEN + IF LEN(dummy%&) = 8 THEN + address%& = _CV(_INTEGER64, LEFT$(recvData$, 8)) 'Pointer to data + ELSE + address%& = _CV(LONG, LEFT$(recvData$, 4)) 'Pointer to data + END IF + address%& = address%& + ((tempArrayIndex& - 1) * varSize&) + cmd$ = "get address:" + MKL$(tempIndex&) + MKL$(tempArrayIndex&) + MKI$(2) + MKL$(varSize&) + _MK$(_OFFSET, address%&) + GOSUB SendCommand + GOTO vwatch_seq1_done + END IF END IF + varType$ = usedVariableList(tempIndex&).varType + IF INSTR(varType$, "STRING *") THEN varType$ = "STRING" + SELECT CASE varType$ + CASE "_BYTE", "BYTE": recvData$ = STR$(_CV(_BYTE, recvData$)) + CASE "_UNSIGNED _BYTE", "UNSIGNED BYTE": recvData$ = STR$(_CV(_UNSIGNED _BYTE, recvData$)) + CASE "INTEGER": recvData$ = STR$(_CV(INTEGER, recvData$)) + CASE "_UNSIGNED INTEGER", "UNSIGNED INTEGER": recvData$ = STR$(_CV(_UNSIGNED INTEGER, recvData$)) + CASE "LONG": recvData$ = STR$(_CV(LONG, recvData$)) + CASE "_UNSIGNED LONG", "UNSIGNED LONG": recvData$ = STR$(_CV(_UNSIGNED LONG, recvData$)) + CASE "_INTEGER64", "INTEGER64": recvData$ = STR$(_CV(_INTEGER64, recvData$)) + CASE "_UNSIGNED _INTEGER64", "UNSIGNED INTEGER64": recvData$ = STR$(_CV(_UNSIGNED _INTEGER64, recvData$)) + CASE "SINGLE": recvData$ = STR$(_CV(SINGLE, recvData$)) + CASE "DOUBLE": recvData$ = STR$(_CV(DOUBLE, recvData$)) + CASE "_FLOAT", "FLOAT": recvData$ = STR$(_CV(_FLOAT, recvData$)) + CASE "_OFFSET", "OFFSET": recvData$ = STR$(_CV(_OFFSET, recvData$)) + CASE "_UNSIGNED _OFFSET", "UNSIGNED OFFSET": recvData$ = STR$(_CV(_UNSIGNED _OFFSET, recvData$)) + CASE "STRING" + IF sequence% = 1 THEN + IF LEN(dummy%&) = 8 THEN + address%& = _CV(_INTEGER64, LEFT$(recvData$, 8)) 'Pointer to data + usedVariableList(tempIndex&).address = address%& + strLength& = CVL(MID$(recvData$, 9)) + usedVariableList(tempIndex&).strLength = strLength& + ELSE + address%& = _CV(LONG, LEFT$(recvData$, 4)) 'Pointer to data + usedVariableList(tempIndex&).address = address%& + strLength& = CVL(MID$(recvData$, 5)) + usedVariableList(tempIndex&).strLength = strLength& + END IF + cmd$ = "get address:" + MKL$(tempIndex&) + MKL$(tempArrayIndex&) + MKI$(2) + MKL$(strLength&) + _MK$(_OFFSET, address%&) + GOSUB SendCommand + GOTO vwatch_seq1_done + END IF + END SELECT + IF usedVariableList(tempIndex&).isarray THEN + seqIndex& = INSTR(usedVariableList(tempIndex&).indexes, MKL$(tempArrayIndex&)) + storageSlot& = CVL(MID$(usedVariableList(tempIndex&).storage, seqIndex&, 4)) + vWatchArrayReceivedData$(storageSlot&) = recvData$ + ELSE + usedVariableList(tempIndex&).mostRecentValue = recvData$ + END IF + vwatch_seq1_done: IF PauseMode THEN GOSUB UpdateDisplay CASE "current sub" currentSub$ = value$ @@ -7607,6 +7611,21 @@ SUB DebugMode PCOPY 3, 0 RETURN + GetVarSize: + varType$ = usedVariableList(tempIndex&).varType + IF INSTR(varType$, "STRING *") THEN varType$ = "STRING" + SELECT CASE varType$ + CASE "_BYTE", "_UNSIGNED _BYTE", "BYTE", "UNSIGNED BYTE": varSize& = LEN(dummy%%) + CASE "INTEGER", "_UNSIGNED INTEGER", "UNSIGNED INTEGER": varSize& = LEN(dummy%) + CASE "LONG", "_UNSIGNED LONG", "UNSIGNED LONG": varSize& = LEN(dummy&) + CASE "_INTEGER64", "_UNSIGNED _INTEGER64", "INTEGER64", "UNSIGNED INTEGER64": varSize& = LEN(dummy&&) + CASE "SINGLE": varSize& = LEN(dummy!) + CASE "DOUBLE": varSize& = LEN(dummy#) + CASE "_FLOAT", "FLOAT": varSize& = LEN(dummy##) + CASE "_OFFSET", "_UNSIGNED _OFFSET", "OFFSET", "UNSIGNED OFFSET": varSize& = LEN(dummy%&) + CASE "STRING": varSize& = LEN(dummy%&) + LEN(dummy&) + END SELECT + RETURN END SUB Function map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!) @@ -7670,7 +7689,15 @@ SUB showvWatchPanel (this AS vWatchPanelType, currentScope$, totalVisibleVariabl END IF item$ = thisName$ + SPACE$(longestVarName - LEN(thisName$)) + " = " IF usedVariableList(tempIndex&).subfunc = currentScope$ OR usedVariableList(tempIndex&).subfunc = "" THEN - item$ = item$ + usedVariableList(tempIndex&).mostRecentValue + IF usedVariableList(tempIndex&).isarray THEN + seqIndex& = INSTR(usedVariableList(tempIndex&).indexes, MKL$(tempArrayIndex&)) + storageSlot& = CVL(MID$(usedVariableList(tempIndex&).storage, seqIndex&, 4)) + tempValue$ = vWatchArrayReceivedData$(storageSlot&) + ELSE + tempValue$ = usedVariableList(tempIndex&).mostRecentValue + END IF + + item$ = item$ + tempValue$ COLOR fg ELSE item$ = item$ + "" @@ -7963,6 +7990,7 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction) (IdeDebugMode > 0 AND focus = 6 AND info <> 0) THEN variableWatchList$ = "" longestVarName = 0 + nextvWatchArraySlot = 0 FOR y = 1 TO totalVariablesCreated IF usedVariableList(y).watch THEN thisLen = LEN(usedVariableList(y).name) @@ -7979,6 +8007,12 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction) temp$ = usedVariableList(y).indexes DO WHILE LEN(temp$) variableWatchList$ = variableWatchList$ + MKL$(y) + LEFT$(temp$, 4) + nextvWatchArraySlot = nextvWatchArraySlot + 1 + WHILE nextvWatchArraySlot > UBOUND(vWatchArrayReceivedData$) + REDIM _PRESERVE vWatchArrayReceivedData$(1 TO UBOUND(vWatchArrayReceivedData$) + 999) + WEND + usedVariableList(y).storage = usedVariableList(y).storage + MKL$(nextvWatchArraySlot) + vWatchArrayReceivedData$(nextvWatchArraySlot) = "" temp$ = MID$(temp$, 5) LOOP ELSE diff --git a/source/qb64.bas b/source/qb64.bas index ef996560f..5411b9a97 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -112,7 +112,7 @@ TYPE usedVarList AS LONG id, linenumber, includeLevel, includedLine, scope, localIndex, strLength AS _BYTE used, watch, isarray AS STRING name, cname, varType, includedFile, subfunc, mostRecentValue - AS STRING watchRange, indexes, elements 'for Arrays and UDTs + AS STRING watchRange, indexes, elements, storage 'for Arrays and UDTs AS _OFFSET baseAddress, address END TYPE @@ -25955,6 +25955,7 @@ SUB manageVariableList (__name$, __cname$, localIndex AS LONG, action AS _BYTE) usedVariableList(i).used = 0 usedVariableList(i).watch = 0 usedVariableList(i).mostRecentValue = "" + usedVariableList(i).storage = "" usedVariableList(i).linenumber = linenumber usedVariableList(i).includeLevel = inclevel IF inclevel > 0 THEN