Fixing debugger startup race.
This commit is contained in:
@@ -218,8 +218,10 @@ X_STATUS XUserModule::Launch(uint32_t flags) {
|
||||
XELOGI("Launching module...");
|
||||
|
||||
// Create a thread to run in.
|
||||
auto thread = object_ref<XThread>(
|
||||
new XThread(kernel_state(), stack_size_, 0, entry_point_, 0, 0, true));
|
||||
// We start suspended so we can run the debugger prep.
|
||||
auto thread = object_ref<XThread>(new XThread(kernel_state(), stack_size_, 0,
|
||||
entry_point_, 0,
|
||||
X_CREATE_SUSPENDED, true));
|
||||
|
||||
X_STATUS result = thread->Create();
|
||||
if (XFAILED(result)) {
|
||||
@@ -227,6 +229,16 @@ X_STATUS XUserModule::Launch(uint32_t flags) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Waits for a debugger client, if desired.
|
||||
if (emulator()->debugger()) {
|
||||
emulator()->debugger()->PreLaunch();
|
||||
}
|
||||
|
||||
// Resume the thread now.
|
||||
// If the debugger has requested a suspend this will just decrement the
|
||||
// suspend count without resuming it until the debugger wants.
|
||||
thread->Resume();
|
||||
|
||||
// Wait until thread completes.
|
||||
thread->Wait(0, 0, 0, nullptr);
|
||||
|
||||
|
||||
@@ -179,11 +179,6 @@ int XboxkrnlModule::LaunchModule(const char* path) {
|
||||
// Set as the main module, while running.
|
||||
kernel_state_->SetExecutableModule(module);
|
||||
|
||||
// Waits for a debugger client, if desired.
|
||||
if (emulator()->debugger()) {
|
||||
emulator()->debugger()->PreLaunch();
|
||||
}
|
||||
|
||||
// Launch the module.
|
||||
// NOTE: this won't return until the module exits.
|
||||
X_STATUS result_code = module->Launch(0);
|
||||
|
||||
Reference in New Issue
Block a user