diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/process.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 18 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.h | 12 |
3 files changed, 17 insertions, 18 deletions
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index 4e94048da..8b2b3877d 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp | |||
| @@ -40,9 +40,8 @@ void SetupMainThread(Process& owner_process, KernelCore& kernel, VAddr entry_poi | |||
| 40 | SharedPtr<Thread> thread = std::move(thread_res).Unwrap(); | 40 | SharedPtr<Thread> thread = std::move(thread_res).Unwrap(); |
| 41 | 41 | ||
| 42 | // Register 1 must be a handle to the main thread | 42 | // Register 1 must be a handle to the main thread |
| 43 | const Handle guest_handle = owner_process.GetHandleTable().Create(thread).Unwrap(); | 43 | const Handle thread_handle = owner_process.GetHandleTable().Create(thread).Unwrap(); |
| 44 | thread->SetGuestHandle(guest_handle); | 44 | thread->GetContext().cpu_registers[1] = thread_handle; |
| 45 | thread->GetContext().cpu_registers[1] = guest_handle; | ||
| 46 | 45 | ||
| 47 | // Threads by default are dormant, wake up the main thread so it runs when the scheduler fires | 46 | // Threads by default are dormant, wake up the main thread so it runs when the scheduler fires |
| 48 | thread->ResumeFromWait(); | 47 | thread->ResumeFromWait(); |
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index d48a2203a..4eeb97bef 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -1380,20 +1380,22 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e | |||
| 1380 | return ERR_INVALID_THREAD_PRIORITY; | 1380 | return ERR_INVALID_THREAD_PRIORITY; |
| 1381 | } | 1381 | } |
| 1382 | 1382 | ||
| 1383 | const std::string name = fmt::format("thread-{:X}", entry_point); | ||
| 1384 | auto& kernel = system.Kernel(); | 1383 | auto& kernel = system.Kernel(); |
| 1385 | CASCADE_RESULT(SharedPtr<Thread> thread, | 1384 | CASCADE_RESULT(SharedPtr<Thread> thread, |
| 1386 | Thread::Create(kernel, name, entry_point, priority, arg, processor_id, stack_top, | 1385 | Thread::Create(kernel, "", entry_point, priority, arg, processor_id, stack_top, |
| 1387 | *current_process)); | 1386 | *current_process)); |
| 1388 | 1387 | ||
| 1389 | const auto new_guest_handle = current_process->GetHandleTable().Create(thread); | 1388 | const auto new_thread_handle = current_process->GetHandleTable().Create(thread); |
| 1390 | if (new_guest_handle.Failed()) { | 1389 | if (new_thread_handle.Failed()) { |
| 1391 | LOG_ERROR(Kernel_SVC, "Failed to create handle with error=0x{:X}", | 1390 | LOG_ERROR(Kernel_SVC, "Failed to create handle with error=0x{:X}", |
| 1392 | new_guest_handle.Code().raw); | 1391 | new_thread_handle.Code().raw); |
| 1393 | return new_guest_handle.Code(); | 1392 | return new_thread_handle.Code(); |
| 1394 | } | 1393 | } |
| 1395 | thread->SetGuestHandle(*new_guest_handle); | 1394 | *out_handle = *new_thread_handle; |
| 1396 | *out_handle = *new_guest_handle; | 1395 | |
| 1396 | // Set the thread name for debugging purposes. | ||
| 1397 | thread->SetName( | ||
| 1398 | fmt::format("thread[entry_point={:X}, handle={:X}]", entry_point, *new_thread_handle)); | ||
| 1397 | 1399 | ||
| 1398 | system.CpuCore(thread->GetProcessorID()).PrepareReschedule(); | 1400 | system.CpuCore(thread->GetProcessorID()).PrepareReschedule(); |
| 1399 | 1401 | ||
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 32026d7f0..411a73b49 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -102,6 +102,11 @@ public: | |||
| 102 | std::string GetName() const override { | 102 | std::string GetName() const override { |
| 103 | return name; | 103 | return name; |
| 104 | } | 104 | } |
| 105 | |||
| 106 | void SetName(std::string new_name) { | ||
| 107 | name = std::move(new_name); | ||
| 108 | } | ||
| 109 | |||
| 105 | std::string GetTypeName() const override { | 110 | std::string GetTypeName() const override { |
| 106 | return "Thread"; | 111 | return "Thread"; |
| 107 | } | 112 | } |
| @@ -339,10 +344,6 @@ public: | |||
| 339 | arb_wait_address = address; | 344 | arb_wait_address = address; |
| 340 | } | 345 | } |
| 341 | 346 | ||
| 342 | void SetGuestHandle(Handle handle) { | ||
| 343 | guest_handle = handle; | ||
| 344 | } | ||
| 345 | |||
| 346 | bool HasWakeupCallback() const { | 347 | bool HasWakeupCallback() const { |
| 347 | return wakeup_callback != nullptr; | 348 | return wakeup_callback != nullptr; |
| 348 | } | 349 | } |
| @@ -436,9 +437,6 @@ private: | |||
| 436 | /// If waiting for an AddressArbiter, this is the address being waited on. | 437 | /// If waiting for an AddressArbiter, this is the address being waited on. |
| 437 | VAddr arb_wait_address{0}; | 438 | VAddr arb_wait_address{0}; |
| 438 | 439 | ||
| 439 | /// Handle used by guest emulated application to access this thread | ||
| 440 | Handle guest_handle = 0; | ||
| 441 | |||
| 442 | /// Handle used as userdata to reference this object when inserting into the CoreTiming queue. | 440 | /// Handle used as userdata to reference this object when inserting into the CoreTiming queue. |
| 443 | Handle callback_handle = 0; | 441 | Handle callback_handle = 0; |
| 444 | 442 | ||