Skip to content

Commit

Permalink
support config.rdbgInitialScripts
Browse files Browse the repository at this point in the history
for future extensions.

And rename:

* `load_rdbgExtension` -> `load_extensions`
* `config.rdbgExtension` -> `config.rdbgExtensions`
  • Loading branch information
Ruby authored and ko1 committed May 8, 2023
1 parent 3becfa1 commit ab2a1ed
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
19 changes: 15 additions & 4 deletions lib/debug/server_dap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,23 @@ def recv_request
retry
end

def load_rdbgExtension req
if exts = req.dig('arguments', 'rdbgExtension')
def load_extensions req
if exts = req.dig('arguments', 'rdbgExtensions')
exts.each{|ext|
require_relative "dap_custom/#{File.basename(ext)}"
}
end

if scripts = req.dig('arguments', 'rdbgInitialScripts')
scripts.each do |script|
begin
eval(script)
rescue Exception => e
puts e.message
puts e.backtrace.inspect
end
end
end
end

def process
Expand All @@ -303,7 +314,7 @@ def process_request req
UI_DAP.local_fs_map_set req.dig('arguments', 'localfs') || req.dig('arguments', 'localfsMap') || true
@nonstop = true

load_rdbgExtension req
load_extensions req

when 'attach'
send_response req
Expand All @@ -315,7 +326,7 @@ def process_request req
@nonstop = false
end

load_rdbgExtension req
load_extensions req

when 'configurationDone'
send_response req
Expand Down
28 changes: 14 additions & 14 deletions test/protocol/rdbgTraceInspctor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class RdbgTraceInspectorTraceTest < ProtocolTestCase
RUBY

def test_defaut_setting
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtension] = ["traceInspector"]
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtensions] = ["traceInspector"]
run_protocol_scenario(PROGRAM, cdp: false) do
req_rdbgTraceInspector_trace_enable
req_add_breakpoint 5
Expand Down Expand Up @@ -43,11 +43,11 @@ def test_defaut_setting
req_terminate_debuggee
end
ensure
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtension
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtensions
end

def test_call_event
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtension] = ["traceInspector"]
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtensions] = ["traceInspector"]
run_protocol_scenario(PROGRAM, cdp: false) do
req_rdbgTraceInspector_trace_enable(events: ['traceCall'])
req_add_breakpoint 5
Expand All @@ -65,11 +65,11 @@ def test_call_event
req_terminate_debuggee
end
ensure
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtension
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtensions
end

def test_return_event
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtension] = ["traceInspector"]
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtensions] = ["traceInspector"]
run_protocol_scenario(PROGRAM, cdp: false) do
req_rdbgTraceInspector_trace_enable(events: ['traceReturn'])
req_add_breakpoint 5
Expand All @@ -88,11 +88,11 @@ def test_return_event
req_terminate_debuggee
end
ensure
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtension
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtensions
end

def test_line_event
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtension] = ["traceInspector"]
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtensions] = ["traceInspector"]
run_protocol_scenario(PROGRAM, cdp: false) do
req_rdbgTraceInspector_trace_enable(events: ['traceLine'])
req_add_breakpoint 5
Expand All @@ -109,11 +109,11 @@ def test_line_event
req_terminate_debuggee
end
ensure
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtension
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtensions
end

def test_restart_trace
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtension] = ["traceInspector"]
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtensions] = ["traceInspector"]
run_protocol_scenario(PROGRAM, cdp: false) do
req_rdbgTraceInspector_trace_enable
req_rdbgTraceInspector_trace_disable
Expand All @@ -132,7 +132,7 @@ def test_restart_trace
req_terminate_debuggee
end
ensure
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtension
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtensions
end
end

Expand All @@ -150,7 +150,7 @@ class RdbgTraceInspectorRecordTest < ProtocolTestCase
RUBY

def test_defaut_setting
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtension] = ["traceInspector"]
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtensions] = ["traceInspector"]
run_protocol_scenario(PROGRAM, cdp: false) do
req_rdbgTraceInspector_record_enable
req_add_breakpoint 5
Expand Down Expand Up @@ -178,11 +178,11 @@ def test_defaut_setting
req_terminate_debuggee
end
ensure
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtension
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtensions
end

def test_restart_trace
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtension] = ["traceInspector"]
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments][:rdbgExtensions] = ["traceInspector"]
run_protocol_scenario(PROGRAM, cdp: false) do
req_rdbgTraceInspector_record_enable
req_rdbgTraceInspector_record_disable
Expand Down Expand Up @@ -212,7 +212,7 @@ def test_restart_trace
req_terminate_debuggee
end
ensure
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtension
DEBUGGER__::INITIALIZE_DAP_MSGS[1][:arguments].delete :rdbgExtensions
end
end
end

0 comments on commit ab2a1ed

Please sign in to comment.