Re-evaluate the visualized variable's address on refresh - #518
Open
tiresiasfromthebai wants to merge 1 commit into
Open
Re-evaluate the visualized variable's address on refresh#518tiresiasfromthebai wants to merge 1 commit into
tiresiasfromthebai wants to merge 1 commit into
Conversation
The Array and Matrix visualizers evaluated the variable's address only when the name was typed; every refresh then re-read memory at that stored address forever. A stale address (a vector entered before its construction, a reallocation, a re-run) kept being read — errors at best, plausible-looking dead data at worst. Split the refresh in two: the refresh handlers now re-evaluate the variable name, and the answer reads the memory at the fresh address (readaMemory/readbMemory/readMemory). Every refresh path — the manual button, the auto-refresh at each stop, and the length/offset/stride changes — now goes through the re-evaluation. The read is skipped for a null address or an empty length, so a not-yet-constructed variable shows its 0x0 address quietly instead of raising memory errors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Array and Matrix visualizers evaluate the variable's address only
when the name is typed. Every refresh — the manual button as well as the
auto-refresh at each stop (#496/#498) — then re-reads memory at that
stored address, and never re-evaluates the name. So whenever the
variable's address changes, the plot silently shows stale (or wrong)
memory, and no amount of refreshing heals it:
&pos[0]for astd::vectorbefore it is constructed (e.g.before Run, or at an early breakpoint): the address evaluates to
0x0and is trapped forever — every subsequent stop re-reads address 0 and
pops "Unable to read memory", even though the vector now exists.
visualizer keeps plotting the old buffer — plausible-looking but
dead data, with no error at all.
Fix
Split the refresh in two steps. The refresh handlers now re-evaluate the
variable name, and the
^doneanswer reads the memory at the freshaddress (new
readaMemory()/readbMemory()/readMemory()holding theprevious read logic). Since every refresh path funnels through the same
handlers — the manual Refresh button, the auto-refresh at each stop, and
the length/rows/columns/offset/stride changes — they all pick up the
fresh address now. A nice side effect: re-typing the name while
stopped refreshes the plot immediately, instead of only updating the
address field.
The read step is skipped for a null address or an empty length: a
not-yet-constructed variable now shows its
0x0address quietly and theplot simply appears at the first stop where the variable exists, instead
of raising a memory error at every interaction.
Testing
Qt 6.4.2, Linux Mint. With a 4000-point
std::vectorphase portrait(scatter, Auto checked):
&pos[0]/&vit[0]at an early breakpoint (vectors not yetconstructed), address shows
0x0→ Continue to the fillingbreakpoint, or simply hit Refresh: the address updates and the plot
appears (previously: "Unable to read memory" on every stop and every
refresh, forever).
Continue refresh exactly as before.