📄 taskshow.c
字号:
else for (pStackHigh = (char *)td.td_pStackLimit; (*(UINT8 *)pStackHigh == 0xee) && ((UINT)pStackHigh != memStackBase); pStackHigh ++); memStackHigh = (int)(memStackBase - (UINT)pStackHigh); memStackSize = memStackBase - (UINT)td.td_pStackLimit; memStackMargin = memStackSize - memStackHigh; taskRegsGet (tid, ®Set); memStackCurrent = (int)(memStackBase - regSet.msp); if (memStackHigh < memStackCurrent) /* if msp is decremented but */ memStackHigh = memStackCurrent; /* nothing is put in stack */ printf ("mem stack: base 0x%-6x end 0x%-6x size %-5d ", (memStackBase - 4), (UINT)td.td_pStackEnd, memStackSize); if (td.td_options & VX_NO_STACK_FILL) printf ("high %5s margin %5s\n", "???", "???"); else printf ("high %-5d margin %-5d\n", memStackHigh, memStackMargin); }#endif /* (CPU_FAMILY != AM29XXX) */ printf ("\noptions: 0x%x\n%s\n", td.td_options, optionsString); if (tid != taskIdSelf ()) /* no self exam */ { taskRegsShow (tid); if (_func_fppTaskRegsShow != NULL) /* fp regs if attached*/ (* _func_fppTaskRegsShow) (tid); } /* print exception info if any */ if ((_func_excInfoShow != NULL) && ((pTcb = taskTcb (tid)) != NULL)) (* _func_excInfoShow) (&pTcb->excInfo, FALSE); break; } case 2 : /* summarize all tasks */ default : { printf (infoHdr); nTasks = taskIdListGet (idList, NELEMENTS (idList)); taskIdListSort (idList, nTasks); for (ix = 0; ix < nTasks; ++ix) { if (taskInfoGet (idList [ix], &td) == OK) taskSummary (&td); } break; } } return (OK); }/********************************************************************************* taskSummary - print task summary line** This routine is used by i() and ti() to print each task's summary line.** NOMANUAL*/LOCAL void taskSummary ( TASK_DESC *pTd /* task descriptor to summarize */ ) { REG_SET regSet; /* get task's regs into here */ char statusString[10]; /* status string goes here */ char name[MAX_SYS_SYM_LEN + 1]; /* main routine names go here */ SYM_TYPE type; /* actual symbol type */ int value = 0; /* actual symbol value */ taskStatusString (pTd->td_id, statusString); name[0] = EOS; /* null terminate name */ /* Print the summary of the TCB */ printf ("%-11.11s", pTd->td_name); /* print the name of the task */ if ((_func_symFindByValueAndType != (FUNCPTR) NULL) && (sysSymTbl != NULL)) (* _func_symFindByValueAndType) (sysSymTbl, pTd->td_entry, name, &value, &type, N_EXT | N_TEXT, N_EXT | N_TEXT); if ((int)pTd->td_entry == value) printf ("%-12.12s", name); else printf ("%-12x", pTd->td_entry); /* get task's registers; if the tcb being printed is the * calling task's tcb, then taskRegsGet will return garbage for pc, * so we fudge it a little so it won't look bad. */ taskRegsGet (pTd->td_id, ®Set); printf (" %8x %3d %-10.10s %8x %8x %7x %5u\n", pTd->td_id, pTd->td_priority, statusString, ((taskIdSelf () == pTd->td_id) ? (int)taskSummary : (int)regSet.pc), (int)regSet.spReg, pTd->td_errorStatus, pTd->td_delay); }/******************************************************************************** taskIdListSort - sort the ID list by priority** This routine sorts the <idList> by task priority.** NOMANUAL*/void taskIdListSort ( int idList[], /* id list to sort */ int nTasks /* number of tasks in id list */ ) { FAST int temp; int prevPri; int curPri; FAST int *pCurId; BOOL change = TRUE; FAST int *pEndId = &idList [nTasks]; if (nTasks == 0) return; while (change) { change = FALSE; taskPriorityGet (idList[0], &prevPri); for (pCurId = &idList[1]; pCurId < pEndId; ++pCurId, prevPri = curPri) { taskPriorityGet (*pCurId, &curPri); if (prevPri > curPri) { temp = *pCurId; *pCurId = *(pCurId - 1); *(pCurId - 1) = temp; change = TRUE; } } } }/********************************************************************************* taskRegsShow - display the contents of a task's registers** This routine displays the register contents of a specified task* on standard output.** EXAMPLE: The following example displays the register of the shell task * (68000 family):* .CS 4* -> taskRegsShow (taskNameToId ("tShell"))** d0 = 0 d1 = 0 d2 = 578fe d3 = 1* d4 = 3e84e1 d5 = 3e8568 d6 = 0 d7 = ffffffff* a0 = 0 a1 = 0 a2 = 4f06c a3 = 578d0* a4 = 3fffc4 a5 = 0 fp = 3e844c sp = 3e842c* sr = 3000 pc = 4f0f2* value = 0 = 0x0* .CE** RETURNS: N/A*/void taskRegsShow ( int tid /* task ID */ ) { int ix; int * pReg; /* points to register value */ REG_SET regSet; /* register set */ if (_func_taskRegsShowRtn != NULL) { (_func_taskRegsShowRtn) (tid); return; } if (taskRegsGet (tid, ®Set) == ERROR) { printf ("taskRegsShow: invalid task id %#x\n", tid); return; }#if CPU_FAMILY==MIPS taskArchRegsShow (®Set);#else /* print out registers */ for (ix = 0; taskRegName[ix].regName != NULL; ix++) { if ((ix % 4) == 0) printf ("\n"); else printf ("%3s",""); if (taskRegName[ix].regName[0] != EOS) { pReg = (int *) ((int)®Set + taskRegName[ix].regOff); printf (taskRegsFmt, taskRegName[ix].regName, *pReg); } else printf ("%17s", ""); } printf ("\n");#endif }/********************************************************************************* taskStatusString - get a task's status as a string** This routine deciphers the WIND task status word in the TCB for a* specified task, and copies the appropriate string to <pString>.* * The formatted string is one of the following:** .TS* tab(|);* lf3 lf3* l l .* String | Meaning* _* READY | Task is not waiting for any resource other than the CPU.* PEND | Task is blocked due to the unavailability of some resource.* DELAY | Task is asleep for some duration.* SUSPEND | Task is unavailable for execution (but not suspended, delayed, or pended).* DELAY+S | Task is both delayed and suspended.* PEND+S | Task is both pended and suspended.* PEND+T | Task is pended with a timeout.* PEND+S+T | Task is pended with a timeout, and also suspended.* \&...+I | Task has inherited priority (+I may be appended to any string above).* DEAD | Task no longer exists.* .TE** EXAMPLE* .CS* -> taskStatusString (taskNameToId ("tShell"), xx=malloc (10))* new symbol "xx" added to symbol table.* value = 0 = 0x0* -> printf ("shell status = <%s>\en", xx)* shell status = <READY>* value = 2 = 0x2* .CE** RETURNS: OK, or ERROR if the task ID is invalid.*/STATUS taskStatusString ( int tid, /* task to get string for */ char *pString /* where to return string */ ) { WIND_TCB *pTcb = taskTcb (tid); if (pTcb == NULL) return (ERROR); switch (pTcb->status) { case WIND_READY: strcpy (pString, "READY"); break; case WIND_DELAY: strcpy (pString, "DELAY"); break; case WIND_DELAY | WIND_SUSPEND: strcpy (pString, "DELAY+S"); break; case WIND_PEND: strcpy (pString, "PEND"); break; case WIND_PEND | WIND_DELAY: strcpy (pString, "PEND+T"); break; case WIND_PEND | WIND_SUSPEND: strcpy (pString, "PEND+S"); break; case WIND_PEND | WIND_DELAY | WIND_SUSPEND: strcpy (pString, "PEND+S+T"); break; case WIND_SUSPEND: strcpy (pString, "SUSPEND"); break; case WIND_DEAD: strcpy (pString, "DEAD"); break; default: /* unanticipated combination */ sprintf (pString, "0x%02x", pTcb->status); return (ERROR); } if (pTcb->priority != pTcb->priNormal) strcat (pString, "+I"); /* task's priority inherited */ return (OK); }/********************************************************************************* taskOptionsString - get a task's options as a string** This routine deciphers the WIND task options field in the TCB, for a* specified task, and copies the appropriate string to <pString>.** RETURNS: OK, or ERROR if the task ID is invalid.** NOMANUAL*/STATUS taskOptionsString ( int tid, /* task to get options string for */ char *pString /* where to return string of options */ ) { WIND_TCB *pTcb = taskTcb (tid); if (pTcb == NULL) return (ERROR); pString[0] = EOS; /* null terminate string */ if (pTcb->options & VX_SUPERVISOR_MODE) strcat (pString, "VX_SUPERVISOR_MODE "); if (pTcb->options & VX_UNBREAKABLE) strcat (pString, "VX_UNBREAKABLE "); if (pTcb->options & VX_DEALLOC_STACK) strcat (pString, "VX_DEALLOC_STACK "); if (pTcb->options & VX_FP_TASK) strcat (pString, "VX_FP_TASK "); if (pTcb->options & VX_STDIO) strcat (pString, "VX_STDIO "); if (pTcb->options & VX_ADA_DEBUG) strcat (pString, "VX_ADA_DEBUG "); if (pTcb->options & VX_FORTRAN) strcat (pString, "VX_FORTRAN "); if (pTcb->options & VX_PRIVATE_ENV) strcat (pString, "VX_PRIVATE_ENV "); if (pTcb->options & VX_NO_STACK_FILL) strcat (pString, "VX_NO_STACK_FILL "); return (OK); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -