blob: 160f13f4aab51a196200184c60cc625a5de4acc6 [file] [log] [blame]
Lv Zheng6d33b6b2012-10-31 02:25:05 +00001/******************************************************************************
2 *
3 * Module Name: uttrack - Memory allocation tracking routines (debug only)
4 *
5 *****************************************************************************/
6
7/*
Bob Moore25f044e2013-01-25 05:38:56 +00008 * Copyright (C) 2000 - 2013, Intel Corp.
Lv Zheng6d33b6b2012-10-31 02:25:05 +00009 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44/*
45 * These procedures are used for tracking memory leaks in the subsystem, and
46 * they get compiled out when the ACPI_DBG_TRACK_ALLOCATIONS is not set.
47 *
Bob Moore73a30902012-10-31 02:26:55 +000048 * Each memory allocation is tracked via a doubly linked list. Each
Lv Zheng6d33b6b2012-10-31 02:25:05 +000049 * element contains the caller's component, module name, function name, and
Bob Moore73a30902012-10-31 02:26:55 +000050 * line number. acpi_ut_allocate and acpi_ut_allocate_zeroed call
Lv Zheng6d33b6b2012-10-31 02:25:05 +000051 * acpi_ut_track_allocation to add an element to the list; deletion
52 * occurs in the body of acpi_ut_free.
53 */
54
55#include <acpi/acpi.h>
56#include "accommon.h"
57
58#ifdef ACPI_DBG_TRACK_ALLOCATIONS
59
60#define _COMPONENT ACPI_UTILITIES
61ACPI_MODULE_NAME("uttrack")
62
63/* Local prototypes */
Bob Moored8da9152012-10-31 02:27:32 +000064static struct acpi_debug_mem_block *acpi_ut_find_allocation(struct
65 acpi_debug_mem_block
66 *allocation);
Lv Zheng6d33b6b2012-10-31 02:25:05 +000067
68static acpi_status
69acpi_ut_track_allocation(struct acpi_debug_mem_block *address,
70 acpi_size size,
71 u8 alloc_type,
72 u32 component, const char *module, u32 line);
73
74static acpi_status
75acpi_ut_remove_allocation(struct acpi_debug_mem_block *address,
76 u32 component, const char *module, u32 line);
77
78/*******************************************************************************
79 *
80 * FUNCTION: acpi_ut_create_list
81 *
82 * PARAMETERS: cache_name - Ascii name for the cache
83 * object_size - Size of each cached object
84 * return_cache - Where the new cache object is returned
85 *
86 * RETURN: Status
87 *
88 * DESCRIPTION: Create a local memory list for tracking purposed
89 *
90 ******************************************************************************/
91
92acpi_status
93acpi_ut_create_list(char *list_name,
94 u16 object_size, struct acpi_memory_list **return_cache)
95{
96 struct acpi_memory_list *cache;
97
98 cache = acpi_os_allocate(sizeof(struct acpi_memory_list));
99 if (!cache) {
100 return (AE_NO_MEMORY);
101 }
102
103 ACPI_MEMSET(cache, 0, sizeof(struct acpi_memory_list));
104
105 cache->list_name = list_name;
106 cache->object_size = object_size;
107
108 *return_cache = cache;
109 return (AE_OK);
110}
111
112/*******************************************************************************
113 *
114 * FUNCTION: acpi_ut_allocate_and_track
115 *
116 * PARAMETERS: size - Size of the allocation
117 * component - Component type of caller
118 * module - Source file name of caller
119 * line - Line number of caller
120 *
121 * RETURN: Address of the allocated memory on success, NULL on failure.
122 *
123 * DESCRIPTION: The subsystem's equivalent of malloc.
124 *
125 ******************************************************************************/
126
127void *acpi_ut_allocate_and_track(acpi_size size,
128 u32 component, const char *module, u32 line)
129{
130 struct acpi_debug_mem_block *allocation;
131 acpi_status status;
132
133 allocation =
134 acpi_ut_allocate(size + sizeof(struct acpi_debug_mem_header),
135 component, module, line);
136 if (!allocation) {
137 return (NULL);
138 }
139
140 status = acpi_ut_track_allocation(allocation, size,
141 ACPI_MEM_MALLOC, component, module,
142 line);
143 if (ACPI_FAILURE(status)) {
144 acpi_os_free(allocation);
145 return (NULL);
146 }
147
148 acpi_gbl_global_list->total_allocated++;
149 acpi_gbl_global_list->total_size += (u32)size;
150 acpi_gbl_global_list->current_total_size += (u32)size;
151 if (acpi_gbl_global_list->current_total_size >
152 acpi_gbl_global_list->max_occupied) {
153 acpi_gbl_global_list->max_occupied =
154 acpi_gbl_global_list->current_total_size;
155 }
156
157 return ((void *)&allocation->user_space);
158}
159
160/*******************************************************************************
161 *
162 * FUNCTION: acpi_ut_allocate_zeroed_and_track
163 *
164 * PARAMETERS: size - Size of the allocation
165 * component - Component type of caller
166 * module - Source file name of caller
167 * line - Line number of caller
168 *
169 * RETURN: Address of the allocated memory on success, NULL on failure.
170 *
171 * DESCRIPTION: Subsystem equivalent of calloc.
172 *
173 ******************************************************************************/
174
175void *acpi_ut_allocate_zeroed_and_track(acpi_size size,
176 u32 component,
177 const char *module, u32 line)
178{
179 struct acpi_debug_mem_block *allocation;
180 acpi_status status;
181
182 allocation =
183 acpi_ut_allocate_zeroed(size + sizeof(struct acpi_debug_mem_header),
184 component, module, line);
185 if (!allocation) {
186
187 /* Report allocation error */
188
189 ACPI_ERROR((module, line,
190 "Could not allocate size %u", (u32)size));
191 return (NULL);
192 }
193
194 status = acpi_ut_track_allocation(allocation, size,
195 ACPI_MEM_CALLOC, component, module,
196 line);
197 if (ACPI_FAILURE(status)) {
198 acpi_os_free(allocation);
199 return (NULL);
200 }
201
202 acpi_gbl_global_list->total_allocated++;
203 acpi_gbl_global_list->total_size += (u32)size;
204 acpi_gbl_global_list->current_total_size += (u32)size;
205 if (acpi_gbl_global_list->current_total_size >
206 acpi_gbl_global_list->max_occupied) {
207 acpi_gbl_global_list->max_occupied =
208 acpi_gbl_global_list->current_total_size;
209 }
210
211 return ((void *)&allocation->user_space);
212}
213
214/*******************************************************************************
215 *
216 * FUNCTION: acpi_ut_free_and_track
217 *
218 * PARAMETERS: allocation - Address of the memory to deallocate
219 * component - Component type of caller
220 * module - Source file name of caller
221 * line - Line number of caller
222 *
223 * RETURN: None
224 *
225 * DESCRIPTION: Frees the memory at Allocation
226 *
227 ******************************************************************************/
228
229void
230acpi_ut_free_and_track(void *allocation,
231 u32 component, const char *module, u32 line)
232{
233 struct acpi_debug_mem_block *debug_block;
234 acpi_status status;
235
236 ACPI_FUNCTION_TRACE_PTR(ut_free, allocation);
237
238 if (NULL == allocation) {
239 ACPI_ERROR((module, line, "Attempt to delete a NULL address"));
240
241 return_VOID;
242 }
243
244 debug_block = ACPI_CAST_PTR(struct acpi_debug_mem_block,
245 (((char *)allocation) -
246 sizeof(struct acpi_debug_mem_header)));
247
248 acpi_gbl_global_list->total_freed++;
249 acpi_gbl_global_list->current_total_size -= debug_block->size;
250
251 status = acpi_ut_remove_allocation(debug_block,
252 component, module, line);
253 if (ACPI_FAILURE(status)) {
254 ACPI_EXCEPTION((AE_INFO, status, "Could not free memory"));
255 }
256
257 acpi_os_free(debug_block);
258 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "%p freed\n", allocation));
259 return_VOID;
260}
261
262/*******************************************************************************
263 *
264 * FUNCTION: acpi_ut_find_allocation
265 *
266 * PARAMETERS: allocation - Address of allocated memory
267 *
Bob Moored8da9152012-10-31 02:27:32 +0000268 * RETURN: Three cases:
269 * 1) List is empty, NULL is returned.
270 * 2) Element was found. Returns Allocation parameter.
271 * 3) Element was not found. Returns position where it should be
272 * inserted into the list.
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000273 *
274 * DESCRIPTION: Searches for an element in the global allocation tracking list.
Bob Moored8da9152012-10-31 02:27:32 +0000275 * If the element is not found, returns the location within the
276 * list where the element should be inserted.
277 *
278 * Note: The list is ordered by larger-to-smaller addresses.
279 *
280 * This global list is used to detect memory leaks in ACPICA as
281 * well as other issues such as an attempt to release the same
282 * internal object more than once. Although expensive as far
283 * as cpu time, this list is much more helpful for finding these
284 * types of issues than using memory leak detectors outside of
285 * the ACPICA code.
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000286 *
287 ******************************************************************************/
288
Bob Moored8da9152012-10-31 02:27:32 +0000289static struct acpi_debug_mem_block *acpi_ut_find_allocation(struct
290 acpi_debug_mem_block
291 *allocation)
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000292{
293 struct acpi_debug_mem_block *element;
294
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000295 element = acpi_gbl_global_list->list_head;
Bob Moored8da9152012-10-31 02:27:32 +0000296 if (!element) {
297 return (NULL);
298 }
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000299
Bob Moored8da9152012-10-31 02:27:32 +0000300 /*
301 * Search for the address.
302 *
303 * Note: List is ordered by larger-to-smaller addresses, on the
304 * assumption that a new allocation usually has a larger address
305 * than previous allocations.
306 */
307 while (element > allocation) {
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000308
Bob Moored8da9152012-10-31 02:27:32 +0000309 /* Check for end-of-list */
310
311 if (!element->next) {
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000312 return (element);
313 }
314
315 element = element->next;
316 }
317
Bob Moored8da9152012-10-31 02:27:32 +0000318 if (element == allocation) {
319 return (element);
320 }
321
322 return (element->previous);
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000323}
324
325/*******************************************************************************
326 *
327 * FUNCTION: acpi_ut_track_allocation
328 *
329 * PARAMETERS: allocation - Address of allocated memory
330 * size - Size of the allocation
331 * alloc_type - MEM_MALLOC or MEM_CALLOC
332 * component - Component type of caller
333 * module - Source file name of caller
334 * line - Line number of caller
335 *
Bob Moored8da9152012-10-31 02:27:32 +0000336 * RETURN: Status
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000337 *
338 * DESCRIPTION: Inserts an element into the global allocation tracking list.
339 *
340 ******************************************************************************/
341
342static acpi_status
343acpi_ut_track_allocation(struct acpi_debug_mem_block *allocation,
344 acpi_size size,
345 u8 alloc_type,
346 u32 component, const char *module, u32 line)
347{
348 struct acpi_memory_list *mem_list;
349 struct acpi_debug_mem_block *element;
350 acpi_status status = AE_OK;
351
352 ACPI_FUNCTION_TRACE_PTR(ut_track_allocation, allocation);
353
354 if (acpi_gbl_disable_mem_tracking) {
355 return_ACPI_STATUS(AE_OK);
356 }
357
358 mem_list = acpi_gbl_global_list;
359 status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY);
360 if (ACPI_FAILURE(status)) {
361 return_ACPI_STATUS(status);
362 }
363
364 /*
Bob Moored8da9152012-10-31 02:27:32 +0000365 * Search the global list for this address to make sure it is not
366 * already present. This will catch several kinds of problems.
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000367 */
368 element = acpi_ut_find_allocation(allocation);
Bob Moored8da9152012-10-31 02:27:32 +0000369 if (element == allocation) {
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000370 ACPI_ERROR((AE_INFO,
Bob Moored8da9152012-10-31 02:27:32 +0000371 "UtTrackAllocation: Allocation (%p) already present in global list!",
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000372 allocation));
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000373 goto unlock_and_exit;
374 }
375
Bob Moored8da9152012-10-31 02:27:32 +0000376 /* Fill in the instance data */
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000377
378 allocation->size = (u32)size;
379 allocation->alloc_type = alloc_type;
380 allocation->component = component;
381 allocation->line = line;
382
383 ACPI_STRNCPY(allocation->module, module, ACPI_MAX_MODULE_NAME);
384 allocation->module[ACPI_MAX_MODULE_NAME - 1] = 0;
385
Bob Moored8da9152012-10-31 02:27:32 +0000386 if (!element) {
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000387
Bob Moored8da9152012-10-31 02:27:32 +0000388 /* Insert at list head */
389
390 if (mem_list->list_head) {
391 ((struct acpi_debug_mem_block *)(mem_list->list_head))->
392 previous = allocation;
393 }
394
395 allocation->next = mem_list->list_head;
396 allocation->previous = NULL;
397
398 mem_list->list_head = allocation;
399 } else {
400 /* Insert after element */
401
402 allocation->next = element->next;
403 allocation->previous = element;
404
405 if (element->next) {
406 (element->next)->previous = allocation;
407 }
408
409 element->next = allocation;
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000410 }
411
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000412 unlock_and_exit:
413 status = acpi_ut_release_mutex(ACPI_MTX_MEMORY);
414 return_ACPI_STATUS(status);
415}
416
417/*******************************************************************************
418 *
419 * FUNCTION: acpi_ut_remove_allocation
420 *
421 * PARAMETERS: allocation - Address of allocated memory
422 * component - Component type of caller
423 * module - Source file name of caller
424 * line - Line number of caller
425 *
Bob Moored8da9152012-10-31 02:27:32 +0000426 * RETURN: Status
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000427 *
428 * DESCRIPTION: Deletes an element from the global allocation tracking list.
429 *
430 ******************************************************************************/
431
432static acpi_status
433acpi_ut_remove_allocation(struct acpi_debug_mem_block *allocation,
434 u32 component, const char *module, u32 line)
435{
436 struct acpi_memory_list *mem_list;
437 acpi_status status;
438
Bob Moore0e770b32012-12-19 05:37:59 +0000439 ACPI_FUNCTION_NAME(ut_remove_allocation);
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000440
441 if (acpi_gbl_disable_mem_tracking) {
Bob Moore0e770b32012-12-19 05:37:59 +0000442 return (AE_OK);
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000443 }
444
445 mem_list = acpi_gbl_global_list;
446 if (NULL == mem_list->list_head) {
447
448 /* No allocations! */
449
450 ACPI_ERROR((module, line,
451 "Empty allocation list, nothing to free!"));
452
Bob Moore0e770b32012-12-19 05:37:59 +0000453 return (AE_OK);
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000454 }
455
456 status = acpi_ut_acquire_mutex(ACPI_MTX_MEMORY);
457 if (ACPI_FAILURE(status)) {
Bob Moore0e770b32012-12-19 05:37:59 +0000458 return (status);
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000459 }
460
461 /* Unlink */
462
463 if (allocation->previous) {
464 (allocation->previous)->next = allocation->next;
465 } else {
466 mem_list->list_head = allocation->next;
467 }
468
469 if (allocation->next) {
470 (allocation->next)->previous = allocation->previous;
471 }
472
Bob Moore0e770b32012-12-19 05:37:59 +0000473 ACPI_DEBUG_PRINT((ACPI_DB_ALLOCATIONS, "Freeing %p, size 0%X\n",
474 &allocation->user_space, allocation->size));
475
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000476 /* Mark the segment as deleted */
477
478 ACPI_MEMSET(&allocation->user_space, 0xEA, allocation->size);
479
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000480 status = acpi_ut_release_mutex(ACPI_MTX_MEMORY);
Bob Moore0e770b32012-12-19 05:37:59 +0000481 return (status);
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000482}
483
484/*******************************************************************************
485 *
486 * FUNCTION: acpi_ut_dump_allocation_info
487 *
Bob Moored8da9152012-10-31 02:27:32 +0000488 * PARAMETERS: None
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000489 *
490 * RETURN: None
491 *
492 * DESCRIPTION: Print some info about the outstanding allocations.
493 *
494 ******************************************************************************/
495
496void acpi_ut_dump_allocation_info(void)
497{
498/*
499 struct acpi_memory_list *mem_list;
500*/
501
502 ACPI_FUNCTION_TRACE(ut_dump_allocation_info);
503
504/*
505 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
506 ("%30s: %4d (%3d Kb)\n", "Current allocations",
507 mem_list->current_count,
508 ROUND_UP_TO_1K (mem_list->current_size)));
509
510 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
511 ("%30s: %4d (%3d Kb)\n", "Max concurrent allocations",
512 mem_list->max_concurrent_count,
513 ROUND_UP_TO_1K (mem_list->max_concurrent_size)));
514
515 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
516 ("%30s: %4d (%3d Kb)\n", "Total (all) internal objects",
517 running_object_count,
518 ROUND_UP_TO_1K (running_object_size)));
519
520 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
521 ("%30s: %4d (%3d Kb)\n", "Total (all) allocations",
522 running_alloc_count,
523 ROUND_UP_TO_1K (running_alloc_size)));
524
525 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
526 ("%30s: %4d (%3d Kb)\n", "Current Nodes",
527 acpi_gbl_current_node_count,
528 ROUND_UP_TO_1K (acpi_gbl_current_node_size)));
529
530 ACPI_DEBUG_PRINT (TRACE_ALLOCATIONS | TRACE_TABLES,
531 ("%30s: %4d (%3d Kb)\n", "Max Nodes",
532 acpi_gbl_max_concurrent_node_count,
533 ROUND_UP_TO_1K ((acpi_gbl_max_concurrent_node_count *
534 sizeof (struct acpi_namespace_node)))));
535*/
536 return_VOID;
537}
538
539/*******************************************************************************
540 *
541 * FUNCTION: acpi_ut_dump_allocations
542 *
543 * PARAMETERS: component - Component(s) to dump info for.
Bob Moore73a30902012-10-31 02:26:55 +0000544 * module - Module to dump info for. NULL means all.
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000545 *
546 * RETURN: None
547 *
548 * DESCRIPTION: Print a list of all outstanding allocations.
549 *
550 ******************************************************************************/
551
552void acpi_ut_dump_allocations(u32 component, const char *module)
553{
554 struct acpi_debug_mem_block *element;
555 union acpi_descriptor *descriptor;
556 u32 num_outstanding = 0;
557 u8 descriptor_type;
558
559 ACPI_FUNCTION_TRACE(ut_dump_allocations);
560
561 if (acpi_gbl_disable_mem_tracking) {
Bob Moore68aafc32012-10-31 02:26:01 +0000562 return_VOID;
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000563 }
564
565 /*
566 * Walk the allocation list.
567 */
568 if (ACPI_FAILURE(acpi_ut_acquire_mutex(ACPI_MTX_MEMORY))) {
Bob Moore68aafc32012-10-31 02:26:01 +0000569 return_VOID;
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000570 }
571
572 element = acpi_gbl_global_list->list_head;
573 while (element) {
574 if ((element->component & component) &&
575 ((module == NULL)
576 || (0 == ACPI_STRCMP(module, element->module)))) {
577 descriptor =
578 ACPI_CAST_PTR(union acpi_descriptor,
579 &element->user_space);
580
581 if (element->size <
582 sizeof(struct acpi_common_descriptor)) {
583 acpi_os_printf("%p Length 0x%04X %9.9s-%u "
584 "[Not a Descriptor - too small]\n",
585 descriptor, element->size,
586 element->module, element->line);
587 } else {
588 /* Ignore allocated objects that are in a cache */
589
590 if (ACPI_GET_DESCRIPTOR_TYPE(descriptor) !=
591 ACPI_DESC_TYPE_CACHED) {
592 acpi_os_printf
593 ("%p Length 0x%04X %9.9s-%u [%s] ",
594 descriptor, element->size,
595 element->module, element->line,
596 acpi_ut_get_descriptor_name
597 (descriptor));
598
599 /* Validate the descriptor type using Type field and length */
600
601 descriptor_type = 0; /* Not a valid descriptor type */
602
603 switch (ACPI_GET_DESCRIPTOR_TYPE
604 (descriptor)) {
605 case ACPI_DESC_TYPE_OPERAND:
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000606
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000607 if (element->size ==
608 sizeof(union
609 acpi_operand_object))
610 {
611 descriptor_type =
612 ACPI_DESC_TYPE_OPERAND;
613 }
614 break;
615
616 case ACPI_DESC_TYPE_PARSER:
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000617
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000618 if (element->size ==
619 sizeof(union
620 acpi_parse_object)) {
621 descriptor_type =
622 ACPI_DESC_TYPE_PARSER;
623 }
624 break;
625
626 case ACPI_DESC_TYPE_NAMED:
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000627
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000628 if (element->size ==
629 sizeof(struct
630 acpi_namespace_node))
631 {
632 descriptor_type =
633 ACPI_DESC_TYPE_NAMED;
634 }
635 break;
636
637 default:
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000638
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000639 break;
640 }
641
642 /* Display additional info for the major descriptor types */
643
644 switch (descriptor_type) {
645 case ACPI_DESC_TYPE_OPERAND:
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000646
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000647 acpi_os_printf
648 ("%12.12s RefCount 0x%04X\n",
649 acpi_ut_get_type_name
650 (descriptor->object.common.
651 type),
652 descriptor->object.common.
653 reference_count);
654 break;
655
656 case ACPI_DESC_TYPE_PARSER:
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000657
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000658 acpi_os_printf
659 ("AmlOpcode 0x%04hX\n",
660 descriptor->op.asl.
661 aml_opcode);
662 break;
663
664 case ACPI_DESC_TYPE_NAMED:
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000665
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000666 acpi_os_printf("%4.4s\n",
667 acpi_ut_get_node_name
668 (&descriptor->
669 node));
670 break;
671
672 default:
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000673
Lv Zheng6d33b6b2012-10-31 02:25:05 +0000674 acpi_os_printf("\n");
675 break;
676 }
677 }
678 }
679
680 num_outstanding++;
681 }
682
683 element = element->next;
684 }
685
686 (void)acpi_ut_release_mutex(ACPI_MTX_MEMORY);
687
688 /* Print summary */
689
690 if (!num_outstanding) {
691 ACPI_INFO((AE_INFO, "No outstanding allocations"));
692 } else {
693 ACPI_ERROR((AE_INFO, "%u(0x%X) Outstanding allocations",
694 num_outstanding, num_outstanding));
695 }
696
697 return_VOID;
698}
699
700#endif /* ACPI_DBG_TRACK_ALLOCATIONS */