core/systems/HandleSys.cpp
changeset 900 b38c83f9d526
parent 789 61b9fe952a02
child 1231 17badaf66ce4
     1.1 --- a/core/systems/HandleSys.cpp	Thu Jun 07 02:26:06 2007 +0000
     1.2 +++ b/core/systems/HandleSys.cpp	Thu Jun 07 02:36:54 2007 +0000
     1.3 @@ -15,6 +15,7 @@
     1.4  #include "HandleSys.h"
     1.5  #include "ShareSys.h"
     1.6  #include "PluginSys.h"
     1.7 +#include "ExtensionSys.h"
     1.8  #include <assert.h>
     1.9  #include <string.h>
    1.10  
    1.11 @@ -899,3 +900,52 @@
    1.12  
    1.13  	return true;
    1.14  }
    1.15 +
    1.16 +void HandleSystem::Dump(FILE *fp)
    1.17 +{
    1.18 +	fprintf(fp, "%-10.10s\t%-20.20s\t%-20.20s\n", "Handle", "Owner", "Type");
    1.19 +	fprintf(fp, "---------------------------------------------\n");
    1.20 +	for (unsigned int i=1; i<=m_HandleTail; i++)
    1.21 +	{
    1.22 +		if (m_Handles[i].set == HandleSet_Freed
    1.23 +			|| m_Handles[i].set == HandleSet_Identity)
    1.24 +		{
    1.25 +			continue;
    1.26 +		}
    1.27 +		/* Get the index */
    1.28 +		unsigned int index = (m_Handles[i].serial << 16) | i;
    1.29 +		/* Determine the owner */
    1.30 +		const char *owner = "UNKNOWN";
    1.31 +		if (m_Handles[i].owner)
    1.32 +		{
    1.33 +			IdentityToken_t *pOwner = m_Handles[i].owner;
    1.34 +			if (pOwner == g_pCoreIdent)
    1.35 +			{
    1.36 +				owner = "CORE";
    1.37 +			} else if (pOwner == g_PluginSys.GetIdentity()) {
    1.38 +				owner = "PLUGINSYS";
    1.39 +			} else {
    1.40 +				CExtension *ext = g_Extensions.GetExtensionFromIdent(pOwner);
    1.41 +				if (ext)
    1.42 +				{
    1.43 +					owner = ext->GetFilename();
    1.44 +				} else {
    1.45 +					CPlugin *pPlugin = g_PluginSys.GetPluginFromIdentity(pOwner);
    1.46 +					if (pPlugin)
    1.47 +					{
    1.48 +						owner = pPlugin->GetFilename();
    1.49 +					}
    1.50 +				}
    1.51 +			}
    1.52 +		} else {
    1.53 +			owner = "NONE";
    1.54 +		}
    1.55 +		const char *type = "ANON";
    1.56 +		QHandleType *pType = &m_Types[m_Handles[i].type];
    1.57 +		if (pType->nameIdx != -1)
    1.58 +		{
    1.59 +			type = m_strtab->GetString(pType->nameIdx);
    1.60 +		}
    1.61 +		fprintf(fp, "0x%08x\t%-20.20s\t%-20.20s\n", index, owner, type);
    1.62 +	}
    1.63 +}