debugger2 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.travis.yml +3 -0
- data/AUTHORS +10 -0
- data/CHANGELOG.md +65 -0
- data/CONTRIBUTING.md +1 -0
- data/Gemfile +3 -0
- data/LICENSE +23 -0
- data/OLDER_CHANGELOG +334 -0
- data/OLD_CHANGELOG +5655 -0
- data/OLD_README +122 -0
- data/README.md +108 -0
- data/Rakefile +78 -0
- data/bin/rdebug +397 -0
- data/debugger2.gemspec +29 -0
- data/doc/.cvsignore +42 -0
- data/doc/Makefile.am +63 -0
- data/doc/emacs-notes.txt +38 -0
- data/doc/hanoi.rb +35 -0
- data/doc/primes.rb +28 -0
- data/doc/rdebug-emacs.texi +1030 -0
- data/doc/ruby-debug.texi +3791 -0
- data/doc/test-tri2.rb +18 -0
- data/doc/tri3.rb +8 -0
- data/doc/triangle.rb +12 -0
- data/emacs/Makefile.am +130 -0
- data/emacs/rdebug-annotate.el +385 -0
- data/emacs/rdebug-breaks.el +407 -0
- data/emacs/rdebug-cmd.el +92 -0
- data/emacs/rdebug-core.el +502 -0
- data/emacs/rdebug-dbg.el +62 -0
- data/emacs/rdebug-error.el +79 -0
- data/emacs/rdebug-fns.el +111 -0
- data/emacs/rdebug-frames.el +230 -0
- data/emacs/rdebug-gud.el +242 -0
- data/emacs/rdebug-help.el +104 -0
- data/emacs/rdebug-info.el +83 -0
- data/emacs/rdebug-layouts.el +180 -0
- data/emacs/rdebug-locring.el +118 -0
- data/emacs/rdebug-output.el +106 -0
- data/emacs/rdebug-regexp.el +118 -0
- data/emacs/rdebug-secondary.el +260 -0
- data/emacs/rdebug-shortkey.el +175 -0
- data/emacs/rdebug-source.el +568 -0
- data/emacs/rdebug-track.el +392 -0
- data/emacs/rdebug-varbuf.el +150 -0
- data/emacs/rdebug-vars.el +125 -0
- data/emacs/rdebug-watch.el +132 -0
- data/emacs/rdebug.el +326 -0
- data/emacs/test/elk-test.el +242 -0
- data/emacs/test/test-annotate.el +103 -0
- data/emacs/test/test-cmd.el +116 -0
- data/emacs/test/test-core.el +104 -0
- data/emacs/test/test-fns.el +65 -0
- data/emacs/test/test-frames.el +62 -0
- data/emacs/test/test-gud.el +35 -0
- data/emacs/test/test-indent.el +58 -0
- data/emacs/test/test-regexp.el +144 -0
- data/emacs/test/test-shortkey.el +61 -0
- data/ext/ruby_debug/breakpoint.c +630 -0
- data/ext/ruby_debug/extconf.rb +11 -0
- data/ext/ruby_debug/ruby_debug.c +2203 -0
- data/ext/ruby_debug/ruby_debug.h +151 -0
- data/lib/debugger.rb +5 -0
- data/lib/debugger/version.rb +5 -0
- data/lib/debugger2.rb +6 -0
- data/lib/ruby-debug-base.rb +307 -0
- data/lib/ruby-debug.rb +176 -0
- data/lib/ruby-debug/command.rb +227 -0
- data/lib/ruby-debug/commands/breakpoints.rb +153 -0
- data/lib/ruby-debug/commands/catchpoint.rb +55 -0
- data/lib/ruby-debug/commands/condition.rb +49 -0
- data/lib/ruby-debug/commands/continue.rb +38 -0
- data/lib/ruby-debug/commands/control.rb +107 -0
- data/lib/ruby-debug/commands/display.rb +120 -0
- data/lib/ruby-debug/commands/edit.rb +48 -0
- data/lib/ruby-debug/commands/enable.rb +202 -0
- data/lib/ruby-debug/commands/eval.rb +176 -0
- data/lib/ruby-debug/commands/finish.rb +42 -0
- data/lib/ruby-debug/commands/frame.rb +301 -0
- data/lib/ruby-debug/commands/help.rb +56 -0
- data/lib/ruby-debug/commands/info.rb +467 -0
- data/lib/ruby-debug/commands/irb.rb +123 -0
- data/lib/ruby-debug/commands/jump.rb +66 -0
- data/lib/ruby-debug/commands/kill.rb +51 -0
- data/lib/ruby-debug/commands/list.rb +94 -0
- data/lib/ruby-debug/commands/method.rb +84 -0
- data/lib/ruby-debug/commands/quit.rb +39 -0
- data/lib/ruby-debug/commands/reload.rb +40 -0
- data/lib/ruby-debug/commands/save.rb +90 -0
- data/lib/ruby-debug/commands/set.rb +223 -0
- data/lib/ruby-debug/commands/show.rb +247 -0
- data/lib/ruby-debug/commands/skip.rb +35 -0
- data/lib/ruby-debug/commands/source.rb +36 -0
- data/lib/ruby-debug/commands/stepping.rb +81 -0
- data/lib/ruby-debug/commands/threads.rb +189 -0
- data/lib/ruby-debug/commands/tmate.rb +36 -0
- data/lib/ruby-debug/commands/trace.rb +57 -0
- data/lib/ruby-debug/commands/variables.rb +199 -0
- data/lib/ruby-debug/debugger.rb +5 -0
- data/lib/ruby-debug/helper.rb +69 -0
- data/lib/ruby-debug/interface.rb +232 -0
- data/lib/ruby-debug/processor.rb +474 -0
- data/man/rdebug.1 +241 -0
- data/old_scripts/Makefile.am +14 -0
- data/old_scripts/README.md +2 -0
- data/old_scripts/autogen.sh +4 -0
- data/old_scripts/configure.ac +12 -0
- data/old_scripts/rdbg.rb +33 -0
- data/old_scripts/runner.sh +7 -0
- data/old_scripts/svn2cl_usermap +3 -0
- data/test/.cvsignore +1 -0
- data/test/breakpoints_test.rb +366 -0
- data/test/conditions_test.rb +77 -0
- data/test/continue_test.rb +28 -0
- data/test/display_test.rb +143 -0
- data/test/edit_test.rb +55 -0
- data/test/eval_test.rb +94 -0
- data/test/examples/breakpoint1.rb +15 -0
- data/test/examples/breakpoint2.rb +7 -0
- data/test/examples/conditions.rb +4 -0
- data/test/examples/continue.rb +4 -0
- data/test/examples/display.rb +5 -0
- data/test/examples/edit.rb +3 -0
- data/test/examples/edit2.rb +3 -0
- data/test/examples/eval.rb +4 -0
- data/test/examples/finish.rb +20 -0
- data/test/examples/frame.rb +31 -0
- data/test/examples/help.rb +2 -0
- data/test/examples/info.rb +48 -0
- data/test/examples/info2.rb +3 -0
- data/test/examples/irb.rb +6 -0
- data/test/examples/jump.rb +14 -0
- data/test/examples/kill.rb +2 -0
- data/test/examples/list.rb +12 -0
- data/test/examples/method.rb +15 -0
- data/test/examples/post_mortem.rb +19 -0
- data/test/examples/quit.rb +2 -0
- data/test/examples/reload.rb +6 -0
- data/test/examples/restart.rb +6 -0
- data/test/examples/save.rb +3 -0
- data/test/examples/set.rb +3 -0
- data/test/examples/set_annotate.rb +12 -0
- data/test/examples/settings.rb +1 -0
- data/test/examples/show.rb +2 -0
- data/test/examples/source.rb +3 -0
- data/test/examples/stepping.rb +21 -0
- data/test/examples/thread.rb +32 -0
- data/test/examples/tmate.rb +10 -0
- data/test/examples/trace.rb +7 -0
- data/test/examples/trace_threads.rb +20 -0
- data/test/examples/variables.rb +26 -0
- data/test/finish_test.rb +49 -0
- data/test/frame_test.rb +140 -0
- data/test/help_test.rb +51 -0
- data/test/info_test.rb +326 -0
- data/test/irb_test.rb +82 -0
- data/test/jump_test.rb +70 -0
- data/test/kill_test.rb +49 -0
- data/test/list_test.rb +147 -0
- data/test/method_test.rb +72 -0
- data/test/post_mortem_test.rb +25 -0
- data/test/quit_test.rb +56 -0
- data/test/reload_test.rb +47 -0
- data/test/restart_test.rb +145 -0
- data/test/save_test.rb +94 -0
- data/test/set_test.rb +183 -0
- data/test/show_test.rb +294 -0
- data/test/source_test.rb +46 -0
- data/test/stepping_test.rb +122 -0
- data/test/support/breakpoint.rb +12 -0
- data/test/support/context.rb +14 -0
- data/test/support/matchers.rb +67 -0
- data/test/support/mocha_extensions.rb +71 -0
- data/test/support/processor.rb +7 -0
- data/test/support/test_dsl.rb +206 -0
- data/test/support/test_interface.rb +66 -0
- data/test/test_helper.rb +9 -0
- data/test/thread_test.rb +124 -0
- data/test/tmate_test.rb +45 -0
- data/test/trace_test.rb +156 -0
- data/test/variables_test.rb +116 -0
- metadata +319 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
debugger
|
2
|
+
|
3
|
+
@should_break = false
|
4
|
+
|
5
|
+
t = Thread.new do
|
6
|
+
while !@should_break
|
7
|
+
A.new.a
|
8
|
+
sleep 0.1
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class A
|
13
|
+
def a
|
14
|
+
b
|
15
|
+
end
|
16
|
+
def b
|
17
|
+
c
|
18
|
+
2
|
19
|
+
end
|
20
|
+
def c
|
21
|
+
d('a')
|
22
|
+
3
|
23
|
+
end
|
24
|
+
def d(e)
|
25
|
+
5
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
A.new.a
|
30
|
+
@should_break = true
|
31
|
+
t.join
|
@@ -0,0 +1,48 @@
|
|
1
|
+
debugger
|
2
|
+
def bla(a, b)
|
3
|
+
a + b
|
4
|
+
end
|
5
|
+
va = 2
|
6
|
+
vb = 3
|
7
|
+
vc = 4
|
8
|
+
vd = 5
|
9
|
+
ve = 6
|
10
|
+
bla("a" * 30, "b")
|
11
|
+
|
12
|
+
class A
|
13
|
+
def initialize
|
14
|
+
@foo = "bar"
|
15
|
+
@bla = "blabla"
|
16
|
+
end
|
17
|
+
|
18
|
+
def a
|
19
|
+
a = "1" * 30
|
20
|
+
b = 2
|
21
|
+
@foo
|
22
|
+
end
|
23
|
+
|
24
|
+
def c
|
25
|
+
a = BasicObject.new
|
26
|
+
a
|
27
|
+
end
|
28
|
+
|
29
|
+
def b
|
30
|
+
a
|
31
|
+
e = "%.2f"
|
32
|
+
e
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
@break = false
|
37
|
+
t1 = Thread.new do
|
38
|
+
while true
|
39
|
+
break if @break
|
40
|
+
sleep 0.02
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
A.new.b
|
45
|
+
A.new.a
|
46
|
+
A.new.c
|
47
|
+
@break = true
|
48
|
+
t1.join
|
@@ -0,0 +1 @@
|
|
1
|
+
debugger
|
@@ -0,0 +1,32 @@
|
|
1
|
+
debugger
|
2
|
+
class ThreadExample
|
3
|
+
def initialize
|
4
|
+
Thread.main[:should_break] = false
|
5
|
+
end
|
6
|
+
|
7
|
+
def launch
|
8
|
+
@t1 = Thread.new do
|
9
|
+
while true
|
10
|
+
break if Thread.main[:should_break]
|
11
|
+
sleep 0.02
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
@t2 = Thread.new do
|
16
|
+
while true
|
17
|
+
sleep 0.02
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
@t1.join
|
22
|
+
Thread.main[:should_break]
|
23
|
+
end
|
24
|
+
|
25
|
+
def kill
|
26
|
+
@t2.kill
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
t = ThreadExample.new
|
31
|
+
t.launch
|
32
|
+
t.kill
|
@@ -0,0 +1,26 @@
|
|
1
|
+
debugger
|
2
|
+
class VariablesExample
|
3
|
+
SOMECONST = 'foo' unless defined?(SOMECONST)
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
$glob = 100
|
7
|
+
@inst_a = 1
|
8
|
+
@inst_b = 2
|
9
|
+
@inst_c = "1" * 40
|
10
|
+
@inst_d = BasicObject.new
|
11
|
+
@@class_c = 3
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
a = 4
|
16
|
+
b = [1, 2, 3].map do |i|
|
17
|
+
a * i
|
18
|
+
end
|
19
|
+
b
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
v = VariablesExample.new
|
25
|
+
v.run
|
26
|
+
v
|
data/test/finish_test.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Finish Command" do
|
4
|
+
include TestDsl
|
5
|
+
|
6
|
+
it "must stop at the next frame by default" do
|
7
|
+
enter 'break 16', 'cont', 'finish'
|
8
|
+
debug_file('finish') { state.line.must_equal 13 }
|
9
|
+
end
|
10
|
+
|
11
|
+
it "must stop at the #0 frame by default" do
|
12
|
+
enter 'break 16', 'cont', 'finish 0'
|
13
|
+
debug_file('finish') { state.line.must_equal 13 }
|
14
|
+
end
|
15
|
+
|
16
|
+
it "must stop at the specified frame" do
|
17
|
+
enter 'break 16', 'cont', 'finish 1'
|
18
|
+
debug_file('finish') { state.line.must_equal 9 }
|
19
|
+
end
|
20
|
+
|
21
|
+
it "must stop at the next frame if the current frame was changed" do
|
22
|
+
enter 'break 16', 'cont', 'up', 'finish'
|
23
|
+
debug_file('finish') { state.line.must_equal 9 }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "not a number is specified for frame" do
|
27
|
+
before { enter 'break 16', 'cont', 'finish foo' }
|
28
|
+
|
29
|
+
it "must show an error" do
|
30
|
+
debug_file('finish')
|
31
|
+
check_output_includes "Finish argument 'foo' needs to be a number."
|
32
|
+
end
|
33
|
+
|
34
|
+
it "must be on the same line" do
|
35
|
+
debug_file('finish') { state.line.must_equal 16 }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
describe "Post Mortem" do
|
41
|
+
it "must not work in post-mortem mode"
|
42
|
+
0.times do
|
43
|
+
enter 'cont', 'finish'
|
44
|
+
debug_file "post_mortem"
|
45
|
+
check_output_includes 'Unknown command: "finish". Try "help".', interface.error_queue
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/test/frame_test.rb
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
describe "Frame Command" do
|
4
|
+
include TestDsl
|
5
|
+
|
6
|
+
it "must go up" do
|
7
|
+
enter 'break 25', 'cont', 'up'
|
8
|
+
debug_file('frame') { state.line.must_equal 21 }
|
9
|
+
end
|
10
|
+
|
11
|
+
it "must go up by specific number of frames" do
|
12
|
+
enter 'break 25', 'cont', 'up 2'
|
13
|
+
debug_file('frame') { state.line.must_equal 17 }
|
14
|
+
end
|
15
|
+
|
16
|
+
it "must go down" do
|
17
|
+
enter 'break 25', 'cont', 'up', 'down'
|
18
|
+
debug_file('frame') { state.line.must_equal 25 }
|
19
|
+
end
|
20
|
+
|
21
|
+
it "must go down by specific number of frames" do
|
22
|
+
enter 'break 25', 'cont', 'up 3', 'down 2'
|
23
|
+
debug_file('frame') { state.line.must_equal 21 }
|
24
|
+
end
|
25
|
+
|
26
|
+
it "must set frame" do
|
27
|
+
enter 'break 25', 'cont', 'frame 2'
|
28
|
+
debug_file('frame') { state.line.must_equal 17 }
|
29
|
+
end
|
30
|
+
|
31
|
+
it "must set frame to the first one by default" do
|
32
|
+
enter 'break 25', 'cont', 'up', 'frame'
|
33
|
+
debug_file('frame') { state.line.must_equal 25 }
|
34
|
+
end
|
35
|
+
|
36
|
+
it "must print current stack frame when without arguments" do
|
37
|
+
enter 'break 25', 'cont', 'up', 'frame'
|
38
|
+
debug_file('frame')
|
39
|
+
check_output_includes "#0 ", "A.d(e#String)"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "must set frame to the first one" do
|
43
|
+
enter 'break 25', 'cont', 'up', 'frame 0'
|
44
|
+
debug_file('frame') { state.line.must_equal 25 }
|
45
|
+
end
|
46
|
+
|
47
|
+
it "must set frame to the last one" do
|
48
|
+
enter 'break 25', 'cont', 'frame -1'
|
49
|
+
debug_file('frame') { state.line.must_equal 73 }
|
50
|
+
end
|
51
|
+
|
52
|
+
it "must not set frame if the frame number is too low" do
|
53
|
+
enter 'break 25', 'cont', 'down'
|
54
|
+
debug_file('frame') { state.line.must_equal 25 }
|
55
|
+
check_output_includes "Adjusting would put us beyond the newest (innermost) frame.", interface.error_queue
|
56
|
+
end
|
57
|
+
|
58
|
+
it "must not set frame if the frame number is too high" do
|
59
|
+
enter 'break 25', 'cont', 'up 100'
|
60
|
+
debug_file('frame') { state.line.must_equal 25 }
|
61
|
+
check_output_includes "Adjusting would put us beyond the oldest (initial) frame.", interface.error_queue
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "full path settings" do
|
65
|
+
temporary_change_hash_value(Debugger::Command.settings, :full_path, false)
|
66
|
+
|
67
|
+
def short_path(fullpath)
|
68
|
+
separator = File::ALT_SEPARATOR || File::SEPARATOR
|
69
|
+
"...#{separator}" + fullpath.split(separator)[-3..-1].join(separator)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "must display current backtrace with full path = true" do
|
73
|
+
enter 'set fullpath', 'break 25', 'cont', 'where'
|
74
|
+
debug_file('frame')
|
75
|
+
check_output_includes(
|
76
|
+
"-->", "#0", "A.d(e#String)", "at line #{fullpath('frame')}:25",
|
77
|
+
"#1", "A.c", "at line #{fullpath('frame')}:21"
|
78
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "must display current backtrace with full path = false" do
|
82
|
+
enter 'set nofullpath', 'break 25', 'cont', 'where'
|
83
|
+
debug_file('frame')
|
84
|
+
check_output_includes(
|
85
|
+
"-->", "#0", "A.d(e#String)", "at line #{short_path(fullpath('frame'))}:25",
|
86
|
+
"#1", "A.c", "at line #{short_path(fullpath('frame'))}:21"
|
87
|
+
)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe "display backtrace with callstyle" do
|
92
|
+
temporary_change_hash_value(Debugger::Command.settings, :callstyle, :last)
|
93
|
+
|
94
|
+
it "must display current backtrace" do
|
95
|
+
enter 'set callstyle last', 'break 25', 'cont', 'where'
|
96
|
+
debug_file('frame')
|
97
|
+
check_output_includes(
|
98
|
+
"-->", "#0", "A.d(e#String)", "at line #{fullpath('frame')}:25",
|
99
|
+
"#1", "A.c", "at line #{fullpath('frame')}:21",
|
100
|
+
"#2", "A.b", "at line #{fullpath('frame')}:17",
|
101
|
+
"#3", "A.a", "at line #{fullpath('frame')}:14"
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
it "must display current backtrace" do
|
106
|
+
enter 'set callstyle short', 'break 25', 'cont', 'where'
|
107
|
+
debug_file('frame')
|
108
|
+
check_output_includes(
|
109
|
+
"-->", "#0", "d(e)", "at line #{fullpath('frame')}:25",
|
110
|
+
"#1", "c", "at line #{fullpath('frame')}:21",
|
111
|
+
"#2", "b", "at line #{fullpath('frame')}:17",
|
112
|
+
"#3", "a", "at line #{fullpath('frame')}:14"
|
113
|
+
)
|
114
|
+
end
|
115
|
+
|
116
|
+
# NOTE: We also have support of 'tracked' callstyle in the code, but by some reason
|
117
|
+
# it is not allowed to be set by the 'set' command
|
118
|
+
it "must not set 'tracked' callstyle" do
|
119
|
+
enter 'set callstyle tracked'
|
120
|
+
debug_file('frame')
|
121
|
+
check_output_includes "Invalid call style tracked. Should be one of: 'short' or 'last'."
|
122
|
+
Debugger::Command.settings[:callstyle].must_equal :last
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
it "must change frame in another thread"
|
127
|
+
it "must not change frame in another thread if specified thread doesn't exist"
|
128
|
+
|
129
|
+
describe "Post Mortem" do
|
130
|
+
# TODO: This test fails with "Segmentation fault". Probably need to fix it somehow, or forbid this
|
131
|
+
# command in the post mortem mode. Seems like state.context.frame_file and state.context.frame_line
|
132
|
+
# cause that.
|
133
|
+
it "must work in post-mortem mode"
|
134
|
+
# enter 'cont', "frame"
|
135
|
+
# debug_file "post_mortem"
|
136
|
+
# pi
|
137
|
+
#end
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|