NOTES:- Things of interest :
local_variables, instance_variables, caller, methods - Keep a close eye on the prompt. A * means breakpointer (irb really) expects you to enter more ruby code since it senses that the code entered so far is not fully valid yet.
- breakpointer (irb really) will by default print the return value to the irb console. You can explicitly return false to disable printing of large datasets.
breakpointer> @copy = @huge_dataset; false
For regular irb (and script/console) setting conf.return_format allows you to limit what is printed, but conf object doesn't seem to exist in breakpointer's irb session.
How do you print out variable values?puts doesn't work :)
Update: It actually prints the output along with the script/server output.
You can use @logger.info etc which will print the info to development.log
Local variables I put a breakpoint in a helper method and tried to view some local variables defined in the helper method, but it didn't work.
breakpoint> local_variables
=> ["id", "block", "_"]
(note that I cleaned the irb prompt and replaced it with breakpoint for blogging)
The reason is breakpoint drops me in the breakpoint.rb's breakpoint method.
breakpoint> caller
=> ["/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/breakpoint.rb:512:in `breakpoint'", "/usr/local/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/breakpoint.rb:512:in `breakpoint'", "script/../...
Now to figure out how we pop the stack back up so we end up in the method. Anyone know?
Printing Huge datasets
Suppose I am debugging some calculations I am doing on a hude dataset in breakpointer:
breakpoint> @huge_dataset
This will print the entire dataset. Ctrl-C will stop the display.
breakpoint> @huge_dataset;
This doesn't print the dataset.
So how is one to print the dataset. One solution is to use
to_yaml.
breakpoint> fh = File.open("/tmp/foo", "w");
breakpoint> fh.puts(@huge_dataset.to_yaml)
=> nil
breakpoint>
I would really like to print the value in the breakpointer's irb console though.
Is there a special console object that I can target?
Update: Another way to debug your rails app -
ruby-debug