From 82d949b34eb89133a052fb6217550d013db29a6f Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 24 Jul 2008 06:48:54 +0000 Subject: [PATCH] Added more debug info to sm_dump_handles --HG-- branch : sourcemod-1.0.x extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/branches/sourcemod-1.0.x%402424 --- core/systems/HandleSys.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/core/systems/HandleSys.cpp b/core/systems/HandleSys.cpp index 951e0cb9..41cc361f 100644 --- a/core/systems/HandleSys.cpp +++ b/core/systems/HandleSys.cpp @@ -997,8 +997,9 @@ bool HandleSystem::TryAndFreeSomeHandles() void HandleSystem::Dump(HANDLE_REPORTER rep) { + char refcount[20], parent[20]; unsigned int total_size = 0; - rep("%-10.10s\t%-20.20s\t%-20.20s\t%-10.10s", "Handle", "Owner", "Type", "Memory"); + rep("%-10.10s\t%-20.20s\t%-20.20s\t%-10.10s\t%-10.10s\t%-10.10s", "Handle", "Owner", "Type", "Memory", "Refcount", "Parent"); rep("--------------------------------------------------------------------------"); for (unsigned int i = 1; i <= m_HandleTail; i++) { @@ -1049,16 +1050,26 @@ void HandleSystem::Dump(HANDLE_REPORTER rep) { type = m_strtab->GetString(pType->nameIdx); } + if (m_Handles[i].clone == 0) + { + UTIL_Format(refcount, sizeof(refcount), "%d", m_Handles[i].refcount); + UTIL_Format(parent, sizeof(parent), "NULL"); + } + else + { + UTIL_Format(refcount, sizeof(refcount), "%d", m_Handles[m_Handles[i].clone].refcount); + UTIL_Format(parent, sizeof(parent), "%d", m_Handles[i].clone); + } if (pType->dispatch->GetDispatchVersion() < HANDLESYS_MEMUSAGE_MIN_VERSION || !pType->dispatch->GetHandleApproxSize(m_Handles[i].type, m_Handles[i].object, &size)) { - rep("0x%08x\t%-20.20s\t%-20.20s\t%-10.10s", index, owner, type, "-1"); + rep("0x%08x\t%-20.20s\t%-20.20s\t%-10.10s\t%-10.10s\t%-10.10s", index, owner, type, "-1", refcount, parent); } else { char buffer[32]; UTIL_Format(buffer, sizeof(buffer), "%d", size); - rep("0x%08x\t%-20.20s\t%-20.20s\t%-10.10s", index, owner, type, buffer); + rep("0x%08x\t%-20.20s\t%-20.20s\t%-10.10s\t%-10.10s\t%-10.10s", index, owner, type, buffer, refcount, parent); total_size += size; } }