summaryrefslogtreecommitdiff
path: root/vm_backtrace.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-13 04:31:06 (GMT)
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-13 04:31:06 (GMT)
commit0aed7c6874ba75f1a85899d0ed0ea07b24a9f3ef (patch)
tree71350c2b48c1b2defd672ed3f672d130a7e5ebc0 /vm_backtrace.c
parent4547d773c2ea02864df5658a99d18718626e902d (diff)
* error.c: add Exception#backtrace_locations.
Now, there are no setter and independent from Exception#backtrace. [Feature #8960] * eval.c (setup_exception): set backtrace locations for `bt_location' special attribute. * vm_backtrace.c (rb_backtrace_to_location_ary): added. * internal.h: ditto. * test/ruby/test_backtrace.rb: add a test for Exception#backtrace_locations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_backtrace.c')
-rw-r--r--vm_backtrace.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/vm_backtrace.c b/vm_backtrace.c
index 5b05b04..f57458e 100644
--- a/vm_backtrace.c
+++ b/vm_backtrace.c
@@ -372,6 +372,7 @@ typedef struct rb_backtrace_struct {
rb_backtrace_location_t *backtrace_base;
int backtrace_size;
VALUE strary;
+ VALUE locary;
} rb_backtrace_t;
static void
@@ -383,8 +384,9 @@ backtrace_mark(void *ptr)
for (i=0; i<s; i++) {
location_mark_entry(&bt->backtrace[i]);
- rb_gc_mark(bt->strary);
}
+ rb_gc_mark(bt->strary);
+ rb_gc_mark(bt->locary);
}
}
@@ -631,6 +633,18 @@ backtrace_to_location_ary(VALUE self, long lev, long n)
return r;
}
+VALUE
+rb_backtrace_to_location_ary(VALUE self)
+{
+ rb_backtrace_t *bt;
+ GetCoreDataFromValue(self, rb_backtrace_t, bt);
+
+ if (!bt->locary) {
+ bt->locary = backtrace_to_location_ary(self, 0, 0);
+ }
+ return bt->locary;
+}
+
static VALUE
backtrace_dump_data(VALUE self)
{