Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6611

Show
Ignore:
Timestamp:
04/28/07 15:57:29 (2 years ago)
Author:
david
Message:

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]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/rescue.rb

    r6178 r6611  
    125125        perform_action_without_rescue 
    126126      rescue Exception => exception  # errors from action performed 
    127         if defined?(Breakpoint) && params["BP-RETRY"] 
    128           msg = exception.backtrace.first 
    129           if md = /^(.+?):(\d+)(?::in `(.+)')?$/.match(msg) then 
    130             origin_file, origin_line = md[1], md[2].to_i 
    131  
    132             set_trace_func(lambda do |type, file, line, method, context, klass| 
    133               if file == origin_file and line == origin_line then 
    134                 set_trace_func(nil) 
    135                 params["BP-RETRY"] = false 
    136  
    137                 callstack = caller 
    138                 callstack.slice!(0) if callstack.first["rescue.rb"] 
    139                 file, line, method = *callstack.first.match(/^(.+?):(\d+)(?::in `(.*?)')?/).captures 
    140  
    141                 message = "Exception at #{file}:#{line}#{" in `#{method}'" if method}." # `Ž ( for ruby-mode) 
    142  
    143                 Breakpoint.handle_breakpoint(context, message, file, line) 
    144               end 
    145             end) 
    146  
    147             retry 
    148           end 
    149         end 
    150  
    151127        rescue_action(exception) 
    152128      end 
  • trunk/actionpack/lib/action_controller/templates/rescues/_request_and_response.erb

    r6180 r6611  
    44  <% end %> 
    55  <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 %> 
    266<% end %> 
    277 
  • trunk/actionpack/test/abstract_unit.rb

    r6498 r6611  
    66require 'test/unit' 
    77require 'action_controller' 
    8 require 'breakpoint' 
    98require 'action_controller/test_process' 
    109 
  • trunk/activerecord/lib/active_record/connection_adapters/openbase_adapter.rb

    r6044 r6611  
    199199                                row["notnull"] 
    200200                                ) 
    201     #      breakpoint() if row["fieldname"] == "content" 
    202201        end 
    203202        columns 
  • trunk/activerecord/test/abstract_unit.rb

    r6348 r6611  
    55require 'active_record' 
    66require 'active_record/fixtures' 
    7 require 'active_support/binding_of_caller' 
    8 require 'active_support/breakpoint' 
    97require 'connection' 
    108 
  • trunk/activeresource/test/abstract_unit.rb

    r6595 r6611  
    44require 'active_resource' 
    55require 'active_resource/http_mock' 
    6 require 'active_support/breakpoint' 
    76 
    87$:.unshift "#{File.dirname(__FILE__)}/../test" 
  • trunk/activesupport/CHANGELOG

    r6578 r6611  
    11*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] 
    24 
    35* 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  
    33require File.dirname(__FILE__) + '/kernel/agnostics' 
    44require File.dirname(__FILE__) + '/kernel/requires' 
     5require File.dirname(__FILE__) + '/kernel/debugger' 
  • trunk/railties/CHANGELOG

    r6580 r6611  
    11*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. 
    214 
    315* Resource scaffolding returns the created entity.to_xml.  [Jeremy Kemper] 
  • trunk/railties/environments/development.rb

    r4189 r6611  
    99config.whiny_nils = true 
    1010 
    11 # Enable the breakpoint server that script/breakpointer connects to 
    12 config.breakpoint_server = true 
    13  
    1411# Show full error reports and disable caching 
    1512config.action_controller.consider_all_requests_local = true 
  • trunk/railties/lib/commands/servers/base.rb

    r4506 r6611  
    1818  tail_thread 
    1919end 
     20 
     21def 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 
     31end 
  • trunk/railties/lib/commands/servers/mongrel.rb

    r5654 r6611  
    1313  :ip          => "0.0.0.0", 
    1414  :environment => (ENV['RAILS_ENV'] || "development").dup, 
    15   :detach      => false 
     15  :detach      => false, 
     16  :debugger    => false 
    1617} 
    1718 
     
    2021  opts.on("-b", "--binding=ip", String, "Binds Rails to the specified ip.", "Default: 0.0.0.0") { |v| OPTIONS[:ip] = v } 
    2122  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 } 
    2224  opts.on("-e", "--environment=name", String, 
    2325          "Specifies the environment to run this server under (test/development/production).", 
     
    4749  RAILS_ENV.replace(OPTIONS[:environment]) if defined?(RAILS_ENV) 
    4850 
     51  start_debugger if OPTIONS[:debugger] 
     52 
    4953  require 'initializer' 
    5054  Rails::Initializer.run(:initialize_logger) 
  • trunk/railties/lib/commands/servers/webrick.rb

    r4502 r6611  
    33 
    44OPTIONS = { 
    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   
    1214} 
    1315 
     
    3537          ) { OPTIONS[:server_type] = WEBrick::Daemon } 
    3638 
     39  opts.on("-u", "--debugger", "Enable ruby-debugging for the server.") { OPTIONS[:debugger] = true } 
     40 
    3741  opts.on("-c", "--charset=charset", String, 
    3842          "Set default charset for output.", 
     
    4751end 
    4852 
     53start_debugger if OPTIONS[:debugger] 
     54 
    4955ENV["RAILS_ENV"] = OPTIONS[:environment] 
    5056RAILS_ENV.replace(OPTIONS[:environment]) if defined?(RAILS_ENV) 
  • trunk/railties/lib/dispatcher.rb

    r6307 r6611  
    105105        end 
    106106 
    107         prepare_breakpoint 
    108107        require_dependency 'application' unless Object.const_defined?(:ApplicationController) 
    109108        ActiveRecord::Base.verify_active_connections! if defined?(ActiveRecord) 
     
    113112      def reset_after_dispatch 
    114113        reset_application! if Dependencies.load? 
    115         Breakpoint.deactivate_drb if defined?(BREAKPOINT_SERVER_PORT) 
    116       end 
    117  
    118       def prepare_breakpoint 
    119         return unless defined?(BREAKPOINT_SERVER_PORT) 
    120         require 'breakpoint' 
    121         Breakpoint.activate_drb("druby://localhost:#{BREAKPOINT_SERVER_PORT}", nil, !defined?(FastCGI)) 
    122         true 
    123       rescue 
    124         nil 
    125114      end 
    126115 
  • trunk/railties/lib/fcgi_handler.rb

    r5485 r6611  
    1010    'TERM'    => :exit_now, 
    1111    'USR1'    => :exit, 
    12     'USR2'    => :restart, 
    13     'SIGTRAP' => :breakpoint 
     12    'USR2'    => :restart 
    1413  } 
    1514  GLOBAL_SIGNALS = SIGNALS.keys - %w(USR1) 
     
    132131    end 
    133132 
    134     def breakpoint_handler(signal) 
    135       dispatcher_log :info, "asked to breakpoint ASAP" 
    136       @when_ready = :breakpoint 
    137     end 
    138  
    139133    def process_each_request!(provider) 
    140134      cgi = nil 
     
    153147            close_connection(cgi) 
    154148            break 
    155           when :breakpoint 
    156             close_connection(cgi) 
    157             breakpoint! 
    158149        end 
    159150 
     
    199190    end 
    200191 
    201     def breakpoint! 
    202       require 'breakpoint' 
    203       port = defined?(BREAKPOINT_SERVER_PORT) ? BREAKPOINT_SERVER_PORT : 42531 
    204       Breakpoint.activate_drb("druby://localhost:#{port}", nil, !defined?(FastCGI)) 
    205       dispatcher_log :info, "breakpointing" 
    206       breakpoint 
    207       @when_ready = nil 
    208     end 
    209  
    210192    def run_gc! 
    211193      @gc_request_countdown = gc_request_period 
  • trunk/railties/lib/initializer.rb

    r6550 r6611  
    7070    # * #initialize_framework_views 
    7171    # * #initialize_dependency_mechanism 
    72     # * #initialize_breakpoints 
    7372    # * #initialize_whiny_nils 
    7473    # * #initialize_framework_settings 
     
    9998      initialize_framework_views 
    10099      initialize_dependency_mechanism 
    101       initialize_breakpoints 
    102100      initialize_whiny_nils 
    103101      initialize_temporary_directories 
     
    299297    end 
    300298 
    301     # Sets the +BREAKPOINT_SERVER_PORT+ if Configuration#breakpoint_server 
    302     # is true. 
    303     def initialize_breakpoints 
    304       silence_warnings { Object.const_set("BREAKPOINT_SERVER_PORT", 42531) if configuration.breakpoint_server } 
    305     end 
    306  
    307299    # Loads support for "whiny nil" (noisy warnings when methods are invoked 
    308300    # on +nil+ values) if Configuration#whiny_nils is true. 
     
    386378    attr_accessor :active_resource 
    387379 
    388     # Whether or not to use the breakpoint server (boolean) 
    389     attr_accessor :breakpoint_server 
    390  
    391380    # Whether or not classes should be cached (set to false if you want 
    392381    # application classes to be reloaded on each request) 
     
    475464      self.controller_paths             = default_controller_paths 
    476465      self.cache_classes                = default_cache_classes 
    477       self.breakpoint_server            = default_breakpoint_server 
    478466      self.whiny_nils                   = default_whiny_nils 
    479467      self.plugins                      = default_plugins 
     
    635623      end 
    636624 
    637       def default_breakpoint_server 
    638         false 
    639       end 
    640  
    641625      def default_whiny_nils 
    642626        false 
  • trunk/railties/lib/rails_generator/generators/applications/app/app_generator.rb

    r6429 r6611  
    6868 
    6969      # Scripts 
    70       %w( about breakpointer console 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| 
    7171        m.file "bin/#{file}", "script/#{file}", script_options 
    7272      end 
  • trunk/railties/lib/test_help.rb

    r6575 r6611  
    99require 'action_controller/test_process' 
    1010require 'action_controller/integration' 
    11 require 'breakpoint' 
    1211 
    1312Test::Unit::TestCase.fixture_path = RAILS_ROOT + "/test/fixtures/" 
  • trunk/railties/Rakefile

    r6552 r6611  
    7070                   javascripts/prototype.js javascripts/application.js 
    7171                   javascripts/effects.js javascripts/dragdrop.js javascripts/controls.js ) 
    72 BIN_FILES    = %w( about breakpointer console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/inspector runner server plugin ) 
     72BIN_FILES    = %w( about console destroy generate performance/benchmarker performance/profiler process/reaper process/spawner process/inspector runner server plugin ) 
    7373 
    7474VENDOR_LIBS = %w( actionpack activerecord actionmailer activesupport actionwebservice railties ) 
  • trunk/railties/README

    r6180 r6611  
    7070 
    7171 
    72 == Breakpoints 
     72== Debugger 
    7373 
    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, investigate 
     74Debugger support is available through the debugger command when you start your Mongrel or 
     75Webrick server with --debugger. This means that you can break out of execution at any point in the code, investigate 
    7676and change the model, AND then resume execution! Example: 
    7777 
     
    7979    def index 
    8080      @posts = Post.find(:all) 
    81       breakpoint "Breaking out from the list" 
     81      debugger 
    8282    end 
    8383  end 
    8484 
    8585So 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' 
     86with a IRB prompt in the server window. Here you can do things like: 
    8987 
    9088  >> @posts.inspect 
    9189  => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>, 
    9290       #<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
    9593 
    9694...and even better is that you can examine how your runtime objects actually work: 
     
    10199  Display all 152 possibilities? (y or n) 
    102100 
    103 Finally, when you're ready to resume execution, you press CTRL-D 
     101Finally, when you're ready to resume execution, you enter "cont" 
    104102 
    105103 
  • trunk/railties/test/fcgi_dispatcher_test.rb

    r5118 r6611  
    1313require 'fcgi_handler' 
    1414require 'routes' 
    15 require 'stubbed_breakpoint' 
    1615require 'stubbed_kernel' 
    1716 
     
    3635  end 
    3736   
    38   def breakpoint 
    39   end 
    40  
    4137  alias_method :old_run_gc!, :run_gc! 
    4238  def run_gc! 
     
    7268  end 
    7369   
    74   def test_process_breakpoint 
    75     @handler.stubs(:when_ready).returns(:breakpoint) 
    76      
    77     @handler.expects(:close_connection) 
    78     @handler.expects(:breakpoint!) 
    79     @handler.process! 
    80   end 
    81    
    8270  def test_process_with_system_exit_exception 
    8371    @handler.stubs(:process_request).raises(SystemExit) 
     
    9280    @handler.send(:restart_handler, nil) 
    9381    assert_equal :restart, @handler.when_ready 
    94   end 
    95    
    96   def test_breakpoint_handler 
    97     @handler.expects(:dispatcher_log).with(:info, "asked to breakpoint ASAP") 
    98  
    99     @handler.send(:breakpoint_handler, nil) 
    100     assert_equal :breakpoint, @handler.when_ready 
    10182  end 
    10283   
     
    144125  end 
    145126 
    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_ready 
    153   end 
    154    
    155127  def test_uninterrupted_processing 
    156128    @handler.process!