aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-23 04:12:14 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-08-23 04:12:14 +0000
commit32ce367ff0de181d8a056d593476352ce041bc7e (patch)
treef3ad93ed725d32547b318360d1064a8e2f4b84a7
parenta13b18877dc553a0357b67e7e0eec07e5ab6ac88 (diff)
downloadruby-32ce367ff0de181d8a056d593476352ce041bc7e.tar.gz
check trace flags at loading [Bug #14702]
* iseq.c (iseq_init_trace): at ISeq loading time, we need to check `ruby_vm_event_enabled_flags` to turn on trace instructions. Seprate this checking code from `finish_iseq_build()` and make new function. `iseq_ibf_load()` calls this funcation after loading. * test/ruby/test_iseq.rb: add a test for this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64514 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--compile.c2
-rw-r--r--iseq.c14
-rw-r--r--iseq.h2
-rw-r--r--test/ruby/test_iseq.rb14
4 files changed, 28 insertions, 4 deletions
diff --git a/compile.c b/compile.c
index 2631a97aed..00b9e1d6ae 100644
--- a/compile.c
+++ b/compile.c
@@ -10010,6 +10010,8 @@ iseq_ibf_load(VALUE str)
ibf_load_setup(load, loader_obj, str);
iseq = ibf_load_iseq(load, 0);
+ iseq_init_trace(iseq);
+
RB_GC_GUARD(loader_obj);
return iseq;
}
diff --git a/iseq.c b/iseq.c
index 04b55bba02..cbd216089e 100644
--- a/iseq.c
+++ b/iseq.c
@@ -504,6 +504,15 @@ rb_iseq_insns_info_decode_positions(const struct rb_iseq_constant_body *body)
}
#endif
+void
+iseq_init_trace(rb_iseq_t *iseq)
+{
+ iseq->aux.trace_events = 0;
+ if (ruby_vm_event_enabled_flags & ISEQ_TRACE_EVENTS) {
+ rb_iseq_trace_set(iseq, ruby_vm_event_enabled_flags & ISEQ_TRACE_EVENTS);
+ }
+}
+
static VALUE
finish_iseq_build(rb_iseq_t *iseq)
{
@@ -531,10 +540,7 @@ finish_iseq_build(rb_iseq_t *iseq)
rb_exc_raise(err);
}
- iseq->aux.trace_events = 0;
- if (ruby_vm_event_enabled_flags & ISEQ_TRACE_EVENTS) {
- rb_iseq_trace_set(iseq, ruby_vm_event_enabled_flags & ISEQ_TRACE_EVENTS);
- }
+ iseq_init_trace(iseq);
return Qtrue;
}
diff --git a/iseq.h b/iseq.h
index 851eaeabbc..e889a275fc 100644
--- a/iseq.h
+++ b/iseq.h
@@ -144,6 +144,8 @@ VALUE iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt);
void ibf_load_iseq_complete(rb_iseq_t *iseq);
const rb_iseq_t *iseq_ibf_load(VALUE str);
VALUE iseq_ibf_load_extra_data(VALUE str);
+void iseq_init_trace(rb_iseq_t *iseq);
+
#if VM_INSN_INFO_TABLE_IMPL == 2
unsigned int *rb_iseq_insns_info_decode_positions(const struct rb_iseq_constant_body *body);
#endif
diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb
index 86aad2da69..d193f41c6e 100644
--- a/test/ruby/test_iseq.rb
+++ b/test/ruby/test_iseq.rb
@@ -438,4 +438,18 @@ class TestISeq < Test::Unit::TestCase
end
end;
end
+
+ def test_to_binary_tracepoint
+ filename = "#{File.basename(__FILE__)}_#{__LINE__}"
+ iseq = RubyVM::InstructionSequence.compile("x = 1\n y = 2", filename)
+ iseq_bin = iseq.to_binary
+ ary = []
+ TracePoint.new(:line){|tp|
+ next unless tp.path == filename
+ ary << [tp.path, tp.lineno]
+ }.enable{
+ ISeq.load_from_binary(iseq_bin).eval
+ }
+ assert_equal [[filename, 1], [filename, 2]], ary, '[Bug #14702]'
+ end
end