Skip to content

Commit

Permalink
DAP: introduce Rdbg Record Inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
ono-max authored and ko1 committed Mar 22, 2023
1 parent ec4e2f7 commit e29faba
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions lib/debug/server_dap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,10 @@ def process
send_event :terminated unless @sock.closed?
end

def request_rdbgRecordInspector req
@q_msg << req
end

## called by the SESSION thread

def respond req, res
Expand Down Expand Up @@ -664,6 +668,43 @@ def process_protocol_request req
end
end

def request_rdbgRecordInspector req
cmd = req.dig('arguments', 'command')
case cmd
when 'enable'
request_tc [:record, :on]
@ui.respond req, {}
when 'disable'
request_tc [:record, :off]
@ui.respond req, {}
when 'step'
tid = req.dig('arguments', 'threadId')
count = req.dig('arguments', 'count')
if tc = find_waiting_tc(tid)
tc << [:step, :in, count]
else
fail_response req
end
when 'stepBack'
tid = req.dig('arguments', 'threadId')
count = req.dig('arguments', 'count')
if tc = find_waiting_tc(tid)
tc << [:step, :back, count]
else
fail_response req
end
when 'collect'
tid = req.dig('arguments', 'threadId')
if tc = find_waiting_tc(tid)
tc << [:dap, :rdbgRecordInspector, req]
else
fail_response req
end
else
raise "Unknown command #{cmd}"
end
end

def dap_event args
# puts({dap_event: args}.inspect)
type, req, result = args
Expand Down Expand Up @@ -711,6 +752,10 @@ def dap_event args
end
when :completions
@ui.respond req, result

# custom request
when :rdbgRecordInspector
@ui.respond req, result
else
raise "unsupported: #{args.inspect}"
end
Expand Down Expand Up @@ -981,6 +1026,26 @@ def process_dap args
end
end

def request_rdbgRecordInspector req
logs = []
log_index = nil
unless @recorder.nil?
log_index = @recorder.log_index
@recorder.log.each{|frames|
crt_frame = frames[0]
logs << {
name: crt_frame.name,
location: {
path: crt_frame.location.path,
line: crt_frame.location.lineno,
},
depth: crt_frame.frame_depth
}
}
end
event! :dap_result, :rdbgRecordInspector, req, logs: logs, stoppedIndex: log_index
end

def search_const b, expr
cs = expr.delete_prefix('::').split('::')
[Object, *b.eval('::Module.nesting')].reverse_each{|mod|
Expand Down

0 comments on commit e29faba

Please sign in to comment.