From 5738f83aeb59361a0a2eda2460113f6dc9194271 Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Wed, 12 Dec 2012 16:00:35 -0800 Subject: Snapshot cdeccf6fdd8c2d494ea2867cb37a025bf8879baf Change-Id: Ia2de32ccb97a9641462c72363b0a8c4288f4f36d --- gki/common/gki_debug.c | 354 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 354 insertions(+) create mode 100644 gki/common/gki_debug.c (limited to 'gki/common/gki_debug.c') diff --git a/gki/common/gki_debug.c b/gki/common/gki_debug.c new file mode 100644 index 0000000..46d7e38 --- /dev/null +++ b/gki/common/gki_debug.c @@ -0,0 +1,354 @@ +/****************************************************************************** + * + * Copyright (C) 1999-2012 Broadcom Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +#include "gki_int.h" + +#if (GKI_DEBUG == TRUE) + +const INT8 * const OSTaskStates[] = +{ + (INT8 *)"DEAD", /* 0 */ + (INT8 *)"REDY", /* 1 */ + (INT8 *)"WAIT", /* 2 */ + (INT8 *)"", + (INT8 *)"DELY", /* 4 */ + (INT8 *)"", + (INT8 *)"", + (INT8 *)"", + (INT8 *)"SUSP", /* 8 */ +}; + + +/******************************************************************************* +** +** Function GKI_PrintBufferUsage +** +** Description Displays Current Buffer Pool summary +** +** Returns void +** +*******************************************************************************/ +void GKI_PrintBufferUsage(UINT8 *p_num_pools, UINT16 *p_cur_used) +{ + int i; + FREE_QUEUE_T *p; + UINT8 num = gki_cb.com.curr_total_no_of_pools; + UINT16 cur[GKI_NUM_TOTAL_BUF_POOLS]; + + GKI_TRACE_0(""); + GKI_TRACE_0("--- GKI Buffer Pool Summary (R - restricted, P - public) ---"); + + GKI_TRACE_0("POOL SIZE USED MAXU TOTAL"); + GKI_TRACE_0("------------------------------"); + for (i = 0; i < gki_cb.com.curr_total_no_of_pools; i++) + { + p = &gki_cb.com.freeq[i]; + if ((1 << i) & gki_cb.com.pool_access_mask) + { + GKI_TRACE_5("%02d: (R), %4d, %3d, %3d, %3d", + i, p->size, p->cur_cnt, p->max_cnt, p->total); + } + else + { + GKI_TRACE_5("%02d: (P), %4d, %3d, %3d, %3d", + i, p->size, p->cur_cnt, p->max_cnt, p->total); + } + cur[i] = p->cur_cnt; + } + if (p_num_pools) + *p_num_pools = num; + if (p_cur_used) + memcpy(p_cur_used, cur, num*2); +} + +/******************************************************************************* +** +** Function GKI_PrintBuffer +** +** Description Called internally by OSS to print the buffer pools +** +** Returns void +** +*******************************************************************************/ +void GKI_PrintBuffer(void) +{ + UINT16 i; + for(i=0; i GKI_NUM_TOTAL_BUF_POOLS || pool < 0) + { + print("Not a valid Buffer pool\n"); + return; + } + + size = gki_cb.com.freeq[pool].size; + maxbuffs = gki_cb.com.freeq[pool].total; + act_size = size + BUFFER_PADDING_SIZE; + print("Buffer Pool[%u] size=%u cur_cnt=%u max_cnt=%u total=%u\n", + pool, gki_cb.com.freeq[pool].size, + gki_cb.com.freeq[pool].cur_cnt, gki_cb.com.freeq[pool].max_cnt, gki_cb.com.freeq[pool].total); + + print(" Owner State Sanity\n"); + print("----------------------------\n"); + hdr = (BUFFER_HDR_T *)(gki_cb.com.pool_start[pool]); + for(i=0; itask_id, hdr->status, (*magic == MAGIC_NO)?"OK":"CORRUPTED"); + hdr = (BUFFER_HDR_T *)((UINT8 *)hdr + act_size); + } + return; +} + + +/******************************************************************************* +** +** Function gki_print_used_bufs +** +** Description Dumps used buffers in the particular pool +** +*******************************************************************************/ +GKI_API void gki_print_used_bufs (FP_PRINT print, UINT8 pool_id) +{ + UINT8 *p_start; + UINT16 buf_size; + UINT16 num_bufs; + BUFFER_HDR_T *p_hdr; + UINT16 i; + UINT32 *magic; + UINT16 *p; + + + if ((pool_id >= GKI_NUM_TOTAL_BUF_POOLS) || (gki_cb.com.pool_start[pool_id] != 0)) + { + print("Not a valid Buffer pool\n"); + return; + } + + p_start = gki_cb.com.pool_start[pool_id]; + buf_size = gki_cb.com.freeq[pool_id].size + BUFFER_PADDING_SIZE; + num_bufs = gki_cb.com.freeq[pool_id].total; + + for (i = 0; i < num_bufs; i++, p_start += buf_size) + { + p_hdr = (BUFFER_HDR_T *)p_start; + magic = (UINT32 *)((UINT8 *)p_hdr + buf_size - sizeof(UINT32)); + p = (UINT16 *) p_hdr; + + if (p_hdr->status != BUF_STATUS_FREE) + { + print ("%d:0x%x (Q:%d,Task:%s,Stat:%d,%s) %04x %04x %04x %04x %04x %04x %04x %04x\n", + i, p_hdr, + p_hdr->q_id, + GKI_map_taskname(p_hdr->task_id), + p_hdr->status, + (*magic == MAGIC_NO)? "OK" : "CORRUPTED", + p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); + } + } +} + + +/******************************************************************************* +** +** Function gki_print_task +** +** Description This function prints the task states. +** +** Returns void +** +*******************************************************************************/ +void gki_print_task (FP_PRINT print) +{ + UINT8 i; + + print("TID VID TASKNAME STATE WAIT WAITFOR TIMEOUT STACK\n"); + print("-------------------------------------------------\n"); + for(i=0; itype, (INT32)pExp->taskid, (INT8 *)pExp->msg); + } +} + + +/*****************************************************************************/ +void gki_dump (UINT8 *s, UINT16 len, FP_PRINT print) +{ + UINT16 i, j; + + for(i=0, j=0; i