Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 50 additions & 25 deletions lib/debug/server_dap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ def show_protocol dir, msg
# nil: no localfs
@local_fs_map = nil

def self.local_fs_map_path path
def self.remote_to_local_path path
case @local_fs_map
when nil
false
nil
when true
path
else # Array
Expand All @@ -92,6 +92,23 @@ def self.local_fs_map_path path
end
end

def self.local_to_remote_path path
case @local_fs_map
when nil
nil
when true
path
else # Array
@local_fs_map.each do |(remote_path_prefix, local_path_prefix)|
if path.start_with? local_path_prefix
return path.sub(local_path_prefix){ remote_path_prefix }
end
end

nil
end
end

def self.local_fs_map_set map
return if @local_fs_map # already setup

Expand Down Expand Up @@ -276,21 +293,29 @@ def process
end

when 'setBreakpoints'
path = args.dig('source', 'path')
SESSION.clear_line_breakpoints path

bps = []
args['breakpoints'].each{|bp|
line = bp['line']
if cond = bp['condition']
bps << SESSION.add_line_breakpoint(path, line, cond: cond)
else
bps << SESSION.add_line_breakpoint(path, line)
end
}
send_response req, breakpoints: (bps.map do |bp| {verified: true,} end)
req_path = args.dig('source', 'path')
path = UI_DAP.local_to_remote_path(req_path)

if path
SESSION.clear_line_breakpoints path

bps = []
args['breakpoints'].each{|bp|
line = bp['line']
if cond = bp['condition']
bps << SESSION.add_line_breakpoint(path, line, cond: cond)
else
bps << SESSION.add_line_breakpoint(path, line)
end
}
send_response req, breakpoints: (bps.map do |bp| {verified: true,} end)
else
send_response req, success: false, message: "#{req_path} is not available"
end

when 'setFunctionBreakpoints'
send_response req

when 'setExceptionBreakpoints'
process_filter = ->(filter_id, cond = nil) {
bp =
Expand All @@ -302,19 +327,19 @@ def process
else
nil
end
{
verified: !bp.nil?,
message: bp.inspect,
{
verified: !bp.nil?,
message: bp.inspect,
}
}
}

SESSION.clear_catch_breakpoints 'Exception', 'RuntimeError'
SESSION.clear_catch_breakpoints 'Exception', 'RuntimeError'

filters = args.fetch('filters').map {|filter_id|
process_filter.call(filter_id)
}
filters = args.fetch('filters').map {|filter_id|
process_filter.call(filter_id)
}

filters += args.fetch('filterOptions', {}).map{|bp_info|
filters += args.fetch('filterOptions', {}).map{|bp_info|
process_filter.call(bp_info['filterId'], bp_info['condition'])
}

Expand Down Expand Up @@ -689,7 +714,7 @@ def process_dap args
path = frame.realpath || frame.path
source_name = path ? File.basename(path) : frame.location.to_s

if (path && File.exist?(path)) && (local_path = UI_DAP.local_fs_map_path(path))
if (path && File.exist?(path)) && (local_path = UI_DAP.remote_to_local_path(path))
# ok
else
ref = frame.file_lines
Expand Down
2 changes: 2 additions & 0 deletions lib/debug/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,8 @@ def clear_line_breakpoints path
clear_breakpoints do |k, bp|
bp.is_a?(LineBreakpoint) && DEBUGGER__.compare_path(k.first, path)
end
rescue Errno::ENOENT
# just ignore
end

def clear_catch_breakpoints *exception_names
Expand Down