ruby-debug-base 0.10.4-java → 0.10.5.rc1-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ module Debugger
2
+ VERSION = "0.10.5.rc1"
3
+ end
@@ -1,16 +1,15 @@
1
- require 'ruby_debug.jar'
2
- require File.join(File.dirname(__FILE__), 'tracelines')
3
- require File.join(File.dirname(__FILE__), 'linecache')
4
-
5
- SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
6
- SCRIPT_TIMESTAMPS__ = {} unless defined? SCRIPT_TIMESTAMPS__
1
+ require 'ruby_debug'
2
+ require 'ruby-debug-base/version'
3
+ require 'linecache'
7
4
 
8
5
  module Debugger
9
6
 
10
7
  # Default options to Debugger.start
11
8
  DEFAULT_START_SETTINGS = {
12
9
  :init => true, # Set $0 and save ARGV?
13
- :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
14
13
  } unless defined?(DEFAULT_START_SETTINGS)
15
14
 
16
15
  class Context
@@ -27,7 +26,7 @@ module Debugger
27
26
 
28
27
  def hbinding(frame)
29
28
  hash = frame_locals(frame)
30
- 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'
31
30
  if obj = frame_self(frame)
32
31
  obj.instance_eval code
33
32
  else
@@ -91,12 +90,13 @@ module Debugger
91
90
  end
92
91
 
93
92
  def source_reload
94
- LineCache::clear_file_cache(true)
93
+ LineCache::clear_file_cache
95
94
  end
96
95
 
97
96
  # Get line +line_number+ from file named +filename+. Return "\n"
98
97
  # there was a problem. Leaking blanks are stripped off.
99
98
  def line_at(filename, line_number) # :nodoc:
99
+ @reload_on_change=nil unless defined?(@reload_on_change)
100
100
  line = LineCache::getline(filename, line_number, @reload_on_change)
101
101
  return "\n" unless line
102
102
  return "#{line.gsub(/^\s+/, '').chomp}\n"
@@ -164,34 +164,29 @@ module Debugger
164
164
 
165
165
  class ThreadsTable # :nodoc:
166
166
  end
167
- end
168
167
 
169
- module Kernel
168
+ # Debugger.start(options) -> bool
169
+ # Debugger.start(options) { ... } -> obj
170
170
  #
171
- # Enters the debugger in the current thread after a number of
172
- # _steps_ made.
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.
173
175
  #
174
- def debugger(steps = 1)
175
- Debugger.start unless Debugger.started?
176
- Debugger.run_init_script(StringIO.new)
177
- Debugger.current_context.stop_next = steps
178
- end
179
- alias breakpoint debugger unless respond_to?(:breakpoint)
180
-
181
- # Debugger.start(options) -> bool
182
- # Debugger.start(options) { ... } -> obj
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:
183
180
  #
184
- # This method is internal and activates the debugger. Use
185
- # Debugger.start (from ruby-debug-base.rb) instead.
181
+ # Debugger.start{debugger; foo} # Stop inside of foo
186
182
  #
187
- # If it's called without a block it returns +true+, unless debugger
188
- # was already started. If a block is given, it starts debugger and
189
- # yields to block. When the block is finished executing it stops
190
- # the debugger with Debugger.stop method.
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.
191
186
  #
192
- # <i>Note that if you want to stop debugger, you must call
193
- # Debugger.stop as many time as you called Debugger.start
194
- # method.</i>
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>
195
190
  #
196
191
  # +options+ is a hash used to set various debugging options.
197
192
  # Set :init true if you want to save ARGV and some variables which
@@ -211,13 +206,49 @@ module Kernel
211
206
  Debugger.const_set('INITIAL_DIR', Dir.pwd) unless
212
207
  defined? Debugger::INITIAL_DIR
213
208
  end
214
- 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)
215
211
  if options[:post_mortem]
216
212
  post_mortem
217
213
  end
218
214
  return retval
219
215
  end
216
+ module_function :start
217
+ end
218
+
219
+ module Kernel
220
220
 
221
+ # Enters the debugger in the current thread after _steps_ line
222
+ # events occur. Before entering the debugger, a user-defined
223
+ # startup script is may be read.
224
+ #
225
+ # Setting _steps_ to 0 will cause a break in the debugger subroutine
226
+ # and not wait for a line event to occur. You will have to go "up 1"
227
+ # in order to be back in your debugged program rather than the
228
+ # debugger. Settings _steps_ to 0 could be useful you want to stop
229
+ # right after the last statement in some scope, because the next
230
+ # step will take you out of some scope.
231
+ #
232
+ # If block _block_ is given (and the debugger hasn't been started,
233
+ # we run the block under the debugger.
234
+ #
235
+ # FIXME: Alas, when a block is given, we can't support running the
236
+ # startup script or support the steps option.
237
+ def debugger(steps = 1, &block)
238
+ if block
239
+ Debugger.start({}, &block)
240
+ else
241
+ Debugger.start unless Debugger.started?
242
+ Debugger.run_init_script(StringIO.new)
243
+ if 0 == steps
244
+ Debugger.current_context.stop_frame = 0
245
+ else
246
+ Debugger.current_context.stop_next = steps
247
+ end
248
+ end
249
+ end
250
+ alias breakpoint debugger unless respond_to?(:breakpoint)
251
+
221
252
  #
222
253
  # Returns a binding of n-th call frame
223
254
  #
data/lib/ruby_debug.jar CHANGED
Binary file
data/test/base/base.rb ADDED
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path("../../helper", __FILE__)
3
+
4
+ # Some tests of Debugger module in C extension ruby_debug
5
+ class TestRubyDebug < Test::Unit::TestCase
6
+ def test_version
7
+ assert(defined?(Debugger::VERSION))
8
+ end
9
+
10
+ # test current_context
11
+ def test_current_context
12
+ assert_equal(false, Debugger.started?,
13
+ 'debugger should not initially be started.')
14
+ Debugger.start_
15
+ assert(Debugger.started?,
16
+ 'debugger should now be started.')
17
+ assert_equal(__LINE__, Debugger.current_context.frame_line)
18
+ assert_equal(nil, Debugger.current_context.frame_args_info,
19
+ 'no frame args info.')
20
+ assert_equal(Debugger.current_context.frame_file,
21
+ Debugger.current_context.frame_file(0))
22
+ assert_equal(File.basename(__FILE__),
23
+ File.basename(Debugger.current_context.frame_file))
24
+ assert_raises(ArgumentError) {Debugger.current_context.frame_file(1, 2)}
25
+ assert_raises(ArgumentError) {Debugger.current_context.frame_file(10)}
26
+ assert_equal(1, Debugger.current_context.stack_size)
27
+ assert_equal(TestRubyDebug, Debugger.current_context.frame_class)
28
+ assert_equal(false, Debugger.current_context.dead?, 'Not dead yet!')
29
+ ensure
30
+ Debugger.stop
31
+ assert_equal(false, Debugger.started?,
32
+ 'Debugger should no longer be started.')
33
+ end
34
+
35
+ # Test initial variables and setting/getting state.
36
+ def test_debugger_base
37
+ assert_equal(false, Debugger.started?,
38
+ 'Debugger should not initially be started.')
39
+ Debugger.start_
40
+ assert(Debugger.started?,
41
+ 'Debugger should now be started.')
42
+ assert_equal(false, Debugger.debug,
43
+ 'Debug variable should not be set.')
44
+ assert_equal(false, Debugger.post_mortem?,
45
+ 'Post mortem debugging should not be set.')
46
+ a = Debugger.contexts
47
+ assert_equal(1, a.size,
48
+ 'There should only be one context.')
49
+ assert_equal(Array, a.class,
50
+ 'Context should be an array.')
51
+ ensure
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
+ ensure
74
+ Debugger.stop
75
+ end
76
+ end
77
+
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path("../../helper", __FILE__)
3
+
4
+ # Test binding_n command
5
+ class TestBinding < Test::Unit::TestCase
6
+ def test_basic
7
+ def inside_fn
8
+ s = 'some other string'
9
+ b2 = Kernel::binding_n(1)
10
+ y2 = eval('s', b2)
11
+ assert_equal('this is a test', y2)
12
+ end
13
+ s = 'this is a test'
14
+ Debugger.start
15
+ b = Kernel::binding_n(0)
16
+ y = eval('s', b)
17
+ assert_equal(s, y)
18
+ inside_fn
19
+ ensure
20
+ Debugger.stop
21
+ end
22
+ end
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path("../../helper", __FILE__)
3
+
4
+ # Test catchpoint in C ruby_debug extension.
5
+
6
+ class TestRubyDebugCatchpoint < Test::Unit::TestCase
7
+ def test_catchpoints
8
+ assert_raise(RuntimeError) {Debugger.catchpoints}
9
+ Debugger.start_
10
+ assert_equal({}, Debugger.catchpoints)
11
+ Debugger.add_catchpoint('ZeroDivisionError')
12
+ assert_equal({'ZeroDivisionError' => 0}, Debugger.catchpoints)
13
+ Debugger.add_catchpoint('RuntimeError')
14
+ assert_equal(['RuntimeError', 'ZeroDivisionError'],
15
+ Debugger.catchpoints.keys.sort)
16
+ ensure
17
+ Debugger.stop
18
+ end
19
+ end
data/test/base/load.rb ADDED
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path("../../helper", __FILE__)
3
+
4
+ # Test of Debugger.debug_load in C extension ruby_debug.so
5
+ class TestDebugLoad < Test::Unit::TestCase
6
+ class << self
7
+ def at_line(file, line)
8
+ @@at_line = [File.basename(file), line]
9
+ end
10
+ end
11
+
12
+ class Debugger::Context
13
+ def at_line(file, line)
14
+ TestDebugLoad::at_line(file, line)
15
+ end
16
+ end
17
+
18
+ def test_debug_load
19
+ src_dir = File.dirname(__FILE__)
20
+ prog_script = File.join(src_dir, '..', 'example', 'gcd.rb')
21
+
22
+ # Without stopping
23
+ bt = Debugger.debug_load(prog_script, false)
24
+ assert_equal(nil, bt)
25
+ assert(Debugger.started?)
26
+ Debugger.stop
27
+
28
+ # With stopping
29
+ bt = Debugger.debug_load(prog_script, true)
30
+ assert_equal(nil, bt)
31
+ assert_equal(['gcd.rb', 4], @@at_line)
32
+ assert(Debugger.started?)
33
+ Debugger.stop
34
+
35
+ # Test that we get a proper backtrace on a script that raises 'abc'
36
+ prog_script = File.join(src_dir, '..', 'example', 'raise.rb')
37
+ bt = Debugger.debug_load(prog_script, false)
38
+ assert_equal('abc', bt.to_s)
39
+ assert(Debugger.started?)
40
+ Debugger.stop
41
+ ensure
42
+ Debugger.stop if Debugger.started?
43
+ end
44
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path("../../helper", __FILE__)
3
+
4
+ class TestReloadBug < Test::Unit::TestCase
5
+ def test_reload_bug
6
+ assert_equal({}, Debugger::source_reload)
7
+ end
8
+ end
metadata CHANGED
@@ -1,47 +1,72 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-debug-base
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 10
8
- - 4
9
- version: 0.10.4
4
+ prerelease: 7
5
+ version: 0.10.5.rc1
10
6
  platform: java
11
7
  authors:
12
- - debug-commons team
8
+ - Kent Sibilev
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2010-11-10 00:00:00 -06:00
13
+ date: 2011-10-19 00:00:00 -07:00
18
14
  default_executable:
19
- dependencies: []
20
-
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: linecache
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0.3"
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake-compiler
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "0"
36
+ type: :development
37
+ version_requirements: *id002
21
38
  description: |
22
- Java extension to make fast ruby debugger run on JRuby.
23
- It is the same what ruby-debug-base is for native Ruby.
39
+ ruby-debug is a fast implementation of the standard Ruby debugger debug.rb.
40
+ It is implemented by utilizing a new Ruby C API hook. The core component
41
+ provides support that front-ends can build on. It provides breakpoint
42
+ handling, bindings for stack frames among other things.
24
43
 
25
- email:
44
+ email: ksibilev@yahoo.com
26
45
  executables: []
27
46
 
28
47
  extensions: []
29
48
 
30
- extra_rdoc_files: []
31
-
49
+ extra_rdoc_files:
50
+ - README
51
+ - ext/ruby_debug.c
32
52
  files:
33
53
  - AUTHORS
34
- - ChangeLog
35
- - lib/linecache.rb
36
- - lib/linecache-ruby.rb
54
+ - CHANGES
55
+ - LICENSE
56
+ - README
57
+ - Rakefile
37
58
  - lib/ruby-debug-base.rb
59
+ - lib/ruby-debug-base/version.rb
60
+ - test/base/base.rb
61
+ - test/base/binding.rb
62
+ - test/base/catchpoint.rb
63
+ - test/base/load.rb
64
+ - test/base/reload_bug.rb
65
+ - ext/ruby_debug.c
66
+ - ext/extconf.rb
38
67
  - lib/ruby_debug.jar
39
- - lib/tracelines.rb
40
- - MIT-LICENSE
41
- - Rakefile
42
- - README
43
68
  has_rdoc: true
44
- homepage: http://rubyforge.org/projects/debug-commons/
69
+ homepage: http://rubyforge.org/projects/ruby-debug/
45
70
  licenses: []
46
71
 
47
72
  post_install_message:
@@ -54,23 +79,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
54
79
  requirements:
55
80
  - - ">="
56
81
  - !ruby/object:Gem::Version
57
- segments:
58
- - 0
59
- version: "0"
82
+ version: 1.8.2
60
83
  required_rubygems_version: !ruby/object:Gem::Requirement
61
84
  none: false
62
85
  requirements:
63
- - - ">="
86
+ - - ">"
64
87
  - !ruby/object:Gem::Version
65
- segments:
66
- - 0
67
- version: "0"
88
+ version: 1.3.1
68
89
  requirements: []
69
90
 
70
- rubyforge_project: debug-commons
71
- rubygems_version: 1.3.7
91
+ rubyforge_project: ruby-debug
92
+ rubygems_version: 1.5.1
72
93
  signing_key:
73
94
  specification_version: 3
74
- summary: Java implementation of Fast Ruby Debugger
75
- test_files: []
76
-
95
+ summary: Fast Ruby debugger - core component
96
+ test_files:
97
+ - test/base/base.rb
98
+ - test/base/binding.rb
99
+ - test/base/catchpoint.rb
100
+ - test/base/load.rb
101
+ - test/base/reload_bug.rb