Note: Breakpointer has pretty much been deprecated as far as I can tell (Rails Changeset 6611). Use Ruby Debug, as it is much more robust and should be incorporated into Rails 2.0. – Adam G.
Breakpoints allow you to step into a running program and poke around its innards from a Rails-included “breakpointer” client. This ability is great for both debugging and code exploration.
Specifically, a breakpoint will pop up in an interactive ruby(irb) session at a pre-defined break point in a Ruby application — it will pop up from within a standard terminal or shell window.
This tutorial describes how to use the built in breakpoint (which uses irb). For explanation of how to use rdebug see HowtoDebugWithRubyDebug.
In the location of your program that you want to inspect place the following code:
breakpoint
No, really, that’s it.
When the program runs into the breakpoint statement it will try to get to an irb session. If you’re running the Rails breakpointer client (see below), through an interactive ruby session you can inspect all of the objects that exist where breakpoint was called.
Quick tips:
exit to leave the breakpoint and continue running the programexit! to terminate the program from within a breakpointlocal_variables, instance_variables, caller, methodsYou can also use breakpoints directly from the error screens you get when an unhandled exception occurs somewhere in your application code. Just hit the “Retry with breakpoint” link and fire up the breakpoint client.
When your test isn’t working and you’re not sure why, don’t you just wish you had a crystal ball that could see right into your code, inspect every object in sight and coerce all the variables in the land? Well guess what? We’re fresh out of crystal balls! Fortunately for you, breakpoints are totally up to the job!
Breakpoints work well with unit tests because the tests set up the sample data, and the breakpoint allows you to see what’s happening inside your application; i.e. why it’s not working.
Inside your cryptic test, place the breakpoint method. You can give the breakpoint a name or message if you like (it’s optional).
def test_complex_stuff
@david.projects << @new_project
breakpoint "Let's have a closer look at @david"
end
When this program is run and the breakpoint is reached the server connects to the running breakpointer client, starting a new debugging session. In that irb session you can poke and prod all the suspect objects and methods to determine their exact states and operations.
The breakpoint statement need not be in the test. It can be anywhere in your application. Put it in the context you need to investigate.
[ @todo Paste in good example of irb session ]
Breakpoints can be inserted into your application code as well. This allows you to freeze the excution of your entire application and interrogate it at any step along the way.
Breakpoints can go anywhere: in the models, the controllers, or even the views!
When the breakpoint is encountered, Rails establishes a connection between the server and a breakpoint client. During development the client and the server are likely to both be on the same machine, but the breakpoint server can connect with a remote client as well.
Once you’ve set a breakpoint or twelve in your Rails application, you might try to run your code and wonder, “How do I access this elusive IRB prompt?” Here’s the answer:
cd /path/to/your/app./script/breakpointer (windows: ruby script/breakpointer)exit at the irb prompt.Breakpoints can be used remotely over sockets. This means that you debug a remote CGI application, or tunnel the connection over SSH to get through a firewall.
(NB: when you execute the breakpoint script, it will display something that possibly “looks” like an error:
bash-3.00$ ./script/breakpointer
No connection to breakpoint service at druby://localhost:42531 (DRb::DRbConnError)
Tries to connect will be made every 2 seconds…
Don’t be worried! It’s fine and only says that the script is waiting for an incoming connection from your breakpointed application.)
(NB: by default, the development environment is configured to support druby breakpointing, but not the production environment.
If you need this for some reason, you can append
to the end of environments/production.rb)
./script/breakpointer -h gives the command line options to change the client settings.
Usage: ruby breakpointer [options] [server uri]
This tool lets you connect to a breakpoint service
which was started via Breakpoint.activate_drb.
The server uri defaults to druby://localhost:42531
-c, --client-uri=uri Run the client on the specified uri.
This can be used to specify the port
that the client uses to allow for back
connections from the server.
Default: Find a good URI automatically.
Example: -c druby://localhost:12345
-s, --server-uri=uri Connect to the server specified at the
specified uri.
Default: druby://localhost:42531
-v, --verbose Report all connections and disconnections
Default: false
-R, --retry-delay=delay Automatically try to reconnect to the
server after delay seconds when the
connection failed or timed out.
A value of 0 disables automatical
reconnecting completely.
Default: 10
-h, --help Show this help message.
[ @todo Explain how to put default settings(client and server) into environment files]
A newer (apparently faster) alternative to “breakpoint” is using ruby-debug which allows you to see the source code of your original application, etc.
Older versions of Rails(eg. 0.8.5) required a seperate libary(dev-utils) to facilitate breakpoints. If you are using such a version you need to install dev-utils yourself for this function to work (“gem install dev-utils”). Note that older versions do not support breakpoints outside of tests.
For further information you may be interested in:
Have a look at the Frequently Asked Questions page at the ruby-breakpoint Wiki
—
Timeout/Application Error:
If breakpointing works for you, but the script times out after half a minute or so, you might have to put this into your Apache’s httpd.conf:
FastCgiConfig -idle-timeout 320
(makes fast-cgi scripts timeout after 5 mins instead of 1/2 a min)
I can’t get it to work. The terminal gives me:
./script/breakpointer
No connection to breakpoint service at druby://localhost:42531 (DRb::DRb\ConnError)
Tries to connect will be made every 3 seconds…
I am using Mac OS X, and rails 0.9.5
Il Doge
—
Try invoking the breakpointer like this:
./script/breakpointer --client-uri=druby://localhost:42532
The breakpoint client right will prefer the public network interface to the local one leading to the above problem — this can be fixed by manually specifying the client-uri as in the example above. In the future the breakpoint client will do a better job at guessing it.
— Florian Gross
—
Same thing:
./script/breakpointer --client-uri=druby://localhost:42532
No connection to breakpoint service at druby://localhost:42531 (DRb::DRbConnError)
Tries to connect will be made every 2 seconds...
Il Doge
—
Are you using the DMG installer or Ruby 1.8.1? BTW, it’s probably best to continue this via private mail — I’m reachable via flgr@ccan.de
—
Hi, I don’t know why continue by e-mail.
Now I have the same problem and don’t know the answer, can you post here how you resolve this?
Thank you!
Pedro Valentini
—
Pedro, I was having the same problem. I found the problem was my fault. If your problem was the same as mine, I was trying to run the breakpoint client before running my application. I found I had to put the breakpoint in my code, run the application and THEN run the breakpoint client. Hope this helps.
—
I was trying to solve this via private mail as then I would not forgot to check back to the discussion as easily. You can of course also submit this as a bug report on the ruby-breakpoint page, but I’m not trying to hide bugs or something like that, but it is hard for me to watch a page on a Wiki and I expect that it will be similar for you as well thus delaying communication even more.
For anyone with the “No connection to breakpoint service” error
For whatever reason, I could only run the breakpointer in the development environment. I don’t doubt it will run in test, but if you are looking to get to debugging quickly, try to do it from development. Follow these steps:
breakpoint
./script/server
ruby script/server
./script/breakpointer
ruby script/breakpointer
Note: you can also do this in order of steps 2, 1, 4, 3 (swap 1 & 2 or 3 & 4). If you load up the web page before starting the breakpointer it will hang and wait with an hourglass cursor until you start the breakpointer script and tell it to continue (ctrl+d)
It seems that, on OS X, the breakpoint server decides to only listen on IPv6, and the breakpoint client will only connect on IPv4. Then, when the server tries to connect back to the client, it first tries the IPv6 network address of the primary interace…
Anyway, the workaround is as follows. First:
sudo ip6 -d lo0
Then
./script/breakpointer —client-uri=druby://localhost:12345
— Pete Yandell
I am trying to use the a breakpoint in a controller but when it hits a breakpoint the app does nothing. It is during a page transition and it does not proceed to the next page, it does not bring up an irb session and it does not process anything any further. I simply hangs up the browser. I am running this on Win2000.
— Ken Fettig
The ip6 fix did not work for me on OS X. However, replacing localhost with 127.0.0.1 seems to do the trick.
./script/breakpointer -c druby://127.0.0.1:42531
— Keith Morrison
Using multiple webrick/breakpointers
We are trying to work on a linux server at different projects at the same time. We are running multiple instances of webrick using the -p option (-p3001, -p3002, …), but we can’t get breakpointer to work with the individual webrick servers. When starting multiple breakpointers, it seems that every breakpoint is picked up by a random breakpointer process. We tried using the -c and -s option, but somehow it’s not clear to us how to get things working.
Anyone knowing how to solve this problem?
Thanks!
Today we got an answer from Florian Gross!!
Basically this should work if you change the drb://-url that Rails uses to call Breakpoint.activate_drb() to a different one for each webrick server. The easiest way of doing that is to modify the BREAKPOINT_SERVER_PORT constant in your application’s environment file.
You will then need to specify the server to connect to to breakpointer via the -s option. You shouldn’t need to supply -c in this case.
Hope this helps!
Kind regards,
Florian Gross
in environment.rb:
BREAKPOINT_SERVER_PORT = 42532
in your shell:
script/breakpointer -s druby://127.0.0.1:42532
Thus, every project needs it’s own port.
— Mark de Haan
category:Howto
Bath and Shower
Fragrance
Gift Sets
Hair Care
Makeup
Men’s Grooming
Shaving and Hair Removal
Skin Care
Tools and Accessories
Baby Apparel
Baby Bathing & Skin Care
Baby Bedding
Baby Car Seats
Baby Diapering
Baby Feeding
For Moms
Baby Furniture
Baby Gear
Baby Gifts
Baby Health & Baby Care
Nursery Décor
Potty Training
Baby Safety
Baby Strollers
Books – Business & Investing
Books – Children’s Books
Books – Comics & Graphic Novels
Books – Computers & Internet
Books – Cooking, Food & Wine
Books – Entertainment
Books – Gay & Lesbian
Books – Health, Mind & Body
Books – History
Books – Home & Garden
Books – Law
Books – Literature & Fiction
Books – Medicine
Books – Mystery & Thrillers
Books – Nonfiction
Books – Outdoors & Nature
Books – Parenting & Families
Books – Professional & Technical
Books – Reference
Books – Religion & Spirituality
Books – Romance
Books – Science
Books – Science Fiction & Fantasy
Books – Sports
Books – Teens
Books – Travel
Camera & Photo – Accessories
Camera & Photo – Camcorders
Camera & Photo – Digital Cameras
Camera & Photo – Film Cameras
Camera & Photo – Optics
Camera & Photo – Printers & Scanners
Health & Personal Care – Baby & Child Care
Health & Personal Care – Food & Snacks
Health & Personal Care – Health & Personal Care Outlet Store
Health & Personal Care – Health Care
Health & Personal Care – House Supplies
Health & Personal Care – Nutrition & Fitness
Health & Personal Care – Personal Care
Health & Personal Care – Sexual Wellness
Computers – Computer Add-Ons
Computers – Desktops
Computers – Handhelds & PDAs
Computers – Notebooks
Electronics – Accessories & Supplies
Electronics – Audio & Video
Electronics – Camera & Photo
Electronics – Car Electronics
Electronics – Computers & Add-Ons
Electronics – GPS & Navigation
Electronics – Home Automation & Security
Electronics – Office Electronics
Electronics – Service & Replacement Plans
Gourmet Food – Appetizers & Hors d’oeuvres
Gourmet Food – Baking Supplies
Gourmet Food – Beverages
Gourmet Food – Bread
Gourmet Food – Breakfast Foods
Gourmet Food – Candy
Gourmet Food – Cheese
Gourmet Food – Chocolate
Gourmet Food – Coffee & Tea
Gourmet Food – Cookies
Gourmet Food – Dairy Foods & Eggs
Gourmet Food – Desserts
Gourmet Food – Fruits & Vegetables
Gourmet Food – Gourmet Gifts
Gourmet Food – Jams, Jellies & Preserves
Gourmet Food – Meat, Game & Pâtés
Gourmet Food – Oils, Vinegars & Salad Dressings
Gourmet Food – Pasta, Beans, Grains & Rice
Gourmet Food – Prepared Meals
Gourmet Food – Salsas & Condiments
Gourmet Food – Seafood & Caviar
Gourmet Food – Seasonings, Herbs & Spices
Gourmet Food – Snack Food
Gourmet Food – Soups & Stocks
Grocery – Appetizers & Hors D’Oeuvres
Grocery – Baking Supplies
Grocery – Beverages
Grocery – Boxed Meals & Side Dishes
Grocery – Breads
Grocery – Breakfast Foods
Grocery – Canned & Packaged Goods
Grocery – Coffee, Tea & Cocoa
Grocery – Condiments, Sauces & Spreads
Grocery – Dairy & Eggs
Grocery – Desserts & Pastries
Grocery – Fruits & Vegetables
Grocery – Health & Family
Grocery – Herbs, Spices & Seasonings
Grocery – Household Supplies
Grocery – Meats
Grocery – Pasta & Grains
Grocery – Pet Supplies
Grocery – Seafood
Grocery – Snacks, Cookies & Candy
Home & Garden – Backyard Birding
Home & Garden – Bar Tools & Glasses
Home & Garden – Bedding & Bath
Home & Garden – Coffee, Tea & Espresso
Home & Garden – Cook’s Tools & Gadgets
Home & Garden – Cookware & Baking
Home & Garden – Cutlery
Home & Garden – Fresh Flowers & Indoor Plants
Home & Garden – Furniture & Décor
Home & Garden – Gardening Tools
Home & Garden – Grills, Smokers & Outdoor Cooking
Home & Garden – Heating & Lighting
Home & Garden – Kitchen & Table Linens
Home & Garden – Large Appliances
Home & Garden – Leisure & Fitness
Home & Garden – Outdoor Décor
Home & Garden – Patio Furniture
Home & Garden – Pest Control
Home & Garden – Pet Supplies
Home & Garden – Plants & Planting
Home & Garden – Small Appliances
Home & Garden – Tableware
Home & Garden – Vacuums, Cleaning & Storage
Home & Garden – Weather Instruments
Home & Garden – Wine Accessories
Industrial & Scientific – Adhesive Tapes
Industrial & Scientific – Fasteners
Industrial & Scientific – Industrial Abrasives
Industrial & Scientific – Industrial Adhesives
Industrial & Scientific – Industrial Cutting Tools
Industrial & Scientific – Industrial Hoses
Industrial & Scientific – Material Handling Equipment
Industrial & Scientific – Mechanical Components
Industrial & Scientific – Precision Measurement Products
Industrial & Scientific – Raw Materials
Jewelry – Accessories
Jewelry – Body Jewelry
Jewelry – Bracelets
Jewelry – Brooches & Pins
Jewelry – Charms
Jewelry – Children’s Jewelry
Jewelry – Earrings
Jewelry – Engagement
Jewelry – Jewelry Sets
Jewelry – Men’s Jewelry
Jewelry – Necklaces & Pendants
Jewelry – Religious Jewelry
Jewelry – Rings
Jewelry – Wedding & Anniversary
Kindle Store – Advice & How-to
Kindle Store – Arts & Entertainment
Kindle Store – Biographies & Memoirs
Kindle Store – Business & Investing
Kindle Store – Children’s Chapter Books
Kindle Store – Computers & Internet
Kindle Store – Fantasy
Kindle Store – Fiction
Kindle Store – History
Kindle Store – Humor
Kindle Store – Lifestyle & Home
Kindle Store – Literary Fiction
Kindle Store – Mystery & Thrillers
Kindle Store – Nonfiction
Kindle Store – Parenting & Families
Kindle Store – Politics & Current Events
Kindle Store – Reference
Kindle Store – Religion & Spirituality
Kindle Store – Romance
Kindle Store – Science
Kindle Store – Science Fiction
Kindle Store – Sports
Kindle Store – Travel
Kitchen & Housewares – Bar Tools & Glasses
Kitchen & Housewares – Coffee, Tea & Espresso
Kitchen & Housewares – Cook’s Tools & Gadgets
Kitchen & Housewares – Cookware & Baking
Kitchen & Housewares – Cutlery
Kitchen & Housewares – Dining Room Furniture
Kitchen & Housewares – Kitchen & Table Linens
Kitchen & Housewares – Kitchen Furniture
Kitchen & Housewares – Small Appliances
Kitchen & Housewares – Storage & Organization
Kitchen & Housewares – Tableware
Kitchen & Housewares – Wine Accessories
Magazine Subscriptions – Arts & Crafts
Magazine Subscriptions – Automotive
Magazine Subscriptions – Bridal
Magazine Subscriptions – Business & Finance
Magazine Subscriptions – Children’s
Magazine Subscriptions – Computer & Internet
Magazine Subscriptions – Electronics & Audio
Magazine Subscriptions – Entertainment
Magazine Subscriptions – Family & Parenting
Magazine Subscriptions – Fashion & Style
Magazine Subscriptions – Food & Gourmet
Magazine Subscriptions – Games & Hobbies
Magazine Subscriptions – Gay & Lesbian
Magazine Subscriptions – Health & Fitness
Magazine Subscriptions – History
Magazine Subscriptions – Home & Garden
Magazine Subscriptions – International
Magazine Subscriptions – Lifestyle & Cultures
Magazine Subscriptions – Literary
Magazine Subscriptions – Men’s Interest
Magazine Subscriptions – Music
Magazine Subscriptions – News & Politics
Magazine Subscriptions – Pets
Magazine Subscriptions – Religion & Spirituality
Magazine Subscriptions – Science & Nature
Magazine Subscriptions – Sports & Leisure
Magazine Subscriptions – Teens
Magazine Subscriptions – Travel & Regional
Magazine Subscriptions – Women’s Interest
Miscellaneous – Aircraft
Miscellaneous – Antiques
Miscellaneous – Coins
Miscellaneous – Collectibles
Miscellaneous – General
Miscellaneous – Other Products
Miscellaneous – Scientific Supplies
Miscellaneous – Stamps
Miscellaneous – Vehicles
Miscellaneous – Watercraft
MP3 Downloads – MP3 Albums
MP3 Downloads – MP3 Songs
Music – Alternative Rock
Music – Blues
Music – Broadway & Vocalists
Music – Children’s Music
Music – Christian & Gospel
Music – Classic Rock
Music – Classical
Music – Country
Music – Dance & DJ
Music – Folk
Music – Hard Rock & Metal
Music – International
Music – Jazz
Music – Latin Music
Music – Miscellaneous
Music – New Age
Music – Pop
Music – R&B
Music – Rap & Hip-Hop
Music – Rock
Music – Soundtracks
Classical Music – Ballads
Classical Music – Canons
Classical Music – Concertos
Classical Music – Etudes
Classical Music – Fantasies
Classical Music – Fugues
Classical Music – Improvisation
Classical Music – Inventions
Classical Music – Lullabies & Berceuse
Classical Music – Oratorio
Classical Music – Preludes
Classical Music – Requiems, Elegies & Tombeau
Classical Music – Rondos
Classical Music – Scherzo
Classical Music – Serenades & Divertimentos
Classical Music – Short Forms
Classical Music – Sonatas
Classical Music – Suites
Classical Music – Symphonies
Classical Music – Theatrical, Incidental & Program Music
Classical Music – Toccatas
Classical Music – Variations
Musical Instruments – Band & Orchestra
Musical Instruments – Bass Guitars
Musical Instruments – DJ, Electronic Music & Karaoke
Musical Instruments – Drums & Percussion
Musical Instruments – Folk & World Instruments
Musical Instruments – Guitars
Musical Instruments – Instrument Accessories
Musical Instruments – Keyboards
Musical Instruments – Live Sound & Stage
Musical Instruments – Recording Equipment
Office Products – Business Presentation Supplies
Office Products – Educational Supplies
Office Products – Mailroom Supplies
Office Products – Office Furniture & Accessories
Office Products – Office Lighting
Office Products – Office Supplies
Cell Phones & Service – All
Cell Phones & Service – Bluetooth
Cell Phones & Service – Camera
Cell Phones & Service – E-mail
Cell Phones & Service – Flip
Cell Phones & Service – Kid’s
Cell Phones & Service – Mobile Broadband Cards
Cell Phones & Service – MP3
Cell Phones & Service – PDA
Cell Phones & Service – Prepaid
Cell Phones & Service – Video
Cell Phones & Service – Wi-Fi
Software – Business & Office
Software – Children’s Software
Software – Education & Reference
Software – Graphics
Software – Home & Hobbies
Software – Language & Travel
Software – Linux
Software – Macintosh
Software – Networking
Software – Operating Systems
Software – Outlet
Software – Personal Finance
Software – Programming
Software – Software for Handhelds
Software – Utilities
Software – Video & Music
Software – Web Development
Sports & Outdoors – Accessories
Sports & Outdoors – Airsoft
Sports & Outdoors – Apparel
Sports & Outdoors – Archery
Sports & Outdoors – Badminton
Sports & Outdoors – Ballet & Dance
Sports & Outdoors – Baseball
Sports & Outdoors – Basketball
Sports & Outdoors – Boating
Sports & Outdoors – Bowling
Sports & Outdoors – Boxing
Sports & Outdoors – Camping & Hiking
Sports & Outdoors – Cheerleading
Sports & Outdoors – Climbing
Sports & Outdoors – Crew
Sports & Outdoors – Cricket
Sports & Outdoors – Curling
Sports & Outdoors – Cycling & Wheel Sports
Sports & Outdoors – Disc Sports
Sports & Outdoors – Diving
Sports & Outdoors – Dog Sports
Sports & Outdoors – Equestrian Sports
Sports & Outdoors – Exercise & Fitness
Sports & Outdoors – Fan Shop
Sports & Outdoors – Fencing
Sports & Outdoors – Field Hockey
Sports & Outdoors – Fishing
Sports & Outdoors – Football
Sports & Outdoors – Game Room
Sports & Outdoors – Golf
Sports & Outdoors – Gymnastics
Sports & Outdoors – Hockey
Sports & Outdoors – Hunting
Sports & Outdoors – Jai Alai
Sports & Outdoors – Kayaking
Sports & Outdoors – Lacrosse
Sports & Outdoors – Lawn Games
Sports & Outdoors – Martial Arts
Sports & Outdoors – Motor Sports
Sports & Outdoors – Paddle Court Sports
Sports & Outdoors – Paintball
Sports & Outdoors – Pilates
Sports & Outdoors – Polo
Sports & Outdoors – Racquetball
Sports & Outdoors – Rodeo
Sports & Outdoors – Rugby
Sports & Outdoors – Running
Sports & Outdoors – RV Equipment
Sports & Outdoors – Scooters
Sports & Outdoors – Shoes
Sports & Outdoors – Skateboarding
Sports & Outdoors – Skating
Sports & Outdoors – Skydiving
Sports & Outdoors – Sledding
Sports & Outdoors – Snow Skiing
Sports & Outdoors – Snowboarding
Sports & Outdoors – Snowmobiling
Sports & Outdoors – Snowshoeing
Sports & Outdoors – Soccer
Sports & Outdoors – Softball
Sports & Outdoors – Sports Medicine
Sports & Outdoors – Squash
Sports & Outdoors – Surfing
Sports & Outdoors – Swimming
Sports & Outdoors – Tennis & Racquet Sports
Sports & Outdoors – Track & Field
Sports & Outdoors – Triathlon
Sports & Outdoors – Volleyball
Sports & Outdoors – Water Polo
Sports & Outdoors – Water Sports
Sports & Outdoors – Windsurfing
Sports & Outdoors – Wrestling
Sports & Outdoors – Yoga
Tools & Hardware – Air Tools
Tools & Hardware – Appliances
Tools & Hardware – Building Supplies & Heavy Equipment
Tools & Hardware – Electrical
Tools & Hardware – Hand Tools
Tools & Hardware – Hardware
Tools & Hardware – Heating & Cooling
Tools & Hardware – Home Improvement Outlet
Tools & Hardware – Lawn & Garden
Tools & Hardware – Lighting
Tools & Hardware – Organization & Storage
Tools & Hardware – Painting Tools & Supplies
Tools & Hardware – Plumbing
Tools & Hardware – Power Tool Accessories
Tools & Hardware – Power Tools
Tools & Hardware – Safety & Security
Toys & Games – Action Figures
Toys & Games – Activities & Amusements
Toys & Games – Arts & Crafts
Toys & Games – Bikes, Skates & Ride-Ons
Toys & Games – Construction, Blocks & Models
Toys & Games – Dolls
Toys & Games – Electronics for Kids
Toys & Games – Games
Toys & Games – Hobbies
Toys & Games – Kids’ Furniture & Room Décor
Toys & Games – Learning & Education
Toys & Games – Music
Toys & Games – Party Supplies
Toys & Games – Play Vehicles
Toys & Games – Preschool
Toys & Games – Pretend Play & Dress-up
Toys & Games – Puzzles
Toys & Games – Sports & Outdoor Play
Toys & Games – Stuffed Animals & Plush
Toys & Games – Toy Figures & Playsets
Unbox Video Downloads – International
Unbox Video Downloads – Movies
Unbox Video Downloads – Nonfiction
Unbox Video Downloads – TV
DVD – Action & Adventure
DVD – African American Cinema
DVD – Animation
DVD – Anime & Manga
DVD – Art House & International
DVD – Classics
DVD – Comedy
DVD – Cult Movies
DVD – Documentary
DVD – Drama
DVD – Educational
DVD – Fitness & Yoga
DVD – Gay & Lesbian
DVD – Horror
DVD – Kids & Family
DVD – Military & War
DVD – Music Video & Concerts
DVD – Musicals & Performing Arts
DVD – Mystery & Suspense
DVD – Science Fiction & Fantasy
DVD – Special Interests
DVD – Sports
DVD – Television
DVD – Westerns
"Computer & Video Games – ":http://astore.amazon.com/vgamesbuy-20
VHS – Action & Adventure
VHS – African American Cinema
VHS – Animation
VHS – Anime & Manga
VHS – Art House & International
VHS – Boxed Sets
VHS – Classics
VHS – Comedy
VHS – Cult Movies
VHS – Documentary
VHS – Drama
VHS – Educational
VHS – Fitness
VHS – Gay & Lesbian
VHS – Horror
VHS – Kids & Family
VHS – Military & War
VHS – Music Video & Concerts
VHS – Musicals & Performing Arts
VHS – Mystery & Suspense
VHS – Science Fiction & Fantasy
VHS – Spanish Language
VHS – Special Interests
VHS – Sports
VHS – Television
VHS – Westerns
VHS – Widescreen
Watches – Accessories
Watches – Casual Watches
Watches – Collectible Watches
Watches – Dress Watches
Watches – Fashion Watches
Watches – Pocket Watches
Watches – Sport Watches
Note: Breakpointer has pretty much been deprecated as far as I can tell (Rails Changeset 6611). Use Ruby Debug, as it is much more robust and should be incorporated into Rails 2.0. – Adam G.
Breakpoints allow you to step into a running program and poke around its innards from a Rails-included “breakpointer” client. This ability is great for both debugging and code exploration.
Specifically, a breakpoint will pop up in an interactive ruby(irb) session at a pre-defined break point in a Ruby application — it will pop up from within a standard terminal or shell window.
This tutorial describes how to use the built in breakpoint (which uses irb). For explanation of how to use rdebug see HowtoDebugWithRubyDebug.
In the location of your program that you want to inspect place the following code:
breakpoint
No, really, that’s it.
When the program runs into the breakpoint statement it will try to get to an irb session. If you’re running the Rails breakpointer client (see below), through an interactive ruby session you can inspect all of the objects that exist where breakpoint was called.
Quick tips:
exit to leave the breakpoint and continue running the programexit! to terminate the program from within a breakpointlocal_variables, instance_variables, caller, methodsYou can also use breakpoints directly from the error screens you get when an unhandled exception occurs somewhere in your application code. Just hit the “Retry with breakpoint” link and fire up the breakpoint client.
When your test isn’t working and you’re not sure why, don’t you just wish you had a crystal ball that could see right into your code, inspect every object in sight and coerce all the variables in the land? Well guess what? We’re fresh out of crystal balls! Fortunately for you, breakpoints are totally up to the job!
Breakpoints work well with unit tests because the tests set up the sample data, and the breakpoint allows you to see what’s happening inside your application; i.e. why it’s not working.
Inside your cryptic test, place the breakpoint method. You can give the breakpoint a name or message if you like (it’s optional).
def test_complex_stuff
@david.projects << @new_project
breakpoint "Let's have a closer look at @david"
end
When this program is run and the breakpoint is reached the server connects to the running breakpointer client, starting a new debugging session. In that irb session you can poke and prod all the suspect objects and methods to determine their exact states and operations.
The breakpoint statement need not be in the test. It can be anywhere in your application. Put it in the context you need to investigate.
[ @todo Paste in good example of irb session ]
Breakpoints can be inserted into your application code as well. This allows you to freeze the excution of your entire application and interrogate it at any step along the way.
Breakpoints can go anywhere: in the models, the controllers, or even the views!
When the breakpoint is encountered, Rails establishes a connection between the server and a breakpoint client. During development the client and the server are likely to both be on the same machine, but the breakpoint server can connect with a remote client as well.
Once you’ve set a breakpoint or twelve in your Rails application, you might try to run your code and wonder, “How do I access this elusive IRB prompt?” Here’s the answer:
cd /path/to/your/app./script/breakpointer (windows: ruby script/breakpointer)exit at the irb prompt.Breakpoints can be used remotely over sockets. This means that you debug a remote CGI application, or tunnel the connection over SSH to get through a firewall.
(NB: when you execute the breakpoint script, it will display something that possibly “looks” like an error:
bash-3.00$ ./script/breakpointer
No connection to breakpoint service at druby://localhost:42531 (DRb::DRbConnError)
Tries to connect will be made every 2 seconds…
Don’t be worried! It’s fine and only says that the script is waiting for an incoming connection from your breakpointed application.)
(NB: by default, the development environment is configured to support druby breakpointing, but not the production environment.
If you need this for some reason, you can append
to the end of environments/production.rb)
./script/breakpointer -h gives the command line options to change the client settings.
Usage: ruby breakpointer [options] [server uri]
This tool lets you connect to a breakpoint service
which was started via Breakpoint.activate_drb.
The server uri defaults to druby://localhost:42531
-c, --client-uri=uri Run the client on the specified uri.
This can be used to specify the port
that the client uses to allow for back
connections from the server.
Default: Find a good URI automatically.
Example: -c druby://localhost:12345
-s, --server-uri=uri Connect to the server specified at the
specified uri.
Default: druby://localhost:42531
-v, --verbose Report all connections and disconnections
Default: false
-R, --retry-delay=delay Automatically try to reconnect to the
server after delay seconds when the
connection failed or timed out.
A value of 0 disables automatical
reconnecting completely.
Default: 10
-h, --help Show this help message.
[ @todo Explain how to put default settings(client and server) into environment files]
A newer (apparently faster) alternative to “breakpoint” is using ruby-debug which allows you to see the source code of your original application, etc.
Older versions of Rails(eg. 0.8.5) required a seperate libary(dev-utils) to facilitate breakpoints. If you are using such a version you need to install dev-utils yourself for this function to work (“gem install dev-utils”). Note that older versions do not support breakpoints outside of tests.
For further information you may be interested in:
Have a look at the Frequently Asked Questions page at the ruby-breakpoint Wiki
—
Timeout/Application Error:
If breakpointing works for you, but the script times out after half a minute or so, you might have to put this into your Apache’s httpd.conf:
FastCgiConfig -idle-timeout 320
(makes fast-cgi scripts timeout after 5 mins instead of 1/2 a min)
I can’t get it to work. The terminal gives me:
./script/breakpointer
No connection to breakpoint service at druby://localhost:42531 (DRb::DRb\ConnError)
Tries to connect will be made every 3 seconds…
I am using Mac OS X, and rails 0.9.5
Il Doge
—
Try invoking the breakpointer like this:
./script/breakpointer --client-uri=druby://localhost:42532
The breakpoint client right will prefer the public network interface to the local one leading to the above problem — this can be fixed by manually specifying the client-uri as in the example above. In the future the breakpoint client will do a better job at guessing it.
— Florian Gross
—
Same thing:
./script/breakpointer --client-uri=druby://localhost:42532
No connection to breakpoint service at druby://localhost:42531 (DRb::DRbConnError)
Tries to connect will be made every 2 seconds...
Il Doge
—
Are you using the DMG installer or Ruby 1.8.1? BTW, it’s probably best to continue this via private mail — I’m reachable via flgr@ccan.de
—
Hi, I don’t know why continue by e-mail.
Now I have the same problem and don’t know the answer, can you post here how you resolve this?
Thank you!
Pedro Valentini
—
Pedro, I was having the same problem. I found the problem was my fault. If your problem was the same as mine, I was trying to run the breakpoint client before running my application. I found I had to put the breakpoint in my code, run the application and THEN run the breakpoint client. Hope this helps.
—
I was trying to solve this via private mail as then I would not forgot to check back to the discussion as easily. You can of course also submit this as a bug report on the ruby-breakpoint page, but I’m not trying to hide bugs or something like that, but it is hard for me to watch a page on a Wiki and I expect that it will be similar for you as well thus delaying communication even more.
For anyone with the “No connection to breakpoint service” error
For whatever reason, I could only run the breakpointer in the development environment. I don’t doubt it will run in test, but if you are looking to get to debugging quickly, try to do it from development. Follow these steps:
breakpoint
./script/server
ruby script/server
./script/breakpointer
ruby script/breakpointer
Note: you can also do this in order of steps 2, 1, 4, 3 (swap 1 & 2 or 3 & 4). If you load up the web page before starting the breakpointer it will hang and wait with an hourglass cursor until you start the breakpointer script and tell it to continue (ctrl+d)
It seems that, on OS X, the breakpoint server decides to only listen on IPv6, and the breakpoint client will only connect on IPv4. Then, when the server tries to connect back to the client, it first tries the IPv6 network address of the primary interace…
Anyway, the workaround is as follows. First:
sudo ip6 -d lo0
Then
./script/breakpointer —client-uri=druby://localhost:12345
— Pete Yandell
I am trying to use the a breakpoint in a controller but when it hits a breakpoint the app does nothing. It is during a page transition and it does not proceed to the next page, it does not bring up an irb session and it does not process anything any further. I simply hangs up the browser. I am running this on Win2000.
— Ken Fettig
The ip6 fix did not work for me on OS X. However, replacing localhost with 127.0.0.1 seems to do the trick.
./script/breakpointer -c druby://127.0.0.1:42531
— Keith Morrison
Using multiple webrick/breakpointers
We are trying to work on a linux server at different projects at the same time. We are running multiple instances of webrick using the -p option (-p3001, -p3002, …), but we can’t get breakpointer to work with the individual webrick servers. When starting multiple breakpointers, it seems that every breakpoint is picked up by a random breakpointer process. We tried using the -c and -s option, but somehow it’s not clear to us how to get things working.
Anyone knowing how to solve this problem?
Thanks!
Today we got an answer from Florian Gross!!
Basically this should work if you change the drb://-url that Rails uses to call Breakpoint.activate_drb() to a different one for each webrick server. The easiest way of doing that is to modify the BREAKPOINT_SERVER_PORT constant in your application’s environment file.
You will then need to specify the server to connect to to breakpointer via the -s option. You shouldn’t need to supply -c in this case.
Hope this helps!
Kind regards,
Florian Gross
in environment.rb:
BREAKPOINT_SERVER_PORT = 42532
in your shell:
script/breakpointer -s druby://127.0.0.1:42532
Thus, every project needs it’s own port.
— Mark de Haan
category:Howto
Bath and Shower
Fragrance
Gift Sets
Hair Care
Makeup
Men’s Grooming
Shaving and Hair Removal
Skin Care
Tools and Accessories
Baby Apparel
Baby Bathing & Skin Care
Baby Bedding
Baby Car Seats
Baby Diapering
Baby Feeding
For Moms
Baby Furniture
Baby Gear
Baby Gifts
Baby Health & Baby Care
Nursery Décor
Potty Training
Baby Safety
Baby Strollers
Books – Business & Investing
Books – Children’s Books
Books – Comics & Graphic Novels
Books – Computers & Internet
Books – Cooking, Food & Wine
Books – Entertainment
Books – Gay & Lesbian
Books – Health, Mind & Body
Books – History
Books – Home & Garden
Books – Law
Books – Literature & Fiction
Books – Medicine
Books – Mystery & Thrillers
Books – Nonfiction
Books – Outdoors & Nature
Books – Parenting & Families
Books – Professional & Technical
Books – Reference
Books – Religion & Spirituality
Books – Romance
Books – Science
Books – Science Fiction & Fantasy
Books – Sports
Books – Teens
Books – Travel
Camera & Photo – Accessories
Camera & Photo – Camcorders
Camera & Photo – Digital Cameras
Camera & Photo – Film Cameras
Camera & Photo – Optics
Camera & Photo – Printers & Scanners
Health & Personal Care – Baby & Child Care
Health & Personal Care – Food & Snacks
Health & Personal Care – Health & Personal Care Outlet Store
Health & Personal Care – Health Care
Health & Personal Care – House Supplies
Health & Personal Care – Nutrition & Fitness
Health & Personal Care – Personal Care
Health & Personal Care – Sexual Wellness
Computers – Computer Add-Ons
Computers – Desktops
Computers – Handhelds & PDAs
Computers – Notebooks
Electronics – Accessories & Supplies
Electronics – Audio & Video
Electronics – Camera & Photo
Electronics – Car Electronics
Electronics – Computers & Add-Ons
Electronics – GPS & Navigation
Electronics – Home Automation & Security
Electronics – Office Electronics
Electronics – Service & Replacement Plans
Gourmet Food – Appetizers & Hors d’oeuvres
Gourmet Food – Baking Supplies
Gourmet Food – Beverages
Gourmet Food – Bread
Gourmet Food – Breakfast Foods
Gourmet Food – Candy
Gourmet Food – Cheese
Gourmet Food – Chocolate
Gourmet Food – Coffee & Tea
Gourmet Food – Cookies
Gourmet Food – Dairy Foods & Eggs
Gourmet Food – Desserts
Gourmet Food – Fruits & Vegetables
Gourmet Food – Gourmet Gifts
Gourmet Food – Jams, Jellies & Preserves
Gourmet Food – Meat, Game & Pâtés
Gourmet Food – Oils, Vinegars & Salad Dressings
Gourmet Food – Pasta, Beans, Grains & Rice
Gourmet Food – Prepared Meals
Gourmet Food – Salsas & Condiments
Gourmet Food – Seafood & Caviar
Gourmet Food – Seasonings, Herbs & Spices
Gourmet Food – Snack Food
Gourmet Food – Soups & Stocks
Grocery – Appetizers & Hors D’Oeuvres
Grocery – Baking Supplies
Grocery – Beverages
Grocery – Boxed Meals & Side Dishes
Grocery – Breads
Grocery – Breakfast Foods
Grocery – Canned & Packaged Goods
Grocery – Coffee, Tea & Cocoa
Grocery – Condiments, Sauces & Spreads
Grocery – Dairy & Eggs
Grocery – Desserts & Pastries
Grocery – Fruits & Vegetables
Grocery – Health & Family
Grocery – Herbs, Spices & Seasonings
Grocery – Household Supplies
Grocery – Meats
Grocery – Pasta & Grains
Grocery – Pet Supplies
Grocery – Seafood
Grocery – Snacks, Cookies & Candy
Home & Garden – Backyard Birding
Home & Garden – Bar Tools & Glasses
Home & Garden – Bedding & Bath
Home & Garden – Coffee, Tea & Espresso
Home & Garden – Cook’s Tools & Gadgets
Home & Garden – Cookware & Baking
Home & Garden – Cutlery
Home & Garden – Fresh Flowers & Indoor Plants
Home & Garden – Furniture & Décor
Home & Garden – Gardening Tools
Home & Garden – Grills, Smokers & Outdoor Cooking
Home & Garden – Heating & Lighting
Home & Garden – Kitchen & Table Linens
Home & Garden – Large Appliances
Home & Garden – Leisure & Fitness
Home & Garden – Outdoor Décor
Home & Garden – Patio Furniture
Home & Garden – Pest Control
Home & Garden – Pet Supplies
Home & Garden – Plants & Planting
Home & Garden – Small Appliances
Home & Garden – Tableware
Home & Garden – Vacuums, Cleaning & Storage
Home & Garden – Weather Instruments
Home & Garden – Wine Accessories
Industrial & Scientific – Adhesive Tapes
Industrial & Scientific – Fasteners
Industrial & Scientific – Industrial Abrasives
Industrial & Scientific – Industrial Adhesives
Industrial & Scientific – Industrial Cutting Tools
Industrial & Scientific – Industrial Hoses
Industrial & Scientific – Material Handling Equipment
Industrial & Scientific – Mechanical Components
Industrial & Scientific – Precision Measurement Products
Industrial & Scientific – Raw Materials
Jewelry – Accessories
Jewelry – Body Jewelry
Jewelry – Bracelets
Jewelry – Brooches & Pins
Jewelry – Charms
Jewelry – Children’s Jewelry
Jewelry – Earrings
Jewelry – Engagement
Jewelry – Jewelry Sets
Jewelry – Men’s Jewelry
Jewelry – Necklaces & Pendants
Jewelry – Religious Jewelry
Jewelry – Rings
Jewelry – Wedding & Anniversary
Kindle Store – Advice & How-to
Kindle Store – Arts & Entertainment
Kindle Store – Biographies & Memoirs
Kindle Store – Business & Investing
Kindle Store – Children’s Chapter Books
Kindle Store – Computers & Internet
Kindle Store – Fantasy
Kindle Store – Fiction
Kindle Store – History
Kindle Store – Humor
Kindle Store – Lifestyle & Home
Kindle Store – Literary Fiction
Kindle Store – Mystery & Thrillers
Kindle Store – Nonfiction
Kindle Store – Parenting & Families
Kindle Store – Politics & Current Events
Kindle Store – Reference
Kindle Store – Religion & Spirituality
Kindle Store – Romance
Kindle Store – Science
Kindle Store – Science Fiction
Kindle Store – Sports
Kindle Store – Travel
Kitchen & Housewares – Bar Tools & Glasses
Kitchen & Housewares – Coffee, Tea & Espresso
Kitchen & Housewares – Cook’s Tools & Gadgets
Kitchen & Housewares – Cookware & Baking
Kitchen & Housewares – Cutlery
Kitchen & Housewares – Dining Room Furniture
Kitchen & Housewares – Kitchen & Table Linens
Kitchen & Housewares – Kitchen Furniture
Kitchen & Housewares – Small Appliances
Kitchen & Housewares – Storage & Organization
Kitchen & Housewares – Tableware
Kitchen & Housewares – Wine Accessories
Magazine Subscriptions – Arts & Crafts
Magazine Subscriptions – Automotive
Magazine Subscriptions – Bridal
Magazine Subscriptions – Business & Finance
Magazine Subscriptions – Children’s
Magazine Subscriptions – Computer & Internet
Magazine Subscriptions – Electronics & Audio
Magazine Subscriptions – Entertainment
Magazine Subscriptions – Family & Parenting
Magazine Subscriptions – Fashion & Style
Magazine Subscriptions – Food & Gourmet
Magazine Subscriptions – Games & Hobbies
Magazine Subscriptions – Gay & Lesbian
Magazine Subscriptions – Health & Fitness
Magazine Subscriptions – History
Magazine Subscriptions – Home & Garden
Magazine Subscriptions – International
Magazine Subscriptions – Lifestyle & Cultures
Magazine Subscriptions – Literary
Magazine Subscriptions – Men’s Interest
Magazine Subscriptions – Music
Magazine Subscriptions – News & Politics
Magazine Subscriptions – Pets
Magazine Subscriptions – Religion & Spirituality
Magazine Subscriptions – Science & Nature
Magazine Subscriptions – Sports & Leisure
Magazine Subscriptions – Teens
Magazine Subscriptions – Travel & Regional
Magazine Subscriptions – Women’s Interest
Miscellaneous – Aircraft
Miscellaneous – Antiques
Miscellaneous – Coins
Miscellaneous – Collectibles
Miscellaneous – General
Miscellaneous – Other Products
Miscellaneous – Scientific Supplies
Miscellaneous – Stamps
Miscellaneous – Vehicles
Miscellaneous – Watercraft
MP3 Downloads – MP3 Albums
MP3 Downloads – MP3 Songs
Music – Alternative Rock
Music – Blues
Music – Broadway & Vocalists
Music – Children’s Music
Music – Christian & Gospel
Music – Classic Rock
Music – Classical
Music – Country
Music – Dance & DJ
Music – Folk
Music – Hard Rock & Metal
Music – International
Music – Jazz
Music – Latin Music
Music – Miscellaneous
Music – New Age
Music – Pop
Music – R&B
Music – Rap & Hip-Hop
Music – Rock
Music – Soundtracks
Classical Music – Ballads
Classical Music – Canons
Classical Music – Concertos
Classical Music – Etudes
Classical Music – Fantasies
Classical Music – Fugues
Classical Music – Improvisation
Classical Music – Inventions
Classical Music – Lullabies & Berceuse
Classical Music – Oratorio
Classical Music – Preludes
Classical Music – Requiems, Elegies & Tombeau
Classical Music – Rondos
Classical Music – Scherzo
Classical Music – Serenades & Divertimentos
Classical Music – Short Forms
Classical Music – Sonatas
Classical Music – Suites
Classical Music – Symphonies
Classical Music – Theatrical, Incidental & Program Music
Classical Music – Toccatas
Classical Music – Variations
Musical Instruments – Band & Orchestra
Musical Instruments – Bass Guitars
Musical Instruments – DJ, Electronic Music & Karaoke
Musical Instruments – Drums & Percussion
Musical Instruments – Folk & World Instruments
Musical Instruments – Guitars
Musical Instruments – Instrument Accessories
Musical Instruments – Keyboards
Musical Instruments – Live Sound & Stage
Musical Instruments – Recording Equipment
Office Products – Business Presentation Supplies
Office Products – Educational Supplies
Office Products – Mailroom Supplies
Office Products – Office Furniture & Accessories
Office Products – Office Lighting
Office Products – Office Supplies
Cell Phones & Service – All
Cell Phones & Service – Bluetooth
Cell Phones & Service – Camera
Cell Phones & Service – E-mail
Cell Phones & Service – Flip
Cell Phones & Service – Kid’s
Cell Phones & Service – Mobile Broadband Cards
Cell Phones & Service – MP3
Cell Phones & Service – PDA
Cell Phones & Service – Prepaid
Cell Phones & Service – Video
Cell Phones & Service – Wi-Fi
Software – Business & Office
Software – Children’s Software
Software – Education & Reference
Software – Graphics
Software – Home & Hobbies
Software – Language & Travel
Software – Linux
Software – Macintosh
Software – Networking
Software – Operating Systems
Software – Outlet
Software – Personal Finance
Software – Programming
Software – Software for Handhelds
Software – Utilities
Software – Video & Music
Software – Web Development
Sports & Outdoors – Accessories
Sports & Outdoors – Airsoft
Sports & Outdoors – Apparel
Sports & Outdoors – Archery
Sports & Outdoors – Badminton
Sports & Outdoors – Ballet & Dance
Sports & Outdoors – Baseball
Sports & Outdoors – Basketball
Sports & Outdoors – Boating
Sports & Outdoors – Bowling
Sports & Outdoors – Boxing
Sports & Outdoors – Camping & Hiking
Sports & Outdoors – Cheerleading
Sports & Outdoors – Climbing
Sports & Outdoors – Crew
Sports & Outdoors – Cricket
Sports & Outdoors – Curling
Sports & Outdoors – Cycling & Wheel Sports
Sports & Outdoors – Disc Sports
Sports & Outdoors – Diving
Sports & Outdoors – Dog Sports
Sports & Outdoors – Equestrian Sports
Sports & Outdoors – Exercise & Fitness
Sports & Outdoors – Fan Shop
Sports & Outdoors – Fencing
Sports & Outdoors – Field Hockey
Sports & Outdoors – Fishing
Sports & Outdoors – Football
Sports & Outdoors – Game Room
Sports & Outdoors – Golf
Sports & Outdoors – Gymnastics
Sports & Outdoors – Hockey
Sports & Outdoors – Hunting
Sports & Outdoors – Jai Alai
Sports & Outdoors – Kayaking
Sports & Outdoors – Lacrosse
Sports & Outdoors – Lawn Games
Sports & Outdoors – Martial Arts
Sports & Outdoors – Motor Sports
Sports & Outdoors – Paddle Court Sports
Sports & Outdoors – Paintball
Sports & Outdoors – Pilates
Sports & Outdoors – Polo
Sports & Outdoors – Racquetball
Sports & Outdoors – Rodeo
Sports & Outdoors – Rugby
Sports & Outdoors – Running
Sports & Outdoors – RV Equipment
Sports & Outdoors – Scooters
Sports & Outdoors – Shoes
Sports & Outdoors – Skateboarding
Sports & Outdoors – Skating
Sports & Outdoors – Skydiving
Sports & Outdoors – Sledding
Sports & Outdoors – Snow Skiing
Sports & Outdoors – Snowboarding
Sports & Outdoors – Snowmobiling
Sports & Outdoors – Snowshoeing
Sports & Outdoors – Soccer
Sports & Outdoors – S