mame-prettytrace 0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +3 -0
- data/Manifest.txt +5 -0
- data/README.txt +34 -0
- data/Rakefile +12 -0
- data/lib/prettytrace.rb +50 -0
- metadata +69 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
= prettytrace
|
|
2
|
+
|
|
3
|
+
* http://github.com/mame/prettytrace/tree/master
|
|
4
|
+
|
|
5
|
+
== DESCRIPTION:
|
|
6
|
+
|
|
7
|
+
prettytrace detects and omits repetition of backtrace, which makes
|
|
8
|
+
backtrace shorter and smarter.
|
|
9
|
+
|
|
10
|
+
== FEATURES/PROBLEMS:
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
== SYNOPSIS:
|
|
14
|
+
|
|
15
|
+
$ ruby -rprettytrace -e 'def foo; foo; end; foo'
|
|
16
|
+
-e:1:in `foo': stack level too deep (SystemStackError)
|
|
17
|
+
from -e:1:in `foo'
|
|
18
|
+
from -e:1:in `foo'
|
|
19
|
+
(repeat the above lines 8000 times)
|
|
20
|
+
from -e:1:in `foo'
|
|
21
|
+
from -e:1:in `<main>'
|
|
22
|
+
|
|
23
|
+
== REQUIREMENTS:
|
|
24
|
+
|
|
25
|
+
None
|
|
26
|
+
|
|
27
|
+
== INSTALL:
|
|
28
|
+
|
|
29
|
+
* gem install mame-prettytrace
|
|
30
|
+
|
|
31
|
+
== LICENSE:
|
|
32
|
+
|
|
33
|
+
Copyright (c) 2009 Yusuke Endoh <mame@tsg.ne.jp>
|
|
34
|
+
License: Ruby's
|
data/Rakefile
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# -*- ruby -*-
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'hoe'
|
|
5
|
+
require './lib/prettytrace.rb'
|
|
6
|
+
|
|
7
|
+
Hoe.new('prettytrace', Prettytrace::VERSION) do |p|
|
|
8
|
+
p.rubyforge_name = 'prettytrace' # if different than lowercase project name
|
|
9
|
+
p.developer('Yusuke Endoh', 'mame@tsg.ne.jp')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# vim: syntax=Ruby
|
data/lib/prettytrace.rb
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
class Prettytrace
|
|
2
|
+
VERSION = '0.10'
|
|
3
|
+
|
|
4
|
+
END {
|
|
5
|
+
# do nothing at normal exit
|
|
6
|
+
next unless $!
|
|
7
|
+
|
|
8
|
+
msg, exc, bt = $!.message, $!.class, $!.backtrace.dup
|
|
9
|
+
|
|
10
|
+
# print an error message
|
|
11
|
+
msg = case
|
|
12
|
+
when msg.empty? && exc == RuntimeError then "unhandled exception"
|
|
13
|
+
when msg.empty? then exc.to_s
|
|
14
|
+
else "%s (%p)" % [msg, exc]
|
|
15
|
+
end
|
|
16
|
+
puts "#{ bt.shift }: #{ msg }"
|
|
17
|
+
|
|
18
|
+
# detect repetations and build backtrace
|
|
19
|
+
hash = {}
|
|
20
|
+
str = bt.map {|ent| hash[ent] ||= hash.size }.reverse.pack("v*")
|
|
21
|
+
buf = []
|
|
22
|
+
while str[/^((?:..)*?)((?:..)+?)(\2{10,})/m]
|
|
23
|
+
left, fragment = [$1, $2].map {|s| s.unpack("v*") }
|
|
24
|
+
buf.concat(left).concat(fragment)
|
|
25
|
+
buf << [($3.bytesize / 2) / fragment.size - 1, fragment. reverse]
|
|
26
|
+
buf.concat(fragment)
|
|
27
|
+
str = $'
|
|
28
|
+
end
|
|
29
|
+
buf.concat(str.unpack("v*"))
|
|
30
|
+
|
|
31
|
+
# print backtrace
|
|
32
|
+
hash = hash.invert
|
|
33
|
+
buf.reverse_each do |ent|
|
|
34
|
+
if ent.is_a?(Array)
|
|
35
|
+
# repetition part
|
|
36
|
+
num, fragment = ent
|
|
37
|
+
fragment.each do |ent|
|
|
38
|
+
puts "\t from #{ hash[ent] }"
|
|
39
|
+
end
|
|
40
|
+
s = fragment.size > 1 ? "s" : ""
|
|
41
|
+
puts "\t (repeat the above line#{ s } #{ num } times)"
|
|
42
|
+
else
|
|
43
|
+
puts "\tfrom #{ hash[ent] }"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# suppress an original error print
|
|
48
|
+
exit!
|
|
49
|
+
}
|
|
50
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: mame-prettytrace
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: "0.10"
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Yusuke Endoh
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2009-01-01 00:00:00 -08:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: hoe
|
|
17
|
+
version_requirement:
|
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
19
|
+
requirements:
|
|
20
|
+
- - ">="
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: 1.8.2
|
|
23
|
+
version:
|
|
24
|
+
description: prettytrace detects and omits repetition of backtrace, which makes backtrace shorter and smarter.
|
|
25
|
+
email:
|
|
26
|
+
- mame@tsg.ne.jp
|
|
27
|
+
executables: []
|
|
28
|
+
|
|
29
|
+
extensions: []
|
|
30
|
+
|
|
31
|
+
extra_rdoc_files:
|
|
32
|
+
- History.txt
|
|
33
|
+
- Manifest.txt
|
|
34
|
+
- README.txt
|
|
35
|
+
files:
|
|
36
|
+
- History.txt
|
|
37
|
+
- Manifest.txt
|
|
38
|
+
- README.txt
|
|
39
|
+
- Rakefile
|
|
40
|
+
- lib/prettytrace.rb
|
|
41
|
+
has_rdoc: true
|
|
42
|
+
homepage: http://github.com/mame/prettytrace/tree/master
|
|
43
|
+
post_install_message:
|
|
44
|
+
rdoc_options:
|
|
45
|
+
- --main
|
|
46
|
+
- README.txt
|
|
47
|
+
require_paths:
|
|
48
|
+
- lib
|
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: "0"
|
|
54
|
+
version:
|
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - ">="
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: "0"
|
|
60
|
+
version:
|
|
61
|
+
requirements: []
|
|
62
|
+
|
|
63
|
+
rubyforge_project: prettytrace
|
|
64
|
+
rubygems_version: 1.2.0
|
|
65
|
+
signing_key:
|
|
66
|
+
specification_version: 2
|
|
67
|
+
summary: prettytrace detects and omits repetition of backtrace, which makes backtrace shorter and smarter.
|
|
68
|
+
test_files: []
|
|
69
|
+
|