Skip to content

Commit 170f938

Browse files
committed
Merge pull request #67 from ruby-debug/rm-protocol-extensions
RubyMine-specific protocol extensions
2 parents 2f4a16f + c38e7c0 commit 170f938

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

bin/rdebug-ide

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ options = OpenStruct.new(
1919
'tracing' => false,
2020
'int_handler' => true,
2121
'dispatcher_port' => -1,
22-
'evaluation_timeout' => 10
22+
'evaluation_timeout' => 10,
23+
'rm_protocol_extensions' => false
2324
)
2425

2526
opts = OptionParser.new do |opts|
@@ -54,6 +55,9 @@ EOB
5455

5556
opts.on("--keep-frame-binding", "Keep frame bindings") {options.frame_bind = true}
5657
opts.on("--disable-int-handler", "Disables interrupt signal handler") {options.int_handler = false}
58+
opts.on("--rubymine-protocol-extensions", "Enable RubyMine-specific incompatible protocol extensions") do
59+
options.rm_protocol_extensions = true
60+
end
5761
opts.separator ""
5862
opts.separator "Common options:"
5963
opts.on_tail("-v", "--version", "Show version") do
@@ -112,6 +116,7 @@ end
112116
Debugger.keep_frame_binding = options.frame_bind
113117
Debugger.tracing = options.tracing
114118
Debugger.evaluation_timeout = options.evaluation_timeout
119+
Debugger.rm_protocol_extensions = options.rm_protocol_extensions
115120

116121
Debugger.debug_program(options)
117122

lib/ruby-debug-ide.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def cleanup_backtrace(backtrace)
4141
cleared
4242
end
4343

44-
attr_accessor :cli_debug, :xml_debug, :evaluation_timeout
44+
attr_accessor :cli_debug, :xml_debug, :evaluation_timeout, :rm_protocol_extensions
4545
attr_accessor :control_thread
4646
attr_reader :interface
4747

lib/ruby-debug-ide/ide_processor.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ def process_commands
2828
s.interface = @interface
2929
end
3030
event_cmds = Command.commands.map{|cmd| cmd.new(state, @printer) }
31-
while !state.proceed? do
31+
until state.proceed? do
3232
input = @interface.command_queue.pop
3333
catch(:debug_error) do
3434
splitter[input].each do |input|
3535
# escape % since print_debug might use printf
3636
@printer.print_debug "Processing in context: #{input.gsub('%', '%%')}"
37-
if cmd = event_cmds.find { |c| c.match(input) }
37+
if (cmd = event_cmds.find { |c| c.match(input) })
3838
if context.dead? && cmd.class.need_context
3939
@printer.print_msg "Command is unavailable\n"
4040
else
4141
cmd.execute
4242
end
4343
else
4444
@printer.print_msg "Unknown command: #{input}"
45-
end
45+
end
4646
end
4747
end
4848
state.restore_context

lib/ruby-debug-ide/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Debugger
2-
IDE_VERSION='0.4.24.beta2'
2+
IDE_VERSION='0.4.24.beta4'
33
end

lib/ruby-debug-ide/xml_printer.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def print_current_frame(frame_pos)
7878
def print_frame(context, frame_id, current_frame_id)
7979
# idx + 1: one-based numbering as classic-debugger
8080
file = context.frame_file(frame_id)
81-
print "<frame no=\'%s\' file=\'%s\' line=\'%s\' #{"current='true' " if frame_id == current_frame_id}/>",
81+
print "<frame no=\"%s\" file=\"%s\" line=\"%s\" #{"current='true' " if frame_id == current_frame_id}/>",
8282
frame_id + 1, File.expand_path(file), context.frame_line(frame_id)
8383
end
8484

@@ -173,9 +173,9 @@ def print_variable(name, value, kind)
173173
value_str = handle_binary_data(value_str)
174174
escaped_value_str = CGI.escapeHTML(value_str)
175175
print("<variable name=\"%s\" %s kind=\"%s\" value=\"%s\" type=\"%s\" hasChildren=\"%s\" objectId=\"%#+x\">",
176-
CGI.escapeHTML(name), build_compact_value_attr(value), kind, escaped_value_str, value.class,
176+
CGI.escapeHTML(name), build_compact_value_attr(value), kind, build_value_attr(escaped_value_str), value.class,
177177
has_children, value.respond_to?(:object_id) ? value.object_id : value.id)
178-
print("<value><![CDATA[%s]]></value>", escaped_value_str)
178+
print("<value><![CDATA[%s]]></value>", escaped_value_str) if Debugger.rm_protocol_extensions
179179
print('</variable>')
180180
end
181181

@@ -345,6 +345,9 @@ def build_compact_name(value)
345345
return compact_array_str(value) if value.is_a?(Array)
346346
return compact_hash_str(value) if value.is_a?(Hash)
347347
nil
348+
rescue ::Exception => e
349+
print_debug(e)
350+
nil
348351
end
349352

350353
def compact_array_str(value)
@@ -367,6 +370,10 @@ def build_compact_value_attr(value)
367370
compact_value_str.nil? ? '' : "compactValue=\"#{CGI.escapeHTML(compact_value_str)}\""
368371
end
369372

373+
def build_value_attr(escaped_value_str)
374+
Debugger.rm_protocol_extensions ? '' : escaped_value_str
375+
end
376+
370377
instance_methods.each do |m|
371378
if m.to_s.index('print_') == 0
372379
protect m

0 commit comments

Comments
 (0)