From 4d5be7c16ef4d06edf0048c710a2b9ab4b8e5c76 Mon Sep 17 00:00:00 2001 From: Swift Date: Sun, 7 Jun 2026 18:37:48 -0500 Subject: [PATCH] debugger: remove forced hexadecimal formatting when writing values --- src/gui/wxgui/debugger/RegisterWindow.cpp | 36 +++++++++++++++-------- src/gui/wxgui/helpers/wxHelpers.h | 3 ++ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/gui/wxgui/debugger/RegisterWindow.cpp b/src/gui/wxgui/debugger/RegisterWindow.cpp index e8a136b9..cd9aa4d7 100644 --- a/src/gui/wxgui/debugger/RegisterWindow.cpp +++ b/src/gui/wxgui/debugger/RegisterWindow.cpp @@ -1,5 +1,6 @@ #include "wxgui/wxgui.h" #include "wxgui/debugger/RegisterWindow.h" +#include "wxgui/helpers/wxHelpers.h" #include @@ -355,14 +356,17 @@ void RegisterWindow::OnMouseDClickEvent(wxMouseEvent& event) { const uint32 register_index = id - kRegisterValueR0; const uint32 register_value = ppcSnapshot.gpr[register_index]; - wxTextEntryDialog set_value_dialog(this, _("Enter a new value."), wxString::Format(_("Set R%d value"), register_index), wxString::Format("%08x", register_value)); + wxTextEntryDialog set_value_dialog(this, _("Enter a new value."), wxString::Format(_("Set R%d value"), register_index), wxString::Format("0x%08x", register_value)); if (set_value_dialog.ShowModal() == wxID_OK) { - const uint32 new_value = std::stoul(set_value_dialog.GetValue().ToStdString(), nullptr, 16); - if (debugSession = debugger_lockDebugSession(); debugSession) + const std::optional opt = parse_numeric(set_value_dialog.GetValue()); + if (opt.has_value()) { - debugSession->gpr[register_index] = new_value; - debugger_unlockDebugSession(debugSession); + if (debugSession = debugger_lockDebugSession(); debugSession) + { + debugSession->gpr[register_index] = opt.value(); + debugger_unlockDebugSession(debugSession); + } } OnUpdateView(); } @@ -376,11 +380,14 @@ void RegisterWindow::OnMouseDClickEvent(wxMouseEvent& event) wxTextEntryDialog set_value_dialog(this, _("Enter a new value."), wxString::Format(_("Set FP0_%d value"), register_index), wxString::Format("%lf", register_value)); if (set_value_dialog.ShowModal() == wxID_OK) { - const double new_value = std::stod(set_value_dialog.GetValue().ToStdString()); - if (debugSession = debugger_lockDebugSession(); debugSession) + const std::optional opt = parse_numeric(set_value_dialog.GetValue()); + if (opt.has_value()) { - debugSession->fpr[register_index].fp0 = new_value; - debugger_unlockDebugSession(debugSession); + if (debugSession = debugger_lockDebugSession(); debugSession) + { + debugSession->fpr[register_index].fp0 = opt.value(); + debugger_unlockDebugSession(debugSession); + } } OnUpdateView(); } @@ -395,11 +402,14 @@ void RegisterWindow::OnMouseDClickEvent(wxMouseEvent& event) wxTextEntryDialog set_value_dialog(this, _("Enter a new value."), wxString::Format(_("Set FP1_%d value"), register_index), wxString::Format("%lf", register_value)); if (set_value_dialog.ShowModal() == wxID_OK) { - const double new_value = std::stod(set_value_dialog.GetValue().ToStdString()); - if (debugSession = debugger_lockDebugSession(); debugSession) + const std::optional opt = parse_numeric(set_value_dialog.GetValue()); + if (opt.has_value()) { - debugSession->fpr[register_index].fp1 = new_value; - debugger_unlockDebugSession(debugSession); + if (debugSession = debugger_lockDebugSession(); debugSession) + { + debugSession->fpr[register_index].fp1 = opt.value(); + debugger_unlockDebugSession(debugSession); + } } OnUpdateView(); } diff --git a/src/gui/wxgui/helpers/wxHelpers.h b/src/gui/wxgui/helpers/wxHelpers.h index bf030803..489362cc 100644 --- a/src/gui/wxgui/helpers/wxHelpers.h +++ b/src/gui/wxgui/helpers/wxHelpers.h @@ -117,6 +117,9 @@ std::optional parse_numeric(const wxString& text) if (std::is_same::value) return std::stof(text.ToStdString()); + else if (std::is_same::value) + return std::stod(text.ToStdString()); + // it's integral return static_cast(std::stol(text.ToStdString(), nullptr, 0)); }