mirror of
https://github.com/cemu-project/Cemu.git
synced 2026-05-14 15:10:46 -05:00
* Implement GDB stub debugger Can be enabled by using the "--enable-gdbstub" option (and the debugger GUI, although that's untested) which'll pause any game you launch at start-up. Will start at port 1337 although it'll eventually be user-editable. The code is a bit weirdly sorted and also just needs a general cleanup, so expect that eventually too. And uses egyptian braces but formatting was easier to do at the end, so that's also something to do. It has been tested to work with IDA Pro, Clion and the standalone interface for now, but I plan on writing some instructions in the PR to follow for people who want to use this. Memory breakpoints aren't possible yet, only execution breakpoints. This code was aimed to be decoupled from the existing debugger to be able to be ported to the Wii U for an equal debugging experience. That's also why it uses the Cafe OS's thread sleep and resuming functions whenever possible instead of using recompiler/interpreter controls. * Add memory writing and floating point registers support * Reformat code a bit * Format code to adhere to Cemu's coding style * Rework GDB Stub settings in GUI * Small styling fixes * Rework execution breakpoints Should work better in some edge cases now. But this should also allow for adding access breakpoints since it's now more separated. * Implement access breakpoints * Fix some issues with breakpoints * Fix includes for Linux * Fix unnecessary include * Tweaks for Linux compatibility * Use std::thread instead of std::jthread to fix MacOS support * Enable GDB read/write breakpoints on x86 only * Fix compilation for GCC compilers at least The thread type varies on some platforms, so supporting this is hell... but let's get it to compile on MacOS first. * Disable them for MacOS due to lack of ptrace --------- Co-authored-by: Exzap <13877693+Exzap@users.noreply.github.com>
117 lines
3.3 KiB
C++
117 lines
3.3 KiB
C++
#pragma once
|
|
|
|
#include "gui/debugger/DisasmCtrl.h"
|
|
#include "config/XMLConfig.h"
|
|
#include "Cafe/HW/Espresso/Debugger/Debugger.h"
|
|
#include "Cafe/OS/RPL/rpl.h"
|
|
#include "Cafe/HW/Espresso/Debugger/GDBStub.h"
|
|
|
|
#include <wx/bitmap.h>
|
|
#include <wx/frame.h>
|
|
|
|
class BreakpointWindow;
|
|
class RegisterWindow;
|
|
class DumpWindow;
|
|
class ModuleWindow;
|
|
class SymbolWindow;
|
|
class wxStaticText;
|
|
|
|
wxDECLARE_EVENT(wxEVT_UPDATE_VIEW, wxCommandEvent);
|
|
wxDECLARE_EVENT(wxEVT_BREAKPOINT_HIT, wxCommandEvent);
|
|
wxDECLARE_EVENT(wxEVT_RUN, wxCommandEvent);
|
|
wxDECLARE_EVENT(wxEVT_BREAKPOINT_CHANGE, wxCommandEvent);
|
|
wxDECLARE_EVENT(wxEVT_MOVE_IP, wxCommandEvent);
|
|
wxDECLARE_EVENT(wxEVT_NOTIFY_MODULE_LOADED, wxCommandEvent);
|
|
wxDECLARE_EVENT(wxEVT_NOTIFY_MODULE_UNLOADED, wxCommandEvent);
|
|
|
|
struct DebuggerConfig
|
|
{
|
|
DebuggerConfig()
|
|
: pin_to_main(true), break_on_start(true), show_register(true), show_dump(true), show_stack(true), show_breakpoints(true), show_modules(true), show_symbols(true) {}
|
|
|
|
bool pin_to_main;
|
|
bool break_on_start;
|
|
|
|
bool show_register;
|
|
bool show_dump;
|
|
bool show_stack;
|
|
bool show_breakpoints;
|
|
bool show_modules;
|
|
bool show_symbols;
|
|
|
|
void Load(XMLConfigParser& parser);
|
|
void Save(XMLConfigParser& parser);
|
|
};
|
|
typedef XMLDataConfig<DebuggerConfig, &DebuggerConfig::Load, &DebuggerConfig::Save> XMLDebuggerConfig;
|
|
|
|
struct DebuggerModuleStorage
|
|
{
|
|
std::string module_name;
|
|
uint32_t crc_hash;
|
|
const RPLModule* rpl_module;
|
|
bool delete_breakpoints_after_saving;
|
|
|
|
void Load(XMLConfigParser& parser);
|
|
void Save(XMLConfigParser& parser);
|
|
};
|
|
typedef XMLDataConfig<DebuggerModuleStorage, &DebuggerModuleStorage::Load, &DebuggerModuleStorage::Save> XMLDebuggerModuleConfig;
|
|
|
|
class DebuggerWindow2 : public wxFrame
|
|
{
|
|
public:
|
|
void CreateToolBar();
|
|
void LoadModuleStorage(const RPLModule* module);
|
|
void SaveModuleStorage(const RPLModule* module, bool delete_breakpoints);
|
|
DebuggerWindow2(wxFrame& parent, const wxRect& display_size);
|
|
~DebuggerWindow2();
|
|
|
|
void OnParentMove(const wxPoint& position, const wxSize& size);
|
|
void OnGameLoaded();
|
|
|
|
XMLDebuggerConfig& GetConfig();
|
|
|
|
bool Show(bool show = true) override;
|
|
std::wstring GetModuleStoragePath(std::string module_name, uint32_t crc_hash) const;
|
|
private:
|
|
void OnBreakpointHit(wxCommandEvent& event);
|
|
void OnRunProgram(wxCommandEvent& event);
|
|
void OnToolClicked(wxCommandEvent& event);
|
|
void OnBreakpointChange(wxCommandEvent& event);
|
|
void OnOptionsInput(wxCommandEvent& event);
|
|
void OnWindowMenu(wxCommandEvent& event);
|
|
void OnUpdateView(wxCommandEvent& event);
|
|
void OnExit(wxCommandEvent& event);
|
|
void OnShow(wxShowEvent& event);
|
|
void OnClose(wxCloseEvent& event);
|
|
void OnMoveIP(wxCommandEvent& event);
|
|
void OnNotifyModuleLoaded(wxCommandEvent& event);
|
|
void OnNotifyModuleUnloaded(wxCommandEvent& event);
|
|
|
|
void CreateMenuBar();
|
|
void UpdateModuleLabel(uint32 address = 0);
|
|
|
|
XMLDebuggerConfig m_config;
|
|
std::vector<std::unique_ptr<XMLDebuggerModuleConfig>> m_modules_storage;
|
|
|
|
wxPoint m_main_position;
|
|
wxSize m_main_size;
|
|
|
|
RegisterWindow* m_register_window;
|
|
DumpWindow* m_dump_window;
|
|
BreakpointWindow* m_breakpoint_window;
|
|
ModuleWindow* m_module_window;
|
|
SymbolWindow* m_symbol_window;
|
|
|
|
DisasmCtrl* m_disasm_ctrl;
|
|
|
|
wxToolBar* m_toolbar;
|
|
wxBitmap m_run, m_pause;
|
|
|
|
uint32 m_module_address;
|
|
wxStaticText* m_module_label;
|
|
|
|
|
|
wxDECLARE_EVENT_TABLE();
|
|
};
|
|
|