Skip to content

DAP: introduce Rdbg Record Inspector #946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
78 changes: 78 additions & 0 deletions lib/debug/dap_custom.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
module DEBUGGER__
module RdbgRecordInspector
module Custom_UI_DAP
def custom_dap_request_rdbgRecordInspector(req)
@q_msg << req
end
end

module Custom_Session
def custom_dap_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 custom_dap_request_event_rdbgRecordInspector(req, result)
@ui.respond req, result
end
end

module Custom_ThreadClient
def custom_dap_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! :protocol_result, :rdbgRecordInspector, req, logs: logs, stoppedIndex: log_index
end
end

::DEBUGGER__::UI_DAP.include Custom_UI_DAP
::DEBUGGER__::Session.include Custom_Session
::DEBUGGER__::ThreadClient.include Custom_ThreadClient
end
end
3 changes: 3 additions & 0 deletions lib/debug/server_dap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ module DEBUGGER__
module UI_DAP
SHOW_PROTOCOL = ENV['DEBUG_DAP_SHOW_PROTOCOL'] == '1' || ENV['RUBY_DEBUG_DAP_SHOW_PROTOCOL'] == '1'

# After loading UI_DAP module, load the custom DAP file.
require_relative 'dap_custom'

def self.setup debug_port
if File.directory? '.vscode'
dir = Dir.pwd
Expand Down