Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
dlanileonardo committed Nov 14, 2019
2 parents 57f4243 + 0f58b1e commit 6d12ed9
Show file tree
Hide file tree
Showing 14 changed files with 511 additions and 49 deletions.
13 changes: 9 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ os:
- osx

rvm:
- 1.8.7
- 1.9.3
- 2.0.0
- 2.1.10
- 2.2.8
- 2.3.5
- 2.4.2
- 2.5.0
- 2.3.8
- 2.4.6
- 2.5.5
- 2.6.3
- ruby-head

matrix:
Expand All @@ -25,10 +27,13 @@ matrix:
- os: osx
rvm: 2.0.0

- os: osx
rvm: 1.8.7

# include:
# - os: osx
# rvm: 1.9.3
# before_script: rvm install ruby-1.9.3 # not binary
# - os: osx
# rvm: 2.0.0
# before_script: rvm install ruby-2.0.0 # not binary
# before_script: rvm install ruby-2.0.0 # not binary
26 changes: 18 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@ source "http://rubygems.org"
# @param [Array<String>] versions compatible ruby versions
# @return [Array<String>] an array with mri platforms of given versions
def mries(*versions)
versions.flat_map do |v|
%w(ruby mingw x64_mingw)
.map { |platform| "#{platform}_#{v}".to_sym unless platform == "x64_mingw" && v < "2.0" }
.delete_if &:nil?
end
versions.map do |v|
%w(ruby mingw x64_mingw).map do |platform|
"#{platform}_#{v}".to_sym unless platform == "x64_mingw" && v < "2.0"
end.delete_if &:nil?
end.flatten
end

if RUBY_VERSION < '1.9' || defined?(JRUBY_VERSION)
gem "ruby-debug-base", :platforms => [:jruby, *mries('18')]
end

if RUBY_VERSION && RUBY_VERSION >= "1.9"
gem "ruby-debug-base19x", ">= 0.11.32", :platforms => mries('19')
end

gem "ruby-debug-base", :platforms => [:jruby, *mries('18')]
gem "ruby-debug-base19x", ">= 0.11.32", :platforms => mries('19')
if RUBY_VERSION && RUBY_VERSION >= "2.0"
gem "debase", "~> 0.2", ">= 0.2.2", :platforms => mries('20', '21', '22', '23', '24', '25')
end
Expand All @@ -23,6 +29,10 @@ group :development do
end

group :test do
gem "test-unit"
if RUBY_VERSION < "1.9"
gem "test-unit", "~> 2.1.2"
else
gem "test-unit"
end
end

33 changes: 29 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
[gem]: https://rubygems.org/gems/ruby-debug-ide
# ruby-debug-ide
An interface which glues ruby-debug to IDEs like Eclipse (RDT), NetBeans and RubyMine.

[![official JetBrains project](http://jb.gg/badges/official.svg)](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
[![Gem Version](https://badge.fury.io/rb/ruby-debug-ide.svg)][gem]
[![Build Status](https://travis-ci.org/ruby-debug/ruby-debug-ide.svg?branch=master)](https://travis-ci.org/ruby-debug/ruby-debug-ide)

[gem]: https://rubygems.org/gems/ruby-debug-ide
# ruby-debug-ide

The 'ruby-debug-ide' gem provides the protocol to establish communication between the debugger engine (such as [debase](https://rubygems.org/gems/debase) or [ruby-debug-base](https://rubygems.org/gems/ruby-debug-base)) and IDEs (for example, RubyMine, Visual Studio Code, or Eclipse). 'ruby-debug-ide' redirect commands from the IDE to the debugger engine. Then, it returns answers/events received from the debugger engine to the IDE. To learn more about a communication protocol, see the following document: [ruby-debug-ide protocol](protocol-spec.md).

## Install debugging gems
Depending on the used Ruby version, you need to add/install the following debugging gems to the Gemfile:
- Ruby 2.x - [ruby-debug-ide](https://rubygems.org/gems/ruby-debug-ide) and [debase](https://rubygems.org/gems/debase)
- Ruby 1.9.x - [ruby-debug-ide](https://rubygems.org/gems/ruby-debug-ide) and [ruby-debug-base19x](https://rubygems.org/gems/ruby-debug-base19x)
- jRuby or Ruby 1.8.x - [ruby-debug-ide](https://rubygems.org/gems/ruby-debug-ide) and [ruby-debug-base](https://rubygems.org/gems/ruby-debug-base)
> For Windows, make sure that the Ruby [DevKit](https://github.com/oneclick/rubyinstaller/wiki/Development-Kit) is installed.
## Start debugging session
To start the debugging session for a Rails application, run the following command:
```shell
rdebug-ide --host 0.0.0.0 --port 1234 --dispatcher-port 1234 -- bin/rails s
```
If you want to debug a Rails application run using Docker Compose, you need to start the Rails server from the Docker in the following way:
```yaml
command: bundle exec rdebug-ide --host 0.0.0.0 --port 1234 -- bin/rails s -p 3000 -b 0.0.0.0
volumes:
- .:/sample_rails_app
ports:
- "1234:1234"
- "3000:3000"
- "26162:26162"
```
Note that all ports above should be exposed in the Dockerfile.
8 changes: 3 additions & 5 deletions bin/rdebug-ide
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ options = OpenStruct.new(
'port' => 1234,
'stop' => false,
'tracing' => false,
'skip_wait_for_start' => false,
'int_handler' => true,
'dispatcher_port' => -1,
'evaluation_timeout' => 10,
Expand All @@ -29,7 +30,6 @@ options = OpenStruct.new(
'attach_mode' => false,
'cli_debug' => false,
'key_value_mode' => false,
'server_mode' => false
)

opts = OptionParser.new do |opts|
Expand Down Expand Up @@ -68,6 +68,7 @@ EOB

opts.on('--stop', 'stop when the script is loaded') {options.stop = true}
opts.on("-x", "--trace", "turn on line tracing") {options.tracing = true}
opts.on("--skip_wait_for_start", "skip wait for 'start' command") {options.skip_wait_for_start = true}
opts.on("-l", "--load-mode", "load mode (experimental)") {options.load_mode = true}
opts.on("-d", "--debug", "Debug self - prints information for debugging ruby-debug itself") do
Debugger.cli_debug = true
Expand All @@ -85,9 +86,6 @@ EOB
opts.on("--key-value", "Key/Value presentation of hash items") do
options.key_value_mode = true
end
opts.on("--server-mode", "Tells that rdebug-ide is working in server mode") do
options.server_mode = true
end
opts.on("--ignore-port", "Generate another port") do
options.ignore_port = true
end
Expand Down Expand Up @@ -169,7 +167,7 @@ Debugger.inspect_time_limit = options.inspect_time_limit
Debugger.catchpoint_deleted_event = options.catchpoint_deleted_event || options.rm_protocol_extensions
Debugger.value_as_nested_element = options.value_as_nested_element || options.rm_protocol_extensions
Debugger.key_value_mode = options.key_value_mode
Debugger.server_mode = options.server_mode
Debugger.skip_wait_for_start = options.skip_wait_for_start

if options.attach_mode
Debugger.require_multiprocess
Expand Down
5 changes: 3 additions & 2 deletions ext/mkrf_conf.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
install_dir = File.expand_path("../../../..", __FILE__)
jruby = defined?(JRUBY_VERSION) || (defined?(RUBY_ENGINE) && 'jruby' == RUBY_ENGINE)
rbx = defined?(RUBY_ENGINE) && 'rbx' == RUBY_ENGINE

Expand Down Expand Up @@ -27,11 +28,11 @@ def already_installed(dep)

begin
puts "Installing base gem"
inst = Gem::DependencyInstaller.new :prerelease => dep.prerelease?
inst = Gem::DependencyInstaller.new(:prerelease => dep.prerelease?, :install_dir => install_dir)
inst.install dep
rescue
begin
inst = Gem::DependencyInstaller.new(:prerelease => true)
inst = Gem::DependencyInstaller.new(:prerelease => true, :install_dir => install_dir)
inst.install dep
rescue Exception => e
puts e
Expand Down
6 changes: 3 additions & 3 deletions lib/ruby-debug-ide.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def cleanup_backtrace(backtrace)
attr_reader :interface
# protocol extensions
attr_accessor :catchpoint_deleted_event, :value_as_nested_element
attr_accessor :server_mode
attr_accessor :skip_wait_for_start


#
Expand Down Expand Up @@ -100,8 +100,8 @@ def prepare_debugger(options)

# wait for 'start' command
@mutex.synchronize do
@proceed.wait(@mutex) unless server_mode
end
@proceed.wait(@mutex)
end unless options.skip_wait_for_start
end

def debug_program(options)
Expand Down
22 changes: 11 additions & 11 deletions lib/ruby-debug-ide/commands/control.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ def help_command

def help(cmd)
%{
q[uit]\texit from debugger,
q[uit]\texit from debugger,
exit\talias to quit
}
end
end
end

class RestartCommand < Command # :nodoc:
self.control = true

Expand All @@ -39,7 +39,7 @@ def regexp
$
/x
end

def execute
if not defined? Debugger::RDEBUG_SCRIPT or not defined? Debugger::ARGV
print "We are not in a context we can restart from.\n"
Expand All @@ -64,7 +64,7 @@ def help_command

def help(cmd)
%{
restart|R [args]
restart|R [args]
Restart the program. This is is a re-exec - all debugger state
is lost. If command arguments are passed those are used.
}
Expand All @@ -78,7 +78,7 @@ class StartCommand < Command # :nodoc:
def regexp
/^\s*(start)(\s+ \S+ .*)?$/x
end

def execute
@printer.print_debug("Starting: running program script")
Debugger.run_prog_script #Debugger.prog_script_running?
Expand All @@ -102,23 +102,23 @@ class InterruptCommand < Command # :nodoc:
self.event = false
self.control = true
self.need_context = true

def regexp
/^\s*i(?:nterrupt)?\s*$/
end

def execute
unless Debugger.interrupt_last
context = Debugger.thread_context(Thread.main)
context.interrupt
end
end

class << self
def help_command
'interrupt'
end

def help(cmd)
%{
i[nterrupt]\tinterrupt the program
Expand All @@ -137,12 +137,12 @@ def regexp

def execute
Debugger.require_multiprocess
interface.command_queue << "finish" if Debugger.server_mode
interface.command_queue << "finish" if Debugger.skip_wait_for_start
Debugger.stop
Debugger.interface.close
Debugger::MultiProcess.undo_monkey
Debugger.control_thread = nil
Thread.current.exit unless Debugger.server_mode #@control_thread is a current thread
Thread.current.exit unless Debugger.skip_wait_for_start #@control_thread is a current thread
end

class << self
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby-debug-ide/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Debugger
IDE_VERSION='0.7.0.beta6'
IDE_VERSION='0.7.1.beta1'
end
3 changes: 1 addition & 2 deletions lib/ruby-debug-ide/xml_printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,7 @@ def print_load_result(file, exception = nil)
end

def print_element(name, additional_tags = nil)
additional_tags_presentation = additional_tags.nil? ? ''
: additional_tags.map {|tag, value| " #{tag}=\"#{value}\""}.reduce(:+)
additional_tags_presentation = additional_tags.nil? ? '' : additional_tags.map {|tag, value| " #{tag}=\"#{value}\""}.reduce(:+)

print("<#{name}#{additional_tags_presentation}>")
begin
Expand Down
Loading

0 comments on commit 6d12ed9

Please sign in to comment.