Skip to content

Commit bd6203f

Browse files
committed
Merge pull request rails#5880 from asanghi/master
Stamp out ruby-debug with debugger everywhere else in the code base
2 parents 217e9c0 + d6c831c commit bd6203f

File tree

9 files changed

+32
-35
lines changed

9 files changed

+32
-35
lines changed

activesupport/lib/active_support/core_ext/kernel/debugger.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module Kernel
22
unless respond_to?(:debugger)
3-
# Starts a debugging session if ruby-debug has been loaded (call rails server --debugger to do load it).
3+
# Starts a debugging session if the +debugger+ gem has been loaded (call rails server --debugger to do load it).
44
def debugger
5-
message = "\n***** Debugger requested, but was not available (ensure ruby-debug19 is listed in Gemfile/installed as gem): Start server with --debugger to enable *****\n"
5+
message = "\n***** Debugger requested, but was not available (ensure the debugger gem is listed in Gemfile/installed as gem): Start server with --debugger to enable *****\n"
66
defined?(Rails) ? Rails.logger.info(message) : $stderr.puts(message)
77
end
88
alias breakpoint debugger unless respond_to?(:breakpoint)

guides/code/getting_started/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ gem 'jquery-rails'
3535
# gem 'capistrano'
3636

3737
# To use debugger
38-
# gem 'ruby-debug19', :require => 'ruby-debug'
38+
# gem 'debugger'

guides/code/getting_started/README.rdoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ programming in general.
8686
Debugger support is available through the debugger command when you start your
8787
Mongrel or WEBrick server with --debugger. This means that you can break out of
8888
execution at any point in the code, investigate and change the model, and then,
89-
resume execution! You need to install ruby-debug19 to run the server in debugging
90-
mode. With gems, use <tt>sudo gem install ruby-debug19</tt>. Example:
89+
resume execution! You need to install the 'debugger' gem to run the server in debugging
90+
mode. Add gem 'debugger' to your Gemfile and run <tt>bundle</tt> to install it. Example:
9191

9292
class WeblogController < ActionController::Base
9393
def index

guides/source/debugging_rails_applications.textile

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -191,25 +191,21 @@ Completed in 0.01224 (81 reqs/sec) | DB: 0.00044 (3%) | 302 Found [http://localh
191191

192192
Adding extra logging like this makes it easy to search for unexpected or unusual behavior in your logs. If you add extra logging, be sure to make sensible use of log levels, to avoid filling your production logs with useless trivia.
193193

194-
h3. Debugging with +ruby-debug+
194+
h3. Debugging with the +debugger+ gem
195195

196196
When your code is behaving in unexpected ways, you can try printing to logs or the console to diagnose the problem. Unfortunately, there are times when this sort of error tracking is not effective in finding the root cause of a problem. When you actually need to journey into your running source code, the debugger is your best companion.
197197

198198
The debugger can also help you if you want to learn about the Rails source code but don't know where to start. Just debug any request to your application and use this guide to learn how to move from the code you have written deeper into Rails code.
199199

200200
h4. Setup
201201

202-
The debugger used by Rails, +ruby-debug+, comes as a gem. To install it, just run:
202+
Rails uses the +debugger+ gem to set breakpoints and step through live code. To install it, just run:
203203

204204
<shell>
205-
$ sudo gem install ruby-debug
205+
$ gem install debugger
206206
</shell>
207207

208-
TIP: If you are using Ruby 1.9, you can install a compatible version of +ruby-debug+ by running +sudo gem install ruby-debug19+
209-
210-
In case you want to download a particular version or get the source code, refer to the "project's page on rubyforge":http://rubyforge.org/projects/ruby-debug/.
211-
212-
Rails has had built-in support for ruby-debug since Rails 2.0. Inside any Rails application you can invoke the debugger by calling the +debugger+ method.
208+
Rails has had built-in support for debugging since Rails 2.0. Inside any Rails application you can invoke the debugger by calling the +debugger+ method.
213209

214210
Here's an example:
215211

@@ -238,11 +234,11 @@ $ rails server --debugger
238234
...
239235
</shell>
240236

241-
TIP: In development mode, you can dynamically +require \'ruby-debug\'+ instead of restarting the server, if it was started without +--debugger+.
237+
TIP: In development mode, you can dynamically +require \'debugger\'+ instead of restarting the server, if it was started without +--debugger+.
242238

243239
h4. The Shell
244240

245-
As soon as your application calls the +debugger+ method, the debugger will be started in a debugger shell inside the terminal window where you launched your application server, and you will be placed at ruby-debug's prompt +(rdb:n)+. The _n_ is the thread number. The prompt will also show you the next line of code that is waiting to run.
241+
As soon as your application calls the +debugger+ method, the debugger will be started in a debugger shell inside the terminal window where you launched your application server, and you will be placed at the debugger's prompt +(rdb:n)+. The _n_ is the thread number. The prompt will also show you the next line of code that is waiting to run.
246242

247243
If you got there by a browser request, the browser tab containing the request will be hung until the debugger has finished and the trace has finished processing the entire request.
248244

@@ -270,7 +266,7 @@ continue edit frame method putl set tmate where
270266

271267
TIP: To view the help menu for any command use +help &lt;command-name&gt;+ in active debug mode. For example: _+help var+_
272268

273-
The next command to learn is one of the most useful: +list+. You can also abbreviate ruby-debug commands by supplying just enough letters to distinguish them from other commands, so you can also use +l+ for the +list+ command.
269+
The next command to learn is one of the most useful: +list+. You can abbreviate any debugging command by supplying just enough letters to distinguish them from other commands, so you can also use +l+ for the +list+ command.
274270

275271
This command shows you where you are in the code by printing 10 lines centered around the current line; the current line in this particular case is line 6 and is marked by +=>+.
276272

@@ -347,7 +343,7 @@ h4. The Context
347343

348344
When you start debugging your application, you will be placed in different contexts as you go through the different parts of the stack.
349345

350-
ruby-debug creates a context when a stopping point or an event is reached. The context has information about the suspended program which enables a debugger to inspect the frame stack, evaluate variables from the perspective of the debugged program, and contains information about the place where the debugged program is stopped.
346+
The debugger creates a context when a stopping point or an event is reached. The context has information about the suspended program which enables a debugger to inspect the frame stack, evaluate variables from the perspective of the debugged program, and contains information about the place where the debugged program is stopped.
351347

352348
At any time you can call the +backtrace+ command (or its alias +where+) to print the backtrace of the application. This can be very helpful to know how you got where you are. If you ever wondered about how you got somewhere in your code, then +backtrace+ will supply the answer.
353349

@@ -463,7 +459,7 @@ h4. Step by Step
463459

464460
Now you should know where you are in the running trace and be able to print the available variables. But lets continue and move on with the application execution.
465461

466-
Use +step+ (abbreviated +s+) to continue running your program until the next logical stopping point and return control to ruby-debug.
462+
Use +step+ (abbreviated +s+) to continue running your program until the next logical stopping point and return control to the debugger.
467463

468464
TIP: You can also use <tt>step<plus> n</tt> and <tt>step- n</tt> to move forward or backward +n+ steps respectively.
469465

@@ -485,12 +481,12 @@ class Author < ActiveRecord::Base
485481
end
486482
</ruby>
487483

488-
TIP: You can use ruby-debug while using +rails console+. Just remember to +require "ruby-debug"+ before calling the +debugger+ method.
484+
TIP: You can use the debugger while using +rails console+. Just remember to +require "debugger"+ before calling the +debugger+ method.
489485

490486
<shell>
491487
$ rails console
492488
Loading development environment (Rails 3.1.0)
493-
>> require "ruby-debug"
489+
>> require "debugger"
494490
=> []
495491
>> author = Author.first
496492
=> #<Author id: 1, first_name: "Bob", last_name: "Smith", created_at: "2008-07-31 12:46:10", updated_at: "2008-07-31 12:46:10">
@@ -603,7 +599,7 @@ A simple quit tries to terminate all threads in effect. Therefore your server wi
603599

604600
h4. Settings
605601

606-
There are some settings that can be configured in ruby-debug to make it easier to debug your code. Here are a few of the available options:
602+
The +debugger+ gem can automatically show the code you're stepping through and reload it when you change it in an editor. Here are a few of the available options:
607603

608604
* +set reload+: Reload source code when changed.
609605
* +set autolist+: Execute +list+ command on every breakpoint.
@@ -612,7 +608,7 @@ There are some settings that can be configured in ruby-debug to make it easier t
612608

613609
You can see the full list by using +help set+. Use +help set _subcommand_+ to learn about a particular +set+ command.
614610

615-
TIP: You can include any number of these configuration lines inside a +.rdebugrc+ file in your HOME directory. ruby-debug will read this file every time it is loaded and configure itself accordingly.
611+
TIP: You can save these settings in an +.rdebugrc+ file in your home directory. The debugger reads these global settings when it starts.
616612

617613
Here's a good start for an +.rdebugrc+:
618614

@@ -637,7 +633,7 @@ If a Ruby object does not go out of scope, the Ruby Garbage Collector won't swee
637633
To install it run:
638634

639635
<shell>
640-
$ sudo gem install bleak_house
636+
$ gem install bleak_house
641637
</shell>
642638

643639
Then setup your application for profiling. Then add the following at the bottom of config/environment.rb:
@@ -703,11 +699,12 @@ There are some Rails plugins to help you to find errors and debug your applicati
703699
h3. References
704700

705701
* "ruby-debug Homepage":http://www.datanoise.com/ruby-debug
702+
* "debugger Homepage":http://github.com/cldwalker/debugger
706703
* "Article: Debugging a Rails application with ruby-debug":http://www.sitepoint.com/article/debug-rails-app-ruby-debug/
707704
* "ruby-debug Basics screencast":http://brian.maybeyoureinsane.net/blog/2007/05/07/ruby-debug-basics-screencast/
708-
* "Ryan Bate's ruby-debug screencast":http://railscasts.com/episodes/54-debugging-with-ruby-debug
709-
* "Ryan Bate's stack trace screencast":http://railscasts.com/episodes/24-the-stack-trace
710-
* "Ryan Bate's logger screencast":http://railscasts.com/episodes/56-the-logger
705+
* "Ryan Bates' debugging ruby (revised) screencast":http://railscasts.com/episodes/54-debugging-ruby-revised
706+
* "Ryan Bates' stack trace screencast":http://railscasts.com/episodes/24-the-stack-trace
707+
* "Ryan Bates' logger screencast":http://railscasts.com/episodes/56-the-logger
711708
* "Debugging with ruby-debug":http://bashdb.sourceforge.net/ruby-debug.html
712709
* "ruby-debug cheat sheet":http://cheat.errtheblog.com/s/rdebug/
713710
* "Ruby on Rails Wiki: How to Configure Logging":http://wiki.rubyonrails.org/rails/pages/HowtoConfigureLogging

railties/lib/rails/commands/console.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def options
2727
opt.on("-e", "--environment=name", String,
2828
"Specifies the environment to run this console under (test/development/production).",
2929
"Default: development") { |v| options[:environment] = v.strip }
30-
opt.on("--debugger", 'Enable ruby-debugging for the console.') { |v| options[:debugger] = v }
30+
opt.on("--debugger", 'Enable the debugger.') { |v| options[:debugger] = v }
3131
opt.parse!(arguments)
3232
end
3333

@@ -73,10 +73,10 @@ def start
7373

7474
def require_debugger
7575
begin
76-
require 'ruby-debug'
76+
require 'debugger'
7777
puts "=> Debugger enabled"
7878
rescue Exception
79-
puts "You need to install ruby-debug19 to run the console in debugging mode. With gems, use 'gem install ruby-debug19'"
79+
puts "You're missing the 'debugger' gem. Add it to your Gemfile, bundle, and try again."
8080
exit
8181
end
8282
end

railties/lib/rails/commands/server.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def parse!(args)
1717
opts.on("-c", "--config=file", String,
1818
"Use custom rackup configuration file") { |v| options[:config] = v }
1919
opts.on("-d", "--daemon", "Make server run as a Daemon.") { options[:daemonize] = true }
20-
opts.on("-u", "--debugger", "Enable ruby-debugging for the server.") { options[:debugger] = true }
20+
opts.on("-u", "--debugger", "Enable the debugger") { options[:debugger] = true }
2121
opts.on("-e", "--environment=name", String,
2222
"Specifies the environment to run this server under (test/development/production).",
2323
"Default: development") { |v| options[:environment] = v }

railties/lib/rails/generators/rails/app/templates/README

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ programming in general.
8686
Debugger support is available through the debugger command when you start your
8787
Mongrel or WEBrick server with --debugger. This means that you can break out of
8888
execution at any point in the code, investigate and change the model, and then,
89-
resume execution! You need to install ruby-debug19 to run the server in debugging
90-
mode. With gems, use <tt>sudo gem install ruby-debug19</tt>. Example:
89+
resume execution! You need to install the 'debugger' gem to run the server in debugging
90+
mode. Add gem 'debugger' to your Gemfile and run <tt>bundle</tt> to install it. Example:
9191

9292
class WeblogController < ActionController::Base
9393
def index

railties/lib/rails/generators/rails/plugin_new/templates/Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ gem "jquery-rails"
2020
2121
<% end -%>
2222
# To use debugger
23-
# gem 'ruby-debug19', :require => 'ruby-debug'
23+
# gem 'debugger'

railties/lib/rails/rack/debugger.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ def initialize(app)
66

77
ARGV.clear # clear ARGV so that rails server options aren't passed to IRB
88

9-
require 'ruby-debug'
9+
require 'debugger'
1010

1111
::Debugger.start
1212
::Debugger.settings[:autoeval] = true if ::Debugger.respond_to?(:settings)
1313
puts "=> Debugger enabled"
1414
rescue LoadError
15-
puts "You need to install ruby-debug19 to run the server in debugging mode. With gems, use 'gem install ruby-debug19'"
15+
puts "You're missing the 'debugger' gem. Add it to your Gemfile, bundle, and try again."
1616
exit
1717
end
1818

0 commit comments

Comments
 (0)