README in backtracer-0.4.1 vs README in backtracer-0.5.0

- old
+ new

@@ -1,112 +1,117 @@ -backtracer: ruby gem to output higher quality backtraces if an unhandled exception is thrown. +backtracer: gem to output higher quality backtraces if an unhandled exception occurs. If you've ever seen ...24 levels... and disliked it, this is the gem for you. -It displays the full back trace, with or without code and/or local variables, etc. +If you've ever wished an exception printout would display the code of the lines in a backtrace (a la Python), this is for you. -There are several options available. +It displays the full back trace (no ...'s), along with the code from each line! It can even display local variables at each level of the call stack, if desired. -example: +Examples: -a script that used to output: - ->ruby crash.rb +a script that once output: +$ ruby crash.rb crash.rb:2:in `go2': unhandled exception from crash.rb:6:in `go' from crash.rb:9 Now outputs: ->backtracer --locals crash.rb +$ backtracer crash.rb + + RuntimeError +crash.rb:2:in `go2' + raise +crash.rb:7:in `go' + go2(a, 55) +crash.rb:10 + go '3' + + +(Note--has the code lines, and if there had been ...'s, would have ovecome them). + +or the --locals option + +$backtracer --locals crash.rb + unhandled exception: crash.rb:2: raise locals: {"a"=>"3", "b"=>55} from: crash.rb:1 go2(a=>3, b=>55) locals: {"a"=>"3", "b"=>55} crash.rb:5 go(a=>3) locals: {"a"=>"3"} -or ->backtracer crash.rb -==== -crash.rb:2:in `go2' - raise -crash.rb:7:in `go' - go2(a, 55) -crash.rb:10 - go '3' -==== -crash.rb:2:in `go2': unhandled exception - from crash.rb:7:in `go' - from crash.rb:10 -Also included is a --ping option which periodically dumps the current running threads' backtrace(s)--quite useful for figuring out where you code is spending a lot of its time. +(displays locals, parameters kind of) -To see all possible options run +Also included is a --ping option, which periodically dumps current threads' backtrace(s)--quite useful for profiling to see where you code is spending a lot of its time (thanks xray gem!). There is also an option that will print out thread dumps whenever you hit ctrl+c. + +To see all possible backtrace options run $ backtracer -h +or +$ backtracer --help + +More example outputs: + +http://github.com/rdp/backtracer/blob/master/examples/example_test_all_output +http://github.com/rdp/backtracer/blob/master/examples/example_test_large_output +http://github.com/rdp/backtracer/blob/master/examples/pinger_example + == Installation == == 1.8.x == -$ gem install ruby-debug -$ gem sources add http://gemcutter.org # if necessary +$ gem install ruby-debug # only necessary for the --locals option +$ gem install jeweler && jeweler tumble # if necessary $ gem install backtracer now run like -$ backtracer script_name -$ backtracer --locals script_name +$ backtracer script_name.rb +$ backtracer --locals script_name.rb arg1 arg2 + == 1.9.1 == -$ gem install ruby-debug19 # if you want some of the more exotic backtraces -$ gem sources add http://gemcutter.org # if necessary +$ gem install ruby-debug19 # only necessary for the --locals option +$ gem install jeweler && jeweler tumble # if necessary $ gem install backtracer run as above (backtracer executable), or as a ruby require: $ ruby -rbacktracer script_name $ ruby -rbacktracer_locals script_name -== Descriptions == - -Try out the options: -create a file like - - def go(a) - raise - end - go(3) - -then run backtracer against it. - == Other == -Note that you can load the better backtracing capability within a script itself: +Note that you can load backtracing capability within a script itself by: require 'backtracer' -will cause it to output a coded backtrace at exit time, if an unhandled exception occurs. Backtracer default and backtracer_simple don't cause runtime slowdown. +which will cause it to output a coded backtrace at exit time, if an unhandled exception occurs. Backtracer default and backtracer_simple don't cause runtime slowdown, so sometimes you just want to add this by default. If so, then add it to your RUBYOPT variable. (Once I did this, I wondered why I would ever want anything else). Here's how: -You can also add it to your RUBYOPT variable if you always want it to run against all scripts (backtracer_simple and backtracer don't cause any slowdowns). -Here's how: 1.9: $ export RUBYOPT=-rbacktracer +or +$ export RUBYOPT=-rbacktracer_simple # or whichever one you want -1.8.7: -you'll need to install a helper loader since gems can't load on the command line for some reason. +1.8: -$ sudo gem install faster_rubygems # the helper--installs faster_rubygems.rb and some other files to your site_ruby +you'll need to install a helper gem since rubygems can't load both itself and a gem on the command line for some reason. + +$ sudo gem install faster_rubygems # the helper--installs faster_rubygems.rb and some other files to your site_ruby dir $ export RUBYOPT='-rfaster_rubygems -rbacktracer' +or +$ export RUBYOPT='-rfaster_rubygems -rbacktracer_simple' Enjoy. -== Related projects == -unroller, http://eigenclass.org/hiki/method+arguments+via+introspection, liveconsole, ruby-debug +== Other related projects == -Comments welcome -rdp on github. +unroller, http://eigenclass.org/hiki/method+arguments+via+introspection, liveconsole, ruby-debug (thanks guys!) + +Comments welcome. http://github.com/rdp/backtracer \ No newline at end of file