Commit 48d393e79d41c1bb5a181b5b0d7f17508e0831a3

much improved error handling of remote-evaluation. Errors are trapped on the remote side to prevent them from taking down your debugger.

Commit diff

Commands/Debug - Copy inspection to clipboard as YAML.tmCommand

 
1212exit unless d.connected?
1313
1414what = RubyAMP::Inspect.get_selection
15RubyAMP::Inspect.copy_to_clipboard(d.inspect(what, :yaml))
15RubyAMP::Inspect.copy_to_clipboard(d.evaluate(what, :current, :yaml))
1616puts "Copied value of #{what} to clipboard"</string>
1717 <key>input</key>
1818 <string>document</string>
toggle raw diff

Commands/Debug - Copy inspection to clipboard as pretty print.tmCommand

 
1212exit unless d.connected?
1313
1414what = RubyAMP::Inspect.get_selection
15RubyAMP::Inspect.copy_to_clipboard(d.inspect(what, :pp))
15RubyAMP::Inspect.copy_to_clipboard(d.evaluate(what, :current, :pp))
1616puts "Copied value of #{what} to clipboard"</string>
1717 <key>input</key>
1818 <string>document</string>
toggle raw diff

Commands/Debug - Copy inspection to clipboard as string.tmCommand

 
1212exit unless d.connected?
1313
1414what = RubyAMP::Inspect.get_selection
15RubyAMP::Inspect.copy_to_clipboard(d.inspect(what, :string))
15RubyAMP::Inspect.copy_to_clipboard(d.evaluate(what, :current, :string))
1616puts "Copied value of #{what} to clipboard"</string>
1717 <key>input</key>
1818 <string>document</string>
toggle raw diff

Commands/Debug - Inspect with pretty print.tmCommand

 
1313
1414what = RubyAMP::Inspect.get_selection
1515
16puts "#{what} = \n#{d.inspect(what, :pp)}"
16puts "#{what} = \n#{d.evaluate(what, :current, :pp)}"
1717</string>
1818 <key>fallbackInput</key>
1919 <string>word</string>
toggle raw diff

Support/ext/debugger_extension.rb

 
1616 eval(cmd, current_binding)
1717 end
1818
19 def evaluate(cmd, binding = :current, format = :raw)
20 result = Kernel.eval(cmd, (binding == :current) ? current_binding : Kernel.binding)
21 case format
22 when :pp
23 require('pp')
24 ::PP.pp(result, output='')
25 output
26 when :yaml
27 require('yaml')
28 result.to_yaml
29 when :string
30 result.to_s
31 when :raw
32 result
33 end
34 rescue Exception => e
35 "Error inspecting #{cmd} - #{e.inspect}"
36 end
37
1938 def wait_for_connection
2039 while Debugger.handler.interface.nil?; sleep 0.10; end
2140 end
toggle raw diff

Support/lib/ruby_amp/remote_debugger.rb

 
8585 read_output
8686 end
8787
88 def raw_evaluate(cmd, binding = :current)
89 case binding
90 when :current
91 command("e Debugger.eval_from_current_binding(#{cmd.inspect})")
92 when :control
93 command("e send(:eval, #{cmd.inspect})")
94 end
95 end
96
97 def evaluate(cmd, binding = :current)
98 o = raw_evaluate(cmd, binding)
99 return o if o.nil? || (line = o.split("\n").first).nil? || line.match(/^[a-z:]+ *Exception: /i)
88 def evaluate(cmd, binding = :current, format = :raw)
89 o = command("e Debugger.evaluate(#{cmd.inspect}, :#{binding}, :#{format})")
10090 eval(o)
91 rescue Exception
92 o
10193 end
10294
10395 def current_frame
9797 end
9898
9999 def inspect(expression, format = :pp)
100 case format
101 when :pp
102 evaluate("::Object.require('pp'); ::Object::PP.pp((#{expression}), __tmp_output__=''); __tmp_output__")
103 when :yaml
104 evaluate("::Object.require 'yaml'; (#{expression}).to_yaml")
105 when :string
106 evaluate("#{expression}.to_s")
107 when :raw
108 raw_evaluate(expression)
109 end
100 evaluate(expression, :current, format)
110101 end
111102
112103 AUTO_LOAD = {
toggle raw diff