@@ -23,7 +23,8 @@ options = OpenStruct.new(
2323 'rm_protocol_extensions' => false ,
2424 'catchpoint_deleted_event' => false ,
2525 'value_as_nested_element' => false ,
26- 'attach_mode' => false
26+ 'attach_mode' => false ,
27+ 'cli_debug' => false
2728)
2829
2930opts = OptionParser . new do |opts |
4849 opts . on ( "-l" , "--load-mode" , "load mode (experimental)" ) { options . load_mode = true }
4950 opts . on ( "-d" , "--debug" , "Debug self - prints information for debugging ruby-debug itself" ) do
5051 Debugger . cli_debug = true
52+ options . cli_debug = true
5153 end
5254 opts . on ( "--xml-debug" , "Debug self - sends information <message>s for debugging ruby-debug itself" ) do
5355 Debugger . xml_debug = true
@@ -109,16 +111,20 @@ end
109111if options . dispatcher_port != -1
110112 ENV [ 'IDE_PROCESS_DISPATCHER' ] = options . dispatcher_port . to_s
111113 if RUBY_VERSION < "1.9"
112- $: << File . expand_path ( File . dirname ( __FILE__ ) + "/../lib/" )
114+ lib_path = File . expand_path ( File . dirname ( __FILE__ ) + "/../lib/" )
115+ $: << lib_path unless $:. include? lib_path
113116 require 'ruby-debug-ide/multiprocess'
114117 else
115118 require_relative '../lib/ruby-debug-ide/multiprocess'
116119 end
117120
118121 ENV [ 'DEBUGGER_STORED_RUBYLIB' ] = ENV [ 'RUBYLIB' ]
119- old_opts = ENV [ 'RUBYOPT' ]
120- ENV [ 'RUBYOPT' ] = "-r#{ File . expand_path ( File . dirname ( __FILE__ ) ) } /../lib/ruby-debug-ide/multiprocess/starter"
121- ENV [ 'RUBYOPT' ] += " #{ old_opts } " if old_opts
122+ old_opts = ENV [ 'RUBYOPT' ] || ''
123+ starter = "-r#{ File . expand_path ( File . dirname ( __FILE__ ) ) } /../lib/ruby-debug-ide/multiprocess/starter"
124+ unless old_opts . include? starter
125+ ENV [ 'RUBYOPT' ] = starter
126+ ENV [ 'RUBYOPT' ] += " #{ old_opts } " if old_opts != ''
127+ end
122128 ENV [ 'DEBUGGER_CLI_DEBUG' ] = Debugger . cli_debug . to_s
123129end
124130
@@ -135,13 +141,15 @@ Debugger.catchpoint_deleted_event = options.catchpoint_deleted_event || options.
135141Debugger . value_as_nested_element = options . value_as_nested_element || options . rm_protocol_extensions
136142
137143if options . attach_mode
144+ if Debugger ::FRONT_END == "debase"
145+ Debugger . init_variables
146+ end
147+
138148 Debugger ::MultiProcess ::pre_child ( options )
139149
140- # This will trigger `setup_tracepoints` and `prepare_context` (which is private in debase)
141- # without any actual excessive code execution.
142150 if Debugger ::FRONT_END == "debase"
143- EMPTY_TEMPLATE = File . expand_path ( File . dirname ( __FILE__ ) ) + '/../lib/ruby-debug-ide/attach/empty_file.rb'
144- Debugger . debug_load ( EMPTY_TEMPLATE )
151+ Debugger . setup_tracepoints
152+ Debugger . prepare_context
145153 end
146154else
147155 Debugger . debug_program ( options )
0 commit comments