Merge pull request #19628 from hrydgard/assorted-debugger-fixes
Some checks failed
Build / build-windows (ARM64) (push) Has been cancelled
Build / build-windows (x64) (push) Has been cancelled
Build / build-uwp (push) Has been cancelled
Build / build (./b.sh --headless --unittest --fat --no-png --no-sdl2, clang, clang++, test, macos, macos-latest) (push) Has been cancelled
Build / build (./b.sh --headless --unittest, clang, clang++, test, clang-normal, ubuntu-latest) (push) Has been cancelled
Build / build (./b.sh --headless --unittest, gcc, g++, gcc-normal, ubuntu-latest) (push) Has been cancelled
Build / build (./b.sh --ios, clang, clang++, ios, ios, macos-latest) (push) Has been cancelled
Build / build (./b.sh --libretro_android ppsspp_libretro, clang, clang++, android, android-libretro, ubuntu-latest) (push) Has been cancelled
Build / build (./b.sh --qt, gcc, g++, qt, qt, ubuntu-latest) (push) Has been cancelled
Build / build (cd android && ./ab.sh -j2 APP_ABI=arm64-v8a OPENXR=1, clang, clang++, android, android-vr, ubuntu-latest) (push) Has been cancelled
Build / build (cd android && ./ab.sh -j2 APP_ABI=arm64-v8a UNITTEST=1 HEADLESS=1, clang, clang++, android, android-arm64, ubuntu-latest) (push) Has been cancelled
Build / build (cd android && ./ab.sh -j2 APP_ABI=armeabi-v7a UNITTEST=1 HEADLESS=1, clang, clang++, android, android-arm32, ubuntu-latest) (push) Has been cancelled
Build / build (cd android && ./ab.sh -j2 APP_ABI=x86_64 UNITTEST=1 HEADLESS=1, clang, clang++, android, android-x86_64, ubuntu-latest) (push) Has been cancelled
Build / build (make -C libretro -f Makefile -j2, clang, clang++, libretro, clang-libretro, ubuntu-latest) (push) Has been cancelled
Build / build (make -C libretro -f Makefile -j2, gcc, g++, libretro, gcc-libretro, ubuntu-latest) (push) Has been cancelled
Build / build_test_headless_alpine (push) Has been cancelled
Generate Docker Layer / build (push) Has been cancelled
Build / test-windows (push) Has been cancelled
Build / test (macos-latest) (push) Has been cancelled
Build / test (ubuntu-latest) (push) Has been cancelled

Assorted debugger fixes
This commit is contained in:
Henrik Rydgård 2024-11-12 13:02:16 +01:00 committed by GitHub
commit 2d96304bad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 61 additions and 41 deletions

View File

@ -206,6 +206,7 @@ static const ConfigSetting generalSettings[] = {
ConfigSetting("IgnoreBadMemAccess", &g_Config.bIgnoreBadMemAccess, true, CfgFlag::DEFAULT),
ConfigSetting("CurrentDirectory", &g_Config.currentDirectory, "", CfgFlag::DEFAULT),
ConfigSetting("ShowDebuggerOnLoad", &g_Config.bShowDebuggerOnLoad, false, CfgFlag::DEFAULT),
ConfigSetting("ShowImDebugger", &g_Config.bShowImDebugger, false, CfgFlag::DONT_SAVE),
ConfigSetting("CheckForNewVersion", &g_Config.bCheckForNewVersion, true, CfgFlag::DEFAULT),
ConfigSetting("Language", &g_Config.sLanguageIni, &DefaultLangRegion, CfgFlag::DEFAULT),
ConfigSetting("ForceLagSync2", &g_Config.bForceLagSync, false, CfgFlag::PER_GAME),

View File

@ -190,6 +190,8 @@ public:
bool bIgnoreScreenInsets; // Android: Center screen disregarding insets if this is enabled.
bool bVSync;
bool bShowImDebugger;
int iFrameSkip;
int iFrameSkipType;
int iFastForwardMode; // See FastForwardMode in ConfigValues.h.

View File

@ -415,13 +415,18 @@ bool Core_Run(GraphicsContext *ctx) {
// Free-threaded (hm, possibly except tracing).
void Core_Break(const char *reason, u32 relatedAddress) {
// Stop the tracer
mipsTracer.stop_tracing();
{
std::lock_guard<std::mutex> lock(g_stepMutex);
if (!g_stepCommand.empty()) {
// Already broke.
ERROR_LOG(Log::CPU, "Core_Break called with a break already in progress: %s", g_stepCommand.reason);
return;
}
mipsTracer.stop_tracing();
g_stepCommand.reason = reason;
g_stepCommand.relatedAddr = relatedAddress;
steppingCounter++;
_assert_msg_(reason != nullptr, "No reason specified for break");
Core_UpdateState(CORE_STEPPING);
}
System_Notify(SystemNotification::DEBUG_MODE_CHANGE);

View File

@ -33,8 +33,10 @@ struct CPUSteppingEvent {
j.writeUint("pc", currentMIPS->pc);
// A double ought to be good enough for a 156 day debug session.
j.writeFloat("ticks", CoreTiming::GetTicks());
j.writeString("reason", reason_.reason);
j.writeUint("relatedAddress", reason_.relatedAddress);
if (reason_.reason) {
j.writeString("reason", reason_.reason);
j.writeUint("relatedAddress", reason_.relatedAddress);
}
j.end();
return j.str();
}

View File

@ -17,6 +17,7 @@
#include <thread>
#include "Core/Core.h"
#include "Common/Data/Encoding/Utf8.h"
#include "Common/Thread/ThreadUtil.h"
#include "Common/System/Request.h"
@ -324,7 +325,11 @@ bool Load_PSP_ISO(FileLoader *fileLoader, std::string *error_string) {
// TODO: We can't use the initial error_string pointer.
bool success = __KernelLoadExec(bootpath.c_str(), 0, &PSP_CoreParameter().errorString);
if (success && coreState == CORE_POWERUP) {
coreState = PSP_CoreParameter().startBreak ? CORE_STEPPING : CORE_RUNNING;
if (PSP_CoreParameter().startBreak) {
Core_Break("start-break");
} else {
coreState = CORE_RUNNING;
}
} else {
coreState = CORE_BOOT_ERROR;
// TODO: This is a crummy way to communicate the error...
@ -483,7 +488,11 @@ bool Load_PSP_ELF_PBP(FileLoader *fileLoader, std::string *error_string) {
bool success = __KernelLoadExec(finalName.c_str(), 0, &PSP_CoreParameter().errorString);
if (success && coreState == CORE_POWERUP) {
coreState = PSP_CoreParameter().startBreak ? CORE_STEPPING : CORE_RUNNING;
if (PSP_CoreParameter().startBreak) {
Core_Break("start-break");
} else {
coreState = CORE_RUNNING;
}
} else {
coreState = CORE_BOOT_ERROR;
// TODO: This is a crummy way to communicate the error...
@ -509,7 +518,11 @@ bool Load_PSP_GE_Dump(FileLoader *fileLoader, std::string *error_string) {
bool success = __KernelLoadGEDump("disc0:/data.ppdmp", &PSP_CoreParameter().errorString);
if (success && coreState == CORE_POWERUP) {
coreState = PSP_CoreParameter().startBreak ? CORE_STEPPING : CORE_RUNNING;
if (PSP_CoreParameter().startBreak) {
Core_Break("start-break");
} else {
coreState = CORE_RUNNING;
}
} else {
coreState = CORE_BOOT_ERROR;
// TODO: This is a crummy way to communicate the error...

View File

@ -656,7 +656,7 @@ bool EmuScreen::UnsyncTouch(const TouchInput &touch) {
}
}
if (!(imguiVisible_ && imguiInited_)) {
if (!(g_Config.bShowImDebugger && imguiInited_)) {
GamepadTouch();
}
@ -673,7 +673,7 @@ void EmuScreen::onVKey(int virtualKeyCode, bool down) {
switch (virtualKeyCode) {
case VIRTKEY_TOGGLE_DEBUGGER:
if (down) {
imguiVisible_ = !imguiVisible_;
g_Config.bShowImDebugger = !g_Config.bShowImDebugger;
}
break;
case VIRTKEY_FASTFORWARD:
@ -952,10 +952,10 @@ void EmuScreen::onVKeyAnalog(int virtualKeyCode, float value) {
bool EmuScreen::UnsyncKey(const KeyInput &key) {
System_Notify(SystemNotification::ACTIVITY);
if (UI::IsFocusMovementEnabled() || (imguiVisible_ && imguiInited_)) {
if (UI::IsFocusMovementEnabled() || (g_Config.bShowImDebugger && imguiInited_)) {
// Note: Allow some Vkeys through, so we can toggle the imgui for example (since we actually block the control mapper otherwise in imgui mode).
// We need to manually implement it here :/
if (imguiVisible_ && imguiInited_ && (key.flags & (KEY_UP | KEY_DOWN))) {
if (g_Config.bShowImDebugger && imguiInited_ && (key.flags & (KEY_UP | KEY_DOWN))) {
InputMapping mapping(key.deviceId, key.keyCode);
std::vector<int> pspButtons;
bool mappingFound = KeyMap::InputMappingToPspButton(mapping, &pspButtons);
@ -976,7 +976,7 @@ bool EmuScreen::UnsyncKey(const KeyInput &key) {
bool EmuScreen::key(const KeyInput &key) {
bool retval = UIScreen::key(key);
if (!retval && imguiVisible_ && imguiInited_) {
if (!retval && g_Config.bShowImDebugger && imguiInited_) {
ImGui_ImplPlatform_KeyEvent(key);
}
@ -993,7 +993,7 @@ bool EmuScreen::key(const KeyInput &key) {
}
void EmuScreen::touch(const TouchInput &touch) {
if (imguiVisible_ && imguiInited_) {
if (g_Config.bShowImDebugger && imguiInited_) {
ImGui_ImplPlatform_TouchEvent(touch);
} else {
UIScreen::touch(touch);
@ -1637,23 +1637,25 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) {
darken();
}
if (imguiVisible_ && !imguiInited_) {
imguiInited_ = true;
imDebugger_ = std::make_unique<ImDebugger>();
ImGui_ImplThin3d_Init(draw);
}
if (g_Config.bShowImDebugger) {
if (!imguiInited_) {
imguiInited_ = true;
imDebugger_ = std::make_unique<ImDebugger>();
ImGui_ImplThin3d_Init(draw);
}
if (imguiVisible_ && imguiInited_ && PSP_IsInited()) {
_dbg_assert_(imDebugger_);
if (PSP_IsInited()) {
_dbg_assert_(imDebugger_);
ImGui_ImplPlatform_NewFrame();
ImGui_ImplThin3d_NewFrame(draw, ui_draw2d.GetDrawMatrix());
ImGui_ImplPlatform_NewFrame();
ImGui_ImplThin3d_NewFrame(draw, ui_draw2d.GetDrawMatrix());
ImGui::NewFrame();
imDebugger_->Frame(currentDebugMIPS);
ImGui::NewFrame();
imDebugger_->Frame(currentDebugMIPS);
ImGui::Render();
ImGui_ImplThin3d_RenderDrawData(ImGui::GetDrawData(), draw);
ImGui::Render();
ImGui_ImplThin3d_RenderDrawData(ImGui::GetDrawData(), draw);
}
}
return flags;
}

View File

@ -134,5 +134,4 @@ private:
std::unique_ptr<ImDebugger> imDebugger_ = nullptr;
bool imguiInited_ = false;
bool imguiVisible_ = false;
};

View File

@ -641,20 +641,20 @@ namespace MainWindow
SetCapture(hWnd);
// Simulate doubleclick, doesn't work with RawInput enabled
static double lastMouseDown;
static double lastMouseDownTime;
static float lastMouseDownX = -1.0f;
static float lastMouseDownY = -1.0f;
double now = time_now_d();
if ((now - lastMouseDown) < 0.001 * GetDoubleClickTime()) {
float dx = lastMouseDownX - x;
float dy = lastMouseDownY - y;
float distSq = dx * dx + dy * dy;
if (distSq < 3.0f*3.0f && !g_Config.bShowTouchControls && !g_Config.bMouseControl && GetUIState() == UISTATE_INGAME && g_Config.bFullscreenOnDoubleclick) {
const double now = time_now_d();
if ((now - lastMouseDownTime) < 0.001 * GetDoubleClickTime()) {
const float dx = lastMouseDownX - x;
const float dy = lastMouseDownY - y;
const float distSq = dx * dx + dy * dy;
if (distSq < 3.0f*3.0f && !g_Config.bShowTouchControls && !g_Config.bShowImDebugger && !g_Config.bMouseControl && GetUIState() == UISTATE_INGAME && g_Config.bFullscreenOnDoubleclick) {
SendToggleFullscreen(!g_Config.UseFullScreen());
}
lastMouseDown = 0.0;
lastMouseDownTime = 0.0;
} else {
lastMouseDown = now;
lastMouseDownTime = now;
}
lastMouseDownX = x;
lastMouseDownY = y;

View File

@ -24,8 +24,6 @@ void ImGui_ImplPlatform_KeyEvent(const KeyInput &key) {
ImGuiKey keyCode = KeyCodeToImGui(key.keyCode);
if (keyCode != ImGuiKey_None) {
io.AddKeyEvent(keyCode, true);
} else {
WARN_LOG(Log::System, "KeyDown: Unmapped ImGui keycode conversion from %d", key.keyCode);
}
break;
}
@ -35,8 +33,6 @@ void ImGui_ImplPlatform_KeyEvent(const KeyInput &key) {
ImGuiKey keyCode = KeyCodeToImGui(key.keyCode);
if (keyCode != ImGuiKey_None) {
io.AddKeyEvent(keyCode, false);
} else {
WARN_LOG(Log::System, "KeyUp: Unmapped ImGui keycode conversion from %d", key.keyCode);
}
}
if (key.flags & KEY_CHAR) {