rb-trace 0.5 → 0.6
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/.gitignore +1 -1
- data/NEWS +4 -1
- data/README.textile +3 -2
- data/Rakefile +4 -3
- data/ext/1.9.2/thread_pthread.h +24 -0
- data/ext/{trace.c → 1.9.2/trace.c} +1 -3
- data/ext/{vm_core_mini.h → 1.9.2/vm_core_mini.h} +0 -0
- data/ext/1.9.3/trace.c +22 -0
- data/ext/extconf.rb +9 -1
- data/ext/version.h +2 -0
- data/lib/eventbuffer.rb +1 -0
- data/lib/trace_mod.rb +1 -1
- data/lib/tracefilter.rb +5 -4
- data/rb-trace.gemspec +38 -0
- data/test/unit/test-trace-hook.rb +1 -1
- data/test/unit/test-trace_mod.rb +1 -1
- data/test/unit/test-tracefilter.rb +6 -1
- metadata +47 -57
data/.gitignore
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
1
|
+
*~
|
2
2
|
/pkg
|
data/NEWS
CHANGED
data/README.textile
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
_rb-trace_ adds a trace_hook object, translates hooks bitmasks to Ruby sets and vice versa, and extends _set_trace_func()_ to allow ignore specified frames or functions.
|
2
|
+
|
3
|
+
See "this":https://github.com/rocky/rb-trace/wiki/irb-method%2C-class%2C-and-definition-capturing for a cool non-debugger use of this.
|
data/Rakefile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
# -*- Ruby -*-
|
3
3
|
require 'rubygems'
|
4
|
+
require 'fileutils'
|
4
5
|
|
5
6
|
ROOT_DIR = File.dirname(__FILE__)
|
6
7
|
Gemspec_filename='rb-trace.gemspec'
|
@@ -9,7 +10,7 @@ def gemspec
|
|
9
10
|
@gemspec ||= eval(File.read(Gemspec_filename), binding, Gemspec_filename)
|
10
11
|
end
|
11
12
|
|
12
|
-
require '
|
13
|
+
require 'rubygems/package_task'
|
13
14
|
desc "Build the gem"
|
14
15
|
task :package=>:gem
|
15
16
|
task :gem=>:gemspec do
|
@@ -45,11 +46,11 @@ Rake::TestTask.new(:'test:unit') do |t|
|
|
45
46
|
t.options = '--verbose' if $VERBOSE
|
46
47
|
end
|
47
48
|
|
48
|
-
desc "Create the core
|
49
|
+
desc "Create the core rb-trace shared library extension"
|
49
50
|
task :ext do
|
50
51
|
Dir.chdir('ext') do
|
51
52
|
system("#{Gem.ruby} extconf.rb && make")
|
52
|
-
end
|
53
|
+
end if '1.9.2' == RUBY_VERSION
|
53
54
|
end
|
54
55
|
|
55
56
|
desc 'Remove built files'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/**********************************************************************
|
2
|
+
|
3
|
+
thread_pthread.h -
|
4
|
+
|
5
|
+
$Author$
|
6
|
+
|
7
|
+
Copyright (C) 2004-2007 Koichi Sasada
|
8
|
+
|
9
|
+
**********************************************************************/
|
10
|
+
|
11
|
+
#ifndef RUBY_THREAD_PTHREAD_H
|
12
|
+
#define RUBY_THREAD_PTHREAD_H
|
13
|
+
|
14
|
+
#include <pthread.h>
|
15
|
+
typedef pthread_t rb_thread_id_t;
|
16
|
+
typedef pthread_mutex_t rb_thread_lock_t;
|
17
|
+
typedef pthread_cond_t rb_thread_cond_t;
|
18
|
+
|
19
|
+
typedef struct native_thread_data_struct {
|
20
|
+
void *signal_thread_list;
|
21
|
+
pthread_cond_t sleep_cond;
|
22
|
+
} native_thread_data_t;
|
23
|
+
|
24
|
+
#endif /* RUBY_THREAD_PTHREAD_H */
|
File without changes
|
data/ext/1.9.3/trace.c
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
/* Ruby 1.9.3 doesn't need a C extension while 1.9.2 does. I can't figure
|
2
|
+
out a way build a gem so that it loads the C extension conditionally.
|
3
|
+
So instead we have a simple stupid stub extension.
|
4
|
+
|
5
|
+
This as it is not elegant.
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include <ruby.h>
|
9
|
+
#include <ruby/version.h>
|
10
|
+
#include <string.h>
|
11
|
+
void
|
12
|
+
Init_trace(void)
|
13
|
+
{
|
14
|
+
if (0 == strncmp("1.9.2", ruby_version, sizeof("1.9.2")))
|
15
|
+
{
|
16
|
+
rb_raise(rb_eLoadError,
|
17
|
+
"Gem installed under Ruby 1.9.3 but this Ruby 1.9.2. Please reinstall 'rb-trace' gem under 1.9.2.");
|
18
|
+
} else if (0 == strncmp("1.9.3", ruby_version, sizeof("1.9.3"))) {
|
19
|
+
rb_raise(rb_eLoadError,
|
20
|
+
"Under Ruby 1.9.3 there is no reason to load this trace C extension.");
|
21
|
+
}
|
22
|
+
}
|
data/ext/extconf.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
require "mkmf"
|
2
2
|
|
3
|
+
fail "You need to install a threadframe-patched Ruby.
|
4
|
+
See http://github.com/rocky/rb-threadframe/wiki/How-to-Install" unless
|
5
|
+
RbConfig::CONFIG.member?('rb-threadframe')
|
6
|
+
|
7
|
+
# Allow use customization of compile options. For example, the
|
8
|
+
# following lines could be put in config_options:
|
9
|
+
# CONFIG['optflags'] = '' # Or -O3
|
10
|
+
# CONFIG['debugflags'] = '-g3 -ggdb'
|
3
11
|
config_file = File.join(File.dirname(__FILE__), 'config_options')
|
4
12
|
load config_file if File.exist?(config_file)
|
5
13
|
|
6
14
|
# Temporary: to turn off optimization
|
7
15
|
# $CFLAGS='-fno-strict-aliasing -g -fPIC'
|
8
|
-
create_makefile(
|
16
|
+
create_makefile('trace', RUBY_VERSION)
|
data/ext/version.h
ADDED
data/lib/eventbuffer.rb
CHANGED
data/lib/trace_mod.rb
CHANGED
data/lib/tracefilter.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
1
2
|
require 'set'
|
2
3
|
# require '/src/external-vcs/rb-threadframe/ext/thread_frame'
|
3
4
|
require 'thread_frame'
|
@@ -19,7 +20,7 @@ module Trace
|
|
19
20
|
@excluded = Set.new(excluded_meths.map{|m| m.to_s})
|
20
21
|
end
|
21
22
|
|
22
|
-
# +fn+ should be a RubyVM::
|
23
|
+
# +fn+ should be a RubyVM::Frame object or a Proc which has an
|
23
24
|
# instruction sequence
|
24
25
|
def valid_meth?(fn)
|
25
26
|
fn.is_a?(Method)
|
@@ -56,10 +57,10 @@ module Trace
|
|
56
57
|
end
|
57
58
|
|
58
59
|
# A shim to convert between older-style trace hook call to newer
|
59
|
-
# style trace hook using RubyVM::
|
60
|
+
# style trace hook using RubyVM::Frame. Methods stored in
|
60
61
|
# @+excluded+ are ignored.
|
61
62
|
def trace_hook(event, file, line, id, binding, klass)
|
62
|
-
tf = RubyVM::
|
63
|
+
tf = RubyVM::Frame::current.prev
|
63
64
|
|
64
65
|
# FIXME: Clean this mess up. And while your at it, understand
|
65
66
|
# what's going on better.
|
@@ -81,7 +82,7 @@ module Trace
|
|
81
82
|
# turning it off in the frame and frames called from that.
|
82
83
|
# Example: if a trace hook yields to or calls a block
|
83
84
|
# outside not derived from the frame, then tracing should
|
84
|
-
# start again. But either way, since RubyVM::
|
85
|
+
# start again. But either way, since RubyVM::Frame
|
85
86
|
# allows control over tracing *any* decision is not
|
86
87
|
# irrevocable, just possibly unhelpful.
|
87
88
|
tf_check.trace_off = true
|
data/rb-trace.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- Ruby -*-
|
2
|
+
# -*- encoding: utf-8 -*-
|
3
|
+
require 'rake'
|
4
|
+
require 'rubygems' unless
|
5
|
+
Object.const_defined?(:Gem)
|
6
|
+
|
7
|
+
PACKAGE_VERSION = open('ext/version.h') do |f|
|
8
|
+
f.grep(/^#define TRACE_VERSION/).first[/"(.+)"/,1]
|
9
|
+
end
|
10
|
+
|
11
|
+
spec = Gem::Specification.new do |spec|
|
12
|
+
spec.authors = ['R. Bernstein']
|
13
|
+
spec.name = 'rb-trace'
|
14
|
+
|
15
|
+
spec.homepage = 'https://github.com/rocky/rb-trace/wiki'
|
16
|
+
spec.summary = 'Trace hook extensions'
|
17
|
+
spec.description = <<-EOF
|
18
|
+
|
19
|
+
rb-trace adds a trace_hook object, translates hooks bitmasks to Ruby sets and vice versa, and extends set_trace_func() to allow ignore specified frames or functions.
|
20
|
+
EOF
|
21
|
+
|
22
|
+
spec.version = PACKAGE_VERSION
|
23
|
+
spec.extensions = ['ext/extconf.rb']
|
24
|
+
|
25
|
+
spec.email = 'rockyb@rubyforge.org'
|
26
|
+
spec.platform = Gem::Platform::RUBY
|
27
|
+
spec.files = `git ls-files`.split("\n")
|
28
|
+
spec.add_dependency('rb-threadframe', '>= 0.39.9')
|
29
|
+
|
30
|
+
# spec.required_ruby_version = '~> 1.9.2frame'
|
31
|
+
spec.date = Time.now
|
32
|
+
# spec.rubyforge_project = 'rocky-hacks'
|
33
|
+
|
34
|
+
# rdoc
|
35
|
+
spec.has_rdoc = true
|
36
|
+
# spec.extra_rdoc_files = ['README', 'threadframe.rd']
|
37
|
+
end
|
38
|
+
|
data/test/unit/test-trace_mod.rb
CHANGED
@@ -60,7 +60,12 @@ class TestTraceFilter < Test::Unit::TestCase
|
|
60
60
|
|
61
61
|
assert_equal(false, $events.empty?,
|
62
62
|
'We should have gotting some trace output')
|
63
|
-
|
63
|
+
if '1.9.3' == RUBY_VERSION
|
64
|
+
expected = [Kernel, Kernel]
|
65
|
+
else
|
66
|
+
expected = [Kernel]
|
67
|
+
end
|
68
|
+
assert_equal(expected, $args,
|
64
69
|
'C call/returns set $args')
|
65
70
|
|
66
71
|
$line_nos.each_with_index do
|
metadata
CHANGED
@@ -1,47 +1,44 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb-trace
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 5
|
8
|
-
version: "0.5"
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.6'
|
5
|
+
prerelease:
|
9
6
|
platform: ruby
|
10
|
-
authors:
|
7
|
+
authors:
|
11
8
|
- R. Bernstein
|
12
9
|
autorequire:
|
13
10
|
bindir: bin
|
14
11
|
cert_chain: []
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
dependencies:
|
19
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-11-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
20
15
|
name: rb-threadframe
|
21
|
-
|
22
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
23
17
|
none: false
|
24
|
-
requirements:
|
25
|
-
- -
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
- 0
|
29
|
-
- 38
|
30
|
-
version: "0.38"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.39.9
|
31
22
|
type: :runtime
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.39.9
|
30
|
+
description: ! '
|
31
|
+
|
32
|
+
rb-trace adds a trace_hook object, translates hooks bitmasks to Ruby sets and vice
|
33
|
+
versa, and extends set_trace_func() to allow ignore specified frames or functions.
|
34
|
+
|
35
|
+
'
|
37
36
|
email: rockyb@rubyforge.org
|
38
37
|
executables: []
|
39
|
-
|
40
|
-
extensions:
|
38
|
+
extensions:
|
41
39
|
- ext/extconf.rb
|
42
40
|
extra_rdoc_files: []
|
43
|
-
|
44
|
-
files:
|
41
|
+
files:
|
45
42
|
- .gitignore
|
46
43
|
- ChangeLog
|
47
44
|
- LICENSE
|
@@ -49,53 +46,46 @@ files:
|
|
49
46
|
- README.textile
|
50
47
|
- Rakefile
|
51
48
|
- ext/.gitignore
|
49
|
+
- ext/1.9.2/thread_pthread.h
|
50
|
+
- ext/1.9.2/trace.c
|
51
|
+
- ext/1.9.2/vm_core_mini.h
|
52
|
+
- ext/1.9.3/trace.c
|
52
53
|
- ext/extconf.rb
|
53
54
|
- ext/thread_pthread.h
|
54
|
-
- ext/
|
55
|
-
- ext/vm_core_mini.h
|
55
|
+
- ext/version.h
|
56
56
|
- lib/.gitignore
|
57
57
|
- lib/eventbuffer.rb
|
58
58
|
- lib/trace.rb
|
59
59
|
- lib/trace_mod.rb
|
60
60
|
- lib/tracefilter.rb
|
61
|
+
- rb-trace.gemspec
|
61
62
|
- test/unit/.gitignore
|
62
63
|
- test/unit/test-event2bitmask.rb
|
63
64
|
- test/unit/test-trace-hook.rb
|
64
65
|
- test/unit/test-trace_mod.rb
|
65
66
|
- test/unit/test-tracefilter.rb
|
66
|
-
|
67
|
-
homepage: http://github.com/rocky/rb-trace/tree/master
|
67
|
+
homepage: https://github.com/rocky/rb-trace/wiki
|
68
68
|
licenses: []
|
69
|
-
|
70
69
|
post_install_message:
|
71
70
|
rdoc_options: []
|
72
|
-
|
73
|
-
require_paths:
|
71
|
+
require_paths:
|
74
72
|
- lib
|
75
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
74
|
none: false
|
77
|
-
requirements:
|
78
|
-
- -
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
|
81
|
-
|
82
|
-
- 9
|
83
|
-
- 2frame
|
84
|
-
version: 1.9.2frame
|
85
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
80
|
none: false
|
87
|
-
requirements:
|
88
|
-
- -
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
|
91
|
-
- 0
|
92
|
-
version: "0"
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
93
85
|
requirements: []
|
94
|
-
|
95
86
|
rubyforge_project:
|
96
|
-
rubygems_version: 1.
|
87
|
+
rubygems_version: 1.8.23
|
97
88
|
signing_key:
|
98
89
|
specification_version: 3
|
99
90
|
summary: Trace hook extensions
|
100
91
|
test_files: []
|
101
|
-
|