1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 11:40:38 +00:00

Preliminary work to watch arrays (native types).

Strings not working yet.
This commit is contained in:
FellippeHeitor 2021-08-16 01:32:07 -03:00
parent c2ce0df83f
commit eeff3207d6
4 changed files with 108 additions and 70 deletions

View file

@ -2,7 +2,7 @@ $CHECKING:OFF
SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET) 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_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 _BYTE vw_pauseMode, vw_stepOver, vw_bypass, vw_setNextLine, vw_hwndsent
STATIC AS _OFFSET vw_idehwnd STATIC AS _OFFSET vw_idehwnd
STATIC vw_buffer$ STATIC vw_buffer$
@ -249,7 +249,8 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET)
CASE "global var", "local var" CASE "global var", "local var"
vw_tempIndex = CVL(LEFT$(vw_value$, 4)) vw_tempIndex = CVL(LEFT$(vw_value$, 4))
vw_localIndex = CVL(MID$(vw_value$, 5, 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 IF vw_cmd$ = "global var" THEN
vw_address = _OFFSET(globalVariables) + LEN(vw_address) * vw_localIndex vw_address = _OFFSET(globalVariables) + LEN(vw_address) * vw_localIndex
ELSE ELSE
@ -261,18 +262,19 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET)
END IF END IF
vw_address = _MEMGET(vw_m, vw_address, _OFFSET) 'first resolve pass vw_address = _MEMGET(vw_m, vw_address, _OFFSET) 'first resolve pass
vw_address = _MEMGET(vw_m, vw_address, _OFFSET) 'second 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 GOSUB SendCommand
CASE "get address" CASE "get address"
vw_tempIndex = CVL(LEFT$(vw_value$, 4)) vw_tempIndex = CVL(LEFT$(vw_value$, 4))
vw_sequence = CVI(MID$(vw_value$, 5, 2)) vw_arrayIndex = CVL(MID$(vw_value$, 5, 4))
vw_varSize = CVL(MID$(vw_value$, 7, 4)) vw_sequence = CVI(MID$(vw_value$, 9, 2))
vw_address = _CV(_OFFSET, MID$(vw_value$, 11, LEN(vw_address))) 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_buf$ = SPACE$(vw_varSize)
vw_m = _MEM(vw_address, vw_varSize) vw_m = _MEM(vw_address, vw_varSize)
vw_m2 = _MEM(_OFFSET(vw_buf$), 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 _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 GOSUB SendCommand
CASE "set global address", "set local address" CASE "set global address", "set local address"
vw_localIndex = CVL(LEFT$(vw_value$, 4)) vw_localIndex = CVL(LEFT$(vw_value$, 4))

View file

@ -12,6 +12,7 @@ DIM SHARED IdeInfo AS STRING
DIM SHARED IdeContextHelpSF AS _BYTE DIM SHARED IdeContextHelpSF AS _BYTE
DIM SHARED host&, debugClient&, hostport$, variableWatchList$ DIM SHARED host&, debugClient&, hostport$, variableWatchList$
DIM SHARED vWatchArrayReceivedData$(1 TO 1000), nextvWatchArraySlot
DIM SHARED startPausedPending AS _BYTE DIM SHARED startPausedPending AS _BYTE
DIM SHARED IdeSystem AS LONG DIM SHARED IdeSystem AS LONG

View file

@ -1140,6 +1140,7 @@ FUNCTION ide2 (ignore)
IF idelayoutallow THEN idelayoutallow = idelayoutallow - 1 IF idelayoutallow THEN idelayoutallow = idelayoutallow - 1
variableWatchList$ = ""
idecurrentlinelayouti = 0 'invalidate idecurrentlinelayouti = 0 'invalidate
idefocusline = 0 idefocusline = 0
idechangemade = 0 idechangemade = 0
@ -7387,7 +7388,7 @@ SUB DebugMode
cmd$ = "local var:" cmd$ = "local var:"
END IF END IF
IF LEN(cmd$) THEN 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 GOSUB SendCommand
END IF END IF
LOOP LOOP
@ -7396,71 +7397,74 @@ SUB DebugMode
debuggeehwnd = _CV(_OFFSET, value$) debuggeehwnd = _CV(_OFFSET, value$)
CASE "global var", "local var" CASE "global var", "local var"
tempIndex& = CVL(LEFT$(value$, 4)) 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%& usedVariableList(tempIndex&).baseAddress = address%&
varType$ = usedVariableList(tempIndex&).varType GOSUB GetVarSize
IF usedVariableList(tempIndex&).isarray THEN IF usedVariableList(tempIndex&).isarray THEN varSize& = LEN(dummy%&)
'TODO cmd$ = "get address:" + MKL$(tempIndex&) + MKL$(tempArrayIndex&) + MKI$(1) + MKL$(varSize&) + _MK$(_OFFSET, address%&)
ELSE GOSUB SendCommand
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
CASE "address read" CASE "address read"
tempIndex& = CVL(LEFT$(value$, 4)) tempIndex& = CVL(LEFT$(value$, 4))
sequence% = CVI(MID$(value$, 5, 2)) tempArrayIndex& = CVL(MID$(value$, 5, 4))
recvData$ = MID$(value$, 7) sequence% = CVI(MID$(value$, 9, 2))
recvData$ = MID$(value$, 11)
GOSUB GetVarSize
IF usedVariableList(tempIndex&).isarray THEN IF usedVariableList(tempIndex&).isarray THEN
'TODO IF sequence% = 1 THEN
ELSE IF LEN(dummy%&) = 8 THEN
varType$ = usedVariableList(tempIndex&).varType address%& = _CV(_INTEGER64, LEFT$(recvData$, 8)) 'Pointer to data
IF INSTR(varType$, "STRING *") THEN varType$ = "STRING" ELSE
SELECT CASE varType$ address%& = _CV(LONG, LEFT$(recvData$, 4)) 'Pointer to data
CASE "_BYTE", "BYTE": recvData$ = STR$(_CV(_BYTE, recvData$)) END IF
CASE "_UNSIGNED _BYTE", "UNSIGNED BYTE": recvData$ = STR$(_CV(_UNSIGNED _BYTE, recvData$)) address%& = address%& + ((tempArrayIndex& - 1) * varSize&)
CASE "INTEGER": recvData$ = STR$(_CV(INTEGER, recvData$)) cmd$ = "get address:" + MKL$(tempIndex&) + MKL$(tempArrayIndex&) + MKI$(2) + MKL$(varSize&) + _MK$(_OFFSET, address%&)
CASE "_UNSIGNED INTEGER", "UNSIGNED INTEGER": recvData$ = STR$(_CV(_UNSIGNED INTEGER, recvData$)) GOSUB SendCommand
CASE "LONG": recvData$ = STR$(_CV(LONG, recvData$)) GOTO vwatch_seq1_done
CASE "_UNSIGNED LONG", "UNSIGNED LONG": recvData$ = STR$(_CV(_UNSIGNED LONG, recvData$)) END IF
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:
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 IF PauseMode THEN GOSUB UpdateDisplay
CASE "current sub" CASE "current sub"
currentSub$ = value$ currentSub$ = value$
@ -7607,6 +7611,21 @@ SUB DebugMode
PCOPY 3, 0 PCOPY 3, 0
RETURN 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 END SUB
Function map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!) Function map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
@ -7670,7 +7689,15 @@ SUB showvWatchPanel (this AS vWatchPanelType, currentScope$, totalVisibleVariabl
END IF END IF
item$ = thisName$ + SPACE$(longestVarName - LEN(thisName$)) + " = " item$ = thisName$ + SPACE$(longestVarName - LEN(thisName$)) + " = "
IF usedVariableList(tempIndex&).subfunc = currentScope$ OR usedVariableList(tempIndex&).subfunc = "" THEN 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 COLOR fg
ELSE ELSE
item$ = item$ + "<out of scope>" item$ = item$ + "<out of scope>"
@ -7963,6 +7990,7 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction)
(IdeDebugMode > 0 AND focus = 6 AND info <> 0) THEN (IdeDebugMode > 0 AND focus = 6 AND info <> 0) THEN
variableWatchList$ = "" variableWatchList$ = ""
longestVarName = 0 longestVarName = 0
nextvWatchArraySlot = 0
FOR y = 1 TO totalVariablesCreated FOR y = 1 TO totalVariablesCreated
IF usedVariableList(y).watch THEN IF usedVariableList(y).watch THEN
thisLen = LEN(usedVariableList(y).name) thisLen = LEN(usedVariableList(y).name)
@ -7979,6 +8007,12 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction)
temp$ = usedVariableList(y).indexes temp$ = usedVariableList(y).indexes
DO WHILE LEN(temp$) DO WHILE LEN(temp$)
variableWatchList$ = variableWatchList$ + MKL$(y) + LEFT$(temp$, 4) 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) temp$ = MID$(temp$, 5)
LOOP LOOP
ELSE ELSE

View file

@ -112,7 +112,7 @@ TYPE usedVarList
AS LONG id, linenumber, includeLevel, includedLine, scope, localIndex, strLength AS LONG id, linenumber, includeLevel, includedLine, scope, localIndex, strLength
AS _BYTE used, watch, isarray AS _BYTE used, watch, isarray
AS STRING name, cname, varType, includedFile, subfunc, mostRecentValue 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 AS _OFFSET baseAddress, address
END TYPE END TYPE
@ -25955,6 +25955,7 @@ SUB manageVariableList (__name$, __cname$, localIndex AS LONG, action AS _BYTE)
usedVariableList(i).used = 0 usedVariableList(i).used = 0
usedVariableList(i).watch = 0 usedVariableList(i).watch = 0
usedVariableList(i).mostRecentValue = "" usedVariableList(i).mostRecentValue = ""
usedVariableList(i).storage = ""
usedVariableList(i).linenumber = linenumber usedVariableList(i).linenumber = linenumber
usedVariableList(i).includeLevel = inclevel usedVariableList(i).includeLevel = inclevel
IF inclevel > 0 THEN IF inclevel > 0 THEN