| |   |
| 11 | 11 | |
| 12 | 12 | d = RubyAMP::RemoteDebugger.new |
| 13 | 13 | |
| 14 | | count_breakpoints = d.evaluate("Debugger.breakpoints.length", :control) |
| 14 | count_breakpoints = d.breakpoint.list.length |
| 15 | 15 | if count_breakpoints == 0 |
| 16 | 16 | puts "There are no breakpoints set" |
| 17 | 17 | exit |
| 18 | 18 | end |
| 19 | 19 | |
| 20 | | d.evaluate("Debugger.breakpoints.map{ |b| b.id }.each { |b_id| Debugger.remove_breakpoint(b_id) }", :control) |
| 20 | count_deleted = d.breakpoint.delete_all |
| 21 | 21 | |
| 22 | | new_count_breakpoints = d.evaluate("Debugger.breakpoints.length", :control) |
| 23 | | if new_count_breakpoints == 0 |
| 24 | | puts "Deleted all #{count_breakpoints} breakpoint(s)" |
| 22 | if count_deleted == count_breakpoints |
| 23 | puts "Deleted all #{count_deleted} breakpoint(s)" |
| 25 | 24 | else |
| 26 | 25 | puts "Error deleting breakpoints." |
| 27 | 26 | end</string> |
| toggle raw diff |
--- a/Commands/Debug - Delete All Breakpoints.tmCommand
+++ b/Commands/Debug - Delete All Breakpoints.tmCommand
@@ -11,17 +11,16 @@ require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/ruby_amp.rb"
d = RubyAMP::RemoteDebugger.new
-count_breakpoints = d.evaluate("Debugger.breakpoints.length", :control)
+count_breakpoints = d.breakpoint.list.length
if count_breakpoints == 0
puts "There are no breakpoints set"
exit
end
-d.evaluate("Debugger.breakpoints.map{ |b| b.id }.each { |b_id| Debugger.remove_breakpoint(b_id) }", :control)
+count_deleted = d.breakpoint.delete_all
-new_count_breakpoints = d.evaluate("Debugger.breakpoints.length", :control)
-if new_count_breakpoints == 0
- puts "Deleted all #{count_breakpoints} breakpoint(s)"
+if count_deleted == count_breakpoints
+ puts "Deleted all #{count_deleted} breakpoint(s)"
else
puts "Error deleting breakpoints."
end</string> |
| |   |
| 12 | 12 | d = RubyAMP::RemoteDebugger.new |
| 13 | 13 | exit unless d.connected? |
| 14 | 14 | |
| 15 | | result = d.evaluate <<-EOF, :control |
| 16 | | bp = Debugger.add_breakpoint #{ENV['TM_FILEPATH'].to_s.inspect}, #{ENV['TM_LINE_NUMBER']} |
| 17 | | if bp |
| 18 | | "Set breakpoint at \#{bp.source}:\#{bp.pos}" |
| 19 | | else |
| 20 | | "Failed to set breakpoint." |
| 21 | | end |
| 22 | | EOF |
| 15 | source = ENV['TM_FILEPATH'] |
| 16 | line = ENV['TM_LINE_NUMBER'] |
| 23 | 17 | |
| 24 | | puts result |
| 25 | | </string> |
| 18 | if d.breakpoint.add(source, line) |
| 19 | puts "Set breakpoint at #{source}:#{line}" |
| 20 | else |
| 21 | puts "Failed to set breakpoint." |
| 22 | end</string> |
| 26 | 23 | <key>fallbackInput</key> |
| 27 | 24 | <string>line</string> |
| 28 | 25 | <key>input</key> |
| toggle raw diff |
--- a/Commands/Debug - Set Breakpoint at Current Line.tmCommand
+++ b/Commands/Debug - Set Breakpoint at Current Line.tmCommand
@@ -12,17 +12,14 @@ require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/ruby_amp.rb"
d = RubyAMP::RemoteDebugger.new
exit unless d.connected?
-result = d.evaluate <<-EOF, :control
- bp = Debugger.add_breakpoint #{ENV['TM_FILEPATH'].to_s.inspect}, #{ENV['TM_LINE_NUMBER']}
- if bp
- "Set breakpoint at \#{bp.source}:\#{bp.pos}"
- else
- "Failed to set breakpoint."
- end
-EOF
+source = ENV['TM_FILEPATH']
+line = ENV['TM_LINE_NUMBER']
-puts result
-</string>
+if d.breakpoint.add(source, line)
+ puts "Set breakpoint at #{source}:#{line}"
+else
+ puts "Failed to set breakpoint."
+end</string>
<key>fallbackInput</key>
<string>line</string>
<key>input</key> |
| |   |
| 16 | 16 | require "#{ENV['TM_SUPPORT_PATH']}/lib/ui.rb" |
| 17 | 17 | |
| 18 | 18 | d = RubyAMP::RemoteDebugger.new |
| 19 | | breakpoints = d.evaluate("Debugger.breakpoints.map{|b| {:source => b.source, :line => b.pos} }", :control) |
| 19 | breakpoints = d.breakpoint.list |
| 20 | 20 | |
| 21 | 21 | if breakpoints.empty? |
| 22 | 22 | puts "No breakpoints" |
| 23 | 23 | exit_show_tool_tip |
| 24 | 24 | end |
| 25 | 25 | |
| 26 | | b_index = TextMate::UI.menu(breakpoints.map{|b| "#{b[:source]}:#{b[:line]}"}) |
| 26 | b_index = TextMate::UI.menu(breakpoints.map{|b| "#{b.source}:#{b.line}"}) |
| 27 | 27 | |
| 28 | 28 | exit_discard if b_index.nil? |
| 29 | 29 | |
| 30 | 30 | breakpoint = breakpoints[b_index] |
| 31 | | tm_open(breakpoint[:source], :line => breakpoint[:line])</string> |
| 31 | tm_open(breakpoint.source, :line => breakpoint.line)</string> |
| 32 | 32 | <key>input</key> |
| 33 | 33 | <string>none</string> |
| 34 | 34 | <key>keyEquivalent</key> |
| toggle raw diff |
--- a/Commands/Debug - Show Breakpoints Menu.tmCommand
+++ b/Commands/Debug - Show Breakpoints Menu.tmCommand
@@ -16,19 +16,19 @@ require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/ruby_tm_helpers.rb"
require "#{ENV['TM_SUPPORT_PATH']}/lib/ui.rb"
d = RubyAMP::RemoteDebugger.new
-breakpoints = d.evaluate("Debugger.breakpoints.map{|b| {:source => b.source, :line => b.pos} }", :control)
+breakpoints = d.breakpoint.list
if breakpoints.empty?
puts "No breakpoints"
exit_show_tool_tip
end
-b_index = TextMate::UI.menu(breakpoints.map{|b| "#{b[:source]}:#{b[:line]}"})
+b_index = TextMate::UI.menu(breakpoints.map{|b| "#{b.source}:#{b.line}"})
exit_discard if b_index.nil?
breakpoint = breakpoints[b_index]
-tm_open(breakpoint[:source], :line => breakpoint[:line])</string>
+tm_open(breakpoint.source, :line => breakpoint.line)</string>
<key>input</key>
<string>none</string>
<key>keyEquivalent</key> |
| |   |
| 116 | 116 | raw_evaluate(expression) |
| 117 | 117 | end |
| 118 | 118 | end |
| 119 | |
| 120 | AUTO_LOAD = { |
| 121 | :BreakpointCommander => 'breakpoint_commander.rb', |
| 122 | :CommanderBase => 'commander_base.rb', |
| 123 | } |
| 124 | |
| 125 | def self.const_missing(name) |
| 126 | @looked_for ||= {} |
| 127 | raise "Class not found: #{name}" if @looked_for[name] |
| 128 | |
| 129 | return super unless AUTO_LOAD[name] |
| 130 | @looked_for[name] = true |
| 131 | |
| 132 | require File.join(RUBYAMP_ROOT, "remote_debugger", AUTO_LOAD[name]) |
| 133 | const_get(name) |
| 134 | end |
| 135 | |
| 136 | def breakpoint |
| 137 | @breakpoint ||= BreakpointCommander.new(self) |
| 138 | end |
| 119 | 139 | end |
| 120 | 140 | end |
| 121 | 141 | |
| toggle raw diff |
--- a/Support/lib/ruby_amp/remote_debugger.rb
+++ b/Support/lib/ruby_amp/remote_debugger.rb
@@ -116,6 +116,26 @@ module RubyAMP
raw_evaluate(expression)
end
end
+
+ AUTO_LOAD = {
+ :BreakpointCommander => 'breakpoint_commander.rb',
+ :CommanderBase => 'commander_base.rb',
+ }
+
+ def self.const_missing(name)
+ @looked_for ||= {}
+ raise "Class not found: #{name}" if @looked_for[name]
+
+ return super unless AUTO_LOAD[name]
+ @looked_for[name] = true
+
+ require File.join(RUBYAMP_ROOT, "remote_debugger", AUTO_LOAD[name])
+ const_get(name)
+ end
+
+ def breakpoint
+ @breakpoint ||= BreakpointCommander.new(self)
+ end
end
end
|
| |   |
| 1 | module RubyAMP |
| 2 | class RemoteDebugger |
| 3 | class BreakpointCommander < CommanderBase |
| 4 | def list |
| 5 | base.evaluate("Debugger.breakpoints.map{|b| {:id => b.id, :source => b.source, :line => b.pos} }", :control).map do |bp_options| |
| 6 | Breakpoint.new(base, self, bp_options) |
| 7 | end |
| 8 | end |
| 9 | |
| 10 | def delete_all |
| 11 | base.evaluate <<-EOF, :control |
| 12 | breakpoint_ids = Debugger.breakpoints.map { |b| b.id } |
| 13 | begin |
| 14 | breakpoint_ids.each { |b_id| Debugger.remove_breakpoint(b_id) } |
| 15 | breakpoint_ids.length |
| 16 | rescue |
| 17 | 0 |
| 18 | end |
| 19 | EOF |
| 20 | end |
| 21 | |
| 22 | def add(source, line) |
| 23 | base.evaluate <<-EOF, :control |
| 24 | bp = Debugger.add_breakpoint #{ENV['TM_FILEPATH'].to_s.inspect}, #{ENV['TM_LINE_NUMBER']} |
| 25 | bp ? true : false |
| 26 | EOF |
| 27 | end |
| 28 | end |
| 29 | |
| 30 | class Breakpoint |
| 31 | attr_accessor :source, :line, :id |
| 32 | |
| 33 | def initialize(base, parent, options = {}) |
| 34 | self.id = options[:id] |
| 35 | self.source = options[:source] |
| 36 | self.line = options[:line] |
| 37 | end |
| 38 | end |
| 39 | end |
| 40 | end |
| toggle raw diff |
--- /dev/null
+++ b/Support/lib/ruby_amp/remote_debugger/breakpoint_commander.rb
@@ -0,0 +1,40 @@
+module RubyAMP
+ class RemoteDebugger
+ class BreakpointCommander < CommanderBase
+ def list
+ base.evaluate("Debugger.breakpoints.map{|b| {:id => b.id, :source => b.source, :line => b.pos} }", :control).map do |bp_options|
+ Breakpoint.new(base, self, bp_options)
+ end
+ end
+
+ def delete_all
+ base.evaluate <<-EOF, :control
+ breakpoint_ids = Debugger.breakpoints.map { |b| b.id }
+ begin
+ breakpoint_ids.each { |b_id| Debugger.remove_breakpoint(b_id) }
+ breakpoint_ids.length
+ rescue
+ 0
+ end
+ EOF
+ end
+
+ def add(source, line)
+ base.evaluate <<-EOF, :control
+ bp = Debugger.add_breakpoint #{ENV['TM_FILEPATH'].to_s.inspect}, #{ENV['TM_LINE_NUMBER']}
+ bp ? true : false
+ EOF
+ end
+ end
+
+ class Breakpoint
+ attr_accessor :source, :line, :id
+
+ def initialize(base, parent, options = {})
+ self.id = options[:id]
+ self.source = options[:source]
+ self.line = options[:line]
+ end
+ end
+ end
+end
\ No newline at end of file |