From 1159908ecd2887047fb6bc15240141d457d497fc Mon Sep 17 00:00:00 2001 From: Charles Oliver Nutter Date: Thu, 23 Sep 2021 14:42:09 -0500 Subject: [PATCH 1/4] Mask features only available on CRuby * Continuations for the restart command require the 'continuation' library and full 'callcc' support. * ISeq support is only available on CRuby --- lib/debug.rb | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/debug.rb b/lib/debug.rb index 34d7d2740..0031ce4eb 100644 --- a/lib/debug.rb +++ b/lib/debug.rb @@ -3,8 +3,6 @@ # Copyright (C) 2000 Information-technology Promotion Agency, Japan # Copyright (C) 2000-2003 NAKAMURA, Hiroshi -require 'continuation' - if $SAFE > 0 STDERR.print "-r debug.rb is not available in safe mode\n" exit 1 @@ -183,6 +181,9 @@ def Tracer.trace_func(*vars) class DEBUGGER__ MUTEX = Thread::Mutex.new # :nodoc: + CONTINUATIONS_SUPPORTED = RUBY_ENGINE == 'ruby' + + require 'continuation' if CONTINUATIONS_SUPPORTED class Context # :nodoc: DEBUG_LAST_CMD = [] @@ -380,8 +381,10 @@ def thnum def debug_command(file, line, id, binding) MUTEX.lock - unless defined?($debugger_restart) and $debugger_restart - callcc{|c| $debugger_restart = c} + if CONTINUATIONS_SUPPORTED + unless defined?($debugger_restart) and $debugger_restart + callcc{|c| $debugger_restart = c} + end end set_last_thread(Thread.current) frame_pos = 0 @@ -653,7 +656,11 @@ def debug_command(file, line, id, binding) stdout.printf "%s\n", debug_eval($', binding).inspect when /^\s*r(?:estart)?$/ - $debugger_restart.call + if CONTINUATIONS_SUPPORTED + $debugger_restart.call + else + stdout.print "Restart requires continuations.\n" + end when /^\s*h(?:elp)?$/ debug_print_help() @@ -1102,9 +1109,11 @@ def debug_thread_info(input, binding) stdout.printf "Debug.rb\n" stdout.printf "Emacs support available.\n\n" - RubyVM::InstructionSequence.compile_option = { - trace_instruction: true - } + if defined?(RubyVM::InstructionSequence) + RubyVM::InstructionSequence.compile_option = { + trace_instruction: true + } + end set_trace_func proc { |event, file, line, id, binding, klass, *rest| DEBUGGER__.context.trace_func event, file, line, id, binding, klass } From f4fc7f4a0b10d66d7f5b6c9d3bd0809d3c6b4a0c Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Mon, 25 Nov 2019 21:25:53 -0300 Subject: [PATCH 2/4] debug.rb: expand filenames in breakpoints When debugging some local code, specifying a breakpoint to a local filename does not work, i.e. break lib/foo.rb:10 Expanding the filename makes it work. FWIW byebug has the same behavior. --- lib/debug.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/debug.rb b/lib/debug.rb index 0031ce4eb..8138adfeb 100644 --- a/lib/debug.rb +++ b/lib/debug.rb @@ -435,7 +435,7 @@ def debug_command(file, line, id, binding) pos = $2 if $1 klass = debug_silent_eval($1, binding) - file = $1 + file = File.expand_path($1) end if pos =~ /^\d+$/ pname = pos From 7262e1834ba3eacc108e39d6e7ce64f53641bf33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Quang=20Minh?= Date: Thu, 6 Aug 2020 09:56:24 +0700 Subject: [PATCH 3/4] [Feature #16513] TracePoint#inspect returns "... file:line" (#3391) * Fix debug documents to match Thread#to_s change (Feature #16412 ticket) * TracePoint#inspect returns "... file:line" (Feature #16513) * Guard older version of Ruby in Tracepoint inspection tests * Focus on current thread only when running TracePoint inspection test --- lib/debug.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/debug.rb b/lib/debug.rb index 8138adfeb..bf63ccf34 100644 --- a/lib/debug.rb +++ b/lib/debug.rb @@ -1024,8 +1024,8 @@ def thread_list(num) # # (rdb:1) DEBUGGER__.thread_list_all # +1 # debug_me.rb.rb:3 - # 2 # - # 3 # + # 2 # + # 3 # # [1, 2, 3] # # Your current thread is indicated by a + @@ -1034,8 +1034,8 @@ def thread_list(num) # # (rdb:1) th l # +1 # debug_me.rb:3 - # 2 # debug_me.rb:3 - # 3 # debug_me.rb:3 + # 2 # debug_me.rb:3 + # 3 # debug_me.rb:3 # # See DEBUGGER__ for more usage. From 622a07bf0f8820e899d1ecc9b5dadd636f357b52 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 11 Nov 2021 16:27:40 +0900 Subject: [PATCH 4/4] Bump debug version to 0.2.1 --- debug.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debug.gemspec b/debug.gemspec index ccd7b7769..0c414d482 100644 --- a/debug.gemspec +++ b/debug.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |spec| spec.name = "debug" - spec.version = "0.2.0" + spec.version = "0.2.1" spec.authors = ["Yukihiro Matsumoto"] spec.email = ["matz@ruby-lang.org"]