byebug 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.travis.yml +0 -5
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/LICENSE +23 -20
- data/byebug.gemspec +5 -5
- data/ext/byebug/breakpoint.c +102 -134
- data/ext/byebug/byebug.c +110 -64
- data/ext/byebug/byebug.h +2 -3
- data/ext/byebug/context.c +72 -39
- data/lib/byebug.rb +34 -38
- data/lib/byebug/command.rb +19 -24
- data/lib/byebug/commands/breakpoints.rb +11 -12
- data/lib/byebug/commands/catchpoint.rb +1 -1
- data/lib/byebug/commands/control.rb +2 -4
- data/lib/byebug/commands/finish.rb +1 -1
- data/lib/byebug/commands/frame.rb +15 -17
- data/lib/byebug/commands/info.rb +29 -28
- data/lib/byebug/commands/irb.rb +23 -21
- data/lib/byebug/commands/method.rb +4 -4
- data/lib/byebug/commands/reload.rb +8 -6
- data/lib/byebug/commands/set.rb +27 -23
- data/lib/byebug/commands/show.rb +6 -4
- data/lib/byebug/commands/stepping.rb +2 -2
- data/lib/byebug/commands/threads.rb +10 -10
- data/lib/byebug/commands/trace.rb +13 -14
- data/lib/byebug/commands/variables.rb +14 -12
- data/lib/byebug/context.rb +2 -15
- data/lib/byebug/interface.rb +5 -0
- data/lib/byebug/processor.rb +59 -64
- data/lib/byebug/version.rb +2 -1
- data/old_doc/Makefile +20 -0
- data/{man/rdebug.1 → old_doc/byebug.1} +5 -5
- data/old_doc/byebug.html +6178 -0
- data/old_doc/byebug.texi +3775 -0
- data/{doc → old_doc}/hanoi.rb +0 -0
- data/{doc → old_doc}/primes.rb +0 -0
- data/{doc → old_doc}/test-tri2.rb +0 -0
- data/{doc → old_doc}/tri3.rb +0 -0
- data/{doc → old_doc}/triangle.rb +0 -0
- data/test/breakpoints_test.rb +96 -60
- data/test/conditions_test.rb +15 -12
- data/test/examples/info.rb +5 -5
- data/test/examples/stepping.rb +1 -1
- data/test/frame_test.rb +40 -39
- data/test/info_test.rb +105 -96
- data/test/irb_test.rb +66 -61
- data/test/jump_test.rb +18 -9
- data/test/list_test.rb +114 -107
- data/test/restart_test.rb +51 -58
- data/test/save_test.rb +8 -7
- data/test/set_test.rb +8 -11
- data/test/show_test.rb +3 -5
- data/test/stepping_test.rb +43 -53
- data/test/support/context.rb +1 -0
- data/test/support/processor.rb +10 -4
- data/test/support/test_dsl.rb +46 -18
- data/test/support/test_interface.rb +8 -5
- data/test/test_helper.rb +2 -2
- data/test/trace_test.rb +123 -124
- metadata +39 -17
- data/AUTHORS +0 -10
- data/doc/rdebug-emacs.texi +0 -1030
data/test/irb_test.rb
CHANGED
@@ -2,80 +2,85 @@ require_relative 'test_helper'
|
|
2
2
|
|
3
3
|
describe "Irb Command" do
|
4
4
|
include TestDsl
|
5
|
-
before do
|
6
|
-
interface.stubs(:kind_of?).with(Byebug::LocalInterface).returns(true)
|
7
|
-
IRB::Irb.stubs(:new).returns(irb)
|
8
|
-
Signal.trap("SIGINT", "IGNORE")
|
9
|
-
end
|
10
|
-
after do
|
11
|
-
Signal.trap("SIGINT", "DEFAULT")
|
12
|
-
end
|
13
|
-
let(:irb) { stub(context: ->{}) }
|
14
5
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
6
|
+
describe "Irb Command Setup" do
|
7
|
+
before do
|
8
|
+
interface.stubs(:kind_of?).with(Byebug::LocalInterface).returns(true)
|
9
|
+
IRB::Irb.stubs(:new).returns(irb)
|
10
|
+
Signal.trap("SIGINT", "IGNORE")
|
11
|
+
end
|
12
|
+
after do
|
13
|
+
Signal.trap("SIGINT", "DEFAULT")
|
14
|
+
end
|
15
|
+
let(:irb) { stub(context: ->{}) }
|
26
16
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
17
|
+
it "must support next command" do
|
18
|
+
irb.stubs(:eval_input).throws(:IRB_EXIT, :next)
|
19
|
+
enter 'irb'
|
20
|
+
debug_file('irb') { state.line.must_equal 3 }
|
21
|
+
end
|
32
22
|
|
33
|
-
|
34
|
-
|
23
|
+
it "must support step command" do
|
24
|
+
irb.stubs(:eval_input).throws(:IRB_EXIT, :step)
|
25
|
+
enter 'irb'
|
26
|
+
debug_file('irb') { state.line.must_equal 3 }
|
27
|
+
end
|
35
28
|
|
36
|
-
it "must
|
37
|
-
irb.
|
38
|
-
enter '
|
39
|
-
debug_file
|
29
|
+
it "must support cont command" do
|
30
|
+
irb.stubs(:eval_input).throws(:IRB_EXIT, :cont)
|
31
|
+
enter 'break 4', 'irb'
|
32
|
+
debug_file('irb') { state.line.must_equal 4 }
|
40
33
|
end
|
41
|
-
end
|
42
34
|
|
43
|
-
|
44
|
-
|
45
|
-
it "must translate SIGINT into 'cont' command" # do
|
46
|
-
# irb.stubs(:eval_input).calls { Process.kill("SIGINT", Process.pid) }
|
47
|
-
# enter 'break 4', 'irb'
|
48
|
-
# debug_file('irb') { state.line.must_equal 4 }
|
49
|
-
#end
|
35
|
+
describe "autoirb" do
|
36
|
+
temporary_change_hash_value(Byebug::Command.settings, :autoirb, 0)
|
50
37
|
|
51
|
-
|
52
|
-
|
53
|
-
|
38
|
+
it "must call irb automatically after breakpoint" do
|
39
|
+
irb.expects(:eval_input)
|
40
|
+
enter 'set autoirb', 'break 4', 'cont'
|
41
|
+
debug_file 'irb'
|
42
|
+
end
|
43
|
+
end
|
54
44
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
45
|
+
# TODO: Can't reliably test the signal, from time to time Signal.trap, which
|
46
|
+
# is defined in IRBCommand, misses the SIGINT signal, which makes the test
|
47
|
+
# suite exit. Not sure how to fix that...
|
48
|
+
it "must translate SIGINT into 'cont' command" do
|
49
|
+
irb.stubs(:eval_input).calls { Process.kill("SIGINT", Process.pid) }
|
50
|
+
enter 'break 4', 'irb'
|
51
|
+
debug_file('irb') { state.line.must_equal 4 }
|
61
52
|
end
|
62
53
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
54
|
+
describe "setting context to $byebug_state" do
|
55
|
+
before { $byebug_state = nil }
|
56
|
+
temporary_change_hash_value(Byebug::Command.settings, :byebugtesting, false)
|
57
|
+
|
58
|
+
it "must set $byebug_state if irb is in the debug mode" do
|
59
|
+
byebug_state = nil
|
60
|
+
irb.stubs(:eval_input).calls { byebug_state = $byebug_state }
|
61
|
+
enter 'irb -d'
|
62
|
+
debug_file('irb')
|
63
|
+
byebug_state.must_be_kind_of Byebug::CommandProcessor::State
|
64
|
+
end
|
65
|
+
|
66
|
+
it "must not set $byebug_state if irb is not in the debug mode" do
|
67
|
+
byebug_state = nil
|
68
|
+
irb.stubs(:eval_input).calls { byebug_state = $byebug_state }
|
69
|
+
enter 'irb'
|
70
|
+
debug_file('irb')
|
71
|
+
byebug_state.must_be_nil
|
72
|
+
end
|
69
73
|
end
|
70
|
-
end
|
71
74
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
75
|
+
describe "Post Mortem" do
|
76
|
+
it "must work in post-mortem mode" do
|
77
|
+
skip("No post morten mode for now")
|
78
|
+
irb.stubs(:eval_input).throws(:IRB_EXIT, :cont)
|
79
|
+
enter 'cont', 'break 12', 'irb'
|
80
|
+
debug_file("post_mortem") { state.line.must_equal 12 }
|
81
|
+
end
|
78
82
|
end
|
83
|
+
|
79
84
|
end
|
80
85
|
|
81
86
|
end
|
data/test/jump_test.rb
CHANGED
@@ -5,11 +5,13 @@ describe "Jump Command" do
|
|
5
5
|
|
6
6
|
describe "successful" do
|
7
7
|
it "must jump with absolute line number" do
|
8
|
+
skip("No jumping for now")
|
8
9
|
enter 'break 6', 'cont', "jump 8 #{fullpath('jump')}"
|
9
10
|
debug_file('jump') { state.line.must_equal 8 }
|
10
11
|
end
|
11
12
|
|
12
13
|
it "must not initialize skipped variables during jump" do
|
14
|
+
skip("No jumping for now")
|
13
15
|
enter 'break 6', 'cont', "jump 8 #{fullpath('jump')}", 'next'
|
14
16
|
enter 'var local'
|
15
17
|
debug_file('jump')
|
@@ -17,11 +19,13 @@ describe "Jump Command" do
|
|
17
19
|
end
|
18
20
|
|
19
21
|
it "must jump with relative line number (-)" do
|
22
|
+
skip("No jumping for now")
|
20
23
|
enter 'break 8', 'cont', "jump -2 #{fullpath('jump')}"
|
21
24
|
debug_file('jump') { state.line.must_equal 6 }
|
22
25
|
end
|
23
26
|
|
24
27
|
it "must jump with relative line number (+)" do
|
28
|
+
skip("No jumping for now")
|
25
29
|
enter 'break 8', 'cont', "jump +2 #{fullpath('jump')}"
|
26
30
|
debug_file('jump') { state.line.must_equal 10 }
|
27
31
|
end
|
@@ -29,42 +33,47 @@ describe "Jump Command" do
|
|
29
33
|
|
30
34
|
describe "errors" do
|
31
35
|
it "must show an error if line number is invalid" do
|
36
|
+
skip("No jumping for now")
|
32
37
|
enter 'jump bla'
|
33
38
|
debug_file('jump')
|
34
39
|
check_output_includes "Bad line number: bla", interface.error_queue
|
35
40
|
end
|
36
41
|
|
37
42
|
it "must show an error if line number is not specified" do
|
43
|
+
skip("No jumping for now")
|
38
44
|
enter 'jump'
|
39
45
|
debug_file('jump')
|
40
|
-
check_output_includes '"jump" must be followed by a line number',
|
46
|
+
check_output_includes '"jump" must be followed by a line number',
|
47
|
+
interface.error_queue
|
41
48
|
end
|
42
49
|
|
43
50
|
describe "when there is no active code in specified line" do
|
44
51
|
it "must not jump to there" do
|
52
|
+
skip("No jumping for now")
|
45
53
|
enter "jump 13 #{fullpath('jump')}"
|
46
54
|
debug_file('jump') { state.line.must_equal 3 }
|
47
55
|
end
|
48
56
|
|
49
57
|
it "must show an error" do
|
58
|
+
skip("No jumping for now")
|
50
59
|
enter "jump 13 #{fullpath('jump')}"
|
51
60
|
debug_file('jump')
|
52
|
-
check_output_includes
|
61
|
+
check_output_includes \
|
62
|
+
"Couldn't find active code at #{fullpath('jump')}:13",
|
63
|
+
interface.error_queue
|
53
64
|
end
|
54
65
|
end
|
55
66
|
end
|
56
67
|
|
57
68
|
describe "Post Mortem" do
|
58
|
-
# TODO: This test fails with "Segmentation fault". Probably need to fix it
|
59
|
-
# command in
|
60
|
-
# cause that.
|
69
|
+
# TODO: This test fails with "Segmentation fault". Probably need to fix it
|
70
|
+
# somehow or forbid this command in post mortem mode. Seems like
|
71
|
+
# state.context.frame_file and state.context.frame_line cause that.
|
61
72
|
it "must work in post-mortem mode" do
|
62
73
|
skip("No post morten mode for now")
|
63
|
-
|
64
|
-
|
65
|
-
#pi
|
74
|
+
enter 'cont', 'jump 12'
|
75
|
+
debug_file 'post_mortem'
|
66
76
|
end
|
67
77
|
end
|
68
78
|
|
69
|
-
|
70
79
|
end
|
data/test/list_test.rb
CHANGED
@@ -2,144 +2,151 @@ require_relative 'test_helper'
|
|
2
2
|
|
3
3
|
describe "List Command" do
|
4
4
|
include TestDsl
|
5
|
-
temporary_change_hash_value(Byebug::Command.settings, :listsize, 3)
|
6
|
-
before { LineCache.clear_file_cache }
|
7
|
-
after { LineCache.clear_file_cache }
|
8
5
|
|
9
|
-
describe "
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
check_output_includes "[3, 6] in #{fullpath('list')}"
|
6
|
+
describe "List Command Setup" do
|
7
|
+
before do
|
8
|
+
LineCache.clear_file_cache
|
9
|
+
Byebug::Command.settings[:listsize] = 3
|
14
10
|
end
|
15
11
|
|
16
|
-
|
17
|
-
enter 'set listsize 4.0', 'break 5', 'cont', 'list'
|
18
|
-
debug_file 'list'
|
19
|
-
check_output_includes "[4, 6] in #{fullpath('list')}"
|
20
|
-
end
|
21
|
-
end
|
12
|
+
after { LineCache.clear_file_cache }
|
22
13
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
14
|
+
describe "listsize" do
|
15
|
+
it "must show lines according to :listsize setting" do
|
16
|
+
enter 'set listsize 4', 'break 5', 'cont', 'list'
|
17
|
+
debug_file 'list'
|
18
|
+
check_output_includes "[3, 6] in #{fullpath('list')}"
|
19
|
+
end
|
29
20
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
21
|
+
it "must not set it if the param is not an integer" do
|
22
|
+
enter 'set listsize 4.0', 'break 5', 'cont', 'list'
|
23
|
+
debug_file 'list'
|
24
|
+
check_output_includes "[4, 6] in #{fullpath('list')}"
|
25
|
+
end
|
34
26
|
end
|
35
|
-
end
|
36
27
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
28
|
+
describe "without arguments" do
|
29
|
+
it "must show surrounding lines with the first call" do
|
30
|
+
enter 'break 5', 'cont', 'list'
|
31
|
+
debug_file 'list'
|
32
|
+
check_output_includes "[4, 6] in #{fullpath('list')}", "4 4", "=> 5 5", "6 6"
|
33
|
+
end
|
43
34
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
35
|
+
it "must list forward after second call" do
|
36
|
+
enter 'break 5', 'cont', 'list', 'list'
|
37
|
+
debug_file 'list'
|
38
|
+
check_output_includes "[7, 9] in #{fullpath('list')}", "7 7", "8 8", "9 9"
|
39
|
+
end
|
48
40
|
end
|
49
|
-
end
|
50
41
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
42
|
+
describe "list backward" do
|
43
|
+
it "must show surrounding lines with the first call" do
|
44
|
+
enter 'break 5', 'cont', 'list -'
|
45
|
+
debug_file 'list'
|
46
|
+
check_output_includes "[4, 6] in #{fullpath('list')}", "4 4", "=> 5 5", "6 6"
|
47
|
+
end
|
56
48
|
|
57
|
-
|
58
|
-
|
49
|
+
it "must list backward after second call" do
|
50
|
+
enter 'break 5', 'cont', 'list -', 'list -'
|
51
|
+
debug_file 'list'
|
52
|
+
check_output_includes "[1, 3] in #{fullpath('list')}", "1 byebug", "2 2", "3 3"
|
53
|
+
end
|
54
|
+
end
|
59
55
|
|
60
|
-
it "must show the
|
61
|
-
enter '
|
56
|
+
it "must show the surrounding lines with =" do
|
57
|
+
enter 'break 5', 'cont', 'list ='
|
62
58
|
debug_file 'list'
|
63
59
|
check_output_includes "[4, 6] in #{fullpath('list')}", "4 4", "=> 5 5", "6 6"
|
64
60
|
end
|
65
|
-
end
|
66
61
|
|
67
|
-
|
68
|
-
|
69
|
-
enter 'list 4-6'
|
70
|
-
debug_file 'list'
|
71
|
-
check_output_includes "[4, 6] in #{fullpath('list')}", "4 4", "5 5", "6 6"
|
72
|
-
end
|
62
|
+
describe "autolist" do
|
63
|
+
temporary_change_hash_value(Byebug::Command.settings, :autolist, 0)
|
73
64
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
65
|
+
it "must show the surronding lines even without 'list' command if autolist is enabled" do
|
66
|
+
enter 'set autolist', 'break 5', 'cont'
|
67
|
+
debug_file 'list'
|
68
|
+
check_output_includes "[4, 6] in #{fullpath('list')}", "4 4", "=> 5 5", "6 6"
|
69
|
+
end
|
78
70
|
end
|
79
71
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
72
|
+
describe "specified lines" do
|
73
|
+
it "must show with mm-nn" do
|
74
|
+
enter 'list 4-6'
|
75
|
+
debug_file 'list'
|
76
|
+
check_output_includes "[4, 6] in #{fullpath('list')}", "4 4", "5 5", "6 6"
|
77
|
+
end
|
85
78
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
79
|
+
it "must show with mm,nn" do
|
80
|
+
enter 'list 4,6'
|
81
|
+
debug_file 'list'
|
82
|
+
check_output_includes "[4, 6] in #{fullpath('list')}", "4 4", "5 5", "6 6"
|
83
|
+
end
|
91
84
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
end
|
85
|
+
it "must show surroundings with mm-" do
|
86
|
+
enter 'list 4-'
|
87
|
+
debug_file 'list'
|
88
|
+
check_output_includes "[3, 5] in #{fullpath('list')}", "3 3", "4 4", "5 5"
|
89
|
+
end
|
98
90
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
check_output_doesnt_include "4 4"
|
105
|
-
end
|
106
|
-
end
|
91
|
+
it "must show surroundings with mm," do
|
92
|
+
enter 'list 4,'
|
93
|
+
debug_file 'list'
|
94
|
+
check_output_includes "[3, 5] in #{fullpath('list')}", "3 3", "4 4", "5 5"
|
95
|
+
end
|
107
96
|
|
108
|
-
|
109
|
-
|
97
|
+
it "must show nothing if there is no such lines" do
|
98
|
+
enter 'list 44,44'
|
99
|
+
debug_file 'list'
|
100
|
+
check_output_includes "[44, 44] in #{fullpath('list')}"
|
101
|
+
check_output_doesnt_include /^44 \S/
|
102
|
+
end
|
110
103
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
104
|
+
it "must show nothing if range is incorrect" do
|
105
|
+
enter 'list 5,4'
|
106
|
+
debug_file 'list'
|
107
|
+
check_output_includes "[5, 4] in #{fullpath('list')}"
|
108
|
+
check_output_doesnt_include "5 5"
|
109
|
+
check_output_doesnt_include "4 4"
|
116
110
|
end
|
117
|
-
debug_file 'list'
|
118
|
-
check_output_includes "4 4"
|
119
111
|
end
|
120
112
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
113
|
+
describe "reload source" do
|
114
|
+
temporary_change_hash_value(Byebug::Command.settings, :reload_source_on_change, false)
|
115
|
+
|
116
|
+
after { change_line_in_file(fullpath('list'), 4, '4') }
|
117
|
+
it "must not reload if setting is false" do
|
118
|
+
enter 'set noautoreload', -> do
|
119
|
+
change_line_in_file(fullpath('list'), 4, '100')
|
120
|
+
'list 4-4'
|
121
|
+
end
|
122
|
+
debug_file 'list'
|
123
|
+
check_output_includes "4 4"
|
124
|
+
end
|
125
|
+
|
126
|
+
it "must reload if setting is true" do
|
127
|
+
enter 'set autoreload', -> do
|
128
|
+
change_line_in_file(fullpath('list'), 4, '100')
|
129
|
+
'list 4-4'
|
130
|
+
end
|
131
|
+
debug_file 'list'
|
132
|
+
check_output_includes "4 100"
|
125
133
|
end
|
126
|
-
debug_file 'list'
|
127
|
-
check_output_includes "4 100"
|
128
134
|
end
|
129
|
-
end
|
130
135
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
+
it "must show an error when there is no such file" do
|
137
|
+
enter ->{state.file = "blabla"; 'list 4-4'}
|
138
|
+
debug_file 'list'
|
139
|
+
check_output_includes "No sourcefile available for blabla", interface.error_queue
|
140
|
+
end
|
136
141
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
142
|
+
describe "Post Mortem" do
|
143
|
+
it "must work in post-mortem mode" do
|
144
|
+
skip("No post morten mode for now")
|
145
|
+
enter 'cont', 'list'
|
146
|
+
debug_file 'post_mortem'
|
147
|
+
check_output_includes "[7, 9] in #{fullpath('post_mortem')}"
|
148
|
+
end
|
143
149
|
end
|
150
|
+
|
144
151
|
end
|
145
152
|
end
|