A new debugger.
Lots of bugs/rough edges/etc - issues will be filed. Old-style debugging still works (just use --emit_source_annotations to get the helpful movs back and --break_on_instruction will still fire).
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "xenia/app/emulator_window.h"
|
||||
|
||||
#include "third_party/elemental-forms/src/el/elements.h"
|
||||
#include "xenia/base/clock.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/platform.h"
|
||||
@@ -105,6 +106,10 @@ bool EmulatorWindow::Initialize() {
|
||||
}
|
||||
} break;
|
||||
|
||||
case 0x13: { // VK_PAUSE
|
||||
CpuBreakIntoDebugger();
|
||||
} break;
|
||||
|
||||
case 0x70: { // VK_F1
|
||||
ShowHelpWebsite();
|
||||
} break;
|
||||
@@ -147,6 +152,12 @@ bool EmulatorWindow::Initialize() {
|
||||
L"&Pause/Resume Profiler", L"`",
|
||||
[]() { Profiler::TogglePause(); }));
|
||||
}
|
||||
cpu_menu->AddChild(MenuItem::Create(MenuItem::Type::kSeparator));
|
||||
{
|
||||
cpu_menu->AddChild(MenuItem::Create(
|
||||
MenuItem::Type::kString, L"&Break and Show Debugger", L"Pause/Break",
|
||||
std::bind(&EmulatorWindow::CpuBreakIntoDebugger, this)));
|
||||
}
|
||||
main_menu->AddChild(std::move(cpu_menu));
|
||||
|
||||
// GPU menu.
|
||||
@@ -207,6 +218,25 @@ void EmulatorWindow::CpuTimeScalarSetDouble() {
|
||||
UpdateTitle();
|
||||
}
|
||||
|
||||
void EmulatorWindow::CpuBreakIntoDebugger() {
|
||||
auto debugger = emulator()->debugger();
|
||||
if (!debugger) {
|
||||
auto message_form = new el::MessageForm(window_->root_element(),
|
||||
TBIDC("debug_error_window"));
|
||||
message_form->Show("Xenia Debugger",
|
||||
"Xenia must be launched with the --debug flag in order "
|
||||
"to enable debugging.");
|
||||
return;
|
||||
}
|
||||
if (debugger->execution_state() == debug::ExecutionState::kRunning) {
|
||||
// Currently running, so interrupt (and show the debugger).
|
||||
debugger->Pause();
|
||||
} else {
|
||||
// Not running, so just bring the debugger into focus.
|
||||
debugger->Show();
|
||||
}
|
||||
}
|
||||
|
||||
void EmulatorWindow::GpuTraceFrame() {
|
||||
emulator()->graphics_system()->RequestFrameTrace();
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ class EmulatorWindow {
|
||||
void CpuTimeScalarReset();
|
||||
void CpuTimeScalarSetHalf();
|
||||
void CpuTimeScalarSetDouble();
|
||||
void CpuBreakIntoDebugger();
|
||||
void GpuTraceFrame();
|
||||
void GpuClearCaches();
|
||||
void ToggleFullscreen();
|
||||
|
||||
@@ -10,6 +10,7 @@ project("xenia-app")
|
||||
links({
|
||||
"elemental-forms",
|
||||
"gflags",
|
||||
"imgui",
|
||||
"xenia-apu",
|
||||
"xenia-apu-nop",
|
||||
"xenia-base",
|
||||
@@ -17,6 +18,7 @@ project("xenia-app")
|
||||
"xenia-cpu",
|
||||
"xenia-cpu-backend-x64",
|
||||
"xenia-debug",
|
||||
"xenia-debug-ui",
|
||||
"xenia-gpu",
|
||||
"xenia-gpu-gl4",
|
||||
"xenia-hid-nop",
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "xenia/app/emulator_window.h"
|
||||
#include "xenia/base/logging.h"
|
||||
#include "xenia/base/main.h"
|
||||
#include "xenia/debug/ui/debug_window.h"
|
||||
#include "xenia/emulator.h"
|
||||
#include "xenia/profiling.h"
|
||||
#include "xenia/ui/file_picker.h"
|
||||
@@ -39,6 +40,27 @@ int xenia_main(const std::vector<std::wstring>& args) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Set a debug handler.
|
||||
// This will respond to debugging requests so we can open the debug UI.
|
||||
std::unique_ptr<xe::debug::ui::DebugWindow> debug_window;
|
||||
if (emulator->debugger()) {
|
||||
emulator->debugger()->set_debug_listener_request_handler([&](
|
||||
xe::debug::Debugger* debugger) {
|
||||
if (debug_window) {
|
||||
return debug_window.get();
|
||||
}
|
||||
emulator_window->loop()->PostSynchronous([&]() {
|
||||
debug_window = xe::debug::ui::DebugWindow::Create(
|
||||
emulator.get(), emulator_window->loop());
|
||||
debug_window->window()->on_closed.AddListener([&](xe::ui::UIEvent* e) {
|
||||
emulator->debugger()->set_debug_listener(nullptr);
|
||||
emulator_window->loop()->Post([&]() { debug_window.reset(); });
|
||||
});
|
||||
});
|
||||
return debug_window.get();
|
||||
});
|
||||
}
|
||||
|
||||
// Grab path from the flag or unnamed argument.
|
||||
std::wstring path;
|
||||
if (!FLAGS_target.empty() || args.size() >= 2) {
|
||||
@@ -91,6 +113,7 @@ int xenia_main(const std::vector<std::wstring>& args) {
|
||||
emulator->display_window()->loop()->AwaitQuit();
|
||||
}
|
||||
|
||||
debug_window.reset();
|
||||
emulator.reset();
|
||||
emulator_window.reset();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user