Skip to content

Commit d014117

Browse files
marianosimoneko1
authored andcommitted
🐛 Respect skip_path when returning the backtrace in ServerDAP
1 parent f80ef44 commit d014117

File tree

2 files changed

+64
-1
lines changed

2 files changed

+64
-1
lines changed

lib/debug/server_dap.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -708,9 +708,10 @@ def process_dap args
708708
frames = []
709709
@target_frames.each_with_index do |frame, i|
710710
next if i < start_frame
711-
break if (levels -= 1) < 0
712711

713712
path = frame.realpath || frame.path
713+
next if skip_path?(path)
714+
break if (levels -= 1) < 0
714715
source_name = path ? File.basename(path) : frame.location.to_s
715716

716717
if (path && File.exist?(path)) && (local_path = UI_DAP.remote_to_local_path(path))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../support/protocol_test_case'
4+
5+
module DEBUGGER__
6+
class CallStackWithSkipDAPTest < ProtocolTestCase
7+
def program(path)
8+
<<~RUBY
9+
1| require_relative "#{path}"
10+
2| with_foo do
11+
3| "something"
12+
4| end
13+
RUBY
14+
end
15+
16+
def extra_file
17+
<<~RUBY
18+
def with_foo
19+
yield
20+
end
21+
RUBY
22+
end
23+
24+
def req_stacktrace_file_names
25+
response = send_dap_request('stackTrace', threadId: 1)
26+
stack_frames = response.dig(:body, :stackFrames)
27+
stack_frames.map { |f| f.dig(:source, :name) }
28+
end
29+
30+
def test_it_does_not_skip_a_path
31+
with_extra_tempfile do |extra_file|
32+
run_protocol_scenario(program(extra_file.path), cdp: false) do
33+
req_add_breakpoint 3
34+
req_continue
35+
36+
assert_equal(
37+
[File.basename(temp_file_path), File.basename(extra_file.path), File.basename(temp_file_path)],
38+
req_stacktrace_file_names
39+
)
40+
41+
req_terminate_debuggee
42+
end
43+
end
44+
end
45+
46+
def test_it_skips_a_path
47+
with_extra_tempfile do |extra_file|
48+
ENV['RUBY_DEBUG_SKIP_PATH'] = extra_file.path
49+
run_protocol_scenario(program(extra_file.path), cdp: false) do
50+
req_add_breakpoint 3
51+
req_continue
52+
53+
assert_equal([File.basename(temp_file_path), File.basename(temp_file_path)], req_stacktrace_file_names)
54+
55+
req_terminate_debuggee
56+
end
57+
end
58+
ensure
59+
ENV['RUBY_DEBUG_SKIP_PATH'] = nil
60+
end
61+
end
62+
end

0 commit comments

Comments
 (0)