ruby-debug-base19x 0.11.30.pre3 → 0.11.30.pre4

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.
Files changed (2) hide show
  1. data/ext/ruby_debug/ruby_debug.c +38 -83
  2. metadata +10 -10
@@ -9,7 +9,7 @@
9
9
  #include <insns_info.inc>
10
10
  #include "ruby_debug.h"
11
11
 
12
- #define DEBUG_VERSION "0.11.30.pre3"
12
+ #define DEBUG_VERSION "0.11.30.pre4"
13
13
 
14
14
  #define FRAME_N(n) (&debug_context->frames[debug_context->stack_size-(n)-1])
15
15
  #define GET_FRAME (FRAME_N(check_frame_number(debug_context, frame)))
@@ -134,55 +134,16 @@ real_class(VALUE klass)
134
134
  return klass;
135
135
  }
136
136
 
137
- inline static void *
138
- ruby_method_ptr(VALUE class, ID meth_id)
139
- {
140
- #ifndef HAVE_RB_METHOD_ENTRY
141
- NODE *body, *method;
142
- st_lookup(RCLASS_M_TBL(class), meth_id, (st_data_t *)&body);
143
- method = (NODE *)body->u2.value;
144
- return (void *)method->u2.node->u1.value;
145
- #else
146
- rb_method_entry_t * method;
147
- method = rb_method_entry(class, meth_id);
148
- #ifdef HAVE_ST_BODY
149
- return (void *)method->body.cfunc.func;
150
- #else
151
- return (void *)method->def->body.cfunc.func;
152
- #endif
153
- #endif
154
- }
155
-
156
137
  inline static VALUE
157
138
  ref2id(VALUE obj)
158
139
  {
159
- return rb_obj_id(obj);
140
+ return obj;
160
141
  }
161
142
 
162
- static VALUE
163
- id2ref_unprotected(VALUE id)
164
- {
165
- typedef VALUE (*id2ref_func_t)(VALUE, VALUE);
166
- static id2ref_func_t f_id2ref = NULL;
167
- if(f_id2ref == NULL)
168
- {
169
- f_id2ref = (id2ref_func_t)ruby_method_ptr(rb_mObjectSpace, rb_intern("_id2ref"));
170
- }
171
- return f_id2ref(rb_mObjectSpace, id);
172
- }
173
-
174
- static VALUE
175
- id2ref_error()
176
- {
177
- if(debug == Qtrue)
178
- rb_p(rb_errinfo());
179
- return Qnil;
180
- }
181
-
182
- static VALUE
143
+ inline static VALUE
183
144
  id2ref(VALUE id)
184
145
  {
185
- return rb_rescue(id2ref_unprotected, id, id2ref_error, 0);
146
+ return id;
186
147
  }
187
148
 
188
149
  inline static VALUE
@@ -256,10 +217,22 @@ remove_from_locked()
256
217
  return thread;
257
218
  }
258
219
 
220
+ static int is_living_thread(VALUE thread);
221
+
259
222
  static int
260
- threads_table_mark_keyvalue(VALUE key, VALUE value, int dummy)
223
+ threads_table_mark_keyvalue(st_data_t key, st_data_t value, st_data_t tbl)
261
224
  {
262
- rb_gc_mark(value);
225
+ VALUE thread = id2ref((VALUE)key);
226
+ if (!value) {
227
+ return ST_CONTINUE;
228
+ }
229
+ rb_gc_mark((VALUE)value);
230
+ if (is_living_thread(thread)) {
231
+ rb_gc_mark(thread);
232
+ }
233
+ else {
234
+ st_insert((st_table *)tbl, key, 0);
235
+ }
263
236
  return ST_CONTINUE;
264
237
  }
265
238
 
@@ -267,7 +240,8 @@ static void
267
240
  threads_table_mark(void* data)
268
241
  {
269
242
  threads_table_t *threads_table = (threads_table_t*)data;
270
- st_foreach(threads_table->tbl, threads_table_mark_keyvalue, 0);
243
+ st_table *tbl = threads_table->tbl;
244
+ st_foreach(tbl, threads_table_mark_keyvalue, (st_data_t)tbl);
271
245
  }
272
246
 
273
247
  static void
@@ -279,7 +253,7 @@ threads_table_free(void* data)
279
253
  }
280
254
 
281
255
  static VALUE
282
- threads_table_create()
256
+ threads_table_create(void)
283
257
  {
284
258
  threads_table_t *threads_table;
285
259
 
@@ -288,44 +262,40 @@ threads_table_create()
288
262
  return Data_Wrap_Struct(cThreadsTable, threads_table_mark, threads_table_free, threads_table);
289
263
  }
290
264
 
291
- static int
292
- threads_table_clear_i(VALUE key, VALUE value, VALUE dummy)
293
- {
294
- return ST_DELETE;
295
- }
296
-
297
265
  static void
298
266
  threads_table_clear(VALUE table)
299
267
  {
300
268
  threads_table_t *threads_table;
301
269
 
302
270
  Data_Get_Struct(table, threads_table_t, threads_table);
303
- st_foreach(threads_table->tbl, threads_table_clear_i, 0);
271
+ st_clear(threads_table->tbl);
304
272
  }
305
273
 
306
- static VALUE
274
+ static int
307
275
  is_thread_alive(VALUE thread)
308
276
  {
309
- typedef VALUE (*thread_alive_func_t)(VALUE);
310
- static thread_alive_func_t f_thread_alive = NULL;
311
- if(!f_thread_alive)
312
- {
313
- f_thread_alive = (thread_alive_func_t)ruby_method_ptr(rb_cThread, rb_intern("alive?"));
314
- }
315
- return f_thread_alive(thread);
277
+ rb_thread_t *th;
278
+ GetThreadPtr(thread, th);
279
+ return th->status != THREAD_KILLED;
316
280
  }
317
281
 
318
282
  static int
319
- threads_table_check_i(VALUE key, VALUE value, VALUE dummy)
283
+ is_living_thread(VALUE thread)
284
+ {
285
+ return rb_obj_is_kind_of(thread, rb_cThread) && is_thread_alive(thread);
286
+ }
287
+
288
+ static int
289
+ threads_table_check_i(st_data_t key, st_data_t value, st_data_t dummy)
320
290
  {
321
291
  VALUE thread;
322
292
 
323
- thread = id2ref(key);
324
- if(!rb_obj_is_kind_of(thread, rb_cThread))
293
+ if(!value)
325
294
  {
326
295
  return ST_DELETE;
327
296
  }
328
- if(rb_protect(is_thread_alive, thread, 0) != Qtrue)
297
+ thread = id2ref((VALUE)key);
298
+ if(!is_living_thread(thread))
329
299
  {
330
300
  return ST_DELETE;
331
301
  }
@@ -333,7 +303,7 @@ threads_table_check_i(VALUE key, VALUE value, VALUE dummy)
333
303
  }
334
304
 
335
305
  static void
336
- check_thread_contexts()
306
+ check_thread_contexts(void)
337
307
  {
338
308
  threads_table_t *threads_table;
339
309
 
@@ -740,11 +710,6 @@ debug_event_hook(rb_event_flag_t event, VALUE data, VALUE self, ID mid, VALUE kl
740
710
  char *file = (char*)rb_sourcefile();
741
711
  int line = rb_sourceline();
742
712
  int moved = 0;
743
- #ifndef HAVE_RB_METHOD_ENTRY
744
- NODE *node = NULL;
745
- #else
746
- rb_method_entry_t *me = NULL;
747
- #endif
748
713
  rb_thread_t *thread = GET_THREAD();
749
714
  struct rb_iseq_struct *iseq = thread->cfp->iseq;
750
715
 
@@ -762,12 +727,6 @@ debug_event_hook(rb_event_flag_t event, VALUE data, VALUE self, ID mid, VALUE kl
762
727
 
763
728
  if (mid == ID_ALLOCATOR) return;
764
729
 
765
- #ifndef HAVE_RB_METHOD_ENTRY
766
- node = rb_method_node(klass, mid);
767
- #else
768
- me = rb_method_entry(klass, mid);
769
- #endif
770
-
771
730
  /* return if thread is marked as 'ignored'.
772
731
  debugger's threads are marked this way
773
732
  */
@@ -978,11 +937,7 @@ debug_event_hook(rb_event_flag_t event, VALUE data, VALUE self, ID mid, VALUE kl
978
937
  case RUBY_EVENT_C_RETURN:
979
938
  {
980
939
  /* note if a block is given we fall through! */
981
- #ifndef HAVE_RB_METHOD_ENTRY
982
- if(!node || !c_call_new_frame_p(klass, mid))
983
- #else
984
- if(!me || !c_call_new_frame_p(klass, mid))
985
- #endif
940
+ if(!rb_method_boundp(klass, mid, 0) || !c_call_new_frame_p(klass, mid))
986
941
  break;
987
942
  }
988
943
  case RUBY_EVENT_RETURN:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-debug-base19x
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.30.pre3
4
+ version: 0.11.30.pre4
5
5
  prerelease: 8
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-28 00:00:00.000000000Z
12
+ date: 2011-11-14 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: columnize
16
- requirement: &70263133374820 !ruby/object:Gem::Requirement
16
+ requirement: &70102561752300 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.3.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70263133374820
24
+ version_requirements: *70102561752300
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: ruby_core_source
27
- requirement: &70263133374340 !ruby/object:Gem::Requirement
27
+ requirement: &70102561751820 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.1.4
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70263133374340
35
+ version_requirements: *70102561751820
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: linecache19
38
- requirement: &70263133373860 !ruby/object:Gem::Requirement
38
+ requirement: &70102561751340 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.5.11
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70263133373860
46
+ version_requirements: *70102561751340
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &70263133373400 !ruby/object:Gem::Requirement
49
+ requirement: &70102561767260 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 0.8.1
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70263133373400
57
+ version_requirements: *70102561767260
58
58
  description: ! 'ruby-debug is a fast implementation of the standard Ruby debugger
59
59
  debug.rb.
60
60