Changeset 6611
- Timestamp:
- 04/28/07 15:57:29 (1 year ago)
- Files:
-
- trunk/actionpack/lib/action_controller/rescue.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/templates/rescues/_request_and_response.erb (modified) (1 diff)
- trunk/actionpack/test/abstract_unit.rb (modified) (1 diff)
- trunk/activerecord/lib/active_record/connection_adapters/openbase_adapter.rb (modified) (1 diff)
- trunk/activerecord/test/abstract_unit.rb (modified) (1 diff)
- trunk/activeresource/test/abstract_unit.rb (modified) (1 diff)
- trunk/activesupport/CHANGELOG (modified) (1 diff)
- trunk/activesupport/lib/active_support/binding_of_caller.rb (deleted)
- trunk/activesupport/lib/active_support/breakpoint.rb (deleted)
- trunk/activesupport/lib/active_support/core_ext/kernel.rb (modified) (1 diff)
- trunk/activesupport/lib/active_support/core_ext/kernel/debugger.rb (added)
- trunk/railties/bin/breakpointer (deleted)
- trunk/railties/CHANGELOG (modified) (1 diff)
- trunk/railties/environments/development.rb (modified) (1 diff)
- trunk/railties/lib/binding_of_caller.rb (deleted)
- trunk/railties/lib/breakpoint_client.rb (deleted)
- trunk/railties/lib/breakpoint.rb (deleted)
- trunk/railties/lib/commands/breakpointer.rb (deleted)
- trunk/railties/lib/commands/servers/base.rb (modified) (1 diff)
- trunk/railties/lib/commands/servers/mongrel.rb (modified) (3 diffs)
- trunk/railties/lib/commands/servers/webrick.rb (modified) (3 diffs)
- trunk/railties/lib/dispatcher.rb (modified) (2 diffs)
- trunk/railties/lib/fcgi_handler.rb (modified) (4 diffs)
- trunk/railties/lib/initializer.rb (modified) (6 diffs)
- trunk/railties/lib/rails_generator/generators/applications/app/app_generator.rb (modified) (1 diff)
- trunk/railties/lib/test_help.rb (modified) (1 diff)
- trunk/railties/Rakefile (modified) (1 diff)
- trunk/railties/README (modified) (3 diffs)
- trunk/railties/test/fcgi_dispatcher_test.rb (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_controller/rescue.rb
r6178 r6611 125 125 perform_action_without_rescue 126 126 rescue Exception => exception # errors from action performed 127 if defined?(Breakpoint) && params["BP-RETRY"]128 msg = exception.backtrace.first129 if md = /^(.+?):(\d+)(?::in `(.+)')?$/.match(msg) then130 origin_file, origin_line = md[1], md[2].to_i131 132 set_trace_func(lambda do |type, file, line, method, context, klass|133 if file == origin_file and line == origin_line then134 set_trace_func(nil)135 params["BP-RETRY"] = false136 137 callstack = caller138 callstack.slice!(0) if callstack.first["rescue.rb"]139 file, line, method = *callstack.first.match(/^(.+?):(\d+)(?::in `(.*?)')?/).captures140 141 message = "Exception at #{file}:#{line}#{" in `#{method}'" if method}." # `Ž ( for ruby-mode)142 143 Breakpoint.handle_breakpoint(context, message, file, line)144 end145 end)146 147 retry148 end149 end150 151 127 rescue_action(exception) 152 128 end trunk/actionpack/lib/action_controller/templates/rescues/_request_and_response.erb
r6180 r6611 4 4 <% end %> 5 5 <pre id="blame_trace" <%='style="display:none"' if hide %>><code><%=h @exception.describe_blame %></code></pre> 6 <% end %>7 8 <% if false %>9 <br /><br />10 <% begin %>11 <%= form_tag(request.request_uri, "method" => request.method) %>12 <input type="hidden" name="BP-RETRY" value="1" />13 14 <% for key, values in params %>15 <% next if key == "BP-RETRY" %>16 <% for value in Array(values) %>17 <input type="hidden" name="<%= key %>" value="<%= value %>" />18 <% end %>19 <% end %>20 21 <input type="submit" value="Retry with Breakpoint" />22 </form>23 <% rescue Exception => e %>24 <%=h "Couldn't render breakpoint link due to #{e.class} #{e.message}" %>25 <% end %>26 6 <% end %> 27 7 trunk/actionpack/test/abstract_unit.rb
r6498 r6611 6 6 require 'test/unit' 7 7 require 'action_controller' 8 require 'breakpoint'9 8 require 'action_controller/test_process' 10 9 trunk/activerecord/lib/active_record/connection_adapters/openbase_adapter.rb
r6044 r6611 199 199 row["notnull"] 200 200 ) 201 # breakpoint() if row["fieldname"] == "content"202 201 end 203 202 columns trunk/activerecord/test/abstract_unit.rb
r6348 r6611 5 5 require 'active_record' 6 6 require 'active_record/fixtures' 7 require 'active_support/binding_of_caller'8 require 'active_support/breakpoint'9 7 require 'connection' 10 8 trunk/activeresource/test/abstract_unit.rb
r6595 r6611 4 4 require 'active_resource' 5 5 require 'active_resource/http_mock' 6 require 'active_support/breakpoint'7 6 8 7 $:.unshift "#{File.dirname(__FILE__)}/../test" trunk/activesupport/CHANGELOG
r6578 r6611 1 1 *SVN* 2 3 * Removed breakpointer and Binding.of_caller in favor of relying on ruby-debug by Kent Sibilev since the breakpointer has been broken since Ruby 1.8.4 and will not be coming back [DHH] 2 4 3 5 * Added parsing of file type in Hash.xml_in so you can easily do file uploads with base64 from an API [DHH] trunk/activesupport/lib/active_support/core_ext/kernel.rb
r3714 r6611 3 3 require File.dirname(__FILE__) + '/kernel/agnostics' 4 4 require File.dirname(__FILE__) + '/kernel/requires' 5 require File.dirname(__FILE__) + '/kernel/debugger' trunk/railties/CHANGELOG
r6580 r6611 1 1 *SVN* 2 3 * Removed breakpointer and Binding.of_caller in favor of relying on ruby-debug by Kent Sibilev since the breakpointer has been broken since Ruby 1.8.4 and will not be coming back [DHH] 4 5 To use the new debugger, start your server with script/server --debugger and insert a call to 'debugger' 6 (instead of 'breakpoint') where you want to jump into the debugger. 7 8 BACKWARDS INCOMPATIBILITY NOTE: You must remove the default line 12 from config/environments/development.rb: 9 10 config.breakpoint_server = true 11 12 This configuration option is no longer available. Rails will fail to start in development mode as long as 13 that's still present. 2 14 3 15 * Resource scaffolding returns the created entity.to_xml. [Jeremy Kemper] trunk/railties/environments/development.rb
r4189 r6611 9 9 config.whiny_nils = true 10 10 11 # Enable the breakpoint server that script/breakpointer connects to12 config.breakpoint_server = true13 14 11 # Show full error reports and disable caching 15 12 config.action_controller.consider_all_requests_local = true trunk/railties/lib/commands/servers/base.rb
r4506 r6611 18 18 tail_thread 19 19 end 20 21 def start_debugger 22 begin 23 require_library_or_gem 'ruby-debug' 24 Debugger.start 25 # Debugger.settings[:autoirb] = true 26 puts "=> Debugger enabled" 27 rescue Exception 28 puts "You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'" 29 exit 30 end 31 end trunk/railties/lib/commands/servers/mongrel.rb
r5654 r6611 13 13 :ip => "0.0.0.0", 14 14 :environment => (ENV['RAILS_ENV'] || "development").dup, 15 :detach => false 15 :detach => false, 16 :debugger => false 16 17 } 17 18 … … 20 21 opts.on("-b", "--binding=ip", String, "Binds Rails to the specified ip.", "Default: 0.0.0.0") { |v| OPTIONS[:ip] = v } 21 22 opts.on("-d", "--daemon", "Make server run as a Daemon.") { OPTIONS[:detach] = true } 23 opts.on("-u", "--debugger", "Enable ruby-debugging for the server.") { OPTIONS[:debugger] = true } 22 24 opts.on("-e", "--environment=name", String, 23 25 "Specifies the environment to run this server under (test/development/production).", … … 47 49 RAILS_ENV.replace(OPTIONS[:environment]) if defined?(RAILS_ENV) 48 50 51 start_debugger if OPTIONS[:debugger] 52 49 53 require 'initializer' 50 54 Rails::Initializer.run(:initialize_logger) trunk/railties/lib/commands/servers/webrick.rb
r4502 r6611 3 3 4 4 OPTIONS = { 5 :port => 3000, 6 :ip => "0.0.0.0", 7 :environment => (ENV['RAILS_ENV'] || "development").dup, 8 :server_root => File.expand_path(RAILS_ROOT + "/public/"), 9 :server_type => WEBrick::SimpleServer, 10 :charset => "UTF-8", 11 :mime_types => WEBrick::HTTPUtils::DefaultMimeTypes 5 :port => 3000, 6 :ip => "0.0.0.0", 7 :environment => (ENV['RAILS_ENV'] || "development").dup, 8 :server_root => File.expand_path(RAILS_ROOT + "/public/"), 9 :server_type => WEBrick::SimpleServer, 10 :charset => "UTF-8", 11 :mime_types => WEBrick::HTTPUtils::DefaultMimeTypes, 12 :debugger => false 13 12 14 } 13 15 … … 35 37 ) { OPTIONS[:server_type] = WEBrick::Daemon } 36 38 39 opts.on("-u", "--debugger", "Enable ruby-debugging for the server.") { OPTIONS[:debugger] = true } 40 37 41 opts.on("-c", "--charset=charset", String, 38 42 "Set default charset for output.", … … 47 51 end 48 52 53 start_debugger if OPTIONS[:debugger] 54 49 55 ENV["RAILS_ENV"] = OPTIONS[:environment] 50 56 RAILS_ENV.replace(OPTIONS[:environment]) if defined?(RAILS_ENV) trunk/railties/lib/dispatcher.rb
r6307 r6611 105 105 end 106 106 107 prepare_breakpoint108 107 require_dependency 'application' unless Object.const_defined?(:ApplicationController) 109 108 ActiveRecord::Base.verify_active_connections! if defined?(ActiveRecord) … … 113 112 def reset_after_dispatch 114 113 reset_application! if Dependencies.load? 115 Breakpoint.deactivate_drb if defined?(BREAKPOINT_SERVER_PORT)116 end117 118 def prepare_breakpoint119 return unless defined?(BREAKPOINT_SERVER_PORT)120 require 'breakpoint'121 Breakpoint.activate_drb("druby://localhost:#{BREAKPOINT_SERVER_PORT}", nil, !defined?(FastCGI))122 true123 rescue124 nil125 114 end 126 115 trunk/railties/lib/fcgi_handler.rb
r5485 r6611 10 10 'TERM' => :exit_now, 11 11 'USR1' => :exit, 12 'USR2' => :restart, 13 'SIGTRAP' => :breakpoint 12 'USR2' => :restart 14 13 } 15 14 GLOBAL_SIGNALS = SIGNALS.keys - %w(USR1) … … 132 131 end 133 132 134 def breakpoint_handler(signal)135 dispatcher_log :info, "asked to breakpoint ASAP"136 @when_ready = :breakpoint137 end138 139 133 def process_each_request!(provider) 140 134 cgi = nil … … 153 147 close_connection(cgi) 154 148 break 155 when :breakpoint156 close_connection(cgi)157 breakpoint!158 149 end 159 150 … … 199 190 end 200 191 201 def breakpoint!202 require 'breakpoint'203 port = defined?(BREAKPOINT_SERVER_PORT) ? BREAKPOINT_SERVER_PORT : 42531204 Breakpoint.activate_drb("druby://localhost:#{port}", nil, !defined?(FastCGI))205 dispatcher_log :info, "breakpointing"206 breakpoint207 @when_ready = nil208 end209 210 192 def run_gc! 211 193 @gc_request_countdown = gc_request_period trunk/railties/lib/initializer.rb
r6550 r6611 70 70 # * #initialize_framework_views 71 71 # * #initialize_dependency_mechanism 72 # * #initialize_breakpoints73 72 # * #initialize_whiny_nils 74 73 # * #initialize_framework_settings … … 99 98 initialize_framework_views 100 99 initialize_dependency_mechanism 101 initialize_breakpoints102 100 initialize_whiny_nils 103 101 initialize_temporary_directories … … 299 297 end 300 298 301 # Sets the +BREAKPOINT_SERVER_PORT+ if Configuration#breakpoint_server302 # is true.303 def initialize_breakpoints304 silence_warnings { Object.const_set("BREAKPOINT_SERVER_PORT", 42531) if configuration.breakpoint_server }305 end306 307 299 # Loads support for "whiny nil" (noisy warnings when methods are invoked 308 300 # on +nil+ values) if Configuration#whiny_nils is true. … … 386 378 attr_accessor :active_resource 387 379 388 # Whether or not to use the breakpoint server (boolean)389 attr_accessor :breakpoint_server390 391 380 # Whether or not classes should be cached (set to false if you want 392 381 # application classes to be reloaded on each request) … … 475 464 self.controller_paths = default_controller_paths 476 465 self.cache_classes = default_cache_classes 477 self.breakpoint_server = default_breakpoint_server478 466 self.whiny_nils = default_whiny_nils 479 467 self.plugins = default_plugins … … 635 623 end 636 624 637 def default_breakpoint_server638 false639 end640 641 625 def default_whiny_nils 642 626 false trunk/railties/lib/rails_generator/generators/applications/app/app_generator.rb
r6429 r6611 68 68 69 69 # Scripts 70 %w( about breakpointerconsole destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/inspector runner server plugin ).each do |file|70 %w( about console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/inspector runner server plugin ).each do |file| 71 71 m.file "bin/#{file}", "script/#{file}", script_options 72 72 end trunk/railties/lib/test_help.rb
r6575 r6611 9 9 require 'action_controller/test_process' 10 10 require 'action_controller/integration' 11 require 'breakpoint'12 11 13 12 Test::Unit::TestCase.fixture_path = RAILS_ROOT + "/test/fixtures/" trunk/railties/Rakefile
r6552 r6611 70 70 javascripts/prototype.js javascripts/application.js 71 71 javascripts/effects.js javascripts/dragdrop.js javascripts/controls.js ) 72 BIN_FILES = %w( about breakpointerconsole destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/inspector runner server plugin )72 BIN_FILES = %w( about console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/inspector runner server plugin ) 73 73 74 74 VENDOR_LIBS = %w( actionpack activerecord actionmailer activesupport actionwebservice railties ) trunk/railties/README
r6180 r6611 70 70 71 71 72 == Breakpoints72 == Debugger 73 73 74 Breakpoint support is available through the script/breakpointer client. This 75 means that you can break out of execution at any point in the code, investigate74 Debugger support is available through the debugger command when you start your Mongrel or 75 Webrick server with --debugger. This means that you can break out of execution at any point in the code, investigate 76 76 and change the model, AND then resume execution! Example: 77 77 … … 79 79 def index 80 80 @posts = Post.find(:all) 81 breakpoint "Breaking out from the list"81 debugger 82 82 end 83 83 end 84 84 85 85 So the controller will accept the action, run the first line, then present you 86 with a IRB prompt in the breakpointer window. Here you can do things like: 87 88 Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint' 86 with a IRB prompt in the server window. Here you can do things like: 89 87 90 88 >> @posts.inspect 91 89 => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>, 92 90 #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]" 93 >> @posts.first.title = "hello from a breakpoint"94 => "hello from a breakpoint"91 >> @posts.first.title = "hello from a debugger" 92 => "hello from a debugger" 95 93 96 94 ...and even better is that you can examine how your runtime objects actually work: … … 101 99 Display all 152 possibilities? (y or n) 102 100 103 Finally, when you're ready to resume execution, you press CTRL-D101 Finally, when you're ready to resume execution, you enter "cont" 104 102 105 103 trunk/railties/test/fcgi_dispatcher_test.rb
r5118 r6611 13 13 require 'fcgi_handler' 14 14 require 'routes' 15 require 'stubbed_breakpoint'16 15 require 'stubbed_kernel' 17 16 … … 36 35 end 37 36 38 def breakpoint39 end40 41 37 alias_method :old_run_gc!, :run_gc! 42 38 def run_gc! … … 72 68 end 73 69 74 def test_process_breakpoint75 @handler.stubs(:when_ready).returns(:breakpoint)76 77 @handler.expects(:close_connection)78 @handler.expects(:breakpoint!)79 @handler.process!80 end81 82 70 def test_process_with_system_exit_exception 83 71 @handler.stubs(:process_request).raises(SystemExit) … … 92 80 @handler.send(:restart_handler, nil) 93 81 assert_equal :restart, @handler.when_ready 94 end95 96 def test_breakpoint_handler97 @handler.expects(:dispatcher_log).with(:info, "asked to breakpoint ASAP")98 99 @handler.send(:breakpoint_handler, nil)100 assert_equal :breakpoint, @handler.when_ready101 82 end 102 83 … … 144 125 end 145 126 146 def test_breakpoint!147 @handler.expects(:require).with('breakpoint')148 Breakpoint.expects(:activate_drb)149 @handler.expects(:breakpoint)150 @handler.expects(:dispatcher_log).with(:info, "breakpointing")151 @handler.send(:breakpoint!)152 assert_nil @handler.when_ready153 end154 155 127 def test_uninterrupted_processing 156 128 @handler.process!