Remove processor dependency on XThread for breakpoints
This commit is contained in:
parent
666f5543a8
commit
42c657c40a
|
@ -10,6 +10,7 @@
|
||||||
#ifndef XENIA_BASE_THREADING_H_
|
#ifndef XENIA_BASE_THREADING_H_
|
||||||
#define XENIA_BASE_THREADING_H_
|
#define XENIA_BASE_THREADING_H_
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
|
@ -344,6 +345,7 @@ class Thread : public WaitHandle {
|
||||||
// within that thread.
|
// within that thread.
|
||||||
static std::unique_ptr<Thread> Create(CreationParameters params,
|
static std::unique_ptr<Thread> Create(CreationParameters params,
|
||||||
std::function<void()> start_routine);
|
std::function<void()> start_routine);
|
||||||
|
static std::unique_ptr<Thread> GetCurrentThread();
|
||||||
|
|
||||||
// Ends the calling thread.
|
// Ends the calling thread.
|
||||||
// No destructors are called, and this function does not return.
|
// No destructors are called, and this function does not return.
|
||||||
|
|
|
@ -442,7 +442,7 @@ std::unique_ptr<Thread> Thread::Create(CreationParameters params,
|
||||||
HANDLE handle =
|
HANDLE handle =
|
||||||
CreateThread(NULL, params.stack_size, ThreadStartRoutine, start_data,
|
CreateThread(NULL, params.stack_size, ThreadStartRoutine, start_data,
|
||||||
params.create_suspended ? CREATE_SUSPENDED : 0, NULL);
|
params.create_suspended ? CREATE_SUSPENDED : 0, NULL);
|
||||||
if (!handle) {
|
if (handle == INVALID_HANDLE_VALUE) {
|
||||||
// TODO(benvanik): pass back?
|
// TODO(benvanik): pass back?
|
||||||
auto last_error = GetLastError();
|
auto last_error = GetLastError();
|
||||||
XELOGE("Unable to CreateThread: %d", last_error);
|
XELOGE("Unable to CreateThread: %d", last_error);
|
||||||
|
@ -453,6 +453,15 @@ std::unique_ptr<Thread> Thread::Create(CreationParameters params,
|
||||||
return std::make_unique<Win32Thread>(handle);
|
return std::make_unique<Win32Thread>(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<Thread> Thread::GetCurrentThread() {
|
||||||
|
HANDLE handle = ::GetCurrentThread();
|
||||||
|
if (handle == INVALID_HANDLE_VALUE) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::make_unique<Win32Thread>(handle);
|
||||||
|
}
|
||||||
|
|
||||||
void Thread::Exit(int exit_code) { ExitThread(exit_code); }
|
void Thread::Exit(int exit_code) { ExitThread(exit_code); }
|
||||||
|
|
||||||
} // namespace threading
|
} // namespace threading
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include "xenia/cpu/thread_state.h"
|
#include "xenia/cpu/thread_state.h"
|
||||||
#include "xenia/cpu/xex_module.h"
|
#include "xenia/cpu/xex_module.h"
|
||||||
#include "xenia/debug/debugger.h"
|
#include "xenia/debug/debugger.h"
|
||||||
#include "xenia/kernel/xthread.h"
|
|
||||||
|
|
||||||
// TODO(benvanik): based on compiler support
|
// TODO(benvanik): based on compiler support
|
||||||
#include "xenia/cpu/backend/x64/x64_backend.h"
|
#include "xenia/cpu/backend/x64/x64_backend.h"
|
||||||
|
@ -454,9 +453,7 @@ bool Processor::BreakpointHit(uint32_t address, uint64_t host_pc) {
|
||||||
if (bp) {
|
if (bp) {
|
||||||
bp->Hit(host_pc);
|
bp->Hit(host_pc);
|
||||||
|
|
||||||
// TODO: Remove dependency on XThread for suspending ourselves
|
xe::threading::Thread::GetCurrentThread()->Suspend();
|
||||||
kernel::XThread::GetCurrentThread()->Suspend();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue