debase 0.2.2.beta9 → 0.2.2.beta10
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 +4 -4
- data/.gitignore +6 -6
- data/ext/breakpoint.c +39 -5
- data/ext/debase_internals.c +1 -1
- data/ext/debase_internals.h +1 -1
- data/lib/debase/version.rb +1 -1
- data/test/test_breakpoints.rb +23 -3
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79fde9e93badfd98fb0fbe1f7f625d154dc9b4f4
|
4
|
+
data.tar.gz: 956c8b8bf4d1d2355440bbb98f76cd3df5ba256e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be07ccaac91b1707899b07424dbf0a633c3c5ca4695d1cd424cbe17e4b65cbb826a12aee67e7a82d8d08f450a8a93d6b6c85c5a3502dd1b95932af9c76fc33e9
|
7
|
+
data.tar.gz: 91a164dee212080ebe56f434579a49ff07951a41633eb80cd3e83ba2d6144d83a0b117f6dcf76926a70e6825ce63c0cfab8cef689330f421e44c29eb09aa0395
|
data/.gitignore
CHANGED
data/ext/breakpoint.c
CHANGED
@@ -13,6 +13,14 @@
|
|
13
13
|
static VALUE cBreakpoint;
|
14
14
|
static int breakpoint_max;
|
15
15
|
|
16
|
+
static ID idEval;
|
17
|
+
|
18
|
+
static VALUE
|
19
|
+
eval_expression(VALUE args)
|
20
|
+
{
|
21
|
+
return rb_funcall2(rb_mKernel, idEval, 2, RARRAY_PTR(args));
|
22
|
+
}
|
23
|
+
|
16
24
|
extern VALUE
|
17
25
|
catchpoint_hit_count(VALUE catchpoints, VALUE exception, VALUE *exception_name) {
|
18
26
|
VALUE ancestors;
|
@@ -191,14 +199,37 @@ check_breakpoint_by_pos(VALUE breakpoint_object, char *file, int line)
|
|
191
199
|
return 0;
|
192
200
|
}
|
193
201
|
|
202
|
+
static int
|
203
|
+
check_breakpoint_expr(VALUE breakpoint_object, VALUE trace_point)
|
204
|
+
{
|
205
|
+
breakpoint_t *breakpoint;
|
206
|
+
VALUE binding, args, result;
|
207
|
+
int error;
|
208
|
+
|
209
|
+
if(breakpoint_object == Qnil) return 0;
|
210
|
+
Data_Get_Struct(breakpoint_object, breakpoint_t, breakpoint);
|
211
|
+
if (Qtrue != breakpoint->enabled) return 0;
|
212
|
+
if (NIL_P(breakpoint->expr)) return 1;
|
213
|
+
|
214
|
+
if (NIL_P(trace_point)) {
|
215
|
+
binding = rb_const_get(rb_cObject, rb_intern("TOPLEVEL_BINDING"));
|
216
|
+
} else {
|
217
|
+
binding = rb_tracearg_binding(rb_tracearg_from_tracepoint(trace_point));
|
218
|
+
}
|
219
|
+
|
220
|
+
args = rb_ary_new3(2, breakpoint->expr, binding);
|
221
|
+
result = rb_protect(eval_expression, args, &error);
|
222
|
+
return !error && RTEST(result);
|
223
|
+
}
|
224
|
+
|
194
225
|
static VALUE
|
195
|
-
Breakpoint_find(VALUE self, VALUE breakpoints, VALUE source, VALUE pos)
|
226
|
+
Breakpoint_find(VALUE self, VALUE breakpoints, VALUE source, VALUE pos, VALUE trace_point)
|
196
227
|
{
|
197
|
-
return breakpoint_find(breakpoints, source, pos);
|
228
|
+
return breakpoint_find(breakpoints, source, pos, trace_point);
|
198
229
|
}
|
199
230
|
|
200
231
|
extern VALUE
|
201
|
-
breakpoint_find(VALUE breakpoints, VALUE source, VALUE pos)
|
232
|
+
breakpoint_find(VALUE breakpoints, VALUE source, VALUE pos, VALUE trace_point)
|
202
233
|
{
|
203
234
|
VALUE breakpoint_object;
|
204
235
|
char *file;
|
@@ -210,7 +241,8 @@ breakpoint_find(VALUE breakpoints, VALUE source, VALUE pos)
|
|
210
241
|
for(i = 0; i < RARRAY_LENINT(breakpoints); i++)
|
211
242
|
{
|
212
243
|
breakpoint_object = rb_ary_entry(breakpoints, i);
|
213
|
-
if (check_breakpoint_by_pos(breakpoint_object, file, line)
|
244
|
+
if (check_breakpoint_by_pos(breakpoint_object, file, line) &&
|
245
|
+
check_breakpoint_expr(breakpoint_object, trace_point))
|
214
246
|
{
|
215
247
|
return breakpoint_object;
|
216
248
|
}
|
@@ -229,11 +261,13 @@ Init_breakpoint(VALUE mDebase)
|
|
229
261
|
{
|
230
262
|
breakpoint_init_variables();
|
231
263
|
cBreakpoint = rb_define_class_under(mDebase, "Breakpoint", rb_cObject);
|
232
|
-
rb_define_singleton_method(cBreakpoint, "find", Breakpoint_find,
|
264
|
+
rb_define_singleton_method(cBreakpoint, "find", Breakpoint_find, 4);
|
233
265
|
rb_define_singleton_method(cBreakpoint, "remove", Breakpoint_remove, 2);
|
234
266
|
rb_define_method(cBreakpoint, "initialize", Breakpoint_initialize, 3);
|
235
267
|
rb_define_method(cBreakpoint, "id", Breakpoint_id, 0);
|
236
268
|
rb_define_method(cBreakpoint, "source", Breakpoint_source, 0);
|
237
269
|
rb_define_method(cBreakpoint, "pos", Breakpoint_pos, 0);
|
238
270
|
rb_define_alloc_func(cBreakpoint, Breakpoint_create);
|
271
|
+
|
272
|
+
idEval = rb_intern("eval");
|
239
273
|
}
|
data/ext/debase_internals.c
CHANGED
@@ -371,7 +371,7 @@ process_line_event(VALUE trace_point, void *data)
|
|
371
371
|
context->stop_frame = -1;
|
372
372
|
}
|
373
373
|
|
374
|
-
breakpoint = breakpoint_find(breakpoints, path, lineno);
|
374
|
+
breakpoint = breakpoint_find(breakpoints, path, lineno, trace_point);
|
375
375
|
if (context->stop_next == 0 || context->stop_line == 0 || breakpoint != Qnil) {
|
376
376
|
rb_ensure(start_inspector, context_object, stop_inspector, Qnil);
|
377
377
|
context->stop_reason = CTX_STOP_STEP;
|
data/ext/debase_internals.h
CHANGED
@@ -103,7 +103,7 @@ typedef struct
|
|
103
103
|
} breakpoint_t;
|
104
104
|
|
105
105
|
extern VALUE catchpoint_hit_count(VALUE catchpoints, VALUE exception, VALUE *exception_name);
|
106
|
-
extern VALUE breakpoint_find(VALUE breakpoints, VALUE source, VALUE pos);
|
106
|
+
extern VALUE breakpoint_find(VALUE breakpoints, VALUE source, VALUE pos, VALUE trace_point);
|
107
107
|
extern void Init_breakpoint(VALUE mDebase);
|
108
108
|
|
109
109
|
extern void breakpoint_init_variables();
|
data/lib/debase/version.rb
CHANGED
data/test/test_breakpoints.rb
CHANGED
@@ -6,9 +6,29 @@ class TestBreakpoints < Test::Unit::TestCase
|
|
6
6
|
def test_find
|
7
7
|
Debugger.start
|
8
8
|
Debugger.add_breakpoint("foo.rb", 11, nil)
|
9
|
-
assert_not_nil(Debugger::Breakpoint.find(Debugger.breakpoints, "foo.rb", 11))
|
10
|
-
assert_nil(Debugger::Breakpoint.find(Debugger.breakpoints, "bar.rb", 11))
|
11
|
-
assert_nil(Debugger::Breakpoint.find(Debugger.breakpoints, "foo.rb", 10))
|
9
|
+
assert_not_nil(Debugger::Breakpoint.find(Debugger.breakpoints, "foo.rb", 11, nil))
|
10
|
+
assert_nil(Debugger::Breakpoint.find(Debugger.breakpoints, "bar.rb", 11, nil))
|
11
|
+
assert_nil(Debugger::Breakpoint.find(Debugger.breakpoints, "foo.rb", 10, nil))
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_conditional_true_expression
|
15
|
+
Debugger.start
|
16
|
+
Debugger.add_breakpoint("foo.rb", 11, "[1, 2, 3].length == 3")
|
17
|
+
assert_not_nil(Debugger::Breakpoint.find(Debugger.breakpoints, "foo.rb", 11, nil))
|
18
|
+
Debugger.stop
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_conditional_false_expression
|
22
|
+
Debugger.start
|
23
|
+
Debugger.add_breakpoint("foo.rb", 11, "(2 + 2) == 5")
|
24
|
+
assert_nil(Debugger::Breakpoint.find(Debugger.breakpoints, "foo.rb", 11, nil))
|
25
|
+
Debugger.stop
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_conditional_undefined_variable
|
29
|
+
Debugger.start
|
30
|
+
Debugger.add_breakpoint("foo.rb", 11, "this_variable_does_not_exist")
|
31
|
+
assert_nil(Debugger::Breakpoint.find(Debugger.breakpoints, "foo.rb", 11, nil))
|
12
32
|
Debugger.stop
|
13
33
|
end
|
14
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.2.
|
4
|
+
version: 0.2.2.beta10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dennis Ushakov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debase-ruby_core_source
|
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: 1.3.1
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project: debase
|
138
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.5.1
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: debase is a fast implementation of the standard Ruby debugger debug.rb for
|
@@ -165,4 +165,3 @@ test_files:
|
|
165
165
|
- test/test_catchpoint.rb
|
166
166
|
- test/test_load.rb
|
167
167
|
- test/test_reload_bug.rb
|
168
|
-
has_rdoc:
|