📄 uttrack.c
字号:
/******************************************************************************* * * FUNCTION: AcpiUtFindAllocation * * PARAMETERS: Allocation - Address of allocated memory * * RETURN: A list element if found; NULL otherwise. * * DESCRIPTION: Searches for an element in the global allocation tracking list. * ******************************************************************************/static ACPI_DEBUG_MEM_BLOCK *AcpiUtFindAllocation ( void *Allocation){ ACPI_DEBUG_MEM_BLOCK *Element; ACPI_FUNCTION_ENTRY (); Element = AcpiGbl_GlobalList->ListHead; /* Search for the address. */ while (Element) { if (Element == Allocation) { return (Element); } Element = Element->Next; } return (NULL);}/******************************************************************************* * * FUNCTION: AcpiUtTrackAllocation * * PARAMETERS: Allocation - Address of allocated memory * Size - Size of the allocation * AllocType - MEM_MALLOC or MEM_CALLOC * Component - Component type of caller * Module - Source file name of caller * Line - Line number of caller * * RETURN: None. * * DESCRIPTION: Inserts an element into the global allocation tracking list. * ******************************************************************************/static ACPI_STATUSAcpiUtTrackAllocation ( ACPI_DEBUG_MEM_BLOCK *Allocation, ACPI_SIZE Size, UINT8 AllocType, UINT32 Component, char *Module, UINT32 Line){ ACPI_MEMORY_LIST *MemList; ACPI_DEBUG_MEM_BLOCK *Element; ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_TRACE_PTR (UtTrackAllocation, Allocation); MemList = AcpiGbl_GlobalList; Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* * Search list for this address to make sure it is not already on the list. * This will catch several kinds of problems. */ Element = AcpiUtFindAllocation (Allocation); if (Element) { ACPI_ERROR ((AE_INFO, "UtTrackAllocation: Allocation already present in list! (%p)", Allocation)); ACPI_ERROR ((AE_INFO, "Element %p Address %p", Element, Allocation)); goto UnlockAndExit; } /* Fill in the instance data. */ Allocation->Size = (UINT32) Size; Allocation->AllocType = AllocType; Allocation->Component = Component; Allocation->Line = Line; ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME); Allocation->Module[ACPI_MAX_MODULE_NAME-1] = 0; /* Insert at list head */ if (MemList->ListHead) { ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation; } Allocation->Next = MemList->ListHead; Allocation->Previous = NULL; MemList->ListHead = Allocation;UnlockAndExit: Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY); return_ACPI_STATUS (Status);}/******************************************************************************* * * FUNCTION: AcpiUtRemoveAllocation * * PARAMETERS: Allocation - Address of allocated memory * Component - Component type of caller * Module - Source file name of caller * Line - Line number of caller * * RETURN: * * DESCRIPTION: Deletes an element from the global allocation tracking list. * ******************************************************************************/static ACPI_STATUSAcpiUtRemoveAllocation ( ACPI_DEBUG_MEM_BLOCK *Allocation, UINT32 Component, char *Module, UINT32 Line){ ACPI_MEMORY_LIST *MemList; ACPI_STATUS Status; ACPI_FUNCTION_TRACE (UtRemoveAllocation); MemList = AcpiGbl_GlobalList; if (NULL == MemList->ListHead) { /* No allocations! */ ACPI_ERROR ((Module, Line, "Empty allocation list, nothing to free!")); return_ACPI_STATUS (AE_OK); } Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (Status); } /* Unlink */ if (Allocation->Previous) { (Allocation->Previous)->Next = Allocation->Next; } else { MemList->ListHead = Allocation->Next; } if (Allocation->Next) { (Allocation->Next)->Previous = Allocation->Previous; } /* Mark the segment as deleted */ ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size); ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n", Allocation->Size)); Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY); return_ACPI_STATUS (Status);}/******************************************************************************* * * FUNCTION: AcpiUtDumpAllocationInfo * * PARAMETERS: * * RETURN: None * * DESCRIPTION: Print some info about the outstanding allocations. * ******************************************************************************/voidAcpiUtDumpAllocationInfo ( void){/* ACPI_MEMORY_LIST *MemList;*/ ACPI_FUNCTION_TRACE (UtDumpAllocationInfo);/* ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, ("%30s: %4d (%3d Kb)\n", "Current allocations", MemList->CurrentCount, ROUND_UP_TO_1K (MemList->CurrentSize))); ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations", MemList->MaxConcurrentCount, ROUND_UP_TO_1K (MemList->MaxConcurrentSize))); ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects", RunningObjectCount, ROUND_UP_TO_1K (RunningObjectSize))); ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, ("%30s: %4d (%3d Kb)\n", "Total (all) allocations", RunningAllocCount, ROUND_UP_TO_1K (RunningAllocSize))); ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, ("%30s: %4d (%3d Kb)\n", "Current Nodes", AcpiGbl_CurrentNodeCount, ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize))); ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES, ("%30s: %4d (%3d Kb)\n", "Max Nodes", AcpiGbl_MaxConcurrentNodeCount, ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount * sizeof (ACPI_NAMESPACE_NODE)))));*/ return_VOID;}/******************************************************************************* * * 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. * ******************************************************************************/voidAcpiUtDumpAllocations ( UINT32 Component, char *Module){ ACPI_DEBUG_MEM_BLOCK *Element; ACPI_DESCRIPTOR *Descriptor; UINT32 NumOutstanding = 0; ACPI_FUNCTION_TRACE (UtDumpAllocations); /* * Walk the allocation list. */ if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY))) { return; } Element = AcpiGbl_GlobalList->ListHead; while (Element) { if ((Element->Component & Component) && ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module)))) { /* Ignore allocated objects that are in a cache */ Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace); if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) != ACPI_DESC_TYPE_CACHED) { AcpiOsPrintf ("%p Len %04X %9.9s-%d [%s] ", Descriptor, Element->Size, Element->Module, Element->Line, AcpiUtGetDescriptorName (Descriptor)); /* Most of the elements will be Operand objects. */ switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor)) { case ACPI_DESC_TYPE_OPERAND: AcpiOsPrintf ("%12.12s R%hd", AcpiUtGetTypeName (Descriptor->Object.Common.Type), Descriptor->Object.Common.ReferenceCount); break; case ACPI_DESC_TYPE_PARSER: AcpiOsPrintf ("AmlOpcode %04hX", Descriptor->Op.Asl.AmlOpcode); break; case ACPI_DESC_TYPE_NAMED: AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (&Descriptor->Node)); break; default: break; } AcpiOsPrintf ( "\n"); NumOutstanding++; } } Element = Element->Next; } (void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY); /* Print summary */ if (!NumOutstanding) { ACPI_INFO ((AE_INFO, "No outstanding allocations")); } else { ACPI_ERROR ((AE_INFO, "%d(%X) Outstanding allocations", NumOutstanding, NumOutstanding)); } return_VOID;}#endif /* ACPI_DBG_TRACK_ALLOCATIONS */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -