Path: blob/main/sys/contrib/dev/acpica/components/utilities/uttrack.c
48406 views
/******************************************************************************1*2* Module Name: uttrack - Memory allocation tracking routines (debug only)3*4*****************************************************************************/56/******************************************************************************7*8* 1. Copyright Notice9*10* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.11* All rights reserved.12*13* 2. License14*15* 2.1. This is your license from Intel Corp. under its intellectual property16* rights. You may have additional license terms from the party that provided17* you this software, covering your right to use that party's intellectual18* property rights.19*20* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a21* copy of the source code appearing in this file ("Covered Code") an22* irrevocable, perpetual, worldwide license under Intel's copyrights in the23* base code distributed originally by Intel ("Original Intel Code") to copy,24* make derivatives, distribute, use and display any portion of the Covered25* Code in any form, with the right to sublicense such rights; and26*27* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent28* license (with the right to sublicense), under only those claims of Intel29* patents that are infringed by the Original Intel Code, to make, use, sell,30* offer to sell, and import the Covered Code and derivative works thereof31* solely to the minimum extent necessary to exercise the above copyright32* license, and in no event shall the patent license extend to any additions33* to or modifications of the Original Intel Code. No other license or right34* is granted directly or by implication, estoppel or otherwise;35*36* The above copyright and patent license is granted only if the following37* conditions are met:38*39* 3. Conditions40*41* 3.1. Redistribution of Source with Rights to Further Distribute Source.42* Redistribution of source code of any substantial portion of the Covered43* Code or modification with rights to further distribute source must include44* the above Copyright Notice, the above License, this list of Conditions,45* and the following Disclaimer and Export Compliance provision. In addition,46* Licensee must cause all Covered Code to which Licensee contributes to47* contain a file documenting the changes Licensee made to create that Covered48* Code and the date of any change. Licensee must include in that file the49* documentation of any changes made by any predecessor Licensee. Licensee50* must include a prominent statement that the modification is derived,51* directly or indirectly, from Original Intel Code.52*53* 3.2. Redistribution of Source with no Rights to Further Distribute Source.54* Redistribution of source code of any substantial portion of the Covered55* Code or modification without rights to further distribute source must56* include the following Disclaimer and Export Compliance provision in the57* documentation and/or other materials provided with distribution. In58* addition, Licensee may not authorize further sublicense of source of any59* portion of the Covered Code, and must include terms to the effect that the60* license from Licensee to its licensee is limited to the intellectual61* property embodied in the software Licensee provides to its licensee, and62* not to intellectual property embodied in modifications its licensee may63* make.64*65* 3.3. Redistribution of Executable. Redistribution in executable form of any66* substantial portion of the Covered Code or modification must reproduce the67* above Copyright Notice, and the following Disclaimer and Export Compliance68* provision in the documentation and/or other materials provided with the69* distribution.70*71* 3.4. Intel retains all right, title, and interest in and to the Original72* Intel Code.73*74* 3.5. Neither the name Intel nor any other trademark owned or controlled by75* Intel shall be used in advertising or otherwise to promote the sale, use or76* other dealings in products derived from or relating to the Covered Code77* without prior written authorization from Intel.78*79* 4. Disclaimer and Export Compliance80*81* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED82* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE83* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,84* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY85* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY86* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A87* PARTICULAR PURPOSE.88*89* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES90* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR91* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,92* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY93* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL94* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS95* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY96* LIMITED REMEDY.97*98* 4.3. Licensee shall not export, either directly or indirectly, any of this99* software or system incorporating such software without first obtaining any100* required license or other approval from the U. S. Department of Commerce or101* any other agency or department of the United States Government. In the102* event Licensee exports any such software from the United States or103* re-exports any such software from a foreign destination, Licensee shall104* ensure that the distribution and export/re-export of the software is in105* compliance with all laws, regulations, orders, or other restrictions of the106* U.S. Export Administration Regulations. Licensee agrees that neither it nor107* any of its subsidiaries will export/re-export any technical data, process,108* software, or service, directly or indirectly, to any country for which the109* United States government or any agency thereof requires an export license,110* other governmental approval, or letter of assurance, without first obtaining111* such license, approval or letter.112*113*****************************************************************************114*115* Alternatively, you may choose to be licensed under the terms of the116* following license:117*118* Redistribution and use in source and binary forms, with or without119* modification, are permitted provided that the following conditions120* are met:121* 1. Redistributions of source code must retain the above copyright122* notice, this list of conditions, and the following disclaimer,123* without modification.124* 2. Redistributions in binary form must reproduce at minimum a disclaimer125* substantially similar to the "NO WARRANTY" disclaimer below126* ("Disclaimer") and any redistribution must be conditioned upon127* including a substantially similar Disclaimer requirement for further128* binary redistribution.129* 3. Neither the names of the above-listed copyright holders nor the names130* of any contributors may be used to endorse or promote products derived131* from this software without specific prior written permission.132*133* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS134* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT135* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR136* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT137* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,138* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT139* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,140* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY141* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT142* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE143* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.144*145* Alternatively, you may choose to be licensed under the terms of the146* GNU General Public License ("GPL") version 2 as published by the Free147* Software Foundation.148*149*****************************************************************************/150151/*152* These procedures are used for tracking memory leaks in the subsystem, and153* they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set.154*155* Each memory allocation is tracked via a doubly linked list. Each156* element contains the caller's component, module name, function name, and157* line number. AcpiUtAllocate and AcpiUtAllocateZeroed call158* AcpiUtTrackAllocation to add an element to the list; deletion159* occurs in the body of AcpiUtFree.160*/161162#include <contrib/dev/acpica/include/acpi.h>163#include <contrib/dev/acpica/include/accommon.h>164165#ifdef ACPI_DBG_TRACK_ALLOCATIONS166167#define _COMPONENT ACPI_UTILITIES168ACPI_MODULE_NAME ("uttrack")169170171/* Local prototypes */172173static ACPI_DEBUG_MEM_BLOCK *174AcpiUtFindAllocation (175ACPI_DEBUG_MEM_BLOCK *Allocation);176177static ACPI_STATUS178AcpiUtTrackAllocation (179ACPI_DEBUG_MEM_BLOCK *Address,180ACPI_SIZE Size,181UINT8 AllocType,182UINT32 Component,183const char *Module,184UINT32 Line);185186static ACPI_STATUS187AcpiUtRemoveAllocation (188ACPI_DEBUG_MEM_BLOCK *Address,189UINT32 Component,190const char *Module,191UINT32 Line);192193194/*******************************************************************************195*196* FUNCTION: AcpiUtCreateList197*198* PARAMETERS: CacheName - Ascii name for the cache199* ObjectSize - Size of each cached object200* ReturnCache - Where the new cache object is returned201*202* RETURN: Status203*204* DESCRIPTION: Create a local memory list for tracking purposed205*206******************************************************************************/207208ACPI_STATUS209AcpiUtCreateList (210const char *ListName,211UINT16 ObjectSize,212ACPI_MEMORY_LIST **ReturnCache)213{214ACPI_MEMORY_LIST *Cache;215216217Cache = AcpiOsAllocateZeroed (sizeof (ACPI_MEMORY_LIST));218if (!Cache)219{220return (AE_NO_MEMORY);221}222223Cache->ListName = ListName;224Cache->ObjectSize = ObjectSize;225226*ReturnCache = Cache;227return (AE_OK);228}229230231/*******************************************************************************232*233* FUNCTION: AcpiUtAllocateAndTrack234*235* PARAMETERS: Size - Size of the allocation236* Component - Component type of caller237* Module - Source file name of caller238* Line - Line number of caller239*240* RETURN: Address of the allocated memory on success, NULL on failure.241*242* DESCRIPTION: The subsystem's equivalent of malloc.243*244******************************************************************************/245246void *247AcpiUtAllocateAndTrack (248ACPI_SIZE Size,249UINT32 Component,250const char *Module,251UINT32 Line)252{253ACPI_DEBUG_MEM_BLOCK *Allocation;254ACPI_STATUS Status;255256257/* Check for an inadvertent size of zero bytes */258259if (!Size)260{261ACPI_WARNING ((Module, Line,262"Attempt to allocate zero bytes, allocating 1 byte"));263Size = 1;264}265266Allocation = AcpiOsAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER));267if (!Allocation)268{269/* Report allocation error */270271ACPI_WARNING ((Module, Line,272"Could not allocate size %u", (UINT32) Size));273274return (NULL);275}276277Status = AcpiUtTrackAllocation (278Allocation, Size, ACPI_MEM_MALLOC, Component, Module, Line);279if (ACPI_FAILURE (Status))280{281AcpiOsFree (Allocation);282return (NULL);283}284285AcpiGbl_GlobalList->TotalAllocated++;286AcpiGbl_GlobalList->TotalSize += (UINT32) Size;287AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size;288289if (AcpiGbl_GlobalList->CurrentTotalSize >290AcpiGbl_GlobalList->MaxOccupied)291{292AcpiGbl_GlobalList->MaxOccupied =293AcpiGbl_GlobalList->CurrentTotalSize;294}295296return ((void *) &Allocation->UserSpace);297}298299300/*******************************************************************************301*302* FUNCTION: AcpiUtAllocateZeroedAndTrack303*304* PARAMETERS: Size - Size of the allocation305* Component - Component type of caller306* Module - Source file name of caller307* Line - Line number of caller308*309* RETURN: Address of the allocated memory on success, NULL on failure.310*311* DESCRIPTION: Subsystem equivalent of calloc.312*313******************************************************************************/314315void *316AcpiUtAllocateZeroedAndTrack (317ACPI_SIZE Size,318UINT32 Component,319const char *Module,320UINT32 Line)321{322ACPI_DEBUG_MEM_BLOCK *Allocation;323ACPI_STATUS Status;324325326/* Check for an inadvertent size of zero bytes */327328if (!Size)329{330ACPI_WARNING ((Module, Line,331"Attempt to allocate zero bytes, allocating 1 byte"));332Size = 1;333}334335Allocation = AcpiOsAllocateZeroed (336Size + sizeof (ACPI_DEBUG_MEM_HEADER));337if (!Allocation)338{339/* Report allocation error */340341ACPI_ERROR ((Module, Line,342"Could not allocate size %u", (UINT32) Size));343return (NULL);344}345346Status = AcpiUtTrackAllocation (Allocation, Size,347ACPI_MEM_CALLOC, Component, Module, Line);348if (ACPI_FAILURE (Status))349{350AcpiOsFree (Allocation);351return (NULL);352}353354AcpiGbl_GlobalList->TotalAllocated++;355AcpiGbl_GlobalList->TotalSize += (UINT32) Size;356AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size;357358if (AcpiGbl_GlobalList->CurrentTotalSize >359AcpiGbl_GlobalList->MaxOccupied)360{361AcpiGbl_GlobalList->MaxOccupied =362AcpiGbl_GlobalList->CurrentTotalSize;363}364365return ((void *) &Allocation->UserSpace);366}367368369/*******************************************************************************370*371* FUNCTION: AcpiUtFreeAndTrack372*373* PARAMETERS: Allocation - Address of the memory to deallocate374* Component - Component type of caller375* Module - Source file name of caller376* Line - Line number of caller377*378* RETURN: None379*380* DESCRIPTION: Frees the memory at Allocation381*382******************************************************************************/383384void385AcpiUtFreeAndTrack (386void *Allocation,387UINT32 Component,388const char *Module,389UINT32 Line)390{391ACPI_DEBUG_MEM_BLOCK *DebugBlock;392ACPI_STATUS Status;393394395ACPI_FUNCTION_TRACE_PTR (UtFree, Allocation);396397398if (NULL == Allocation)399{400ACPI_ERROR ((Module, Line,401"Attempt to delete a NULL address"));402403return_VOID;404}405406DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK,407(((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER)));408409AcpiGbl_GlobalList->TotalFreed++;410AcpiGbl_GlobalList->CurrentTotalSize -= DebugBlock->Size;411412Status = AcpiUtRemoveAllocation (DebugBlock, Component, Module, Line);413if (ACPI_FAILURE (Status))414{415ACPI_EXCEPTION ((AE_INFO, Status, "Could not free memory"));416}417418AcpiOsFree (DebugBlock);419ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed (block %p)\n",420Allocation, DebugBlock));421return_VOID;422}423424425/*******************************************************************************426*427* FUNCTION: AcpiUtFindAllocation428*429* PARAMETERS: Allocation - Address of allocated memory430*431* RETURN: Three cases:432* 1) List is empty, NULL is returned.433* 2) Element was found. Returns Allocation parameter.434* 3) Element was not found. Returns position where it should be435* inserted into the list.436*437* DESCRIPTION: Searches for an element in the global allocation tracking list.438* If the element is not found, returns the location within the439* list where the element should be inserted.440*441* Note: The list is ordered by larger-to-smaller addresses.442*443* This global list is used to detect memory leaks in ACPICA as444* well as other issues such as an attempt to release the same445* internal object more than once. Although expensive as far446* as cpu time, this list is much more helpful for finding these447* types of issues than using memory leak detectors outside of448* the ACPICA code.449*450******************************************************************************/451452static ACPI_DEBUG_MEM_BLOCK *453AcpiUtFindAllocation (454ACPI_DEBUG_MEM_BLOCK *Allocation)455{456ACPI_DEBUG_MEM_BLOCK *Element;457458459Element = AcpiGbl_GlobalList->ListHead;460if (!Element)461{462return (NULL);463}464465/*466* Search for the address.467*468* Note: List is ordered by larger-to-smaller addresses, on the469* assumption that a new allocation usually has a larger address470* than previous allocations.471*/472while (Element > Allocation)473{474/* Check for end-of-list */475476if (!Element->Next)477{478return (Element);479}480481Element = Element->Next;482}483484if (Element == Allocation)485{486return (Element);487}488489return (Element->Previous);490}491492493/*******************************************************************************494*495* FUNCTION: AcpiUtTrackAllocation496*497* PARAMETERS: Allocation - Address of allocated memory498* Size - Size of the allocation499* AllocType - MEM_MALLOC or MEM_CALLOC500* Component - Component type of caller501* Module - Source file name of caller502* Line - Line number of caller503*504* RETURN: Status505*506* DESCRIPTION: Inserts an element into the global allocation tracking list.507*508******************************************************************************/509510static ACPI_STATUS511AcpiUtTrackAllocation (512ACPI_DEBUG_MEM_BLOCK *Allocation,513ACPI_SIZE Size,514UINT8 AllocType,515UINT32 Component,516const char *Module,517UINT32 Line)518{519ACPI_MEMORY_LIST *MemList;520ACPI_DEBUG_MEM_BLOCK *Element;521ACPI_STATUS Status = AE_OK;522523524ACPI_FUNCTION_TRACE_PTR (UtTrackAllocation, Allocation);525526527if (AcpiGbl_DisableMemTracking)528{529return_ACPI_STATUS (AE_OK);530}531532MemList = AcpiGbl_GlobalList;533Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);534if (ACPI_FAILURE (Status))535{536return_ACPI_STATUS (Status);537}538539/*540* Search the global list for this address to make sure it is not541* already present. This will catch several kinds of problems.542*/543Element = AcpiUtFindAllocation (Allocation);544if (Element == Allocation)545{546ACPI_ERROR ((AE_INFO,547"UtTrackAllocation: Allocation (%p) already present in global list!",548Allocation));549goto UnlockAndExit;550}551552/* Fill in the instance data */553554Allocation->Size = (UINT32) Size;555Allocation->AllocType = AllocType;556Allocation->Component = Component;557Allocation->Line = Line;558559AcpiUtSafeStrncpy (Allocation->Module, (char *) Module, ACPI_MAX_MODULE_NAME);560561if (!Element)562{563/* Insert at list head */564565if (MemList->ListHead)566{567((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous =568Allocation;569}570571Allocation->Next = MemList->ListHead;572Allocation->Previous = NULL;573574MemList->ListHead = Allocation;575}576else577{578/* Insert after element */579580Allocation->Next = Element->Next;581Allocation->Previous = Element;582583if (Element->Next)584{585(Element->Next)->Previous = Allocation;586}587588Element->Next = Allocation;589}590591592UnlockAndExit:593Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);594return_ACPI_STATUS (Status);595}596597598/*******************************************************************************599*600* FUNCTION: AcpiUtRemoveAllocation601*602* PARAMETERS: Allocation - Address of allocated memory603* Component - Component type of caller604* Module - Source file name of caller605* Line - Line number of caller606*607* RETURN: Status608*609* DESCRIPTION: Deletes an element from the global allocation tracking list.610*611******************************************************************************/612613static ACPI_STATUS614AcpiUtRemoveAllocation (615ACPI_DEBUG_MEM_BLOCK *Allocation,616UINT32 Component,617const char *Module,618UINT32 Line)619{620ACPI_MEMORY_LIST *MemList;621ACPI_STATUS Status;622623624ACPI_FUNCTION_NAME (UtRemoveAllocation);625626627if (AcpiGbl_DisableMemTracking)628{629return (AE_OK);630}631632MemList = AcpiGbl_GlobalList;633if (NULL == MemList->ListHead)634{635/* No allocations! */636637ACPI_ERROR ((Module, Line,638"Empty allocation list, nothing to free!"));639640return (AE_OK);641}642643Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);644if (ACPI_FAILURE (Status))645{646return (Status);647}648649/* Unlink */650651if (Allocation->Previous)652{653(Allocation->Previous)->Next = Allocation->Next;654}655else656{657MemList->ListHead = Allocation->Next;658}659660if (Allocation->Next)661{662(Allocation->Next)->Previous = Allocation->Previous;663}664665ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing %p, size 0%X\n",666&Allocation->UserSpace, Allocation->Size));667668/* Mark the segment as deleted */669670memset (&Allocation->UserSpace, 0xEA, Allocation->Size);671672Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);673return (Status);674}675676677/*******************************************************************************678*679* FUNCTION: AcpiUtDumpAllocationInfo680*681* PARAMETERS: None682*683* RETURN: None684*685* DESCRIPTION: Print some info about the outstanding allocations.686*687******************************************************************************/688689void690AcpiUtDumpAllocationInfo (691void)692{693/*694ACPI_MEMORY_LIST *MemList;695*/696697ACPI_FUNCTION_TRACE (UtDumpAllocationInfo);698699/*700ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,701("%30s: %4d (%3d Kb)\n", "Current allocations",702MemList->CurrentCount,703ROUND_UP_TO_1K (MemList->CurrentSize)));704705ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,706("%30s: %4d (%3d Kb)\n", "Max concurrent allocations",707MemList->MaxConcurrentCount,708ROUND_UP_TO_1K (MemList->MaxConcurrentSize)));709710711ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,712("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",713RunningObjectCount,714ROUND_UP_TO_1K (RunningObjectSize)));715716ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,717("%30s: %4d (%3d Kb)\n", "Total (all) allocations",718RunningAllocCount,719ROUND_UP_TO_1K (RunningAllocSize)));720721722ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,723("%30s: %4d (%3d Kb)\n", "Current Nodes",724AcpiGbl_CurrentNodeCount,725ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize)));726727ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,728("%30s: %4d (%3d Kb)\n", "Max Nodes",729AcpiGbl_MaxConcurrentNodeCount,730ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount *731sizeof (ACPI_NAMESPACE_NODE)))));732*/733return_VOID;734}735736737/*******************************************************************************738*739* FUNCTION: AcpiUtDumpAllocations740*741* PARAMETERS: Component - Component(s) to dump info for.742* Module - Module to dump info for. NULL means all.743*744* RETURN: None745*746* DESCRIPTION: Print a list of all outstanding allocations.747*748******************************************************************************/749750void751AcpiUtDumpAllocations (752UINT32 Component,753const char *Module)754{755ACPI_DEBUG_MEM_BLOCK *Element;756ACPI_DESCRIPTOR *Descriptor;757UINT32 NumOutstanding = 0;758UINT8 DescriptorType;759760761ACPI_FUNCTION_TRACE (UtDumpAllocations);762763764if (AcpiGbl_DisableMemTracking)765{766return_VOID;767}768769/*770* Walk the allocation list.771*/772if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY)))773{774return_VOID;775}776777if (!AcpiGbl_GlobalList)778{779goto Exit;780}781782Element = AcpiGbl_GlobalList->ListHead;783while (Element)784{785if ((Element->Component & Component) &&786((Module == NULL) || (0 == strcmp (Module, Element->Module))))787{788Descriptor = ACPI_CAST_PTR (789ACPI_DESCRIPTOR, &Element->UserSpace);790791if (Element->Size < sizeof (ACPI_COMMON_DESCRIPTOR))792{793AcpiOsPrintf ("%p Length 0x%04X %9.9s-%4.4u "794"[Not a Descriptor - too small]\n",795Descriptor, Element->Size, Element->Module,796Element->Line);797}798else799{800/* Ignore allocated objects that are in a cache */801802if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) !=803ACPI_DESC_TYPE_CACHED)804{805AcpiOsPrintf ("%p Length 0x%04X %9.9s-%4.4u [%s] ",806Descriptor, Element->Size, Element->Module,807Element->Line, AcpiUtGetDescriptorName (Descriptor));808809/* Optional object hex dump */810811if (AcpiGbl_VerboseLeakDump)812{813AcpiOsPrintf ("\n");814AcpiUtDumpBuffer ((UINT8 *) Descriptor, Element->Size,815DB_BYTE_DISPLAY, 0);816}817818/* Validate the descriptor type using Type field and length */819820DescriptorType = 0; /* Not a valid descriptor type */821822switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor))823{824case ACPI_DESC_TYPE_OPERAND:825826if (Element->Size == sizeof (ACPI_OPERAND_OBJECT))827{828DescriptorType = ACPI_DESC_TYPE_OPERAND;829}830break;831832case ACPI_DESC_TYPE_PARSER:833834if (Element->Size == sizeof (ACPI_PARSE_OBJECT))835{836DescriptorType = ACPI_DESC_TYPE_PARSER;837}838break;839840case ACPI_DESC_TYPE_NAMED:841842if (Element->Size == sizeof (ACPI_NAMESPACE_NODE))843{844DescriptorType = ACPI_DESC_TYPE_NAMED;845}846break;847848default:849850break;851}852853/* Display additional info for the major descriptor types */854855switch (DescriptorType)856{857case ACPI_DESC_TYPE_OPERAND:858859AcpiOsPrintf ("%12.12s RefCount 0x%04X\n",860AcpiUtGetTypeName (Descriptor->Object.Common.Type),861Descriptor->Object.Common.ReferenceCount);862break;863864case ACPI_DESC_TYPE_PARSER:865866AcpiOsPrintf ("AmlOpcode 0x%04X\n",867Descriptor->Op.Asl.AmlOpcode);868break;869870case ACPI_DESC_TYPE_NAMED:871872AcpiOsPrintf ("%4.4s\n",873AcpiUtGetNodeName (&Descriptor->Node));874break;875876default:877878AcpiOsPrintf ( "\n");879break;880}881}882}883884NumOutstanding++;885}886887Element = Element->Next;888}889890Exit:891(void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY);892893/* Print summary */894895if (!NumOutstanding)896{897ACPI_INFO (("No outstanding allocations"));898}899else900{901ACPI_ERROR ((AE_INFO, "%u (0x%X) Outstanding cache allocations",902NumOutstanding, NumOutstanding));903}904905return_VOID;906}907908#endif /* ACPI_DBG_TRACK_ALLOCATIONS */909910911