ruby-debug 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,9 @@
1
+ 0.7.4
2
+ - Added a workaround of the Ruby interpreter problem where a method created with Module#define_method
3
+ and which raises an exception doesn't trigger a :return event, this way screwing the stack trace.
4
+ - Fixed a situation of an array 'out of bounds' access.
5
+ - Fixed the help for 'where' command.
6
+
1
7
  0.7.3
2
8
  - Fixed a case when a frame is not popped up properly.
3
9
  - Removed Context.ignore= method, since it can result with the segmentation fault error.
@@ -5,7 +11,7 @@
5
11
  - Fixed several cases of seg faults when accessing dyna_vars structure.
6
12
 
7
13
  0.7.2
8
- - Fixed Context#resume (a thread should be waked up only when it was running when it wsa suspened).
14
+ - Fixed Context#resume (a thread should be waked up only when it was running when it was suspended).
9
15
  - When handling post-mortem exception, all threads must be suspended.
10
16
 
11
17
  0.7.1
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.7.3"
7
+ #define DEBUG_VERSION "0.7.4"
8
8
 
9
9
  #ifdef _WIN32
10
10
  struct FRAME {
@@ -71,6 +71,7 @@ RUBY_EXTERN struct RVarmap *ruby_dyna_vars;
71
71
  typedef struct {
72
72
  VALUE binding;
73
73
  ID id;
74
+ ID orig_id;
74
75
  int line;
75
76
  const char * file;
76
77
  short dead;
@@ -127,6 +128,7 @@ static VALUE tracing = Qfalse;
127
128
  static VALUE locker = Qnil;
128
129
  static VALUE post_mortem = Qfalse;
129
130
  static VALUE keep_frame_binding = Qfalse;
131
+ static VALUE debug = Qfalse;
130
132
 
131
133
  static VALUE last_context = Qnil;
132
134
  static VALUE last_thread = Qnil;
@@ -523,6 +525,7 @@ save_call_frame(rb_event_t event, VALUE self, char *file, int line, ID mid, debu
523
525
  debug_frame->line = line;
524
526
  debug_frame->binding = binding;
525
527
  debug_frame->id = mid;
528
+ debug_frame->orig_id = mid;
526
529
  debug_frame->dead = 0;
527
530
  debug_frame->self = self;
528
531
  debug_frame->info.runtime.frame = ruby_frame;
@@ -683,7 +686,7 @@ save_top_binding(debug_context_t *debug_context, VALUE binding)
683
686
  }
684
687
 
685
688
  inline static void
686
- set_frame_source(rb_event_t event, debug_context_t *debug_context, VALUE self, char *file, int line)
689
+ set_frame_source(rb_event_t event, debug_context_t *debug_context, VALUE self, char *file, int line, ID mid)
687
690
  {
688
691
  debug_frame_t *top_frame;
689
692
  top_frame = get_top_frame(debug_context);
@@ -692,6 +695,7 @@ set_frame_source(rb_event_t event, debug_context_t *debug_context, VALUE self, c
692
695
  top_frame->self = self;
693
696
  top_frame->file = file;
694
697
  top_frame->line = line;
698
+ top_frame->id = mid;
695
699
  top_frame->info.runtime.dyna_vars = event == RUBY_EVENT_C_CALL ? NULL : ruby_dyna_vars;
696
700
  }
697
701
  }
@@ -747,7 +751,7 @@ debug_event_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass)
747
751
  hook_count++;
748
752
 
749
753
  if (mid == ID_ALLOCATOR) return;
750
-
754
+
751
755
  thread = rb_thread_current();
752
756
  thread_context_lookup(thread, &context, &debug_context);
753
757
 
@@ -785,23 +789,29 @@ debug_event_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass)
785
789
  /* ignore a skipped section of code */
786
790
  if(CTX_FL_TEST(debug_context, CTX_FL_SKIPPED)) goto cleanup;
787
791
 
788
- if(!node && !(event == RUBY_EVENT_RETURN || event == RUBY_EVENT_C_RETURN))
789
- goto cleanup;
790
-
791
792
  if(node)
792
793
  {
793
794
  file = node->nd_file;
794
795
  line = nd_line(node);
795
- }
796
+
797
+ if(debug == Qtrue)
798
+ fprintf(stderr, "%s:%d [%s] %s\n", file, line, get_event_name(event), rb_id2name(mid));
796
799
 
797
- if(DID_MOVED)
798
- CTX_FL_SET(debug_context, CTX_FL_MOVED);
800
+ if(DID_MOVED)
801
+ CTX_FL_SET(debug_context, CTX_FL_MOVED);
802
+ }
803
+ else if(event != RUBY_EVENT_RETURN && event != RUBY_EVENT_C_RETURN)
804
+ {
805
+ if(debug == Qtrue)
806
+ fprintf(stderr, "return [%s] %s\n", get_event_name(event), rb_id2name(mid));
807
+ goto cleanup;
808
+ }
799
809
 
800
810
  switch(event)
801
811
  {
802
812
  case RUBY_EVENT_LINE:
803
813
  {
804
- set_frame_source(event, debug_context, self, file, line);
814
+ set_frame_source(event, debug_context, self, file, line, mid);
805
815
 
806
816
  if(RTEST(tracing) || CTX_FL_TEST(debug_context, CTX_FL_TRACING))
807
817
  rb_funcall(context, idAtTracing, 2, rb_str_new2(file), INT2FIX(line));
@@ -850,7 +860,7 @@ debug_event_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass)
850
860
  }
851
861
  case RUBY_EVENT_C_CALL:
852
862
  {
853
- set_frame_source(event, debug_context, self, file, line);
863
+ set_frame_source(event, debug_context, self, file, line, mid);
854
864
  break;
855
865
  }
856
866
  case RUBY_EVENT_CALL:
@@ -883,8 +893,12 @@ debug_event_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass)
883
893
  debug_context->stop_next = 1;
884
894
  debug_context->stop_frame = 0;
885
895
  }
886
- if(debug_context->stack_size > 0)
896
+ while(debug_context->stack_size > 0)
897
+ {
887
898
  debug_context->stack_size--;
899
+ if(debug_context->frames[debug_context->stack_size].orig_id == mid)
900
+ break;
901
+ }
888
902
  break;
889
903
  }
890
904
  case RUBY_EVENT_CLASS:
@@ -898,7 +912,7 @@ debug_event_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass)
898
912
  VALUE expn_class, aclass;
899
913
  int i;
900
914
 
901
- set_frame_source(event, debug_context, self, file, line);
915
+ set_frame_source(event, debug_context, self, file, line, mid);
902
916
 
903
917
  if(post_mortem == Qtrue && self)
904
918
  {
@@ -1423,6 +1437,19 @@ debug_set_keep_frame_binding(VALUE self, VALUE value)
1423
1437
  return value;
1424
1438
  }
1425
1439
 
1440
+ static VALUE
1441
+ debug_debug(VALUE self)
1442
+ {
1443
+ return debug;
1444
+ }
1445
+
1446
+ static VALUE
1447
+ debug_set_debug(VALUE self, VALUE value)
1448
+ {
1449
+ debug = RTEST(value) ? Qtrue : Qfalse;
1450
+ return value;
1451
+ }
1452
+
1426
1453
  static VALUE
1427
1454
  debug_thread_inherited(VALUE klass)
1428
1455
  {
@@ -2111,6 +2138,8 @@ Init_ruby_debug()
2111
2138
  rb_define_module_function(mDebugger, "post_mortem=", debug_set_post_mortem, 1);
2112
2139
  rb_define_module_function(mDebugger, "keep_frame_binding?", debug_keep_frame_binding, 0);
2113
2140
  rb_define_module_function(mDebugger, "keep_frame_binding=", debug_set_keep_frame_binding, 1);
2141
+ rb_define_module_function(mDebugger, "debug", debug_debug, 0);
2142
+ rb_define_module_function(mDebugger, "debug=", debug_set_debug, 1);
2114
2143
 
2115
2144
  cThreadsTable = rb_define_class_under(mDebugger, "ThreadsTable", rb_cObject);
2116
2145
 
@@ -26,7 +26,7 @@ module Debugger
26
26
  @state.file = @state.context.frame_file(@state.frame_pos)
27
27
  @state.line = @state.context.frame_line(@state.frame_pos)
28
28
 
29
- print format_frame(@state.frame_pos)
29
+ print_frame(@state.frame_pos, true)
30
30
  end
31
31
 
32
32
  def get_int(str, cmd)
@@ -38,10 +38,10 @@ module Debugger
38
38
  end
39
39
  end
40
40
 
41
- def format_frame(pos)
42
- printf "\032\032" if ENV['EMACS']
41
+ def print_frame(pos, adjust = false)
43
42
  file, line, id = @state.context.frame_file(pos), @state.context.frame_line(pos), @state.context.frame_id(pos)
44
- "#%d %s:%s%s\n" % [pos, file, line, (id ? ":in `#{id.id2name}'" : "")]
43
+ print "#%d %s:%d%s\n", pos, file, line, id ? " in `#{id.id2name}'" : ""
44
+ print "\032\032%s:%d\n", file, line if ENV['EMACS'] && adjust
45
45
  end
46
46
  end
47
47
 
@@ -59,13 +59,13 @@ module Debugger
59
59
  else
60
60
  print " "
61
61
  end
62
- print format_frame(idx)
62
+ print_frame(idx)
63
63
  end
64
64
  end
65
65
 
66
66
  class << self
67
67
  def help_command
68
- %w|where frame|
68
+ %w|where backtrace|
69
69
  end
70
70
 
71
71
  def help(cmd)
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.1
3
3
  specification_version: 1
4
4
  name: ruby-debug
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.7.3
7
- date: 2007-02-04 20:32:53 -05:00
6
+ version: 0.7.4
7
+ date: 2007-02-05 17:50:28 -05:00
8
8
  summary: Fast Ruby debugger
9
9
  require_paths:
10
10
  - lib