debase 0.2.2.beta9 → 0.2.2.beta10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 72f6bca149dbf44230032e0bc5232ed4dfbf1790
4
- data.tar.gz: 1e1d31d2b83bcbd464ea32d0ad46b1f0f5c276d3
3
+ metadata.gz: 79fde9e93badfd98fb0fbe1f7f625d154dc9b4f4
4
+ data.tar.gz: 956c8b8bf4d1d2355440bbb98f76cd3df5ba256e
5
5
  SHA512:
6
- metadata.gz: ef7fbb2819851e3fc04bda8532eb07a2da3c8be2c206dfdd0d8c056f4e19e376a48842b3f35ad350b2ffedc0e9aec4ec7b621bebd0a612cd830eedda45cb2f48
7
- data.tar.gz: 7ca7fe17d565d711e67b6754fc04b04174bf8bad8a86fd4a0ed9d20905c42d4655eee94d8a1893674ac8713c4f6e3deebe381e8d135be6113c6d3f3978f46d74
6
+ metadata.gz: be07ccaac91b1707899b07424dbf0a633c3c5ca4695d1cd424cbe17e4b65cbb826a12aee67e7a82d8d08f450a8a93d6b6c85c5a3502dd1b95932af9c76fc33e9
7
+ data.tar.gz: 91a164dee212080ebe56f434579a49ff07951a41633eb80cd3e83ba2d6144d83a0b117f6dcf76926a70e6825ce63c0cfab8cef689330f421e44c29eb09aa0395
data/.gitignore CHANGED
@@ -2,12 +2,12 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
- ext/*.o
6
- ext/*.bundle
7
- ext/Makefile
8
- ext/*.log
5
+ ext/**/*.o
6
+ ext/**/*.bundle
7
+ ext/**/Makefile
8
+ ext/**/*.log
9
+ ext/**/*.so
10
+ ext/**/*.def
9
11
  .ruby-gemset
10
12
  .ruby-version
11
13
  .idea/*
12
-
13
-
@@ -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, 3);
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
  }
@@ -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;
@@ -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();
@@ -1,3 +1,3 @@
1
1
  module Debase
2
- VERSION = "0.2.2.beta9" unless defined? VERSION
2
+ VERSION = "0.2.2.beta10" unless defined? VERSION
3
3
  end
@@ -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.beta9
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: 2016-11-10 00:00:00.000000000 Z
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.4.8
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: