Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ruby/debug
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.9.0
Choose a base ref
...
head repository: ruby/debug
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.9.1
Choose a head ref
  • 4 commits
  • 4 files changed
  • 1 contributor

Commits on Dec 10, 2023

  1. fix condition of USE_TMP_HOME

    Use tmp home if home can be changed.
    
    fix https://github.com/ruby/actions/actions/runs/7164065566/job/19503611173
    
    ```
        > /home/runner/work/actions/actions/ruby-3.3.0-rc1/lib/irb/history.rb:62:in `initialize': Permission denied @ rb_sysopen - /home/runner/.irb_history (Errno::EACCES)
    ...
    ```
    ko1 committed Dec 10, 2023
    Copy the full SHA
    d4feeae View commit details

Commits on Dec 11, 2023

  1. add verbose mode for debug_code

    show backlog if verbose is true.
    ko1 committed Dec 11, 2023
    Copy the full SHA
    52694a9 View commit details
  2. fix bt on nested break points

    `di_body()` doesn't filter C locations.
    ko1 committed Dec 11, 2023
    Copy the full SHA
    557233a View commit details

Commits on Dec 22, 2023

  1. v1.9.1

    ko1 committed Dec 22, 2023
    Copy the full SHA
    9de0ff4 View commit details
Showing with 46 additions and 15 deletions.
  1. +12 −4 ext/debug/debug.c
  2. +1 −1 lib/debug/version.rb
  3. +24 −3 test/console/nested_break_test.rb
  4. +9 −7 test/support/console_test_case.rb
16 changes: 12 additions & 4 deletions ext/debug/debug.c
Original file line number Diff line number Diff line change
@@ -62,15 +62,23 @@ di_body(const rb_debug_inspector_t *dc, void *ptr)
long i;

for (i=1; i<len; i++) {
VALUE loc, e;
VALUE e;
VALUE iseq = rb_debug_inspector_frame_iseq_get(dc, i);
VALUE loc = RARRAY_AREF(locs, i);
VALUE path;

if (!NIL_P(iseq)) {
VALUE path = iseq_realpath(iseq);
if (!NIL_P(path) && !NIL_P(skip_path_prefix) && str_start_with(path, skip_path_prefix)) continue;
path = iseq_realpath(iseq);
}
else {
// C frame
path = rb_funcall(loc, rb_intern("path"), 0);
}

if (!NIL_P(path) && !NIL_P(skip_path_prefix) && str_start_with(path, skip_path_prefix)) {
continue;
}

loc = RARRAY_AREF(locs, i);
e = di_entry(loc,
rb_debug_inspector_frame_self_get(dc, i),
rb_debug_inspector_frame_binding_get(dc, i),
2 changes: 1 addition & 1 deletion lib/debug/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module DEBUGGER__
VERSION = "1.9.0"
VERSION = "1.9.1"
end
27 changes: 24 additions & 3 deletions test/console/nested_break_test.rb
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ def program
2| b = a + 1 # break
3| end
4| def bar
5| x = 1 # break
5| x = 1 # break
6| end
7| bar
8| x = 2
@@ -35,7 +35,7 @@ def test_nested_break
type 'p a'
assert_line_text(/42/)
type 'c'
assert_line_num 7
assert_line_num 7 # because restored `up` line
end

# pop nested break
@@ -48,6 +48,27 @@ def test_nested_break
end
end

def test_nested_break_bt
debug_code program do
type 'break 2'
type 'break 5'
type 'c'

assert_line_num 5
type 'p foo(42)'

if TracePoint.respond_to? :allow_reentry
# nested break
assert_line_num 2
type 'bt'
assert_no_line_text 'thread_client.rb'
type 'c'
end

type 'c'
end
end

def test_multiple_nested_break
debug_code program do
type 'break 2'
@@ -62,7 +83,7 @@ def test_multiple_nested_break
assert_line_num 2
type 'p foo(142)'
type 'bt'
assert_line_text(/\#9/) # TODO: can be changed
assert_line_text(/\#7\s+<main>/) # TODO: can be changed

type 'c'
assert_line_text(/143/)
16 changes: 9 additions & 7 deletions test/support/console_test_case.rb
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ class ConsoleTestCase < TestCase
PTY.spawn({ "HOME" => pwd }, ruby, '-e', 'puts ENV["HOME"]') do |r,|
home_cannot_change = r.gets.chomp != pwd
end
home_cannot_change
!home_cannot_change
end

class << self
@@ -85,7 +85,7 @@ def create_message fail_msg, test_info
MSG
end

def debug_code(program, remote: true, &test_steps)
def debug_code(program, remote: true, verbose: false, &test_steps)
Timeout.timeout(60) do
prepare_test_environment(program, test_steps) do
if remote && !NO_REMOTE && MULTITHREADED_TEST
@@ -109,17 +109,17 @@ def debug_code(program, remote: true, &test_steps)
th.each {|t| t.join}
end
elsif remote && !NO_REMOTE
debug_code_on_local unless remote == :remote_only
debug_code_on_local verbose: verbose unless remote == :remote_only
debug_code_on_unix_domain_socket
debug_code_on_tcpip
else
debug_code_on_local unless remote == :remote_only
debug_code_on_local verbose: verbose unless remote == :remote_only
end
end
end
end

def run_test_scenario cmd, test_info
def run_test_scenario cmd, test_info, verbose: false
PTY.spawn({ "HOME" => pty_home_dir }, cmd) do |read, write, pid|
test_info.backlog = []
test_info.last_backlog = []
@@ -206,6 +206,8 @@ def run_test_scenario cmd, test_info
kill_safely pid, force: is_assertion_failure
end
end
ensure
pp backlog: test_info.backlog if verbose
end

def assert_program_finish test_info, pid, name
@@ -249,10 +251,10 @@ def manual_debug_code(program)
kill_remote_debuggee remote_info
end

private def debug_code_on_local
private def debug_code_on_local verbose: false
test_info = TestInfo.new(dup_scenario, 'LOCAL', /\(rdbg\)/)
cmd = "#{RDBG_EXECUTABLE} #{temp_file_path}"
run_test_scenario cmd, test_info
run_test_scenario cmd, test_info, verbose: verbose
end

private def debug_code_on_unix_domain_socket