byebug 0.0.1 → 1.0.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.
Files changed (63) hide show
  1. data/.gitignore +4 -0
  2. data/.travis.yml +0 -5
  3. data/CHANGELOG.md +6 -0
  4. data/Gemfile +1 -1
  5. data/LICENSE +23 -20
  6. data/byebug.gemspec +5 -5
  7. data/ext/byebug/breakpoint.c +102 -134
  8. data/ext/byebug/byebug.c +110 -64
  9. data/ext/byebug/byebug.h +2 -3
  10. data/ext/byebug/context.c +72 -39
  11. data/lib/byebug.rb +34 -38
  12. data/lib/byebug/command.rb +19 -24
  13. data/lib/byebug/commands/breakpoints.rb +11 -12
  14. data/lib/byebug/commands/catchpoint.rb +1 -1
  15. data/lib/byebug/commands/control.rb +2 -4
  16. data/lib/byebug/commands/finish.rb +1 -1
  17. data/lib/byebug/commands/frame.rb +15 -17
  18. data/lib/byebug/commands/info.rb +29 -28
  19. data/lib/byebug/commands/irb.rb +23 -21
  20. data/lib/byebug/commands/method.rb +4 -4
  21. data/lib/byebug/commands/reload.rb +8 -6
  22. data/lib/byebug/commands/set.rb +27 -23
  23. data/lib/byebug/commands/show.rb +6 -4
  24. data/lib/byebug/commands/stepping.rb +2 -2
  25. data/lib/byebug/commands/threads.rb +10 -10
  26. data/lib/byebug/commands/trace.rb +13 -14
  27. data/lib/byebug/commands/variables.rb +14 -12
  28. data/lib/byebug/context.rb +2 -15
  29. data/lib/byebug/interface.rb +5 -0
  30. data/lib/byebug/processor.rb +59 -64
  31. data/lib/byebug/version.rb +2 -1
  32. data/old_doc/Makefile +20 -0
  33. data/{man/rdebug.1 → old_doc/byebug.1} +5 -5
  34. data/old_doc/byebug.html +6178 -0
  35. data/old_doc/byebug.texi +3775 -0
  36. data/{doc → old_doc}/hanoi.rb +0 -0
  37. data/{doc → old_doc}/primes.rb +0 -0
  38. data/{doc → old_doc}/test-tri2.rb +0 -0
  39. data/{doc → old_doc}/tri3.rb +0 -0
  40. data/{doc → old_doc}/triangle.rb +0 -0
  41. data/test/breakpoints_test.rb +96 -60
  42. data/test/conditions_test.rb +15 -12
  43. data/test/examples/info.rb +5 -5
  44. data/test/examples/stepping.rb +1 -1
  45. data/test/frame_test.rb +40 -39
  46. data/test/info_test.rb +105 -96
  47. data/test/irb_test.rb +66 -61
  48. data/test/jump_test.rb +18 -9
  49. data/test/list_test.rb +114 -107
  50. data/test/restart_test.rb +51 -58
  51. data/test/save_test.rb +8 -7
  52. data/test/set_test.rb +8 -11
  53. data/test/show_test.rb +3 -5
  54. data/test/stepping_test.rb +43 -53
  55. data/test/support/context.rb +1 -0
  56. data/test/support/processor.rb +10 -4
  57. data/test/support/test_dsl.rb +46 -18
  58. data/test/support/test_interface.rb +8 -5
  59. data/test/test_helper.rb +2 -2
  60. data/test/trace_test.rb +123 -124
  61. metadata +39 -17
  62. data/AUTHORS +0 -10
  63. data/doc/rdebug-emacs.texi +0 -1030
@@ -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
- it "must support next command" do
16
- irb.stubs(:eval_input).throws(:IRB_EXIT, :next)
17
- enter 'irb'
18
- debug_file('irb') { state.line.must_equal 3 }
19
- end
20
-
21
- it "must support step command" do
22
- irb.stubs(:eval_input).throws(:IRB_EXIT, :step)
23
- enter 'irb'
24
- debug_file('irb') { state.line.must_equal 3 }
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
- it "must support cont command" do
28
- irb.stubs(:eval_input).throws(:IRB_EXIT, :cont)
29
- enter 'break 4', 'irb'
30
- debug_file('irb') { state.line.must_equal 4 }
31
- end
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
- describe "autoirb" do
34
- temporary_change_hash_value(Byebug::Command.settings, :autoirb, 0)
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 call irb automatically after breakpoint" do
37
- irb.expects(:eval_input)
38
- enter 'set autoirb', 'break 4', 'cont'
39
- debug_file 'irb'
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
- # TODO: Can't reliably test the signal, from time to time Signal.trap, which is defined in IRBCommand, misses
44
- # the SIGINT signal, which makes the test suite exit. Not sure how to fix that...
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
- describe "setting context to $rdebug_state" do
52
- before { $rdebug_state = nil }
53
- temporary_change_hash_value(Byebug::Command.settings, :byebugtesting, false)
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
- it "must set $rdebug_state if irb is in the debug mode" do
56
- rdebug_state = nil
57
- irb.stubs(:eval_input).calls { rdebug_state = $rdebug_state }
58
- enter 'irb -d'
59
- debug_file('irb')
60
- rdebug_state.must_be_kind_of Byebug::CommandProcessor::State
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
- it "must not set $rdebug_state if irb is not in the debug mode" do
64
- rdebug_state = nil
65
- irb.stubs(:eval_input).calls { rdebug_state = $rdebug_state }
66
- enter 'irb'
67
- debug_file('irb')
68
- rdebug_state.must_be_nil
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
- describe "Post Mortem" do
73
- it "must work in post-mortem mode" do
74
- skip("No post morten mode for now")
75
- #irb.stubs(:eval_input).throws(:IRB_EXIT, :cont)
76
- #enter 'cont', 'break 12', 'irb'
77
- #debug_file("post_mortem") { state.line.must_equal 12 }
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
@@ -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', interface.error_queue
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 "Couldn't find active code at #{fullpath('jump')}:13", interface.error_queue
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 somehow, or forbid this
59
- # command in the post mortem mode. Seems like state.context.frame_file and state.context.frame_line
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
- #enter 'cont', 'jump 12'
64
- #debug_file 'post_mortem'
65
- #pi
74
+ enter 'cont', 'jump 12'
75
+ debug_file 'post_mortem'
66
76
  end
67
77
  end
68
78
 
69
-
70
79
  end
@@ -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 "listsize" do
10
- it "must show lines according to :listsize setting" do
11
- enter 'set listsize 4', 'break 5', 'cont', 'list'
12
- debug_file 'list'
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
- it "must not set it if the param is not an integer" do
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
- describe "without arguments" do
24
- it "must show surrounding lines with the first call" do
25
- enter 'break 5', 'cont', 'list'
26
- debug_file 'list'
27
- check_output_includes "[4, 6] in #{fullpath('list')}", "4 4", "=> 5 5", "6 6"
28
- end
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
- it "must list forward after second call" do
31
- enter 'break 5', 'cont', 'list', 'list'
32
- debug_file 'list'
33
- check_output_includes "[7, 9] in #{fullpath('list')}", "7 7", "8 8", "9 9"
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
- describe "list backward" do
38
- it "must show surrounding lines with the first call" do
39
- enter 'break 5', 'cont', 'list -'
40
- debug_file 'list'
41
- check_output_includes "[4, 6] in #{fullpath('list')}", "4 4", "=> 5 5", "6 6"
42
- end
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
- it "must list backward after second call" do
45
- enter 'break 5', 'cont', 'list -', 'list -'
46
- debug_file 'list'
47
- check_output_includes "[1, 3] in #{fullpath('list')}", "1 byebug", "2 2", "3 3"
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
- it "must show the surrounding lines with =" do
52
- enter 'break 5', 'cont', 'list ='
53
- debug_file 'list'
54
- check_output_includes "[4, 6] in #{fullpath('list')}", "4 4", "=> 5 5", "6 6"
55
- end
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
- describe "autolist" do
58
- temporary_change_hash_value(Byebug::Command.settings, :autolist, 0)
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 surronding lines even without 'list' command if autolist is enabled" do
61
- enter 'set autolist', 'break 5', 'cont'
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
- describe "specified lines" do
68
- it "must show with mm-nn" do
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
- it "must show with mm,nn" do
75
- enter 'list 4,6'
76
- debug_file 'list'
77
- check_output_includes "[4, 6] in #{fullpath('list')}", "4 4", "5 5", "6 6"
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
- it "must show surroundings with mm-" do
81
- enter 'list 4-'
82
- debug_file 'list'
83
- check_output_includes "[3, 5] in #{fullpath('list')}", "3 3", "4 4", "5 5"
84
- end
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
- it "must show surroundings with mm," do
87
- enter 'list 4,'
88
- debug_file 'list'
89
- check_output_includes "[3, 5] in #{fullpath('list')}", "3 3", "4 4", "5 5"
90
- end
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
- it "must show nothing if there is no such lines" do
93
- enter 'list 44,44'
94
- debug_file 'list'
95
- check_output_includes "[44, 44] in #{fullpath('list')}"
96
- check_output_doesnt_include /^44 \S/
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
- it "must show nothing if range is incorrect" do
100
- enter 'list 5,4'
101
- debug_file 'list'
102
- check_output_includes "[5, 4] in #{fullpath('list')}"
103
- check_output_doesnt_include "5 5"
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
- describe "reload source" do
109
- temporary_change_hash_value(Byebug::Command.settings, :reload_source_on_change, false)
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
- after { change_line_in_file(fullpath('list'), 4, '4') }
112
- it "must not reload if setting is false" do
113
- enter 'set noautoreload', -> do
114
- change_line_in_file(fullpath('list'), 4, '100')
115
- 'list 4-4'
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
- it "must reload if setting is true" do
122
- enter 'set autoreload', -> do
123
- change_line_in_file(fullpath('list'), 4, '100')
124
- 'list 4-4'
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
- it "must show an error when there is no such file" do
132
- enter ->{state.file = "blabla"; 'list 4-4'}
133
- debug_file 'list'
134
- check_output_includes "No sourcefile available for blabla", interface.error_queue
135
- end
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
- describe "Post Mortem" do
138
- it "must work in post-mortem mode" do
139
- skip("No post morten mode for now")
140
- #enter 'cont', 'list'
141
- #debug_file 'post_mortem'
142
- #check_output_includes "[7, 9] in #{fullpath('post_mortem')}"
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