ruby-debug-ide 0.4.3 → 0.4.4
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.
- data/CHANGES +75 -0
- data/ChangeLog +381 -0
- data/ChangeLog.archive +1073 -0
- data/MIT-LICENSE +24 -0
- data/Rakefile +110 -0
- data/lib/ruby-debug.rb +6 -2
- data/test/rd_basic_test.rb +10 -0
- data/test/rd_catchpoint_test.rb +20 -0
- data/test/rd_condition_test.rb +11 -0
- data/test/rd_enable_disable_test.rb +43 -0
- data/test/rd_inspect_test.rb +11 -0
- data/test/rd_stepping_breakpoints_test.rb +36 -0
- data/test/rd_test_base.rb +44 -0
- data/test/rd_threads_and_frames_test.rb +11 -0
- data/test/rd_variables_test.rb +11 -0
- data/test/ruby-debug/xml_printer_test.rb +105 -0
- metadata +20 -4
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
The file lib/classic-debug.rb is based on the debug.rb file from Ruby
|
|
2
|
+
project.
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2007-2008, debug-commons team
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
7
|
+
a copy of this software and associated documentation files (the
|
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
12
|
+
the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be
|
|
15
|
+
included in all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
24
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
|
|
3
|
+
require 'rake/gempackagetask'
|
|
4
|
+
require 'rake/rdoctask'
|
|
5
|
+
require 'rake/testtask'
|
|
6
|
+
require 'date'
|
|
7
|
+
|
|
8
|
+
desc 'Default: run unit tests.'
|
|
9
|
+
task :default => [:test]
|
|
10
|
+
|
|
11
|
+
# ------- Default Package ----------
|
|
12
|
+
RUBY_DEBUG_BASE_VERSION = "0.10.3"
|
|
13
|
+
RUBY_DEBUG_IDE_VERSION = "0.4.4"
|
|
14
|
+
|
|
15
|
+
FILES = FileList[
|
|
16
|
+
'CHANGES',
|
|
17
|
+
'ChangeLog',
|
|
18
|
+
'ChangeLog.archive',
|
|
19
|
+
'MIT-LICENSE',
|
|
20
|
+
'Rakefile',
|
|
21
|
+
'bin/*',
|
|
22
|
+
'lib/**/*',
|
|
23
|
+
'test/**/*'
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
ide_spec = Gem::Specification.new do |spec|
|
|
27
|
+
spec.name = "ruby-debug-ide"
|
|
28
|
+
|
|
29
|
+
spec.homepage = "http://rubyforge.org/projects/debug-commons/"
|
|
30
|
+
spec.summary = "IDE interface for ruby-debug."
|
|
31
|
+
spec.description = <<-EOF
|
|
32
|
+
An interface which glues ruby-debug to IDEs like Eclipse (RDT) and NetBeans.
|
|
33
|
+
EOF
|
|
34
|
+
|
|
35
|
+
spec.version = RUBY_DEBUG_IDE_VERSION
|
|
36
|
+
|
|
37
|
+
spec.author = "Markus Barchfeld, Martin Krauskopf"
|
|
38
|
+
spec.email = "rubyeclipse-dev-list@sourceforge.net"
|
|
39
|
+
spec.platform = Gem::Platform::RUBY
|
|
40
|
+
spec.require_path = "lib"
|
|
41
|
+
spec.bindir = "bin"
|
|
42
|
+
spec.executables = ["rdebug-ide"]
|
|
43
|
+
spec.autorequire = "ruby-debug-base"
|
|
44
|
+
spec.files = FILES.to_a
|
|
45
|
+
|
|
46
|
+
spec.required_ruby_version = '>= 1.8.2'
|
|
47
|
+
spec.date = DateTime.now
|
|
48
|
+
spec.rubyforge_project = 'debug-commons'
|
|
49
|
+
spec.add_dependency('ruby-debug-base', "~> #{RUBY_DEBUG_BASE_VERSION}.0")
|
|
50
|
+
|
|
51
|
+
# rdoc
|
|
52
|
+
spec.has_rdoc = false
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Rake task to build the default package
|
|
56
|
+
Rake::GemPackageTask.new(ide_spec) do |pkg|
|
|
57
|
+
pkg.need_tar = true
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Unit tests
|
|
61
|
+
Rake::TestTask.new do |t|
|
|
62
|
+
t.libs << "test"
|
|
63
|
+
t.libs << "test-base"
|
|
64
|
+
t.pattern = 'test/*_test.rb'
|
|
65
|
+
t.verbose = true
|
|
66
|
+
t.warning = false
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
desc "Create a GNU-style ChangeLog via svn2cl"
|
|
71
|
+
task :ChangeLog do
|
|
72
|
+
system("svn2cl --authors=svn2cl_usermap svn://rubyforge.org/var/svn/debug-commons/ruby-debug-ide/trunk -o ChangeLog")
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
#desc "Publish ruby-debug to RubyForge."
|
|
76
|
+
#task :publish do
|
|
77
|
+
# require 'rake/contrib/sshpublisher'
|
|
78
|
+
#
|
|
79
|
+
# # Get ruby-debug path
|
|
80
|
+
# ruby_debug_path = File.expand_path(File.dirname(__FILE__))
|
|
81
|
+
#
|
|
82
|
+
# publisher = Rake::SshDirPublisher.new("kent@rubyforge.org",
|
|
83
|
+
# "/var/www/gforge-projects/ruby-debug", ruby_debug_path)
|
|
84
|
+
#end
|
|
85
|
+
#
|
|
86
|
+
#desc "Clear temp files"
|
|
87
|
+
#task :clean do
|
|
88
|
+
# cd "ext" do
|
|
89
|
+
# if File.exists?("Makefile")
|
|
90
|
+
# sh "make clean"
|
|
91
|
+
# rm "Makefile"
|
|
92
|
+
# end
|
|
93
|
+
# end
|
|
94
|
+
#end
|
|
95
|
+
#
|
|
96
|
+
## --------- RDoc Documentation ------
|
|
97
|
+
#desc "Generate rdoc documentation"
|
|
98
|
+
#Rake::RDocTask.new("rdoc") do |rdoc|
|
|
99
|
+
# rdoc.rdoc_dir = 'doc'
|
|
100
|
+
# rdoc.title = "ruby-debug"
|
|
101
|
+
# # Show source inline with line numbers
|
|
102
|
+
# rdoc.options << "--inline-source" << "--line-numbers"
|
|
103
|
+
# # Make the readme file the start page for the generated html
|
|
104
|
+
# rdoc.options << '--main' << 'README'
|
|
105
|
+
# rdoc.rdoc_files.include('bin/**/*',
|
|
106
|
+
# 'lib/**/*.rb',
|
|
107
|
+
# 'ext/**/ruby_debug.c',
|
|
108
|
+
# 'README',
|
|
109
|
+
# 'LICENSE')
|
|
110
|
+
#end
|
data/lib/ruby-debug.rb
CHANGED
|
@@ -98,7 +98,11 @@ module Debugger
|
|
|
98
98
|
@proceed.wait(@mutex)
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
debug_load(Debugger::PROG_SCRIPT, options.stop, options.load_mode)
|
|
101
|
+
bt = debug_load(Debugger::PROG_SCRIPT, options.stop, options.load_mode)
|
|
102
|
+
if bt
|
|
103
|
+
$stderr.print bt.backtrace.map{|l| "\t#{l}"}.join("\n"), "\n"
|
|
104
|
+
$stderr.print "Uncaught exception: #{bt}\n"
|
|
105
|
+
end
|
|
102
106
|
end
|
|
103
107
|
|
|
104
108
|
def run_prog_script
|
|
@@ -115,7 +119,7 @@ module Debugger
|
|
|
115
119
|
unless RUBY_PLATFORM =~ /darwin/i # Mac OS X seems to have problem with 'localhost'
|
|
116
120
|
host ||= 'localhost' # nil does not seem to work for IPv6, localhost does
|
|
117
121
|
end
|
|
118
|
-
$stderr.printf "Fast Debugger (ruby-debug-ide 0.4.
|
|
122
|
+
$stderr.printf "Fast Debugger (ruby-debug-ide 0.4.4) listens on #{host}:#{port}\n"
|
|
119
123
|
server = TCPServer.new(host, port)
|
|
120
124
|
while (session = server.accept)
|
|
121
125
|
begin
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'rd_test_base'
|
|
4
|
+
|
|
5
|
+
class RDCatchpointTest < RDTestBase
|
|
6
|
+
|
|
7
|
+
def test_catchpoint_basics
|
|
8
|
+
create_socket ['sleep 0.01', '5/0', 'sleep 0.01']
|
|
9
|
+
run_to_line(1)
|
|
10
|
+
send_next
|
|
11
|
+
assert_suspension(@test_path, 2, 1)
|
|
12
|
+
send_ruby('catch ZeroDivisionError')
|
|
13
|
+
assert_catchpoint_set('ZeroDivisionError')
|
|
14
|
+
send_next
|
|
15
|
+
assert_exception(@test_path, 2, 'ZeroDivisionError')
|
|
16
|
+
send_next
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
20
|
+
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'rd_test_base'
|
|
4
|
+
|
|
5
|
+
class RDEnableDisableTest < RDTestBase
|
|
6
|
+
|
|
7
|
+
def test_enable_disable_basics
|
|
8
|
+
create_socket ['1.upto(10) do', 'sleep 0.01', 'sleep 0.01', 'end']
|
|
9
|
+
|
|
10
|
+
send_test_breakpoint(2)
|
|
11
|
+
assert_breakpoint_added_no(1)
|
|
12
|
+
send_test_breakpoint(3)
|
|
13
|
+
assert_breakpoint_added_no(2)
|
|
14
|
+
|
|
15
|
+
start_debugger
|
|
16
|
+
assert_test_breakpoint(2)
|
|
17
|
+
send_cont
|
|
18
|
+
assert_test_breakpoint(3)
|
|
19
|
+
send_cont
|
|
20
|
+
assert_test_breakpoint(2)
|
|
21
|
+
send_ruby('disable 2')
|
|
22
|
+
assert_breakpoint_disabled(2)
|
|
23
|
+
send_cont
|
|
24
|
+
assert_test_breakpoint(2)
|
|
25
|
+
send_cont
|
|
26
|
+
assert_test_breakpoint(2)
|
|
27
|
+
send_ruby('enable 2')
|
|
28
|
+
assert_breakpoint_enabled(2)
|
|
29
|
+
send_cont
|
|
30
|
+
assert_test_breakpoint(3)
|
|
31
|
+
send_cont
|
|
32
|
+
assert_test_breakpoint(2)
|
|
33
|
+
send_cont
|
|
34
|
+
assert_test_breakpoint(3)
|
|
35
|
+
send_ruby('disable 1')
|
|
36
|
+
assert_breakpoint_disabled(1)
|
|
37
|
+
send_ruby('disable 2')
|
|
38
|
+
assert_breakpoint_disabled(2)
|
|
39
|
+
send_cont
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'rd_test_base'
|
|
4
|
+
require 'stepping_breakpoints_test'
|
|
5
|
+
|
|
6
|
+
class RDSteppingAndBreakpointsTest < RDTestBase
|
|
7
|
+
|
|
8
|
+
include SteppingAndBreakpointsTest
|
|
9
|
+
|
|
10
|
+
def test_hit_breakpoint_while_stepping_over
|
|
11
|
+
create_test2 ["class Test2", "def print", "puts 'XX'", "puts 'XX'", "end", "end"]
|
|
12
|
+
create_socket ["require 'test2.rb'", "Test2.new.print", "puts 'a'"]
|
|
13
|
+
send_ruby("b #{@test2_name}:4")
|
|
14
|
+
assert_breakpoint_added_no(1)
|
|
15
|
+
run_to_line(2)
|
|
16
|
+
send_next
|
|
17
|
+
assert_breakpoint(@test2_name, 4)
|
|
18
|
+
send_cont
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_breakpoint_and_continue_from_other_file
|
|
22
|
+
create_test2 ["class Test2", "def print12", "puts 'one'","puts 'two'", "end", "end"]
|
|
23
|
+
create_socket ["require 'test2.rb'", "Test2.new.print12", "puts 'three'"]
|
|
24
|
+
send_test_breakpoint(2)
|
|
25
|
+
assert_breakpoint_added_no(1)
|
|
26
|
+
send_ruby("b #{@test2_name}:4")
|
|
27
|
+
assert_breakpoint_added_no(2)
|
|
28
|
+
start_debugger
|
|
29
|
+
assert_test_breakpoint(2)
|
|
30
|
+
send_next # test:1 -> test2:4
|
|
31
|
+
assert_breakpoint(@test2_name, 4)
|
|
32
|
+
send_cont # test2:4 -> test:3
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "test-base")
|
|
4
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
|
5
|
+
|
|
6
|
+
require 'test_base'
|
|
7
|
+
|
|
8
|
+
class RDTestBase < TestBase
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
super
|
|
12
|
+
@rdebug_ide = config_load('rdebug_ide', true) || find_rdebug_ide
|
|
13
|
+
unless @rdebug_ide and File.exist?(@rdebug_ide)
|
|
14
|
+
@fast_fail = true
|
|
15
|
+
assert_not_nil(@rdebug_ide, "Cannot find rdebug-ide executable. " +
|
|
16
|
+
"Neither set in the config(.private).yaml nor found on the PATH")
|
|
17
|
+
assert(false, "#{@rdebug_ide} exist")
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def debug_command(script, port)
|
|
22
|
+
cmd = "#{interpreter}"
|
|
23
|
+
cmd << " --debug" if jruby?
|
|
24
|
+
cmd << " -J-Xdebug -J-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y" if jruby? and debug_jruby?
|
|
25
|
+
cmd << " -I '#{File.dirname(script)}' #{@rdebug_ide} _0.4.4_" +
|
|
26
|
+
(@verbose_server ? " -d" : "") +
|
|
27
|
+
" -p #{port} -- '#{script}'"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def start_debugger
|
|
31
|
+
send_ruby("start")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def find_rdebug_ide
|
|
37
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |dir|
|
|
38
|
+
rdebug_ide = File.join(dir, 'rdebug-ide')
|
|
39
|
+
return rdebug_ide if File.exists?(rdebug_ide)
|
|
40
|
+
end
|
|
41
|
+
nil
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
|
2
|
+
|
|
3
|
+
require 'test/unit'
|
|
4
|
+
require 'ruby-debug'
|
|
5
|
+
|
|
6
|
+
class XmlPrinterTest < Test::Unit::TestCase
|
|
7
|
+
|
|
8
|
+
def teardown
|
|
9
|
+
Debugger.xml_debug = false
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_print_msg
|
|
13
|
+
interface = MockInterface.new
|
|
14
|
+
printer = Debugger::XmlPrinter.new(interface)
|
|
15
|
+
printer.print_msg('%s test', 'message')
|
|
16
|
+
assert_equal(['<message>message test</message>'], interface.data)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_print_msg_with_debug
|
|
20
|
+
Debugger.xml_debug = true
|
|
21
|
+
interface = MockInterface.new
|
|
22
|
+
printer = Debugger::XmlPrinter.new(interface)
|
|
23
|
+
printer.print_msg('%s test', 'message')
|
|
24
|
+
expected = ["<message>message test</message>"]
|
|
25
|
+
assert_equal(expected, interface.data)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_print_debug
|
|
29
|
+
Debugger.xml_debug = true
|
|
30
|
+
interface = MockInterface.new
|
|
31
|
+
printer = Debugger::XmlPrinter.new(interface)
|
|
32
|
+
printer.print_debug('%s test', 'debug message 1')
|
|
33
|
+
printer.print_debug('%s test', 'debug message 2')
|
|
34
|
+
expected = [
|
|
35
|
+
"<message debug='true'>debug message 1 test</message>",
|
|
36
|
+
"<message debug='true'>debug message 2 test</message>"]
|
|
37
|
+
assert_equal(expected, interface.data)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_print_frames
|
|
41
|
+
interface = MockInterface.new
|
|
42
|
+
printer = Debugger::XmlPrinter.new(interface)
|
|
43
|
+
Debugger.start
|
|
44
|
+
begin
|
|
45
|
+
context = MockContext.new(2)
|
|
46
|
+
printer.print_frames(context, 0)
|
|
47
|
+
ensure
|
|
48
|
+
Debugger.stop
|
|
49
|
+
end
|
|
50
|
+
test_path = File.join(Dir.pwd, 'test.rb')
|
|
51
|
+
expected = [
|
|
52
|
+
"<frames>",
|
|
53
|
+
"<frame no='1' file='#{test_path}' line='0' current='true' />",
|
|
54
|
+
"<frame no='2' file='#{test_path}' line='10' />",
|
|
55
|
+
"</frames>"]
|
|
56
|
+
assert_equal(expected, interface.data)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_print_at_line
|
|
60
|
+
interface = MockInterface.new
|
|
61
|
+
printer = Debugger::XmlPrinter.new(interface)
|
|
62
|
+
Debugger.start
|
|
63
|
+
begin
|
|
64
|
+
printer.print_at_line('test.rb', 1)
|
|
65
|
+
ensure
|
|
66
|
+
Debugger.stop
|
|
67
|
+
end
|
|
68
|
+
test_path = File.join(Dir.pwd, 'test.rb')
|
|
69
|
+
expected = ["<suspended file='#{test_path}' line='1' threadId='1' frames='2'/>"]
|
|
70
|
+
assert_equal(expected, interface.data)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
class MockContext < Debugger::Context
|
|
74
|
+
|
|
75
|
+
attr_accessor :stack_size
|
|
76
|
+
|
|
77
|
+
def initialize(stack_size)
|
|
78
|
+
@stack_size = stack_size
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def frame_file(id)
|
|
82
|
+
"test.rb"
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def frame_line(id)
|
|
86
|
+
id * 10
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
class MockInterface
|
|
92
|
+
|
|
93
|
+
attr_accessor :data
|
|
94
|
+
|
|
95
|
+
def initialize
|
|
96
|
+
@data = []
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def print(*args)
|
|
100
|
+
@data << format(*args)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
end
|