Ejemplo n.º 1
0
void
rb_vm_bugreport(void)
{
    VALUE bt;

    if (GET_THREAD()->vm) {
	int i;
	SDR();

	bt = rb_make_backtrace();
	if (TYPE(bt) == T_ARRAY)
	for (i = 0; i < RARRAY_LEN(bt); i++) {
	    dp(RARRAY_AT(bt, i));
	}
    }

#if HAVE_BACKTRACE
#include <execinfo.h>
#define MAX_NATIVE_TRACE 1024
    {
	static void *trace[MAX_NATIVE_TRACE];
	int n = backtrace(trace, MAX_NATIVE_TRACE);
	int i;

	fprintf(stderr, "-- backtrace of native function call (Use addr2line) --\n");
	for (i=0; i<n; i++) {
	    fprintf(stderr, "%p\n", trace[i]);
	}
	fprintf(stderr, "-------------------------------------------------------\n");
    }
#endif
}
Ejemplo n.º 2
0
static void
stacktrace_dumper(int signum)
{
    #define MAX_TRACES 1024
    static void *trace[MAX_TRACES];
    int n;
    VALUE backtrace_arr;

    backtrace_arr = rb_make_backtrace();
    fprintf(stderr,
            "-- Ruby level backtrace --------------------------------------\n");
    rb_io_puts(1, &backtrace_arr, rb_stderr);
    fprintf(stderr, "\n");

    fprintf(stderr,
            "-- C level backtrace -----------------------------------------\n");
#if defined(HAVE_BACKTRACE) && !defined(__APPLE__)
    n = backtrace(trace, MAX_TRACES);
    backtrace_symbols_fd(trace, n, STDERR_FILENO);
#elif defined(HAVE_BACKTRACE) && defined(__APPLE__)
    fprintf(stderr,
            "C level backtrace is unavailable due to the bug in the OSX's environment.\nSee r39301 and r39808 of CRuby for the details.\n");
#else
    fprintf(stderr,
            "C level backtrace is unavailable because backtrace(3) is unavailable.\n")
#endif
    exit(exitcode);
}
Ejemplo n.º 3
0
void
rb_vm_bugreport(void)
{
    VALUE bt;

    if (GET_THREAD()->vm) {
	int i;
	SDR();

	bt = rb_make_backtrace();

	if (bt) {
	    fprintf(stderr, "-- Ruby level backtrace information"
		    "-----------------------------------------\n");

	    for (i = 0; i < RARRAY_LEN(bt); i++) {
		VALUE str = RARRAY_PTR(bt)[i];
		fprintf(stderr, "%s\n", RSTRING_PTR(str));
	    }
	    fprintf(stderr, "\n");
	}
    }

#if HAVE_BACKTRACE
#include <execinfo.h>
#define MAX_NATIVE_TRACE 1024
    {
	static void *trace[MAX_NATIVE_TRACE];
	int n = backtrace(trace, MAX_NATIVE_TRACE);
	char **syms = backtrace_symbols(trace, n);
	int i;

	fprintf(stderr, "-- C level backtrace information "
		"-------------------------------------------\n");
	for (i=0; i<n; i++) {
	    const char *info = syms ? syms[i] : "";
	    fprintf(stderr, "%p %s\n", trace[i], info);
	}
	fprintf(stderr, "\n");

	if (syms) {
	    free(syms);
	}
    }
#endif
}
Ejemplo n.º 4
0
static void
argument_error(const rb_iseq_t *iseq, int miss_argc, int correct_argc)
{
    VALUE mesg = rb_sprintf("wrong number of arguments (%d for %d)", miss_argc, correct_argc);
    VALUE exc = rb_exc_new3(rb_eArgError, mesg);
    VALUE bt = rb_make_backtrace();
    VALUE err_line = 0;

    if (iseq) {
	int line_no = 1;

	if (iseq->insn_info_size) {
	    line_no = iseq->insn_info_table[0].line_no;
	}

	err_line = rb_sprintf("%s:%d:in `%s'",
			      RSTRING_PTR(iseq->filename),
			      line_no, RSTRING_PTR(iseq->name));
	rb_funcall(bt, rb_intern("unshift"), 1, err_line);
    }

    rb_funcall(exc, rb_intern("set_backtrace"), 1, bt);
    rb_exc_raise(exc);
}
Ejemplo n.º 5
0
static VALUE kernel_spec_rb_make_backtrace(VALUE self) {
  return rb_make_backtrace();
}