aboutsummaryrefslogtreecommitdiffstats
path: root/vm_eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'vm_eval.c')
-rw-r--r--vm_eval.c41
1 files changed, 6 insertions, 35 deletions
diff --git a/vm_eval.c b/vm_eval.c
index ff7d785354..cd83d42847 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -20,9 +20,8 @@ static VALUE vm_exec(rb_thread_t *th);
static void vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const NODE *cref);
static int vm_collect_local_variables_in_heap(rb_thread_t *th, VALUE *dfp, VALUE ary);
-static int vm_backtrace_each(rb_thread_t *th, int lev, ptrdiff_t n, void (*init)(void *), rb_backtrace_iter_func *iter, void *arg);
-static VALUE backtrace_object(rb_thread_t *th, int lev, ptrdiff_t n);
-static VALUE vm_backtrace_str_ary(rb_thread_t *th, int lev, int n);
+static VALUE vm_backtrace_str_ary(rb_thread_t *th, size_t lev, size_t n);
+static void vm_backtrace_print(FILE *fp);
typedef enum call_type {
CALL_PUBLIC,
@@ -1087,7 +1086,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, const char
errat = rb_get_backtrace(errinfo);
mesg = rb_attr_get(errinfo, id_mesg);
if (!NIL_P(errat) && RB_TYPE_P(errat, T_ARRAY) &&
- (bt2 = vm_backtrace_str_ary(th, -2, 0), RARRAY_LEN(bt2) > 0)) {
+ (bt2 = vm_backtrace_str_ary(th, 0, 0), RARRAY_LEN(bt2) > 0)) {
if (!NIL_P(mesg) && RB_TYPE_P(mesg, T_STRING) && !RSTRING_LEN(mesg)) {
if (OBJ_FROZEN(mesg)) {
VALUE m = rb_str_cat(rb_str_dup(RARRAY_PTR(errat)[0]), ": ", 2);
@@ -1622,41 +1621,19 @@ rb_f_caller(int argc, VALUE *argv)
if (lev < 0)
rb_raise(rb_eArgError, "negative level (%d)", lev);
- return vm_backtrace_str_ary(GET_THREAD(), lev, 0);
-}
-
-static int
-print_backtrace(void *arg, VALUE file, int line, VALUE method)
-{
- FILE *fp = arg;
- const char *filename = NIL_P(file) ? "ruby" : RSTRING_PTR(file);
- if (NIL_P(method)) {
- fprintf(fp, "\tfrom %s:%d:in unknown method\n",
- filename, line);
- }
- else {
- fprintf(fp, "\tfrom %s:%d:in `%s'\n",
- filename, line, RSTRING_PTR(method));
- }
- return FALSE;
+ return vm_backtrace_str_ary(GET_THREAD(), lev+1, 0);
}
void
rb_backtrace(void)
{
- vm_backtrace_each(GET_THREAD(), -1, 0, NULL, print_backtrace, stderr);
+ vm_backtrace_print(stderr);
}
VALUE
rb_make_backtrace(void)
{
- return vm_backtrace_str_ary(GET_THREAD(), -1, 0);
-}
-
-VALUE
-rb_vm_backtrace_object()
-{
- return backtrace_object(GET_THREAD(), -1, 0);
+ return vm_backtrace_str_ary(GET_THREAD(), 0, 0);
}
VALUE
@@ -1678,12 +1655,6 @@ rb_thread_backtrace(VALUE thval)
return vm_backtrace_str_ary(th, 0, 0);
}
-int
-rb_backtrace_each(rb_backtrace_iter_func *iter, void *arg)
-{
- return vm_backtrace_each(GET_THREAD(), -1, 0, NULL, iter, arg);
-}
-
/*
* call-seq:
* local_variables -> array