backtracer 0.7.1 → 0.7.2

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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/backtracer_pinger.rb +10 -7
  3. metadata +2 -3
  4. data/lib/tracerr.rb +0 -168
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.1
1
+ 0.7.2
@@ -1,16 +1,19 @@
1
1
  require 'pp'
2
+ WINDOZE = (ENV['OS'] == 'Windows_NT')
2
3
 
3
-
4
- require 'rbconfig'
5
- WINDOZE = Config::CONFIG['host_os'] =~ /mswin|mingw/
6
-
4
+ if WINDOZE && RUBY_VERSION >= '1.9'
5
+ raise 'not supported on doze 1.9 yet'
6
+ end
7
7
 
8
8
  def xray
9
+ # unfortunately xray is linux only I think...
10
+ # it's not all that, anyway...
9
11
  require 'xray'
10
12
  proc { Process.kill "QUIT", Process.pid; '' }
11
13
  end
12
14
 
13
15
  if Thread.current.respond_to? :backtrace
16
+ # 1.9.2
14
17
  fella = proc {
15
18
  out = {}
16
19
  Thread.list.each{|t|
@@ -19,7 +22,7 @@ if Thread.current.respond_to? :backtrace
19
22
  out
20
23
  }
21
24
  elsif respond_to? :caller_for_all_threads
22
- if OS.windows?
25
+ if WINDOZE
23
26
  fella = proc {
24
27
  caller_for_all_threads
25
28
  }
@@ -29,8 +32,8 @@ elsif respond_to? :caller_for_all_threads
29
32
  else
30
33
  # weak sauce for the old school users :)
31
34
  if WINDOZE
32
- trap("ILL") { puts "All threads:" + Thread.list.inspect, "Current thread:" + Thread.current.to_s, caller } # puts current thread caller
33
- fella = proc { Process.kill "ILL", Process.pid } # send myself a signal
35
+ trap("TERM") { puts "All threads:" + Thread.list.inspect, "Current thread:" + Thread.current.to_s, caller } # puts current thread caller
36
+ fella = proc { Process.kill "TERM", Process.pid } # send myself a signal
34
37
  else
35
38
  fella = xray
36
39
  end
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.7.1
4
+ version: 0.7.2
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: 2010-01-12 00:00:00 -07:00
12
+ date: 2010-01-14 00:00:00 -07:00
13
13
  default_executable: backtracer
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -53,7 +53,6 @@ files:
53
53
  - lib/backtracer_tracer_args.rb
54
54
  - lib/core_backtracer_locals.rb
55
55
  - lib/shared.rb
56
- - lib/tracerr.rb
57
56
  - test/test.rb
58
57
  - test/test2.rb
59
58
  has_rdoc: true
@@ -1,168 +0,0 @@
1
- #
2
- # tracer.rb -
3
- # $Release Version: 0.2$
4
- # $Revision: 1.8 $
5
- # $Date: 1998/05/19 03:42:49 $
6
- # by Keiju ISHITSUKA(Nippon Rational Inc.)
7
- #
8
- # --
9
- #
10
- #
11
- #
12
-
13
- #
14
- # tracer main class
15
- #
16
- class Tracer
17
- @RCS_ID='-$Id: tracer.rb,v 1.8 1998/05/19 03:42:49 keiju Exp keiju $-'
18
-
19
- @stdout = STDOUT
20
- @verbose = false
21
- class << self
22
- attr :verbose, true
23
- alias verbose? verbose
24
- attr :stdout, true
25
- end
26
-
27
- EVENT_SYMBOL = {
28
- "line" => "-",
29
- "call" => ">",
30
- "return" => "<",
31
- "class" => "C",
32
- "end" => "E",
33
- "c-call" => ">",
34
- "c-return" => "<",
35
- }
36
-
37
- def initialize
38
- @threads = Hash.new
39
- if defined? Thread.main
40
- @threads[Thread.main.object_id] = 0
41
- else
42
- @threads[Thread.current.object_id] = 0
43
- end
44
-
45
- @get_line_procs = {}
46
-
47
- @filters = []
48
- end
49
-
50
- def stdout
51
- Tracer.stdout
52
- end
53
-
54
- def on
55
- if block_given?
56
- on
57
- begin
58
- yield
59
- ensure
60
- off
61
- end
62
- else
63
- set_trace_func method(:trace_func).to_proc
64
- stdout.print "Trace on\n" if Tracer.verbose?
65
- end
66
- end
67
-
68
- def off
69
- set_trace_func nil
70
- stdout.print "Trace off\n" if Tracer.verbose?
71
- end
72
-
73
- def add_filter(p = proc)
74
- @filters.push p
75
- end
76
-
77
- def set_get_line_procs(file, p = proc)
78
- @get_line_procs[file] = p
79
- end
80
-
81
- def get_line(file, line)
82
- if p = @get_line_procs[file]
83
- return p.call(line)
84
- end
85
-
86
- unless list = SCRIPT_LINES__[file]
87
- begin
88
- raise 'binary file' if file =~ /\.so$/
89
- f = open(file)
90
- begin
91
- SCRIPT_LINES__[file] = list = f.readlines
92
- ensure
93
- f.close
94
- end
95
- rescue
96
- SCRIPT_LINES__[file] = list = []
97
- end
98
- end
99
-
100
- if l = list[line - 1]
101
- l
102
- else
103
- "-\n"
104
- end
105
- end
106
-
107
- def get_thread_no
108
- if no = @threads[Thread.current.object_id]
109
- no
110
- else
111
- @threads[Thread.current.object_id] = @threads.size
112
- end
113
- end
114
-
115
- def trace_func(event, file, line, id, binding, klass, *)
116
- return if file == __FILE__
117
-
118
- for p in @filters
119
- return unless p.call event, file, line, id, binding, klass
120
- end
121
-
122
- (saved_crit = Thread.critical) rescue nil
123
- (Thread.critical = true) rescue nil
124
- stdout.printf("#%d:%s:%d:%s:%s: %s",
125
- get_thread_no,
126
- file,
127
- line,
128
- klass || '',
129
- EVENT_SYMBOL[event],
130
- get_line(file, line))
131
- (Thread.critical = saved_crit) rescue nil
132
- end
133
-
134
- Single = new
135
- def Tracer.on
136
- if block_given?
137
- Single.on{yield}
138
- else
139
- Single.on
140
- end
141
- end
142
-
143
- def Tracer.off
144
- Single.off
145
- end
146
-
147
- def Tracer.set_get_line_procs(file_name, p = proc)
148
- Single.set_get_line_procs(file_name, p)
149
- end
150
-
151
- def Tracer.add_filter(p = proc)
152
- Single.add_filter(p)
153
- end
154
-
155
- end
156
-
157
- SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
158
- puts caller(0).size
159
- if $0 == __FILE__
160
- # direct call
161
-
162
- $0 = ARGV[0]
163
- ARGV.shift
164
- Tracer.on
165
- require $0
166
- elsif caller(0).size <= 2
167
- Tracer.on
168
- end