backtracer 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +48 -46
- data/VERSION +1 -1
- data/bin/backtracer +23 -6
- data/lib/backtracer.rb +3 -3
- data/lib/backtracer_ping.rb +4 -2
- data/lib/backtracer_tracer.rb +1 -1
- data/lib/core_backtracer.rb +1 -1
- metadata +3 -4
- data/bin/backtracer~ +0 -7
data/README
CHANGED
@@ -1,16 +1,25 @@
|
|
1
|
-
|
1
|
+
backtracer: ruby gem to output higher quality backtraces if an unhandled exception is thrown.
|
2
2
|
|
3
|
-
There are several options available (the more verbose ones rely on ruby-debug, which slows things down a bit).
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
If you've ever seen
|
5
|
+
...24 levels...
|
6
|
+
and disliked it, this is the gem for you.
|
7
|
+
|
8
|
+
It displays the full back trace, with or without code and/or local variables, etc.
|
9
|
+
|
10
|
+
There are several options available.
|
11
|
+
|
12
|
+
example:
|
13
|
+
|
14
|
+
a script that used to output:
|
15
|
+
|
16
|
+
>ruby crash.rb
|
8
17
|
crash.rb:2:in `go2': unhandled exception
|
9
18
|
from crash.rb:6:in `go'
|
10
19
|
from crash.rb:9
|
11
20
|
|
12
|
-
|
13
|
-
|
21
|
+
Now outputs:
|
22
|
+
>backtracer --locals crash.rb
|
14
23
|
|
15
24
|
unhandled exception: crash.rb:2: raise
|
16
25
|
locals: {"a"=>"3", "b"=>55}
|
@@ -20,7 +29,7 @@ unhandled exception: crash.rb:2: raise
|
|
20
29
|
crash.rb:5 go(a=>3)
|
21
30
|
locals: {"a"=>"3"}
|
22
31
|
or
|
23
|
-
|
32
|
+
>backtracer crash.rb
|
24
33
|
====
|
25
34
|
crash.rb:2:in `go2'
|
26
35
|
raise
|
@@ -33,78 +42,71 @@ crash.rb:2:in `go2': unhandled exception
|
|
33
42
|
from crash.rb:7:in `go'
|
34
43
|
from crash.rb:10
|
35
44
|
|
45
|
+
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.
|
36
46
|
|
37
|
-
|
38
|
-
|
47
|
+
To see all possible options run
|
48
|
+
$ backtracer -h
|
39
49
|
|
40
50
|
== Installation ==
|
41
51
|
|
42
|
-
== 1.
|
52
|
+
== 1.8.x ==
|
43
53
|
|
44
|
-
$ gem install ruby-
|
54
|
+
$ gem install ruby-debug
|
45
55
|
$ gem sources add http://gemcutter.org # if necessary
|
46
56
|
$ gem install backtracer
|
47
57
|
|
48
|
-
run
|
49
|
-
$
|
58
|
+
now run like
|
59
|
+
$ backtracer script_name
|
60
|
+
$ backtracer --locals script_name
|
50
61
|
|
51
|
-
== 1.
|
62
|
+
== 1.9.1 ==
|
52
63
|
|
53
|
-
$ gem install ruby-
|
64
|
+
$ gem install ruby-debug19 # if you want some of the more exotic backtraces
|
54
65
|
$ gem sources add http://gemcutter.org # if necessary
|
55
|
-
$ sudo gem install faster_rubygems # necessary to be able to load gems from the command line -- installs the file rubygemsf into your site_ruby
|
56
66
|
$ gem install backtracer
|
57
67
|
|
58
|
-
|
59
|
-
$ ruby -
|
60
|
-
|
61
|
-
the rubygemsf is necessary because for some reason running
|
62
|
-
$ ruby -rubygems -rbacktracer script_name
|
63
|
-
|
64
|
-
fails [probably a bug in ruby]
|
68
|
+
run as above (backtracer executable), or as a ruby require:
|
69
|
+
$ ruby -rbacktracer script_name
|
70
|
+
$ ruby -rbacktracer_locals script_name
|
65
71
|
|
66
72
|
== Descriptions ==
|
67
73
|
|
68
|
-
Try
|
69
|
-
create a file like
|
74
|
+
Try out the options:
|
75
|
+
create a file like
|
70
76
|
|
71
77
|
def go(a)
|
72
78
|
raise
|
73
79
|
end
|
74
80
|
go(3)
|
75
81
|
|
76
|
-
then run
|
82
|
+
then run backtracer against it.
|
77
83
|
|
78
|
-
|
79
|
-
outputs full backtrace with code of each line [a la Python]
|
80
|
-
ruby -rbacktracer_locals name
|
81
|
-
outputs full backtrace with local variables and parameters
|
82
|
-
ruby -rbacktracer_simple name
|
83
|
-
outputs backtrace without the ...24 levels... [yea!]
|
84
|
-
ruby -backtracer_tracer name
|
85
|
-
same as backtracer_locals except it shows traces of calls as they're made
|
84
|
+
== Other ==
|
86
85
|
|
86
|
+
Note that you can load the better backtracing capability within a script itself:
|
87
87
|
|
88
|
-
|
89
|
-
ruby -rubygemsf -rbacktracer name
|
90
|
-
etc.
|
88
|
+
require 'backtracer'
|
91
89
|
|
90
|
+
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.
|
92
91
|
|
93
|
-
|
92
|
+
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).
|
93
|
+
Here's how:
|
94
|
+
1.9:
|
94
95
|
|
95
|
-
|
96
|
-
require 'backtracer'
|
96
|
+
$ export RUBYOPT=-rbacktracer
|
97
97
|
|
98
|
-
|
98
|
+
1.8.7:
|
99
|
+
you'll need to install a helper loader since gems can't load on the command line for some reason.
|
99
100
|
|
100
|
-
|
101
|
-
$ export RUBYOPT
|
101
|
+
$ sudo gem install faster_rubygems # the helper--installs faster_rubygems.rb and some other files to your site_ruby
|
102
|
+
$ export RUBYOPT='-rfaster_rubygems -rbacktracer'
|
102
103
|
|
103
|
-
|
104
|
+
Enjoy.
|
104
105
|
|
105
106
|
== Related projects ==
|
106
107
|
unroller, http://eigenclass.org/hiki/method+arguments+via+introspection, liveconsole, ruby-debug
|
107
108
|
|
108
|
-
Comments welcome
|
109
|
+
Comments welcome
|
110
|
+
rdp on github.
|
109
111
|
|
110
112
|
http://github.com/rdp/backtracer
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/bin/backtracer
CHANGED
@@ -1,10 +1,27 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# gems will fill this in for me
|
3
2
|
|
4
|
-
if
|
3
|
+
if (ARGV.include? '-h') || (ARGV.include? '--help')
|
5
4
|
dir = File.dirname(__FILE__) + '/../lib'
|
6
|
-
puts 'options:
|
7
|
-
for file in Dir[dir + '
|
8
|
-
puts File.basename(file)
|
5
|
+
puts 'options: '
|
6
|
+
for file in Dir[dir + '/backtracer_*.rb']
|
7
|
+
puts '--' + File.basename(file)[11..-4] # of backtracer_locals.rb, just locals
|
9
8
|
end
|
10
|
-
|
9
|
+
puts 'ex: $ backtracer filename.rb arg1 arg2'
|
10
|
+
puts 'ex: $ backtracer --simple filename.rb arg1 arg2'
|
11
|
+
puts 'you can also do $ ruby -rtracerr for an improved tracer (though 1.9.2 has the same already patched)'
|
12
|
+
exit
|
13
|
+
end
|
14
|
+
|
15
|
+
# expect
|
16
|
+
# backtracer --plain --simple filename options
|
17
|
+
|
18
|
+
if ARGV[0][0..1] == '--'
|
19
|
+
require 'backtracer_' + ARGV[0][2..-1] # take it off, too
|
20
|
+
ARGV.shift
|
21
|
+
else
|
22
|
+
require 'backtracer'
|
23
|
+
end
|
24
|
+
|
25
|
+
$0 = File.expand_path ARGV[0] # for their benefit :)
|
26
|
+
ARGV.shift
|
27
|
+
load $0
|
data/lib/backtracer.rb
CHANGED
@@ -4,8 +4,8 @@ require File.dirname(__FILE__) + "/shared"
|
|
4
4
|
require 'sane'
|
5
5
|
|
6
6
|
at_exit {
|
7
|
-
if $!
|
8
|
-
puts "==== "
|
7
|
+
if $! && !$!.is_a?(SystemExit) # SystemExit's are just normal, not exceptional
|
8
|
+
puts "==== ", $!.inspect + ' ' + $!.to_s
|
9
9
|
bt2 = $!.backtrace
|
10
10
|
backtrace_with_code = $!.backtrace.map{ |bt_line|
|
11
11
|
if OS.windows? && bt_line[1..1] == ':'
|
@@ -23,7 +23,7 @@ at_exit {
|
|
23
23
|
puts backtrace_with_code
|
24
24
|
puts "===="
|
25
25
|
else
|
26
|
-
puts "(no exception found to backtrace)"
|
26
|
+
puts "(no exception found to backtrace)" if $VERBOSE
|
27
27
|
end
|
28
28
|
# exit! TODO I guess do this once ours isn't *so* ugly
|
29
29
|
# TODO compare with that fella xray
|
data/lib/backtracer_ping.rb
CHANGED
@@ -39,10 +39,12 @@ time = 1 if $0 == __FILE__
|
|
39
39
|
Thread.new {
|
40
40
|
loop {
|
41
41
|
sleep time
|
42
|
-
pp fella.call
|
42
|
+
pp 'current stack trace', Time.now, fella.call
|
43
43
|
}
|
44
44
|
}
|
45
45
|
|
46
|
-
|
46
|
+
require File.dirname(__FILE__) + '/backtracer' # we want the normal backtracer, too
|
47
|
+
|
48
|
+
if $0 == __FILE__ # i.e. a test
|
47
49
|
sleep
|
48
50
|
end
|
data/lib/backtracer_tracer.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
1
|
+
$print_trace = true
|
2
2
|
require File.dirname(__FILE__) + '/core_backtracer.rb'
|
data/lib/core_backtracer.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backtracer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors: []
|
7
7
|
|
@@ -9,8 +9,8 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
13
|
-
default_executable:
|
12
|
+
date: 2009-11-10 00:00:00 -07:00
|
13
|
+
default_executable: backtracer
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sane
|
@@ -36,7 +36,6 @@ description: Quality backtraces for ruby
|
|
36
36
|
email: rogerdpack@gmail.com
|
37
37
|
executables:
|
38
38
|
- backtracer
|
39
|
-
- backtracer~
|
40
39
|
extensions: []
|
41
40
|
|
42
41
|
extra_rdoc_files:
|