ruby-debug 0.8.1 → 0.9

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,18 @@
1
+ 0.9
2
+ - Kernel#debugger method will start the debugger if it's not running.
3
+ - Added Context#stop_reason method.
4
+ - Calling a method with a block will create a new frame. This changes the behavior of 'next' command. So in order to step into a block, 'step' command must be used. That fixes bug #9629.
5
+ - Added the possibility to add a temporary context-specific breakpoint. Context#breakpoint and Context#set_breakpoint methods are added.
6
+ - 'cont' command now accepts a numerical parameter which implements 'Continue until line' behavior.
7
+ - Added new Context.frame_class method
8
+ - Added new 'framefullpath' setting.
9
+ - Added new 'frameclassname' setting.
10
+ - All Ruby's 'eval' and require/load methods create a new frame. Fixes bug #9686.
11
+
12
+ 0.8.1
13
+ - Added a shortcut module 'debugger'. require "ruby-debug/debugger" will start the debugger and stop at the next line (similar to require 'debug').
14
+ - Fixed remote debugging.
15
+
1
16
  0.8
2
17
  - Extract the base debugger API into a separate gem (ruby-debug-base), so it will be easier to add a new interface.
3
18
  - Added 'set autoirb' setting.
@@ -42,9 +42,15 @@ module Debugger
42
42
  def options
43
43
  @options ||= {}
44
44
  end
45
+
46
+ def setting(name)
47
+ class_variable_get("@@#{name}")
48
+ end
45
49
  end
46
50
 
47
51
  @@display_stack_trace = false
52
+ @@full_file_names = true
53
+ @@full_class_names = false
48
54
 
49
55
  def initialize(state)
50
56
  @state = state
@@ -57,7 +57,8 @@ module Debugger
57
57
 
58
58
  def help(cmd)
59
59
  %{
60
- b[reak] [file|class(:|.|#)]<line|method> [if expr] -
60
+ b[reak] file:line [if expr]
61
+ b[reak] class(.|#)method [if expr]
61
62
  \tset breakpoint to some position, (optionally) if expr == true
62
63
  }
63
64
  end
@@ -1,6 +1,27 @@
1
1
  module Debugger
2
+ module EvalFunctions
3
+ def run_with_binding
4
+ binding = @state.context ? get_binding : TOPLEVEL_BINDING
5
+ $__dbg_interface = @state.interface
6
+ eval(<<-EOC, binding)
7
+ def dbg_print(*args)
8
+ $__dbg_interface.print(*args)
9
+ end
10
+ def dbg_puts(*args)
11
+ $__dbg_interface.print(*args)
12
+ $__dbg_interface.print("\n")
13
+ end
14
+ EOC
15
+ yield binding
16
+ ensure
17
+ $__dbg_interface = nil
18
+ end
19
+ end
20
+
2
21
  class EvalCommand < Command # :nodoc:
3
22
  self.control = true
23
+
24
+ include EvalFunctions
4
25
 
5
26
  def match(input)
6
27
  @input = input
@@ -13,8 +34,9 @@ module Debugger
13
34
 
14
35
  def execute
15
36
  expr = @match ? @match.post_match : @input
16
- binding = @state.context ? get_binding : TOPLEVEL_BINDING
17
- print "%s\n", debug_eval(expr, binding).inspect
37
+ run_with_binding do |b|
38
+ print "%s\n", debug_eval(expr, b).inspect
39
+ end
18
40
  end
19
41
 
20
42
  class << self
@@ -39,14 +61,22 @@ module Debugger
39
61
  end
40
62
 
41
63
  class PPCommand < Command # :nodoc:
64
+ self.control = true
65
+
66
+ include EvalFunctions
67
+
42
68
  def regexp
43
69
  /^\s*pp\s+/
44
70
  end
45
71
 
46
72
  def execute
47
73
  out = StringIO.new
48
- PP.pp(debug_eval(@match.post_match), out) rescue out.puts $!.message
74
+ run_with_binding do |b|
75
+ PP.pp(debug_eval(@match.post_match, b), out)
76
+ end
49
77
  print out.string
78
+ rescue
79
+ out.puts $!.message
50
80
  end
51
81
 
52
82
  class << self
@@ -56,7 +86,7 @@ module Debugger
56
86
 
57
87
  def help(cmd)
58
88
  %{
59
- pp expression\tevaluate expression and print its value
89
+ pp expression\tevaluate expression and pretty-print its value
60
90
  }
61
91
  end
62
92
  end
@@ -39,8 +39,28 @@ module Debugger
39
39
  end
40
40
 
41
41
  def print_frame(pos, adjust = false)
42
- file, line, id = @state.context.frame_file(pos), @state.context.frame_line(pos), @state.context.frame_id(pos)
43
- print "#%d %s:%d%s\n", pos, file, line, id ? " in `#{id.id2name}'" : ""
42
+ file = @state.context.frame_file(pos)
43
+ line = @state.context.frame_line(pos)
44
+ id = @state.context.frame_method(pos)
45
+ klass = @state.context.frame_class(pos)
46
+
47
+ method = ""
48
+ if id
49
+ method << " in '"
50
+ method << "#{klass}." if Command.setting('full_class_names') && klass
51
+ method << id.id2name
52
+ method << "'"
53
+ end
54
+
55
+ unless Command.setting('full_file_names')
56
+ path_components = file.split(/[\\\/]/)
57
+ if path_components.size > 3
58
+ path_components[0...-3] = '...'
59
+ file = path_components.join(File::ALT_SEPARATOR || File::SEPARATOR)
60
+ end
61
+ end
62
+
63
+ print "#%d %s:%d%s\n", pos, file, line, method
44
64
  print "\032\032%s:%d\n", file, line if ENV['EMACS'] && adjust
45
65
  end
46
66
  end
@@ -7,12 +7,13 @@ module Debugger
7
7
  end
8
8
 
9
9
  def execute
10
- print "ruby-debug help v.#{Debugger::VERSION}\n"
10
+ print "ruby-debug help v#{Debugger::VERSION}\n"
11
11
  cmds = @state.commands.select{ |cmd| [cmd.help_command].flatten.include?(@match[1]) }
12
12
  unless cmds.empty?
13
13
  help = cmds.map{ |cmd| cmd.help(@match[1]) }.join
14
14
  print help.split("\n").reject{|l| l =~ /^\s*$/ }.map{|l| l.gsub(/^ +/, '')}.join("\n")
15
15
  else
16
+ print "Type 'help <command-name>' for help on a specific command\n\n"
16
17
  print "Available commands:\n"
17
18
  cmds = @state.commands.map{ |cmd| cmd.help_command }
18
19
  cmds = cmds.flatten.uniq.sort
@@ -16,7 +16,13 @@ module Debugger
16
16
  print "autoeval is #{$1.nil? ? 'on' : 'off'}.\n"
17
17
  when /^(no)?trace$/
18
18
  @@display_stack_trace = $1.nil?
19
- print "Display stack trace is #{$1.nil? ? 'on' : 'off'}.\n"
19
+ print "Displaying stack trace is #{$1.nil? ? 'on' : 'off'}.\n"
20
+ when /^(no)?framefullpath$/
21
+ @@full_file_names = $1.nil?
22
+ print "Displaying frame's full file names is #{$1.nil? ? 'on' : 'off'}.\n"
23
+ when /^(no)?frameclassname$/
24
+ @@full_class_names = $1.nil?
25
+ print "Displaying frame's original class name is #{$1.nil? ? 'on' : 'off'}.\n"
20
26
  when /^(no)?autoreload$/
21
27
  Debugger.reload_source_on_change = $1.nil?
22
28
  print "autoreload is #{$1.nil? ? 'on' : 'off'}.\n"
@@ -36,11 +42,13 @@ module Debugger
36
42
  def help(cmd)
37
43
  %{
38
44
  set <setting>, where <setting>:
39
- autolist - execute 'list' command on every breakpoint
40
- autoeval - evaluate every unrecognized command
41
- autoreload - enables automatic source code reloading
42
- autoirb - debugger invokes IRB on every stop
43
- trace - display stack trace when 'eval' raises exception
45
+ autolist - execute 'list' command on every breakpoint
46
+ autoeval - evaluate every unrecognized command
47
+ autoreload - enables automatic source code reloading
48
+ autoirb - debugger invokes IRB on every stop
49
+ trace - display stack trace when 'eval' raises exception
50
+ framefullpath - frame will display full file names
51
+ frameclassname - frame will display class names
44
52
  To disable setting, use 'no' prefix, like 'noautolist'
45
53
  }
46
54
  end
@@ -19,7 +19,7 @@ module Debugger
19
19
 
20
20
  def help(cmd)
21
21
  %{
22
- n[ext][ nnn]\tgo over one line or till line nnn
22
+ n[ext][ nnn]\tstep over once or nnn times
23
23
  }
24
24
  end
25
25
  end
@@ -44,7 +44,7 @@ module Debugger
44
44
 
45
45
  def help(cmd)
46
46
  %{
47
- s[tep][ nnn]\tstep (into methods) one line or till line nnn
47
+ s[tep][ nnn]\tstep (into methods) once or nnn times
48
48
  }
49
49
  end
50
50
  end
@@ -82,10 +82,14 @@ module Debugger
82
82
 
83
83
  class ContinueCommand < Command # :nodoc:
84
84
  def regexp
85
- /^\s*c(?:ont)?$/
85
+ /^\s*c(?:ont)?(?:\s+(\d+))?$/
86
86
  end
87
87
 
88
88
  def execute
89
+ if @match[1] && !@state.context.dead?
90
+ file = File.expand_path(@state.file)
91
+ @state.context.set_breakpoint(file, @match[1].to_i)
92
+ end
89
93
  @state.proceed
90
94
  end
91
95
 
@@ -96,7 +100,7 @@ module Debugger
96
100
 
97
101
  def help(cmd)
98
102
  %{
99
- c[ont]\trun until program ends or hit breakpoint
103
+ c[ont][ nnn]\trun until program ends or hits breakpoint or reaches line nnn
100
104
  }
101
105
  end
102
106
  end
@@ -34,7 +34,7 @@ module Debugger
34
34
  Readline::HISTORY.to_a.last(500).each do |line|
35
35
  file.puts line unless line.strip.empty?
36
36
  end
37
- end rescue nil
37
+ end rescue nil
38
38
  end
39
39
  public :save_history
40
40
  end
@@ -205,7 +205,8 @@ module Debugger
205
205
  end
206
206
 
207
207
  class State # :nodoc:
208
- attr_reader :commands
208
+ attr_reader :commands, :interface
209
+
209
210
  def initialize(interface, commands)
210
211
  @interface = interface
211
212
  @commands = commands
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: ruby-debug
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.8.1
7
- date: 2007-03-19 03:56:11 -04:00
6
+ version: "0.9"
7
+ date: 2007-04-01 13:18:02 -04:00
8
8
  summary: Command line interface (CLI) for ruby-debug-base
9
9
  require_paths:
10
10
  - cli
@@ -78,5 +78,5 @@ dependencies:
78
78
  requirements:
79
79
  - - "="
80
80
  - !ruby/object:Gem::Version
81
- version: 0.8.1
81
+ version: "0.9"
82
82
  version: