-
Notifications
You must be signed in to change notification settings - Fork 34
don't prepend InstructionSequence#load_iseq if ruby version is < 2.5 #63
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ def monkey_patch_prepend | |
| class << RubyVM::InstructionSequence | ||
| def self.prepend(mod, *smth) | ||
| super | ||
| if mod.to_s.include? 'Bootsnap' && RUBY_VERSION >= "2.5" | ||
| if (mod.to_s.include?('Bootsnap') && RUBY_VERSION >= "2.5") | ||
| prepend InstructionSequenceMixin | ||
| end | ||
| end | ||
|
|
@@ -107,7 +107,7 @@ def load_iseq(path) | |
|
|
||
| def do_set_flags(iseq) | ||
| Debugger.set_trace_flag_to_iseq(iseq) | ||
| iseq.each_child{|child_iseq| do_set_flags(child_iseq)} | ||
| iseq.each_child{|child_iseq| do_set_flags(child_iseq)} if iseq.respond_to? :each_child | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spacing |
||
| end | ||
| end | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| class A | ||
| def foo(a) | ||
| puts a | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| require_relative 'a.rb' | ||
|
|
||
| A.new.foo('hi') |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,9 @@ | |
|
|
||
| # Test of Debugger.debug_load in C extension ruby_debug.so | ||
| class TestDebugLoad < Test::Unit::TestCase | ||
|
|
||
| self.test_order = :defined | ||
|
|
||
| class << self | ||
| def at_line(file, line) | ||
| @@at_line = [File.basename(file), line] | ||
|
|
@@ -41,4 +44,32 @@ def test_debug_load | |
| ensure | ||
| Debugger.stop if Debugger.started? | ||
| end | ||
|
|
||
| module MyBootsnap | ||
| def load_iseq(path) | ||
| iseq = RubyVM::InstructionSequence.compile_file(path) | ||
|
|
||
| Debugger.unset_iseq_flags(iseq) | ||
| iseq | ||
| end | ||
| end | ||
|
|
||
| def test_bootsnap | ||
| @@at_line = nil | ||
| src_dir = File.dirname(__FILE__) | ||
| prog_script = File.join(src_dir, 'example', 'bootsnap', 'bootsnap.rb') | ||
|
|
||
| class << RubyVM::InstructionSequence | ||
| prepend MyBootsnap | ||
| end | ||
| bt = Debugger.debug_load(prog_script, true) | ||
| assert_equal(nil, bt) | ||
| assert_not_nil(@@at_line) | ||
| if RUBY_VERSION >= '2.5' | ||
| assert_equal(['debase.rb', 101], @@at_line) | ||
| end | ||
|
|
||
| assert(Debugger.started?) | ||
| Debugger.stop | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should remove https://stackoverflow.com/questions/11894308/when-to-use-undef-method-and-when-to-use-remove-method |
||
| end | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excess parentheses