rdx 0.9.0.pre
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.
- checksums.yaml +7 -0
- data/.rdx +20 -0
- data/README +19 -0
- data/bin/rdx +7 -0
- data/examples/minimal/.rdx +8 -0
- data/examples/minimal/README +10 -0
- data/examples/minimal/lib/other_conventions.rb +64 -0
- data/examples/minimal/lib/the_basics.rb +94 -0
- data/examples/minimal/lib/using_directives.rb +66 -0
- data/examples/minimal/rakefile +27 -0
- data/examples/ruby-2.0.0-p0/README +7 -0
- data/examples/ruby-2.0.0-p0/install/core/.rdx +6 -0
- data/examples/ruby-2.0.0-p0/install/core/README +19 -0
- data/examples/ruby-2.0.0-p0/install/core/Rakefile +61 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/array.c.diff +166 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/bignum.c.diff +11 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/class.c.diff +36 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/compar.c.diff +11 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/complex.c.diff +301 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/cont.c.diff +65 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/dir.c.diff +147 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/re.rdoc.diff +328 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/security.rdoc.diff +8 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/standard_library.rdoc.diff +0 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax.rdoc.diff +0 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/assignment.rdoc.diff +160 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/calling_methods.rdoc.diff +130 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/control_expressions.rdoc.diff +254 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/exceptions.rdoc.diff +0 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/literals.rdoc.diff +54 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/methods.rdoc.diff +157 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/miscellaneous.rdoc.diff +91 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/modules_and_classes.rdoc.diff +161 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/precedence.rdoc.diff +8 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/doc/syntax/refinements.rdoc.diff +146 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/encoding.c.diff +276 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/enum.c.diff +281 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/enumerator.c.diff +479 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/error.c.diff +143 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/eval.c.diff +47 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/eval_jump.c.diff +23 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/file.c.diff +752 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/gc.c.diff +195 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/hash.c.diff +84 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/iseq.c.diff +354 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/load.c.diff +53 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/marshal.c.diff +98 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/math.c.diff +110 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/numeric.c.diff +103 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/object.c.diff +295 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/pack.c.diff +18 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/parse.y.diff +23 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/proc.c.diff +155 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/random.c.diff +126 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/range.c.diff +49 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/rational.c.diff +312 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/re.c.diff +207 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/ruby.c.diff +21 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/signal.c.diff +67 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/sprintf.c.diff +29 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/string.c.diff +73 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/struct.c.diff +20 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/time.c.diff +691 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/transcode.c.diff +435 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/variable.c.diff +62 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/vm_backtrace.c.diff +164 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/vm_eval.c.diff +99 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/vm_method.c.diff +17 -0
- data/examples/ruby-2.0.0-p0/install/core/diffs/vm_trace.c.diff +393 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/.rdx +6 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/README +19 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/Rakefile +53 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/abbrev.rb.diff +77 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/base64.rb.diff +42 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/benchmark.rb.diff +144 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/cmath.rb.diff +52 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/forwardable.rb.diff +150 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/mathn.rb.diff +58 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/matrix.rb.diff +657 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/observer.rb.diff +31 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/optparse.rb.diff +147 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/ostruct.rb.diff +78 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/prime.rb.diff +52 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/pstore.rb.diff +110 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/scanf.rb.diff +100 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/securerandom.rb.diff +144 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/set.rb.diff +637 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/shellwords.rb.diff +66 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/singleton.rb.diff +37 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/tempfile.rb.diff +104 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/thread.rb.diff +38 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/time.rb.diff +140 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/tmpdir.rb.diff +52 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/uri.rb.diff +39 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/uri/common.rb.diff +237 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/weakref.rb.diff +36 -0
- data/examples/ruby-2.0.0-p0/install/stdlib/diffs/lib/yaml/store.rb.diff +27 -0
- data/examples/ruby-2.0.0-p0/rakefile +165 -0
- data/lib/rdx.rb +331 -0
- data/lib/rdx/assertions.rb +484 -0
- data/lib/rdx/binding.rb +151 -0
- data/lib/rdx/code_object.rb +598 -0
- data/lib/rdx/comment.rb +338 -0
- data/lib/rdx/convention.rb +1174 -0
- data/lib/rdx/directive.rb +1432 -0
- data/lib/rdx/example.rb +679 -0
- data/lib/rdx/generator.rb +112 -0
- data/lib/rdx/generator/rdoc.rb +1006 -0
- data/lib/rdx/options.rb +359 -0
- data/lib/rdx/plain_text.rb +65 -0
- data/lib/rdx/reporter.rb +421 -0
- data/lib/rdx/ruby_lex.rb +324 -0
- data/lib/rdx/runner.rb +309 -0
- data/lib/rdx/source_file.rb +94 -0
- data/lib/rdx/specification.rb +194 -0
- data/lib/rdx/statement.rb +248 -0
- data/lib/rdx/store.rb +119 -0
- data/lib/rdx/task.rb +361 -0
- data/lib/rdx/text.rb +688 -0
- data/lib/rdx/version.rb +15 -0
- data/rakefile +64 -0
- metadata +203 -0
@@ -0,0 +1,164 @@
|
|
1
|
+
--- core/orig/vm_backtrace.c 2015-06-11 07:51:44 +0000
|
2
|
+
+++ core/patched/vm_backtrace.c 2015-06-20 09:00:52 +0000
|
3
|
+
@@ -147,8 +147,14 @@
|
4
|
+
*
|
5
|
+
* For example, using +caller_locations.rb+ from Thread::Backtrace::Location
|
6
|
+
*
|
7
|
+
- * loc = c(0..1).first
|
8
|
+
- * loc.lineno #=> 2
|
9
|
+
+ * # File: caller_locations.rb
|
10
|
+
+ * loc = caller_locations(0).first
|
11
|
+
+ * puts loc.lineno
|
12
|
+
+ *
|
13
|
+
+ * Running the file:
|
14
|
+
+ *
|
15
|
+
+ * $ ruby caller_locations.rb
|
16
|
+
+ * 1
|
17
|
+
*/
|
18
|
+
static VALUE
|
19
|
+
location_lineno_m(VALUE self)
|
20
|
+
@@ -179,8 +185,14 @@
|
21
|
+
*
|
22
|
+
* For example, using +caller_locations.rb+ from Thread::Backtrace::Location
|
23
|
+
*
|
24
|
+
- * loc = c(0..1).first
|
25
|
+
- * loc.label #=> a
|
26
|
+
+ * # File: caller_locations.rb
|
27
|
+
+ * loc = caller_locations(0).first
|
28
|
+
+ * puts loc.label
|
29
|
+
+ *
|
30
|
+
+ * Running the file:
|
31
|
+
+ *
|
32
|
+
+ * $ ruby caller_locations.rb
|
33
|
+
+ * <main>
|
34
|
+
*/
|
35
|
+
static VALUE
|
36
|
+
location_label_m(VALUE self)
|
37
|
+
@@ -239,8 +251,14 @@
|
38
|
+
*
|
39
|
+
* For example, using +caller_locations.rb+ from Thread::Backtrace::Location
|
40
|
+
*
|
41
|
+
- * loc = c(0..1).first
|
42
|
+
- * loc.path #=> caller_locations.rb
|
43
|
+
+ * # File: tmp/caller_locations.rb
|
44
|
+
+ * loc = caller_locations(0).first
|
45
|
+
+ * puts loc.path
|
46
|
+
+ *
|
47
|
+
+ * Running the file:
|
48
|
+
+ *
|
49
|
+
+ * $ ruby tmp/caller_locations.rb
|
50
|
+
+ * tmp/caller_locations.rb
|
51
|
+
*/
|
52
|
+
static VALUE
|
53
|
+
location_path_m(VALUE self)
|
54
|
+
@@ -870,22 +888,49 @@
|
55
|
+
*
|
56
|
+
* Optionally you can pass a range, which will return an array containing the
|
57
|
+
* entries within the specified range.
|
58
|
+
- *
|
59
|
+
+ *
|
60
|
+
+ * # File: prog.rb
|
61
|
+
* def a(skip)
|
62
|
+
- * caller(skip)
|
63
|
+
+ * caller(skip) # line 2
|
64
|
+
* end
|
65
|
+
* def b(skip)
|
66
|
+
- * a(skip)
|
67
|
+
+ * a(skip) # line 5
|
68
|
+
* end
|
69
|
+
* def c(skip)
|
70
|
+
- * b(skip)
|
71
|
+
+ * b(skip) # line 8
|
72
|
+
* end
|
73
|
+
- * c(0) #=> ["prog:2:in `a'", "prog:5:in `b'", "prog:8:in `c'", "prog:10:in `<main>'"]
|
74
|
+
- * c(1) #=> ["prog:5:in `b'", "prog:8:in `c'", "prog:11:in `<main>'"]
|
75
|
+
- * c(2) #=> ["prog:8:in `c'", "prog:12:in `<main>'"]
|
76
|
+
- * c(3) #=> ["prog:13:in `<main>'"]
|
77
|
+
- * c(4) #=> []
|
78
|
+
- * c(5) #=> nil
|
79
|
+
+ *
|
80
|
+
+ * puts "caller(0):", c(0), "\n" # line 11
|
81
|
+
+ * puts "caller(1):", c(1), "\n" # line 12
|
82
|
+
+ * puts "caller(2):", c(2), "\n" # line 13
|
83
|
+
+ * puts "caller(3):", c(3), "\n" # line 14
|
84
|
+
+ * puts "caller(4): #{c(4).inspect}", "\n"
|
85
|
+
+ * puts "caller(5): #{c(5).inspect}", "\n"
|
86
|
+
+ *
|
87
|
+
+ * then from the command line:
|
88
|
+
+ *
|
89
|
+
+ * $ ruby prog.rb
|
90
|
+
+ * caller(0):
|
91
|
+
+ * prog.rb:2:in `a'
|
92
|
+
+ * prog.rb:5:in `b'
|
93
|
+
+ * prog.rb:8:in `c'
|
94
|
+
+ * prog.rb:11:in `<main>'
|
95
|
+
+ *
|
96
|
+
+ * caller(1):
|
97
|
+
+ * prog.rb:5:in `b'
|
98
|
+
+ * prog.rb:8:in `c'
|
99
|
+
+ * prog.rb:12:in `<main>'
|
100
|
+
+ *
|
101
|
+
+ * caller(2):
|
102
|
+
+ * prog.rb:8:in `c'
|
103
|
+
+ * prog.rb:13:in `<main>'
|
104
|
+
+ *
|
105
|
+
+ * caller(3):
|
106
|
+
+ * prog.rb:14:in `<main>'
|
107
|
+
+ *
|
108
|
+
+ * caller(4): []
|
109
|
+
+ *
|
110
|
+
+ * caller(5): nil
|
111
|
+
*/
|
112
|
+
|
113
|
+
static VALUE
|
114
|
+
@@ -938,7 +983,7 @@
|
115
|
+
*
|
116
|
+
* For example:
|
117
|
+
*
|
118
|
+
- * # caller_locations.rb
|
119
|
+
+ * # File: caller_locations.rb
|
120
|
+
* def a(skip)
|
121
|
+
* caller_locations(skip)
|
122
|
+
* end
|
123
|
+
@@ -949,19 +994,20 @@
|
124
|
+
* b(skip)
|
125
|
+
* end
|
126
|
+
*
|
127
|
+
- * c(0..2).map do |call|
|
128
|
+
+ * c(0..2).each do |call|
|
129
|
+
* puts call.to_s
|
130
|
+
* end
|
131
|
+
*
|
132
|
+
- * Running <code>ruby caller_locations.rb</code> will produce:
|
133
|
+
+ * Then from the command line:
|
134
|
+
*
|
135
|
+
+ * $ ruby caller_locations.rb
|
136
|
+
* caller_locations.rb:2:in `a'
|
137
|
+
* caller_locations.rb:5:in `b'
|
138
|
+
* caller_locations.rb:8:in `c'
|
139
|
+
*
|
140
|
+
* Here's another example with a slightly different result:
|
141
|
+
*
|
142
|
+
- * # foo.rb
|
143
|
+
+ * # File: foo.rb
|
144
|
+
* class Foo
|
145
|
+
* attr_accessor :locations
|
146
|
+
* def initialize(skip)
|
147
|
+
@@ -973,11 +1019,12 @@
|
148
|
+
* puts call.to_s
|
149
|
+
* end
|
150
|
+
*
|
151
|
+
- * Now run <code>ruby foo.rb</code> and you should see:
|
152
|
+
- *
|
153
|
+
- * init.rb:4:in `initialize'
|
154
|
+
- * init.rb:8:in `new'
|
155
|
+
- * init.rb:8:in `<main>'
|
156
|
+
+ * Then from the command line:
|
157
|
+
+ *
|
158
|
+
+ * $ ruby foo.rb
|
159
|
+
+ * foo.rb:4:in `initialize'
|
160
|
+
+ * foo.rb:8:in `new'
|
161
|
+
+ * foo.rb:8:in `<main>'
|
162
|
+
*/
|
163
|
+
rb_cBacktraceLocation = rb_define_class_under(rb_cBacktrace, "Location", rb_cObject);
|
164
|
+
rb_undef_alloc_func(rb_cBacktraceLocation);
|
@@ -0,0 +1,99 @@
|
|
1
|
+
--- core/orig/vm_eval.c 2015-06-11 07:51:45 +0000
|
2
|
+
+++ core/patched/vm_eval.c 2015-06-11 07:51:47 +0000
|
3
|
+
@@ -603,8 +603,14 @@
|
4
|
+
* values.
|
5
|
+
*
|
6
|
+
* class Roman
|
7
|
+
- * def roman_to_int(str)
|
8
|
+
+ * ROMAN_2_NUM = {
|
9
|
+
+ * 'I' => 1, 'V' => 5,
|
10
|
+
+ * 'X' => 10, 'L' => 50,
|
11
|
+
* # ...
|
12
|
+
+ * }
|
13
|
+
+ * def roman_to_int(str)
|
14
|
+
+ * # compute integers - for this example will suffice the table -
|
15
|
+
+ * ROMAN_2_NUM[str.upcase]
|
16
|
+
* end
|
17
|
+
* def method_missing(methId)
|
18
|
+
* str = methId.id2name
|
19
|
+
@@ -613,9 +619,9 @@
|
20
|
+
* end
|
21
|
+
*
|
22
|
+
* r = Roman.new
|
23
|
+
- * r.iv #=> 4
|
24
|
+
- * r.xxiii #=> 23
|
25
|
+
- * r.mm #=> 2000
|
26
|
+
+ * r.i #=> 1
|
27
|
+
+ * r.v #=> 5
|
28
|
+
+ * r.x #=> 10
|
29
|
+
*/
|
30
|
+
|
31
|
+
static VALUE
|
32
|
+
@@ -893,7 +899,7 @@
|
33
|
+
* arguments specified. Unlike send, public_send calls public
|
34
|
+
* methods only.
|
35
|
+
*
|
36
|
+
- * 1.public_send(:puts, "hello") # causes NoMethodError
|
37
|
+
+ * 1.public_send(:puts, "hello") # raises NoMethodError
|
38
|
+
*/
|
39
|
+
|
40
|
+
VALUE
|
41
|
+
@@ -984,13 +990,27 @@
|
42
|
+
* Repeatedly executes the block.
|
43
|
+
*
|
44
|
+
* If no block is given, an enumerator is returned instead.
|
45
|
+
- *
|
46
|
+
+ *
|
47
|
+
+ * When the following input
|
48
|
+
+ * First line given
|
49
|
+
+ * Second line given
|
50
|
+
+ * Last line given
|
51
|
+
+ * Quit!
|
52
|
+
+ *
|
53
|
+
+ * is given into this program
|
54
|
+
+ * :rdx: stdin
|
55
|
+
+ *
|
56
|
+
* loop do
|
57
|
+
- * print "Input: "
|
58
|
+
* line = gets
|
59
|
+
- * break if !line or line =~ /^qQ/
|
60
|
+
- * # ...
|
61
|
+
+ * break if !line or line =~ /^[qQ]/
|
62
|
+
+ * puts "Got: #{line}"
|
63
|
+
* end
|
64
|
+
+ *
|
65
|
+
+ * produces:
|
66
|
+
+ *
|
67
|
+
+ * Got: First line given
|
68
|
+
+ * Got: Second line given
|
69
|
+
+ * Got: Last line given
|
70
|
+
*
|
71
|
+
* StopIteration raised in the block breaks the loop.
|
72
|
+
*/
|
73
|
+
@@ -1630,14 +1650,12 @@
|
74
|
+
* end
|
75
|
+
* a = %q{def hello() "Hello there!" end}
|
76
|
+
* Thing.module_eval(a)
|
77
|
+
- * puts Thing.new.hello()
|
78
|
+
+ * puts Thing.new.hello() # prints: Hello there!
|
79
|
+
* Thing.module_eval("invalid code", "dummy", 123)
|
80
|
+
*
|
81
|
+
- * <em>produces:</em>
|
82
|
+
+ * <em>raises the exception:</em>
|
83
|
+
*
|
84
|
+
- * Hello there!
|
85
|
+
- * dummy:123:in `module_eval': undefined local variable
|
86
|
+
- * or method `code' for Thing:Class
|
87
|
+
+ * undefined local variable or method `code' for Thing (NameError)
|
88
|
+
*/
|
89
|
+
|
90
|
+
VALUE
|
91
|
+
@@ -1826,7 +1844,7 @@
|
92
|
+
* for i in 1..10
|
93
|
+
* # ...
|
94
|
+
* end
|
95
|
+
- * local_variables #=> [:fred, :i]
|
96
|
+
+ * local_variables #=> [:i, :fred]
|
97
|
+
*/
|
98
|
+
|
99
|
+
static VALUE
|
@@ -0,0 +1,17 @@
|
|
1
|
+
--- core/orig/vm_method.c 2015-06-11 07:51:45 +0000
|
2
|
+
+++ core/patched/vm_method.c 2015-06-11 07:51:47 +0000
|
3
|
+
@@ -908,13 +908,12 @@
|
4
|
+
* class Child
|
5
|
+
* undef_method :hello # prevent any calls to 'hello'
|
6
|
+
* end
|
7
|
+
- * c.hello
|
8
|
+
+ * c.hello # raises NoMethodError
|
9
|
+
*
|
10
|
+
* <em>produces:</em>
|
11
|
+
*
|
12
|
+
* In child
|
13
|
+
* In parent
|
14
|
+
- * prog.rb:23: undefined method `hello' for #<Child:0x401b3bb4> (NoMethodError)
|
15
|
+
*/
|
16
|
+
|
17
|
+
static VALUE
|
@@ -0,0 +1,393 @@
|
|
1
|
+
--- core/orig/vm_trace.c 2015-06-11 07:51:43 +0000
|
2
|
+
+++ core/patched/vm_trace.c 2015-06-25 17:35:23 +0000
|
3
|
+
@@ -415,29 +415,37 @@
|
4
|
+
*
|
5
|
+
* Tracing is disabled within the context of _proc_.
|
6
|
+
*
|
7
|
+
+ * # File: prog.rb
|
8
|
+
* class Test
|
9
|
+
- * def test
|
10
|
+
- * a = 1
|
11
|
+
- * b = 2
|
12
|
+
- * end
|
13
|
+
+ * def test
|
14
|
+
+ * a = 1
|
15
|
+
+ * b = 2
|
16
|
+
+ * end
|
17
|
+
* end
|
18
|
+
*
|
19
|
+
* set_trace_func proc { |event, file, line, id, binding, classname|
|
20
|
+
- * printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
|
21
|
+
+ * printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
|
22
|
+
* }
|
23
|
+
* t = Test.new
|
24
|
+
* t.test
|
25
|
+
- *
|
26
|
+
- * line prog.rb:11 false
|
27
|
+
+ * set_trace_func nil
|
28
|
+
+ *
|
29
|
+
+ * Running the file we obtain:
|
30
|
+
+ *
|
31
|
+
+ * $ ruby prog.rb
|
32
|
+
+ * c-return prog.rb:8 set_trace_func Kernel
|
33
|
+
+ * line prog.rb:11
|
34
|
+
* c-call prog.rb:11 new Class
|
35
|
+
- * c-call prog.rb:11 initialize Object
|
36
|
+
- * c-return prog.rb:11 initialize Object
|
37
|
+
+ * c-call prog.rb:11 initialize BasicObject
|
38
|
+
+ * c-return prog.rb:11 initialize BasicObject
|
39
|
+
* c-return prog.rb:11 new Class
|
40
|
+
- * line prog.rb:12 false
|
41
|
+
- * call prog.rb:2 test Test
|
42
|
+
- * line prog.rb:3 test Test
|
43
|
+
- * line prog.rb:4 test Test
|
44
|
+
- * return prog.rb:4 test Test
|
45
|
+
+ * line prog.rb:12
|
46
|
+
+ * call prog.rb:2 test Test
|
47
|
+
+ * line prog.rb:3 test Test
|
48
|
+
+ * line prog.rb:4 test Test
|
49
|
+
+ * return prog.rb:5 test Test
|
50
|
+
+ * line prog.rb:13
|
51
|
+
+ * c-call prog.rb:13 set_trace_func Kernel
|
52
|
+
*/
|
53
|
+
|
54
|
+
static VALUE
|
55
|
+
@@ -850,23 +858,32 @@
|
56
|
+
/*
|
57
|
+
* Return class or module of the method being called.
|
58
|
+
*
|
59
|
+
- * class C; def foo; end; end
|
60
|
+
- * trace = TracePoint.new(:call) do |tp|
|
61
|
+
- * p tp.defined_class #=> C
|
62
|
+
- * end.enable do
|
63
|
+
- * C.new.foo
|
64
|
+
- * end
|
65
|
+
+ * class C; def foo; end; end
|
66
|
+
+ * trace = TracePoint.new(:call) do |tp|
|
67
|
+
+ * puts tp.defined_class
|
68
|
+
+ * end.enable do
|
69
|
+
+ * C.new.foo
|
70
|
+
+ * end
|
71
|
+
+ *
|
72
|
+
+ * produces:
|
73
|
+
+ *
|
74
|
+
+ * C
|
75
|
+
*
|
76
|
+
* If method is defined by a module, then that module is returned.
|
77
|
+
+ * :rdx: new_binding
|
78
|
+
*
|
79
|
+
- * module M; def foo; end; end
|
80
|
+
- * class C; include M; end;
|
81
|
+
- * trace = TracePoint.new(:call) do |tp|
|
82
|
+
- * p tp.defined_class #=> M
|
83
|
+
- * end.enable do
|
84
|
+
- * C.new.foo
|
85
|
+
- * end
|
86
|
+
- *
|
87
|
+
+ * module M; def foo; end; end
|
88
|
+
+ * class C; include M; end;
|
89
|
+
+ * trace = TracePoint.new(:call) do |tp|
|
90
|
+
+ * puts tp.defined_class
|
91
|
+
+ * end.enable do
|
92
|
+
+ * C.new.foo
|
93
|
+
+ * end
|
94
|
+
+ *
|
95
|
+
+ * produces:
|
96
|
+
+ *
|
97
|
+
+ * M
|
98
|
+
+ *
|
99
|
+
* <b>Note:</b> #defined_class returns singleton class.
|
100
|
+
*
|
101
|
+
* 6th block parameter of Kernel#set_trace_func passes original class
|
102
|
+
@@ -874,12 +891,17 @@
|
103
|
+
*
|
104
|
+
* <b>This is a difference between Kernel#set_trace_func and TracePoint.</b>
|
105
|
+
*
|
106
|
+
- * class C; def self.foo; end; end
|
107
|
+
- * trace = TracePoint.new(:call) do |tp|
|
108
|
+
- * p tp.defined_class #=> #<Class:C>
|
109
|
+
- * end.enable do
|
110
|
+
- * C.foo
|
111
|
+
- * end
|
112
|
+
+ * class C; def self.foo; end; end
|
113
|
+
+ * trace = TracePoint.new(:call) do |tp|
|
114
|
+
+ * puts tp.defined_class
|
115
|
+
+ * end.enable do
|
116
|
+
+ * C.foo
|
117
|
+
+ * end
|
118
|
+
+ *
|
119
|
+
+ * produces:
|
120
|
+
+ *
|
121
|
+
+ * #<Class:C>
|
122
|
+
+ *
|
123
|
+
*/
|
124
|
+
static VALUE
|
125
|
+
tracepoint_attr_defined_class(VALUE tpval)
|
126
|
+
@@ -900,7 +922,8 @@
|
127
|
+
* Return the trace object during event
|
128
|
+
*
|
129
|
+
* Same as TracePoint#binding:
|
130
|
+
- * trace.binding.eval('self')
|
131
|
+
+ * :rdx: off -
|
132
|
+
+ * trace.binding.eval('self')
|
133
|
+
*/
|
134
|
+
static VALUE
|
135
|
+
tracepoint_attr_self(VALUE tpval)
|
136
|
+
@@ -979,39 +1002,45 @@
|
137
|
+
|
138
|
+
/*
|
139
|
+
* call-seq:
|
140
|
+
- * trace.enable -> true or false
|
141
|
+
- * trace.enable { block } -> obj
|
142
|
+
+ * trace.enable -> true or false
|
143
|
+
+ * trace.enable { block } -> obj
|
144
|
+
*
|
145
|
+
* Activates the trace
|
146
|
+
*
|
147
|
+
* Return true if trace was enabled.
|
148
|
+
* Return false if trace was disabled.
|
149
|
+
*
|
150
|
+
- * trace.enabled? #=> false
|
151
|
+
- * trace.enable #=> false (previous state)
|
152
|
+
+ *-- rdx
|
153
|
+
+ * trace = TracePoint.new{}
|
154
|
+
+ *++
|
155
|
+
+ * trace.enabled? #=> false
|
156
|
+
+ * trace.enable #=> false # previous state
|
157
|
+
* # trace is enabled
|
158
|
+
- * trace.enabled? #=> true
|
159
|
+
- * trace.enable #=> true (previous state)
|
160
|
+
+ * trace.enabled? #=> true
|
161
|
+
+ * trace.enable #=> true # previous state
|
162
|
+
* # trace is still enabled
|
163
|
+
*
|
164
|
+
* If a block is given, the trace will only be enabled within the scope of the
|
165
|
+
* block.
|
166
|
+
*
|
167
|
+
- * trace.enabled?
|
168
|
+
- * #=> false
|
169
|
+
- *
|
170
|
+
- * trace.enable do
|
171
|
+
- * trace.enabled?
|
172
|
+
- * # only enabled for this block
|
173
|
+
- * end
|
174
|
+
+ *-- rdx
|
175
|
+
+ * trace.disable
|
176
|
+
+ *++
|
177
|
+
+ * trace.enabled?
|
178
|
+
+ * #=> false
|
179
|
+
+ *
|
180
|
+
+ * trace.enable do
|
181
|
+
+ * # only enabled for this block
|
182
|
+
+ * trace.enabled?
|
183
|
+
+ * end #=> true
|
184
|
+
*
|
185
|
+
- * trace.enabled?
|
186
|
+
- * #=> false
|
187
|
+
+ * trace.enabled?
|
188
|
+
+ * #=> false
|
189
|
+
*
|
190
|
+
* Note: You cannot access event hooks within the block.
|
191
|
+
*
|
192
|
+
- * trace.enable { p tp.lineno }
|
193
|
+
- * #=> RuntimeError: access from outside
|
194
|
+
+ * trace.enable { trace.lineno }
|
195
|
+
+ * # raises RuntimeError: access from outside
|
196
|
+
*
|
197
|
+
*/
|
198
|
+
static VALUE
|
199
|
+
@@ -1033,37 +1062,47 @@
|
200
|
+
|
201
|
+
/*
|
202
|
+
* call-seq:
|
203
|
+
- * trace.disable -> true or false
|
204
|
+
- * trace.disable { block } -> obj
|
205
|
+
+ * trace.disable -> true or false
|
206
|
+
+ * trace.disable { block } -> obj
|
207
|
+
*
|
208
|
+
* Deactivates the trace
|
209
|
+
*
|
210
|
+
* Return true if trace was enabled.
|
211
|
+
* Return false if trace was disabled.
|
212
|
+
*
|
213
|
+
- * trace.enabled? #=> true
|
214
|
+
- * trace.disable #=> false (previous status)
|
215
|
+
- * trace.enabled? #=> false
|
216
|
+
- * trace.disable #=> false
|
217
|
+
+ *-- rdx
|
218
|
+
+ * trace = TracePoint.new{}
|
219
|
+
+ * trace.enable
|
220
|
+
+ *++
|
221
|
+
+ * trace.enabled? #=> true
|
222
|
+
+ * trace.disable #=> true # previous status
|
223
|
+
+ * trace.enabled? #=> false
|
224
|
+
+ * trace.disable #=> false
|
225
|
+
*
|
226
|
+
* If a block is given, the trace will only be disable within the scope of the
|
227
|
+
* block.
|
228
|
+
*
|
229
|
+
- * trace.enabled?
|
230
|
+
- * #=> true
|
231
|
+
- *
|
232
|
+
- * trace.disable do
|
233
|
+
- * trace.enabled?
|
234
|
+
- * # only disabled for this block
|
235
|
+
- * end
|
236
|
+
- *
|
237
|
+
- * trace.enabled?
|
238
|
+
- * #=> true
|
239
|
+
+ *-- rdx
|
240
|
+
+ * trace.enable
|
241
|
+
+ *++
|
242
|
+
+ * trace.enabled?
|
243
|
+
+ * #=> true
|
244
|
+
+ *
|
245
|
+
+ * trace.disable do
|
246
|
+
+ * # only disabled for this block
|
247
|
+
+ * trace.enabled?
|
248
|
+
+ * end #=> false
|
249
|
+
+ *
|
250
|
+
+ * trace.enabled?
|
251
|
+
+ * #=> true
|
252
|
+
+ *-- rdx
|
253
|
+
+ * trace.disable
|
254
|
+
+ *++
|
255
|
+
*
|
256
|
+
* Note: You cannot access event hooks within the block.
|
257
|
+
*
|
258
|
+
- * trace.disable { p tp.lineno }
|
259
|
+
- * #=> RuntimeError: access from outside
|
260
|
+
+ * trace.disable { trace.lineno }
|
261
|
+
+ * # raises RuntimeError: access from outside
|
262
|
+
*/
|
263
|
+
static VALUE
|
264
|
+
tracepoint_disable_m(VALUE tpval)
|
265
|
+
@@ -1084,7 +1123,7 @@
|
266
|
+
|
267
|
+
/*
|
268
|
+
* call-seq:
|
269
|
+
- * trace.enabled? -> true or false
|
270
|
+
+ * trace.enabled? -> true or false
|
271
|
+
*
|
272
|
+
* The current status of the trace
|
273
|
+
*/
|
274
|
+
@@ -1126,28 +1165,40 @@
|
275
|
+
|
276
|
+
/*
|
277
|
+
* call-seq:
|
278
|
+
- * TracePoint.new(*events) { |obj| block } -> obj
|
279
|
+
+ * TracePoint.new(*events) { |obj| block } -> obj
|
280
|
+
*
|
281
|
+
* Returns a new TracePoint object, not enabled by default.
|
282
|
+
*
|
283
|
+
* Next, in order to activate the trace, you must use TracePoint.enable
|
284
|
+
*
|
285
|
+
- * trace = TracePoint.new(:call) do |tp|
|
286
|
+
- * p [tp.lineno, tp.defined_class, tp.method_id, tp.event]
|
287
|
+
- * end
|
288
|
+
- * #=> #<TracePoint:0x007f17372cdb20>
|
289
|
+
- *
|
290
|
+
- * trace.enable
|
291
|
+
- * #=> #<TracePoint:0x007f17372cdb20>
|
292
|
+
- *
|
293
|
+
- * puts "Hello, TracePoint!"
|
294
|
+
- * # ...
|
295
|
+
- * # [48, IRB::Notifier::AbstractNotifier, :printf, :call]
|
296
|
+
- * # ...
|
297
|
+
+ * trace = TracePoint.new(:call) do |tp|
|
298
|
+
+ * p [tp.lineno, tp.defined_class, tp.method_id, tp.event]
|
299
|
+
+ * end
|
300
|
+
+ * #=> #<TracePoint:0x007f17372cdb20>
|
301
|
+
+ *
|
302
|
+
+ * trace.enable
|
303
|
+
+ *
|
304
|
+
+ * puts "Hello, TracePoint!"
|
305
|
+
+ *
|
306
|
+
+ *-- rdx
|
307
|
+
+ * trace.disable
|
308
|
+
+ *++
|
309
|
+
+ *
|
310
|
+
+ * produces many lines of output, such as:
|
311
|
+
+ * :rdx: indicative_output
|
312
|
+
+ *
|
313
|
+
+ * ...
|
314
|
+
+ * [69, IRB::Notifier::AbstractNotifier, :printf, :call]
|
315
|
+
+ * [204, IRB::Notifier::LeveledNotifier, :notify?, :call]
|
316
|
+
+ * [198, IRB::Notifier::LeveledNotifier, :<=>, :call]
|
317
|
+
+ * [102, RubyLex, :getc, :call]
|
318
|
+
+ * [145, RubyLex, :ungetc, :call]
|
319
|
+
+ * ...
|
320
|
+
*
|
321
|
+
* When you want to deactivate the trace, you must use TracePoint.disable
|
322
|
+
+ * :rdx: discard_output
|
323
|
+
*
|
324
|
+
- * trace.disable
|
325
|
+
+ * trace.disable
|
326
|
+
*
|
327
|
+
* See TracePoint@Events for possible events and more information.
|
328
|
+
*
|
329
|
+
@@ -1155,18 +1206,24 @@
|
330
|
+
*
|
331
|
+
* If the trace method isn't included in the given events filter, a
|
332
|
+
* RuntimeError is raised.
|
333
|
+
+ * :rdx: off
|
334
|
+
+ * :rdx: # actually it doesn't seem a rescuable exception, but a message displayed to $stderr before exiting
|
335
|
+
*
|
336
|
+
- * TracePoint.trace(:line) do |tp|
|
337
|
+
- * p tp.raised_exception
|
338
|
+
- * end
|
339
|
+
- * #=> RuntimeError: 'raised_exception' not supported by this event
|
340
|
+
+ * TracePoint.trace(:line) do |tp|
|
341
|
+
+ * tp.raised_exception
|
342
|
+
+ * end
|
343
|
+
+ * #=> RuntimeError: 'raised_exception' not supported by this event
|
344
|
+
*
|
345
|
+
* If the trace method is called outside block, a RuntimeError is raised.
|
346
|
+
+ * :rdx: on
|
347
|
+
*
|
348
|
+
- * TracePoint.trace(:line) do |tp|
|
349
|
+
- * $tp = tp
|
350
|
+
- * end
|
351
|
+
- * $tp.line #=> access from outside (RuntimeError)
|
352
|
+
+ * TracePoint.trace(:line) do |tp|
|
353
|
+
+ * $tp = tp
|
354
|
+
+ * end
|
355
|
+
+ * $tp.lineno # raises RuntimeError: access from outside
|
356
|
+
+ *-- rdx
|
357
|
+
+ * $tp = nil
|
358
|
+
+ *++
|
359
|
+
*
|
360
|
+
* Access from other threads is also forbidden.
|
361
|
+
*
|
362
|
+
@@ -1275,16 +1332,23 @@
|
363
|
+
*
|
364
|
+
* We can use TracePoint to gather information specifically for exceptions:
|
365
|
+
*
|
366
|
+
- * trace = TracePoint.new(:raise) do |tp|
|
367
|
+
- * p [tp.lineno, tp.event, tp.raised_exception]
|
368
|
+
- * end
|
369
|
+
- * #=> #<TracePoint:0x007f786a452448>
|
370
|
+
+ * trace = TracePoint.new(:raise) do |tp|
|
371
|
+
+ * p [tp.method_id, tp.event, tp.raised_exception]
|
372
|
+
+ * end
|
373
|
+
+ * #=> #<TracePoint:0x007f786a452448>
|
374
|
+
*
|
375
|
+
- * trace.enable
|
376
|
+
- * #=> #<TracePoint:0x007f786a452448>
|
377
|
+
+ * trace.enable
|
378
|
+
+ * #=> false
|
379
|
+
*
|
380
|
+
- * 0 / 0
|
381
|
+
- * #=> [5, :raise, #<ZeroDivisionError: divided by 0>]
|
382
|
+
+ * begin
|
383
|
+
+ * 0 / 0
|
384
|
+
+ * rescue
|
385
|
+
+ * trace.disable
|
386
|
+
+ * end
|
387
|
+
+ *
|
388
|
+
+ * produces:
|
389
|
+
+ *
|
390
|
+
+ * [:/, :raise, #<ZeroDivisionError: divided by 0>]
|
391
|
+
*
|
392
|
+
* == Events
|
393
|
+
*
|