ruby-debug 0.4.4-mswin32 → 0.4.5-mswin32

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.4.5
2
+ - Fixed debug_method when applied to setter.
3
+ - Added reload command which can be used to reload source code in case it's been changed.
4
+ - Added Debugger.reload_source_on_change option (true, by default) which controls whether ruby-debug should keep
5
+ track of the source files modification times and reload them if they've been changed.
6
+
1
7
  0.4.4
2
8
  - Renamed Context#set_suspend and Context#clear_suspend methods to Context#suspend and Context#resume respectively.
3
9
  - Context#resume method not only clears suspend flag, but also resumes the thread execution.
data/ext/ruby_debug.c CHANGED
@@ -4,7 +4,7 @@
4
4
  #include <rubysig.h>
5
5
  #include <st.h>
6
6
 
7
- #define DEBUG_VERSION "0.4.4"
7
+ #define DEBUG_VERSION "0.4.5"
8
8
 
9
9
  #define CTX_FL_MOVED (1<<1)
10
10
  #define CTX_FL_SUSPEND (1<<2)
data/lib/ruby-debug.rb CHANGED
@@ -5,11 +5,13 @@ require 'ruby_debug.so'
5
5
  require 'ruby-debug/processor'
6
6
 
7
7
  SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
8
+ SCRIPT_TIMESTAMPS__ = {} unless defined? SCRIPT_TIMESTAMPS__
8
9
 
9
10
  module Debugger
10
11
  PORT = 8989
11
12
 
12
13
  @processor = CommandProcessor.new
14
+ @reload_source_on_change = false
13
15
 
14
16
  class Context
15
17
  def interrupt
@@ -48,6 +50,9 @@ module Debugger
48
50
  # in remote mode, wait for the remote connection
49
51
  attr_accessor :wait_connection
50
52
 
53
+ # if <tt>true</tt>, checks the modification time of source files and reloads if it was modified
54
+ attr_accessor :reload_source_on_change
55
+
51
56
  attr_reader :thread, :control_thread
52
57
 
53
58
  #
@@ -164,12 +169,28 @@ module Debugger
164
169
  private :stop_main_thread
165
170
 
166
171
  def source_for(file) # :nodoc:
167
- if source = SCRIPT_LINES__[file]
168
- return source unless source == true
172
+ unless File.exists?(file)
173
+ return (source == true ? nil : source)
169
174
  end
170
- if File.exists?(file)
175
+
176
+ if SCRIPT_LINES__[file].nil? || SCRIPT_LINES__[file] == true
177
+ SCRIPT_LINES__[file] = File.readlines(file)
178
+ end
179
+
180
+ change_time = test(?M, file)
181
+ SCRIPT_TIMESTAMPS__[file] ||= change_time
182
+ if @reload_source_on_change && SCRIPT_TIMESTAMPS__[file] < change_time
171
183
  SCRIPT_LINES__[file] = File.readlines(file)
172
184
  end
185
+
186
+ SCRIPT_LINES__[file]
187
+ end
188
+
189
+ def source_reload
190
+ SCRIPT_LINES__.keys.each do |file|
191
+ next unless File.exists?(file)
192
+ SCRIPT_LINES__[file] = nil
193
+ end
173
194
  end
174
195
 
175
196
  def line_at(file, line) # :nodoc:
@@ -216,12 +237,14 @@ class Module
216
237
  # Wraps the +meth+ method with Debugger.start {...} block.
217
238
  #
218
239
  def debug_method(meth)
219
- alias_method "__debugee_#{meth}".to_sym, meth
240
+ old_meth = "__debugee_#{meth}"
241
+ old_meth = "#{$1}_set" if old_meth =~ /^(.+)=$/
242
+ alias_method old_meth.to_sym, meth
220
243
  class_eval <<-EOD
221
244
  def #{meth}(*args, &block)
222
245
  Debugger.start do
223
246
  debugger 2
224
- __debugee_#{meth}(*args, &block)
247
+ #{old_meth}(*args, &block)
225
248
  end
226
249
  end
227
250
  EOD
@@ -22,7 +22,7 @@ module Debugger
22
22
  def load_commands
23
23
  dir = File.dirname(__FILE__)
24
24
  Dir[File.join(dir, 'commands', '*')].each do |file|
25
- require file
25
+ require file if file =~ /\.rb$/
26
26
  end
27
27
  end
28
28
 
@@ -6,7 +6,7 @@ module Debugger
6
6
  end
7
7
 
8
8
  def regexp
9
- /^\s*(p|e(?:val)?)(?:\s+(on|off)|\s+)/
9
+ /^\s*(p|e(?:val)?)(?:\s+(on|off)$|\s+)/
10
10
  end
11
11
 
12
12
  def execute
@@ -73,4 +73,41 @@ module Debugger
73
73
  end
74
74
  end
75
75
  end
76
+
77
+ class ReloadCommand < Command # :nodoc
78
+ self.control = true
79
+
80
+ def regexp
81
+ /^\s*r(?:eload)?(?:\s*(on|off))?$/
82
+ end
83
+
84
+ def execute
85
+ if @match[1]
86
+ Debugger.reload_source_on_change = (@match[1] == 'on')
87
+ print "Automatic reloading is #{source_reloading}.\n"
88
+ else
89
+ Debugger.source_reload
90
+ print "Source code is reloaded. Automatic reloading is #{source_reloading}.\n"
91
+ end
92
+ end
93
+
94
+ private
95
+
96
+ def source_reloading
97
+ Debugger.reload_source_on_change ? 'on' : 'off'
98
+ end
99
+
100
+ class << self
101
+ def help_command
102
+ 'reload'
103
+ end
104
+
105
+ def help(cmd)
106
+ %{
107
+ r[eload]\tforces source code reloading
108
+ r[eload] on/off\tenales/disables automatic source code reloading
109
+ }
110
+ end
111
+ end
112
+ end
76
113
  end
@@ -118,6 +118,7 @@ module Debugger
118
118
  def initialize
119
119
  @frame_pos = 0
120
120
  @previous_line = nil
121
+ @proceed = false
121
122
  yield self
122
123
  end
123
124
 
data/lib/ruby_debug.so CHANGED
Binary file
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: ruby-debug
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.4.4
7
- date: 2006-10-15 18:27:41 -04:00
6
+ version: 0.4.5
7
+ date: 2006-12-04 15:26:06 -05:00
8
8
  summary: Fast Ruby debugger
9
9
  require_paths:
10
10
  - lib