ruby_ext_backtrace 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -26,14 +26,17 @@ require 'pp'
|
|
26
26
|
require 'ruby_ext_backtrace'
|
27
27
|
|
28
28
|
def some_method2 param
|
29
|
-
|
29
|
+
c1 = caller_ext(0); c2 = caller(0)
|
30
|
+
pp c1
|
31
|
+
puts "\n#Original caller for comparison:"
|
32
|
+
pp c2
|
30
33
|
end
|
31
34
|
|
32
|
-
def some_method param1, param2=nil, &blk
|
35
|
+
def some_method param1, param2=nil, *splat, &blk
|
33
36
|
yield "block_param0", "block_param1"
|
34
37
|
end
|
35
38
|
|
36
|
-
some_method(1111){|bp1,bp2|
|
39
|
+
some_method(1111, nil, 1, 2, 3){|bp1,bp2|
|
37
40
|
some_method2 "some_method2_param"
|
38
41
|
}
|
39
42
|
```
|
@@ -42,36 +45,32 @@ this outputs:
|
|
42
45
|
|
43
46
|
```ruby
|
44
47
|
|
45
|
-
["
|
46
|
-
"./test.rb:17:in `some_method2'",
|
47
|
-
"./test.rb:25:in `block in <main>'",
|
48
|
-
"./test.rb:21:in `some_method'",
|
49
|
-
"./test.rb:24:in `<main>'"]
|
50
|
-
|
51
|
-
[{:file=>"./test.rb",
|
48
|
+
[{:file=>"test.rb",
|
52
49
|
:line=>10,
|
53
|
-
:method=>"meth",
|
54
|
-
:argc=>1,
|
55
|
-
0=>"default_meth_param"},
|
56
|
-
{:file=>"./test.rb",
|
57
|
-
:line=>17,
|
58
50
|
:method=>"some_method2",
|
59
51
|
:argc=>1,
|
60
52
|
0=>"some_method2_param"},
|
61
|
-
{:file=>"
|
62
|
-
:line=>
|
53
|
+
{:file=>"test.rb",
|
54
|
+
:line=>21,
|
63
55
|
:method=>"block in <main>",
|
64
56
|
:argc=>2,
|
65
57
|
0=>"block_param0",
|
66
58
|
1=>"block_param1"},
|
67
|
-
{:file=>"
|
68
|
-
:line=>
|
59
|
+
{:file=>"test.rb",
|
60
|
+
:line=>17,
|
69
61
|
:method=>"some_method",
|
70
|
-
:argc=>
|
62
|
+
:argc=>4,
|
71
63
|
0=>1111,
|
72
64
|
1=>nil,
|
73
|
-
2
|
74
|
-
|
65
|
+
2=>[1, 2, 3],
|
66
|
+
3=>#<Proc:0x007fc87c053290@test.rb:20>},
|
67
|
+
{:file=>"test.rb", :line=>20, :method=>"<main>", :argc=>0}]
|
68
|
+
|
69
|
+
#Original caller for comparison:
|
70
|
+
["test.rb:10:in `some_method2'",
|
71
|
+
"test.rb:21:in `block in <main>'",
|
72
|
+
"test.rb:17:in `some_method'",
|
73
|
+
"test.rb:20:in `<main>'"]
|
75
74
|
```
|
76
75
|
|
77
76
|
Note that fetching parameters for CFUNCs with variable parameters (argc<0) is not supported.
|
@@ -5,7 +5,13 @@ require 'mkmf'
|
|
5
5
|
require 'debugger/ruby_core_source'
|
6
6
|
|
7
7
|
hdrs = proc {
|
8
|
-
have_header("vm_core.h") # and have_header("iseq.h")
|
8
|
+
res = have_header("vm_core.h") # and have_header("iseq.h")
|
9
|
+
|
10
|
+
if RUBY_VERSION=='1.9.2'
|
11
|
+
# on 1.9.3 it fails to link in runtime, but still checks to be ok
|
12
|
+
have_var('ruby_current_thread', 'vm_core.h')
|
13
|
+
end
|
14
|
+
res
|
9
15
|
}
|
10
16
|
|
11
17
|
dir_config("ruby") # allow user to pass in non-standard core include directory
|
@@ -10,6 +10,13 @@
|
|
10
10
|
#error Need RubyVM, use another ruby
|
11
11
|
#endif
|
12
12
|
|
13
|
+
#ifdef HAVE_RUBY_CURRENT_THREAD
|
14
|
+
extern VALUE ruby_engine_name;
|
15
|
+
#else
|
16
|
+
#define ruby_engine_name Qnil
|
17
|
+
#define ruby_current_thread ((rb_thread_t *)RTYPEDDATA_DATA(rb_thread_current()))
|
18
|
+
#endif
|
19
|
+
|
13
20
|
typedef int (rb_backtrace_iter_ext_func)(void *arg, VALUE file, int line, VALUE method_name, int argc, VALUE* argv);
|
14
21
|
|
15
22
|
static int
|
@@ -49,7 +56,7 @@ vm_backtrace_each_ext(rb_thread_t *th, int lev, void (*init)(void *), rb_backtra
|
|
49
56
|
} else
|
50
57
|
if (RUBYVM_CFUNC_FRAME_P(cfp)) {
|
51
58
|
ID id = cfp->me->def? cfp->me->def->original_id : cfp->me->called_id;
|
52
|
-
|
59
|
+
|
53
60
|
if (NIL_P(file)) file = ruby_engine_name;
|
54
61
|
|
55
62
|
if (id != ID_ALLOCATOR){
|
@@ -7,13 +7,16 @@ require 'pp'
|
|
7
7
|
require 'ruby_ext_backtrace'
|
8
8
|
|
9
9
|
def some_method2 param
|
10
|
-
|
10
|
+
c1 = caller_ext(0); c2 = caller(0)
|
11
|
+
pp c1
|
12
|
+
puts "\n #Original caller for comparison:"
|
13
|
+
pp c2
|
11
14
|
end
|
12
15
|
|
13
|
-
def some_method param1, param2=nil, &blk
|
16
|
+
def some_method param1, param2=nil, *splat, &blk
|
14
17
|
yield "block_param0", "block_param1"
|
15
18
|
end
|
16
19
|
|
17
|
-
some_method(1111){|bp1,bp2|
|
20
|
+
some_method(1111, nil, 1, 2, 3){|bp1,bp2|
|
18
21
|
some_method2 "some_method2_param"
|
19
|
-
}
|
22
|
+
}
|
data/ruby_ext_backtrace.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.email = ["vasilyfedoseyev@gmail.com"]
|
11
11
|
gem.description = %q{Extended backtrace for ruby}
|
12
12
|
gem.summary = %q{have you ever wanted to see method parameters in backtrace?}
|
13
|
-
gem.homepage = ""
|
13
|
+
gem.homepage = "https://github.com/Vasfed/ruby_ext_backtrace"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_ext_backtrace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: debugger-ruby_core_source
|
@@ -62,7 +62,7 @@ files:
|
|
62
62
|
- lib/ruby_ext_backtrace.rb
|
63
63
|
- lib/ruby_ext_backtrace/version.rb
|
64
64
|
- ruby_ext_backtrace.gemspec
|
65
|
-
homepage:
|
65
|
+
homepage: https://github.com/Vasfed/ruby_ext_backtrace
|
66
66
|
licenses: []
|
67
67
|
post_install_message:
|
68
68
|
rdoc_options: []
|
@@ -76,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
76
|
version: '0'
|
77
77
|
segments:
|
78
78
|
- 0
|
79
|
-
hash: -
|
79
|
+
hash: -543521818031646013
|
80
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
82
82
|
requirements:
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
segments:
|
87
87
|
- 0
|
88
|
-
hash: -
|
88
|
+
hash: -543521818031646013
|
89
89
|
requirements: []
|
90
90
|
rubyforge_project:
|
91
91
|
rubygems_version: 1.8.24
|