Пример #1
0
/*
 * int __wind_taskinfo_get(TASK_ID task_id, TASK_DESC *desc)
 */
static int __wind_taskinfo_get(struct task_struct *curr, struct pt_regs *regs)
{
	xnhandle_t handle = __xn_reg_arg1(regs);
	TASK_DESC desc;
	WIND_TCB *pTcb;
	int err;

	if (!__xn_access_ok
	    (curr, VERIFY_WRITE, __xn_reg_arg2(regs), sizeof(desc)))
		return -EFAULT;

	pTcb = (WIND_TCB *)xnregistry_fetch(handle);
	if (!pTcb)
		return S_objLib_OBJ_ID_ERROR;

	err = taskInfoGet((TASK_ID)pTcb, &desc);
	if (!err) {
		/* Replace the kernel-based pointer by the userland handle. */
		desc.td_tid = handle;
		__xn_copy_to_user(curr, (void __user *)__xn_reg_arg2(regs), &desc,
				  sizeof(desc));
	}

	return err;
}
Пример #2
0
CVMBool
CVMthreadAttach(CVMThreadID *self, CVMBool orphan)
{
    if (orphan) {
	self->taskID = taskIdSelf();
    } else {
	assert(self->taskID == taskIdSelf());
    }

    fpuInit();
    if (!vxworksSyncInit(self)) {
	CVMdebugPrintf(("WARNING: CVMthreadAttach failed.\n"));
	return CVM_FALSE;
    }

    /* NOTE: taskVarAdd() creates a unique copy of the mySelf pointer for each
       task so that we can have a unique thread ID for each task: */
    taskVarAdd(0, (int *)&mySelf);
    mySelf = self;

    {
        TASK_DESC desc;
        taskInfoGet(0, &desc);
        self->stackTop = desc.td_pStackLimit;
    }

    return CVM_TRUE;
}
Пример #3
0
void
__gnat_get_stack_info (stack_info *vxworks_stack_info)
{
  TASK_DESC descriptor;

  /* Ask the VxWorks kernel about stack values */
  taskInfoGet (taskIdSelf (), &descriptor);

  /* Fill the stack data with the information provided by the kernel */
  vxworks_stack_info->size = descriptor.td_stackSize;
  vxworks_stack_info->base = descriptor.td_pStackBase;
  vxworks_stack_info->end  = descriptor.td_pStackEnd;
}
Пример #4
0
// Set a new proxy value
float Proxy::set(string name, float val)
{
	for(unsigned i=0;i<name.size();i++) {
		name[i] = toupper(name[i]);
	}
	if(data.find(name) == data.end()) {
		Robot::getInstance()->DriverStationDisplay("Proxy ERR: %s", name.c_str());
		printf("Proxy::set cannot find variable: `%s`\n", name.c_str());
		TASK_DESC errtask;
		taskInfoGet(taskIdSelf(),&errtask);
		printf("\tFrom task: %s\n",errtask.td_name);
		return 0;
	}
	semTake(data[name].second, WAIT_FOREVER);
	data[name].first = val;
	semGive(data[name].second);
	return val;
}
Пример #5
0
/*
 * int __wind_taskinfo_get(TASK_ID task_id, TASK_DESC *desc)
 */
static int __wind_taskinfo_get(struct pt_regs *regs)
{
	xnhandle_t handle = __xn_reg_arg1(regs);
	TASK_DESC desc;
	WIND_TCB *pTcb;
	int err;

	pTcb = __wind_lookup_task(handle);
	if (!pTcb)
		return S_objLib_OBJ_ID_ERROR;

	err = taskInfoGet((TASK_ID)pTcb, &desc);
	if (err)
		return err;

	/* Replace the kernel-based pointer by the userland handle. */
	desc.td_tid = handle;

	return __xn_safe_copy_to_user((void __user *)__xn_reg_arg2(regs),
				      &desc, sizeof(desc));
}
Пример #6
0
void
ACE_Stack_Trace::generate_trace (ssize_t starting_frame_offset,
                                 size_t num_frames)
{
  const size_t MAX_FRAMES = 128;
  const ssize_t INITIAL_FRAME = 2;

  if (num_frames == 0) num_frames = MAX_FRAMES;
  size_t starting_frame =
    determine_starting_frame (INITIAL_FRAME, starting_frame_offset);

  jmp_buf regs;
  setjmp (regs);

  TASK_DESC desc;
  if (taskInfoGet (taskIdSelf (), &desc) == ERROR) return;

  TRC_OS_CTX osCtx;
  osCtx.stackBase = desc.td_pStackBase;
  osCtx.stackEnd = desc.td_pStackEnd;
  osCtx.pcValidateRtn = reinterpret_cast<FUNCPTR> (ace_vx_rtp_pc_validate);

  char *fp = _WRS_FRAMEP_FROM_JMP_BUF (regs);
  INSTR *pc = _WRS_RET_PC_FROM_JMP_BUF (regs);

  for (size_t depth = 0; depth < num_frames + starting_frame; ++depth)
    {
      char *prevFp;
      INSTR *prevPc;
      INSTR *prevFn;

      if (trcLibFuncs.lvlInfoGet (fp, pc, &osCtx, &prevFp, &prevPc, &prevFn)
          == ERROR)
        {
          ACE_OS::strcpy (this->buf_, UNABLE_TO_GET_TRACE);
          return;
        }

      if(prevPc == 0 || prevFp == 0) break;

      if (depth >= starting_frame)
        {
          //Hopefully a future version of VxWorks will have a system call
          //for an RTP to query its own symbols, but this is not possible now.
          //An enhancement request has been filed under WIND00123307.
          const char *fnName = "(no symbols)";

          static const int N_ARGS = 12;
          int buf[N_ARGS];
          int *pArgs = 0;
          int numArgs =
            trcLibFuncs.lvlArgsGet (prevPc, prevFn, prevFp,
                                    buf, N_ARGS, &pArgs);

          // VxWorks can return -1 for "numArgs" if there was an error
          if (numArgs == -1) numArgs = 0;

          size_t len = ACE_OS::strlen (this->buf_);
          size_t space = SYMBUFSIZ - len - 1;
          char *cursor = this->buf_ + len;
          size_t written = ACE_OS::snprintf (cursor, space, "%x %s",
                                             prevFn, fnName);
          cursor += written;
          space -= written;

          if (space < 1) return; //no point in logging when we're out of buffer
          for (int arg = 0; numArgs != -1 && pArgs && arg < numArgs; ++arg)
            {
              if (arg == 0) *cursor++ = '(', --space;
              written = ACE_OS::snprintf (cursor, space,
                                          (arg < numArgs - 1) ? "%x, " : "%x",
                                          pArgs[arg]);
              cursor += written;
              space -= written;
              if (space && arg == numArgs - 1) *cursor++ = ')', --space;
            }
          if (space) *cursor++ = '\n', --space;
          *cursor++ = 0; //we saved space for the null terminator
        }

      fp = prevFp;
      pc = prevPc;
    }
}
Пример #7
0
STATUS taskShow
    (
    int tid,		/* task ID */
    int level		/* 0 = summary, 1 = details, 2 = all tasks */
    )
    {
    FAST int	nTasks;			/* number of task */
    FAST int	ix;			/* index */
    TASK_DESC	td;			/* task descriptor for task info */
    WIND_TCB *	pTcb;			/* pointer to tasks tcb */
    int		idList[MAX_DSP_TASKS];	/* list of active IDs */
    char	optionsString[256];	/* task options string */

    tid = taskIdDefault (tid);				/* get default task */

    switch (level)
	{
	case 0 :					/* summarize a task */
	    {
	    if (taskInfoGet (tid, &td) != OK)
		{
		printErr ("Task not found.\n");
		return (ERROR);
		}

	    printf (infoHdr);
	    taskSummary (&td);
	    break;
	    }

	case 1 :					/* get task detail */
	    {
	    if (taskInfoGet (tid, &td) != OK)
		{
		printErr ("Task not found.\n");
		return (ERROR);
		}

	    taskOptionsString (tid, optionsString);	/* get options string */

	    /* Print the summary as in all_task_info, then all the regs. */

	    printf (infoHdr);				/* banner */
	    taskSummary (&td);

	    printf ("\nstack: base 0x%-6x  end 0x%-6x  size %-5d  ",
		    (int)td.td_pStackBase, (int)td.td_pStackEnd,
		    td.td_stackSize);

	    if (td.td_options & VX_NO_STACK_FILL)
		printf ("high %5s  margin %5s\n", "???", "???");
	    else
		printf ("high %-5d  margin %-5d\n", td.td_stackHigh,
			 td.td_stackMargin);

	    printf ("\noptions: 0x%x\n%s\n", td.td_options, optionsString);

	    /* display VxWorks events information */

	    eventTaskShow (&td.td_events);

	    if (tid != taskIdSelf ())			/* no self exam */
		{
		taskRegsShow (tid);
		if (_func_fppTaskRegsShow != NULL)	/* fp regs if attached*/
		    (* _func_fppTaskRegsShow) (tid);
		if (_func_dspTaskRegsShow != NULL)	/* dsp regs if attached*/
		    (* _func_dspTaskRegsShow) (tid);
#ifdef _WRS_ALTIVEC_SUPPORT
		if (_func_altivecTaskRegsShow != NULL)	/* altivec regs if attached*/
		    (* _func_altivecTaskRegsShow) (tid);
#endif /* _WRS_ALTIVEC_SUPPORT */

#if (CPU_FAMILY==I80X86)
		if (_func_sseTaskRegsShow != NULL)	/* SIMD regs if attached */
		    (* _func_sseTaskRegsShow) (tid);
#endif /* (CPU_FAMILY==I80X86) */
		}

	    /* 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);
    }