summaryrefslogtreecommitdiff
path: root/vm_backtrace.c
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2024-02-19 11:30:26 +0100
committerJean Boussier <[email protected]>2024-03-14 11:38:40 +0100
commit315bde5a0f95562f58405a43456ec6715ef20d32 ()
treec499f36305afbc3fb7a4d087708e8dafd6f1ff89 /vm_backtrace.c
parent5326337d4f15ccf33128b3cf5a8896ba7f91fcc4 (diff)
`Exception#set_backtrace` accept arrays of `Backtrace::Location`
[Feature #13557] Setting the backtrace with an array of strings is lossy. The resulting exception will return nil on `#backtrace_locations`. By accepting an array of `Backtrace::Location` instance, we can rebuild a `Backtrace` instance and have a fully functioning Exception. Co-Authored-By: Étienne Barrié <[email protected]>
-rw-r--r--vm_backtrace.c48
1 files changed, 45 insertions, 3 deletions
@@ -531,6 +531,16 @@ backtrace_alloc(VALUE klass)
return obj;
}
static long
backtrace_size(const rb_execution_context_t *ec)
{
@@ -617,9 +627,7 @@ rb_ec_partial_backtrace_object(const rb_execution_context_t *ec, long start_fram
}
}
- size_t memsize = offsetof(rb_backtrace_t, backtrace) + num_frames * sizeof(rb_backtrace_location_t);
- btobj = rb_data_typed_object_zalloc(rb_cBacktrace, memsize, &backtrace_data_type);
- TypedData_Get_Struct(btobj, rb_backtrace_t, &backtrace_data_type, bt);
bt->backtrace_size = 0;
if (num_frames == 0) {
@@ -783,6 +791,40 @@ rb_backtrace_to_location_ary(VALUE self)
return bt->locary;
}
static VALUE
backtrace_dump_data(VALUE self)
{