diff options
author | Benoit Daloze <[email protected]> | 2024-03-21 20:49:50 +0100 |
---|---|---|
committer | Benoit Daloze <[email protected]> | 2024-03-22 12:30:15 +0100 |
commit | 74995a1a772903c5247886da1105caa27a4afa2d () | |
tree | da51d929377bf6ba863fcc5055a3b5b7de5eb88b /vm_backtrace.c | |
parent | e2a9b87126d59e4766479a7aa12cf7a648f46506 (diff) |
[Feature #20275] Remove extra backtrace entries for rescue and ensure
-rw-r--r-- | vm_backtrace.c | 38 |
1 files changed, 26 insertions, 12 deletions
@@ -571,6 +571,13 @@ is_internal_location(const rb_control_frame_t *cfp) return strncmp(prefix, RSTRING_PTR(file), prefix_len) == 0; } static void bt_update_cfunc_loc(unsigned long cfunc_counter, rb_backtrace_location_t *cfunc_loc, const rb_iseq_t *iseq, const VALUE *pc) { @@ -600,6 +607,7 @@ rb_ec_partial_backtrace_object(const rb_execution_context_t *ec, long start_fram VALUE btobj = Qnil; rb_backtrace_location_t *loc = NULL; unsigned long cfunc_counter = 0; // In the case the thread vm_stack or cfp is not initialized, there is no backtrace. if (end_cfp == NULL) { @@ -641,18 +649,21 @@ rb_ec_partial_backtrace_object(const rb_execution_context_t *ec, long start_fram if (start_frame > 0) { start_frame--; } - else if (!skip_internal || !is_internal_location(cfp)) { - const rb_iseq_t *iseq = cfp->iseq; - const VALUE *pc = cfp->pc; - loc = &bt->backtrace[bt->backtrace_size++]; - RB_OBJ_WRITE(btobj, &loc->cme, rb_vm_frame_method_entry(cfp)); - RB_OBJ_WRITE(btobj, &loc->iseq, iseq); - loc->pc = pc; - bt_update_cfunc_loc(cfunc_counter, loc-1, iseq, pc); - if (do_yield) { - bt_yield_loc(loc - cfunc_counter, cfunc_counter+1, btobj); } - cfunc_counter = 0; } } } @@ -671,9 +682,12 @@ rb_ec_partial_backtrace_object(const rb_execution_context_t *ec, long start_fram } } if (cfunc_counter > 0) { for (; cfp != end_cfp; cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp)) { - if (cfp->iseq && cfp->pc && (!skip_internal || !is_internal_location(cfp))) { bt_update_cfunc_loc(cfunc_counter, loc, cfp->iseq, cfp->pc); RB_OBJ_WRITTEN(btobj, Qundef, cfp->iseq); if (do_yield) { |