rbx-trepanning 0.0.2-universal-rubinius-1.2 → 0.0.3-universal-rubinius-1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,17 +1,16 @@
1
1
  # Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
2
2
  require 'rubygems'; require 'require_relative'
3
- require '/home/rocky-rvm/.rvm/src/rbx-trepanning/processor/command/base/cmd'
4
3
  require_relative 'base/cmd'
5
4
 
6
5
  # up command. Like 'down' butthe direction (set by DIRECTION) is different.
7
6
  #
8
- # NOTE: The down command subclasses this, so beware when changing!
7
+ # NOTE: The down command subclasses this, so beware when changing!
9
8
  class Trepan::Command::UpCommand < Trepan::Command
10
9
 
11
10
  # Silence already initialized constant .. warnings
12
- old_verbose = $VERBOSE
11
+ old_verbose = $VERBOSE
13
12
  $VERBOSE = nil
14
- HELP =
13
+ HELP =
15
14
  "u(p) [count]
16
15
 
17
16
  Move the current frame up in the stack trace (to an older frame). 0 is
@@ -26,14 +25,14 @@ See also 'down' and 'frame'.
26
25
  NAME = File.basename(__FILE__, '.rb')
27
26
  NEED_STACK = true
28
27
  SHORT_HELP = 'Move frame in the direction of the caller of the last-selected frame'
29
- $VERBOSE = old_verbose
28
+ $VERBOSE = old_verbose
30
29
 
31
30
  def initialize(proc)
32
31
  super
33
32
  @direction = +1 # -1 for down.
34
33
  end
35
34
 
36
- # Run 'up' command.
35
+ # Run 'up' command.
37
36
  def run(args)
38
37
 
39
38
  # FIXME: move into @proc and test based on NEED_STACK.
@@ -49,7 +48,7 @@ See also 'down' and 'frame'.
49
48
  count_str = args[1]
50
49
  name_or_id = args[1]
51
50
  opts = {
52
- :msg_on_error =>
51
+ :msg_on_error =>
53
52
  "The '#{NAME}' command argument must eval to an integer. Got: %s" % count_str,
54
53
  :min_value => -@proc.stack_size,
55
54
  :max_value => @proc.stack_size-1
@@ -68,19 +67,19 @@ if __FILE__ == $0
68
67
 
69
68
  # def sep ; puts '=' * 40 end
70
69
  # cmd.run [cmd.name]
71
- # %w(-1 0 1 -2).each do |count|
70
+ # %w(-1 0 1 -2).each do |count|
72
71
  # puts "#{cmd.name} #{count}"
73
72
  # cmd.run([cmd.name, count])
74
- # sep
73
+ # sep
75
74
  # end
76
75
  # def foo(cmd, cmd.name)
77
76
  # puts "#{cmd.name}"
78
77
  # cmd.run([cmd.name])
79
78
  # sep
80
- # %w(-2 -1).each do |count|
79
+ # %w(-2 -1).each do |count|
81
80
  # puts "#{cmd.name} #{count}"
82
81
  # cmd.run([cmd.name, count])
83
- # sep
82
+ # sep
84
83
  # end
85
84
  # end
86
85
  # foo(cmd, cmd.name)
data/processor/main.rb CHANGED
@@ -257,7 +257,7 @@ class Trepan
257
257
  end
258
258
  if @return_to_program
259
259
  after_cmdloop
260
- if @step_count >= 0
260
+ if @step_count >= 0 && 'finish' != @return_to_program
261
261
  @step_bp = step_over_by(1)
262
262
  run_command('disassemble') if settings[:debugstep]
263
263
  dbgr.listen('step' == @return_to_program)
data/processor/running.rb CHANGED
@@ -34,14 +34,14 @@ class Trepan
34
34
  # # execution.
35
35
  # # FIXME: turn line_number into a condition.
36
36
 
37
- def continue(how_to_continue)
37
+ def continue(return_to_program)
38
38
  @next_thread = nil
39
39
  @step_count = -1 # No more event stepping
40
- if 'step-finish' == how_to_continue
40
+ if 'step-finish' == return_to_program
41
41
  step_to_return_or_yield
42
- how_to_continue = 'step'
42
+ return_to_program = 'step'
43
43
  end
44
- @return_to_program = how_to_continue
44
+ @return_to_program = return_to_program
45
45
  end
46
46
 
47
47
  # Does whatever setup needs to be done to set to ignore stepping
@@ -52,6 +52,8 @@ class Trepan
52
52
  continue('finish')
53
53
  @next_thread = @current_thread
54
54
 
55
+ @step_count = 2 if 'nostack' == opts[:different_pos]
56
+
55
57
  # # Try high-speed (run-time-assisted) method
56
58
  # @frame.trace_off = true # No more tracing in this frame
57
59
  # @frame.return_stop = true # don't need to
@@ -72,8 +74,8 @@ class Trepan
72
74
 
73
75
  # Does whatever needs to be done to set to step program
74
76
  # execution.
75
- def step(how_to_continue, step_count=1, opts={}, condition=nil)
76
- continue(how_to_continue)
77
+ def step(return_to_program, step_count=1, opts={}, condition=nil)
78
+ continue(return_to_program)
77
79
  @step_count = step_count
78
80
  @different_pos = opts[:different_pos] if
79
81
  opts.keys.member?(:different_pos)
@@ -167,7 +169,7 @@ class Trepan
167
169
  end
168
170
 
169
171
  # Only skip on these kinds of events
170
- unless %w(step-call line).include?(@event)
172
+ unless %w(step-call line return).include?(@event)
171
173
  msg "skip non-line: #{@event} #{debug_loc}" if @settings[:debugskip]
172
174
  return false
173
175
  end
@@ -187,6 +189,7 @@ class Trepan
187
189
  msg("last: #{@last_pos.inspect}, ")
188
190
  msg("new: #{new_pos.inspect}")
189
191
  msg("skip: #{should_skip.inspect}, event: #{@event}")
192
+ msg("@step_count: #{@step_count}")
190
193
  end
191
194
 
192
195
  @last_pos[2] = new_pos[2] if 'nostack' == @different_pos
@@ -222,7 +225,8 @@ class Trepan
222
225
  # @stop_events = nil
223
226
  end
224
227
 
225
- @return_to_program = 'step' if should_skip && !@return_to_program
228
+ @return_to_program = 'step' if should_skip &&
229
+ (!@return_to_program || 'finish' == @return_to_program)
226
230
  return should_skip
227
231
  end
228
232
 
@@ -13,7 +13,11 @@ class Trepan
13
13
 
14
14
  meth = f.method
15
15
  possible_line = f.line + step
16
+ next_ip = f.next_ip == f.ip ? f.next_ip + 1 : f.next_ip
17
+ # BUGGY: remove after writing a decent test case for this.
18
+ # See beginning of rbx-require/require_relative.
16
19
  fin_ip = meth.first_ip_on_line_after(possible_line, f.next_ip)
20
+ # fin_ip = meth.first_ip_on_line_after(possible_line, next_ip)
17
21
 
18
22
  if fin_ip <= -1
19
23
  return step_to_parent('line')
@@ -35,10 +35,10 @@ def run_debugger(testname, ruby_file, opts={})
35
35
 
36
36
  cmd =
37
37
  if opts[:xdebug]
38
- "%s -Xdebug '%s' %s >%s <%s" %
38
+ "%s -Xdebug '%s' %s >%s 2>&1 <%s" %
39
39
  [Trepanning::ruby_path, programfile, opts[:args], outfile, cmdfile]
40
40
  else
41
- "%s %s --nx --command %s %s '%s' %s >%s" %
41
+ "%s %s --nx --command %s %s '%s' %s >%s 2>&1" %
42
42
  [Trepanning::ruby_path, dbgr_path, cmdfile, opts[:dbgr],
43
43
  programfile, opts[:args], outfile]
44
44
  end
@@ -11,15 +11,22 @@ class TestQuit < Test::Unit::TestCase
11
11
  end
12
12
 
13
13
  def test_xcode_call
14
- no_error = run_debugger('quit-Xdebug', 'null.rb',
15
- {:xdebug => true,
16
- :short_cmd => @@NAME,
17
- :do_diff => false
18
- })
19
- assert_equal(true, no_error)
20
- if no_error
21
- outfile = File.join(File.dirname(__FILE__), 'quit-Xdebug.out')
22
- FileUtils.rm(outfile)
14
+ startup_file = File.join(ENV['HOME'], '.rbxrc')
15
+ lines = File.open(startup_file).readlines.grep(/Trepan\.start/)
16
+ if lines && lines.any?{|line| line.grep(/:Xdebug/)}
17
+ no_error = run_debugger('quit-Xdebug', 'null.rb',
18
+ {:xdebug => true,
19
+ :short_cmd => @@NAME,
20
+ :do_diff => false
21
+ })
22
+ assert_equal(true, no_error)
23
+ if no_error
24
+ outfile = File.join(File.dirname(__FILE__), 'quit-Xdebug.out')
25
+ FileUtils.rm(outfile)
26
+ end
27
+ else
28
+ puts "Trepan.start(:skip_loader=>:Xdebug) is not in ~.rbxrc. Skipping."
29
+ assert true
23
30
  end
24
31
  end
25
32
  end
@@ -1,3 +1,4 @@
1
+ require 'test/unit'
1
2
  require 'rubygems'; require 'require_relative'
2
3
  # require_relative '../../app/core'
3
4
  require_relative '../../processor/mock'
@@ -0,0 +1,9 @@
1
+ require 'test/unit'
2
+ require_relative '../../processor/mock'
3
+
4
+ module MockUnitHelper
5
+ def common_setup(name)
6
+ @dbg, @cmd = MockDebugger::setup(name, false)
7
+ end
8
+ end
9
+
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- require 'test/unit'
3
2
  require 'rubygems'; require 'require_relative'
4
3
  require_relative 'cmd-helper'
5
4
  require_relative '../../processor/command/alias'
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- require 'test/unit'
3
2
  require 'rubygems'; require 'require_relative'
4
3
  require_relative 'cmd-helper'
5
4
 
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'test/unit'
3
3
  require 'rubygems'; require 'require_relative'
4
- require_relative '../../processor/mock'
4
+ require_relative './mock-helper'
5
5
  require_relative '../../processor/command/exit'
6
6
 
7
7
  class TestCommandExit < Test::Unit::TestCase
8
-
8
+ include MockUnitHelper
9
9
  def setup
10
10
  @name = File.basename(__FILE__, '.rb').split(/-/)[2]
11
- @dbg, @cmd = MockDebugger::setup(@name, false)
11
+ common_setup(@name)
12
12
  end
13
13
 
14
14
  def test_basic
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'; require 'require_relative'
3
+ require_relative 'cmd-helper'
4
+
5
+ class TestCommandFinish < Test::Unit::TestCase
6
+
7
+ include UnitHelper
8
+ def setup
9
+ common_setup
10
+ @cmdproc.frame_setup
11
+ @name = File.basename(__FILE__, '.rb').split(/-/)[2]
12
+ @my_cmd = @cmds[@name]
13
+ end
14
+
15
+ def test_basic
16
+ [
17
+ [%W(#{@name}), 'finish', -1],
18
+ [%W(#{@name} 2-1), 'finish', -1],
19
+ ].each do |c, rtp, count|
20
+ @cmdproc.instance_variable_set('@return_to_program', false)
21
+ @my_cmd.run(c)
22
+ assert_equal(rtp, @cmdproc.instance_variable_get('@return_to_program'))
23
+ assert_equal(count, @cmdproc.instance_variable_get('@step_count'))
24
+ end
25
+ end
26
+
27
+ end
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- require 'test/unit'
3
2
  require 'rubygems'; require 'require_relative'
4
3
  require_relative 'cmd-helper'
5
4
  require_relative '../../processor/command/help'
@@ -1,14 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
- require 'test/unit'
3
2
  require 'rubygems'; require 'require_relative'
4
- require_relative '../../processor/mock'
3
+ require_relative './mock-helper'
5
4
  require_relative '../../processor/command/kill'
6
5
 
7
6
  class TestCommandKill < Test::Unit::TestCase
8
-
7
+ include MockUnitHelper
9
8
  def setup
10
- @name = File.basename(__FILE__, '.rb').split(/-/)[2]
11
- @dbg, @cmd = MockDebugger::setup(@name, false)
9
+ @name = File.basename(__FILE__, '.rb').split(/-/)[2]
10
+ common_setup(@name)
12
11
  def @cmd.msg(message)
13
12
  @msgs << message
14
13
  end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'; require 'require_relative'
3
+ require_relative 'cmd-helper'
4
+
5
+ class TestCommandStep < Test::Unit::TestCase
6
+
7
+ include UnitHelper
8
+ def setup
9
+ common_setup
10
+ @cmdproc.frame_setup
11
+ @name = File.basename(__FILE__, '.rb').split(/-/)[2]
12
+ @my_cmd = @cmds[@name]
13
+ end
14
+
15
+ def test_basic
16
+ [
17
+ [%W(#{@name}), 'step', 1],
18
+ [%W(#{@name} 2), 'step', 2],
19
+ [%W(#{@name} into 1+2), 'step', 3],
20
+ [%W(#{@name} over), 'next', 1]
21
+ ].each do |c, rtp, count|
22
+ @cmdproc.instance_variable_set('@return_to_program', false)
23
+ @my_cmd.run(c)
24
+ assert_equal(rtp, @cmdproc.instance_variable_get('@return_to_program'))
25
+ assert_equal(count, @cmdproc.instance_variable_get('@step_count'))
26
+ end
27
+ end
28
+
29
+ end
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- require 'test/unit'
3
2
  require 'rubygems'; require 'require_relative'
4
3
  require_relative 'cmd-helper'
5
4
  require_relative '../../processor/main' # Have to include before frame!
@@ -25,7 +25,12 @@ class TestCmdProcessorLocation < Test::Unit::TestCase
25
25
  def test_line_at
26
26
  @proc.settings[:directory] = ''
27
27
  assert_equal(nil, @proc.resolve_file_with_dir(@file))
28
- assert_equal(nil, @proc.line_at(@file, __LINE__))
28
+ if File.expand_path(Dir.pwd) == File.expand_path(File.dirname(__FILE__))
29
+ line = @proc.line_at(@file, __LINE__)
30
+ assert_match(/line = @proc.line_at/, line)
31
+ else
32
+ assert_equal(nil, @proc.line_at(@file, __LINE__))
33
+ end
29
34
  dir = @proc.settings[:directory] = File.dirname(__FILE__)
30
35
  assert_equal(File.join(dir, @file),
31
36
  @proc.resolve_file_with_dir('test-proc-location.rb'))
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- require 'test/unit'
3
2
  require 'rubygems'; require 'require_relative'
4
3
  require_relative 'cmd-helper'
5
4
  require_relative '../../processor/main'