ruby-debug-base 0.9.3-mswin32 → 0.10.0-mswin32

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,7 +22,7 @@ module Debugger
22
22
  if obj = frame_self(frame)
23
23
  obj.instance_eval code
24
24
  else
25
- eval code
25
+ eval code, TOPLEVEL_BINDING
26
26
  end
27
27
  end
28
28
 
@@ -81,7 +81,7 @@ module Debugger
81
81
  SCRIPT_LINES__[file] = File.readlines(file)
82
82
  end
83
83
 
84
- change_time = test(?M, file)
84
+ change_time = File.stat(file).mtime
85
85
  SCRIPT_TIMESTAMPS__[file] ||= change_time
86
86
  if @reload_source_on_change && SCRIPT_TIMESTAMPS__[file] < change_time
87
87
  SCRIPT_LINES__[file] = File.readlines(file)
@@ -134,18 +134,20 @@ module Debugger
134
134
  # ...
135
135
  # end
136
136
  def post_mortem
137
- raise "Post-mortem is already activated" if self.post_mortem?
138
- self.post_mortem = true
139
137
  if block_given?
138
+ old_post_mortem = self.post_mortem?
140
139
  begin
140
+ self.post_mortem = true
141
141
  yield
142
142
  rescue Exception => exp
143
143
  handle_post_mortem(exp)
144
144
  raise
145
145
  ensure
146
- self.post_mortem = false
146
+ self.post_mortem = old_post_mortem
147
147
  end
148
148
  else
149
+ return if post_mortem?
150
+ self.post_mortem = true
149
151
  debug_at_exit do
150
152
  handle_post_mortem($!) if $! && post_mortem?
151
153
  end
@@ -172,16 +174,14 @@ module Debugger
172
174
  end
173
175
  end
174
176
 
175
- class Exception # :nodoc:
176
- attr_reader :__debug_file, :__debug_line, :__debug_binding, :__debug_context
177
- end
178
-
179
177
  module Kernel
180
178
  #
181
- # Stops the current thread after a number of _steps_ made.
179
+ # Enters the debugger in the current thread after a number of
180
+ # _steps_ made.
182
181
  #
183
182
  def debugger(steps = 1)
184
183
  Debugger.start unless Debugger.started?
184
+ Debugger.run_init_script(StringIO.new)
185
185
  Debugger.current_context.stop_next = steps
186
186
  end
187
187
  alias breakpoint debugger unless respond_to?(:breakpoint)
@@ -190,10 +190,16 @@ module Kernel
190
190
  # Returns a binding of n-th call frame
191
191
  #
192
192
  def binding_n(n = 0)
193
- Debugger.current_context.frame_binding[n+1]
193
+ Debugger.skip do
194
+ Debugger.current_context.frame_binding(n+2)
195
+ end
194
196
  end
195
197
  end
196
198
 
199
+ class Exception # :nodoc:
200
+ attr_reader :__debug_file, :__debug_line, :__debug_binding, :__debug_context
201
+ end
202
+
197
203
  class Module
198
204
  #
199
205
  # Wraps the +meth+ method with Debugger.start {...} block.
Binary file
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env ruby
2
+ require "test/unit"
3
+
4
+ $: << File.expand_path(File.dirname(__FILE__)) + '/../ext'
5
+ $: << File.expand_path(File.dirname(__FILE__)) + '/../lib'
6
+ require "ruby_debug"
7
+
8
+ # Test of C extension ruby_debug.so
9
+ class TestRubyDebug < Test::Unit::TestCase
10
+ include Debugger
11
+
12
+ # test current_context
13
+ def test_current_context
14
+ assert_equal(false, Debugger.started?,
15
+ "debugger should not initially be started.")
16
+ Debugger.start
17
+ assert(Debugger.started?,
18
+ "debugger should now be started.")
19
+ assert_equal(19, Debugger.current_context.frame_line)
20
+ assert_equal(nil, Debugger.current_context.frame_args_info,
21
+ "no frame args info.")
22
+ assert_equal(Debugger.current_context.frame_file,
23
+ Debugger.current_context.frame_file(0))
24
+ assert_equal("test-ruby-debug-base.rb",
25
+ File.basename(Debugger.current_context.frame_file))
26
+ assert_raises(ArgumentError) {Debugger.current_context.frame_file(1, 2)}
27
+ assert_raises(ArgumentError) {Debugger.current_context.frame_file(10)}
28
+ assert_equal(1, Debugger.current_context.stack_size)
29
+ assert_equal(TestRubyDebug, Debugger.current_context.frame_class)
30
+ assert_equal(false, Debugger.current_context.dead?, "Not dead yet!")
31
+ Debugger.stop
32
+ assert_equal(false, Debugger.started?,
33
+ "Debugger should no longer be started.")
34
+ end
35
+
36
+ # Test initial variables and setting/getting state.
37
+ def test_debugger_base
38
+ assert_equal(false, Debugger.started?,
39
+ "Debugger should not initially be started.")
40
+ Debugger.start
41
+ assert(Debugger.started?,
42
+ "Debugger should now be started.")
43
+ assert_equal(false, Debugger.debug,
44
+ "Debug variable should not be set.")
45
+ assert_equal(false, Debugger.post_mortem?,
46
+ "Post mortem debugging should not be set.")
47
+ a = Debugger.contexts
48
+ assert_equal(1, a.size,
49
+ "There should only be one context.")
50
+ assert_equal(Array, a.class,
51
+ "Context should be an array.")
52
+ Debugger.stop
53
+ assert_equal(false, Debugger.started?,
54
+ "debugger should no longer be started.")
55
+ end
56
+
57
+ # Test breakpoint handling
58
+ def test_breakpoints
59
+ Debugger.start
60
+ assert_equal(0, Debugger.breakpoints.size,
61
+ "There should not be any breakpoints set.")
62
+ brk = Debugger.add_breakpoint(__FILE__, 1)
63
+ assert_equal(Debugger::Breakpoint, brk.class,
64
+ "Breakpoint should have been set and returned.")
65
+ assert_equal(1, Debugger.breakpoints.size,
66
+ "There should now be one breakpoint set.")
67
+ Debugger.remove_breakpoint(0)
68
+ assert_equal(1, Debugger.breakpoints.size,
69
+ "There should still be one breakpoint set.")
70
+ Debugger.remove_breakpoint(1)
71
+ assert_equal(0, Debugger.breakpoints.size,
72
+ "There should no longer be any breakpoints set.")
73
+ Debugger.stop
74
+ end
75
+ end
76
+
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
2
+ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: ruby-debug-base
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.9.3
7
- date: 2007-05-01 14:29:39 +02:00
8
- summary: Fast Ruby debugger
6
+ version: 0.10.0
7
+ date: 2008-02-07 00:00:00 -05:00
8
+ summary: Fast Ruby debugger - core component
9
9
  require_paths:
10
10
  - lib
11
11
  email: ksibilev@yahoo.com
12
12
  homepage: http://rubyforge.org/projects/ruby-debug/
13
13
  rubyforge_project: ruby-debug
14
- description: ruby-debug is a fast implementation of the standard Ruby debugger debug.rb. It's implemented by utilizing a new hook Ruby C API.
14
+ description: ruby-debug is a fast implementation of the standard Ruby debugger debug.rb. It is implemented by utilizing a new Ruby C API hook. The core component provides support that front-ends can build on. It provides breakpoint handling, bindings for stack frames among other things.
15
15
  autorequire: ruby-debug-base
16
16
  default_executable:
17
17
  bindir: bin
@@ -29,17 +29,23 @@ post_install_message:
29
29
  authors:
30
30
  - Kent Sibilev
31
31
  files:
32
- - README
33
- - LICENSE
34
- - CHANGES
35
32
  - AUTHORS
33
+ - CHANGES
34
+ - LICENSE
35
+ - README
36
+ - Rakefile
36
37
  - lib/ruby-debug-base.rb
37
- - ext/win32
38
- - ext/extconf.rb
38
+ - lib/ChangeLog
39
+ - ext/ChangeLog
39
40
  - ext/ruby_debug.c
41
+ - ext/extconf.rb
42
+ - ext/win32/ruby_debug.so
43
+ - ext/win32/Makefile
44
+ - ext/win32/ruby_debug.o
45
+ - test/test-ruby-debug-base.rb
40
46
  - lib/ruby_debug.so
41
- test_files: []
42
-
47
+ test_files:
48
+ - test/test-ruby-debug-base.rb
43
49
  rdoc_options: []
44
50
 
45
51
  extra_rdoc_files: