mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Started gdb stub support.
This commit is contained in:
@@ -222,6 +222,12 @@ if(FASTLOG)
|
||||
add_definitions(-DDEBUGFAST)
|
||||
endif()
|
||||
|
||||
|
||||
option(GDBSTUB "Enable gdb stub for remote debugging." OFF)
|
||||
if(GDBSTUB)
|
||||
add_definitions(-DUSE_GDBSTUB)
|
||||
endif(GDBSTUB)
|
||||
|
||||
# For now GLES and EGL are tied to each other.
|
||||
# Enabling GLES also disables the OpenGL plugin.
|
||||
option(USE_GLES "Enables GLES, disables OGL" OFF)
|
||||
|
||||
@@ -44,6 +44,7 @@ enum LOG_TYPE {
|
||||
DVDINTERFACE,
|
||||
DYNA_REC,
|
||||
EXPANSIONINTERFACE,
|
||||
GDB_STUB,
|
||||
POWERPC,
|
||||
GPFIFO,
|
||||
OSHLE,
|
||||
|
||||
@@ -57,6 +57,7 @@ LogManager::LogManager()
|
||||
m_Log[LogTypes::DVDINTERFACE] = new LogContainer("DVD", "DVDInterface");
|
||||
m_Log[LogTypes::GPFIFO] = new LogContainer("GP", "GPFifo");
|
||||
m_Log[LogTypes::EXPANSIONINTERFACE] = new LogContainer("EXI", "ExpansionInt");
|
||||
m_Log[LogTypes::GDB_STUB] = new LogContainer("GDB_STUB", "GDB Stub");
|
||||
m_Log[LogTypes::AUDIO_INTERFACE] = new LogContainer("AI", "AudioInt");
|
||||
m_Log[LogTypes::POWERPC] = new LogContainer("PowerPC", "IBM CPU");
|
||||
m_Log[LogTypes::OSHLE] = new LogContainer("HLE", "HLE");
|
||||
|
||||
@@ -222,5 +222,9 @@ if(OPROFILE_FOUND)
|
||||
set(LIBS ${LIBS} opagent bfd)
|
||||
endif(OPROFILE_FOUND)
|
||||
|
||||
if(GDBSTUB)
|
||||
set(SRCS ${SRCS} Src/PowerPC/GDBStub.cpp)
|
||||
endif(GDBSTUB)
|
||||
|
||||
add_library(core STATIC ${SRCS})
|
||||
target_link_libraries(core ${LIBS})
|
||||
|
||||
@@ -157,6 +157,7 @@ void SConfig::SaveSettings()
|
||||
ini.Set("General", "RecursiveGCMPaths", m_RecursiveISOFolder);
|
||||
ini.Set("General", "NANDRoot", m_NANDPath);
|
||||
ini.Set("General", "WirelessMac", m_WirelessMac);
|
||||
ini.Set("General", "GDBPort", m_LocalCoreStartupParameter.iGDBPort);
|
||||
|
||||
// Interface
|
||||
ini.Set("Interface", "ConfirmStop", m_LocalCoreStartupParameter.bConfirmStop);
|
||||
@@ -270,6 +271,9 @@ void SConfig::LoadSettings()
|
||||
{
|
||||
ini.Get("General", "LastFilename", &m_LastFilename);
|
||||
ini.Get("General", "ShowLag", &m_ShowLag, false);
|
||||
#ifdef USE_GDBSTUB
|
||||
ini.Get("General", "GDBPort", &(m_LocalCoreStartupParameter.iGDBPort), -1);
|
||||
#endif
|
||||
|
||||
m_ISOFolder.clear();
|
||||
int numGCMPaths;
|
||||
|
||||
@@ -55,6 +55,9 @@
|
||||
|
||||
#include "PowerPC/PowerPC.h"
|
||||
#include "PowerPC/JitCommon/JitBase.h"
|
||||
#ifdef USE_GDBSTUB
|
||||
#include "PowerPC/GDBStub.h"
|
||||
#endif
|
||||
|
||||
#include "DSPEmulator.h"
|
||||
#include "ConfigManager.h"
|
||||
@@ -101,6 +104,9 @@ std::string g_stateFileName;
|
||||
std::thread g_EmuThread;
|
||||
|
||||
static std::thread g_cpu_thread;
|
||||
#ifdef USE_GDBSTUB
|
||||
static std::thread g_gdb_thread;
|
||||
#endif
|
||||
static bool g_requestRefreshInfo = false;
|
||||
static int g_pauseAndLockDepth = 0;
|
||||
|
||||
@@ -448,6 +454,20 @@ void EmuThread()
|
||||
else
|
||||
cpuThreadFunc = CpuThread;
|
||||
|
||||
#ifdef USE_GDBSTUB
|
||||
if(_CoreParameter.iGDBPort > 0)
|
||||
{
|
||||
INFO_LOG(GDB_STUB, "Trying to start the GDB Stub listening on port %d.", _CoreParameter.iGDBPort);
|
||||
Core::SetState(Core::CORE_PAUSE);
|
||||
gdb_init(_CoreParameter.iGDBPort);
|
||||
|
||||
g_gdb_thread = std::thread(gdb_thread);
|
||||
|
||||
//gdb_signal(SIGTRAP);
|
||||
gdb_add_bp(GDB_BP_TYPE_X, 0x80004050, 4);
|
||||
}
|
||||
#endif
|
||||
|
||||
// ENTER THE VIDEO THREAD LOOP
|
||||
if (_CoreParameter.bCPUThread)
|
||||
{
|
||||
@@ -491,6 +511,14 @@ void EmuThread()
|
||||
g_cpu_thread.join();
|
||||
|
||||
INFO_LOG(CONSOLE, "%s", StopMessage(true, "CPU thread stopped.").c_str());
|
||||
|
||||
#ifdef USE_GDBSTUB
|
||||
// Wait for g_gdb_thread to exit
|
||||
INFO_LOG(CONSOLE, "%s", StopMessage(true, "Stopping GDB thread ...").c_str());
|
||||
gdb_deinit();
|
||||
g_gdb_thread.join();
|
||||
INFO_LOG(CONSOLE, "%s", StopMessage(true, "GDB thread stopped.").c_str());
|
||||
#endif
|
||||
|
||||
VolumeHandler::EjectVolume();
|
||||
FileMon::Close();
|
||||
|
||||
@@ -68,6 +68,9 @@ SCoreStartupParameter::SCoreStartupParameter()
|
||||
void SCoreStartupParameter::LoadDefaults()
|
||||
{
|
||||
bEnableDebugging = false;
|
||||
#ifdef USE_GDBSTUB
|
||||
iGDBPort = -1;
|
||||
#endif
|
||||
iCPUCore = 1;
|
||||
bCPUThread = false;
|
||||
bSkipIdle = false;
|
||||
|
||||
@@ -71,6 +71,9 @@ struct SCoreStartupParameter
|
||||
|
||||
// Settings
|
||||
bool bEnableDebugging;
|
||||
#ifdef USE_GDBSTUB
|
||||
int iGDBPort;
|
||||
#endif
|
||||
bool bAutomaticStart;
|
||||
bool bBootToPause;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,61 @@
|
||||
// Copyright (C) 2010 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
// Originally written by Sven Peter <sven@fail0verflow.com> for anergistic.
|
||||
|
||||
#ifndef GDB_H__
|
||||
#define GDB_H__
|
||||
|
||||
#include <signal.h>
|
||||
#include "Common.h"
|
||||
#include "Thread.h"
|
||||
#include "PowerPC.h"
|
||||
#include "../HW/CPU.h"
|
||||
#include "../HW/Memmap.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define SIGTRAP 5
|
||||
#define SIGTERM 15
|
||||
#define MSG_WAITALL 8
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
GDB_BP_TYPE_NONE = 0,
|
||||
GDB_BP_TYPE_X,
|
||||
GDB_BP_TYPE_R,
|
||||
GDB_BP_TYPE_W,
|
||||
GDB_BP_TYPE_A
|
||||
} gdb_bp_type;
|
||||
|
||||
void gdb_init(u32 port);
|
||||
void gdb_deinit();
|
||||
bool gdb_active();
|
||||
|
||||
void gdb_thread();
|
||||
void gdb_handle_events();
|
||||
int gdb_signal(u32 signal);
|
||||
|
||||
int gdb_bp_x(u32 addr);
|
||||
int gdb_bp_r(u32 addr);
|
||||
int gdb_bp_w(u32 addr);
|
||||
int gdb_bp_a(u32 addr);
|
||||
|
||||
bool gdb_add_bp(u32 type, u32 addr, u32 len);
|
||||
|
||||
static Common::Event m_GdbWaitEvent;
|
||||
|
||||
#endif
|
||||
@@ -27,6 +27,10 @@
|
||||
#include "../../IPC_HLE/WII_IPC_HLE.h"
|
||||
#include "Atomic.h"
|
||||
|
||||
#ifdef USE_GDBSTUB
|
||||
#include "../GDBStub.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace {
|
||||
u32 last_pc;
|
||||
@@ -99,7 +103,18 @@ void Trace( UGeckoInstruction &instCode )
|
||||
int Interpreter::SingleStepInner(void)
|
||||
{
|
||||
static UGeckoInstruction instCode;
|
||||
|
||||
|
||||
#ifdef USE_GDBSTUB
|
||||
if (gdb_active() && gdb_bp_x(PC)) {
|
||||
|
||||
Host_UpdateDisasmDialog();
|
||||
|
||||
gdb_signal(SIGTRAP);
|
||||
gdb_handle_events();
|
||||
m_GdbWaitEvent.Wait();
|
||||
}
|
||||
#endif
|
||||
|
||||
NPC = PC + sizeof(UGeckoInstruction);
|
||||
instCode.hex = Memory::Read_Opcode(PC);
|
||||
|
||||
@@ -218,7 +233,8 @@ void Interpreter::Run()
|
||||
if (PCVec.size() > ShowSteps)
|
||||
PCVec.erase(PCVec.begin());
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//2: check for breakpoint
|
||||
if (PowerPC::breakpoints.IsAddressBreakPoint(PC))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user