diff options
| author | 2015-01-31 14:55:40 -0200 | |
|---|---|---|
| committer | 2015-02-02 15:37:03 -0200 | |
| commit | 869ec46683c508de5692eaace1a66e682f90b4de (patch) | |
| tree | 23cd3b9b8f85d67cf74b174927e938c9ca53df55 /src | |
| parent | Kernel: Use separate Handle tables for CoreTiming userdata (diff) | |
| download | yuzu-869ec46683c508de5692eaace1a66e682f90b4de.tar.gz yuzu-869ec46683c508de5692eaace1a66e682f90b4de.tar.xz yuzu-869ec46683c508de5692eaace1a66e682f90b4de.zip | |
Kernel: Introduce unique Object ids for debugging
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.h | 6 | ||||
| -rw-r--r-- | src/core/hle/kernel/shared_memory.cpp | 6 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 10 |
4 files changed, 16 insertions, 8 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index d7fa4dcea..a2459e7b1 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | 14 | ||
| 15 | namespace Kernel { | 15 | namespace Kernel { |
| 16 | 16 | ||
| 17 | unsigned int Object::next_object_id = 0; | ||
| 18 | |||
| 17 | SharedPtr<Thread> g_main_thread = nullptr; | 19 | SharedPtr<Thread> g_main_thread = nullptr; |
| 18 | HandleTable g_handle_table; | 20 | HandleTable g_handle_table; |
| 19 | u64 g_program_id = 0; | 21 | u64 g_program_id = 0; |
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 9860479ac..5567780fe 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -67,6 +67,9 @@ public: | |||
| 67 | virtual ~Object() {} | 67 | virtual ~Object() {} |
| 68 | Handle GetHandle() const { return handle; } | 68 | Handle GetHandle() const { return handle; } |
| 69 | 69 | ||
| 70 | /// Returns a unique identifier for the object. For debugging purposes only. | ||
| 71 | unsigned int GetObjectId() const { return object_id; } | ||
| 72 | |||
| 70 | virtual std::string GetTypeName() const { return "[BAD KERNEL OBJECT TYPE]"; } | 73 | virtual std::string GetTypeName() const { return "[BAD KERNEL OBJECT TYPE]"; } |
| 71 | virtual std::string GetName() const { return "[UNKNOWN KERNEL OBJECT]"; } | 74 | virtual std::string GetName() const { return "[UNKNOWN KERNEL OBJECT]"; } |
| 72 | virtual Kernel::HandleType GetHandleType() const = 0; | 75 | virtual Kernel::HandleType GetHandleType() const = 0; |
| @@ -101,7 +104,10 @@ private: | |||
| 101 | friend void intrusive_ptr_add_ref(Object*); | 104 | friend void intrusive_ptr_add_ref(Object*); |
| 102 | friend void intrusive_ptr_release(Object*); | 105 | friend void intrusive_ptr_release(Object*); |
| 103 | 106 | ||
| 107 | static unsigned int next_object_id; | ||
| 108 | |||
| 104 | unsigned int ref_count = 0; | 109 | unsigned int ref_count = 0; |
| 110 | unsigned int object_id = next_object_id++; | ||
| 105 | }; | 111 | }; |
| 106 | 112 | ||
| 107 | // Special functions used by boost::instrusive_ptr to do automatic ref-counting | 113 | // Special functions used by boost::instrusive_ptr to do automatic ref-counting |
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp index eff68d481..b586c9903 100644 --- a/src/core/hle/kernel/shared_memory.cpp +++ b/src/core/hle/kernel/shared_memory.cpp | |||
| @@ -23,8 +23,8 @@ ResultCode SharedMemory::Map(VAddr address, MemoryPermission permissions, | |||
| 23 | MemoryPermission other_permissions) { | 23 | MemoryPermission other_permissions) { |
| 24 | 24 | ||
| 25 | if (address < Memory::SHARED_MEMORY_VADDR || address >= Memory::SHARED_MEMORY_VADDR_END) { | 25 | if (address < Memory::SHARED_MEMORY_VADDR || address >= Memory::SHARED_MEMORY_VADDR_END) { |
| 26 | LOG_ERROR(Kernel, "cannot map handle=0x%08X, address=0x%08X outside of shared mem bounds!", | 26 | LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X outside of shared mem bounds!", |
| 27 | GetHandle(), address); | 27 | GetObjectId(), address); |
| 28 | // TODO: Verify error code with hardware | 28 | // TODO: Verify error code with hardware |
| 29 | return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel, | 29 | return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel, |
| 30 | ErrorSummary::InvalidArgument, ErrorLevel::Permanent); | 30 | ErrorSummary::InvalidArgument, ErrorLevel::Permanent); |
| @@ -41,7 +41,7 @@ ResultVal<u8*> SharedMemory::GetPointer(u32 offset) { | |||
| 41 | if (base_address != 0) | 41 | if (base_address != 0) |
| 42 | return MakeResult<u8*>(Memory::GetPointer(base_address + offset)); | 42 | return MakeResult<u8*>(Memory::GetPointer(base_address + offset)); |
| 43 | 43 | ||
| 44 | LOG_ERROR(Kernel_SVC, "memory block handle=0x%08X not mapped!", GetHandle()); | 44 | LOG_ERROR(Kernel_SVC, "memory block id=%u not mapped!", GetObjectId()); |
| 45 | // TODO(yuriks): Verify error code. | 45 | // TODO(yuriks): Verify error code. |
| 46 | return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel, | 46 | return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel, |
| 47 | ErrorSummary::InvalidState, ErrorLevel::Permanent); | 47 | ErrorSummary::InvalidState, ErrorLevel::Permanent); |
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 72a14bfac..2fae1b3bc 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -326,11 +326,11 @@ static void DebugThreadQueue() { | |||
| 326 | if (!thread) { | 326 | if (!thread) { |
| 327 | return; | 327 | return; |
| 328 | } | 328 | } |
| 329 | LOG_DEBUG(Kernel, "0x%02X 0x%08X (current)", thread->current_priority, GetCurrentThread()->GetHandle()); | 329 | LOG_DEBUG(Kernel, "0x%02X %u (current)", thread->current_priority, GetCurrentThread()->GetObjectId()); |
| 330 | for (auto& t : thread_list) { | 330 | for (auto& t : thread_list) { |
| 331 | s32 priority = thread_ready_queue.contains(t.get()); | 331 | s32 priority = thread_ready_queue.contains(t.get()); |
| 332 | if (priority != -1) { | 332 | if (priority != -1) { |
| 333 | LOG_DEBUG(Kernel, "0x%02X 0x%08X", priority, t->GetHandle()); | 333 | LOG_DEBUG(Kernel, "0x%02X %u", priority, t->GetObjectId()); |
| 334 | } | 334 | } |
| 335 | } | 335 | } |
| 336 | } | 336 | } |
| @@ -459,13 +459,13 @@ void Reschedule() { | |||
| 459 | HLE::g_reschedule = false; | 459 | HLE::g_reschedule = false; |
| 460 | 460 | ||
| 461 | if (next != nullptr) { | 461 | if (next != nullptr) { |
| 462 | LOG_TRACE(Kernel, "context switch 0x%08X -> 0x%08X", prev->GetHandle(), next->GetHandle()); | 462 | LOG_TRACE(Kernel, "context switch %u -> %u", prev->GetObjectId(), next->GetObjectId()); |
| 463 | SwitchContext(next); | 463 | SwitchContext(next); |
| 464 | } else { | 464 | } else { |
| 465 | LOG_TRACE(Kernel, "cannot context switch from 0x%08X, no higher priority thread!", prev->GetHandle()); | 465 | LOG_TRACE(Kernel, "cannot context switch from %u, no higher priority thread!", prev->GetObjectId()); |
| 466 | 466 | ||
| 467 | for (auto& thread : thread_list) { | 467 | for (auto& thread : thread_list) { |
| 468 | LOG_TRACE(Kernel, "\thandle=0x%08X prio=0x%02X, status=0x%08X", thread->GetHandle(), | 468 | LOG_TRACE(Kernel, "\tid=%u prio=0x%02X, status=0x%08X", thread->GetObjectId(), |
| 469 | thread->current_priority, thread->status); | 469 | thread->current_priority, thread->status); |
| 470 | } | 470 | } |
| 471 | } | 471 | } |