mirror of
https://github.com/PabloMK7/citra.git
synced 2024-11-26 09:24:06 +00:00
Kernel: Introduce unique Object ids for debugging
This commit is contained in:
parent
a9b86db3cf
commit
869ec46683
4 changed files with 16 additions and 8 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue