📄 usrlib.c
字号:
pIntStackHigh --) ;#endif /* _STACK_DIR == _STACK_GROWS_DOWN) */#if (CPU != MC68060) printf ("%-12.12s %-12.12s", "INTERRUPT", ""); printf (" %8s %5d %5d %5d %6d %s\n", "", /* task name */ (int)((intStackEnd - intStackBase) *_STACK_DIR), /* stack size */ 0, /* current */ (int)((pIntStackHigh - intStackBase) *_STACK_DIR), /* high stack usage */ (int)((intStackEnd - pIntStackHigh) * _STACK_DIR), /* margin */ (pIntStackHigh == intStackEnd) && /* overflow ? */ (intStackEnd != intStackBase != 0) ? /* no interrupt stack ? */ "OVERFLOW" : "");#endif #else#if CPU_FAMILY == AM29XXX /* * Since the Am29k family uses 3 interrupt stacks (Exception Stack * Frame, handler register stack and memory stack), we must compute * each stack usage inside the global stack area allocated at each * interrupt. The ESF takes 1/5 of the global area, the register stack * takes also 1/5 of the global area, and the memory stack takes the * remainder (3/5). See kernelInit(). */ for (pIntStackHigh = vxRegIntStackBase; * (UINT8 *)pIntStackHigh == 0xee; pIntStackHigh ++); printf ("%-12.12s %-12.12s", "INTERRUPT", ""); printf (" %8s %5d %5d %5d %6d %s\n", "", /* task name */ (intStackBase - vxRegIntStackBase), /* ESF size */ 0, /* current */ (intStackBase - pIntStackHigh), /* high stack usage */ (pIntStackHigh - vxRegIntStackBase), /* margin */ (pIntStackHigh == vxRegIntStackBase) && /* overflow ? */ (intStackEnd != intStackBase != 0) ? /* no intr stack ? */ "Ker stack OVERFLOW" : "- Kernel -"); for (pIntStackHigh = vxMemIntStackBase; (* (UINT8 *)pIntStackHigh == 0xee) && (pIntStackHigh != vxRegIntStackBase); pIntStackHigh ++); printf ("%-12.12s %-12.12s", "", ""); printf (" %8s %5d %5d %5d %6d %s\n", "", /* task name */ (vxRegIntStackBase - vxMemIntStackBase),/* Reg stack size */ 0, /* current */ (vxRegIntStackBase - pIntStackHigh), /* high stack usage */ (pIntStackHigh - vxMemIntStackBase), /* margin */ (pIntStackHigh == vxMemIntStackBase) && /* overflow ? */ (intStackEnd != intStackBase != 0) ? /* no intr stack ? */ "Reg stack OVERFLOW" : "- Register -"); for (pIntStackHigh = intStackEnd; (* (UINT8 *)pIntStackHigh == 0xee) && (pIntStackHigh != vxMemIntStackBase); pIntStackHigh ++); printf ("%-12.12s %-12.12s", "", ""); printf (" %8s %5d %5d %5d %6d %s\n", "", /* task name */ (vxMemIntStackBase - intStackEnd), /* Mem stack size */ 0, /* current */ (vxMemIntStackBase - pIntStackHigh), /* high stack usage */ (pIntStackHigh - intStackEnd), /* margin */ (pIntStackHigh == intStackEnd) && /* overflow ? */ (intStackEnd != intStackBase != 0) ? /* no intr stack ? */ "Mem stack OVERFLOW" : "- Memory -");#else#if (CPU_FAMILY == ARM) /* * The ARM processor has a separate stack for each of the two * interrupt modes, IRQ and FIQ, but FIQ is not handled within * VxWorks. The IRQ entry veneer switches to SVC mode (for * reentrancy) so there are still two interrupt stacks to print * out: IRQ and SVC mode. */ intStackBase = vxSvcIntStackBase; intStackEnd = vxSvcIntStackEnd; for (pIntStackHigh = intStackEnd; *(UINT8 *)pIntStackHigh == 0xEE && pIntStackHigh < intStackBase; pIntStackHigh++) ; printf ("%-12.12s %-12.12s", "INTERRUPT", ""); printf (" %8s %5d %5d %5d %6d %s\n", "", /* task name */ (int)(intStackBase - intStackEnd), /* stack size */ 0, /* current */ (int)(intStackBase - pIntStackHigh), /* high stack use */ (int)(pIntStackHigh - intStackEnd), /* margin */ (pIntStackHigh == intStackEnd) && /* overflow ? */ (intStackEnd != intStackBase != 0) ? /* no int stack ? */ "SVC stack OVERFLOW" : "- SVC -"); intStackBase = vxIrqIntStackBase; intStackEnd = vxIrqIntStackEnd; for (pIntStackHigh = intStackEnd; *(UINT8 *)pIntStackHigh == 0xEE && pIntStackHigh < intStackBase; pIntStackHigh++) ; printf ("%-12.12s %-12.12s", "", ""); printf (" %8s %5d %5d %5d %6d %s\n", "", /* task name */ (int)(intStackBase - intStackEnd), /* stack size */ 0, /* current */ (int)(intStackBase - pIntStackHigh), /* high stack use */ (int)(pIntStackHigh - intStackEnd), /* margin */ (pIntStackHigh == intStackEnd) && /* overflow ? */ (intStackEnd != intStackBase != 0) ? /* no int stack ? */ "IRQ stack OVERFLOW" : "- IRQ -"); #endif /* CPU_FAMILY == ARM */#endif /* (CPU_FAMILY == AM29XXX) */#endif /* (CPU_FAMILY != AM29XXX) */ } }/********************************************************************************* printStackSummary - print task stack summary line** This command is used by checkStack(), to print each task's stack summary line.*/LOCAL void printStackSummary ( TASK_DESC *pTd ) { FUNCPTR entry; /* task's initial entry point */ FUNCPTR symboladdr; /* address associated with 'name' */ SYMBOL_ID symId; char *name; /* ptr to sym tbl copy of name of main routine */ char demangled[USR_DEMANGLE_PRINT_LEN + 1]; char *nameToPrint; /* find task's initial entry point, and name (if any) in symbol table */ entry = pTd->td_entry; symFindSymbol (sysSymTbl, NULL, (void *)entry, N_EXT | N_TEXT, N_EXT | N_TEXT, &symId); symNameGet (symId, &name); symValueGet (symId, (void **)&symboladdr); /* Print the summary of the TCB */ printf ("%-12.12s", pTd->td_name); /* print the name of the task */ if (entry == symboladdr) /* entry address (symbolic if poss.) */ { nameToPrint = cplusDemangle (name, demangled, sizeof (demangled)); printf (" %-12.12s", nameToPrint); } else printf (" %#-12.12x", (int) entry);#if (CPU_FAMILY != AM29XXX) printf (" %-8x %5d %5d ", pTd->td_id, pTd->td_stackSize, pTd->td_stackCurrent); if (pTd->td_options & VX_NO_STACK_FILL) printf ("%5s %6s VX_NO_STACK_FILL\n", "???", "???"); else printf ("%5d %6d %s\n", pTd->td_stackHigh, pTd->td_stackMargin, (pTd->td_stackMargin <= 0) ? "OVERFLOW" : "");#else { FAST char *pStackHigh; UINT regStackEnd; /* end of the register stack */ int regStackSize; /* size of the register stack */ int regStackHigh; /* highest position into the register stack */ int regStackMargin; /* margin left in the register stack */ UINT memStackBase; /* base of the memory stack */ int memStackSize; /* size of the memory stack */ int memStackHigh; /* highest position into the memory stack */ int memStackMargin; /* margin left in the memory stack */ int memStackCurrent; /* current position into the memory stack */ REG_SET regSet; /* * Since the Am29k family uses 2 stacks (register stack and memory stack), * we must compute each stack usage inside the global stack area allocated * for each task. The register stack takes 1/4 of the global area, and the * memory stack takes the remainder (3/4). See taskRegsInit(). */ regStackEnd = (UINT)pTd->td_pStackBase - ((UINT)pTd->td_pStackBase - \ (UINT)pTd->td_pStackEnd) / 4; if (pTd->td_options & VX_NO_STACK_FILL) pStackHigh = (char *)regStackEnd; else for (pStackHigh = (char *)regStackEnd; *(UINT8 *)pStackHigh == 0xee; pStackHigh ++); regStackHigh = (int)(pTd->td_pStackBase - pStackHigh); regStackSize = (UINT)pTd->td_pStackBase - regStackEnd; regStackMargin = regStackSize - regStackHigh; printf (" %-8x %5d %5d ", pTd->td_id, regStackSize, pTd->td_stackCurrent); if (pTd->td_options & VX_NO_STACK_FILL) printf ("%5s %6s VX_NO_STACK_FILL\n", "???", "???"); else printf ("%5d %6d %s\n", regStackHigh, regStackMargin, (regStackMargin <= 0) ? "Reg stack OVERFLOW" : "- Register -"); printf (" "); memStackBase = regStackEnd; if (pTd->td_options & VX_NO_STACK_FILL) pStackHigh = (char *)pTd->td_pStackLimit; else for (pStackHigh = (char *)pTd->td_pStackLimit; (*(UINT8 *)pStackHigh == 0xee) && ((UINT)pStackHigh != memStackBase); pStackHigh ++); memStackHigh = (int)(memStackBase - (UINT)pStackHigh); memStackSize = memStackBase - (UINT)pTd->td_pStackLimit; memStackMargin = memStackSize - memStackHigh; taskRegsGet (pTd->td_id, ®Set); memStackCurrent = (int)(regSet.msp - memStackBase) * _STACK_DIR; if (memStackHigh < memStackCurrent) /* if msp is decremented but */ memStackHigh = memStackCurrent; /* nothing is put in stack */ printf (" %5d %5d ", memStackSize, memStackCurrent); if (pTd->td_options & VX_NO_STACK_FILL) printf ("%5s %6s VX_NO_STACK_FILL", "???", "???"); else printf ("%5d %6d %s\n", memStackHigh, memStackMargin, (memStackMargin <= 0) ? "Mem stack OVERFLOW" : "- Memory -"); }#endif /* (CPU_FAMILY != AM29XXX) */ }/********************************************************************************* i - print a summary of each task's TCB** This command displays a synopsis of all the tasks in the system.* The ti() routine provides more complete information on a specific task.** Both i() and ti() use taskShow(); see the documentation for taskShow() for * a description of the output format.** EXAMPLE:* .CS* -> i** NAME ENTRY TID PRI STATUS PC SP ERRNO DELAY* ---------- ---------- -------- --- --------- ------- -------- ----- -----* tExcTask _excTask 20fcb00 0 PEND 200c5fc 20fca6c 0 0* tLogTask _logTask 20fb5b8 0 PEND 200c5fc 20fb520 0 0* tShell _shell 20efcac 1 READY 201dc90 20ef980 0 0* tRlogind _rlogind 20f3f90 2 PEND 2038614 20f3db0 0 0* tTelnetd _telnetd 20f2124 2 PEND 2038614 20f2070 0 0* tNetTask _netTask 20f7398 50 PEND 2038614 20f7340 0 0* value = 57 = 0x39 = '9'* .CE** CAVEAT* This command should be used only as a debugging aid, since the information* is obsolete by the time it is displayed.** RETURNS: N/A** SEE ALSO: ti(), taskShow(),* .pG "Target Shell,"* windsh,* .tG "Shell"*/void i ( int taskNameOrId /* task name or task ID, 0 = summarize all */ ) { int tid; if (taskNameOrId == 0) show (taskIdSelf (), 2); /* summarize all task's info */ else { tid = taskIdFigure (taskNameOrId); if ((tid == ERROR) || (taskIdVerify (tid) != OK)) { printErr ("Task not found.\n"); return; } show (tid, 0); /* summarize a task's info */ } }/********************************************************************************* ti - print complete information from a task's TCB** This command prints the task control block (TCB) contents, including* registers, for a specified task. If <taskNameOrId> is omitted or zero,* the last task referenced is assumed.** The ti() routine uses taskShow(); see the documentation for taskShow() for * a description of the output format.** EXAMPLE:* The following shows the TCB contents for the shell task:* .CS* -> ti** NAME ENTRY TID PRI STATUS PC SP ERRNO DELAY* ---------- --------- -------- --- --------- -------- -------- ------ -----* tShell _shell 20efcac 1 READY 201dc90 20ef980 0 0** stack: base 0x20efcac end 0x20ed59c size 9532 high 1452 margin 8080** options: 0x1e* \&VX_UNBREAKABLE VX_DEALLOC_STACK VX_FP_TASK VX_STDIO*** \&D0 = 0 D4 = 0 A0 = 0 A4 = 0* \&D1 = 0 D5 = 0 A1 = 0 A5 = 203a084 SR = 3000* \&D2 = 0 D6 = 0 A2 = 0 A6 = 20ef9a0 PC = 2038614* \&D3 = 0 D7 = 0 A3 = 0 A7 = 20ef980* value = 34536868 = 0x20efda4* .CE** RETURNS: N/A** SEE ALSO:* taskShow(),* .pG "Target Shell,"* windsh,* .tG "Shell"*/void ti ( int taskNameOrId /* task name or task ID; 0 = use default */ ) { int tid = taskIdFigure (taskNameOrId); if ((tid == ERROR) || (taskIdVerify (tid) != OK)) { printErr ("Task not found.\n"); return; } tid = taskIdDefault (tid); /* set the default task ID */ show (tid, 1); }/********************************************************************************* show - print information on a specified object** This command prints information on the specified object. System objects* include tasks, local and shared semaphores, local and shared message* queues, local and shared memory partitions, watchdogs, and symbol tables.* An information level is interpreted by the objects show routine on a class* by class basis. Refer to the object's library manual page for more* information.** RETURNS: N/A** SEE ALSO: i(), ti(), lkup(),* .pG "Target Shell,"* windsh,* .tG "Shell"*/void show ( int objId, /* object ID */ int level /* information level */ ) { int bb; /* bit bucket for vxMemProbe */ if (ID_IS_SHARED (objId)) { if (vxMemProbe ((char *) SM_OBJ_ID_TO_ADRS (objId), VX_READ, 4, (char *) &bb) == ERROR) { printf ("Object not found.\n"); return; } if (_func_smObjObjShow != (FUNCPTR) NULL) { (*_func_smObjObjShow) (objId, level); return; } else { printf("Show routine of this object not configured into system.\n"); return; } } /* check for invalid show routine reference */ if ((vxMemProbe ((char *) objId, VX_READ, 4, (char *) &bb) == ERROR) || ((((OBJ_ID) ((int)objId + taskClassId->coreOffset))->pObjClass
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -