Skip to content

Commit

Permalink
Debugger: Add option to display namespace summary/counts.
Browse files Browse the repository at this point in the history
If "Objects" command is invoked with no arguments, the counts
for each object type are displayed.
  • Loading branch information
acpibob committed Aug 12, 2015
1 parent 25cf8c4 commit bba222c
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 5 deletions.
4 changes: 2 additions & 2 deletions source/components/debugger/dbinput.c
Expand Up @@ -272,7 +272,7 @@ static const ACPI_DB_COMMAND_INFO AcpiGbl_DbCommands[] =
{"METHODS", 0},
{"NAMESPACE", 0},
{"NOTIFY", 2},
{"OBJECTS", 1},
{"OBJECTS", 0},
{"OPEN", 1},
{"OSI", 0},
{"OWNER", 1},
Expand Down Expand Up @@ -339,7 +339,7 @@ static const ACPI_DB_COMMAND_HELP AcpiGbl_DbCommandHelp[] =
{1, " Methods", "Display list of loaded control methods\n"},
{1, " Namespace [Object] [Depth]", "Display loaded namespace tree/subtree\n"},
{1, " Notify <Object> <Value>", "Send a notification on Object\n"},
{1, " Objects <ObjectType>", "Display all objects of the given type\n"},
{1, " Objects [ObjectType]", "Display summary of all objects or just given type\n"},
{1, " Owner <OwnerId> [Depth]", "Display loaded namespace by object owner\n"},
{1, " Paths", "Display full pathnames of namespace objects\n"},
{1, " Predefined", "Check all predefined names\n"},
Expand Down
84 changes: 83 additions & 1 deletion source/components/debugger/dbnames.c
Expand Up @@ -149,6 +149,13 @@ AcpiDbWalkForSpecificObjects (
void *Context,
void **ReturnValue);

static ACPI_STATUS
AcpiDbWalkForObjectCounts (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue);

static ACPI_STATUS
AcpiDbIntegrityWalk (
ACPI_HANDLE ObjHandle,
Expand Down Expand Up @@ -197,7 +204,13 @@ static ACPI_DB_ARGUMENT_INFO AcpiDbObjectTypes [] =
{"BANKFIELDS"},
{"INDEXFIELDS"},
{"REFERENCES"},
{"ALIAS"},
{"ALIASES"},
{"METHODALIASES"},
{"NOTIFY"},
{"ADDRESSHANDLER"},
{"RESOURCE"},
{"RESOURCEFIELD"},
{"SCOPES"},
{NULL} /* Must be null terminated */
};

Expand Down Expand Up @@ -627,6 +640,43 @@ AcpiDbCheckPredefinedNames (
}


/*******************************************************************************
*
* FUNCTION: AcpiDbWalkForObjectCounts
*
* PARAMETERS: Callback from WalkNamespace
*
* RETURN: Status
*
* DESCRIPTION: Display short info about objects in the namespace
*
******************************************************************************/

static ACPI_STATUS
AcpiDbWalkForObjectCounts (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue)
{
ACPI_OBJECT_INFO *Info = (ACPI_OBJECT_INFO *) Context;
ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;


if (Node->Type > ACPI_TYPE_NS_NODE_MAX)
{
AcpiOsPrintf ("[%4.4s]: Unknown object type %X\n",
Node->Name.Ascii, Node->Type);
}
else
{
Info->Types[Node->Type]++;
}

return (AE_OK);
}


/*******************************************************************************
*
* FUNCTION: AcpiDbWalkForSpecificObjects
Expand Down Expand Up @@ -693,7 +743,39 @@ AcpiDbDisplayObjects (
{
ACPI_WALK_INFO Info;
ACPI_OBJECT_TYPE Type;
ACPI_OBJECT_INFO *ObjectInfo;
UINT32 i;
UINT32 TotalObjects = 0;


/* No argument means display summary/count of all object types */

if (!ObjTypeArg)
{
ObjectInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_OBJECT_INFO));

/* Walk the namespace from the root */

(void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX, AcpiDbWalkForObjectCounts, NULL,
(void *) ObjectInfo, NULL);

AcpiOsPrintf ("\nSummary of namespace objects:\n\n");

for (i = 0; i < ACPI_TOTAL_TYPES; i++)
{
AcpiOsPrintf ("%8u %s\n", ObjectInfo->Types[i],
AcpiUtGetTypeName (i));

TotalObjects += ObjectInfo->Types[i];
}

AcpiOsPrintf ("\n%8u Total namespace objects\n\n",
TotalObjects);

ACPI_FREE (ObjectInfo);
return (AE_OK);
}

/* Get the object type */

Expand Down
4 changes: 2 additions & 2 deletions source/include/acglobal.h
Expand Up @@ -422,8 +422,8 @@ ACPI_GLOBAL (char, AcpiGbl_DbDebugFilename[ACPI_DB_LINE_BUF
/*
* Statistic globals
*/
ACPI_GLOBAL (UINT16, AcpiGbl_ObjTypeCount[ACPI_TYPE_NS_NODE_MAX+1]);
ACPI_GLOBAL (UINT16, AcpiGbl_NodeTypeCount[ACPI_TYPE_NS_NODE_MAX+1]);
ACPI_GLOBAL (UINT16, AcpiGbl_ObjTypeCount[ACPI_TOTAL_TYPES]);
ACPI_GLOBAL (UINT16, AcpiGbl_NodeTypeCount[ACPI_TOTAL_TYPES]);
ACPI_GLOBAL (UINT16, AcpiGbl_ObjTypeCountMisc);
ACPI_GLOBAL (UINT16, AcpiGbl_NodeTypeCountMisc);
ACPI_GLOBAL (UINT32, AcpiGbl_NumNodes);
Expand Down
7 changes: 7 additions & 0 deletions source/include/aclocal.h
Expand Up @@ -1399,6 +1399,13 @@ typedef struct acpi_integrity_info
#define ACPI_DB_DUPLICATE_OUTPUT 0x03


typedef struct acpi_object_info
{
UINT32 Types[ACPI_TOTAL_TYPES];

} ACPI_OBJECT_INFO;


/*****************************************************************************
*
* Debug
Expand Down
2 changes: 2 additions & 0 deletions source/include/actypes.h
Expand Up @@ -746,6 +746,7 @@ typedef UINT32 ACPI_OBJECT_TYPE;
#define ACPI_TYPE_DEBUG_OBJECT 0x10

#define ACPI_TYPE_EXTERNAL_MAX 0x10
#define ACPI_NUM_TYPES (ACPI_TYPE_EXTERNAL_MAX + 1)

/*
* These are object types that do not map directly to the ACPI
Expand All @@ -767,6 +768,7 @@ typedef UINT32 ACPI_OBJECT_TYPE;
#define ACPI_TYPE_LOCAL_SCOPE 0x1B /* 1 Name, multiple ObjectList Nodes */

#define ACPI_TYPE_NS_NODE_MAX 0x1B /* Last typecode used within a NS Node */
#define ACPI_TOTAL_TYPES (ACPI_TYPE_NS_NODE_MAX + 1)

/*
* These are special object types that never appear in
Expand Down
1 change: 1 addition & 0 deletions source/tools/acpisrc/astable.c
Expand Up @@ -368,6 +368,7 @@ ACPI_TYPED_IDENTIFIER_TABLE AcpiIdentifiers[] = {
{"ACPI_OBJECT_HANDLER", SRC_TYPE_SIMPLE},
{"ACPI_OBJECT_INDEX_FIELD", SRC_TYPE_STRUCT},
{"ACPI_OBJECT_INTEGER", SRC_TYPE_STRUCT},
{"ACPI_OBJECT_INFO", SRC_TYPE_STRUCT},
{"ACPI_OBJECT_LIST", SRC_TYPE_STRUCT},
{"ACPI_OBJECT_METHOD", SRC_TYPE_STRUCT},
{"ACPI_OBJECT_MUTEX", SRC_TYPE_STRUCT},
Expand Down

0 comments on commit bba222c

Please sign in to comment.