| |   |
| 12 | 12 | exit unless d.connected? |
| 13 | 13 | |
| 14 | 14 | what = RubyAMP::Inspect.get_selection |
| 15 | | RubyAMP::Inspect.copy_to_clipboard(d.inspect(what, :yaml)) |
| 15 | RubyAMP::Inspect.copy_to_clipboard(d.evaluate(what, :current, :yaml)) |
| 16 | 16 | puts "Copied value of #{what} to clipboard"</string> |
| 17 | 17 | <key>input</key> |
| 18 | 18 | <string>document</string> |
| toggle raw diff |
--- a/Commands/Debug - Copy inspection to clipboard as YAML.tmCommand
+++ b/Commands/Debug - Copy inspection to clipboard as YAML.tmCommand
@@ -12,7 +12,7 @@ d = RubyAMP::RemoteDebugger.new
exit unless d.connected?
what = RubyAMP::Inspect.get_selection
-RubyAMP::Inspect.copy_to_clipboard(d.inspect(what, :yaml))
+RubyAMP::Inspect.copy_to_clipboard(d.evaluate(what, :current, :yaml))
puts "Copied value of #{what} to clipboard"</string>
<key>input</key>
<string>document</string> |
| |   |
| 12 | 12 | exit unless d.connected? |
| 13 | 13 | |
| 14 | 14 | what = RubyAMP::Inspect.get_selection |
| 15 | | RubyAMP::Inspect.copy_to_clipboard(d.inspect(what, :pp)) |
| 15 | RubyAMP::Inspect.copy_to_clipboard(d.evaluate(what, :current, :pp)) |
| 16 | 16 | puts "Copied value of #{what} to clipboard"</string> |
| 17 | 17 | <key>input</key> |
| 18 | 18 | <string>document</string> |
| toggle raw diff |
--- a/Commands/Debug - Copy inspection to clipboard as pretty print.tmCommand
+++ b/Commands/Debug - Copy inspection to clipboard as pretty print.tmCommand
@@ -12,7 +12,7 @@ d = RubyAMP::RemoteDebugger.new
exit unless d.connected?
what = RubyAMP::Inspect.get_selection
-RubyAMP::Inspect.copy_to_clipboard(d.inspect(what, :pp))
+RubyAMP::Inspect.copy_to_clipboard(d.evaluate(what, :current, :pp))
puts "Copied value of #{what} to clipboard"</string>
<key>input</key>
<string>document</string> |
| |   |
| 12 | 12 | exit unless d.connected? |
| 13 | 13 | |
| 14 | 14 | what = RubyAMP::Inspect.get_selection |
| 15 | | RubyAMP::Inspect.copy_to_clipboard(d.inspect(what, :string)) |
| 15 | RubyAMP::Inspect.copy_to_clipboard(d.evaluate(what, :current, :string)) |
| 16 | 16 | puts "Copied value of #{what} to clipboard"</string> |
| 17 | 17 | <key>input</key> |
| 18 | 18 | <string>document</string> |
| toggle raw diff |
--- a/Commands/Debug - Copy inspection to clipboard as string.tmCommand
+++ b/Commands/Debug - Copy inspection to clipboard as string.tmCommand
@@ -12,7 +12,7 @@ d = RubyAMP::RemoteDebugger.new
exit unless d.connected?
what = RubyAMP::Inspect.get_selection
-RubyAMP::Inspect.copy_to_clipboard(d.inspect(what, :string))
+RubyAMP::Inspect.copy_to_clipboard(d.evaluate(what, :current, :string))
puts "Copied value of #{what} to clipboard"</string>
<key>input</key>
<string>document</string> |
| |   |
| 16 | 16 | eval(cmd, current_binding) |
| 17 | 17 | end |
| 18 | 18 | |
| 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 | |
| 19 | 38 | def wait_for_connection |
| 20 | 39 | while Debugger.handler.interface.nil?; sleep 0.10; end |
| 21 | 40 | end |
| toggle raw diff |
--- a/Support/ext/debugger_extension.rb
+++ b/Support/ext/debugger_extension.rb
@@ -16,6 +16,25 @@ module Debugger
eval(cmd, current_binding)
end
+ def evaluate(cmd, binding = :current, format = :raw)
+ result = Kernel.eval(cmd, (binding == :current) ? current_binding : Kernel.binding)
+ case format
+ when :pp
+ require('pp')
+ ::PP.pp(result, output='')
+ output
+ when :yaml
+ require('yaml')
+ result.to_yaml
+ when :string
+ result.to_s
+ when :raw
+ result
+ end
+ rescue Exception => e
+ "Error inspecting #{cmd} - #{e.inspect}"
+ end
+
def wait_for_connection
while Debugger.handler.interface.nil?; sleep 0.10; end
end |
| |   |
| 85 | 85 | read_output |
| 86 | 86 | end |
| 87 | 87 | |
| 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})") |
| 100 | 90 | eval(o) |
| 91 | rescue Exception |
| 92 | o |
| 101 | 93 | end |
| 102 | 94 | |
| 103 | 95 | def current_frame |
| … | … | |
| 97 | 97 | end |
| 98 | 98 | |
| 99 | 99 | 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) |
| 110 | 101 | end |
| 111 | 102 | |
| 112 | 103 | AUTO_LOAD = { |
| toggle raw diff |
--- a/Support/lib/ruby_amp/remote_debugger.rb
+++ b/Support/lib/ruby_amp/remote_debugger.rb
@@ -85,19 +85,11 @@ module RubyAMP
read_output
end
- def raw_evaluate(cmd, binding = :current)
- case binding
- when :current
- command("e Debugger.eval_from_current_binding(#{cmd.inspect})")
- when :control
- command("e send(:eval, #{cmd.inspect})")
- end
- end
-
- def evaluate(cmd, binding = :current)
- o = raw_evaluate(cmd, binding)
- return o if o.nil? || (line = o.split("\n").first).nil? || line.match(/^[a-z:]+ *Exception: /i)
+ def evaluate(cmd, binding = :current, format = :raw)
+ o = command("e Debugger.evaluate(#{cmd.inspect}, :#{binding}, :#{format})")
eval(o)
+ rescue Exception
+ o
end
def current_frame
@@ -105,16 +97,7 @@ module RubyAMP
end
def inspect(expression, format = :pp)
- case format
- when :pp
- evaluate("::Object.require('pp'); ::Object::PP.pp((#{expression}), __tmp_output__=''); __tmp_output__")
- when :yaml
- evaluate("::Object.require 'yaml'; (#{expression}).to_yaml")
- when :string
- evaluate("#{expression}.to_s")
- when :raw
- raw_evaluate(expression)
- end
+ evaluate(expression, :current, format)
end
AUTO_LOAD = { |