Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ruby 2.0.0-p0 compatible patch #9

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions ext/ruby_debug/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
require 'rbconfig'
bindir = RbConfig::CONFIG['bindir']
if bindir =~ %r{(^.*/\.rbenv/versions)/([^/]+)/bin$}
ruby_include = "#{$1}/#{$2}/include/ruby-1.9.1/ruby-#{$2}"
ruby_include = "#{$1}/#{$2}/include/ruby-#{RUBY_VERSION}/ruby-#{$2}"
ARGV << "--with-ruby-include=#{ruby_include}"
elsif bindir =~ %r{(^.*/\.rvm/rubies)/([^/]+)/bin$}
ruby_include = "#{$1}/#{$2}/include/ruby-1.9.1/#{$2}"
ruby_include = "#{$1}/#{$2}/include/ruby-#{RUBY_VERSION}/#{$2}"
ruby_include = "#{ENV['rvm_path']}/src/#{$2}" unless File.exist?(ruby_include)
ARGV << "--with-ruby-include=#{ruby_include}"
end
Expand Down Expand Up @@ -37,6 +37,13 @@
}

$defs << "-O0"
if RUBY_VERSION >= '2.0.0'
# compile on ruby 2.0 , require debugger-ruby_core_source 1.2.0, add INCLUDE path .
DHP1=Gem::Specification.to_a.find {|x| x.name=='debugger-ruby_core_source' and x.version.to_s >= '1.2.0'}.full_gem_path
DHP="#{DHP1}/lib/debugger/ruby_core_source/ruby-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
RUBY20MACRO="-DHAVE_RB_ISEQ_COMPILE_ON_BASE -DVM_DEBUG_BP_CHECK -DHAVE_RB_CONTROL_FRAME_T_EP -DHAVE_RB_ISEQ_T_LOCATION -DHAVE_RB_ISEQ_T_LINE_INFO_SIZE "
$defs << " #{RUBY20MACRO} -I#{DHP} "
end

dir_config("ruby")
if !Debugger::RubyCoreSource.create_makefile_with_core(hdrs, "ruby_debug")
Expand Down
58 changes: 36 additions & 22 deletions ext/ruby_debug/ruby_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <insns_info.inc>
#include "ruby_debug.h"

#define DEBUG_VERSION "0.11.30.pre11"
#define DEBUG_VERSION "0.11.30.pre12"

#define FRAME_N(n) (&debug_context->frames[debug_context->stack_size-(n)-1])
#define GET_FRAME (FRAME_N(check_frame_number(debug_context, frame)))
Expand Down Expand Up @@ -167,7 +167,21 @@ threadptr_data_type(void)
}

#define ruby_threadptr_data_type *threadptr_data_type()
#define ruby_current_thread ((rb_thread_t *)RTYPEDDATA_DATA(rb_thread_current()))

// On ruby 1.9.3-xxx GET_THREAD is a macro, on ruby 2.0.0-p0 is a function. <ruby-ver>/vm_core.h
// CAREFUL: ruby_current_thread, GET_THREAD, rb_thread_set_current_raw
#if GET_THREAD
#define ruby_current_thread ((rb_thread_t *)RTYPEDDATA_DATA(rb_thread_current()))
#define GET_THREAD2 GET_THREAD
#else
#warning "ruby 2.0.0-p0 GET_THREAD is a function."
rb_thread_t *ruby_current_thread;
rb_thread_t *GET_THREAD2(void)
{
ruby_current_thread = ((rb_thread_t *)RTYPEDDATA_DATA(rb_thread_current()));
return GET_THREAD();
}
#endif

static int
is_in_locked(VALUE thread_id)
Expand Down Expand Up @@ -502,16 +516,16 @@ save_call_frame(rb_event_flag_t _event, debug_context_t *debug_context, VALUE se
debug_frame->dead = 0;
debug_frame->self = self;
debug_frame->arg_ary = Qnil;
debug_frame->argc = GET_THREAD()->cfp->iseq->argc;
debug_frame->info.runtime.cfp = GET_THREAD()->cfp;
debug_frame->argc = GET_THREAD2()->cfp->iseq->argc;
debug_frame->info.runtime.cfp = GET_THREAD2()->cfp;
#if VM_DEBUG_BP_CHECK
debug_frame->info.runtime.bp_check = GET_THREAD()->cfp->bp_check;
debug_frame->info.runtime.bp_check = GET_THREAD2()->cfp->bp_check;
#else
debug_frame->info.runtime.bp = GET_THREAD()->cfp->bp;
debug_frame->info.runtime.bp = GET_THREAD2()->cfp->bp;
#endif
debug_frame->info.runtime.block_iseq = GET_THREAD()->cfp->block_iseq;
debug_frame->info.runtime.block_iseq = GET_THREAD2()->cfp->block_iseq;
debug_frame->info.runtime.block_pc = NULL;
debug_frame->info.runtime.last_pc = GET_THREAD()->cfp->pc;
debug_frame->info.runtime.last_pc = GET_THREAD2()->cfp->pc;
if (RTEST(track_frame_args))
copy_scalar_args(debug_frame);
}
Expand Down Expand Up @@ -618,20 +632,20 @@ set_frame_source(rb_event_flag_t event, debug_context_t *debug_context, VALUE se
top_frame = get_top_frame(debug_context);
if(top_frame)
{
top_frame->info.runtime.cfp = GET_THREAD()->cfp;
if (top_frame->info.runtime.block_iseq == GET_THREAD()->cfp->iseq)
top_frame->info.runtime.cfp = GET_THREAD2()->cfp;
if (top_frame->info.runtime.block_iseq == GET_THREAD2()->cfp->iseq)
{
top_frame->info.runtime.block_pc = GET_THREAD()->cfp->pc;
top_frame->info.runtime.block_pc = GET_THREAD2()->cfp->pc;
top_frame->binding = create_binding(self); /* block entered; need to rebind */
}
else if ((top_frame->info.runtime.block_pc != NULL) && (GET_THREAD()->cfp->pc == top_frame->info.runtime.block_pc))
else if ((top_frame->info.runtime.block_pc != NULL) && (GET_THREAD2()->cfp->pc == top_frame->info.runtime.block_pc))
{
top_frame->binding = create_binding(self); /* block re-entered; need to rebind */
}

top_frame->info.runtime.block_iseq = GET_THREAD()->cfp->block_iseq;
top_frame->info.runtime.block_iseq = GET_THREAD2()->cfp->block_iseq;
if (event == RUBY_EVENT_LINE)
top_frame->info.runtime.last_pc = GET_THREAD()->cfp->pc;
top_frame->info.runtime.last_pc = GET_THREAD2()->cfp->pc;
top_frame->self = self;
top_frame->file = file;
top_frame->line = line;
Expand Down Expand Up @@ -708,8 +722,8 @@ create_catch_table(debug_context_t *debug_context, unsigned long cont)
{
struct iseq_catch_table_entry *catch_table = &debug_context->catch_table.tmp_catch_table;

GET_THREAD()->parse_in_eval++;
GET_THREAD()->mild_compile_error++;
GET_THREAD2()->parse_in_eval++;
GET_THREAD2()->mild_compile_error++;
/* compiling with option Qfalse (no options) prevents debug hook calls during this catch routine */
#ifdef HAVE_RB_ISEQ_COMPILE_ON_BASE
catch_table->iseq = rb_iseq_compile_with_option(
Expand All @@ -721,8 +735,8 @@ create_catch_table(debug_context_t *debug_context, unsigned long cont)
catch_table->iseq = rb_iseq_compile_with_option(
rb_str_new_cstr("begin\nend"), rb_str_new_cstr("(exception catcher)"), INT2FIX(1), Qfalse);
#endif
GET_THREAD()->mild_compile_error--;
GET_THREAD()->parse_in_eval--;
GET_THREAD2()->mild_compile_error--;
GET_THREAD2()->parse_in_eval--;

catch_table->type = CATCH_TYPE_RESCUE;
catch_table->start = 0;
Expand Down Expand Up @@ -755,7 +769,7 @@ debug_event_hook(rb_event_flag_t event, VALUE data, VALUE self, ID mid, VALUE kl
char *file = (char*)rb_sourcefile();
int line = rb_sourceline();
int moved = 0;
rb_thread_t *thread = GET_THREAD();
rb_thread_t *thread = GET_THREAD2();
struct rb_iseq_struct *iseq = thread->cfp->iseq;

hook_count++;
Expand Down Expand Up @@ -1007,9 +1021,9 @@ debug_event_hook(rb_event_flag_t event, VALUE data, VALUE self, ID mid, VALUE kl
{
debug_context->stack_size--;
#if VM_DEBUG_BP_CHECK
if (debug_context->frames[debug_context->stack_size].info.runtime.bp_check <= GET_THREAD()->cfp->bp_check)
if (debug_context->frames[debug_context->stack_size].info.runtime.bp_check <= GET_THREAD2()->cfp->bp_check)
#else
if (debug_context->frames[debug_context->stack_size].info.runtime.bp <= GET_THREAD()->cfp->bp)
if (debug_context->frames[debug_context->stack_size].info.runtime.bp <= GET_THREAD2()->cfp->bp)
#endif
break;
}
Expand Down Expand Up @@ -2576,7 +2590,7 @@ context_pause(VALUE self)
return(Qfalse);

GetThreadPtr(context_thread_0(debug_context), th);
if (th == GET_THREAD())
if (th == GET_THREAD2())
return(Qfalse);

debug_context->thread_pause = 1;
Expand Down
2 changes: 1 addition & 1 deletion ruby-debug-base19x.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ EOF
spec.required_ruby_version = '>= 1.9'
spec.date = Time.now
spec.rubyforge_project = 'ruby-debug19'
spec.add_dependency "debugger-ruby_core_source", '~> 1.1.4'
spec.add_dependency "debugger-ruby_core_source", '>= 1.1.4'
spec.add_dependency("rake", ">= 0.8.1")

# rdoc
Expand Down