From 94a0f416ebf654c97169c0e20805dd2c738d7bc4 Mon Sep 17 00:00:00 2001 From: aldelaro5 Date: Fri, 1 Oct 2021 09:56:26 -0400 Subject: [PATCH] GDBStub: remove the cmake option and the ifdefs --- CMakeLists.txt | 5 ----- Source/Core/Core/CMakeLists.txt | 9 ++------- Source/Core/Core/ConfigManager.cpp | 6 ------ Source/Core/Core/ConfigManager.h | 2 -- Source/Core/Core/Core.cpp | 10 +--------- Source/Core/Core/HW/CPU.cpp | 7 +------ Source/Core/Core/PowerPC/GDBStub.h | 4 ---- Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp | 10 +++------- Source/Core/Core/PowerPC/MMU.cpp | 10 +++------- Source/Core/Core/PowerPC/PowerPC.cpp | 10 +++------- 10 files changed, 13 insertions(+), 60 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b9f8ae348d..fa45b3fc7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,6 @@ option(ENCODE_FRAMEDUMPS "Encode framedumps in AVI format" ON) option(ENABLE_GPROF "Enable gprof profiling (must be using Debug build)" OFF) option(FASTLOG "Enable all logs" OFF) -option(GDBSTUB "Enable gdb stub for remote debugging." ON) option(OPROFILING "Enable profiling" OFF) # TODO: Add DSPSpy @@ -389,10 +388,6 @@ if(FASTLOG) add_definitions(-DDEBUGFAST) endif() -if(GDBSTUB) - add_definitions(-DUSE_GDBSTUB) -endif() - if(ENABLE_VTUNE) set(VTUNE_DIR "/opt/intel/vtune_amplifier") add_definitions(-DUSE_VTUNE) diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index b22f523811..a06a391c06 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -452,6 +452,8 @@ add_library(core PowerPC/JitCommon/JitCache.h PowerPC/JitInterface.cpp PowerPC/JitInterface.h + PowerPC/GDBStub.cpp + PowerPC/GDBStub.h PowerPC/MMU.cpp PowerPC/MMU.h PowerPC/PowerPC.cpp @@ -698,13 +700,6 @@ if(TARGET Hidapi::Hidapi) target_compile_definitions(core PRIVATE -DHAVE_HIDAPI=1) endif() -if(GDBSTUB) - target_sources(core PRIVATE - PowerPC/GDBStub.cpp - PowerPC/GDBStub.h - ) -endif() - if(UNIX) target_sources(core PRIVATE MemoryWatcher.cpp diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 9eeba47706..9baa710821 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -132,12 +132,10 @@ void SConfig::SaveGeneralSettings(IniFile& ini) general->Set("WirelessMac", m_WirelessMac); -#ifdef USE_GDBSTUB #ifndef _WIN32 general->Set("GDBSocket", gdb_socket); #endif general->Set("GDBPort", iGDBPort); -#endif } void SConfig::SaveInterfaceSettings(IniFile& ini) @@ -371,12 +369,10 @@ void SConfig::LoadGeneralSettings(IniFile& ini) general->Get("ShowLag", &m_ShowLag, false); general->Get("ShowFrameCount", &m_ShowFrameCount, false); -#ifdef USE_GDBSTUB #ifndef _WIN32 general->Get("GDBSocket", &gdb_socket, ""); #endif general->Get("GDBPort", &(iGDBPort), -1); -#endif m_ISOFolder.clear(); int numISOPaths; @@ -733,11 +729,9 @@ void SConfig::LoadDefaults() bAutomaticStart = false; bBootToPause = false; -#ifdef USE_GDBSTUB iGDBPort = -1; #ifndef _WIN32 gdb_socket = ""; -#endif #endif cpu_core = PowerPC::DefaultCPUCore(); diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h index c6d954a398..319cb1b701 100644 --- a/Source/Core/Core/ConfigManager.h +++ b/Source/Core/Core/ConfigManager.h @@ -79,11 +79,9 @@ struct SConfig // Settings bool bEnableDebugging = false; -#ifdef USE_GDBSTUB int iGDBPort; #ifndef _WIN32 std::string gdb_socket; -#endif #endif bool bAutomaticStart = false; bool bBootToPause = false; diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 444e1bb0ba..1537272571 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -62,15 +62,12 @@ #include "Core/NetPlayClient.h" #include "Core/NetPlayProto.h" #include "Core/PatchEngine.h" +#include "Core/PowerPC/GDBStub.h" #include "Core/PowerPC/JitInterface.h" #include "Core/PowerPC/PowerPC.h" #include "Core/State.h" #include "Core/WiiRoot.h" -#ifdef USE_GDBSTUB -#include "Core/PowerPC/GDBStub.h" -#endif - #ifdef USE_MEMORYWATCHER #include "Core/MemoryWatcher.h" #endif @@ -380,7 +377,6 @@ static void CpuThread(const std::optional& savestate_path, bool del { CPUSetInitialExecutionState(); } -#endif // Enter CPU run loop. When we leave it - we are done. CPU::Run(); @@ -394,14 +390,12 @@ static void CpuThread(const std::optional& savestate_path, bool del if (_CoreParameter.bFastmem) EMM::UninstallExceptionHandler(); -#ifdef USE_GDBSTUB if (gdb_active()) { gdb_deinit(); INFO_LOG_FMT(GDB_STUB, "Killed by CPU shutdown"); return; } -#endif } static void FifoPlayerThread(const std::optional& savestate_path, @@ -662,11 +656,9 @@ static void EmuThread(std::unique_ptr boot, WindowSystemInfo wsi cpuThreadFunc(savestate_path, delete_savestate); } -#ifdef USE_GDBSTUB INFO_LOG_FMT(CONSOLE, "{}", StopMessage(true, "Stopping GDB ...")); gdb_deinit(); INFO_LOG_FMT(CONSOLE, "{}", StopMessage(true, "GDB stopped.")); -#endif } // Set or get the running state diff --git a/Source/Core/Core/HW/CPU.cpp b/Source/Core/Core/HW/CPU.cpp index 3e09340046..d64c1e5c90 100644 --- a/Source/Core/Core/HW/CPU.cpp +++ b/Source/Core/Core/HW/CPU.cpp @@ -12,13 +12,10 @@ #include "Common/Event.h" #include "Core/Core.h" #include "Core/Host.h" +#include "Core/PowerPC/GDBStub.h" #include "Core/PowerPC/PowerPC.h" #include "VideoCommon/Fifo.h" -#ifdef USE_GDBSTUB -#include "Core/PowerPC/GDBStub.h" -#endif - namespace CPU { // CPU Thread execution state. @@ -135,7 +132,6 @@ void Run() // Wait for step command. s_state_cpu_cvar.wait(state_lock, [&state_lock] { ExecutePendingJobs(state_lock); -#ifdef USE_GDBSTUB state_lock.unlock(); if (gdb_active() && gdb_hasControl()) { @@ -146,7 +142,6 @@ void Run() s_state_cpu_step_instruction = true; } state_lock.lock(); -#endif return s_state_cpu_step_instruction || !IsStepping(); }); if (!IsStepping()) diff --git a/Source/Core/Core/PowerPC/GDBStub.h b/Source/Core/Core/PowerPC/GDBStub.h index db7212422e..56bfa35d14 100644 --- a/Source/Core/Core/PowerPC/GDBStub.h +++ b/Source/Core/Core/PowerPC/GDBStub.h @@ -8,10 +8,6 @@ #include "Common/CommonTypes.h" #include "Core/CoreTiming.h" -#ifndef MSG_WAITALL -#define MSG_WAITALL (8) -#endif - typedef enum { GDB_SIGTRAP = 5, diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp index 2ff486566f..453097f016 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp @@ -20,15 +20,12 @@ #include "Core/HLE/HLE.h" #include "Core/HW/CPU.h" #include "Core/Host.h" +#include "Core/PowerPC/GDBStub.h" #include "Core/PowerPC/Interpreter/ExceptionUtils.h" #include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCTables.h" #include "Core/PowerPC/PowerPC.h" -#ifdef USE_GDBSTUB -#include "Core/PowerPC/GDBStub.h" -#endif - namespace { u32 last_pc; @@ -296,9 +293,8 @@ void Interpreter::Run() #endif INFO_LOG_FMT(POWERPC, "Hit Breakpoint - {:08x}", PC); CPU::Break(); -#ifdef USE_GDBSTUB - gdb_takeControl(); -#endif + if (gdb_active()) + gdb_takeControl(); if (PowerPC::breakpoints.IsTempBreakPoint(PC)) PowerPC::breakpoints.Remove(PC); diff --git a/Source/Core/Core/PowerPC/MMU.cpp b/Source/Core/Core/PowerPC/MMU.cpp index 028bdef9a9..a027720a4f 100644 --- a/Source/Core/Core/PowerPC/MMU.cpp +++ b/Source/Core/Core/PowerPC/MMU.cpp @@ -19,15 +19,12 @@ #include "Core/HW/MMIO.h" #include "Core/HW/Memmap.h" #include "Core/HW/ProcessorInterface.h" +#include "Core/PowerPC/GDBStub.h" #include "Core/PowerPC/JitInterface.h" #include "Core/PowerPC/PowerPC.h" #include "VideoCommon/VideoBackendBase.h" -#ifdef USE_GDBSTUB -#include "Core/PowerPC/GDBStub.h" -#endif - namespace PowerPC { // EFB RE @@ -522,9 +519,8 @@ static void Memcheck(u32 address, u64 var, bool write, size_t size) CPU::Break(); -#ifdef USE_GDBSTUB - gdb_takeControl(); -#endif + if (gdb_active()) + gdb_takeControl(); // Fake a DSI so that all the code that tests for it in order to skip // the rest of the instruction will apply. (This means that diff --git a/Source/Core/Core/PowerPC/PowerPC.cpp b/Source/Core/Core/PowerPC/PowerPC.cpp index ab3fde08c3..d124643560 100644 --- a/Source/Core/Core/PowerPC/PowerPC.cpp +++ b/Source/Core/Core/PowerPC/PowerPC.cpp @@ -25,15 +25,12 @@ #include "Core/HW/SystemTimers.h" #include "Core/Host.h" #include "Core/PowerPC/CPUCoreBase.h" +#include "Core/PowerPC/GDBStub.h" #include "Core/PowerPC/Interpreter/Interpreter.h" #include "Core/PowerPC/JitInterface.h" #include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PPCSymbolDB.h" -#ifdef USE_GDBSTUB -#include "Core/PowerPC/GDBStub.h" -#endif - namespace PowerPC { // STATE_TO_SAVE @@ -617,9 +614,8 @@ void CheckBreakPoints() if (PowerPC::breakpoints.IsBreakPointBreakOnHit(PC)) { CPU::Break(); -#ifdef USE_GDBSTUB - gdb_takeControl(); -#endif + if (gdb_active()) + gdb_takeControl(); } if (PowerPC::breakpoints.IsBreakPointLogOnHit(PC)) {