Skip to content
Merged
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
53 changes: 32 additions & 21 deletions lib/debug/server_dap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ def process_protocol_request req

when 'stackTrace'
tid = req.dig('arguments', 'threadId')

if tc = find_waiting_tc(tid)
request_tc [:dap, :backtrace, req]
else
Expand Down Expand Up @@ -551,9 +552,10 @@ def dap_event args

case type
when :backtrace
result[:stackFrames].each.with_index{|fi, i|
result[:stackFrames].each{|fi|
frame_depth = fi[:id]
fi[:id] = id = @frame_map.size + 1
@frame_map[id] = [req.dig('arguments', 'threadId'), i]
@frame_map[id] = [req.dig('arguments', 'threadId'), frame_depth]
if fi[:source]
if src = fi[:source][:sourceReference]
src_id = @src_map.size + 1
Expand Down Expand Up @@ -620,27 +622,36 @@ def process_dap args

case type
when :backtrace
event! :dap_result, :backtrace, req, {
stackFrames: @target_frames.map{|frame|
path = frame.realpath || frame.path
source_name = path ? File.basename(path) : frame.location.to_s

if !UI_DAP.local_fs || !(path && File.exist?(path))
ref = frame.file_lines
end
start_frame = req.dig('arguments', 'startFrame') || 0
levels = req.dig('arguments', 'levels') || 1_000
frames = []
@target_frames.each_with_index do |frame, i|
next if i < start_frame
break if (levels -= 1) < 0

path = frame.realpath || frame.path
source_name = path ? File.basename(path) : frame.location.to_s

if !UI_DAP.local_fs || !(path && File.exist?(path))
ref = frame.file_lines
end

{
# id: ??? # filled by SESSION
name: frame.name,
line: frame.location.lineno,
column: 1,
source: {
name: source_name,
path: path,
sourceReference: ref,
},
}
frames << {
id: i, # id is refilled by SESSION
name: frame.name,
line: frame.location.lineno,
column: 1,
source: {
name: source_name,
path: path,
sourceReference: ref,
},
}
end

event! :dap_result, :backtrace, req, {
stackFrames: frames,
totalFrames: @target_frames.size,
}
when :scopes
fid = args.shift
Expand Down