ruby-debug 0.9.2 → 0.9.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,9 @@
1
+ 0.9.3
2
+ - Fixed if..elsif..end stepping.
3
+ - From irb session Ctrl-C or 'cont' command continues execution without showing the debugger prompt.
4
+ - Added Debugger.settings method to programatically modify command settings.
5
+ - Added Kernel#breakpoint as alias to Kernel#debugger is the former is not already defined.
6
+
1
7
  0.9.2
2
8
  - Fixed file comparison in Windows platform.
3
9
  - Added setter methods to Breakpoint properties
data/bin/rdebug CHANGED
@@ -8,9 +8,11 @@ require 'ruby-debug'
8
8
  options = OpenStruct.new(
9
9
  'server' => false,
10
10
  'client' => false,
11
+ 'debug_module'=> 'debug',
11
12
  'host' => nil,
12
13
  'port' => Debugger::PORT,
13
14
  'cport' => Debugger::PORT + 1,
15
+ 'control' => true,
14
16
  'wait' => false,
15
17
  'nostop' => false,
16
18
  'post_mortem' => false,
@@ -32,6 +34,7 @@ EOB
32
34
  opts.on("-h", "--host HOST", "Host name used for remote debugging") {|options.host|}
33
35
  opts.on("-p", "--port PORT", Integer, "Port used for remote debugging") {|options.port|}
34
36
  opts.on("--cport PORT", Integer, "Port used for contol commands") {|options.cport|}
37
+ opts.on("--no-control", "Do not automatically start control thread") {options.control = false}
35
38
  opts.on("-x", "--trace", "turn on line tracing") {options.tracing = true}
36
39
  opts.on("-n", "--nostop", "Do not stop when stript is loaded") {options.nostop = true}
37
40
  opts.on("-m", "--post-mortem", "Activate post-mortem mode") {options.post_mortem = true}
@@ -44,6 +47,13 @@ EOB
44
47
  exit
45
48
  end
46
49
  end
50
+ opts.on("-r", "--require debug", String,
51
+ "Compatibility with Ruby-distributed debug module") do |options.debug_module|
52
+ if options.debug_module != 'debug'
53
+ puts "Use '-r' option only with 'debug' (You supplied '#{options.debug_module}'). " +
54
+ "This option is ignored."
55
+ end
56
+ end
47
57
  opts.on("--keep-frame-binding", "Keep frame bindings") {options.frame_bind = true}
48
58
  opts.on("--emacs", "Activates emacs mode") {ENV['EMACS'] = '1'}
49
59
  opts.separator ""
@@ -110,7 +120,7 @@ else
110
120
  # activate debugger
111
121
  Debugger.start
112
122
  # start control thread
113
- Debugger.start_control(options.host, options.cport)
123
+ Debugger.start_control(options.host, options.cport) if options.control
114
124
 
115
125
  # load initrc script
116
126
  load_initrc.call
data/cli/ruby-debug.rb CHANGED
@@ -64,7 +64,7 @@ module Debugger
64
64
  end
65
65
  alias start_server start_remote
66
66
 
67
- def start_control(host = nil, ctrl_port = PORT + 1)
67
+ def start_control(host = nil, ctrl_port = PORT + 1) # :nodoc:
68
68
  raise "Debugger is not started" unless started?
69
69
  return if @control_thread
70
70
  @control_thread = DebugThread.new do
@@ -42,16 +42,50 @@ module Debugger
42
42
  def options
43
43
  @options ||= {}
44
44
  end
45
+
46
+ def settings_map
47
+ @@settings_map ||= {}
48
+ end
49
+ private :settings_map
45
50
 
46
- def setting(name)
47
- class_variable_get("@@#{name}")
51
+ def settings
52
+ unless @settings
53
+ @settings = Object.new
54
+ map = settings_map
55
+ class << @settings; self end.send(:define_method, :[]) do |name|
56
+ raise "No such setting #{name}" unless map.has_key?(name)
57
+ map[name][:getter].call
58
+ end
59
+ class << @settings; self end.send(:define_method, :[]=) do |name, value|
60
+ raise "No such setting #{name}" unless map.has_key?(name)
61
+ map[name][:setter].call(value)
62
+ end
63
+ end
64
+ @settings
65
+ end
66
+
67
+ def register_setting_var(name, default)
68
+ var_name = "@@#{name}"
69
+ class_variable_set(var_name, default)
70
+ register_setting_get(name) { class_variable_get(var_name) }
71
+ register_setting_set(name) { |value| class_variable_set(var_name, value) }
72
+ end
73
+
74
+ def register_setting_get(name, &block)
75
+ settings_map[name] ||= {}
76
+ settings_map[name][:getter] = block
77
+ end
78
+
79
+ def register_setting_set(name, &block)
80
+ settings_map[name] ||= {}
81
+ settings_map[name][:setter] = block
48
82
  end
49
83
  end
50
84
 
51
- @@display_stack_trace = false
52
- @@full_file_names = true
53
- @@full_class_names = false
54
- @@force_stepping = false
85
+ register_setting_var(:stack_trace_on_error, false)
86
+ register_setting_var(:frame_full_path, true)
87
+ register_setting_var(:frame_class_names, false)
88
+ register_setting_var(:force_stepping, false)
55
89
 
56
90
  def initialize(state)
57
91
  @state = state
@@ -75,7 +109,7 @@ module Debugger
75
109
  begin
76
110
  val = eval(str, b)
77
111
  rescue StandardError, ScriptError => e
78
- if @@display_stack_trace
112
+ if Command.settings[:stack_trace_on_error]
79
113
  at = eval("caller(1)", b)
80
114
  print "%s:%s\n", at.shift, e.to_s.sub(/\(eval\):1:(in `.*?':)?/, '')
81
115
  for i in at
@@ -110,4 +144,21 @@ module Debugger
110
144
  end
111
145
 
112
146
  Command.load_commands
147
+
148
+ # Returns setting object.
149
+ # Use Debugger.settings[] and Debugger.settings[]= methods to query and set
150
+ # debugger settings. These settings are available:
151
+ #
152
+ # - :autolist - automatically calls 'list' command on breakpoint
153
+ # - :autoeval - evaluates input in the current binding if it's not recognized as a debugger command
154
+ # - :autoirb - automatically calls 'irb' command on breakpoint
155
+ # - :stack_trace_on_error - shows full stack trace if eval command results with an exception
156
+ # - :frame_full_path - displays full paths when showing frame stack
157
+ # - :frame_class_names - displays method's class name when showing frame stack
158
+ # - :reload_source_on_change - makes 'list' command to always display up-to-date source code
159
+ # - :force_stepping - stepping command asways move to the new line
160
+ #
161
+ def self.settings
162
+ Command.settings
163
+ end
113
164
  end
@@ -1,5 +1,5 @@
1
1
  module Debugger
2
- module EvalFunctions
2
+ module EvalFunctions # :nodoc:
3
3
  def run_with_binding
4
4
  binding = @state.context ? get_binding : TOPLEVEL_BINDING
5
5
  $__dbg_interface = @state.interface
@@ -23,6 +23,13 @@ module Debugger
23
23
 
24
24
  include EvalFunctions
25
25
 
26
+ register_setting_get(:autoeval) do
27
+ EvalCommand.unknown
28
+ end
29
+ register_setting_set(:autoeval) do |value|
30
+ EvalCommand.unknown = value
31
+ end
32
+
26
33
  def match(input)
27
34
  @input = input
28
35
  super
@@ -47,12 +47,12 @@ module Debugger
47
47
  method = ""
48
48
  if id
49
49
  method << " in '"
50
- method << "#{klass}." if Command.setting('full_class_names') && klass
50
+ method << "#{klass}." if Command.settings[:frame_class_names] && klass
51
51
  method << id.id2name
52
52
  method << "'"
53
53
  end
54
54
 
55
- unless Command.setting('full_file_names')
55
+ unless Command.settings[:frame_full_path]
56
56
  path_components = file.split(/[\\\/]/)
57
57
  if path_components.size > 3
58
58
  path_components[0...-3] = '...'
@@ -1,5 +1,15 @@
1
1
  require 'irb'
2
+
2
3
  module IRB # :nodoc:
4
+ module ExtendCommand # :nodoc:
5
+ class Continue # :nodoc:
6
+ def self.execute(conf)
7
+ throw :IRB_EXIT, :cont
8
+ end
9
+ end
10
+ end
11
+ ExtendCommandBundle.def_extend_command "cont", :Continue
12
+
3
13
  def self.start_session(binding)
4
14
  unless @__initialized
5
15
  args = ARGV
@@ -16,10 +26,6 @@ module IRB # :nodoc:
16
26
  @CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
17
27
  @CONF[:MAIN_CONTEXT] = irb.context
18
28
 
19
- # trap("SIGINT") do
20
- # irb.signal_handle
21
- # end
22
-
23
29
  catch(:IRB_EXIT) do
24
30
  irb.eval_input
25
31
  end
@@ -28,6 +34,14 @@ end
28
34
 
29
35
  module Debugger
30
36
  class IRBCommand < Command # :nodoc:
37
+
38
+ register_setting_get(:autoirb) do
39
+ IRBCommand.always_run
40
+ end
41
+ register_setting_set(:autoirb) do |value|
42
+ IRBCommand.always_run = value
43
+ end
44
+
31
45
  def regexp
32
46
  /^irb$/
33
47
  end
@@ -37,7 +51,17 @@ module Debugger
37
51
  print "Command is available only in local mode.\n"
38
52
  throw :debug_error
39
53
  end
40
- IRB.start_session(get_binding)
54
+
55
+ save_trap = trap("SIGINT") do
56
+ throw :IRB_EXIT, :cont if $debug_in_irb
57
+ end
58
+
59
+ $debug_in_irb = true
60
+ cont = IRB.start_session(get_binding)
61
+ @state.proceed if cont == :cont
62
+ ensure
63
+ $debug_in_irb = false
64
+ trap("SIGINT", save_trap) if save_trap
41
65
  end
42
66
 
43
67
  class << self
@@ -1,5 +1,13 @@
1
1
  module Debugger
2
2
  class ListCommand < Command # :nodoc:
3
+
4
+ register_setting_get(:autolist) do
5
+ ListCommand.always_run
6
+ end
7
+ register_setting_set(:autolist) do |value|
8
+ ListCommand.always_run = value
9
+ end
10
+
3
11
  def regexp
4
12
  /^\s*l(?:ist)?(?:\s*([-=])|\s+(.+))?$/
5
13
  end
@@ -68,6 +76,13 @@ module Debugger
68
76
 
69
77
  class ReloadCommand < Command # :nodoc:
70
78
  self.control = true
79
+
80
+ register_setting_get(:reload_source_on_change) do
81
+ Debugger.reload_source_on_change
82
+ end
83
+ register_setting_set(:reload_source_on_change) do |value|
84
+ Debugger.reload_source_on_change = value
85
+ end
71
86
 
72
87
  def regexp
73
88
  /^\s*r(?:eload)?$/
@@ -9,28 +9,28 @@ module Debugger
9
9
  def execute
10
10
  case @match[1]
11
11
  when /^(no)?autolist$/
12
- ListCommand.always_run = $1.nil?
12
+ Command.settings[:autolist] = $1.nil?
13
13
  print "autolist is #{$1.nil? ? 'on' : 'off'}.\n"
14
14
  when /^(no)?autoeval$/
15
- EvalCommand.unknown = $1.nil?
15
+ Command.settings[:autoeval] = $1.nil?
16
16
  print "autoeval is #{$1.nil? ? 'on' : 'off'}.\n"
17
17
  when /^(no)?trace$/
18
- @@display_stack_trace = $1.nil?
18
+ Command.settings[:stack_trace_on_error] = $1.nil?
19
19
  print "Displaying stack trace is #{$1.nil? ? 'on' : 'off'}.\n"
20
20
  when /^(no)?framefullpath$/
21
- @@full_file_names = $1.nil?
21
+ Command.settings[:frame_full_path] = $1.nil?
22
22
  print "Displaying frame's full file names is #{$1.nil? ? 'on' : 'off'}.\n"
23
23
  when /^(no)?frameclassname$/
24
- @@full_class_names = $1.nil?
24
+ Command.settings[:frame_class_names] = $1.nil?
25
25
  print "Displaying frame's original class name is #{$1.nil? ? 'on' : 'off'}.\n"
26
26
  when /^(no)?autoreload$/
27
- Debugger.reload_source_on_change = $1.nil?
27
+ Command.settings[:reload_source_on_change] = $1.nil?
28
28
  print "autoreload is #{$1.nil? ? 'on' : 'off'}.\n"
29
29
  when /^(no)?autoirb$/
30
- IRBCommand.always_run = $1.nil?
30
+ Command.settings[:autoirb] = $1.nil?
31
31
  print "autoirb is #{$1.nil? ? 'on' : 'off'}.\n"
32
32
  when /^(no)?forcestep$/
33
- @@force_stepping = $1.nil?
33
+ self.class.settings[:force_stepping] = $1.nil?
34
34
  print "force-stepping is #{$1.nil? ? 'on' : 'off'}.\n"
35
35
  else
36
36
  print "Unknown setting.\n"
@@ -7,7 +7,7 @@ module Debugger
7
7
  end
8
8
 
9
9
  def execute
10
- force = @match[1] == '+' || (@match[1].nil? && @@force_stepping)
10
+ force = @match[1] == '+' || (@match[1].nil? && Command.settings[:force_stepping])
11
11
  steps = @match[2] ? @match[2].to_i : 1
12
12
  @state.context.step_over steps, @state.frame_pos, force
13
13
  @state.proceed
@@ -35,7 +35,7 @@ module Debugger
35
35
  end
36
36
 
37
37
  def execute
38
- force = @match[1] == '+' || (@match[1].nil? && @@force_stepping)
38
+ force = @match[1] == '+' || (@match[1].nil? && Command.settings[:force_stepping])
39
39
  steps = @match[2] ? @match[2].to_i : 1
40
40
  @state.context.step(steps, force)
41
41
  @state.proceed
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.9.2
7
- date: 2007-04-04 16:19:46 -04:00
6
+ version: 0.9.3
7
+ date: 2007-04-27 20:32:40 -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.9.2
81
+ version: 0.9.3
82
82
  version: