Permalink
Browse files

remove sane dependency

  • Loading branch information...
1 parent 6b761b7 commit ec2e4ffc54690efce2b5a3ea185af743c57172c8 @rdp committed Nov 11, 2009
View
@@ -1,16 +1,15 @@
-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 the code from each line! It can even display local variables at each level of the call stack, if desired.
+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 once output:
-
$ ruby crash.rb
crash.rb:2:in `go2': unhandled exception
from crash.rb:6:in `go'
@@ -28,9 +27,13 @@ crash.rb:7:in `go'
crash.rb:10
go '3'
-or outputs
->backtracer --locals crash.rb
+(has the code lines, and if there had been ...'s, would have ovecome them).
+
+or
+
+$backtracer --locals crash.rb
+
unhandled exception: crash.rb:2: raise
locals: {"a"=>"3", "b"=>55}
from:
@@ -39,13 +42,20 @@ unhandled exception: crash.rb:2: raise
crash.rb:5 go(a=>3)
locals: {"a"=>"3"}
+(displays locals, parameters)
To see all possible backtrace options run
$ backtracer -h
or
$ backtracer --help
-Also included is an option --ping, which periodically dumps the current threads' backtrace(s)--quite useful for profiling to easily see where you code is spending a lot of its time. There is also another option to it that will print out thread dumps whenever you hit ctrl+c.
+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 another option that will print out thread dumps whenever you hit ctrl+c.
+
+More examples
+
+http://github.com/rdp/backtracer/blob/master/examples/example_test_all_output
+http://github.com/rdp/backtracer/blob/master/examples/example_test_large_output
+
== Installation ==
@@ -71,51 +81,35 @@ 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 [--xxx] 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:
-you'll need to install a helper loader gem since rubygems can't load itself and a gem on the command line for some reason. Here's how:
+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 # helper--installs faster_rubygems.rb and some other files to your site_ruby dir
+$ 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 ==
+
+unroller, http://eigenclass.org/hiki/method+arguments+via+introspection, liveconsole, ruby-debug (thanks guys!)
-Comments welcome
-rdp on github.
+Comments welcome.
http://github.com/rdp/backtracer
View
@@ -7,7 +7,6 @@ begin
# gemspec.homepage = "http://github.com/technicalpickles/the-perfect-gem"
# gemspec.description = "TODO"
# gemspec.authors = ["Josh Nichols"]
- gemspec.add_dependency 'sane', '>= 0.9.1'
gemspec.add_dependency 'xray'
end
rescue LoadError
@@ -1,42 +1,45 @@
-ruby 1.8.6 (2009-3-4 mbari 8B/0x8770 on patchlevel 287) [i686-linux]
-#0:crash.rb:1::-: def go2(a, b)
- |#0:crash.rb:1:Module:>: def go2(a, b)
-args were []
-#0:crash.rb:1:Module:<: def go2(a, b)
-#0:crash.rb:5::-: def go(a);
- |#0:crash.rb:5:Module:>: def go(a);
-args were []
-#0:crash.rb:5:Module:<: def go(a);
-#0:crash.rb:9::-: go '3'
- |#0:crash.rb:5:Object:>: def go(a);
-args were [["a", "3"]]
- |#0:crash.rb:6:Object:-: go2(a, 55);
- | |#0:crash.rb:1:Object:>: def go2(a, b)
-args were [["a", "3"], ["b", 55]]
- | |#0:crash.rb:2:Object:-: raise
- | | |#0:crash.rb:2:Kernel:>: raise
-args were []
- | | | |#0:crash.rb:2:Class:>: raise
-args were []
- | | | | |#0:crash.rb:2:Exception:>: raise
-args were []
- | | | |#0:crash.rb:2:Exception:<: raise
- | | |#0:crash.rb:2:Class:<: raise
- | | | |#0:crash.rb:2:Exception:>: raise
-args were []
- | | |#0:crash.rb:2:Exception:<: raise
- | | | |#0:crash.rb:2:Exception:>: raise
-args were []
- | | |#0:crash.rb:2:Exception:<: raise
- | | |#0:crash.rb:2:Object:R: raise
- | |#0:crash.rb:2:Kernel:<: raise
- |#0:crash.rb:3:Object:<: end
-#0:crash.rb:7:Object:<: end
-
-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"}
+running
+ruby -v -r../lib/backtracer_locals.rb crash.rb
+ruby 1.8.6 (2009-03-31 patchlevel 368) [i386-mingw32]
+#0:crash.rb:1::-: def go2(a, b)
+ |#0:crash.rb:1:Module:>: def go2(a, b)
+args were []
+#0:crash.rb:1:Module:<: def go2(a, b)
+#0:crash.rb:5::-: def go(a)
+ |#0:crash.rb:5:Module:>: def go(a)
+args were []
+#0:crash.rb:5:Module:<: def go(a)
+#0:crash.rb:10::-: go '3'
+ |#0:crash.rb:5:Object:>: def go(a)
+args were [["a", "3"]]
+ |#0:crash.rb:6:Object:-: b = 3
+ |#0:crash.rb:7:Object:-: go2(a, 55)
+ | |#0:crash.rb:1:Object:>: def go2(a, b)
+args were [["a", "3"], ["b", 55]]
+ | |#0:crash.rb:2:Object:-: raise
+ | | |#0:crash.rb:2:Kernel:>: raise
+args were []
+ | | | |#0:crash.rb:2:Class:>: raise
+args were []
+ | | | | |#0:crash.rb:2:Exception:>: raise
+args were []
+ | | | |#0:crash.rb:2:Exception:<: raise
+ | | |#0:crash.rb:2:Class:<: raise
+ | | | |#0:crash.rb:2:Exception:>: raise
+args were []
+ | | |#0:crash.rb:2:Exception:<: raise
+ | | | |#0:crash.rb:2:Exception:>: raise
+args were []
+ | | |#0:crash.rb:2:Exception:<: raise
+ | | |#0:crash.rb:2:Object:R: raise
+ | |#0:crash.rb:2:Kernel:<: raise
+ |#0:crash.rb:3:Object:<: end
+#0:crash.rb:6:Object:<: b = 3
+
+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", "b"=>3}
@@ -0,0 +1,30 @@
+
+C:\dev\ruby\old\backtracer\examples>backtracer --pinger sleeper.rb
+c:/ruby18/lib/ruby/gems/1.8/gems/backtracer-0.4.1/lib/backtracer.rb:3: warning: already initialized constant WINDOZE
+All threads:[#<Thread:0x3411420 run>, #<Thread:0x28b5580 run>]
+Current thread:#<Thread:0x28b5580>
+C:/dev/ruby/old/backtracer/examples/sleeper.rb:2:in `call'
+C:/dev/ruby/old/backtracer/examples/sleeper.rb:2:in `sleep'
+C:/dev/ruby/old/backtracer/examples/sleeper.rb:2:in `go'
+C:/dev/ruby/old/backtracer/examples/sleeper.rb:4
+c:/ruby18/lib/ruby/gems/1.8/gems/backtracer-0.4.1/bin/backtracer:29:in `load'
+c:/ruby18/lib/ruby/gems/1.8/gems/backtracer-0.4.1/bin/backtracer:29
+c:/ruby18/bin/backtracer:19:in `load'
+c:/ruby18/bin/backtracer:19
+"current stack trace"
+Wed Nov 11 10:57:52 -0700 2009
+1
+All threads:[#<Thread:0x3411420 run>, #<Thread:0x28b5580 run>]
+Current thread:#<Thread:0x28b5580>
+C:/dev/ruby/old/backtracer/examples/sleeper.rb:2:in `call'
+C:/dev/ruby/old/backtracer/examples/sleeper.rb:2:in `sleep'
+C:/dev/ruby/old/backtracer/examples/sleeper.rb:2:in `go'
+C:/dev/ruby/old/backtracer/examples/sleeper.rb:4
+c:/ruby18/lib/ruby/gems/1.8/gems/backtracer-0.4.1/bin/backtracer:29:in `load'
+c:/ruby18/lib/ruby/gems/1.8/gems/backtracer-0.4.1/bin/backtracer:29
+c:/ruby18/bin/backtracer:19:in `load'
+c:/ruby18/bin/backtracer:19
+"current stack trace"
+Wed Nov 11 10:57:57 -0700 2009
+1
+C:\>
@@ -1 +1,3 @@
-system "ruby -v -r../lib/backtrace_with_code_and_locals.rb crash.rb"
+command = "ruby -v -r../lib/backtracer_locals.rb crash.rb"
+puts 'running', command
+system command
View
@@ -1,15 +1,15 @@
# this one display full BT with code, at the end [no performance loss]
+require 'rbconfig'
+WINDOZE = Config::CONFIG['host_os'] =~ /mswin|mingw/
require File.dirname(__FILE__) + "/shared"
-gem 'sane', '0.9.1'
-require 'sane/os'
at_exit {
if $! && !$!.is_a?(SystemExit) # SystemExit's are normal, not exceptional
puts "\n " + $!.inspect + ' ' + $!.to_s
bt2 = $!.backtrace
backtrace_with_code = $!.backtrace.map{ |bt_line|
- if OS.windows? && bt_line[1..1] == ':'
+ if WINDOZE && bt_line[1..1] == ':'
drive, file, line, junk = bt_line.split(":")
#["C", "/dev/ruby/allgems/lib/allgems/GemWorker.rb", "91", "in `unpack'"]
@@ -1,6 +1,9 @@
require 'pp'
-gem 'sane', '0.9.1'
-require 'sane/os'
+
+
+require 'rbconfig'
+WINDOZE = Config::CONFIG['host_os'] =~ /mswin|mingw/
+
def xray
require 'xray'
@@ -25,8 +28,7 @@ def xray
end
else
# weak sauce for the old school users :)
- if OS.windows?
-
+ if WINDOZE
trap("ILL") { puts "All threads:" + Thread.list.inspect, "Current thread:" + Thread.current.to_s, caller } # puts current thread caller
fella = proc { Process.kill "ILL", Process.pid } # send myself a signal
else
@@ -7,8 +7,8 @@
require 'rubygems'
require 'ruby-debug'
Debugger.start # we use this to track args.
+$print_trace = nil unless defined?($print_trace) # avoid warnings
-#Debugger.keep_frame_binding = true # whatever this did :P
#
# tracer main class
#

0 comments on commit ec2e4ff

Please sign in to comment.