aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner <yuriks@yuriks.net>2015-01-31 14:55:40 -0200
committerGravatar Yuri Kunde Schlesner <yuriks@yuriks.net>2015-02-02 15:37:03 -0200
commit869ec46683c508de5692eaace1a66e682f90b4de (patch)
tree23cd3b9b8f85d67cf74b174927e938c9ca53df55 /src
parenta9b86db3cfec5ce907051d6730ffd98c0fd03876 (diff)
Kernel: Introduce unique Object ids for debugging
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/kernel.cpp2
-rw-r--r--src/core/hle/kernel/kernel.h6
-rw-r--r--src/core/hle/kernel/shared_memory.cpp6
-rw-r--r--src/core/hle/kernel/thread.cpp10
4 files changed, 16 insertions, 8 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index d7fa4dce..a2459e7b 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -14,6 +14,8 @@
namespace Kernel {
+unsigned int Object::next_object_id = 0;
+
SharedPtr<Thread> g_main_thread = nullptr;
HandleTable g_handle_table;
u64 g_program_id = 0;
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index 9860479a..5567780f 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -67,6 +67,9 @@ public:
virtual ~Object() {}
Handle GetHandle() const { return handle; }
+ /// Returns a unique identifier for the object. For debugging purposes only.
+ unsigned int GetObjectId() const { return object_id; }
+
virtual std::string GetTypeName() const { return "[BAD KERNEL OBJECT TYPE]"; }
virtual std::string GetName() const { return "[UNKNOWN KERNEL OBJECT]"; }
virtual Kernel::HandleType GetHandleType() const = 0;
@@ -101,7 +104,10 @@ private:
friend void intrusive_ptr_add_ref(Object*);
friend void intrusive_ptr_release(Object*);
+ static unsigned int next_object_id;
+
unsigned int ref_count = 0;
+ unsigned int object_id = next_object_id++;
};
// 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 eff68d48..b586c990 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,
MemoryPermission other_permissions) {
if (address < Memory::SHARED_MEMORY_VADDR || address >= Memory::SHARED_MEMORY_VADDR_END) {
- LOG_ERROR(Kernel, "cannot map handle=0x%08X, address=0x%08X outside of shared mem bounds!",
- GetHandle(), address);
+ LOG_ERROR(Kernel, "cannot map id=%u, address=0x%08X outside of shared mem bounds!",
+ GetObjectId(), address);
// TODO: Verify error code with hardware
return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
@@ -41,7 +41,7 @@ ResultVal<u8*> SharedMemory::GetPointer(u32 offset) {
if (base_address != 0)
return MakeResult<u8*>(Memory::GetPointer(base_address + offset));
- LOG_ERROR(Kernel_SVC, "memory block handle=0x%08X not mapped!", GetHandle());
+ LOG_ERROR(Kernel_SVC, "memory block id=%u not mapped!", GetObjectId());
// TODO(yuriks): Verify error code.
return ResultCode(ErrorDescription::InvalidAddress, ErrorModule::Kernel,
ErrorSummary::InvalidState, ErrorLevel::Permanent);
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 72a14bfa..2fae1b3b 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -326,11 +326,11 @@ static void DebugThreadQueue() {
if (!thread) {
return;
}
- LOG_DEBUG(Kernel, "0x%02X 0x%08X (current)", thread->current_priority, GetCurrentThread()->GetHandle());
+ LOG_DEBUG(Kernel, "0x%02X %u (current)", thread->current_priority, GetCurrentThread()->GetObjectId());
for (auto& t : thread_list) {
s32 priority = thread_ready_queue.contains(t.get());
if (priority != -1) {
- LOG_DEBUG(Kernel, "0x%02X 0x%08X", priority, t->GetHandle());
+ LOG_DEBUG(Kernel, "0x%02X %u", priority, t->GetObjectId());
}
}
}
@@ -459,13 +459,13 @@ void Reschedule() {
HLE::g_reschedule = false;
if (next != nullptr) {
- LOG_TRACE(Kernel, "context switch 0x%08X -> 0x%08X", prev->GetHandle(), next->GetHandle());
+ LOG_TRACE(Kernel, "context switch %u -> %u", prev->GetObjectId(), next->GetObjectId());
SwitchContext(next);
} else {
- LOG_TRACE(Kernel, "cannot context switch from 0x%08X, no higher priority thread!", prev->GetHandle());
+ LOG_TRACE(Kernel, "cannot context switch from %u, no higher priority thread!", prev->GetObjectId());
for (auto& thread : thread_list) {
- LOG_TRACE(Kernel, "\thandle=0x%08X prio=0x%02X, status=0x%08X", thread->GetHandle(),
+ LOG_TRACE(Kernel, "\tid=%u prio=0x%02X, status=0x%08X", thread->GetObjectId(),
thread->current_priority, thread->status);
}
}