Skip to content

Commit 77f20d1

Browse files
committed
check RubyVM.keep_script_lines
Using version string is not good manner on Ruby. Futhermore, `bps_pending_until_load` is added.
1 parent a1213eb commit 77f20d1

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lib/debug/breakpoint.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ def skip_path?(path)
101101
def generate_label(name)
102102
colorize(" BP - #{name} ", [:YELLOW, :BOLD, :REVERSE])
103103
end
104+
105+
def pending_until_load?
106+
false
107+
end
104108
end
105109

106110
if RUBY_VERSION.to_f <= 2.7
@@ -158,6 +162,10 @@ def initialize path, line, cond: nil, oneshot: false, hook_call: true, command:
158162
@pending = !@iseq
159163
end
160164

165+
def pending_until_load?
166+
@pending
167+
end
168+
161169
def setup
162170
return unless @type
163171

lib/debug/session.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ def initialize
126126
@obj_map = {} # { object_id => ... } for CDP
127127

128128
@tp_thread_begin = nil
129+
130+
has_keep_script_lines = RubyVM.respond_to? :keep_script_lines
131+
129132
@tp_load_script = TracePoint.new(:script_compiled){|tp|
130-
if RUBY_VERSION >= '3.1.0'
131-
# skip on_load if no bps for faster loading
132-
ThreadClient.current.on_load tp.instruction_sequence, tp.eval_script if @bps.any?
133-
else
133+
if !has_keep_script_lines || bps_pending_until_load?
134134
ThreadClient.current.on_load tp.instruction_sequence, tp.eval_script
135135
end
136136
}
@@ -1238,6 +1238,10 @@ def ask msg, default = 'Y'
12381238

12391239
# breakpoint management
12401240

1241+
def bps_pending_until_load?
1242+
@bps.any?{|key, bp| bp.pending_until_load?}
1243+
end
1244+
12411245
def iterate_bps
12421246
deleted_bps = []
12431247
i = 0

0 commit comments

Comments
 (0)