ruby-debug-base 0.10.2 → 0.10.3

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,16 @@
1
+ 0.10.3
2
+ 11/17/08
3
+
4
+ - a backtrace now warns when it thinks the callstack is truncated which it
5
+ gets by comparing with caller()
6
+ - fix setting $0.
7
+ - fix bug in showing variables in post-mortem
8
+ - Document how Debugger.start with a block is intended to be used.
9
+ - Move Kernel#debugger from ruby-debug-base into ruby-debug
10
+ - Get regression tests working again
11
+ - Warn and add a "confirmation" when setting a breakpoint on a
12
+ file that is not loaded.
13
+
1
14
  0.10.2
2
15
  - debugger(steps=0) breaks inside of debugger rather than wait for a line event.
3
16
  - trace var varname (stop|nostop) added which issues trace_var.
data/README CHANGED
@@ -3,7 +3,8 @@
3
3
  == Overview
4
4
 
5
5
  ruby-debug is a fast implementation of the standard debugger debug.rb.
6
- The faster execution speed is achieved by utilizing a new hook Ruby C API.
6
+ The faster execution speed is achieved by utilizing a new hook in the
7
+ Ruby C API.
7
8
 
8
9
  == Requirements
9
10
 
@@ -28,20 +29,19 @@ ruby-debug is provided as a RubyGem. To install:
28
29
 
29
30
  This should also pull in <tt>ruby-debug-base</tt> as a dependency.
30
31
 
31
- (If you install ruby-debug-base explicitly, you can add in the secret
32
- --test option after "install" to have the regression test run before
32
+ (If you install ruby-debug-base explicitly, you can add in the <tt>--test</tt>
33
+ option after "install" to have the regression test run before
33
34
  installing.)
34
35
 
35
36
  For Emacs support and the Reference Manual, get
36
37
  <tt>ruby-debug-extra</tt>. This is not a RubyGem, you'll need a Make
37
38
  program and a POSIX shell. With this installed, run:
38
39
 
39
- <pre>
40
40
  sh ./configure
41
41
  make
42
42
  make test # optional, but a good idea
43
43
  sudo make install
44
- </pre>
44
+
45
45
 
46
46
  ==== Install on MS Windows
47
47
 
@@ -86,13 +86,21 @@ code execution at run time.
86
86
  ...
87
87
  end
88
88
 
89
+ or
90
+
91
+ require 'ruby-debug' ;
92
+ Debugger.start do
93
+ ...
94
+ debugger
95
+ end
96
+
89
97
  When Kernel#debugger method is executed, the debugger is activated
90
98
  and you will be able to inspect and step through your code.
91
99
 
92
100
  == Performance
93
101
 
94
- The debug.rb script that comes with the standard Ruby library uses
95
- Kernel#set_trace_func API. Implementing the debugger in pure Ruby has
102
+ The <tt>debug.rb</tt> script that comes with the standard Ruby library uses
103
+ <tt>Kernel#set_trace_func</tt> API. Implementing the debugger in pure Ruby has
96
104
  a negative impact on the speed of your program execution. This is
97
105
  because the Ruby interpreter creates a Binding object each trace call,
98
106
  even though it is not being used most of the time. ruby-debug moves
data/Rakefile CHANGED
@@ -20,7 +20,10 @@ COMMON_FILES = FileList[
20
20
  'Rakefile',
21
21
  ]
22
22
 
23
- CLI_TEST_FILE_LIST = FileList['test/test-*.rb', 'test/cli/**/*_test.rb']
23
+ CLI_TEST_FILE_LIST = FileList['test/cli/commands/unit/*.rb',
24
+ 'test/cli/commands/*_test.rb',
25
+ 'test/cli/**/*_test.rb',
26
+ 'test/test-*.rb']
24
27
  CLI_FILES = COMMON_FILES + FileList[
25
28
  "cli/**/*",
26
29
  'ChangeLog',
@@ -147,7 +150,7 @@ EOF
147
150
  spec.date = Time.now
148
151
  spec.rubyforge_project = 'ruby-debug'
149
152
  spec.add_dependency('columnize', '>= 0.1')
150
- spec.add_dependency('ruby-debug-base', RUBY_DEBUG_VERSION)
153
+ spec.add_dependency('ruby-debug-base', "~> #{RUBY_DEBUG_VERSION}.0")
151
154
 
152
155
  # FIXME: work out operational logistics for this
153
156
  # spec.test_files = FileList[CLI_TEST_FILE_LIST]
@@ -217,13 +220,14 @@ end
217
220
  # --------- RDoc Documentation ------
218
221
  desc "Generate rdoc documentation"
219
222
  Rake::RDocTask.new("rdoc") do |rdoc|
220
- rdoc.rdoc_dir = 'doc'
223
+ rdoc.rdoc_dir = 'doc/rdoc'
221
224
  rdoc.title = "ruby-debug"
222
225
  # Show source inline with line numbers
223
226
  rdoc.options << "--inline-source" << "--line-numbers"
224
227
  # Make the readme file the start page for the generated html
225
228
  rdoc.options << '--main' << 'README'
226
229
  rdoc.rdoc_files.include('bin/**/*',
230
+ 'cli/ruby-debug/commands/*.rb',
227
231
  'lib/**/*.rb',
228
232
  'ext/**/ruby_debug.c',
229
233
  'README',
@@ -67,7 +67,7 @@ check_breakpoint_by_pos(VALUE breakpoint, char *file, int line)
67
67
  return 0;
68
68
  }
69
69
 
70
- static int
70
+ int
71
71
  check_breakpoint_by_method(VALUE breakpoint, VALUE klass, ID mid)
72
72
  {
73
73
  debug_breakpoint_t *debug_breakpoint;
@@ -15,4 +15,6 @@ else
15
15
  exit(1)
16
16
  end
17
17
 
18
+ # Temporary: to turn off optimization
19
+ # $CFLAGS='-fno-strict-aliasing -g -fPIC'
18
20
  create_makefile("ruby_debug")
@@ -4,9 +4,9 @@
4
4
  #include <node.h>
5
5
  #include <rubysig.h>
6
6
  #include <st.h>
7
- #include <version.h>
7
+ #include <intern.h>
8
8
 
9
- #define DEBUG_VERSION "0.10.2"
9
+ #define DEBUG_VERSION "0.10.3"
10
10
 
11
11
 
12
12
  #ifdef _WIN32
@@ -341,6 +341,7 @@ debug_context_mark(void *data)
341
341
  frame = &(debug_context->frames[i]);
342
342
  rb_gc_mark(frame->binding);
343
343
  rb_gc_mark(frame->self);
344
+ rb_gc_mark(frame->arg_ary);
344
345
  if(frame->dead)
345
346
  {
346
347
  rb_gc_mark(frame->info.copy.locals);
@@ -466,26 +467,6 @@ call_at_line(VALUE context, debug_context_t *debug_context, VALUE file, VALUE li
466
467
  return rb_protect(call_at_line_unprotected, args, 0);
467
468
  }
468
469
 
469
- static VALUE
470
- call_at_return_unprotected(VALUE args)
471
- {
472
- VALUE context;
473
- context = *RARRAY(args)->ptr;
474
- return rb_funcall2(context, idAtReturn, RARRAY(args)->len - 1, RARRAY(args)->ptr + 1);
475
- }
476
-
477
- static VALUE
478
- call_at_return(VALUE context, debug_context_t *debug_context, VALUE file, VALUE line)
479
- {
480
- VALUE args;
481
-
482
- last_debugged_thnum = debug_context->thnum;
483
- save_current_position(debug_context);
484
-
485
- args = rb_ary_new3(3, context, file, line);
486
- return rb_protect(call_at_return_unprotected, args, 0);
487
- }
488
-
489
470
  static void
490
471
  save_call_frame(rb_event_t event, VALUE self, char *file, int line, ID mid, debug_context_t *debug_context)
491
472
  {
@@ -510,6 +491,7 @@ save_call_frame(rb_event_t event, VALUE self, char *file, int line, ID mid, debu
510
491
  debug_frame->orig_id = mid;
511
492
  debug_frame->dead = 0;
512
493
  debug_frame->self = self;
494
+ debug_frame->arg_ary = Qnil;
513
495
  debug_frame->info.runtime.frame = ruby_frame;
514
496
  debug_frame->info.runtime.scope = ruby_scope;
515
497
  debug_frame->info.runtime.dyna_vars = event == RUBY_EVENT_LINE ? ruby_dyna_vars : NULL;
@@ -1001,19 +983,28 @@ debug_stop_i(VALUE self)
1001
983
  /*
1002
984
  * call-seq:
1003
985
  * Debugger.start_ -> bool
1004
- * Debugger.start_ { ... } -> obj
986
+ * Debugger.start_ { ... } -> bool
1005
987
  *
1006
988
  * This method is internal and activates the debugger. Use
1007
- * Debugger.start (from ruby-debug-base.rb) instead.
989
+ * Debugger.start (from <tt>lib/ruby-debug-base.rb</tt>) instead.
1008
990
  *
1009
- * If it's called without a block it returns +true+, unless debugger
1010
- * was already started. If a block is given, it starts debugger and
1011
- * yields to block. When the block is finished executing it stops
1012
- * the debugger with Debugger.stop method.
991
+ * The return value is the value of !Debugger.started? <i>before</i>
992
+ * issuing the +start+; That is, +true+ is returned, unless debugger
993
+ * was previously started.
994
+
995
+ * If a block is given, it starts debugger and yields to block. When
996
+ * the block is finished executing it stops the debugger with
997
+ * Debugger.stop method. Inside the block you will probably want to
998
+ * have a call to Debugger.debugger. For example:
999
+ * Debugger.start{debugger; foo} # Stop inside of foo
1000
+ *
1001
+ * Also, ruby-debug only allows
1002
+ * one invocation of debugger at a time; nested Debugger.start's
1003
+ * have no effect and you can't use this inside the debugger itself.
1013
1004
  *
1014
- * <i>Note that if you want to stop debugger, you must call
1015
- * Debugger.stop as many time as you called Debugger.start
1016
- * method.</i>
1005
+ * <i>Note that if you want to completely remove the debugger hook,
1006
+ * you must call Debugger.stop as many times as you called
1007
+ * Debugger.start method.</i>
1017
1008
  */
1018
1009
  static VALUE
1019
1010
  debug_start(VALUE self)
@@ -1034,8 +1025,9 @@ debug_start(VALUE self)
1034
1025
  result = Qtrue;
1035
1026
  }
1036
1027
 
1037
- if(rb_block_given_p())
1038
- return rb_ensure(rb_yield, self, debug_stop_i, self);
1028
+ if(rb_block_given_p())
1029
+ rb_ensure(rb_yield, self, debug_stop_i, self);
1030
+
1039
1031
  return result;
1040
1032
  }
1041
1033
 
@@ -1046,9 +1038,9 @@ debug_start(VALUE self)
1046
1038
  * This method disables the debugger. It returns +true+ if the debugger is disabled,
1047
1039
  * otherwise it returns +false+.
1048
1040
  *
1049
- * <i>Note that if you want to stop debugger, you must call
1050
- * Debugger.stop as many times as you called Debugger.start
1051
- * method.</i>
1041
+ * <i>Note that if you want to complete remove the debugger hook,
1042
+ * you must call Debugger.stop as many times as you called
1043
+ * Debugger.start method.</i>
1052
1044
  */
1053
1045
  static VALUE
1054
1046
  debug_stop(VALUE self)
@@ -1407,6 +1399,8 @@ debug_debug_load(int argc, VALUE *argv, VALUE self)
1407
1399
  debug_context->stack_size = 0;
1408
1400
  if(RTEST(stop))
1409
1401
  debug_context->stop_next = 1;
1402
+ /* Initializing $0 to the script's path */
1403
+ ruby_script(RSTRING(file)->ptr);
1410
1404
  rb_load_protect(file, 0, &state);
1411
1405
  if (0 != state) {
1412
1406
  VALUE errinfo = ruby_errinfo;
@@ -1415,7 +1409,17 @@ debug_debug_load(int argc, VALUE *argv, VALUE self)
1415
1409
  ruby_errinfo = Qnil;
1416
1410
  return errinfo;
1417
1411
  }
1418
- debug_stop(self);
1412
+
1413
+ /* We should run all at_exit handler's in order to provide,
1414
+ * for instance, a chance to run all defined test cases */
1415
+ rb_exec_end_proc();
1416
+
1417
+ /* We could have issued a Debugger.stop inside the debug
1418
+ session. */
1419
+ if (start_count > 0) {
1420
+ debug_stop(self);
1421
+ }
1422
+
1419
1423
  return Qnil;
1420
1424
  }
1421
1425
 
@@ -2068,7 +2072,7 @@ context_tracing(VALUE self)
2068
2072
 
2069
2073
  /*
2070
2074
  * call-seq:
2071
- * context.tracking = bool
2075
+ * context.tracing = bool
2072
2076
  *
2073
2077
  * Controls the tracing for this context.
2074
2078
  */
@@ -109,8 +109,10 @@ typedef struct {
109
109
  /* routines in breakpoint.c */
110
110
  extern int check_breakpoint_expression(VALUE breakpoint, VALUE binding);
111
111
  extern int check_breakpoint_hit_condition(VALUE breakpoint);
112
+ extern VALUE check_breakpoints_by_method(debug_context_t *debug_context,
113
+ VALUE klass, ID mid);
112
114
  extern VALUE check_breakpoints_by_pos(debug_context_t *debug_context,
113
- char *file, int line);
115
+ char *file, int line);
114
116
  extern VALUE create_breakpoint_from_args(int argc, VALUE *argv, int id);
115
117
  extern VALUE context_breakpoint(VALUE self);
116
118
  extern VALUE context_set_breakpoint(int argc, VALUE *argv, VALUE self);
@@ -0,0 +1,149 @@
1
+
2
+ SHELL = /bin/sh
3
+
4
+ #### Start of system configuration section. ####
5
+
6
+ srcdir = ..
7
+ topdir = /usr/local/ruby-mingw32/lib/ruby/1.8/i386-mingw32
8
+ hdrdir = $(topdir)
9
+ VPATH = $(srcdir):$(topdir):$(hdrdir)
10
+ prefix = $(DESTDIR)/usr/local/ruby-mingw32
11
+ exec_prefix = $(prefix)
12
+ sitedir = $(prefix)/lib/ruby/site_ruby
13
+ rubylibdir = $(libdir)/ruby/$(ruby_version)
14
+ docdir = $(datarootdir)/doc/$(PACKAGE)
15
+ dvidir = $(docdir)
16
+ datarootdir = $(prefix)/share
17
+ archdir = $(rubylibdir)/$(arch)
18
+ sbindir = $(exec_prefix)/sbin
19
+ psdir = $(docdir)
20
+ localedir = $(datarootdir)/locale
21
+ htmldir = $(docdir)
22
+ datadir = $(datarootdir)
23
+ includedir = $(prefix)/include
24
+ infodir = $(datarootdir)/info
25
+ sysconfdir = $(prefix)/etc
26
+ mandir = $(datarootdir)/man
27
+ libdir = $(exec_prefix)/lib
28
+ sharedstatedir = $(prefix)/com
29
+ oldincludedir = $(DESTDIR)/usr/include
30
+ pdfdir = $(docdir)
31
+ sitearchdir = $(sitelibdir)/$(sitearch)
32
+ bindir = $(exec_prefix)/bin
33
+ localstatedir = $(prefix)/var
34
+ sitelibdir = $(sitedir)/$(ruby_version)
35
+ libexecdir = $(exec_prefix)/libexec
36
+
37
+ CC = i586-mingw32msvc-gcc
38
+ LIBRUBY = lib$(LIBRUBY_SO).a
39
+ LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
40
+ LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
41
+ LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
42
+
43
+ RUBY_EXTCONF_H =
44
+ CFLAGS = -g -O2
45
+ INCFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir)
46
+ CPPFLAGS =
47
+ CXXFLAGS = $(CFLAGS)
48
+ DLDFLAGS = -L. -Wl,--enable-auto-image-base,--enable-auto-import,--export-all
49
+ LDSHARED = i586-mingw32msvc-gcc -shared -s
50
+ AR = i586-mingw32msvc-ar
51
+ EXEEXT = .exe
52
+
53
+ RUBY_INSTALL_NAME = ruby
54
+ RUBY_SO_NAME = msvcrt-ruby18
55
+ arch = i386-mingw32
56
+ sitearch = i386-msvcrt
57
+ ruby_version = 1.8
58
+ ruby = /usr/local/ruby-mingw32/bin/ruby
59
+ RUBY = $(ruby)
60
+ RM = rm -f
61
+ MAKEDIRS = mkdir -p
62
+ INSTALL = /usr/bin/install -c
63
+ INSTALL_PROG = $(INSTALL) -m 0755
64
+ INSTALL_DATA = $(INSTALL) -m 644
65
+ COPY = cp
66
+
67
+ #### End of system configuration section. ####
68
+
69
+ preload =
70
+
71
+ libpath = . $(libdir)
72
+ LIBPATH = -L"." -L"$(libdir)"
73
+ DEFFILE =
74
+
75
+ CLEANFILES =
76
+ DISTCLEANFILES =
77
+
78
+ extout =
79
+ extout_prefix =
80
+ target_prefix =
81
+ LOCAL_LIBS =
82
+ LIBS = $(LIBRUBYARG_SHARED) -lwsock32
83
+ SRCS = ruby_debug.c breakpoint.c
84
+ OBJS = ruby_debug.o breakpoint.o
85
+ TARGET = ruby_debug
86
+ DLLIB = $(TARGET).so
87
+ EXTSTATIC =
88
+ STATIC_LIB =
89
+
90
+ RUBYCOMMONDIR = $(sitedir)$(target_prefix)
91
+ RUBYLIBDIR = $(sitelibdir)$(target_prefix)
92
+ RUBYARCHDIR = $(sitearchdir)$(target_prefix)
93
+
94
+ TARGET_SO = $(DLLIB)
95
+ CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
96
+ CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
97
+
98
+ all: $(DLLIB)
99
+ static: $(STATIC_LIB)
100
+
101
+ clean:
102
+ @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
103
+
104
+ distclean: clean
105
+ @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
106
+ @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
107
+
108
+ realclean: distclean
109
+ install: install-so install-rb
110
+
111
+ install-so: $(RUBYARCHDIR)
112
+ install-so: $(RUBYARCHDIR)/$(DLLIB)
113
+ $(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
114
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
115
+ install-rb: pre-install-rb install-rb-default
116
+ install-rb-default: pre-install-rb-default
117
+ pre-install-rb: Makefile
118
+ pre-install-rb-default: Makefile
119
+ $(RUBYARCHDIR):
120
+ $(MAKEDIRS) $@
121
+
122
+ site-install: site-install-so site-install-rb
123
+ site-install-so: install-so
124
+ site-install-rb: install-rb
125
+
126
+ .SUFFIXES: .c .m .cc .cxx .cpp .C .o
127
+
128
+ .cc.o:
129
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
130
+
131
+ .cxx.o:
132
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
133
+
134
+ .cpp.o:
135
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
136
+
137
+ .C.o:
138
+ $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
139
+
140
+ .c.o:
141
+ $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
142
+
143
+ $(DLLIB): $(OBJS)
144
+ @-$(RM) $@
145
+ $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
146
+
147
+
148
+
149
+ $(OBJS): ruby.h defines.h
Binary file
Binary file
Binary file
@@ -1,3 +1,92 @@
1
+ 2008-11-14 19:28 Rocky Bernstein
2
+
3
+ * ruby-debug-base.rb: Go over documentation and revise.
4
+
5
+ 2008-11-14 15:32 Rocky Bernstein
6
+
7
+ * ChangeLog, ruby-debug-base.rb: Move Debugger#debugger from base
8
+ to cli. Revert code in ruby_debug.c and block parameter in
9
+ debugger. cf. -> Compare with. Document Debugger.start better.
10
+
11
+ 2008-11-13 10:29 Rocky Bernstein
12
+
13
+ * ChangeLog: Make Debugger.start{block} work if Debugger.started?
14
+ is false. Second try.
15
+
16
+ 2008-11-11 02:07 Rocky Bernstein
17
+
18
+ * ChangeLog: Tweak truncated stack test since Ruby's caller doesn't
19
+ seem to include (tail?) recursive calls and we do. Get regression
20
+ tests working in light of recent changes.
21
+
22
+ 2008-11-10 01:48 Kent Sibilev
23
+
24
+ * ruby-debug-base.rb: a little bit more readable
25
+
26
+ 2008-11-10 01:35 Kent Sibilev
27
+
28
+ * ruby-debug-base.rb: Debugger.start must always call the passed
29
+ block
30
+
31
+ 2008-11-07 19:35 Rocky Bernstein
32
+
33
+ * ChangeLog: Change truncated frame message.
34
+
35
+ 2008-11-07 10:39 Rocky Bernstein
36
+
37
+ * ChangeLog: Add check to "where" to see if the call stack is
38
+ truncated; task #2354
39
+
40
+ 2008-11-06 16:17 Rocky Bernstein
41
+
42
+ * ChangeLog: #22698 Allow ruby-debug-base 0.x.y.z be compatible
43
+ with ruby-debug 0.x.y.
44
+
45
+ 2008-11-02 21:59 Rocky Bernstein
46
+
47
+ * ChangeLog, ruby-debug-base.rb: Debugger.start with a block now
48
+ stops inside the block. Debugger.debugger with a block works like
49
+ Debugger.start with a block.
50
+
51
+ The whole interface is hopelessly kludgy and needs to be redone.
52
+
53
+ 2008-10-26 14:54 Rocky Bernstein
54
+
55
+ * ChangeLog: Doc typo. Add comment to remind me how to turn off
56
+ optimizationin extconf.rb
57
+
58
+ 2008-10-25 16:01 Rocky Bernstein
59
+
60
+ * ChangeLog: Warn and add a "confirmation" when setting a
61
+ breakpoint on a file that is not loaded. Regression tests no
62
+ longer fail.
63
+
64
+ 2008-09-22 00:07 Rocky Bernstein
65
+
66
+ * ruby-debug-base.rb: #22118 bug in showing variables post mortem.
67
+ Patch thanks to rubikitch.
68
+ Update pm.rb integration test.
69
+
70
+ 2008-09-03 17:29 Rocky Bernstein
71
+
72
+ * ChangeLog: Show line numbers when $DEBUG is set. Patch #21772
73
+ from Martin Krauskopf
74
+
75
+ 2008-07-07 07:11 Rocky Bernstein
76
+
77
+ * ruby-debug-base.rb: Tracker [#20041] start erroneously moved to
78
+ Kernel - should be in
79
+ Debugger.start
80
+
81
+ 2008-06-20 06:46 Rocky Bernstein
82
+
83
+ * ruby-debug-base.rb: trace.rb: add "trace var"
84
+ ruby-debug-base.rb: remove another undefined warning.
85
+
86
+ 2008-05-24 01:27 Rocky Bernstein
87
+
88
+ * ChangeLog: Remove dup lines.
89
+
1
90
  2008-05-15 16:05 Rocky Bernstein
2
91
 
3
92
  * ChangeLog: Handle "catch nnn off" Forgotten there during r656.
@@ -7,7 +7,9 @@ module Debugger
7
7
  # Default options to Debugger.start
8
8
  DEFAULT_START_SETTINGS = {
9
9
  :init => true, # Set $0 and save ARGV?
10
- :post_mortem => false # post-mortem debugging on uncaught exception?
10
+ :post_mortem => false, # post-mortem debugging on uncaught exception?
11
+ :tracing => nil # Debugger.tracing value. true/false resets,
12
+ # nil keeps the prior value
11
13
  } unless defined?(DEFAULT_START_SETTINGS)
12
14
 
13
15
  class Context
@@ -24,7 +26,7 @@ module Debugger
24
26
 
25
27
  def hbinding(frame)
26
28
  hash = frame_locals(frame)
27
- code = hash.keys.map{|k| "#{k} = hash['#{k}']"}.join(';') + ';binding'
29
+ code = hash.keys.map{|k| "#{k} = hash['#{k}']" unless k=='self' }.compact.join(';') + ';binding'
28
30
  if obj = frame_self(frame)
29
31
  obj.instance_eval code
30
32
  else
@@ -163,20 +165,28 @@ module Debugger
163
165
  class ThreadsTable # :nodoc:
164
166
  end
165
167
 
166
- # Debugger.start(options) -> bool
167
- # Debugger.start(options) { ... } -> obj
168
+ # Debugger.start(options) -> bool
169
+ # Debugger.start(options) { ... } -> obj
168
170
  #
169
- # This method is internal and activates the debugger. Use
170
- # Debugger.start (from ruby-debug-base.rb) instead.
171
+ # If it's called without a block it returns +true+, unless debugger
172
+ # was already started. If a block is given, it starts debugger and
173
+ # yields to block. When the block is finished executing it stops
174
+ # the debugger with Debugger.stop method.
171
175
  #
172
- # If it's called without a block it returns +true+, unless debugger
173
- # was already started. If a block is given, it starts debugger and
174
- # yields to block. When the block is finished executing it stops
175
- # the debugger with Debugger.stop method.
176
+ # If a block is given, it starts debugger and yields to block. When
177
+ # the block is finished executing it stops the debugger with
178
+ # Debugger.stop method. Inside the block you will probably want to
179
+ # have a call to Debugger.debugger. For example:
176
180
  #
177
- # <i>Note that if you want to stop debugger, you must call
178
- # Debugger.stop as many time as you called Debugger.start
179
- # method.</i>
181
+ # Debugger.start{debugger; foo} # Stop inside of foo
182
+ #
183
+ # Also, ruby-debug only allows
184
+ # one invocation of debugger at a time; nested Debugger.start's
185
+ # have no effect and you can't use this inside the debugger itself.
186
+ #
187
+ # <i>Note that if you want to stop debugger, you must call
188
+ # Debugger.stop as many time as you called Debugger.start
189
+ # method.</i>
180
190
  #
181
191
  # +options+ is a hash used to set various debugging options.
182
192
  # Set :init true if you want to save ARGV and some variables which
@@ -196,7 +206,8 @@ module Debugger
196
206
  Debugger.const_set('INITIAL_DIR', Dir.pwd) unless
197
207
  defined? Debugger::INITIAL_DIR
198
208
  end
199
- retval = Debugger.started? ? nil : Debugger.start_(&block)
209
+ Debugger.tracing = options[:tracing] unless options[:tracing].nil?
210
+ retval = Debugger.started? ? block && block.call(self) : Debugger.start_(&block)
200
211
  if options[:post_mortem]
201
212
  post_mortem
202
213
  end
@@ -213,16 +224,24 @@ module Kernel
213
224
  # Setting _steps_ to 0 will cause a break in the debugger subroutine
214
225
  # and not wait for a line event to occur. You will have to go "up 1"
215
226
  # in order to be back in your debugged program rather than the
216
- # debugger. Settings _stess_ to 0 could be useful you want to stop
227
+ # debugger. Settings _steps_ to 0 could be useful you want to stop
217
228
  # right after the last statement in some scope, because the next
218
229
  # step will take you out of some scope.
219
- def debugger(steps = 1)
220
- Debugger.start unless Debugger.started?
221
- Debugger.run_init_script(StringIO.new)
222
- if 0 == steps
223
- Debugger.current_context.stop_frame = 0
230
+
231
+ # If a block is given (and the debugger hasn't been started, we run the
232
+ # block under the debugger. Alas, when a block is given, we can't support
233
+ # running the startup script or support the steps option. FIXME.
234
+ def debugger(steps = 1, &block)
235
+ if block
236
+ Debugger.start({}, &block)
224
237
  else
225
- Debugger.current_context.stop_next = steps
238
+ Debugger.start unless Debugger.started?
239
+ Debugger.run_init_script(StringIO.new)
240
+ if 0 == steps
241
+ Debugger.current_context.stop_frame = 0
242
+ else
243
+ Debugger.current_context.stop_next = steps
244
+ end
226
245
  end
227
246
  end
228
247
  alias breakpoint debugger unless respond_to?(:breakpoint)
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-debug-base
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kent Sibilev
@@ -9,12 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-28 00:00:00 -04:00
12
+ date: 2008-11-17 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: linecache
17
- type: :runtime
18
17
  version_requirement:
19
18
  version_requirements: !ruby/object:Gem::Requirement
20
19
  requirements:
@@ -41,9 +40,12 @@ files:
41
40
  - ext/extconf.rb
42
41
  - ext/ruby_debug.c
43
42
  - ext/ruby_debug.h
43
+ - ext/win32/Makefile
44
+ - ext/win32/ruby_debug.o
45
+ - ext/win32/breakpoint.o
44
46
  - ext/win32/ruby_debug.so
45
- - lib/ChangeLog
46
47
  - lib/ruby-debug-base.rb
48
+ - lib/ChangeLog
47
49
  - test/base/base.rb
48
50
  - test/base/binding.rb
49
51
  - test/base/catchpoint.rb
@@ -69,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
71
  requirements: []
70
72
 
71
73
  rubyforge_project: ruby-debug
72
- rubygems_version: 1.2.0
74
+ rubygems_version: 1.0.1
73
75
  signing_key:
74
76
  specification_version: 2
75
77
  summary: Fast Ruby debugger - core component