Don't expose a memory reference for non-pointer evaluation results#1601
Open
tieo wants to merge 1 commit into
Open
Don't expose a memory reference for non-pointer evaluation results#1601tieo wants to merge 1 commit into
tieo wants to merge 1 commit into
Conversation
AD7Property.GetMemoryContext interpreted the evaluation result's display value as a memory address for every type. For a pointer this is correct (the value is an address), but for a scalar such as a uint32_t whose value is 1, the value 1 was returned as the memory reference, so the data-tip memory icon navigated to address 0x1. Only treat the value as an address when the result is a pointer (or an array, which already re-evaluates to its address below); otherwise return S_GETMEMORYCONTEXT_NO_MEMORY_CONTEXT so no memoryReference is reported.
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
In a debug data-tip (or the Variables view), hovering a non-pointer scalar shows the value correctly but attaches a
memoryReference, so VS Code renders the "view binary data" hex icon and clicking it navigates to an address equal to the value. For example, hovering auint32_t stsdigwhose value is1offers a memory view that opens at address0x1.Cause
AD7Property.GetMemoryContext(src/MIDebugEngine/AD7.Impl/AD7Property.cs) tries to interpret the result's display value as a memory address, for every type:For a pointer this is correct — the value is an address (
0x...). For a plain scalar (e.g.int/uint32_t) the value is a number, not an address, soUInt64.TryParse("1")succeeds and the memory reference becomes0x1. OpenDebugAD7 then reports that asmemoryReferenceon theevaluate/variablesresponse, and VS Code's memory navigation goes to address1.Fix
Only treat the value as an address when the result is a pointer (or an array, which already re-evaluates to its address with
&(...)further down). For any other type, returnS_GETMEMORYCONTEXT_NO_MEMORY_CONTEXTso nomemoryReferenceis reported and no spurious memory icon/navigation appears.TypeNameis already onIVariableInformation, and the sameEndsWith("*")pointer test is used elsewhere inVariables.cs(IsPointer).Testing
Built the patched engine and ran it against a live
cppdbg/gdb session:int32_t *,const uint32_t *) — still shows its address and the memory icon, unchanged.uint32_t) — now shows just the value, with no memory icon and no navigation to0x<value>.&(...)path).Note: the change was written with the help of an LLM and verified manually in VS Code against a real gdb target.