ruby-debug 0.4-mswin32 → 0.4.1-mswin32

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.
data/CHANGES CHANGED
@@ -1,3 +1,7 @@
1
+ 0.4.1
2
+ - New binding_n method for Kernel module.
3
+ - Bugfixes.
4
+
1
5
  0.4
2
6
  - Debugger.start method takes a block. If a block is specified, this method starts debugger, yields to the block
3
7
  and stops debugger at the end.
@@ -6,7 +10,7 @@
6
10
  - 'eval on/off' controls the evaluation of unknown command.
7
11
  - Debugger reads readline history file .rdebug_hist at startup and saves it at exit.
8
12
  - 'sa[ve] <file>' command can be used to save current breackpoints and catchpoint if any
9
- - 'sc[ript] <file' command can be used to run script file. Script files can contain only control commands.
13
+ - 'sc[ript] <file>' command can be used to run script file. Script files can contain only control commands.
10
14
  - rdebug script accepts '--script FILE' parameter.
11
15
  - thread commands are available for the control port.
12
16
 
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/rdoctask'
5
5
  SO_NAME = "ruby_debug.so"
6
6
 
7
7
  # ------- Default Package ----------
8
- RUBY_DEBUG_VERSION = "0.4"
8
+ RUBY_DEBUG_VERSION = "0.4.1"
9
9
 
10
10
  FILES = FileList[
11
11
  'Rakefile',
data/ext/ruby_debug.c CHANGED
@@ -4,7 +4,7 @@
4
4
  #include <rubysig.h>
5
5
  #include <st.h>
6
6
 
7
- #define DEBUG_VERSION "0.4"
7
+ #define DEBUG_VERSION "0.4.1"
8
8
 
9
9
  typedef struct {
10
10
  int thnum;
@@ -45,6 +45,9 @@ static VALUE cContext;
45
45
  static VALUE cFrame;
46
46
  static VALUE cBreakpoint;
47
47
 
48
+ static VALUE file_separator;
49
+ static VALUE alt_file_separator;
50
+
48
51
  static ID idAtLine;
49
52
  static ID idAtBreakpoint;
50
53
  static ID idAtCatchpoint;
@@ -54,6 +57,7 @@ static ID idBasename;
54
57
  static ID idEval;
55
58
  static ID idList;
56
59
  static ID idClear;
60
+ static ID idIndex;
57
61
 
58
62
  static int thnum_max = 0;
59
63
  static int last_debugged_thnum = -1;
@@ -230,6 +234,27 @@ basename(VALUE filename)
230
234
  return rb_funcall(rb_cFile, idBasename, 1, filename);
231
235
  }
232
236
 
237
+ static int
238
+ filename_cmp(debug_breakpoint_t *debug_breakpoint, VALUE file)
239
+ {
240
+ VALUE flag = Qnil;
241
+
242
+ flag = rb_funcall(debug_breakpoint->source, idIndex, 1, file_separator);
243
+ if(alt_file_separator != Qnil && flag == Qnil)
244
+ flag = rb_funcall(debug_breakpoint->source, idIndex, 1, alt_file_separator);
245
+ if(flag == Qnil)
246
+ file = basename(file);
247
+ else
248
+ file = rb_file_expand_path(file, Qnil);
249
+ return(rb_str_cmp(debug_breakpoint->source, file) == 0);
250
+ }
251
+
252
+ static int
253
+ classname_cmp(debug_breakpoint_t *debug_breakpoint, VALUE klass)
254
+ {
255
+ return (klass != Qnil && rb_str_cmp(debug_breakpoint->source, rb_mod_name(klass)) == 0);
256
+ }
257
+
233
258
  static int
234
259
  check_breakpoints(debug_context_t *debug_context, VALUE file, VALUE klass, VALUE pos)
235
260
  {
@@ -249,8 +274,7 @@ check_breakpoints(debug_context_t *debug_context, VALUE file, VALUE klass, VALUE
249
274
  if(debug_breakpoint->pos != pos && !(TYPE(pos) == T_STRING &&
250
275
  TYPE(debug_breakpoint->pos) == T_STRING && rb_str_cmp(debug_breakpoint->pos, pos) == 0))
251
276
  continue;
252
- if((rb_str_cmp(debug_breakpoint->source, basename(file)) == 0) ||
253
- (klass != Qnil && rb_str_cmp(debug_breakpoint->source, rb_mod_name(klass)) == 0))
277
+ if(filename_cmp(debug_breakpoint, file) || classname_cmp(debug_breakpoint, klass))
254
278
  return i;
255
279
  }
256
280
  return -1;
@@ -350,7 +374,7 @@ debug_event_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass)
350
374
  switch(event)
351
375
  {
352
376
  case RUBY_EVENT_LINE:
353
- {
377
+ {
354
378
  set_frame_source(debug_context, file, line);
355
379
 
356
380
  if(RTEST(tracing) || debug_context->tracing )
@@ -402,14 +426,14 @@ debug_event_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass)
402
426
  call_at_line(context, debug_context->thnum, binding, file, line);
403
427
  }
404
428
  break;
405
- }
429
+ }
406
430
  case RUBY_EVENT_C_CALL:
407
- {
408
- set_frame_source(debug_context, file, line);
409
- break;
410
- }
431
+ {
432
+ set_frame_source(debug_context, file, line);
433
+ break;
434
+ }
411
435
  case RUBY_EVENT_CALL:
412
- {
436
+ {
413
437
  save_call_frame(self, file, line, mid, debug_context);
414
438
  breakpoint_index = check_breakpoints(debug_context, file, klass, rb_str_new2(rb_id2name(mid)));
415
439
  if(breakpoint_index != -1)
@@ -423,10 +447,10 @@ debug_event_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass)
423
447
  }
424
448
  }
425
449
  break;
426
- }
450
+ }
427
451
  case RUBY_EVENT_RETURN:
428
452
  case RUBY_EVENT_END:
429
- {
453
+ {
430
454
  if(RARRAY(debug_context->frames)->len == debug_context->stop_frame)
431
455
  {
432
456
  debug_context->stop_next = 1;
@@ -434,14 +458,14 @@ debug_event_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass)
434
458
  }
435
459
  rb_ary_shift(debug_context->frames);
436
460
  break;
437
- }
461
+ }
438
462
  case RUBY_EVENT_CLASS:
439
- {
440
- save_call_frame(self, file, line, mid, debug_context);
441
- break;
442
- }
463
+ {
464
+ save_call_frame(self, file, line, mid, debug_context);
465
+ break;
466
+ }
443
467
  case RUBY_EVENT_RAISE:
444
- {
468
+ {
445
469
  VALUE ancestors;
446
470
  VALUE expn_class, aclass;
447
471
  int i;
@@ -470,11 +494,11 @@ debug_event_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass)
470
494
  }
471
495
 
472
496
  break;
473
- }
497
+ }
474
498
  case RUBY_EVENT_C_RETURN:
475
- {
476
- break;
477
- }
499
+ {
500
+ break;
501
+ }
478
502
  }
479
503
 
480
504
  debugging--;
@@ -991,9 +1015,15 @@ Init_ruby_debug()
991
1015
  idEval = rb_intern("eval");
992
1016
  idList = rb_intern("list");
993
1017
  idClear = rb_intern("clear");
1018
+ idIndex = rb_intern("index");
1019
+
1020
+ file_separator = rb_eval_string("File::SEPARATOR");
1021
+ alt_file_separator = rb_eval_string("File::ALT_SEPARATOR");
994
1022
 
995
1023
  rb_global_variable(&threads_tbl);
996
1024
  rb_global_variable(&breakpoints);
997
1025
  rb_global_variable(&catchpoint);
998
1026
  rb_global_variable(&waiting);
1027
+ rb_global_variable(&file_separator);
1028
+ rb_global_variable(&alt_file_separator);
999
1029
  }
@@ -36,7 +36,8 @@ module Debugger
36
36
  end
37
37
  file = klass.name if klass
38
38
  else
39
- file = File.basename(file)
39
+ file = File.expand_path(file) if file.index(File::SEPARATOR) || \
40
+ File::ALT_SEPARATOR && file.index(File::ALT_SEPARATOR)
40
41
  end
41
42
  end
42
43
 
@@ -32,7 +32,7 @@ module Debugger
32
32
  class << Debugger; self end.send('define_method', 'save_history') do
33
33
  open(save_file, 'w') do |file|
34
34
  Readline::HISTORY.each do |line|
35
- file.puts line
35
+ file.puts line unless line.strip.empty?
36
36
  end
37
37
  end
38
38
  end
@@ -28,11 +28,11 @@ module Debugger
28
28
  return unless @interface
29
29
  __#{mname}(*args)
30
30
  end
31
- rescue IOError
31
+ rescue IOError, Errno::EPIPE
32
32
  self.interface = nil
33
33
  rescue Exception
34
- print "INTERNAL ERROR!!! #\{$!\}\n"
35
- print $!.backtrace.map{|l| "\t#\{l\}"}.join("\n")
34
+ print "INTERNAL ERROR!!! #\{$!\}\n" rescue nil
35
+ print $!.backtrace.map{|l| "\t#\{l\}"}.join("\n") rescue nil
36
36
  end
37
37
  }
38
38
  end
@@ -162,10 +162,10 @@ module Debugger
162
162
  end
163
163
  end
164
164
  end
165
- rescue IOError
165
+ rescue IOError, Errno::EPIPE
166
166
  rescue Exception
167
- print "INTERNAL ERROR!!! #{$!}\n"
168
- print $!.backtrace.map{|l| "\t#{l}"}.join("\n")
167
+ print "INTERNAL ERROR!!! #{$!}\n" rescue nil
168
+ print $!.backtrace.map{|l| "\t#{l}"}.join("\n") rescue nil
169
169
  ensure
170
170
  @interface.close
171
171
  end
data/lib/ruby-debug.rb CHANGED
@@ -64,6 +64,7 @@ module Debugger
64
64
  # Interrupts the last debugged thread
65
65
  def interrupt_last
66
66
  if context = last_context
67
+ return nil unless context.thread.alive?
67
68
  context.interrupt
68
69
  end
69
70
  context
@@ -187,7 +188,15 @@ module Debugger
187
188
  end
188
189
 
189
190
  module Kernel
191
+ # stops the current thread after a number of _steps_ made.
190
192
  def debugger(steps = 1)
191
193
  Debugger.current_context.stop_next = steps
192
194
  end
195
+
196
+ # returns a binding of n-th call frame
197
+ def binding_n(n = 0)
198
+ frame = Debugger.current_context.frames[n+1]
199
+ raise "Unknown frame #{n}" unless frame
200
+ frame.binding
201
+ end
193
202
  end
data/lib/ruby_debug.so CHANGED
Binary file
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: ruby-debug
5
5
  version: !ruby/object:Gem::Version
6
- version: "0.4"
7
- date: 2006-08-24 23:57:48 -04:00
6
+ version: 0.4.1
7
+ date: 2006-08-27 16:18:00 -04:00
8
8
  summary: Fast Ruby debugger
9
9
  require_paths:
10
10
  - lib