From ac67046afc278dfb6dea1d3ac08ff956d7ae1280 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Wed, 20 Nov 2024 11:32:56 -0500 Subject: [PATCH] Fixed IDE "Find on Stack" functionality --- BeefLibs/corlib/src/Int.bf | 7 ++++--- BeefLibs/corlib/src/UInt.bf | 7 ++++--- IDE/src/ui/HoverWatch.bf | 4 ++++ IDE/src/ui/WatchPanel.bf | 5 +++-- IDEHelper/WinDebugger.cpp | 6 ++++++ 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/BeefLibs/corlib/src/Int.bf b/BeefLibs/corlib/src/Int.bf index 8954acba..96698ed3 100644 --- a/BeefLibs/corlib/src/Int.bf +++ b/BeefLibs/corlib/src/Int.bf @@ -1,4 +1,5 @@ using System; +using System.Globalization; namespace System { @@ -95,16 +96,16 @@ namespace System } } - public static Result Parse(StringView val) + public static Result Parse(StringView val, NumberStyles style = .Number, CultureInfo cultureInfo = null) { if (sizeof(Self) == sizeof(int64)) { - var result = Int64.Parse(val); + var result = Int64.Parse(val, style, cultureInfo); return *(Result*)&result; } else { - var result = Int32.Parse(val); + var result = Int32.Parse(val, style, cultureInfo); return *(Result*)&result; } } diff --git a/BeefLibs/corlib/src/UInt.bf b/BeefLibs/corlib/src/UInt.bf index 4e43f5da..91c9313c 100644 --- a/BeefLibs/corlib/src/UInt.bf +++ b/BeefLibs/corlib/src/UInt.bf @@ -1,3 +1,4 @@ +using System.Globalization; namespace System { #unwarn @@ -85,16 +86,16 @@ namespace System ((uint32)this).ToString(outString, format, formatProvider); } - public static Result Parse(StringView val) + public static Result Parse(StringView val, NumberStyles style = .Number, CultureInfo cultureInfo = null) { if (sizeof(Self) == sizeof(uint64)) { - var result = UInt64.Parse(val); + var result = Int64.Parse(val, style, cultureInfo); return *(Result*)&result; } else { - var result = UInt32.Parse(val); + var result = Int32.Parse(val, style, cultureInfo); return *(Result*)&result; } } diff --git a/IDE/src/ui/HoverWatch.bf b/IDE/src/ui/HoverWatch.bf index c85f9fe3..b7cd9ac8 100644 --- a/IDE/src/ui/HoverWatch.bf +++ b/IDE/src/ui/HoverWatch.bf @@ -879,6 +879,10 @@ namespace IDE.ui { String.NewOrSet!(watch.mEditInitialize, scope String(memberVals[1])); } + else if (memberVals0 == ":pointer") + { + String.NewOrSet!(watch.mPointer, scope String(memberVals[1])); + } else if (memberVals0 == ":break") { watch.mMemoryBreakpointAddr = (int)Int64.Parse(memberVals[1], .HexNumber); diff --git a/IDE/src/ui/WatchPanel.bf b/IDE/src/ui/WatchPanel.bf index 65205c97..dfd1b387 100644 --- a/IDE/src/ui/WatchPanel.bf +++ b/IDE/src/ui/WatchPanel.bf @@ -47,7 +47,8 @@ namespace IDE.ui public String mAddrValueExpr ~ delete _; public String mPointeeExpr ~ delete _; public bool mCanEdit; - public String mEditInitialize ~ delete _; + public String mPointer ~ delete _; + public String mEditInitialize ~ delete _; public bool mHadValue; public bool mHasValue; public bool mIsNewExpression; @@ -4487,7 +4488,7 @@ namespace IDE.ui if (watchEntry.mResultType.HasFlag(.Pointer)) { - if (int.Parse(watchEntry.mEditInitialize) case .Ok(let addr)) + if (int.Parse(watchEntry.mPointer ?? watchEntry.mEditInitialize, .AllowHexSpecifier) case .Ok(let addr)) { int threadId; gApp.mDebugger.GetStackAllocInfo(addr, out threadId, null); diff --git a/IDEHelper/WinDebugger.cpp b/IDEHelper/WinDebugger.cpp index a4d65b8d..8b3f8d73 100644 --- a/IDEHelper/WinDebugger.cpp +++ b/IDEHelper/WinDebugger.cpp @@ -9723,6 +9723,8 @@ String WinDebugger::EvaluateContinue(DbgPendingExpr* pendingExpr, BfPassInstance underlyingType->IsBfObject() ? "" : "*"); val += EncodeDataPtr(exprResult.mPtr, true); } + + val += "\n:pointer\t" + EncodeDataPtr(exprResult.mPtr, true); } if (val[0] == '!') @@ -9761,6 +9763,10 @@ String WinDebugger::EvaluateContinue(DbgPendingExpr* pendingExpr, BfPassInstance { if (canEdit) val += "\n:canEdit"; + if (exprResult.mType->mTypeCode == DbgType_Ptr) + { + val += "\n:editVal\t" + EncodeDataPtr(exprResult.mPtr, true); + } } } }