@@ -22,7 +22,8 @@ options = OpenStruct.new(
2222 'evaluation_timeout' => 10 ,
2323 'rm_protocol_extensions' => false ,
2424 'catchpoint_deleted_event' => false ,
25- 'value_as_nested_element' => false
25+ 'value_as_nested_element' => false ,
26+ 'attach_mode' => false
2627)
2728
2829opts = OptionParser . new do |opts |
5455 opts . on ( "-I" , "--include PATH" , String , "Add PATH to $LOAD_PATH" ) do |path |
5556 $LOAD_PATH. unshift ( path )
5657 end
57-
58+ opts . on ( "--attach-mode" , "Tells that rdebug-ide is working in attach mode" ) do
59+ options . attach_mode = true
60+ end
5861 opts . on ( "--keep-frame-binding" , "Keep frame bindings" ) { options . frame_bind = true }
5962 opts . on ( "--disable-int-handler" , "Disables interrupt signal handler" ) { options . int_handler = false }
6063 opts . on ( "--rubymine-protocol-extensions" , "Enable all RubyMine-specific incompatible protocol extensions" ) do
@@ -89,15 +92,17 @@ rescue StandardError => e
8992 exit ( 1 )
9093end
9194
92- if ARGV . empty?
95+ if ARGV . empty? && ! options . attach_mode
9396 puts opts
9497 puts
9598 puts "Must specify a script to run"
9699 exit ( 1 )
97- end
100+ end
98101
99- # save script name
100- Debugger ::PROG_SCRIPT = ARGV . shift
102+ unless options . attach_mode
103+ # save script name
104+ Debugger ::PROG_SCRIPT = ARGV . shift
105+ end
101106
102107if options . dispatcher_port != -1
103108 ENV [ 'IDE_PROCESS_DISPATCHER' ] = options . dispatcher_port . to_s
@@ -119,13 +124,20 @@ if options.int_handler
119124 # install interruption handler
120125 trap ( 'INT' ) { Debugger . interrupt_last }
121126end
122-
127+
123128# set options
124129Debugger . keep_frame_binding = options . frame_bind
125130Debugger . tracing = options . tracing
126131Debugger . evaluation_timeout = options . evaluation_timeout
127132Debugger . catchpoint_deleted_event = options . catchpoint_deleted_event || options . rm_protocol_extensions
128133Debugger . value_as_nested_element = options . value_as_nested_element || options . rm_protocol_extensions
129134
130- Debugger . debug_program ( options )
135+ if options . attach_mode
136+ Debugger ::MultiProcess ::pre_child ( options )
131137
138+ if Debugger ::FRONT_END == "debase"
139+ Debugger . enable_trace_points
140+ end
141+ else
142+ Debugger . debug_program ( options )
143+ end
0 commit comments