Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #64 - added fallback for VS22 17.11+ in GetPointer #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions solution/GraphicalDebugging/Debugger.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using EnvDTE;
using EnvDTE;
using Microsoft.VisualStudio.Shell;

namespace GraphicalDebugging
Expand Down Expand Up @@ -108,14 +108,21 @@ public bool GetPointerOffset(string pointerName1, string pointerName2, out long
// Returns false if address cannot be loaded, parsed or if it is equal to 0
public bool GetPointer(string pointerName, out ulong result)
{
var genericPtrExpr = debugger.GetExpression("(void*)(" + pointerName + ")");
if (genericPtrExpr.IsValidValue)
{
return Util.TryParseULong(genericPtrExpr.Value, out result) && result != 0;
}

// fallback for c#
var elementPtrExpr = debugger.GetExpression(pointerName);
if (elementPtrExpr.IsValidValue)
{
return Util.TryParseULong(elementPtrExpr.Value, out result) && result != 0;
}

result = 0;
var ptrExpr = debugger.GetExpression("(void*)(" + pointerName + ")");
return ptrExpr.IsValidValue
// NOTE: Hexadecimal value is automatically detected, this is probably not needed.
// But automatically detect the format just in case of various versions
// of VS displayed it differently regardless of debugger mode.
&& Util.TryParseULong(ptrExpr.Value/*, true*/, out result)
&& result != 0;
return false;
}

// Address of variable
Expand Down