Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Commit

Permalink
use struct iseq_line_info_entry.
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Sep 15, 2011
1 parent f4b590a commit cbec7ca
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions ext/ruby_debug/extconf.rb
Expand Up @@ -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(<<SRC)
#include <ruby.h>
Expand Down
12 changes: 7 additions & 5 deletions ext/ruby_debug/ruby_debug.c
Expand Up @@ -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("#$!");
Expand All @@ -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;
Expand Down Expand Up @@ -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 */
Expand All @@ -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 */
}
Expand Down
6 changes: 6 additions & 0 deletions ext/ruby_debug/ruby_debug.h
Expand Up @@ -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;
Expand Down

0 comments on commit cbec7ca

Please sign in to comment.