コード例 #1
0
ファイル: ost.cpp プロジェクト: kuailexs/symbiandump-os1
/**
Outputs a trace packet containing 8 bytes of data.

@deprecated

@param aContext 	The trace packet context. @see TTraceContext
@param aTraceId	    The trace point identifier as specified by @see TTraceId
@param aData1		4 bytes of data
@param aData2		4 bytes of data

@return 		The trace packet was/was not output.
*/
EXPORT_C TBool OstTrace(const TTraceContext& aContext, TTraceId aTraceId, TUint32 aData1, TUint32 aData2)
	{
	GET_PC(pc);
	TUint32 packet[2];
	packet[0] = aData1;
	packet[1] = aData2;
	return OST_SECONDARY_ANY(aContext.GroupId(), aContext.ComponentId(), aContext.HasThreadIdentification(), aContext.HasProgramCounter(), pc, aTraceId, &packet, 8);
	}
コード例 #2
0
ファイル: ost.cpp プロジェクト: kuailexs/symbiandump-os1
/**
Outputs a trace packet containing variable length data.

If the specified data is too big to fit into a single
trace record a multipart trace is generated.

@deprecated

@param aContext 	Attributes of the trace point.
@param aTraceId	    The trace point identifier as specified by @see TTraceId
@param aData		Additional data to add to trace packet.
					Must be word aligned, i.e. a multiple of 4.

@return 			The trace packet was/was not logged.

@See BTrace::TMultipart
*/
EXPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TDesC8& aData)
	{
	if(IsTraceActive(aContext))
		{
		GET_PC(pc);
		return OST_SECONDARY_ANY(aContext.GroupId(), aContext.ComponentId(), aContext.HasThreadIdentification(), aContext.HasProgramCounter(), pc, aTraceId, aData.Ptr(), aData.Size());
		}
	return EFalse;
	}
コード例 #3
0
ファイル: ost.cpp プロジェクト: kuailexs/symbiandump-os1
/**
Prints a string by outputting a trace packet with the Trace ID KFormatPrintfUnicode

If the specified string is too long to fit into a single trace packet
a multipart trace is generated.

@deprecated

@param aContext 	The trace packet context. @see TTraceContext
@param aDes			The string. This must not be longer than 256 characters.

@return 			The trace packet was/was not output.

@See BTrace::TMultipart
*/
EXPORT_C TBool OstPrint(const TTraceContext& aContext, const TDesC16& aDes)
	{
	if(IsTraceActive(aContext))
		{
		GET_PC(pc);
		return OST_SECONDARY_ANY(aContext.GroupId(), aContext.ComponentId(), aContext.HasThreadIdentification(), aContext.HasProgramCounter(), pc, KFormatPrintfUnicode, aDes.Ptr(), aDes.Size());
		}
	return EFalse;
	}
コード例 #4
0
ファイル: ost.cpp プロジェクト: kuailexs/symbiandump-os1
/**
Prints a formatted string in kernel mode only by outputting a trace packet with the Trace ID KFormatPrintf.

The function uses Kern::AppendFormat() to do the formatting.

Although it is safe to call this function from an ISR, it polls the output
serial port and may take a long time to complete, invalidating any
real-time guarantee.

If called from an ISR, it is possible for output text to be intermingled
with other output text if one set of output interrupts or preempts another.

Some of the formatting options may not work inside an ISR.

Be careful not to use a string that is too long to fit onto the stack.
If the specified string is too long to fit into a single trace packet
a multipart trace is generated.

@deprecated

@param aContext 	The trace packet context. @see TTraceContext
@param aFmt 		The format string. This must not be longer than 256 characters.
@param ...			A variable number of arguments to be converted to text as dictated
					by the format string.

@return 			The trace packet was/was not output.

@pre Calling thread can either be in a critical section or not.
@pre Interrupts must be enabled.
@pre Kernel must be unlocked
@pre Call in any context.
@pre Suitable for use in a device driver

@see Kern::AppendFormat()
@See BTrace::TMultipart

*/
EXPORT_C TBool OstPrintf(const TTraceContext& aContext, const char* aFmt, ...)
	{
	if(IsTraceActive(aContext))
		{
		GET_PC(pc);
		TBuf8<KMaxPrintfSize> buf;
		VA_LIST list;
		VA_START(list,aFmt);
		Kern::AppendFormat(buf,aFmt,list);
		return OST_SECONDARY_ANY(aContext.GroupId(), aContext.ComponentId(), aContext.HasThreadIdentification(), aContext.HasProgramCounter(), pc, KFormatPrintf, buf.Ptr(), buf.Size());
		}
	return EFalse;
	}
コード例 #5
0
ファイル: ost.cpp プロジェクト: kuailexs/symbiandump-os1
/**
Prints a formatted string by outputting a trace packet with the Trace ID KFormatPrintf.

If the specified string is too long to fit into a single trace packet
a multipart trace is generated.

@deprecated

@param aContext 	The trace packet context. @see TTraceContext
@param aFmt 		The format string. This must not be longer than 256 characters.
@param ...			A variable number of arguments to be converted to text as dictated
					by the format string.

@return 			The trace packet was/was not output.

@See BTrace::TMultipart
*/
EXPORT_C TBool OstPrintf(const TTraceContext& aContext, TRefByValue<const TDesC8> aFmt,...)
	{
	if(IsTraceActive(aContext))
		{
		GET_PC(pc);
		TTruncateOverflow8 overflow;
		VA_LIST list;
		VA_START(list,aFmt);
		TBuf8<KMaxPrintfSize> buf;
		// coverity[uninit_use_in_call : FALSE]
		buf.AppendFormatList(aFmt,list,&overflow);
		return OST_SECONDARY_ANY(aContext.GroupId(), aContext.ComponentId(), aContext.HasThreadIdentification(), aContext.HasProgramCounter(), pc, KFormatPrintf, buf.Ptr(), buf.Size());
		}
	return EFalse;
	}
コード例 #6
0
static VALUE
vm_exec_core(rb_thread_t *th, VALUE initial)
{
    register rb_control_frame_t *reg_cfp = th->cfp;
    VALUE ret;

    while (*GET_PC()) {
	reg_cfp = ((rb_insn_func_t) (*GET_PC()))(th, reg_cfp);

	if (reg_cfp == 0) {
	    VALUE err = th->errinfo;
	    th->errinfo = Qnil;
	    return err;
	}
    }

    if (VM_FRAME_TYPE(th->cfp) != VM_FRAME_MAGIC_FINISH) {
	rb_bug("cfp consistency error");
    }

    ret = *(th->cfp->sp-1); /* pop */
    th->cfp++; /* pop cf */
    return ret;
}
コード例 #7
0
ファイル: ost.cpp プロジェクト: kuailexs/symbiandump-os1
/**
Prints a formatted string by outputting a trace packet with the Trace ID
KFormatPrintfUnicode for unicode strings and KFormatPrintf for other strings.

If the specified string is too long to fit into a single trace packet
a multipart trace is generated.

@deprecated

@param aContext 	The trace packet context. @see TTraceContext
@param aFmt 		The format string. This must not be longer than 256 characters.
@param ...			A variable number of arguments to be converted to text as dictated
					by the format string.

@return 			The trace packet was/was not output.

@See BTrace::TMultipart
*/
EXPORT_C TBool OstPrintf(const TTraceContext& aContext, TRefByValue<const TDesC16> aFmt,...)
	{
	if(IsTraceActive(aContext))
		{
		GET_PC(pc);
		TTruncateOverflow16 overflow;
		VA_LIST list;
		VA_START(list,aFmt);
		TBuf<KMaxPrintfSize> buf;
		// coverity[uninit_use_in_call : FALSE]
		buf.AppendFormatList(aFmt,list,&overflow);
		#ifndef _UNICODE
		TPtr8 p(buf.Collapse());
		return OST_SECONDARY_ANY(aContext.GroupId(), aContext.ComponentId(), aContext.HasThreadIdentification(), aContext.HasProgramCounter(), myPc, KFormatPrintf, buf.PtrZ(), p.Size());
		#else //_UNICODE
		return OST_SECONDARY_ANY(aContext.GroupId(), aContext.ComponentId(), aContext.HasThreadIdentification(), aContext.HasProgramCounter(), pc, KFormatPrintfUnicode, buf.PtrZ(), buf.Size());
		#endif //_UNICODE
		}
	return EFalse;
	};
コード例 #8
0
ファイル: err.c プロジェクト: 4nykey/rockbox
void runtime_error (int errnum)
{
    int wasfirst;
    
    if (errnum <= 0 || errnum > ERR_NUM_ERRORS)
	return;

    if (f_setup.err_report_mode == ERR_REPORT_FATAL
	|| (!f_setup.ignore_errors && errnum <= ERR_MAX_FATAL)) {
	flush_buffer ();
	os_fatal (err_messages[errnum - 1]);
	return;
    }

    wasfirst = (error_count[errnum - 1] == 0);
    error_count[errnum - 1]++;
    
    if ((f_setup.err_report_mode == ERR_REPORT_ALWAYS)
	|| (f_setup.err_report_mode == ERR_REPORT_ONCE && wasfirst)) {
	long pc;

	GET_PC (pc);
	print_string ("Warning: ");
	print_string (err_messages[errnum - 1]);
	print_string (" (PC = ");
	print_long (pc, 16);
	print_char (')');
        
	if (f_setup.err_report_mode == ERR_REPORT_ONCE) {
	    print_string (" (will ignore further occurrences)");
	} else {
	    print_string (" (occurence ");
	    print_long (error_count[errnum - 1], 10);
	    print_char (')');
	}
	new_line ();
    }

} /* report_error */
コード例 #9
0
ファイル: vm_exec.c プロジェクト: alansparrow/learningruby
static VALUE
vm_exec_core(rb_thread_t *th, VALUE initial)
{
    register rb_control_frame_t *reg_cfp = th->cfp;

    while (1) {
	reg_cfp = ((rb_insn_func_t) (*GET_PC()))(th, reg_cfp);

	if (UNLIKELY(reg_cfp == 0)) {
	    break;
	}
    }

    if (th->retval != Qundef) {
	VALUE ret = th->retval;
	th->retval = Qundef;
	return ret;
    }
    else {
	VALUE err = th->errinfo;
	th->errinfo = Qnil;
	return err;
    }
}
コード例 #10
0
ファイル: ssp16.c プロジェクト: birthdayalex/DroidGEN
// 6
static u32 read_PC(void)
{
  //g_cycles--;
  return GET_PC();
}
コード例 #11
0
ファイル: ost.cpp プロジェクト: kuailexs/symbiandump-os1
/**
Outputs a trace packet containing 4 bytes of data.

@deprecated

@param aContext 	The trace packet context. @see TTraceContext
@param aTraceId	    The trace point identifier as specified by @see TTraceId
@param aData		4 bytes of data

@return 		The trace packet was/was not output.
*/
EXPORT_C TBool OstTrace(const TTraceContext& aContext, const TTraceId aTraceId, const TUint8 aData)
	{
	GET_PC(pc);
	return OST_SECONDARY_1(aContext.GroupId(),aContext.ComponentId(),aContext.HasThreadIdentification(),aContext.HasProgramCounter(),pc,aTraceId,aData);
	}
コード例 #12
0
ファイル: ssp16.c プロジェクト: RetroAchievements/RASuite
/* 6 */
static u32 read_PC(void)
{
  /* g_cycles--; */
  return GET_PC();
}
コード例 #13
0
ファイル: segfault.c プロジェクト: mbref/eglibc-microblaze
/* This function is called when a segmentation fault is caught.  The system
   is in an unstable state now.  This means especially that malloc() might
   not work anymore.  */
static void
catch_segfault (int signal, SIGCONTEXT ctx)
{
    int fd, cnt, i;
    void **arr;
    struct sigaction sa;
    uintptr_t pc;

    /* This is the name of the file we are writing to.  If none is given
       or we cannot write to this file write to stderr.  */
    fd = 2;
    if (fname != NULL)
    {
        fd = open (fname, O_TRUNC | O_WRONLY | O_CREAT, 0666);
        if (fd == -1)
            fd = 2;
    }

    WRITE_STRING ("*** ");
    write_strsignal (fd, signal);
    WRITE_STRING ("\n");

#ifdef REGISTER_DUMP
    REGISTER_DUMP;
#endif

#if __OPTION_EGLIBC_BACKTRACE
    WRITE_STRING ("\nBacktrace:\n");

    /* Get the backtrace.  */
    arr = alloca (256 * sizeof (void *));
    cnt = backtrace (arr, 256);

    /* Now try to locate the PC from signal context in the backtrace.
       Normally it will be found at arr[2], but it might appear later
       if there were some signal handler wrappers.  Allow a few bytes
       difference to cope with as many arches as possible.  */
    pc = (uintptr_t) GET_PC (ctx);
    for (i = 0; i < cnt; ++i)
        if ((uintptr_t) arr[i] >= pc - 16 && (uintptr_t) arr[i] <= pc + 16)
            break;

    /* If we haven't found it, better dump full backtrace even including
       the signal handler frames instead of not dumping anything.  */
    if (i == cnt)
        i = 0;

    /* Now generate nicely formatted output.  */
    __backtrace_symbols_fd (arr + i, cnt - i, fd);
#endif

#ifdef HAVE_PROC_SELF
    /* Now the link map.  */
    int mapfd = open ("/proc/self/maps", O_RDONLY);
    if (mapfd != -1)
    {
        write (fd, "\nMemory map:\n\n", 14);

        char buf[256];
        ssize_t n;

        while ((n = TEMP_FAILURE_RETRY (read (mapfd, buf, sizeof (buf)))) > 0)
            TEMP_FAILURE_RETRY (write (fd, buf, n));

        close (mapfd);
    }
#endif

    /* Pass on the signal (so that a core file is produced).  */
    sa.sa_handler = SIG_DFL;
    sigemptyset (&sa.sa_mask);
    sa.sa_flags = 0;
    sigaction (signal, &sa, NULL);
    raise (signal);
}
コード例 #14
0
/* This function is called when a segmentation fault is caught.  The system
   is in an instable state now.  This means especially that malloc() might
   not work anymore.  */
static void
catch_segfault (int signal, SIGCONTEXT ctx)
{
    struct layout *current;
    void *__unbounded top_frame;
    void *__unbounded top_stack;
    int fd;
    void **arr;
    size_t cnt;
    struct sigaction sa;

    /* This is the name of the file we are writing to.  If none is given
       or we cannot write to this file write to stderr.  */
    fd = 2;
    if (fname != NULL)
    {
        fd = open (fname, O_TRUNC | O_WRONLY | O_CREAT, 0666);
        if (fd == -1)
            fd = 2;
    }

    WRITE_STRING ("*** ");
    write_strsignal (fd, signal);
    WRITE_STRING ("\n");

#ifdef REGISTER_DUMP
    REGISTER_DUMP;
#endif

    WRITE_STRING ("\nBacktrace:\n");

    top_frame = GET_FRAME (ctx);
    top_stack = GET_STACK (ctx);

    /* First count how many entries we'll have.  */
    cnt = 1;
    current = BOUNDED_1 ((struct layout *) top_frame);
    while (!((void *) current INNER_THAN top_stack
             || !((void *) current INNER_THAN __libc_stack_end)))
    {
        ++cnt;

        current = ADVANCE_STACK_FRAME (current->next);
    }

    arr = alloca (cnt * sizeof (void *));

    /* First handle the program counter from the structure.  */
    arr[0] = GET_PC (ctx);

    current = BOUNDED_1 ((struct layout *) top_frame);
    cnt = 1;
    while (!((void *) current INNER_THAN top_stack
             || !((void *) current INNER_THAN __libc_stack_end)))
    {
        arr[cnt++] = current->return_address;

        current = ADVANCE_STACK_FRAME (current->next);
    }

    /* If the last return address was NULL, assume that it doesn't count.  */
    if (arr[cnt-1] == NULL)
        cnt--;

    /* Now generate nicely formatted output.  */
    __backtrace_symbols_fd (arr, cnt, fd);

    /* Pass on the signal (so that a core file is produced).  */
    sa.sa_handler = SIG_DFL;
    sigemptyset (&sa.sa_mask);
    sa.sa_flags = 0;
    sigaction (signal, &sa, NULL);
    raise (signal);
}