Remove xenia-cpu dependency on xenia-kernel
This commit is contained in:
@@ -28,12 +28,10 @@
|
||||
#include "xenia/cpu/ppc/ppc_decode_data.h"
|
||||
#include "xenia/cpu/ppc/ppc_frontend.h"
|
||||
#include "xenia/cpu/stack_walker.h"
|
||||
#include "xenia/cpu/thread.h"
|
||||
#include "xenia/cpu/thread_state.h"
|
||||
#include "xenia/cpu/xex_module.h"
|
||||
|
||||
// HACK(benvanik): XThread has too much stuff :/
|
||||
#include "xenia/kernel/xthread.h"
|
||||
|
||||
// TODO(benvanik): based on compiler support
|
||||
#include "xenia/cpu/backend/x64/x64_backend.h"
|
||||
|
||||
@@ -49,6 +47,10 @@ DEFINE_string(trace_function_data_path, "", "File to write trace data to.");
|
||||
DEFINE_bool(break_on_start, false, "Break into the debugger on startup.");
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
class XThread;
|
||||
} // namespace kernel
|
||||
|
||||
namespace cpu {
|
||||
|
||||
using xe::cpu::ppc::PPCOpcode;
|
||||
@@ -491,8 +493,7 @@ void Processor::OnFunctionDefined(Function* function) {
|
||||
}
|
||||
|
||||
void Processor::OnThreadCreated(uint32_t thread_handle,
|
||||
ThreadState* thread_state,
|
||||
kernel::XThread* thread) {
|
||||
ThreadState* thread_state, Thread* thread) {
|
||||
auto global_lock = global_critical_region_.Acquire();
|
||||
auto thread_info = std::make_unique<ThreadDebugInfo>();
|
||||
thread_info->thread_handle = thread_handle;
|
||||
@@ -683,7 +684,7 @@ bool Processor::OnThreadBreakpointHit(Exception* ex) {
|
||||
debug_listener_->OnExecutionPaused();
|
||||
}
|
||||
|
||||
thread_info->thread->Suspend(nullptr);
|
||||
thread_info->thread->thread()->Suspend();
|
||||
|
||||
// Apply thread context changes.
|
||||
// TODO(benvanik): apply to all threads?
|
||||
@@ -711,7 +712,7 @@ bool Processor::OnUnhandledException(Exception* ex) {
|
||||
}
|
||||
|
||||
// If this isn't a managed thread, fail - let VS handle it for now.
|
||||
if (!XThread::IsInThread()) {
|
||||
if (!Thread::IsInThread()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -720,7 +721,7 @@ bool Processor::OnUnhandledException(Exception* ex) {
|
||||
// Suspend all guest threads (but this one).
|
||||
SuspendAllThreads();
|
||||
|
||||
UpdateThreadExecutionStates(XThread::GetCurrentThreadId(),
|
||||
UpdateThreadExecutionStates(Thread::GetCurrentThreadId(),
|
||||
ex->thread_context());
|
||||
|
||||
// Stop and notify the listener.
|
||||
@@ -733,7 +734,7 @@ bool Processor::OnUnhandledException(Exception* ex) {
|
||||
debug_listener_->OnExecutionPaused();
|
||||
|
||||
// Suspend self.
|
||||
XThread::GetCurrentThread()->Suspend(nullptr);
|
||||
Thread::GetCurrentThread()->thread()->Suspend();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -757,8 +758,8 @@ bool Processor::SuspendAllThreads() {
|
||||
thread_info->state == ThreadDebugInfo::State::kExited) {
|
||||
// Thread is dead and cannot be suspended - ignore.
|
||||
continue;
|
||||
} else if (XThread::IsInThread() &&
|
||||
thread_info->thread_id == XThread::GetCurrentThreadId()) {
|
||||
} else if (Thread::IsInThread() &&
|
||||
thread_info->thread_id == Thread::GetCurrentThreadId()) {
|
||||
// Can't suspend ourselves.
|
||||
continue;
|
||||
}
|
||||
@@ -767,7 +768,7 @@ bool Processor::SuspendAllThreads() {
|
||||
// Thread is a host thread, and we aren't suspending those (for now).
|
||||
continue;
|
||||
}
|
||||
bool did_suspend = XSUCCEEDED(thread->Suspend(nullptr));
|
||||
bool did_suspend = thread->thread()->Suspend(nullptr);
|
||||
assert_true(did_suspend);
|
||||
thread_info->suspended = true;
|
||||
}
|
||||
@@ -786,7 +787,7 @@ bool Processor::ResumeThread(uint32_t thread_id) {
|
||||
thread_info->state == ThreadDebugInfo::State::kZombie);
|
||||
thread_info->suspended = false;
|
||||
auto thread = thread_info->thread;
|
||||
return XSUCCEEDED(thread->Resume());
|
||||
return thread->thread()->Resume();
|
||||
}
|
||||
|
||||
bool Processor::ResumeAllThreads() {
|
||||
@@ -800,8 +801,8 @@ bool Processor::ResumeAllThreads() {
|
||||
thread_info->state == ThreadDebugInfo::State::kExited) {
|
||||
// Thread is dead and cannot be resumed - ignore.
|
||||
continue;
|
||||
} else if (XThread::IsInThread() &&
|
||||
thread_info->thread_id == XThread::GetCurrentThreadId()) {
|
||||
} else if (Thread::IsInThread() &&
|
||||
thread_info->thread_id == Thread::GetCurrentThreadId()) {
|
||||
// Can't resume ourselves.
|
||||
continue;
|
||||
}
|
||||
@@ -811,7 +812,7 @@ bool Processor::ResumeAllThreads() {
|
||||
continue;
|
||||
}
|
||||
thread_info->suspended = false;
|
||||
bool did_resume = XSUCCEEDED(thread->Resume());
|
||||
bool did_resume = thread->thread()->Resume();
|
||||
assert_true(did_resume);
|
||||
}
|
||||
return true;
|
||||
@@ -987,7 +988,7 @@ bool Processor::StepToGuestAddress(uint32_t thread_id, uint32_t pc) {
|
||||
if (functions.empty()) {
|
||||
// Function hasn't been generated yet. Generate it.
|
||||
if (!ResolveFunction(pc)) {
|
||||
XELOGE("XThread::StepToAddress(%.8X) - Function could not be resolved",
|
||||
XELOGE("Processor::StepToAddress(%.8X) - Function could not be resolved",
|
||||
pc);
|
||||
return false;
|
||||
}
|
||||
@@ -1005,7 +1006,7 @@ bool Processor::StepToGuestAddress(uint32_t thread_id, uint32_t pc) {
|
||||
auto thread_info = QueryThreadDebugInfo(thread_id);
|
||||
uint32_t suspend_count = 1;
|
||||
while (suspend_count) {
|
||||
thread_info->thread->Resume(&suspend_count);
|
||||
thread_info->thread->thread()->Resume(&suspend_count);
|
||||
}
|
||||
|
||||
fence.Wait();
|
||||
@@ -1075,7 +1076,7 @@ uint32_t Processor::StepIntoGuestBranchTarget(uint32_t thread_id, uint32_t pc) {
|
||||
// HACK
|
||||
uint32_t suspend_count = 1;
|
||||
while (suspend_count) {
|
||||
thread->Resume(&suspend_count);
|
||||
thread->thread()->Resume(&suspend_count);
|
||||
}
|
||||
|
||||
fence.Wait();
|
||||
@@ -1090,7 +1091,7 @@ uint32_t Processor::StepToGuestSafePoint(uint32_t thread_id, bool ignore_host) {
|
||||
// This cannot be done if we're the calling thread!
|
||||
if (thread_id == ThreadState::GetThreadID()) {
|
||||
assert_always(
|
||||
"XThread::StepToSafePoint(): target thread is the calling thread!");
|
||||
"Processor::StepToSafePoint(): target thread is the calling thread!");
|
||||
return 0;
|
||||
}
|
||||
auto thread_info = QueryThreadDebugInfo(thread_id);
|
||||
@@ -1213,11 +1214,15 @@ uint32_t Processor::StepToGuestSafePoint(uint32_t thread_id, bool ignore_host) {
|
||||
} else {
|
||||
// We've managed to catch a thread before it called into the guest.
|
||||
// Set a breakpoint on its startup procedure and capture it there.
|
||||
// TODO(DrChat): Reimplement
|
||||
assert_always("Unimplemented");
|
||||
/*
|
||||
auto creation_params = thread->creation_params();
|
||||
pc = creation_params->xapi_thread_startup
|
||||
? creation_params->xapi_thread_startup
|
||||
: creation_params->start_address;
|
||||
StepToGuestAddress(thread_id, pc);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user