ruby-debug 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ 0.4.2
2
+ - Module#deubg_method added.
3
+ - Added rdoc.
4
+ - Bugfixes.
5
+
1
6
  0.4.1
2
7
  - New binding_n method for Kernel module.
3
8
  - Bugfixes.
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.1"
8
+ RUBY_DEBUG_VERSION = "0.4.2"
9
9
 
10
10
  FILES = FileList[
11
11
  'Rakefile',
@@ -14,6 +14,7 @@ FILES = FileList[
14
14
  'CHANGES',
15
15
  'lib/**/*',
16
16
  'ext/*',
17
+ 'doc/*',
17
18
  'bin/*'
18
19
  ]
19
20
 
@@ -45,7 +46,7 @@ EOF
45
46
  spec.rubyforge_project = 'ruby-debug'
46
47
 
47
48
  # rdoc
48
- spec.has_rdoc = false
49
+ spec.has_rdoc = true
49
50
  end
50
51
 
51
52
  # Rake task to build the default package
@@ -99,4 +100,20 @@ task :clean do
99
100
  rm "Makefile"
100
101
  end
101
102
  end
102
- end
103
+ end
104
+
105
+ # --------- RDoc Documentation ------
106
+ desc "Generate rdoc documentation"
107
+ Rake::RDocTask.new("rdoc") do |rdoc|
108
+ rdoc.rdoc_dir = 'doc'
109
+ rdoc.title = "ruby-debug"
110
+ # Show source inline with line numbers
111
+ rdoc.options << "--inline-source" << "--line-numbers"
112
+ # Make the readme file the start page for the generated html
113
+ rdoc.options << '--main' << 'README'
114
+ rdoc.rdoc_files.include('bin/**/*',
115
+ 'lib/**/*.rb',
116
+ 'ext/**/ruby_debug.c',
117
+ 'README',
118
+ 'LICENSE')
119
+ end
data/bin/rdebug CHANGED
@@ -19,7 +19,7 @@ options = OpenStruct.new(
19
19
  opts = OptionParser.new do |opts|
20
20
  opts.banner = <<EOB
21
21
  ruby-debug #{Debugger::VERSION}
22
- Usage: rdebug [options] <script.rb> <script.rb parameters>
22
+ Usage: rdebug [options] <script.rb> -- <script.rb parameters>
23
23
  EOB
24
24
  opts.separator ""
25
25
  opts.separator "Options:"
@@ -4,7 +4,7 @@
4
4
  #include <rubysig.h>
5
5
  #include <st.h>
6
6
 
7
- #define DEBUG_VERSION "0.4.1"
7
+ #define DEBUG_VERSION "0.4.2"
8
8
 
9
9
  typedef struct {
10
10
  int thnum;
@@ -59,6 +59,7 @@ static ID idList;
59
59
  static ID idClear;
60
60
  static ID idIndex;
61
61
 
62
+ static int start_count = 0;
62
63
  static int thnum_max = 0;
63
64
  static int last_debugged_thnum = -1;
64
65
 
@@ -68,6 +69,12 @@ static VALUE debug_stop(VALUE);
68
69
 
69
70
  #define IS_STARTED (threads_tbl != Qnil)
70
71
 
72
+ /*
73
+ * call-seq:
74
+ * Debugger.started? -> bool
75
+ *
76
+ * Returns +true+ the debugger is started.
77
+ */
71
78
  static VALUE
72
79
  debug_is_started(VALUE self)
73
80
  {
@@ -512,11 +519,26 @@ debug_stop_i(VALUE value)
512
519
  return Qnil;
513
520
  }
514
521
 
522
+ /*
523
+ * call-seq:
524
+ * Debugger.start -> bool
525
+ * Debugger.start { ... } -> obj
526
+ *
527
+ * This method activates the debugger.
528
+ * If it's called without a block it returns +true+, unless debugger was already started.
529
+ * If a block is given, it starts debugger and yields to block. At the end of stops the debugger
530
+ * with Debugger.stop method.
531
+ *
532
+ * <i>Note that if you want to stop debugger, you must call Debugger.stop as many time as you
533
+ * called Debugger.start method.</i>
534
+ */
515
535
  static VALUE
516
536
  debug_start(VALUE self)
517
537
  {
538
+ start_count++;
539
+
518
540
  if(IS_STARTED)
519
- return Qnil;
541
+ return Qfalse;
520
542
 
521
543
  threads_tbl = rb_hash_new();
522
544
  breakpoints = rb_ary_new();
@@ -531,20 +553,35 @@ debug_start(VALUE self)
531
553
  if(rb_block_given_p())
532
554
  return rb_ensure(rb_yield, Qnil, debug_stop_i, Qnil);
533
555
 
534
- return Qnil;
556
+ return Qtrue;
535
557
  }
536
558
 
559
+ /*
560
+ * call-seq:
561
+ * Debugger.stop -> bool
562
+ *
563
+ * This method disacivates the debugger. It returns +true+ if the debugger is disacivated,
564
+ * otherwise it returns +false+.
565
+ *
566
+ * <i>Note that if you want to stop debugger, you must call Debugger.stop as many time as you
567
+ * called Debugger.start method.</i>
568
+ */
537
569
  static VALUE
538
570
  debug_stop(VALUE self)
539
571
  {
540
572
  debug_check_started();
573
+
574
+ start_count--;
575
+ if(start_count)
576
+ return Qfalse;
577
+
541
578
  rb_remove_event_hook(debug_event_hook);
542
579
 
543
580
  waiting = Qnil;
544
581
  breakpoints = Qnil;
545
582
  threads_tbl = Qnil;
546
583
 
547
- return Qnil;
584
+ return Qtrue;
548
585
  }
549
586
 
550
587
  static void
@@ -557,6 +594,16 @@ breakpoint_mark(void *data)
557
594
  rb_gc_mark(breakpoint->expr);
558
595
  }
559
596
 
597
+ /*
598
+ * call-seq:
599
+ * Debugger.add_breakpoint(source, pos, condition = nil) -> breakpoint
600
+ *
601
+ * Adds a new breakpoint.
602
+ * <i>source</i> is a name of a file or a class.
603
+ * <i>pos</i> is a line number or a method name if <i>source</i> is a class name.
604
+ * <i>condition</i> is a string which is evaluated to +true+ when this breakpoint
605
+ * is activated.
606
+ */
560
607
  static VALUE
561
608
  debug_add_breakpoint(int argc, VALUE *argv, VALUE self)
562
609
  {
@@ -580,6 +627,12 @@ debug_add_breakpoint(int argc, VALUE *argv, VALUE self)
580
627
  return result;
581
628
  }
582
629
 
630
+ /*
631
+ * call-seq:
632
+ * Debugger.breakpoints -> array
633
+ *
634
+ * Returns an array of breakpoints.
635
+ */
583
636
  static VALUE
584
637
  debug_breakpoints(VALUE self)
585
638
  {
@@ -588,6 +641,13 @@ debug_breakpoints(VALUE self)
588
641
  return breakpoints;
589
642
  }
590
643
 
644
+ /*
645
+ * call-seq:
646
+ * Debugger.checkpoint -> string
647
+ *
648
+ * Returns a current checkpoint, which is a name of exception that will
649
+ * trigger a debugger when raised.
650
+ */
591
651
  static VALUE
592
652
  debug_catchpoint(VALUE self)
593
653
  {
@@ -596,6 +656,12 @@ debug_catchpoint(VALUE self)
596
656
  return catchpoint;
597
657
  }
598
658
 
659
+ /*
660
+ * call-seq:
661
+ * Debugger.checkpoint = string -> string
662
+ *
663
+ * Sets checkpoint.
664
+ */
599
665
  static VALUE
600
666
  debug_set_catchpoint(VALUE self, VALUE value)
601
667
  {
@@ -624,6 +690,12 @@ find_last_context_func(VALUE key, VALUE value, VALUE *result)
624
690
  return ST_CONTINUE;
625
691
  }
626
692
 
693
+ /*
694
+ * call-seq:
695
+ * Debugger.last_interrupted -> context
696
+ *
697
+ * Returns last debugged context.
698
+ */
627
699
  static VALUE
628
700
  debug_last_interrupted(VALUE self)
629
701
  {
@@ -635,6 +707,13 @@ debug_last_interrupted(VALUE self)
635
707
  return result;
636
708
  }
637
709
 
710
+ /*
711
+ * call-seq:
712
+ * Debugger.current_context -> context
713
+ *
714
+ * Returns current context.
715
+ * <i>Note:</i> Debugger.current_context.thread == Thread.current
716
+ */
638
717
  static VALUE
639
718
  debug_current_context(VALUE self)
640
719
  {
@@ -648,6 +727,12 @@ debug_current_context(VALUE self)
648
727
  return context;
649
728
  }
650
729
 
730
+ /*
731
+ * call-seq:
732
+ * Debugger.contexts -> array
733
+ *
734
+ * Returns an array of all contexts.
735
+ */
651
736
  static VALUE
652
737
  debug_contexts(VALUE self)
653
738
  {
@@ -681,6 +766,12 @@ debug_contexts(VALUE self)
681
766
  return new_list;
682
767
  }
683
768
 
769
+ /*
770
+ * call-seq:
771
+ * Debugger.suspend -> Debugger
772
+ *
773
+ * Suspends all contexts.
774
+ */
684
775
  static VALUE
685
776
  debug_suspend(VALUE self)
686
777
  {
@@ -713,6 +804,12 @@ debug_suspend(VALUE self)
713
804
  return self;
714
805
  }
715
806
 
807
+ /*
808
+ * call-seq:
809
+ * Debugger.resume -> Debugger
810
+ *
811
+ * Resumes all contexts.
812
+ */
716
813
  static VALUE
717
814
  debug_resume(VALUE self)
718
815
  {
@@ -751,12 +848,24 @@ debug_resume(VALUE self)
751
848
  return self;
752
849
  }
753
850
 
851
+ /*
852
+ * call-seq:
853
+ * Debugger.tracing -> bool
854
+ *
855
+ * Returns +true+ is a global tracing is activated.
856
+ */
754
857
  static VALUE
755
858
  debug_tracing(VALUE self)
756
859
  {
757
860
  return tracing;
758
861
  }
759
862
 
863
+ /*
864
+ * call-seq:
865
+ * Debugger.tracing = bool
866
+ *
867
+ * Sets a global tracing flag.
868
+ */
760
869
  static VALUE
761
870
  debug_set_tracing(VALUE self, VALUE value)
762
871
  {
@@ -764,6 +873,12 @@ debug_set_tracing(VALUE self, VALUE value)
764
873
  return value;
765
874
  }
766
875
 
876
+ /*
877
+ * call-seq:
878
+ * context.stop_next = steps
879
+ *
880
+ * Stops the current context after a number +steps+ are made.
881
+ */
767
882
  static VALUE
768
883
  context_stop_next(VALUE self, VALUE steps)
769
884
  {
@@ -779,6 +894,12 @@ context_stop_next(VALUE self, VALUE steps)
779
894
  return steps;
780
895
  }
781
896
 
897
+ /*
898
+ * call-seq:
899
+ * context.step_over(steps)
900
+ *
901
+ * Steps over a +steps+ number of times.
902
+ */
782
903
  static VALUE
783
904
  context_step_over(int argc, VALUE *argv, VALUE self)
784
905
  {
@@ -807,6 +928,12 @@ context_step_over(int argc, VALUE *argv, VALUE self)
807
928
  return Qnil;
808
929
  }
809
930
 
931
+ /*
932
+ * call-seq:
933
+ * context.stop_frame(frame)
934
+ *
935
+ * Stops when a frame with number +frame+ is activated. Implements +up+ and +down+ commands.
936
+ */
810
937
  static VALUE
811
938
  context_stop_frame(VALUE self, VALUE frame)
812
939
  {
@@ -822,6 +949,12 @@ context_stop_frame(VALUE self, VALUE frame)
822
949
  return frame;
823
950
  }
824
951
 
952
+ /*
953
+ * call-seq:
954
+ * context.frames -> array
955
+ *
956
+ * Returns an array of frames.
957
+ */
825
958
  static VALUE
826
959
  context_frames(VALUE self)
827
960
  {
@@ -831,6 +964,12 @@ context_frames(VALUE self)
831
964
  return debug_context->frames;
832
965
  }
833
966
 
967
+ /*
968
+ * call-seq:
969
+ * context.thread -> trhread
970
+ *
971
+ * Returns a thread this context is associated with.
972
+ */
834
973
  static VALUE
835
974
  context_thread(VALUE self)
836
975
  {
@@ -840,6 +979,12 @@ context_thread(VALUE self)
840
979
  return debug_context->thread;
841
980
  }
842
981
 
982
+ /*
983
+ * call-seq:
984
+ * context.thnum -> int
985
+ *
986
+ * Returns the context's number.
987
+ */
843
988
  static VALUE
844
989
  context_thnum(VALUE self)
845
990
  {
@@ -849,6 +994,12 @@ context_thnum(VALUE self)
849
994
  return INT2FIX(debug_context->thnum);
850
995
  }
851
996
 
997
+ /*
998
+ * call-seq:
999
+ * context.set_suspend -> nil
1000
+ *
1001
+ * Suspends the thread when it is running.
1002
+ */
852
1003
  static VALUE
853
1004
  context_set_suspend(VALUE self)
854
1005
  {
@@ -861,6 +1012,12 @@ context_set_suspend(VALUE self)
861
1012
  return Qnil;
862
1013
  }
863
1014
 
1015
+ /*
1016
+ * call-seq:
1017
+ * context.clear_suspend -> nil
1018
+ *
1019
+ * Clears a suspend flag.
1020
+ */
864
1021
  static VALUE
865
1022
  context_clear_suspend(VALUE self)
866
1023
  {
@@ -873,6 +1030,12 @@ context_clear_suspend(VALUE self)
873
1030
  return Qnil;
874
1031
  }
875
1032
 
1033
+ /*
1034
+ * call-seq:
1035
+ * context.tracing -> bool
1036
+ *
1037
+ * Returns the tracing flag for the current context.
1038
+ */
876
1039
  static VALUE
877
1040
  context_tracing(VALUE self)
878
1041
  {
@@ -884,6 +1047,12 @@ context_tracing(VALUE self)
884
1047
  return debug_context->tracing ? Qtrue : Qfalse;
885
1048
  }
886
1049
 
1050
+ /*
1051
+ * call-seq:
1052
+ * context.tracking = bool
1053
+ *
1054
+ * Controls the tracing for this context.
1055
+ */
887
1056
  static VALUE
888
1057
  context_set_tracing(VALUE self, VALUE value)
889
1058
  {
@@ -896,6 +1065,12 @@ context_set_tracing(VALUE self, VALUE value)
896
1065
  return value;
897
1066
  }
898
1067
 
1068
+ /*
1069
+ * call-seq:
1070
+ * frame.file -> string
1071
+ *
1072
+ * Returns the name of the file.
1073
+ */
899
1074
  static VALUE
900
1075
  frame_file(VALUE self)
901
1076
  {
@@ -905,6 +1080,12 @@ frame_file(VALUE self)
905
1080
  return debug_frame->file;
906
1081
  }
907
1082
 
1083
+ /*
1084
+ * call-seq:
1085
+ * frame.line -> int
1086
+ *
1087
+ * Returns the line number in the file.
1088
+ */
908
1089
  static VALUE
909
1090
  frame_line(VALUE self)
910
1091
  {
@@ -914,6 +1095,12 @@ frame_line(VALUE self)
914
1095
  return debug_frame->line;
915
1096
  }
916
1097
 
1098
+ /*
1099
+ * call-seq:
1100
+ * frame.binding -> binding
1101
+ *
1102
+ * Returns the binding captured at the moment this frame was created.
1103
+ */
917
1104
  static VALUE
918
1105
  frame_binding(VALUE self)
919
1106
  {
@@ -923,6 +1110,12 @@ frame_binding(VALUE self)
923
1110
  return debug_frame->binding;
924
1111
  }
925
1112
 
1113
+ /*
1114
+ * call-seq:
1115
+ * frame.id -> sym
1116
+ *
1117
+ * Returns the sym of the called method.
1118
+ */
926
1119
  static VALUE
927
1120
  frame_id(VALUE self)
928
1121
  {
@@ -932,6 +1125,12 @@ frame_id(VALUE self)
932
1125
  return debug_frame->id ? ID2SYM(debug_frame->id): Qnil;
933
1126
  }
934
1127
 
1128
+ /*
1129
+ * call-seq:
1130
+ * breakpoint.source -> string
1131
+ *
1132
+ * Returns a source of the breakpoint.
1133
+ */
935
1134
  static VALUE
936
1135
  breakpoint_source(VALUE self)
937
1136
  {
@@ -941,6 +1140,12 @@ breakpoint_source(VALUE self)
941
1140
  return breakpoint->source;
942
1141
  }
943
1142
 
1143
+ /*
1144
+ * call-seq:
1145
+ * breakpoint.pos -> string or int
1146
+ *
1147
+ * Returns a position of this breakpoint.
1148
+ */
944
1149
  static VALUE
945
1150
  breakpoint_pos(VALUE self)
946
1151
  {
@@ -950,6 +1155,12 @@ breakpoint_pos(VALUE self)
950
1155
  return breakpoint->pos;
951
1156
  }
952
1157
 
1158
+ /*
1159
+ * call-seq:
1160
+ * breakpoint.expr -> string
1161
+ *
1162
+ * Returns a codition expression when this breakpoint should be activated.
1163
+ */
953
1164
  static VALUE
954
1165
  breakpoint_expr(VALUE self)
955
1166
  {
@@ -959,30 +1170,18 @@ breakpoint_expr(VALUE self)
959
1170
  return breakpoint->expr;
960
1171
  }
961
1172
 
962
-
963
- #if defined(_WIN32)
964
- __declspec(dllexport)
965
- #endif
966
- void
967
- Init_ruby_debug()
1173
+ /*
1174
+ * Document-class: Context
1175
+ *
1176
+ * == Summary
1177
+ *
1178
+ * Debugger keeps a single instance of this class for each Ruby thread.
1179
+ * This class provides access to stack frames (see Frame class). Also it
1180
+ * gives you ability to step thought the code.
1181
+ */
1182
+ static void
1183
+ Init_context()
968
1184
  {
969
- mDebugger = rb_define_module("Debugger");
970
- rb_define_const(mDebugger, "VERSION", rb_str_new2(DEBUG_VERSION));
971
- rb_define_module_function(mDebugger, "start", debug_start, 0);
972
- rb_define_module_function(mDebugger, "stop", debug_stop, 0);
973
- rb_define_module_function(mDebugger, "started?", debug_is_started, 0);
974
- rb_define_module_function(mDebugger, "breakpoints", debug_breakpoints, 0);
975
- rb_define_module_function(mDebugger, "add_breakpoint", debug_add_breakpoint, -1);
976
- rb_define_module_function(mDebugger, "catchpoint", debug_catchpoint, 0);
977
- rb_define_module_function(mDebugger, "catchpoint=", debug_set_catchpoint, 1);
978
- rb_define_module_function(mDebugger, "last_context", debug_last_interrupted, 0);
979
- rb_define_module_function(mDebugger, "contexts", debug_contexts, 0);
980
- rb_define_module_function(mDebugger, "current_context", debug_current_context, 0);
981
- rb_define_module_function(mDebugger, "suspend", debug_suspend, 0);
982
- rb_define_module_function(mDebugger, "resume", debug_resume, 0);
983
- rb_define_module_function(mDebugger, "tracing", debug_tracing, 0);
984
- rb_define_module_function(mDebugger, "tracing=", debug_set_tracing, 1);
985
-
986
1185
  cContext = rb_define_class_under(mDebugger, "Context", rb_cObject);
987
1186
  rb_define_method(cContext, "stop_next=", context_stop_next, 1);
988
1187
  rb_define_method(cContext, "step_over", context_step_over, -1);
@@ -994,17 +1193,76 @@ Init_ruby_debug()
994
1193
  rb_define_method(cContext, "clear_suspend", context_clear_suspend, 0);
995
1194
  rb_define_method(cContext, "tracing", context_tracing, 0);
996
1195
  rb_define_method(cContext, "tracing=", context_set_tracing, 1);
1196
+ }
997
1197
 
1198
+ /*
1199
+ * Document-class: Frame
1200
+ *
1201
+ * == Summary
1202
+ *
1203
+ * This class holds infomation about a particular call frame.
1204
+ */
1205
+ static void
1206
+ Init_frame()
1207
+ {
998
1208
  cFrame = rb_define_class_under(cContext, "Frame", rb_cObject);
999
1209
  rb_define_method(cFrame, "file", frame_file, 0);
1000
1210
  rb_define_method(cFrame, "line", frame_line, 0);
1001
1211
  rb_define_method(cFrame, "binding", frame_binding, 0);
1002
1212
  rb_define_method(cFrame, "id", frame_id, 0);
1213
+ }
1003
1214
 
1215
+ /*
1216
+ * Document-class: Breakpoint
1217
+ *
1218
+ * == Summary
1219
+ *
1220
+ * This class represents a breakpoint. It defines position of the breakpoint and
1221
+ * condition when this breakpoint should be triggered.
1222
+ */
1223
+ static void
1224
+ Init_breakpoint()
1225
+ {
1004
1226
  cBreakpoint = rb_define_class_under(mDebugger, "Breakpoint", rb_cObject);
1005
1227
  rb_define_method(cBreakpoint, "source", breakpoint_source, 0);
1006
1228
  rb_define_method(cBreakpoint, "pos", breakpoint_pos, 0);
1007
1229
  rb_define_method(cBreakpoint, "expr", breakpoint_expr, 0);
1230
+ }
1231
+
1232
+ /*
1233
+ * Document-class: Debugger
1234
+ *
1235
+ * == Summary
1236
+ *
1237
+ * This is a singleton class allows controlling the debugger. Use it to start/stop debugger,
1238
+ * set/remove breakpoints, etc.
1239
+ */
1240
+ #if defined(_WIN32)
1241
+ __declspec(dllexport)
1242
+ #endif
1243
+ void
1244
+ Init_ruby_debug()
1245
+ {
1246
+ mDebugger = rb_define_module("Debugger");
1247
+ rb_define_const(mDebugger, "VERSION", rb_str_new2(DEBUG_VERSION));
1248
+ rb_define_module_function(mDebugger, "start", debug_start, 0);
1249
+ rb_define_module_function(mDebugger, "stop", debug_stop, 0);
1250
+ rb_define_module_function(mDebugger, "started?", debug_is_started, 0);
1251
+ rb_define_module_function(mDebugger, "breakpoints", debug_breakpoints, 0);
1252
+ rb_define_module_function(mDebugger, "add_breakpoint", debug_add_breakpoint, -1);
1253
+ rb_define_module_function(mDebugger, "catchpoint", debug_catchpoint, 0);
1254
+ rb_define_module_function(mDebugger, "catchpoint=", debug_set_catchpoint, 1);
1255
+ rb_define_module_function(mDebugger, "last_context", debug_last_interrupted, 0);
1256
+ rb_define_module_function(mDebugger, "contexts", debug_contexts, 0);
1257
+ rb_define_module_function(mDebugger, "current_context", debug_current_context, 0);
1258
+ rb_define_module_function(mDebugger, "suspend", debug_suspend, 0);
1259
+ rb_define_module_function(mDebugger, "resume", debug_resume, 0);
1260
+ rb_define_module_function(mDebugger, "tracing", debug_tracing, 0);
1261
+ rb_define_module_function(mDebugger, "tracing=", debug_set_tracing, 1);
1262
+
1263
+ Init_context();
1264
+ Init_frame();
1265
+ Init_breakpoint();
1008
1266
 
1009
1267
  idAtLine = rb_intern("at_line");
1010
1268
  idAtBreakpoint = rb_intern("at_breakpoint");
@@ -1015,7 +1273,7 @@ Init_ruby_debug()
1015
1273
  idEval = rb_intern("eval");
1016
1274
  idList = rb_intern("list");
1017
1275
  idClear = rb_intern("clear");
1018
- idIndex = rb_intern("index");
1276
+ idIndex = rb_intern("index");
1019
1277
 
1020
1278
  file_separator = rb_eval_string("File::SEPARATOR");
1021
1279
  alt_file_separator = rb_eval_string("File::ALT_SEPARATOR");
@@ -55,13 +55,17 @@ module Debugger
55
55
 
56
56
  attr_reader :thread, :control_thread
57
57
 
58
+ #
58
59
  # Interrupts the main thread
60
+ #
59
61
  def interrupt
60
62
  context = contexts.find{|c| c.thread == Thread.current }
61
63
  context.interrupt
62
64
  end
63
65
 
66
+ #
64
67
  # Interrupts the last debugged thread
68
+ #
65
69
  def interrupt_last
66
70
  if context = last_context
67
71
  return nil unless context.thread.alive?
@@ -70,11 +74,13 @@ module Debugger
70
74
  context
71
75
  end
72
76
 
73
- def interface=(value)
77
+ def interface=(value) # :nodoc:
74
78
  processor.interface = value
75
79
  end
76
80
 
81
+ #
77
82
  # Starts a remote debugger.
83
+ #
78
84
  def start_remote(host = nil, port = PORT)
79
85
  return if @thread
80
86
  return if started?
@@ -124,7 +130,9 @@ module Debugger
124
130
  end
125
131
  alias start_server start_remote
126
132
 
133
+ #
127
134
  # Connects to the remote debugger
135
+ #
128
136
  def start_client(host = 'localhost', port = PORT)
129
137
  require "socket"
130
138
  interface = Debugger::LocalInterface.new
@@ -151,7 +159,7 @@ module Debugger
151
159
  puts
152
160
  end
153
161
 
154
- def stop_main_thread
162
+ def stop_main_thread # :nodoc:
155
163
  return unless stop_on_connect
156
164
 
157
165
  context = contexts.find{ |c| c.thread == Thread.main }
@@ -159,7 +167,7 @@ module Debugger
159
167
  end
160
168
  private :stop_main_thread
161
169
 
162
- def source_for(file)
170
+ def source_for(file) # :nodoc:
163
171
  if source = SCRIPT_LINES__[file]
164
172
  return source unless source == true
165
173
  end
@@ -168,7 +176,7 @@ module Debugger
168
176
  end
169
177
  end
170
178
 
171
- def line_at(file, line)
179
+ def line_at(file, line) # :nodoc:
172
180
  lines = source_for(file)
173
181
  if lines
174
182
  line = lines[line-1]
@@ -178,7 +186,9 @@ module Debugger
178
186
  return "\n"
179
187
  end
180
188
 
181
- # runs a script file
189
+ #
190
+ # Runs a script file
191
+ #
182
192
  def run_script(file, out = processor.interface)
183
193
  interface = ScriptInterface.new(file, out)
184
194
  processor = ControlCommandProcessor.new(interface)
@@ -188,15 +198,36 @@ module Debugger
188
198
  end
189
199
 
190
200
  module Kernel
191
- # stops the current thread after a number of _steps_ made.
201
+ #
202
+ # Stops the current thread after a number of _steps_ made.
203
+ #
192
204
  def debugger(steps = 1)
193
205
  Debugger.current_context.stop_next = steps
194
206
  end
195
207
 
196
- # returns a binding of n-th call frame
208
+ #
209
+ # Returns a binding of n-th call frame
210
+ #
197
211
  def binding_n(n = 0)
198
212
  frame = Debugger.current_context.frames[n+1]
199
213
  raise "Unknown frame #{n}" unless frame
200
214
  frame.binding
201
215
  end
216
+ end
217
+
218
+ class Module
219
+ #
220
+ # Wraps the +meth+ method with Debugger.start {...} block.
221
+ #
222
+ def debug_method(meth)
223
+ alias_method "__debugee_#{meth}".to_sym, meth
224
+ class_eval <<-EOD
225
+ def #{meth}(*args, &block)
226
+ Debugger.start do
227
+ debugger 2
228
+ __debugee_#{meth}(*args, &block)
229
+ end
230
+ end
231
+ EOD
232
+ end
202
233
  end
@@ -1,5 +1,5 @@
1
1
  module Debugger
2
- class Command
2
+ class Command # :nodoc:
3
3
  class << self
4
4
  def commands
5
5
  @commands ||= []
@@ -1,5 +1,5 @@
1
1
  module Debugger
2
- class AddBreakpoint < Command
2
+ class AddBreakpoint < Command # :nodoc:
3
3
  self.control = true
4
4
 
5
5
  def regexp
@@ -19,13 +19,12 @@ module Debugger
19
19
 
20
20
  def execute
21
21
  if @match[1]
22
- file, pos, expr = @match.captures
22
+ pos, _, _, expr = @match.captures
23
23
  else
24
- file, pos, expr = @match.captures[1..-1]
24
+ _, file, pos, expr = @match.captures
25
25
  end
26
26
 
27
- if file =~ /^\d+$/
28
- pos = file
27
+ if file.nil?
29
28
  file = File.basename(@state.file)
30
29
  else
31
30
  if pos !~ /^\d+$/
@@ -65,7 +64,7 @@ module Debugger
65
64
  end
66
65
  end
67
66
 
68
- class BreakpointsCommand < Command
67
+ class BreakpointsCommand < Command # :nodoc:
69
68
  self.control = true
70
69
 
71
70
  def regexp
@@ -101,7 +100,7 @@ module Debugger
101
100
  end
102
101
  end
103
102
 
104
- class DeleteBreakpointCommand < Command
103
+ class DeleteBreakpointCommand < Command # :nodoc:
105
104
  self.control = true
106
105
 
107
106
  def regexp
@@ -1,5 +1,5 @@
1
1
  module Debugger
2
- class CatchCommand < Command
2
+ class CatchCommand < Command # :nodoc:
3
3
  self.control = true
4
4
 
5
5
  def regexp
@@ -1,5 +1,5 @@
1
1
  module Debugger
2
- class QuitCommand < Command
2
+ class QuitCommand < Command # :nodoc:
3
3
  self.control = true
4
4
 
5
5
  def regexp
@@ -26,7 +26,7 @@ module Debugger
26
26
  end
27
27
  end
28
28
 
29
- class InterruptCommand < Command
29
+ class InterruptCommand < Command # :nodoc:
30
30
  self.event = false
31
31
  self.control = true
32
32
 
@@ -1,11 +1,11 @@
1
1
  module Debugger
2
- module DisplayFunctions
2
+ module DisplayFunctions # :nodoc:
3
3
  def display_expression(exp)
4
4
  print "%s = %s\n", exp, debug_silent_eval(exp).to_s
5
5
  end
6
6
  end
7
7
 
8
- class AddDisplayCommand < Command
8
+ class AddDisplayCommand < Command # :nodoc:
9
9
  include DisplayFunctions
10
10
 
11
11
  def regexp
@@ -32,7 +32,7 @@ module Debugger
32
32
  end
33
33
  end
34
34
 
35
- class DisplayCommand < Command
35
+ class DisplayCommand < Command # :nodoc:
36
36
  self.always_run = true
37
37
  include DisplayFunctions
38
38
 
@@ -68,7 +68,7 @@ module Debugger
68
68
  end
69
69
  end
70
70
 
71
- class DeleteDisplayCommand < Command
71
+ class DeleteDisplayCommand < Command # :nodoc:
72
72
  include DisplayFunctions
73
73
 
74
74
  def regexp
@@ -1,5 +1,5 @@
1
1
  module Debugger
2
- class EvalCommand < Command
2
+ class EvalCommand < Command # :nodoc:
3
3
  def match(input)
4
4
  @input = input
5
5
  super
@@ -40,7 +40,7 @@ module Debugger
40
40
  end
41
41
  end
42
42
 
43
- class PPCommand < Command
43
+ class PPCommand < Command # :nodoc:
44
44
  def regexp
45
45
  /^\s*pp\s+/
46
46
  end
@@ -1,12 +1,12 @@
1
1
  module Debugger
2
- module FrameFunctions
2
+ module FrameFunctions # :nodoc:
3
3
  def format_frame(frame, pos)
4
4
  file, line, id = frame.file, frame.line, frame.id
5
5
  "#%d %s:%s%s\n" % [pos + 1, file, line, (id ? ":in `#{id.id2name}'" : "")]
6
6
  end
7
7
  end
8
8
 
9
- class WhereCommand < Command
9
+ class WhereCommand < Command # :nodoc:
10
10
  include FrameFunctions
11
11
 
12
12
  def regexp
@@ -43,7 +43,7 @@ module Debugger
43
43
  end
44
44
  end
45
45
 
46
- class UpCommand < Command
46
+ class UpCommand < Command # :nodoc:
47
47
  include FrameFunctions
48
48
 
49
49
  def regexp
@@ -91,7 +91,7 @@ module Debugger
91
91
  end
92
92
  end
93
93
 
94
- class DownCommand < Command
94
+ class DownCommand < Command # :nodoc:
95
95
  include FrameFunctions
96
96
 
97
97
  def regexp
@@ -1,5 +1,5 @@
1
1
  module Debugger
2
- class HelpCommand < Command
2
+ class HelpCommand < Command # :nodoc:
3
3
  self.control = true
4
4
 
5
5
  def regexp
@@ -1,5 +1,5 @@
1
1
  module Debugger
2
- class ListCommand < Command
2
+ class ListCommand < Command # :nodoc:
3
3
  def regexp
4
4
  /^\s*l(?:ist)?(?:\s*(.+))?$/
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module Debugger
2
- class MethodCommand < Command
2
+ class MethodCommand < Command # :nodoc:
3
3
  def regexp
4
4
  /^\s*m(?:ethod)?\s+(?:(i(:?nstance)?)\s)?/
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module Debugger
2
- class ScriptCommand < Command
2
+ class ScriptCommand < Command # :nodoc:
3
3
  self.control = true
4
4
 
5
5
  def regexp
@@ -27,7 +27,7 @@ module Debugger
27
27
  end
28
28
  end
29
29
 
30
- class SaveCommand < Command
30
+ class SaveCommand < Command # :nodoc:
31
31
  self.control = true
32
32
 
33
33
  def regexp
@@ -1,5 +1,5 @@
1
1
  module Debugger
2
- class NextCommand < Command
2
+ class NextCommand < Command # :nodoc:
3
3
  def regexp
4
4
  /^\s*n(?:ext)?(?:\s+(\d+))?$/
5
5
  end
@@ -23,7 +23,7 @@ module Debugger
23
23
  end
24
24
  end
25
25
 
26
- class StepCommand < Command
26
+ class StepCommand < Command # :nodoc:
27
27
  def regexp
28
28
  /^\s*s(?:tep)?(?:\s+(\d+))?$/
29
29
  end
@@ -46,7 +46,7 @@ module Debugger
46
46
  end
47
47
  end
48
48
 
49
- class FinishCommand < Command
49
+ class FinishCommand < Command # :nodoc:
50
50
  def regexp
51
51
  /^\s*fin(?:ish)?$/
52
52
  end
@@ -74,7 +74,7 @@ module Debugger
74
74
  end
75
75
  end
76
76
 
77
- class ContinueCommand < Command
77
+ class ContinueCommand < Command # :nodoc:
78
78
  def regexp
79
79
  /^\s*c(?:ont)?$|^\s*r(?:un)?$/
80
80
  end
@@ -1,5 +1,5 @@
1
1
  module Debugger
2
- module ThreadFunctions
2
+ module ThreadFunctions # :nodoc:
3
3
  def display_context(c)
4
4
  c_flag = c.thread == Thread.current ? '+' : ' '
5
5
  d_flag = debugger_thread?(c) ? '!' : ' '
@@ -18,7 +18,7 @@ module Debugger
18
18
  end
19
19
  end
20
20
 
21
- class ThreadListCommand < Command
21
+ class ThreadListCommand < Command # :nodoc:
22
22
  self.control = true
23
23
  include ThreadFunctions
24
24
 
@@ -45,7 +45,7 @@ module Debugger
45
45
  end
46
46
  end
47
47
 
48
- class ThreadSwitchCommand < Command
48
+ class ThreadSwitchCommand < Command # :nodoc:
49
49
  self.control = true
50
50
  include ThreadFunctions
51
51
 
@@ -81,7 +81,7 @@ module Debugger
81
81
  end
82
82
  end
83
83
 
84
- class ThreadStopCommand < Command
84
+ class ThreadStopCommand < Command # :nodoc:
85
85
  self.control = true
86
86
  include ThreadFunctions
87
87
 
@@ -117,7 +117,7 @@ module Debugger
117
117
  end
118
118
  end
119
119
 
120
- class ThreadCurrentCommand < Command
120
+ class ThreadCurrentCommand < Command # :nodoc:
121
121
  include ThreadFunctions
122
122
 
123
123
  def regexp
@@ -141,7 +141,7 @@ module Debugger
141
141
  end
142
142
  end
143
143
 
144
- class ThreadResumeCommand < Command
144
+ class ThreadResumeCommand < Command # :nodoc:
145
145
  self.control = true
146
146
  include ThreadFunctions
147
147
 
@@ -1,6 +1,6 @@
1
1
  module Debugger
2
2
  if RUBY_PLATFORM =~ /darwin/
3
- class TextMateCommand < Command
3
+ class TextMateCommand < Command # :nodoc:
4
4
  def regexp
5
5
  /^\s*tm(?:ate)?(?:\s*(\d+))?$/
6
6
  end
@@ -1,5 +1,5 @@
1
1
  module Debugger
2
- class TraceCommand < Command
2
+ class TraceCommand < Command # :nodoc:
3
3
  def regexp
4
4
  /^\s*tr(?:ace)?(?:\s+(on|off))?(?:\s+(all))?$/
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module Debugger
2
- module VarFunctions
2
+ module VarFunctions # :nodoc:
3
3
  def var_list(ary, bind = nil)
4
4
  bind ||= @state.binding
5
5
  ary.sort!
@@ -9,7 +9,7 @@ module Debugger
9
9
  end
10
10
  end
11
11
 
12
- class VarConstantCommand < Command
12
+ class VarConstantCommand < Command # :nodoc:
13
13
  include VarFunctions
14
14
 
15
15
  def regexp
@@ -38,7 +38,7 @@ module Debugger
38
38
  end
39
39
  end
40
40
 
41
- class VarGlobalCommand < Command
41
+ class VarGlobalCommand < Command # :nodoc:
42
42
  include VarFunctions
43
43
 
44
44
  def regexp
@@ -62,7 +62,7 @@ module Debugger
62
62
  end
63
63
  end
64
64
 
65
- class VarInstanceCommand < Command
65
+ class VarInstanceCommand < Command # :nodoc:
66
66
  include VarFunctions
67
67
 
68
68
  def regexp
@@ -87,7 +87,7 @@ module Debugger
87
87
  end
88
88
  end
89
89
 
90
- class VarLocalCommand < Command
90
+ class VarLocalCommand < Command # :nodoc:
91
91
  include VarFunctions
92
92
 
93
93
  def regexp
@@ -1,5 +1,5 @@
1
1
  module Debugger
2
- class LocalInterface
2
+ class LocalInterface # :nodoc:
3
3
  def read_command(prompt)
4
4
  readline(prompt, true)
5
5
  end
@@ -55,7 +55,7 @@ module Debugger
55
55
  end
56
56
  end
57
57
 
58
- class RemoteInterface
58
+ class RemoteInterface # :nodoc:
59
59
  def initialize(socket)
60
60
  @socket = socket
61
61
  end
@@ -87,7 +87,7 @@ module Debugger
87
87
  end
88
88
  end
89
89
 
90
- class ScriptInterface
90
+ class ScriptInterface # :nodoc:
91
91
  def initialize(file, out)
92
92
  @file = open(file)
93
93
  @out = out
@@ -1,5 +1,5 @@
1
1
  module Debugger
2
- class Lock
2
+ class Lock # :nodoc:
3
3
  def initialize
4
4
  @locker = nil
5
5
  @waiting = []
@@ -2,7 +2,7 @@ require 'ruby-debug/interface'
2
2
  require 'ruby-debug/command'
3
3
 
4
4
  module Debugger
5
- class CommandProcessor
5
+ class CommandProcessor # :nodoc:
6
6
  attr_accessor :interface
7
7
  attr_reader :display
8
8
 
@@ -110,7 +110,7 @@ module Debugger
110
110
  end
111
111
  end
112
112
 
113
- class State
113
+ class State # :nodoc:
114
114
  attr_accessor :context, :file, :line, :binding
115
115
  attr_accessor :frame_pos, :previous_line, :display
116
116
  attr_accessor :interface, :commands
@@ -139,7 +139,7 @@ module Debugger
139
139
  end
140
140
  end
141
141
 
142
- class ControlCommandProcessor
142
+ class ControlCommandProcessor # :nodoc:
143
143
  def initialize(interface)
144
144
  @interface = interface
145
145
  end
@@ -170,7 +170,7 @@ module Debugger
170
170
  @interface.close
171
171
  end
172
172
 
173
- class State
173
+ class State # :nodoc:
174
174
  attr_reader :commands
175
175
  def initialize(interface, commands)
176
176
  @interface = interface
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.1
7
- date: 2006-08-27 16:17:09 -04:00
6
+ version: 0.4.2
7
+ date: 2006-09-15 02:05:10 -04:00
8
8
  summary: Fast Ruby debugger
9
9
  require_paths:
10
10
  - lib
@@ -15,7 +15,7 @@ description: ruby-debug is a fast implementation of the standard Ruby debugger d
15
15
  autorequire: ruby-debug
16
16
  default_executable:
17
17
  bindir: bin
18
- has_rdoc: false
18
+ has_rdoc: true
19
19
  required_ruby_version: !ruby/object:Gem::Version::Requirement
20
20
  requirements:
21
21
  - - ">="