FreeBSD/sys/contrib/dev/acpica/components/utilities/uttrack.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiUtDumpAllocations
 *
 * PARAMETERS:  Component           - Component(s) to dump info for.
 *              Module              - Module to dump info for. NULL means all.
 *
 * RETURN:      None
 *
 * DESCRIPTION: Print a list of all outstanding allocations.
 *
 ******************************************************************************/
AcpiUtDumpAllocations
PARAMETERS:  Component           - Component(s) to dump info for.
Module              - Module to dump info for. NULL means all.

None

Print a list of all outstanding allocations.
AcpiUtDumpAllocations PARAMETERS : Component - Component ( s ) to dump info for . Module - Module to dump info for . NULL means all . None Print a list of all outstanding allocations .
void
AcpiUtDumpAllocations (
    UINT32                  Component,
    const char              *Module)
{
    ACPI_DEBUG_MEM_BLOCK    *Element;
    ACPI_DESCRIPTOR         *Descriptor;
    UINT32                  NumOutstanding = 0;
    UINT8                   DescriptorType;
    ACPI_FUNCTION_TRACE (UtDumpAllocations);
    if (AcpiGbl_DisableMemTracking)
    {
        return_VOID;
    }
    if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY)))
    {
        return_VOID;
    }
    Element = AcpiGbl_GlobalList->ListHead;
    while (Element)
    {
        if ((Element->Component & Component) &&
            ((Module == NULL) || (0 == strcmp (Module, Element->Module))))
        {
            Descriptor = ACPI_CAST_PTR (
                ACPI_DESCRIPTOR, &Element->UserSpace);
            if (Element->Size < sizeof (ACPI_COMMON_DESCRIPTOR))
            {
                AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u "
                    "[Not a Descriptor - too small]\n",
                    Descriptor, Element->Size, Element->Module,
                    Element->Line);
            }
            else
            {
                if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) !=
                    ACPI_DESC_TYPE_CACHED)
                {
                    AcpiOsPrintf ("%p Length 0x%04X %9.9s-%u [%s] ",
                        Descriptor, Element->Size, Element->Module,
                        Element->Line, AcpiUtGetDescriptorName (Descriptor));
                    DescriptorType = 0; 
                    switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor))
                    {
                    case ACPI_DESC_TYPE_OPERAND:
                        if (Element->Size == sizeof (ACPI_OPERAND_OBJECT))
                        {
                            DescriptorType = ACPI_DESC_TYPE_OPERAND;
                        }
                        break;
                    case ACPI_DESC_TYPE_PARSER:
                        if (Element->Size == sizeof (ACPI_PARSE_OBJECT))
                        {
                            DescriptorType = ACPI_DESC_TYPE_PARSER;
                        }
                        break;
                    case ACPI_DESC_TYPE_NAMED:
                        if (Element->Size == sizeof (ACPI_NAMESPACE_NODE))
                        {
                            DescriptorType = ACPI_DESC_TYPE_NAMED;
                        }
                        break;
                    default:
                        break;
                    }
                    switch (DescriptorType)
                    {
                    case ACPI_DESC_TYPE_OPERAND:
                        AcpiOsPrintf ("%12.12s  RefCount 0x%04X\n",
                            AcpiUtGetTypeName (Descriptor->Object.Common.Type),
                            Descriptor->Object.Common.ReferenceCount);
                        break;
                    case ACPI_DESC_TYPE_PARSER:
                        AcpiOsPrintf ("AmlOpcode 0x%04hX\n",
                            Descriptor->Op.Asl.AmlOpcode);
                        break;
                    case ACPI_DESC_TYPE_NAMED:
                        AcpiOsPrintf ("%4.4s\n",
                            AcpiUtGetNodeName (&Descriptor->Node));
                        break;
                    default:
                        AcpiOsPrintf ( "\n");
                        break;
                    }
                }
            }
            NumOutstanding++;
        }
        Element = Element->Next;
    }
    (void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
    if (!NumOutstanding)
    {
        ACPI_INFO (("No outstanding allocations"));
    }
    else
    {
        ACPI_ERROR ((AE_INFO, "%u(0x%X) Outstanding allocations",
            NumOutstanding, NumOutstanding));
    }
    return_VOID;
}
void AcpiUtDumpAllocations ( UINT32 Component , const char * Module ) { ACPI_DEBUG_MEM_BLOCK * Element ; ACPI_DESCRIPTOR * Descriptor ; UINT32 NumOutstanding = 0 ; UINT8 DescriptorType ; ACPI_FUNCTION_TRACE ( UtDumpAllocations ) ; if ( AcpiGbl_DisableMemTracking ) { return_VOID ; } if ( ACPI_FAILURE ( AcpiUtAcquireMutex ( ACPI_MTX_MEMORY ) ) ) { return_VOID ; } Element = AcpiGbl_GlobalList -> ListHead ; while ( Element ) { if ( ( Element -> Component & Component ) && ( ( Module == NULL ) || ( 0 == strcmp ( Module , Element -> Module ) ) ) ) { Descriptor = ACPI_CAST_PTR ( ACPI_DESCRIPTOR , & Element -> UserSpace ) ; if ( Element -> Size < sizeof ( ACPI_COMMON_DESCRIPTOR ) ) { AcpiOsPrintf ( " " " \n " , Descriptor , Element -> Size , Element -> Module , Element -> Line ) ; } else { if ( ACPI_GET_DESCRIPTOR_TYPE ( Descriptor ) != ACPI_DESC_TYPE_CACHED ) { AcpiOsPrintf ( " " , Descriptor , Element -> Size , Element -> Module , Element -> Line , AcpiUtGetDescriptorName ( Descriptor ) ) ; DescriptorType = 0 ; switch ( ACPI_GET_DESCRIPTOR_TYPE ( Descriptor ) ) { case ACPI_DESC_TYPE_OPERAND : if ( Element -> Size == sizeof ( ACPI_OPERAND_OBJECT ) ) { DescriptorType = ACPI_DESC_TYPE_OPERAND ; } break ; case ACPI_DESC_TYPE_PARSER : if ( Element -> Size == sizeof ( ACPI_PARSE_OBJECT ) ) { DescriptorType = ACPI_DESC_TYPE_PARSER ; } break ; case ACPI_DESC_TYPE_NAMED : if ( Element -> Size == sizeof ( ACPI_NAMESPACE_NODE ) ) { DescriptorType = ACPI_DESC_TYPE_NAMED ; } break ; default : break ; } switch ( DescriptorType ) { case ACPI_DESC_TYPE_OPERAND : AcpiOsPrintf ( " \n " , AcpiUtGetTypeName ( Descriptor -> Object . Common . Type ) , Descriptor -> Object . Common . ReferenceCount ) ; break ; case ACPI_DESC_TYPE_PARSER : AcpiOsPrintf ( " \n " , Descriptor -> Op . Asl . AmlOpcode ) ; break ; case ACPI_DESC_TYPE_NAMED : AcpiOsPrintf ( " \n " , AcpiUtGetNodeName ( & Descriptor -> Node ) ) ; break ; default : AcpiOsPrintf ( " \n " ) ; break ; } } } NumOutstanding ++ ; } Element = Element -> Next ; } ( void ) AcpiUtReleaseMutex ( ACPI_MTX_MEMORY ) ; if ( ! NumOutstanding ) { ACPI_INFO ( ( " " ) ) ; } else { ACPI_ERROR ( ( AE_INFO , " " , NumOutstanding , NumOutstanding ) ) ; } return_VOID ; }
FUNCTION:    AcpiUtDumpAllocations
 PARAMETERS:  Component           - Component(s) to dump info for.
FUNCTION : AcpiUtDumpAllocations PARAMETERS : Component - Component ( s ) to dump info for .
/*
     * Walk the allocation list.
     */ /* Ignore allocated objects that are in a cache */ /* Validate the descriptor type using Type field and length */ /* Not a valid descriptor type */ /* Display additional info for the major descriptor types */ /* Print summary */