uttrack.c revision 193249
1218885Sdim/******************************************************************************
2218885Sdim *
3218885Sdim * Module Name: uttrack - Memory allocation tracking routines (debug only)
4218885Sdim *              $Revision: 1.5 $
5218885Sdim *
6218885Sdim *****************************************************************************/
7218885Sdim
8218885Sdim/******************************************************************************
9218885Sdim *
10218885Sdim * 1. Copyright Notice
11218885Sdim *
12218885Sdim * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp.
13218885Sdim * All rights reserved.
14218885Sdim *
15218885Sdim * 2. License
16218885Sdim *
17218885Sdim * 2.1. This is your license from Intel Corp. under its intellectual property
18218885Sdim * rights.  You may have additional license terms from the party that provided
19218885Sdim * you this software, covering your right to use that party's intellectual
20218885Sdim * property rights.
21218885Sdim *
22218885Sdim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23218885Sdim * copy of the source code appearing in this file ("Covered Code") an
24218885Sdim * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25218885Sdim * base code distributed originally by Intel ("Original Intel Code") to copy,
26218885Sdim * make derivatives, distribute, use and display any portion of the Covered
27218885Sdim * Code in any form, with the right to sublicense such rights; and
28218885Sdim *
29218885Sdim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30218885Sdim * license (with the right to sublicense), under only those claims of Intel
31218885Sdim * patents that are infringed by the Original Intel Code, to make, use, sell,
32218885Sdim * offer to sell, and import the Covered Code and derivative works thereof
33218885Sdim * solely to the minimum extent necessary to exercise the above copyright
34218885Sdim * license, and in no event shall the patent license extend to any additions
35218885Sdim * to or modifications of the Original Intel Code.  No other license or right
36218885Sdim * is granted directly or by implication, estoppel or otherwise;
37218885Sdim *
38218885Sdim * The above copyright and patent license is granted only if the following
39218885Sdim * conditions are met:
40218885Sdim *
41218885Sdim * 3. Conditions
42218885Sdim *
43218885Sdim * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44218885Sdim * Redistribution of source code of any substantial portion of the Covered
45218885Sdim * Code or modification with rights to further distribute source must include
46218885Sdim * the above Copyright Notice, the above License, this list of Conditions,
47218885Sdim * and the following Disclaimer and Export Compliance provision.  In addition,
48218885Sdim * Licensee must cause all Covered Code to which Licensee contributes to
49218885Sdim * contain a file documenting the changes Licensee made to create that Covered
50218885Sdim * Code and the date of any change.  Licensee must include in that file the
51218885Sdim * documentation of any changes made by any predecessor Licensee.  Licensee
52218885Sdim * must include a prominent statement that the modification is derived,
53218885Sdim * directly or indirectly, from Original Intel Code.
54218885Sdim *
55218885Sdim * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56218885Sdim * Redistribution of source code of any substantial portion of the Covered
57218885Sdim * Code or modification without rights to further distribute source must
58218885Sdim * include the following Disclaimer and Export Compliance provision in the
59218885Sdim * documentation and/or other materials provided with distribution.  In
60218885Sdim * addition, Licensee may not authorize further sublicense of source of any
61218885Sdim * portion of the Covered Code, and must include terms to the effect that the
62218885Sdim * license from Licensee to its licensee is limited to the intellectual
63218885Sdim * property embodied in the software Licensee provides to its licensee, and
64218885Sdim * not to intellectual property embodied in modifications its licensee may
65218885Sdim * make.
66218885Sdim *
67218885Sdim * 3.3. Redistribution of Executable. Redistribution in executable form of any
68218885Sdim * substantial portion of the Covered Code or modification must reproduce the
69218885Sdim * above Copyright Notice, and the following Disclaimer and Export Compliance
70218885Sdim * provision in the documentation and/or other materials provided with the
71218885Sdim * distribution.
72218885Sdim *
73218885Sdim * 3.4. Intel retains all right, title, and interest in and to the Original
74218885Sdim * Intel Code.
75218885Sdim *
76218885Sdim * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77218885Sdim * Intel shall be used in advertising or otherwise to promote the sale, use or
78218885Sdim * other dealings in products derived from or relating to the Covered Code
79218885Sdim * without prior written authorization from Intel.
80218885Sdim *
81218885Sdim * 4. Disclaimer and Export Compliance
82218885Sdim *
83218885Sdim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84218885Sdim * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85218885Sdim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86218885Sdim * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87218885Sdim * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88218885Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89218885Sdim * PARTICULAR PURPOSE.
90218885Sdim *
91218885Sdim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92218885Sdim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93218885Sdim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94218885Sdim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95218885Sdim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96218885Sdim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97218885Sdim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98218885Sdim * LIMITED REMEDY.
99218885Sdim *
100218885Sdim * 4.3. Licensee shall not export, either directly or indirectly, any of this
101218885Sdim * software or system incorporating such software without first obtaining any
102218885Sdim * required license or other approval from the U. S. Department of Commerce or
103218885Sdim * any other agency or department of the United States Government.  In the
104218885Sdim * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117/*
118 * These procedures are used for tracking memory leaks in the subsystem, and
119 * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set.
120 *
121 * Each memory allocation is tracked via a doubly linked list.  Each
122 * element contains the caller's component, module name, function name, and
123 * line number.  AcpiUtAllocate and AcpiUtAllocateZeroed call
124 * AcpiUtTrackAllocation to add an element to the list; deletion
125 * occurs in the body of AcpiUtFree.
126 */
127
128#define __UTTRACK_C__
129
130#include <contrib/dev/acpica/acpi.h>
131
132#ifdef ACPI_DBG_TRACK_ALLOCATIONS
133
134#define _COMPONENT          ACPI_UTILITIES
135        ACPI_MODULE_NAME    ("uttrack")
136
137/* Local prototypes */
138
139static ACPI_DEBUG_MEM_BLOCK *
140AcpiUtFindAllocation (
141    void                    *Allocation);
142
143static ACPI_STATUS
144AcpiUtTrackAllocation (
145    ACPI_DEBUG_MEM_BLOCK    *Address,
146    ACPI_SIZE               Size,
147    UINT8                   AllocType,
148    UINT32                  Component,
149    char                    *Module,
150    UINT32                  Line);
151
152static ACPI_STATUS
153AcpiUtRemoveAllocation (
154    ACPI_DEBUG_MEM_BLOCK    *Address,
155    UINT32                  Component,
156    char                    *Module,
157    UINT32                  Line);
158
159
160/*******************************************************************************
161 *
162 * FUNCTION:    AcpiUtCreateList
163 *
164 * PARAMETERS:  CacheName       - Ascii name for the cache
165 *              ObjectSize      - Size of each cached object
166 *              ReturnCache     - Where the new cache object is returned
167 *
168 * RETURN:      Status
169 *
170 * DESCRIPTION: Create a local memory list for tracking purposed
171 *
172 ******************************************************************************/
173
174ACPI_STATUS
175AcpiUtCreateList (
176    char                    *ListName,
177    UINT16                  ObjectSize,
178    ACPI_MEMORY_LIST        **ReturnCache)
179{
180    ACPI_MEMORY_LIST        *Cache;
181
182
183    Cache = AcpiOsAllocate (sizeof (ACPI_MEMORY_LIST));
184    if (!Cache)
185    {
186        return (AE_NO_MEMORY);
187    }
188
189    ACPI_MEMSET (Cache, 0, sizeof (ACPI_MEMORY_LIST));
190
191    Cache->ListName   = ListName;
192    Cache->ObjectSize = ObjectSize;
193
194    *ReturnCache = Cache;
195    return (AE_OK);
196}
197
198
199/*******************************************************************************
200 *
201 * FUNCTION:    AcpiUtAllocateAndTrack
202 *
203 * PARAMETERS:  Size                - Size of the allocation
204 *              Component           - Component type of caller
205 *              Module              - Source file name of caller
206 *              Line                - Line number of caller
207 *
208 * RETURN:      Address of the allocated memory on success, NULL on failure.
209 *
210 * DESCRIPTION: The subsystem's equivalent of malloc.
211 *
212 ******************************************************************************/
213
214void *
215AcpiUtAllocateAndTrack (
216    ACPI_SIZE               Size,
217    UINT32                  Component,
218    char                    *Module,
219    UINT32                  Line)
220{
221    ACPI_DEBUG_MEM_BLOCK    *Allocation;
222    ACPI_STATUS             Status;
223
224
225    Allocation = AcpiUtAllocate (Size + sizeof (ACPI_DEBUG_MEM_HEADER),
226                    Component, Module, Line);
227    if (!Allocation)
228    {
229        return (NULL);
230    }
231
232    Status = AcpiUtTrackAllocation (Allocation, Size,
233                    ACPI_MEM_MALLOC, Component, Module, Line);
234    if (ACPI_FAILURE (Status))
235    {
236        AcpiOsFree (Allocation);
237        return (NULL);
238    }
239
240    AcpiGbl_GlobalList->TotalAllocated++;
241    AcpiGbl_GlobalList->TotalSize += (UINT32) Size;
242    AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size;
243    if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied)
244    {
245        AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize;
246    }
247
248    return ((void *) &Allocation->UserSpace);
249}
250
251
252/*******************************************************************************
253 *
254 * FUNCTION:    AcpiUtAllocateZeroedAndTrack
255 *
256 * PARAMETERS:  Size                - Size of the allocation
257 *              Component           - Component type of caller
258 *              Module              - Source file name of caller
259 *              Line                - Line number of caller
260 *
261 * RETURN:      Address of the allocated memory on success, NULL on failure.
262 *
263 * DESCRIPTION: Subsystem equivalent of calloc.
264 *
265 ******************************************************************************/
266
267void *
268AcpiUtAllocateZeroedAndTrack (
269    ACPI_SIZE               Size,
270    UINT32                  Component,
271    char                    *Module,
272    UINT32                  Line)
273{
274    ACPI_DEBUG_MEM_BLOCK    *Allocation;
275    ACPI_STATUS             Status;
276
277
278    Allocation = AcpiUtAllocateZeroed (Size + sizeof (ACPI_DEBUG_MEM_HEADER),
279                    Component, Module, Line);
280    if (!Allocation)
281    {
282        /* Report allocation error */
283
284        ACPI_ERROR ((Module, Line,
285            "Could not allocate size %X", (UINT32) Size));
286        return (NULL);
287    }
288
289    Status = AcpiUtTrackAllocation (Allocation, Size,
290                ACPI_MEM_CALLOC, Component, Module, Line);
291    if (ACPI_FAILURE (Status))
292    {
293        AcpiOsFree (Allocation);
294        return (NULL);
295    }
296
297    AcpiGbl_GlobalList->TotalAllocated++;
298    AcpiGbl_GlobalList->TotalSize += (UINT32) Size;
299    AcpiGbl_GlobalList->CurrentTotalSize += (UINT32) Size;
300    if (AcpiGbl_GlobalList->CurrentTotalSize > AcpiGbl_GlobalList->MaxOccupied)
301    {
302        AcpiGbl_GlobalList->MaxOccupied = AcpiGbl_GlobalList->CurrentTotalSize;
303    }
304
305    return ((void *) &Allocation->UserSpace);
306}
307
308
309/*******************************************************************************
310 *
311 * FUNCTION:    AcpiUtFreeAndTrack
312 *
313 * PARAMETERS:  Allocation          - Address of the memory to deallocate
314 *              Component           - Component type of caller
315 *              Module              - Source file name of caller
316 *              Line                - Line number of caller
317 *
318 * RETURN:      None
319 *
320 * DESCRIPTION: Frees the memory at Allocation
321 *
322 ******************************************************************************/
323
324void
325AcpiUtFreeAndTrack (
326    void                    *Allocation,
327    UINT32                  Component,
328    char                    *Module,
329    UINT32                  Line)
330{
331    ACPI_DEBUG_MEM_BLOCK    *DebugBlock;
332    ACPI_STATUS             Status;
333
334
335    ACPI_FUNCTION_TRACE_PTR (UtFree, Allocation);
336
337
338    if (NULL == Allocation)
339    {
340        ACPI_ERROR ((Module, Line,
341            "Attempt to delete a NULL address"));
342
343        return_VOID;
344    }
345
346    DebugBlock = ACPI_CAST_PTR (ACPI_DEBUG_MEM_BLOCK,
347                    (((char *) Allocation) - sizeof (ACPI_DEBUG_MEM_HEADER)));
348
349    AcpiGbl_GlobalList->TotalFreed++;
350    AcpiGbl_GlobalList->CurrentTotalSize -= DebugBlock->Size;
351
352    Status = AcpiUtRemoveAllocation (DebugBlock,
353                    Component, Module, Line);
354    if (ACPI_FAILURE (Status))
355    {
356        ACPI_EXCEPTION ((AE_INFO, Status, "Could not free memory"));
357    }
358
359    AcpiOsFree (DebugBlock);
360    ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "%p freed\n", Allocation));
361    return_VOID;
362}
363
364
365/*******************************************************************************
366 *
367 * FUNCTION:    AcpiUtFindAllocation
368 *
369 * PARAMETERS:  Allocation              - Address of allocated memory
370 *
371 * RETURN:      A list element if found; NULL otherwise.
372 *
373 * DESCRIPTION: Searches for an element in the global allocation tracking list.
374 *
375 ******************************************************************************/
376
377static ACPI_DEBUG_MEM_BLOCK *
378AcpiUtFindAllocation (
379    void                    *Allocation)
380{
381    ACPI_DEBUG_MEM_BLOCK    *Element;
382
383
384    ACPI_FUNCTION_ENTRY ();
385
386
387    Element = AcpiGbl_GlobalList->ListHead;
388
389    /* Search for the address. */
390
391    while (Element)
392    {
393        if (Element == Allocation)
394        {
395            return (Element);
396        }
397
398        Element = Element->Next;
399    }
400
401    return (NULL);
402}
403
404
405/*******************************************************************************
406 *
407 * FUNCTION:    AcpiUtTrackAllocation
408 *
409 * PARAMETERS:  Allocation          - Address of allocated memory
410 *              Size                - Size of the allocation
411 *              AllocType           - MEM_MALLOC or MEM_CALLOC
412 *              Component           - Component type of caller
413 *              Module              - Source file name of caller
414 *              Line                - Line number of caller
415 *
416 * RETURN:      None.
417 *
418 * DESCRIPTION: Inserts an element into the global allocation tracking list.
419 *
420 ******************************************************************************/
421
422static ACPI_STATUS
423AcpiUtTrackAllocation (
424    ACPI_DEBUG_MEM_BLOCK    *Allocation,
425    ACPI_SIZE               Size,
426    UINT8                   AllocType,
427    UINT32                  Component,
428    char                    *Module,
429    UINT32                  Line)
430{
431    ACPI_MEMORY_LIST        *MemList;
432    ACPI_DEBUG_MEM_BLOCK    *Element;
433    ACPI_STATUS             Status = AE_OK;
434
435
436    ACPI_FUNCTION_TRACE_PTR (UtTrackAllocation, Allocation);
437
438
439    MemList = AcpiGbl_GlobalList;
440    Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
441    if (ACPI_FAILURE (Status))
442    {
443        return_ACPI_STATUS (Status);
444    }
445
446    /*
447     * Search list for this address to make sure it is not already on the list.
448     * This will catch several kinds of problems.
449     */
450    Element = AcpiUtFindAllocation (Allocation);
451    if (Element)
452    {
453        ACPI_ERROR ((AE_INFO,
454            "UtTrackAllocation: Allocation already present in list! (%p)",
455            Allocation));
456
457        ACPI_ERROR ((AE_INFO, "Element %p Address %p",
458            Element, Allocation));
459
460        goto UnlockAndExit;
461    }
462
463    /* Fill in the instance data. */
464
465    Allocation->Size      = (UINT32) Size;
466    Allocation->AllocType = AllocType;
467    Allocation->Component = Component;
468    Allocation->Line      = Line;
469
470    ACPI_STRNCPY (Allocation->Module, Module, ACPI_MAX_MODULE_NAME);
471    Allocation->Module[ACPI_MAX_MODULE_NAME-1] = 0;
472
473    /* Insert at list head */
474
475    if (MemList->ListHead)
476    {
477        ((ACPI_DEBUG_MEM_BLOCK *)(MemList->ListHead))->Previous = Allocation;
478    }
479
480    Allocation->Next = MemList->ListHead;
481    Allocation->Previous = NULL;
482
483    MemList->ListHead = Allocation;
484
485
486UnlockAndExit:
487    Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
488    return_ACPI_STATUS (Status);
489}
490
491
492/*******************************************************************************
493 *
494 * FUNCTION:    AcpiUtRemoveAllocation
495 *
496 * PARAMETERS:  Allocation          - Address of allocated memory
497 *              Component           - Component type of caller
498 *              Module              - Source file name of caller
499 *              Line                - Line number of caller
500 *
501 * RETURN:
502 *
503 * DESCRIPTION: Deletes an element from the global allocation tracking list.
504 *
505 ******************************************************************************/
506
507static ACPI_STATUS
508AcpiUtRemoveAllocation (
509    ACPI_DEBUG_MEM_BLOCK    *Allocation,
510    UINT32                  Component,
511    char                    *Module,
512    UINT32                  Line)
513{
514    ACPI_MEMORY_LIST        *MemList;
515    ACPI_STATUS             Status;
516
517
518    ACPI_FUNCTION_TRACE (UtRemoveAllocation);
519
520
521    MemList = AcpiGbl_GlobalList;
522    if (NULL == MemList->ListHead)
523    {
524        /* No allocations! */
525
526        ACPI_ERROR ((Module, Line,
527            "Empty allocation list, nothing to free!"));
528
529        return_ACPI_STATUS (AE_OK);
530    }
531
532    Status = AcpiUtAcquireMutex (ACPI_MTX_MEMORY);
533    if (ACPI_FAILURE (Status))
534    {
535        return_ACPI_STATUS (Status);
536    }
537
538    /* Unlink */
539
540    if (Allocation->Previous)
541    {
542        (Allocation->Previous)->Next = Allocation->Next;
543    }
544    else
545    {
546        MemList->ListHead = Allocation->Next;
547    }
548
549    if (Allocation->Next)
550    {
551        (Allocation->Next)->Previous = Allocation->Previous;
552    }
553
554    /* Mark the segment as deleted */
555
556    ACPI_MEMSET (&Allocation->UserSpace, 0xEA, Allocation->Size);
557
558    ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS, "Freeing size 0%X\n",
559        Allocation->Size));
560
561    Status = AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
562    return_ACPI_STATUS (Status);
563}
564
565
566/*******************************************************************************
567 *
568 * FUNCTION:    AcpiUtDumpAllocationInfo
569 *
570 * PARAMETERS:
571 *
572 * RETURN:      None
573 *
574 * DESCRIPTION: Print some info about the outstanding allocations.
575 *
576 ******************************************************************************/
577
578void
579AcpiUtDumpAllocationInfo (
580    void)
581{
582/*
583    ACPI_MEMORY_LIST        *MemList;
584*/
585
586    ACPI_FUNCTION_TRACE (UtDumpAllocationInfo);
587
588/*
589    ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
590                    ("%30s: %4d (%3d Kb)\n", "Current allocations",
591                    MemList->CurrentCount,
592                    ROUND_UP_TO_1K (MemList->CurrentSize)));
593
594    ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
595                    ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations",
596                    MemList->MaxConcurrentCount,
597                    ROUND_UP_TO_1K (MemList->MaxConcurrentSize)));
598
599
600    ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
601                    ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",
602                    RunningObjectCount,
603                    ROUND_UP_TO_1K (RunningObjectSize)));
604
605    ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
606                    ("%30s: %4d (%3d Kb)\n", "Total (all) allocations",
607                    RunningAllocCount,
608                    ROUND_UP_TO_1K (RunningAllocSize)));
609
610
611    ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
612                    ("%30s: %4d (%3d Kb)\n", "Current Nodes",
613                    AcpiGbl_CurrentNodeCount,
614                    ROUND_UP_TO_1K (AcpiGbl_CurrentNodeSize)));
615
616    ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
617                    ("%30s: %4d (%3d Kb)\n", "Max Nodes",
618                    AcpiGbl_MaxConcurrentNodeCount,
619                    ROUND_UP_TO_1K ((AcpiGbl_MaxConcurrentNodeCount *
620                        sizeof (ACPI_NAMESPACE_NODE)))));
621*/
622    return_VOID;
623}
624
625
626/*******************************************************************************
627 *
628 * FUNCTION:    AcpiUtDumpAllocations
629 *
630 * PARAMETERS:  Component           - Component(s) to dump info for.
631 *              Module              - Module to dump info for.  NULL means all.
632 *
633 * RETURN:      None
634 *
635 * DESCRIPTION: Print a list of all outstanding allocations.
636 *
637 ******************************************************************************/
638
639void
640AcpiUtDumpAllocations (
641    UINT32                  Component,
642    char                    *Module)
643{
644    ACPI_DEBUG_MEM_BLOCK    *Element;
645    ACPI_DESCRIPTOR         *Descriptor;
646    UINT32                  NumOutstanding = 0;
647
648
649    ACPI_FUNCTION_TRACE (UtDumpAllocations);
650
651
652    /*
653     * Walk the allocation list.
654     */
655    if (ACPI_FAILURE (AcpiUtAcquireMutex (ACPI_MTX_MEMORY)))
656    {
657        return;
658    }
659
660    Element = AcpiGbl_GlobalList->ListHead;
661    while (Element)
662    {
663        if ((Element->Component & Component) &&
664            ((Module == NULL) || (0 == ACPI_STRCMP (Module, Element->Module))))
665        {
666            /* Ignore allocated objects that are in a cache */
667
668            Descriptor = ACPI_CAST_PTR (ACPI_DESCRIPTOR, &Element->UserSpace);
669            if (ACPI_GET_DESCRIPTOR_TYPE (Descriptor) != ACPI_DESC_TYPE_CACHED)
670            {
671                AcpiOsPrintf ("%p Len %04X %9.9s-%d [%s] ",
672                    Descriptor, Element->Size, Element->Module,
673                    Element->Line, AcpiUtGetDescriptorName (Descriptor));
674
675                /* Most of the elements will be Operand objects. */
676
677                switch (ACPI_GET_DESCRIPTOR_TYPE (Descriptor))
678                {
679                case ACPI_DESC_TYPE_OPERAND:
680                    AcpiOsPrintf ("%12.12s R%hd",
681                        AcpiUtGetTypeName (Descriptor->Object.Common.Type),
682                        Descriptor->Object.Common.ReferenceCount);
683                    break;
684
685                case ACPI_DESC_TYPE_PARSER:
686                    AcpiOsPrintf ("AmlOpcode %04hX",
687                        Descriptor->Op.Asl.AmlOpcode);
688                    break;
689
690                case ACPI_DESC_TYPE_NAMED:
691                    AcpiOsPrintf ("%4.4s",
692                        AcpiUtGetNodeName (&Descriptor->Node));
693                    break;
694
695                default:
696                    break;
697                }
698
699                AcpiOsPrintf ( "\n");
700                NumOutstanding++;
701            }
702        }
703        Element = Element->Next;
704    }
705
706    (void) AcpiUtReleaseMutex (ACPI_MTX_MEMORY);
707
708    /* Print summary */
709
710    if (!NumOutstanding)
711    {
712        ACPI_INFO ((AE_INFO,
713            "No outstanding allocations"));
714    }
715    else
716    {
717        ACPI_ERROR ((AE_INFO,
718            "%d(%X) Outstanding allocations",
719            NumOutstanding, NumOutstanding));
720    }
721
722    return_VOID;
723}
724
725#endif  /* ACPI_DBG_TRACK_ALLOCATIONS */
726
727