⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ssp_spy.c

📁 abstract rtos
💻 C
📖 第 1 页 / 共 3 页
字号:
        aos_printf(MPE_DEBUG,"%s",szBuffer);        aos_printf( MPE_DEBUG,"Call Stack:" );        lRet = 0;        for(k = 0;k < EXCEPTION_STACK_LAYER;k++)        {            if(NULL != pItem->m_aStackLayer[k].stack_addr)             {                lRet += aos_sprintf(szBuffer+lRet,                                    "\r\nsp:0x%08x,instr:0x%08x",                                    pItem->m_aStackLayer[k].stack_addr,                                    pItem->m_aStackLayer[k].next_inst_addr);            }        }                aos_printf( MPE_DEBUG,"%s", szBuffer );        aos_printf( MPE_DEBUG,"Stack Content:" );        debug_mem_show( MPE_DEBUG, (U32)pItem->m_aStack, EXCEPTION_STACK_SIZE );    }}VOID dbg_show_last_msg_info( U32 dbg_index ){    DBG_INFO_S     *dbg_infop;    L3_MSG_HEAD_S  *l3_msgp;    U32            msg_handling;     S8             *str;    aos_printf( MPE_DEBUG, "show last message" );    dbg_infop = dbg_get_dbg_info( dbg_index );    if( NULL == dbg_infop )    {        return;    }    msg_handling = *(U32*)&dbg_infop->last_msg[0];    if( MSG_IN == msg_handling )    {        str = "last message is handling";    }    else if( MSG_OUT == msg_handling )    {        str = "last message has handled";    }    else    {        return;    }        l3_msgp = (L3_MSG_HEAD_S*)&dbg_infop->last_msg[4];    aos_printf( MPE_DEBUG, "%s,srcProc=%d,srcMpe=%d,dstProc=%d,dstMpe=%d,size=%u,body at 0x%x ...",        str, l3_msgp->srcProcessorId, l3_msgp->srcMpe, l3_msgp->dstProcessorId, l3_msgp->dstMpe, l3_msgp->ulSize, l3_msgp->msg );    debug_mem_show( MPE_DEBUG, (U32)l3_msgp->msg, DBG_MAX_MSG_LEN - sizeof(L3_MSG_HEAD_S) +4 );}VOID dbg_show_assert_info( U32 dbg_index ){    DBG_INFO_S     *dbg_infop;    ASSERT_INFO_S  *assert_infop;    ASSERT_ITEM_S  *assert_itemp;    U32 i;    aos_printf( MPE_DEBUG, "show assert info" );        dbg_infop = dbg_get_dbg_info( dbg_index );    if( NULL == dbg_infop )    {        return;    }    assert_infop = &dbg_infop->assert_info;    if( assert_infop->count >= DBG_MAX_ASSERT_NUM )    {        for( i = assert_infop->cur_index; i < DBG_MAX_ASSERT_NUM; i++ )        {            assert_itemp = &assert_infop->assert_item[i];            aos_printf( MPE_DEBUG,  "ASSERT at [%02d:%02d:%02d:%03d]%s",                     assert_itemp->tm.hour,assert_itemp->tm.minute,                     assert_itemp->tm.second,assert_itemp->tm.millisec,                     assert_itemp->assert_str );        }    }    if( assert_infop->cur_index >= DBG_MAX_ASSERT_NUM )    {        return;    }        for( i = 0; i < assert_infop->cur_index; i++ )    {        assert_itemp = &assert_infop->assert_item[i];        aos_printf( MPE_DEBUG,  "ASSERT at [%02d:%02d:%02d:%03d]%s",                 assert_itemp->tm.hour,assert_itemp->tm.minute,                 assert_itemp->tm.second,assert_itemp->tm.millisec,                 assert_itemp->assert_str );    }}VOID dbg_show_run_flow( U32 dbg_index ){    DBG_INFO_S     *dbg_infop;    aos_printf( MPE_DEBUG, "show run flow info" );        dbg_infop = dbg_get_dbg_info( dbg_index );    if( NULL == dbg_infop )    {        return;    }    dbg_infop->run_track[DBG_MAX_TRACK_LEN] = '\0';    aos_printf( MPE_DEBUG, "%s", dbg_infop->run_track );    }VOID aos_debug_trace( U32 type, U32 paras[4], S8*name, U32 line ){    U32 tSelf,int_count,sp,lockKey;    DBG_TRACE_INFO *pstDbgTraceInfo;    DBG_TRACE_ITEM *pstDbgTraceItem;    tSelf = aos_task_self();    if(U32_BUTT == tSelf)    {        return;    }    lockKey = aos_int_lock();    int_count = aos_int_count();        pstDbgTraceInfo = &dbg_pool->dbg_info[dbg_pool->cur_dbg_index].trace_info[tSelf];    if( pstDbgTraceInfo->is_deleted )    {        pstDbgTraceInfo->task_name[0] = 0;        pstDbgTraceInfo->is_deleted   = FALSE;        pstDbgTraceInfo->stack_level  = 0;        pstDbgTraceInfo->is_full      = FALSE;        pstDbgTraceInfo->next_index   = 0;        pstDbgTraceInfo->is_stop      = FALSE;    }        if( !pstDbgTraceInfo->task_name[0] )    {        aos_memcpy( pstDbgTraceInfo->task_name, g_pstTask[tSelf].name, AOS_NAME_LEN );    }    pstDbgTraceItem = &pstDbgTraceInfo->trace_item[pstDbgTraceInfo->next_index];    pstDbgTraceItem->info_class = (U8)type;    pstDbgTraceItem->int_count  = (U8)int_count;    pstDbgTraceItem->name = name;        pstDbgTraceItem->line = (U16)line;    pstDbgTraceItem->paras[0] = paras[0];    pstDbgTraceItem->paras[1] = paras[1];    pstDbgTraceItem->paras[2] = paras[2];    pstDbgTraceItem->paras[3] = paras[3];    aos_time_get_usec( &pstDbgTraceItem->sec, &pstDbgTraceItem->usec );    pstDbgTraceItem->sn = m_ulTraceSn++;    if( TRACE_IN == type )    {        pstDbgTraceInfo->stack_level++;    }    else if( TRACE_OUT == type )    {        pstDbgTraceInfo->stack_level--;    }        pstDbgTraceInfo->next_index++;    if( pstDbgTraceInfo->next_index >= MAX_TRACE_ITEM_PER_TASK )    {        pstDbgTraceInfo->next_index = 0;        pstDbgTraceInfo->is_full    = TRUE;    }    aos_int_unlock(lockKey);    if( !pstDbgTraceInfo->is_stop )    {        if( TRACE_IN == type )        {            if(!int_count)            {                if( pstDbgTraceInfo->stack_level >= MAX_STACK_LEVEL )                {                    pstDbgTraceInfo->is_stop = TRUE;                    aos_printf( MPE_SYS, "task %s call stack level too large",                         g_pstTask[tSelf].name );                }                sp = sys_get_cur_sp();                if(  (NULL != g_pstTask[tSelf].stack_bottom )                  && (sp >= (U32)g_pstTask[tSelf].stack_bottom + g_pstTask[tSelf].stack_size) )                {                    aos_printf( MPE_SYS, "task %s stack overflow", g_pstTask[tSelf].name );                    aos_task_suspend(tSelf);                }            }        }        else if( TRACE_OUT == type )        {            if( pstDbgTraceInfo->stack_level < 0 )            {                    pstDbgTraceInfo->is_stop = TRUE;                    aos_printf( MPE_SYS, "task %s loss trace in At F:%s",                         g_pstTask[tSelf].name, name );            }        }    }}VOID aos_debug_trace_cancel( U32 tid ){    U32 lockKey;    DBG_TRACE_INFO *pstDbgTraceInfo;    if( 0 == tid )    {        tid = aos_task_self();    }    if( tid >= CONFIG_TASK_NUMBER )    {        return;    }    lockKey = aos_int_lock();    pstDbgTraceInfo = &dbg_pool->dbg_info[dbg_pool->cur_dbg_index].trace_info[tid];    pstDbgTraceInfo->is_deleted = TRUE;    aos_int_unlock(lockKey);}S32 aos_debug_stack_level( ){    U32 tSelf, lockKey;    S32 level;    DBG_TRACE_INFO *pstDbgTraceInfo;    tSelf = aos_task_self();    if(U32_BUTT == tSelf)    {        return 0;    }    lockKey = aos_int_lock();        pstDbgTraceInfo = &dbg_pool->dbg_info[dbg_pool->cur_dbg_index].trace_info[tSelf];    level = pstDbgTraceInfo->stack_level;    aos_int_unlock(lockKey);    return level;}VOID aos_debug_trace_not_blance( S32 lost ){    U32 tSelf, lockKey;    DBG_TRACE_INFO *pstDbgTraceInfo;    if( !lost )    {        return;    }    tSelf = aos_task_self();    if(U32_BUTT == tSelf)    {        return;    }    pstDbgTraceInfo = &dbg_pool->dbg_info[dbg_pool->cur_dbg_index].trace_info[tSelf];    if( !pstDbgTraceInfo->is_stop )    {        aos_printf( 0, "Attention:Debug Trace Not Banlance!" );        aos_show_trace(0, tSelf, 6);    }            lockKey = aos_int_lock();    pstDbgTraceInfo->is_stop = TRUE;    aos_int_unlock(lockKey);}VOID aos_show_trace( U32 dbg_index, U32 task_id, U32 count ){    DBG_INFO_S     *dbg_infop;    DBG_TRACE_ITEM *pstDbgTraceItem;    U32            tid, tid_max, item, item_min;    S8             *fmt_used;    S8             func_name[100];    aos_printf( MPE_DEBUG, "show trace info" );        dbg_infop = dbg_get_dbg_info( dbg_index );    if( NULL == dbg_infop )    {        return;    }    if( 0 == task_id )    {        tid_max = CONFIG_TASK_NUMBER;    }    else if( task_id < CONFIG_TASK_NUMBER )    {        tid_max = task_id+1;    }    else    {        return;    }        for( tid = task_id; tid < tid_max; tid++ )    {        if( !dbg_infop->trace_info[tid].task_name[0] )		{			continue;		}        aos_printf( MPE_SYS, "Trace Information of task %s, task deleted=%d, stack level=%d",            dbg_infop->trace_info[tid].task_name,            dbg_infop->trace_info[tid].is_deleted,            dbg_infop->trace_info[tid].stack_level );        if( dbg_infop->trace_info[tid].is_full &&            (!count || dbg_infop->trace_info[tid].next_index < count) )        {            if( count >= MAX_TRACE_ITEM_PER_TASK )            {                item_min = dbg_infop->trace_info[tid].next_index;            }            else            {                item_min = MAX_TRACE_ITEM_PER_TASK - count;            }                            for( item = item_min; item < MAX_TRACE_ITEM_PER_TASK; item++ )            {                pstDbgTraceItem = &dbg_infop->trace_info[tid].trace_item[item];                if(NULL!=pstDbgTraceItem->name)                {                    aos_strncpy(func_name, pstDbgTraceItem->name, 99 );                    func_name[99] = '\0';                }                else                {                    func_name[0] = '\0';                }                if( TRACE_IN == pstDbgTraceItem->info_class )                {                    fmt_used = "Trace In. F:%s(%u,%u,%u,%u) At L:%d Time(%us,%uus),IntCount=%d, SN=%u";                }                else if( TRACE_OUT == pstDbgTraceItem->info_class )                {                    fmt_used = "Trace Out F:%s(%u,%u,%u,%u) At L:%d Time(%us,%uus),IntCount=%d, SN=%u";                }                else                {                    fmt_used = "Trace Inf F:%s(%u,%u,%u,%u) At L:%d Time(%us,%uus),IntCount=%d, SN=%u";                }                                    aos_printf( MPE_SYS, fmt_used, func_name,                         pstDbgTraceItem->paras[0],pstDbgTraceItem->paras[1],                        pstDbgTraceItem->paras[2],pstDbgTraceItem->paras[3],                        pstDbgTraceItem->line,pstDbgTraceItem->sec,pstDbgTraceItem->usec,                        pstDbgTraceItem->int_count,pstDbgTraceItem->sn );            }            aos_task_yield_time();        }        if( !count || count > dbg_infop->trace_info[tid].next_index )        {            item_min = 0;                    }        else        {            item_min = dbg_infop->trace_info[tid].next_index - count;        }                for( item = item_min; item < dbg_infop->trace_info[tid].next_index; item++ )        {            pstDbgTraceItem = &dbg_infop->trace_info[tid].trace_item[item];            if(NULL!=pstDbgTraceItem->name)            {                aos_strncpy(func_name, pstDbgTraceItem->name, 99 );                func_name[99] = '\0';            }            else            {                func_name[0] = '\0';            }            if( TRACE_IN == pstDbgTraceItem->info_class )            {                fmt_used = "Trace In. F:%s(%u,%u,%u,%u) At L:%d Time(%us,%uus),IntCount=%d, SN=%u";            }            else if( TRACE_OUT == pstDbgTraceItem->info_class )            {                fmt_used = "Trace Out F:%s(%u,%u,%u,%u) At L:%d Time(%us,%uus),IntCount=%d, SN=%u";            }            else            {                fmt_used = "Trace Inf F:%s(%u,%u,%u,%u) At L:%d Time(%us,%uus),IntCount=%d, SN=%u";            }                            aos_printf( MPE_SYS, fmt_used, func_name,                     pstDbgTraceItem->paras[0],pstDbgTraceItem->paras[1],                    pstDbgTraceItem->paras[2],pstDbgTraceItem->paras[3],                    pstDbgTraceItem->line,pstDbgTraceItem->sec,pstDbgTraceItem->usec,                    pstDbgTraceItem->int_count,pstDbgTraceItem->sn );        }        aos_task_yield_time();    }}void dbg_dbg_info_cache_flush(){}VOID dbg_force_reset(){    drv_cpu_reset();}VOID dbg_info_log(){    DBG_INFO_S                 *dbg_infop;    TASK_INFINITE_LOOP_TRACE_S *pTaskSwitchTraceBase;    TASK_INFINITE_LOOP_ITEM_S  *pItem;        U32 i,j;    S8  szBuffer[1024];    S8  szName[AOS_NAME_LEN+1];        dbg_infop = dbg_get_dbg_info( 1 );    if( NULL == dbg_infop )    {        return;    }    pTaskSwitchTraceBase = &dbg_infop->infinite_loop_task;    for(i = 0;i < SPY_TASK_NUM;i++)    {        pItem = pTaskSwitchTraceBase->m_aItem + i;        if( (pItem->m_ulPowerOn == 0)         || (pItem->m_ulMaxTick < SPY_RUN_DEADLINE_IN_TICK) )        {            continue;        }        for(j = 0;j < AOS_NAME_LEN;j++)        {            szName[j] = pItem->m_cName[j];        }        szName[j] = '\0';        aos_sprintf(szBuffer,                   "Infinite Loop task:%s pc:0x%x "                   "max ticks:%d "                   "loops:%d "                   "last ticks:%d "                   "time:%d %d-%d-%d-%d",                   szName,                   pItem->m_ulPc,                   pItem->m_ulMaxTick,                   pItem->m_ulLoop,                   pItem->m_ulRunTick,                   pItem->m_uDate,                   pItem->m_uHour,                   pItem->m_uMinute,                   pItem->m_uSecond,                   pItem->m_ulMillisec);                log_syslog( MPE_DEBUG, szBuffer );    }}void exc_test( U32 fp, U32 para ){	U32 t;		aos_task_create("exctst", 1024, TASK_PRIO_NORMAL, 0, (VOID(* )(VOID *))fp, (VOID *) para, &t);}void infinite_loop( ){    U32 i, tick, odd;    CPU_TICK_S t1,t2;    sys_task_lock();    i = 0;    aos_cputick_get(&t1);    for(;;)    {        i++;        aos_cputick_get(&t2);        aos_cputick_sub(&t2, &t1);        aos_cputick_2tick(&t2, &tick, &odd);        if( tick >= 200 )        	break;    }    sys_task_lock();    aos_printf(0,"i=%u",i);}void gen_exc(){    void (*p)() = (void(*)())0xfffffffc;    (*p)();    aos_printf( 0, "*p=0x%x", *p );}void gen_exc2(U32 zero){    U32 ulDiv=100;    ulDiv/=zero;    aos_printf( 0, "div=%d", ulDiv );}#endif#ifdef __cplusplus}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -