66 require 'ruby-debug-base'
77else
88 require 'debase'
9- end
9+ end
1010
1111require 'ruby-debug-ide/version'
1212require 'ruby-debug-ide/xml_printer'
1313require 'ruby-debug-ide/ide_processor'
1414require 'ruby-debug-ide/event_processor'
1515
1616module Debugger
17-
17+
1818 class << self
1919 # Prints to the stderr using printf(*args) if debug logging flag (-d) is on.
2020 def print_debug ( *args )
@@ -25,7 +25,7 @@ def print_debug(*args)
2525 $stderr. flush
2626 end
2727 end
28-
28+
2929 def cleanup_backtrace ( backtrace )
3030 cleared = [ ]
3131 return cleared unless backtrace
@@ -40,12 +40,12 @@ def cleanup_backtrace(backtrace)
4040 end
4141 cleared
4242 end
43-
43+
4444 attr_accessor :cli_debug , :xml_debug
4545 attr_accessor :control_thread
4646 attr_reader :interface
4747
48-
48+
4949 #
5050 # Interrupts the last debugged thread
5151 #
@@ -69,10 +69,10 @@ def prepare_debugger(options)
6969 start_server ( options . host , options . port )
7070
7171 raise "Control thread did not start (#{ @control_thread } }" unless @control_thread && @control_thread . alive?
72-
72+
7373 @mutex = Mutex . new
7474 @proceed = ConditionVariable . new
75-
75+
7676 # wait for 'start' command
7777 @mutex . synchronize do
7878 @proceed . wait ( @mutex )
@@ -89,14 +89,14 @@ def debug_program(options)
8989 $stderr. print Debugger . cleanup_backtrace ( bt . backtrace ) . map { |l | "\t #{ l } " } . join ( "\n " ) , "\n "
9090 end
9191 end
92-
92+
9393 def run_prog_script
9494 return unless @mutex
9595 @mutex . synchronize do
9696 @proceed . signal
9797 end
9898 end
99-
99+
100100 def start_control ( host , port )
101101 raise "Debugger is not started" unless started?
102102 return if @control_thread
@@ -110,11 +110,12 @@ def start_control(host, port)
110110 $stderr. printf "Fast Debugger (ruby-debug-ide #{ IDE_VERSION } , #{ gem_name } #{ VERSION } ) listens on #{ host } :#{ port } \n "
111111 server = TCPServer . new ( host , port )
112112 while ( session = server . accept )
113- $stderr. puts "Connected from #{ session . addr [ 2 ] } " if Debugger . cli_debug
113+ $stderr. puts "Connected from #{ session . peeraddr [ 2 ] } " if Debugger . cli_debug
114114 dispatcher = ENV [ 'IDE_PROCESS_DISPATCHER' ]
115115 if ( dispatcher )
116- ENV [ 'IDE_PROCESS_DISPATCHER' ] = "#{ session . addr [ 2 ] } :#{ dispatcher } " unless dispatcher . include? ( ":" )
117- end
116+ ENV [ 'IDE_PROCESS_DISPATCHER' ] = "#{ session . peeraddr [ 2 ] } :#{ dispatcher } " unless dispatcher . include? ( ":" )
117+ ENV [ 'DEBUGGER_HOST' ] = host
118+ end
118119 begin
119120 @interface = RemoteInterface . new ( session )
120121 self . handler = EventProcessor . new ( interface )
@@ -132,9 +133,9 @@ def start_control(host, port)
132133 end
133134 end
134135 end
135-
136+
136137 end
137-
138+
138139 class Exception # :nodoc:
139140 attr_reader :__debug_file , :__debug_line , :__debug_binding , :__debug_context
140141 end
0 commit comments