debugger-xml 0.3.3 → 0.4.0
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/rdebug-ide +12 -9
- data/bin/rdebug-vim +30 -13
- data/debugger-xml.gemspec +7 -3
- data/lib/byebug/commands/frame.rb +16 -0
- data/lib/byebug/commands/help.rb +13 -0
- data/lib/byebug/commands/info.rb +13 -0
- data/lib/byebug/commands/inspect.rb +30 -0
- data/lib/byebug/commands/kill.rb +13 -0
- data/lib/byebug/commands/start.rb +25 -0
- data/lib/byebug/commands/threads.rb +10 -0
- data/lib/byebug/commands/trace.rb +13 -0
- data/lib/byebug/commands/variables.rb +54 -0
- data/lib/byebug/context_xml.rb +29 -0
- data/lib/byebug/printers/texts/xml.yml +122 -0
- data/lib/byebug/printers/xml.rb +197 -0
- data/lib/debugger/{xml/extensions/processor.rb → command_processor.rb} +0 -0
- data/lib/debugger/{xml/extensions/commands → commands}/edit.rb +0 -0
- data/lib/debugger/{xml/extensions/commands → commands}/frame.rb +0 -1
- data/lib/debugger/{xml/extensions/commands → commands}/help.rb +0 -0
- data/lib/debugger/{xml/extensions/commands → commands}/info.rb +0 -0
- data/lib/debugger/{xml/extensions/commands → commands}/inspect.rb +0 -0
- data/lib/debugger/{xml/extensions/commands → commands}/irb.rb +0 -0
- data/lib/debugger/{xml/extensions/commands → commands}/kill.rb +0 -0
- data/lib/debugger/commands/start.rb +25 -0
- data/lib/debugger/{xml/extensions/commands → commands}/threads.rb +0 -0
- data/lib/debugger/{xml/extensions/commands → commands}/tmate.rb +0 -0
- data/lib/debugger/{xml/extensions/commands → commands}/trace.rb +0 -0
- data/lib/debugger/{xml/extensions/commands → commands}/variables.rb +14 -0
- data/lib/debugger_xml.rb +91 -0
- data/lib/debugger_xml/byebug_proxy.rb +108 -0
- data/lib/debugger_xml/debugger_proxy.rb +115 -0
- data/lib/debugger_xml/fake_logger.rb +9 -0
- data/lib/debugger_xml/ide/control_command_processor.rb +69 -0
- data/lib/debugger_xml/ide/interface.rb +74 -0
- data/lib/debugger_xml/ide/logger.rb +9 -0
- data/lib/debugger_xml/ide/processor.rb +118 -0
- data/lib/debugger_xml/multiprocess/monkey.rb +47 -0
- data/lib/debugger_xml/multiprocess/pre_child.rb +79 -0
- data/lib/{debugger/xml → debugger_xml}/multiprocess/starter.rb +2 -2
- data/lib/debugger_xml/version.rb +3 -0
- data/lib/debugger_xml/vim/control_command_processor.rb +23 -0
- data/lib/debugger_xml/vim/interface.rb +46 -0
- data/lib/debugger_xml/vim/logger.rb +16 -0
- data/lib/debugger_xml/vim/notification.rb +35 -0
- data/lib/debugger_xml/vim/processor.rb +20 -0
- data/test/breakpoints_test.rb +0 -1
- data/test/ide/control_command_processor_test.rb +18 -13
- data/test/ide/processor_test.rb +11 -25
- data/test/printers/xml_test.rb +1 -0
- data/test/test_helper.rb +12 -3
- data/test/variables_test.rb +0 -1
- data/test/vim/control_command_processor_test.rb +4 -5
- data/test/vim/interface_test.rb +6 -6
- data/test/vim/notification_test.rb +3 -3
- data/test/vim/processor_test.rb +8 -8
- metadata +61 -48
- data/lib/debugger/xml.rb +0 -11
- data/lib/debugger/xml/extensions/ide_server.rb +0 -33
- data/lib/debugger/xml/extensions/vim_server.rb +0 -56
- data/lib/debugger/xml/fake_logger.rb +0 -11
- data/lib/debugger/xml/ide/control_command_processor.rb +0 -81
- data/lib/debugger/xml/ide/interface.rb +0 -72
- data/lib/debugger/xml/ide/logger.rb +0 -11
- data/lib/debugger/xml/ide/processor.rb +0 -94
- data/lib/debugger/xml/multiprocess/monkey.rb +0 -49
- data/lib/debugger/xml/multiprocess/pre_child.rb +0 -81
- data/lib/debugger/xml/version.rb +0 -5
- data/lib/debugger/xml/vim/control_command_processor.rb +0 -19
- data/lib/debugger/xml/vim/interface.rb +0 -42
- data/lib/debugger/xml/vim/logger.rb +0 -18
- data/lib/debugger/xml/vim/notification.rb +0 -37
- data/lib/debugger/xml/vim/processor.rb +0 -22
@@ -1,72 +0,0 @@
|
|
1
|
-
module Debugger
|
2
|
-
module Xml
|
3
|
-
module Ide
|
4
|
-
class Interface < Debugger::Interface # :nodoc:
|
5
|
-
attr_accessor :command_queue
|
6
|
-
attr_accessor :histfile
|
7
|
-
attr_accessor :history_save
|
8
|
-
attr_accessor :history_length
|
9
|
-
attr_accessor :restart_file
|
10
|
-
|
11
|
-
def initialize(socket)
|
12
|
-
@command_queue = []
|
13
|
-
@socket = socket
|
14
|
-
@history_save = false
|
15
|
-
@history_length = 256
|
16
|
-
@histfile = ''
|
17
|
-
@restart_file = nil
|
18
|
-
end
|
19
|
-
|
20
|
-
def close
|
21
|
-
@socket.close
|
22
|
-
rescue Exception
|
23
|
-
end
|
24
|
-
|
25
|
-
def print_debug(msg)
|
26
|
-
STDOUT.puts(msg)
|
27
|
-
end
|
28
|
-
|
29
|
-
def errmsg(*args)
|
30
|
-
print(*args)
|
31
|
-
end
|
32
|
-
|
33
|
-
def confirm(prompt)
|
34
|
-
true
|
35
|
-
end
|
36
|
-
|
37
|
-
def finalize
|
38
|
-
close
|
39
|
-
end
|
40
|
-
|
41
|
-
# Workaround for JRuby issue http://jira.codehaus.org/browse/JRUBY-2063
|
42
|
-
def non_blocking_gets
|
43
|
-
loop do
|
44
|
-
result, _, _ = IO.select([@socket], nil, nil, 0.2)
|
45
|
-
next unless result
|
46
|
-
return result[0].gets
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def read_command(*args)
|
51
|
-
result = non_blocking_gets
|
52
|
-
raise IOError unless result
|
53
|
-
result.chomp.tap do |r|
|
54
|
-
Xml.logger.puts("Read command: #{r}")
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def readline_support?
|
59
|
-
false
|
60
|
-
end
|
61
|
-
|
62
|
-
def print(*args)
|
63
|
-
escaped_args = escape_input(args)
|
64
|
-
value = escaped_args.first % escaped_args[1..-1]
|
65
|
-
Xml.logger.puts("Going to print: #{value}")
|
66
|
-
@socket.print(value)
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require 'ruby-debug/processor'
|
2
|
-
|
3
|
-
module Debugger
|
4
|
-
module Xml
|
5
|
-
module Ide
|
6
|
-
|
7
|
-
class Processor < Debugger::Processor
|
8
|
-
attr_reader :context, :file, :line, :display
|
9
|
-
def initialize(interface)
|
10
|
-
@mutex = Mutex.new
|
11
|
-
@interface = interface
|
12
|
-
@display = []
|
13
|
-
end
|
14
|
-
|
15
|
-
def at_breakpoint(context, breakpoint)
|
16
|
-
raise "@last_breakpoint supposed to be nil. is #{@last_breakpoint}" if @last_breakpoint
|
17
|
-
# at_breakpoint is immediately followed by #at_line event. So postpone breakpoint printing until #at_line.
|
18
|
-
@last_breakpoint = breakpoint
|
19
|
-
end
|
20
|
-
protect :at_breakpoint
|
21
|
-
|
22
|
-
# TODO: Catching exceptions doesn't work so far, need to fix
|
23
|
-
def at_catchpoint(context, excpt)
|
24
|
-
end
|
25
|
-
|
26
|
-
# We don't have tracing for IDE
|
27
|
-
def at_tracing(*args)
|
28
|
-
end
|
29
|
-
|
30
|
-
def at_line(context, file, line)
|
31
|
-
if context.nil? || context.stop_reason == :step
|
32
|
-
print_file_line(context, file, line)
|
33
|
-
end
|
34
|
-
line_event(context, file, line)
|
35
|
-
end
|
36
|
-
protect :at_line
|
37
|
-
|
38
|
-
def at_return(context, file, line)
|
39
|
-
print_file_line(context, file, line)
|
40
|
-
context.stop_frame = -1
|
41
|
-
line_event(context, file, line)
|
42
|
-
end
|
43
|
-
|
44
|
-
def at_line?
|
45
|
-
!!@line
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def print_file_line(context, file, line)
|
51
|
-
print(
|
52
|
-
Debugger.printer.print(
|
53
|
-
"stop.suspend",
|
54
|
-
file: CommandProcessor.canonic_file(file), line_number: line, line: Debugger.line_at(file, line),
|
55
|
-
thnum: context && context.thnum, frames: context && context.stack_size
|
56
|
-
)
|
57
|
-
)
|
58
|
-
end
|
59
|
-
|
60
|
-
def line_event(context, file, line)
|
61
|
-
@line = line
|
62
|
-
@file = file
|
63
|
-
@context = context
|
64
|
-
if @last_breakpoint
|
65
|
-
# followed after #at_breakpoint in the same thread. Print breakpoint
|
66
|
-
# now when @line, @file and @context are correctly set to prevent race
|
67
|
-
# condition with `control thread'.
|
68
|
-
n = Debugger.breakpoints.index(@last_breakpoint) + 1
|
69
|
-
print pr("breakpoints.stop_at_breakpoint",
|
70
|
-
id: n, file: @file, line: @line, thread_id: Debugger.current_context.thnum
|
71
|
-
)
|
72
|
-
end
|
73
|
-
if @context && @context.thread.is_a?(Debugger::DebugThread)
|
74
|
-
raise pr("thread.errors.debug_trace", thread: @context.thread)
|
75
|
-
end
|
76
|
-
# will be resumed by commands like `step', `next', `continue', `finish'
|
77
|
-
# from `control thread'
|
78
|
-
stop_thread
|
79
|
-
ensure
|
80
|
-
@line = nil
|
81
|
-
@file = nil
|
82
|
-
@context = nil
|
83
|
-
@last_breakpoint = nil
|
84
|
-
InspectCommand.clear_references
|
85
|
-
end
|
86
|
-
|
87
|
-
def stop_thread
|
88
|
-
Thread.stop
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module Debugger
|
2
|
-
module Xml
|
3
|
-
module MultiProcess
|
4
|
-
def self.create_mp_fork(private=false)
|
5
|
-
%Q{
|
6
|
-
alias pre_debugger_fork fork
|
7
|
-
|
8
|
-
#{private ? "private" : ""}
|
9
|
-
def fork(*args)
|
10
|
-
if block_given?
|
11
|
-
return pre_debugger_fork{Debugger::Xml::MultiProcess::pre_child; yield}
|
12
|
-
end
|
13
|
-
result = pre_debugger_fork
|
14
|
-
Debugger::Xml::MultiProcess::pre_child unless result
|
15
|
-
result
|
16
|
-
end
|
17
|
-
}
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.create_mp_exec(private=false)
|
21
|
-
%Q{
|
22
|
-
alias pre_debugger_exec exec
|
23
|
-
|
24
|
-
#{private ? "private" : ""}
|
25
|
-
def exec(*args)
|
26
|
-
Debugger.handler.interface.close
|
27
|
-
pre_debugger_exec(*args)
|
28
|
-
end
|
29
|
-
}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
module Kernel
|
36
|
-
class << self
|
37
|
-
module_eval Debugger::Xml::MultiProcess.create_mp_fork
|
38
|
-
module_eval Debugger::Xml::MultiProcess.create_mp_exec
|
39
|
-
end
|
40
|
-
module_eval Debugger::Xml::MultiProcess.create_mp_fork(true)
|
41
|
-
module_eval Debugger::Xml::MultiProcess.create_mp_exec(true)
|
42
|
-
end
|
43
|
-
|
44
|
-
module Process
|
45
|
-
class << self
|
46
|
-
module_eval Debugger::Xml::MultiProcess.create_mp_fork
|
47
|
-
module_eval Debugger::Xml::MultiProcess.create_mp_exec
|
48
|
-
end
|
49
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
module Debugger
|
2
|
-
module Xml
|
3
|
-
module MultiProcess
|
4
|
-
class << self
|
5
|
-
def pre_child
|
6
|
-
return unless ENV['IDE_PROCESS_DISPATCHER']
|
7
|
-
|
8
|
-
require 'socket'
|
9
|
-
require 'ostruct'
|
10
|
-
|
11
|
-
host = ENV['DEBUGGER_HOST']
|
12
|
-
port = find_free_port(host)
|
13
|
-
|
14
|
-
options = OpenStruct.new(
|
15
|
-
host: host,
|
16
|
-
port: port,
|
17
|
-
stop: false,
|
18
|
-
tracing: false,
|
19
|
-
wait_for_start: true,
|
20
|
-
int_handler: true,
|
21
|
-
debug_mode: (ENV['DEBUGGER_DEBUG_MODE'] == 'true'),
|
22
|
-
dispatcher_port: ENV['IDE_PROCESS_DISPATCHER']
|
23
|
-
)
|
24
|
-
|
25
|
-
acceptor_host, acceptor_port = ENV['IDE_PROCESS_DISPATCHER'].split(":")
|
26
|
-
acceptor_host, acceptor_port = '127.0.0.1', acceptor_host unless acceptor_port
|
27
|
-
|
28
|
-
connected = false
|
29
|
-
3.times do |i|
|
30
|
-
begin
|
31
|
-
s = TCPSocket.open(acceptor_host, acceptor_port)
|
32
|
-
s.print(port)
|
33
|
-
s.close
|
34
|
-
connected = true
|
35
|
-
start_debugger(options)
|
36
|
-
return
|
37
|
-
rescue => bt
|
38
|
-
$stderr.puts "#{Process.pid}: connection failed(#{i+1})"
|
39
|
-
$stderr.puts "Exception: #{bt}"
|
40
|
-
$stderr.puts bt.backtrace.map { |l| "\t#{l}" }.join("\n")
|
41
|
-
sleep 0.3
|
42
|
-
end unless connected
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def start_debugger(options)
|
47
|
-
if Debugger.started?
|
48
|
-
# we're in forked child, only need to restart control thread
|
49
|
-
Debugger.breakpoints.clear
|
50
|
-
Debugger.control_thread = nil
|
51
|
-
end
|
52
|
-
|
53
|
-
if options.int_handler
|
54
|
-
# install interruption handler
|
55
|
-
trap('INT') { Debugger.interrupt_last }
|
56
|
-
end
|
57
|
-
|
58
|
-
# set options
|
59
|
-
Debugger.tracing = options.tracing
|
60
|
-
Debugger.wait_for_start = options.wait_for_start
|
61
|
-
Debugger.wait_connection = true
|
62
|
-
Debugger.printer = Printers::Xml.new
|
63
|
-
Debugger::Xml.logger = if options.debug_mode
|
64
|
-
Debugger::Xml::Ide::Logger.new
|
65
|
-
else
|
66
|
-
Debugger::Xml::FakeLogger.new
|
67
|
-
end
|
68
|
-
Debugger.start_remote_ide(options.host, options.port)
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
def find_free_port(host)
|
73
|
-
server = TCPServer.open(host, 0)
|
74
|
-
port = server.addr[1]
|
75
|
-
server.close
|
76
|
-
port
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
data/lib/debugger/xml/version.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'debugger/xml/ide/control_command_processor'
|
2
|
-
|
3
|
-
module Debugger
|
4
|
-
module Xml
|
5
|
-
module Vim
|
6
|
-
|
7
|
-
class ControlCommandProcessor < Ide::ControlCommandProcessor
|
8
|
-
private
|
9
|
-
|
10
|
-
def process_input(input)
|
11
|
-
super(input)
|
12
|
-
@interface.send_response
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'debugger/xml/ide/interface'
|
2
|
-
|
3
|
-
module Debugger
|
4
|
-
module Xml
|
5
|
-
module Vim
|
6
|
-
class Interface < Ide::Interface
|
7
|
-
def initialize(socket, options)
|
8
|
-
super(socket)
|
9
|
-
@options = options
|
10
|
-
@output = []
|
11
|
-
end
|
12
|
-
|
13
|
-
def print(*args)
|
14
|
-
escaped_args = escape_input(args)
|
15
|
-
value = escaped_args.first % escaped_args[1..-1]
|
16
|
-
Xml.logger.puts("Going to print: #{value}")
|
17
|
-
@output << sprintf(value)
|
18
|
-
end
|
19
|
-
|
20
|
-
def send_response
|
21
|
-
create_directory(@options.file)
|
22
|
-
message = @output.join(@options.separator)
|
23
|
-
@output.clear
|
24
|
-
unless message.empty?
|
25
|
-
File.open(@options.file, 'w') do |f|
|
26
|
-
f.puts(message)
|
27
|
-
end
|
28
|
-
Notification.new("receive_command", @options).send
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def create_directory(file)
|
35
|
-
dir = File.dirname(file)
|
36
|
-
Dir.mkdir(dir) unless File.exist?(dir) && File.directory?(dir)
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Debugger
|
2
|
-
module Xml
|
3
|
-
module Vim
|
4
|
-
class Logger
|
5
|
-
def initialize(logger_file)
|
6
|
-
@logger_file = logger_file
|
7
|
-
end
|
8
|
-
|
9
|
-
def puts(string)
|
10
|
-
File.open(@logger_file, 'a') do |f|
|
11
|
-
# match vim redir style new lines, rather than trailing
|
12
|
-
f << "\ndebugger-xml, #{Time.now.strftime("%H:%M:%S")} : #{string.chomp}"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
module Debugger
|
2
|
-
module Xml
|
3
|
-
module Vim
|
4
|
-
class Notification
|
5
|
-
|
6
|
-
def initialize(command, options)
|
7
|
-
@command = command
|
8
|
-
@executable = options.vim_executable
|
9
|
-
@servername = options.vim_servername
|
10
|
-
@debug_mode = options.debug_mode
|
11
|
-
@logger_file = options.logger_file
|
12
|
-
end
|
13
|
-
|
14
|
-
def send
|
15
|
-
command = ":call RubyDebugger.#{@command}()"
|
16
|
-
starter = "<C-\\\\>"
|
17
|
-
sys_cmd = "#{@executable} --servername #{@servername} -u NONE -U NONE " +
|
18
|
-
"--remote-send \"#{starter}<C-N>#{command}<CR>\""
|
19
|
-
log("Executing command: #{sys_cmd}")
|
20
|
-
system(sys_cmd);
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def log(string)
|
26
|
-
if @debug_mode
|
27
|
-
File.open(@logger_file, 'a') do |f|
|
28
|
-
# match vim redir style new lines, rather than trailing
|
29
|
-
f << "\ndebugger-xml, #{Time.now.strftime("%H:%M:%S")} : #{string.chomp}"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'ruby-debug/processor'
|
2
|
-
require 'debugger/xml/ide/processor'
|
3
|
-
|
4
|
-
module Debugger
|
5
|
-
module Xml
|
6
|
-
module Vim
|
7
|
-
|
8
|
-
class Processor < Ide::Processor
|
9
|
-
private
|
10
|
-
def stop_thread
|
11
|
-
processor = Vim::ControlCommandProcessor.new(@interface)
|
12
|
-
processor.process_command("where")
|
13
|
-
processor.process_command("var local")
|
14
|
-
@interface.send_response
|
15
|
-
super
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|