diff --git a/ext/ruby_debug/extconf.rb b/ext/ruby_debug/extconf.rb index b39b01c..7cd843f 100644 --- a/ext/ruby_debug/extconf.rb +++ b/ext/ruby_debug/extconf.rb @@ -7,12 +7,16 @@ end hdrs = proc { + iseqs = %w[vm_core.h iseq.h] begin have_struct_member("rb_method_entry_t", "called_id", "method.h") or have_struct_member("rb_control_frame_t", "method_id", "method.h") end and have_header("vm_core.h") and have_header("iseq.h") and have_header("insns.inc") and have_header("insns_info.inc") and have_header("eval_intern.h") or break + have_type("struct iseq_line_info_entry", iseqs) or + have_type("struct iseq_insn_info_entry", iseqs) or + break if checking_for(checking_message("if rb_iseq_compile_with_option was added an argument filepath")) do try_compile(< diff --git a/ext/ruby_debug/ruby_debug.c b/ext/ruby_debug/ruby_debug.c index 67bf78c..f125325 100644 --- a/ext/ruby_debug/ruby_debug.c +++ b/ext/ruby_debug/ruby_debug.c @@ -489,8 +489,8 @@ create_exception_catchall(debug_context_t *debug_context) debug_context->catch_iseq.iseq[6] = 0; debug_context->catch_iseq.iseq_size = sizeof(debug_context->iseq_insn) / sizeof(VALUE); debug_context->catch_iseq.mark_ary = rb_ary_new(); - debug_context->catch_iseq.insn_info_table = &debug_context->catch_info_entry; - debug_context->catch_iseq.insn_info_size = 1; + debug_context->catch_iseq.line_info_table = &debug_context->catch_info_entry; + debug_context->catch_iseq.line_info_size = 1; debug_context->catch_iseq.local_size = 1; debug_context->catch_iseq.local_table = &debug_context->local_table; debug_context->catch_iseq.local_table[0] = rb_intern("#$!"); @@ -503,7 +503,9 @@ create_exception_catchall(debug_context_t *debug_context) debug_context->catch_iseq.cref_stack = &debug_context->catch_cref_stack; debug_context->catch_info_entry.position = 0; debug_context->catch_info_entry.line_no = 1; +#if defined HAVE_TYPE_STRUCT_ISEQ_INSN_INFO_ENTRY debug_context->catch_info_entry.sp = 0; +#endif debug_context->catch_cref_stack.flags = 1052; entry->type = CATCH_TYPE_RESCUE; @@ -2261,9 +2263,9 @@ context_jump(VALUE self, VALUE line, VALUE file) { if ((cfp->iseq != NULL) && (rb_str_cmp(file, cfp->iseq->filename) == 0)) { - for (i = 0; i < cfp->iseq->insn_info_size; i++) + for (i = 0; i < cfp->iseq->line_info_size; i++) { - if (cfp->iseq->insn_info_table[i].line_no != line) + if (cfp->iseq->line_info_table[i].line_no != line) continue; /* hijack the currently running code so that we can change the frame PC */ @@ -2274,7 +2276,7 @@ context_jump(VALUE self, VALUE line, VALUE file) debug_context->jump_cfp = cfp; debug_context->jump_pc = - cfp->iseq->iseq_encoded + cfp->iseq->insn_info_table[i].position; + cfp->iseq->iseq_encoded + cfp->iseq->line_info_table[i].position; return(INT2FIX(0)); /* success */ } diff --git a/ext/ruby_debug/ruby_debug.h b/ext/ruby_debug/ruby_debug.h index 2b34c63..7f18725 100644 --- a/ext/ruby_debug/ruby_debug.h +++ b/ext/ruby_debug/ruby_debug.h @@ -66,7 +66,13 @@ typedef struct { // struct RData catch_rdata; struct rb_iseq_struct catch_iseq; +#if defined HAVE_TYPE_STRUCT_ISEQ_INSN_INFO_ENTRY struct iseq_insn_info_entry catch_info_entry; +# define line_info_size insn_info_size +# define line_info_table insn_info_table +#elif defined HAVE_TYPE_STRUCT_ISEQ_LINE_INFO_ENTRY + struct iseq_line_info_entry catch_info_entry; +#endif struct RNode catch_cref_stack; VALUE iseq_insn[7]; VALUE local_table;