示例#1
0
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   */
    SYMBOL_ID symbolId;                 /* symbol identifier         */
    char *    name;   /* ptr to sym tbl copy of name of main routine */
    void *    value = NULL;		/* symbol's actual value     */

    taskStatusString (pTd->td_id, statusString);

    /* Print the summary of the TCB */

    printf ("%-11.11s", pTd->td_name);	/* print the name of the task */

    /* 
     * Only check one symLib function pointer (for performance's sake). 
     * All symLib functions are provided by the same library, by convention.    
     */

    if ((_func_symFindSymbol != (FUNCPTR) NULL) && 
	(sysSymTbl != NULL) && 
	((* _func_symFindSymbol) (sysSymTbl, NULL, (char *)pTd->td_entry, 
				 N_EXT | N_TEXT, N_EXT | N_TEXT,
				 &symbolId) == OK))
	{
	(* _func_symNameGet) (symbolId, &name);
	(* _func_symValueGet) (symbolId, &value);
	}

    if (pTd->td_entry == (FUNCPTR) value)
	printf ("%-12.12s", name);
    else
	printf ("%-12x", (int)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, &regSet);

    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);
    }
示例#2
0
static INT32 wpiStackTask(INT32 taskId)
{
	taskDelay(1);
	//tt(taskId);

	REG_SET regs;
	taskRegsGet(taskId, &regs);
	trcStack(&regs, (FUNCPTR) wpiCleanTracePrint, taskId);

	// The task should be resumed because it had to be suspended to get the stack trace.
	taskResume(taskId);
	return 0;
}
示例#3
0
void taskRegsShow
    (
    int tid             /* task ID */
    )
    {
#if ((CPU_FAMILY != MIPS) && (CPU_FAMILY != COLDFIRE))
    int		ix;
    int *	pReg;		/* points to register value */
#endif /* (CPU_FAMILY != MIPS) && (CPU_FAMILY != COLDFIRE) */
    REG_SET	regSet;		/* register set */

    if (_func_taskRegsShowRtn != NULL)
        {
        (_func_taskRegsShowRtn) (tid);
        return;
        }

    if (taskRegsGet (tid, &regSet) == ERROR)
	{
	printf ("taskRegsShow: invalid task id %#x\n", tid);
	return;
	}

#if (CPU_FAMILY==MIPS || CPU_FAMILY==COLDFIRE)
    taskArchRegsShow (&regSet);
#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)&regSet + taskRegName[ix].regOff);
	    printf (taskRegsFmt, taskRegName[ix].regName, *pReg);
	    }
	else
	    printf ("%17s", "");
	}
    printf ("\n");
#endif
    }
示例#4
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 = 3;

  if (num_frames == 0)
    num_frames = MAX_FRAMES;

  size_t starting_frame =
    determine_starting_frame (INITIAL_FRAME, starting_frame_offset);

  ACE_Stack_Trace_stackstate state (&this->buf_[0], this->buflen_,
                                    num_frames, starting_frame);

  REG_SET regs;

  taskRegsGet ((int)taskIdSelf(), &regs);
  // Maybe we should take a lock here to guard stateptr?
  ACE_Stack_Trace_stateptr = &state;
  trcStack (&regs, (FUNCPTR)ACE_Stack_Trace_Add_Frame_To_Buf, taskIdSelf ());
}
示例#5
0
void fastPoll( void )
	{
	RANDOM_STATE randomState;
	BYTE buffer[ RANDOM_BUFSIZE + 8 ];
	REG_SET registerSet;
	struct timespec timeSpec;
	ULONG tickCount;
	int value, status;

	status = initRandomData( randomState, buffer, RANDOM_BUFSIZE );
	if( cryptStatusError( status ) )
		retIntError_Void();

	/* Add various clock/timer values.  These are both very fast clocks/
	   counters, however the difference over subsequent calls is only
	   2-3 bits in the LSB */
	tickCount = tickGet();
	addRandomLong( randomState, tickCount );
	status = clock_gettime( CLOCK_REALTIME, &timeSpec );
	if( status == 0 )
		addRandomData( randomState, &timeSpec, sizeof( struct timespec ) );

	/* Add the interrupt nesting depth (usually 0) */
	value = intCount();
	addRandomLong( randomState, value );

	/* Add the current task's registers.  The documentation states that 
	   "self-examination is not advisable as results are unpredictable",
	   which is either good (the registers are random garbage values) or
	   bad (the registers have fixed values).  Usually they seem to be 
	   pretty fixed, at least when called repeatedly in rapid succession */
	status = taskRegsGet( taskIdSelf(), &registerSet );
	if( status == OK )
		addRandomData( randomState, &registerSet, sizeof( REG_SET ) );

	endRandomData( randomState, 5 );
	}
示例#6
0
static void event_handler(void * arg) {
    struct event_info * info = (struct event_info *)arg;
    Context * current_ctx = context_find_from_pid(info->current_ctx.ctxId, 1);
    Context * stopped_ctx = context_find_from_pid(info->stopped_ctx.ctxId, 1);

    switch (info->event) {
    case EVENT_HOOK_BREAKPOINT:
        if (stopped_ctx == NULL) break;
        assert(!stopped_ctx->stopped);
        assert(!EXT(stopped_ctx)->regs_dirty);
        if (EXT(stopped_ctx)->regs_error) {
            release_error_report(EXT(stopped_ctx)->regs_error);
            EXT(stopped_ctx)->regs_error = NULL;
        }
        memcpy(EXT(stopped_ctx)->regs, &info->regs, sizeof(REG_SET));
        EXT(stopped_ctx)->event = 0;
        stopped_ctx->signal = SIGTRAP;
        stopped_ctx->stopped = 1;
        stopped_ctx->stopped_by_bp = info->bp_info_ok;
        stopped_ctx->stopped_by_exception = 0;
        assert(get_regs_PC(stopped_ctx) == info->addr);
        if (stopped_ctx->stopped_by_bp && !is_breakpoint_address(stopped_ctx, info->addr)) {
            /* Break instruction that is not planted by us */
            stopped_ctx->stopped_by_bp = 0;
            stopped_ctx->pending_intercept = 1;
        }
        EXT(stopped_ctx)->bp_info = info->bp_info;
        if (current_ctx != NULL) EXT(stopped_ctx)->bp_pid = EXT(current_ctx)->pid;
        assert(taskIsStopped(EXT(stopped_ctx)->pid));
        trace(LOG_CONTEXT, "context: stopped by breakpoint: ctx %#lx, id %#x",
                stopped_ctx, EXT(stopped_ctx)->pid);
        send_context_stopped_event(stopped_ctx);
        break;
    case EVENT_HOOK_STEP_DONE:
        if (current_ctx == NULL) break;
        assert(!current_ctx->stopped);
        assert(!EXT(current_ctx)->regs_dirty);
        if (EXT(current_ctx)->regs_error) {
            release_error_report(EXT(current_ctx)->regs_error);
            EXT(current_ctx)->regs_error = NULL;
        }
        memcpy(EXT(current_ctx)->regs, &info->regs, sizeof(REG_SET));
        EXT(current_ctx)->event = TRACE_EVENT_STEP;
        current_ctx->signal = SIGTRAP;
        current_ctx->stopped = 1;
        current_ctx->stopped_by_bp = 0;
        current_ctx->stopped_by_exception = 0;
        assert(taskIsStopped(EXT(current_ctx)->pid));
        trace(LOG_CONTEXT, "context: stopped by end of step: ctx %#lx, id %#x",
                current_ctx, EXT(current_ctx)->pid);
        send_context_stopped_event(current_ctx);
        break;
    case EVENT_HOOK_STOP:
        if (stopped_ctx == NULL) break;
        assert(!stopped_ctx->exited);
        if (stopped_ctx->stopped) break;
        if (EXT(stopped_ctx)->regs_error) {
            release_error_report(EXT(stopped_ctx)->regs_error);
            EXT(stopped_ctx)->regs_error = NULL;
        }
        if (taskRegsGet(EXT(stopped_ctx)->pid, EXT(stopped_ctx)->regs) != OK) {
            EXT(stopped_ctx)->regs_error = get_error_report(errno);
            assert(EXT(stopped_ctx)->regs_error != NULL);
        }
        EXT(stopped_ctx)->event = 0;
        stopped_ctx->signal = SIGSTOP;
        stopped_ctx->stopped = 1;
        stopped_ctx->stopped_by_bp = 0;
        stopped_ctx->stopped_by_exception = 0;
        assert(taskIsStopped(EXT(stopped_ctx)->pid));
        trace(LOG_CONTEXT, "context: stopped by sofware request: ctx %#lx, id %#x",
                stopped_ctx, EXT(stopped_ctx)->pid);
        send_context_stopped_event(stopped_ctx);
        break;
    case EVENT_HOOK_TASK_ADD:
        if (current_ctx == NULL) break;
        assert(stopped_ctx == NULL);
        stopped_ctx = create_context(pid2id((pid_t)info->stopped_ctx.ctxId, EXT(current_ctx->parent)->pid));
        EXT(stopped_ctx)->pid = (pid_t)info->stopped_ctx.ctxId;
        EXT(stopped_ctx)->regs = (REG_SET *)loc_alloc(sizeof(REG_SET));
        stopped_ctx->mem = current_ctx->mem;
        stopped_ctx->big_endian = current_ctx->mem->big_endian;
        (stopped_ctx->creator = current_ctx)->ref_count++;
        (stopped_ctx->parent = current_ctx->parent)->ref_count++;
        assert(stopped_ctx->mem == stopped_ctx->parent->mem);
        list_add_last(&stopped_ctx->cldl, &stopped_ctx->parent->children);
        link_context(stopped_ctx);
        trace(LOG_CONTEXT, "context: created: ctx %#lx, id %#x",
                stopped_ctx, EXT(stopped_ctx)->pid);
        send_context_created_event(stopped_ctx);
        break;
    default:
        assert(0);
        break;
    }
    loc_free(info);
    SPIN_LOCK_ISR_TAKE(&events_lock);
    events_cnt--;
    SPIN_LOCK_ISR_GIVE(&events_lock);
}