backtracer 0.6.5 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/backtracer +3 -4
- data/lib/backtracer.rb +41 -7
- data/lib/{backtracer_inline.rb → backtracer_code_same_line.rb} +0 -2
- data/lib/backtracer_just_code_lines.rb +5 -0
- data/lib/backtracer_locals.rb +1 -1
- data/lib/backtracer_tracer.rb +1 -1
- data/lib/backtracer_tracer_args.rb +1 -1
- data/lib/{core_backtracer.rb → core_backtracer_locals.rb} +0 -0
- data/test/test.rb +9 -0
- data/test/test2.rb +10 -0
- metadata +9 -5
- data/lib/backtracer_tracer_exception_creation.rb +0 -21
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.7.1
|
data/bin/backtracer
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
if (ARGV.include? '-h') || (ARGV.include? '--help')
|
3
|
+
if (ARGV.include? '-h') || (ARGV.include? '--help') || ARGV.length == 0
|
4
4
|
dir = File.dirname(__FILE__) + '/../lib'
|
5
5
|
puts 'options: '
|
6
6
|
for file in Dir[dir + '/backtracer_*.rb'].sort.reverse
|
7
7
|
puts '--' + File.basename(file)[11..-4] # of backtracer_locals.rb, just locals
|
8
8
|
end
|
9
|
-
puts 'ex: $ backtracer filename.rb arg1 arg2'
|
9
|
+
puts 'ex\'s:', '$ backtracer filename.rb arg1 arg2'
|
10
10
|
puts '$ backtracer --simple filename.rb arg1 arg2'
|
11
|
-
puts 'or its equivalent: $ ruby -rbacktracer_simple filename.rb arg1 arg2'
|
12
|
-
puts '$ ruby -rtracerr'
|
11
|
+
puts 'or its equivalent:', '$ ruby -rbacktracer_simple filename.rb arg1 arg2'
|
13
12
|
exit
|
14
13
|
end
|
15
14
|
|
data/lib/backtracer.rb
CHANGED
@@ -6,6 +6,7 @@ DOZE = Config::CONFIG['host_os'] =~ /mswin|mingw/
|
|
6
6
|
require File.dirname(__FILE__) + "/shared"
|
7
7
|
|
8
8
|
at_exit {
|
9
|
+
exception_that_killed_us = $!
|
9
10
|
if $! && !$!.is_a?(SystemExit) # SystemExit's are normal, not exceptional
|
10
11
|
print "\n"
|
11
12
|
print "\t" unless defined?($same_line)
|
@@ -16,7 +17,7 @@ at_exit {
|
|
16
17
|
$!.backtrace.each{|bt_line| max = [bt_line.length, max].max}
|
17
18
|
|
18
19
|
backtrace_with_code = $!.backtrace.map{ |bt_line|
|
19
|
-
next if bt_line.include? 'bin/backtracer' #
|
20
|
+
next if bt_line.include? 'bin/backtracer' # lines from ourself...
|
20
21
|
if DOZE && bt_line[1..1] == ':'
|
21
22
|
|
22
23
|
drive, file, line, junk = bt_line.split(":")
|
@@ -26,15 +27,48 @@ at_exit {
|
|
26
27
|
file, line, junk = bt_line.split(":")
|
27
28
|
end
|
28
29
|
line = line.to_i
|
29
|
-
|
30
|
-
|
31
|
-
"%-#{max + 1}s
|
32
|
-
|
30
|
+
actual_code = Tracer.get_line(file, line)
|
31
|
+
output_line = ' '
|
32
|
+
output_line += "%-#{max + 1}s " % bt_line unless $no_code_line_numbers
|
33
|
+
if actual_code && actual_code != '-'
|
34
|
+
output_line += "\n\t" unless defined?($same_line)
|
35
|
+
output_line += actual_code.strip
|
36
|
+
end
|
37
|
+
output_line
|
38
|
+
}
|
39
|
+
|
40
|
+
previous_line = nil
|
41
|
+
count = 0
|
42
|
+
|
43
|
+
backtrace_with_code = backtrace_with_code.map{|line|
|
44
|
+
if previous_line == nil
|
45
|
+
# startup
|
46
|
+
previous_line = line
|
47
|
+
line
|
48
|
+
elsif previous_line == line
|
49
|
+
# redundant line
|
50
|
+
count += 1
|
51
|
+
|
52
|
+
nil
|
53
|
+
else
|
54
|
+
# good line
|
55
|
+
previous_line = line
|
56
|
+
if count > 0
|
57
|
+
# first good line after a string of bad
|
58
|
+
a = [" (repeat #{count} times) ", line]
|
59
|
+
count = 0
|
60
|
+
a
|
61
|
+
else
|
62
|
+
line
|
63
|
+
end
|
64
|
+
end
|
65
|
+
}.flatten.compact
|
66
|
+
|
67
|
+
|
33
68
|
puts backtrace_with_code
|
34
69
|
puts # blank line
|
35
70
|
# for some reason this can be nil...
|
36
|
-
|
37
|
-
|
71
|
+
exception_that_killed_us.set_backtrace [] # avoid the original backtrace being outputted--though annoyingly it does still output its #to_s...
|
38
72
|
else
|
39
73
|
puts "(backtracer: no exception found to backtrace)" if $DEBUG
|
40
74
|
end
|
data/lib/backtracer_locals.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
# this is the default
|
2
|
-
require File.dirname(__FILE__) + '/
|
2
|
+
require File.dirname(__FILE__) + '/core_backtracer_locals.rb'
|
data/lib/backtracer_tracer.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
$print_trace = true
|
2
|
-
require File.dirname(__FILE__) + '/
|
2
|
+
require File.dirname(__FILE__) + '/core_backtracer_locals.rb'
|
File without changes
|
data/test/test.rb
ADDED
data/test/test2.rb
ADDED
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.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors: []
|
7
7
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-01-12 00:00:00 -07:00
|
13
13
|
default_executable: backtracer
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -43,17 +43,19 @@ files:
|
|
43
43
|
- examples/run_all_styles_of_backtracer.rb
|
44
44
|
- examples/run_large_style_output.rb
|
45
45
|
- lib/backtracer.rb
|
46
|
+
- lib/backtracer_code_same_line.rb
|
46
47
|
- lib/backtracer_ctrl_c_debugger.rb
|
47
|
-
- lib/
|
48
|
+
- lib/backtracer_just_code_lines.rb
|
48
49
|
- lib/backtracer_locals.rb
|
49
50
|
- lib/backtracer_pinger.rb
|
50
51
|
- lib/backtracer_simple.rb
|
51
52
|
- lib/backtracer_tracer.rb
|
52
53
|
- lib/backtracer_tracer_args.rb
|
53
|
-
- lib/
|
54
|
-
- lib/core_backtracer.rb
|
54
|
+
- lib/core_backtracer_locals.rb
|
55
55
|
- lib/shared.rb
|
56
56
|
- lib/tracerr.rb
|
57
|
+
- test/test.rb
|
58
|
+
- test/test2.rb
|
57
59
|
has_rdoc: true
|
58
60
|
homepage:
|
59
61
|
licenses: []
|
@@ -83,6 +85,8 @@ signing_key:
|
|
83
85
|
specification_version: 3
|
84
86
|
summary: Quality backtraces for ruby
|
85
87
|
test_files:
|
88
|
+
- test/test.rb
|
89
|
+
- test/test2.rb
|
86
90
|
- examples/crash.rb
|
87
91
|
- examples/crash_longer.rb
|
88
92
|
- examples/run_all_styles_of_backtracer.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'faster_rubygems'
|
2
|
-
require 'event_hook'
|
3
|
-
|
4
|
-
class Demo < EventHook
|
5
|
-
def self.process(*args)
|
6
|
-
|
7
|
-
# args => [64, #<RuntimeError: hello>, :initialize, Exception]
|
8
|
-
begin
|
9
|
-
if args[1].is_a? Exception
|
10
|
-
puts args.inspect
|
11
|
-
end
|
12
|
-
rescue
|
13
|
-
# fantastically, this check fails within rails at times
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
Demo.start_hook
|
19
|
-
|
20
|
-
# TODO 1.9 compat
|
21
|
-
#set_trace_func proc {|*args| puts args.inspect }
|