rotoscope 0.3.0 → 0.3.1.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/dev.yml +1 -1
- data/ext/rotoscope/callsite.c +35 -24
- data/ext/rotoscope/callsite.h +3 -3
- data/ext/rotoscope/rotoscope.c +7 -16
- data/ext/rotoscope/stack.h +1 -3
- data/lib/rotoscope/call_logger.rb +4 -4
- data/lib/rotoscope/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f72d8d9a3775c27bafb2214f668282b5defe8731e04befe0957bbd628fe99a82
|
4
|
+
data.tar.gz: cbc5bded38b6287945e629c6bc64fbcb1fee23c23c1ed588e04fbe2aabdb60fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bd1d1a8fdea550f69513e8b36b3753684239d6cb662655cce35b4da1e4b163041265bd3771f6dd2c37e8c07b6efedef2b7b51d1d2a7f313b70adbe0e093e2d4
|
7
|
+
data.tar.gz: '009a2baef7ec589dd738077f523aecfa8dbc7af486a1a67eba91cd990530c494caf7134b92f9e6a83e3991bf3484bad69bd5123755cdd24440c0209378e64e80'
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.5.3
|
data/dev.yml
CHANGED
data/ext/rotoscope/callsite.c
CHANGED
@@ -1,39 +1,50 @@
|
|
1
1
|
#include "callsite.h"
|
2
2
|
#include <ruby.h>
|
3
3
|
#include <ruby/debug.h>
|
4
|
+
#include <stdbool.h>
|
4
5
|
|
5
|
-
VALUE
|
6
|
+
static VALUE caller_frame(int *line, bool ruby_call) {
|
7
|
+
VALUE frames[2] = {Qnil, Qnil};
|
8
|
+
int lines[2] = {0, 0};
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
// At this point, the top ruby stack frame is for the method
|
11
|
+
// being called, so we want to skip that frame and get
|
12
|
+
// the caller location. This is why we use 1 for ruby calls.
|
13
|
+
//
|
14
|
+
// However, rb_profile_frames also automatically skips over
|
15
|
+
// non-ruby stack frames, so we don't want to have to skip
|
16
|
+
// over any extra stack frames for a C call.
|
17
|
+
int frame_index = ruby_call ? 1 : 0;
|
14
18
|
|
15
|
-
rs_callsite_t ruby_callsite(rb_trace_arg_t *trace_arg) {
|
16
|
-
VALUE frames[2];
|
17
|
-
int lines[2];
|
18
19
|
// There is currently a bug in rb_profile_frames that
|
19
20
|
// causes the start argument to effectively always
|
20
21
|
// act as if it were 0, so we need to also get the top
|
21
|
-
// frame.
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
}
|
22
|
+
// frame. (https://bugs.ruby-lang.org/issues/14607)
|
23
|
+
rb_profile_frames(0, frame_index + 1, frames, lines);
|
24
|
+
|
25
|
+
*line = lines[frame_index];
|
26
|
+
return frames[frame_index];
|
27
|
+
}
|
28
28
|
|
29
|
+
rs_callsite_t c_callsite(rb_trace_arg_t *trace_arg) {
|
30
|
+
int line;
|
31
|
+
VALUE frame = caller_frame(&line, false);
|
29
32
|
return (rs_callsite_t){
|
30
|
-
.filepath =
|
31
|
-
.lineno =
|
33
|
+
.filepath = rb_tracearg_path(trace_arg),
|
34
|
+
.lineno = FIX2INT(rb_tracearg_lineno(trace_arg)),
|
35
|
+
.method_name = rb_profile_frame_method_name(frame),
|
36
|
+
.singleton_p = rb_profile_frame_singleton_method_p(frame),
|
32
37
|
};
|
33
38
|
}
|
34
39
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
40
|
+
rs_callsite_t ruby_callsite() {
|
41
|
+
int line;
|
42
|
+
VALUE frame = caller_frame(&line, true);
|
43
|
+
|
44
|
+
return (rs_callsite_t){
|
45
|
+
.filepath = rb_profile_frame_path(frame),
|
46
|
+
.lineno = line,
|
47
|
+
.method_name = rb_profile_frame_method_name(frame),
|
48
|
+
.singleton_p = rb_profile_frame_singleton_method_p(frame),
|
49
|
+
};
|
39
50
|
}
|
data/ext/rotoscope/callsite.h
CHANGED
@@ -7,11 +7,11 @@
|
|
7
7
|
typedef struct {
|
8
8
|
VALUE filepath;
|
9
9
|
unsigned int lineno;
|
10
|
+
VALUE method_name;
|
11
|
+
VALUE singleton_p;
|
10
12
|
} rs_callsite_t;
|
11
13
|
|
12
|
-
void init_callsite();
|
13
|
-
|
14
14
|
rs_callsite_t c_callsite(rb_trace_arg_t *trace_arg);
|
15
|
-
rs_callsite_t ruby_callsite(
|
15
|
+
rs_callsite_t ruby_callsite();
|
16
16
|
|
17
17
|
#endif
|
data/ext/rotoscope/rotoscope.c
CHANGED
@@ -49,7 +49,7 @@ static rs_callsite_t tracearg_path(rb_trace_arg_t *trace_arg) {
|
|
49
49
|
case RUBY_EVENT_C_CALL:
|
50
50
|
return c_callsite(trace_arg);
|
51
51
|
default:
|
52
|
-
return ruby_callsite(
|
52
|
+
return ruby_callsite();
|
53
53
|
}
|
54
54
|
}
|
55
55
|
|
@@ -61,9 +61,7 @@ static rs_method_desc_t called_method_desc(rb_trace_arg_t *trace_arg) {
|
|
61
61
|
SYM2ID(method_id) != id_initialize;
|
62
62
|
|
63
63
|
return (rs_method_desc_t){
|
64
|
-
.receiver = receiver,
|
65
|
-
.id = method_id,
|
66
|
-
.singleton_p = singleton_p,
|
64
|
+
.receiver = receiver, .id = method_id, .singleton_p = singleton_p,
|
67
65
|
};
|
68
66
|
}
|
69
67
|
|
@@ -154,8 +152,9 @@ static VALUE rs_alloc(VALUE klass) {
|
|
154
152
|
config->tid = gettid();
|
155
153
|
config->tracing = false;
|
156
154
|
config->caller = NULL;
|
157
|
-
config->callsite
|
158
|
-
|
155
|
+
config->callsite = (rs_callsite_t){
|
156
|
+
.filepath = Qnil, .lineno = 0, .method_name = Qnil, .singleton_p = Qnil,
|
157
|
+
};
|
159
158
|
config->trace_proc = Qnil;
|
160
159
|
rs_stack_init(&config->stack, STACK_CAPACITY);
|
161
160
|
config->tracepoint = rb_tracepoint_new(Qnil, EVENT_CALL | EVENT_RETURN,
|
@@ -264,18 +263,12 @@ VALUE rotoscope_caller_class_name(VALUE self) {
|
|
264
263
|
|
265
264
|
VALUE rotoscope_caller_method_name(VALUE self) {
|
266
265
|
Rotoscope *config = get_config(self);
|
267
|
-
|
268
|
-
return Qnil;
|
269
|
-
}
|
270
|
-
return rb_sym2str(config->caller->method.id);
|
266
|
+
return config->callsite.method_name;
|
271
267
|
}
|
272
268
|
|
273
269
|
VALUE rotoscope_caller_singleton_method_p(VALUE self) {
|
274
270
|
Rotoscope *config = get_config(self);
|
275
|
-
|
276
|
-
return Qnil;
|
277
|
-
}
|
278
|
-
return config->caller->method.singleton_p ? Qtrue : Qfalse;
|
271
|
+
return config->callsite.singleton_p;
|
279
272
|
}
|
280
273
|
|
281
274
|
VALUE rotoscope_caller_path(VALUE self) {
|
@@ -317,6 +310,4 @@ void Init_rotoscope(void) {
|
|
317
310
|
rotoscope_caller_singleton_method_p, 0);
|
318
311
|
rb_define_method(cRotoscope, "caller_path", rotoscope_caller_path, 0);
|
319
312
|
rb_define_method(cRotoscope, "caller_lineno", rotoscope_caller_lineno, 0);
|
320
|
-
|
321
|
-
init_callsite();
|
322
313
|
}
|
data/ext/rotoscope/stack.h
CHANGED
@@ -88,15 +88,15 @@ class Rotoscope
|
|
88
88
|
private
|
89
89
|
|
90
90
|
def log_call(call)
|
91
|
-
|
91
|
+
caller_path = call.caller_path || ''
|
92
|
+
return if blacklist.match?(caller_path)
|
92
93
|
return if self == call.receiver
|
93
94
|
|
95
|
+
caller_class_name = call.caller_class_name || '<UNKNOWN>'
|
94
96
|
if call.caller_method_name.nil?
|
95
|
-
caller_class_name = '<ROOT>'
|
96
97
|
caller_method_name = '<UNKNOWN>'
|
97
98
|
caller_method_level = '<UNKNOWN>'
|
98
99
|
else
|
99
|
-
caller_class_name = call.caller_class_name
|
100
100
|
caller_method_name = escape_csv_string(call.caller_method_name)
|
101
101
|
caller_method_level = call.caller_singleton_method? ? 'class' : 'instance'
|
102
102
|
end
|
@@ -109,7 +109,7 @@ class Rotoscope
|
|
109
109
|
buffer <<
|
110
110
|
'"' << call.receiver_class_name << '",' \
|
111
111
|
'"' << caller_class_name << '",' \
|
112
|
-
'"' <<
|
112
|
+
'"' << caller_path << '",' \
|
113
113
|
<< call.caller_lineno.to_s << ',' \
|
114
114
|
'"' << method_name << '",' \
|
115
115
|
<< call_method_level << ',' \
|
data/lib/rotoscope/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rotoscope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1.pre.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jahfer Husain
|
@@ -115,9 +115,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
115
|
version: 2.2.0
|
116
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
117
|
requirements:
|
118
|
-
- - "
|
118
|
+
- - ">"
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
version:
|
120
|
+
version: 1.3.1
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
123
|
rubygems_version: 2.7.6
|