byebug 3.5.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +4 -1
  3. data/.rubocop.yml +18 -1
  4. data/.travis.yml +21 -1
  5. data/CHANGELOG.md +356 -308
  6. data/CONTRIBUTING.md +31 -15
  7. data/GUIDE.md +859 -475
  8. data/Gemfile +8 -10
  9. data/LICENSE +1 -1
  10. data/README.md +41 -45
  11. data/Rakefile +30 -28
  12. data/byebug.gemspec +18 -18
  13. data/ext/byebug/breakpoint.c +88 -75
  14. data/ext/byebug/byebug.c +253 -252
  15. data/ext/byebug/byebug.h +53 -53
  16. data/ext/byebug/context.c +188 -159
  17. data/ext/byebug/extconf.rb +9 -6
  18. data/ext/byebug/locker.c +53 -11
  19. data/ext/byebug/threads.c +137 -39
  20. data/lib/byebug/attacher.rb +7 -2
  21. data/lib/byebug/breakpoint.rb +30 -0
  22. data/lib/byebug/command.rb +36 -32
  23. data/lib/byebug/commands/break.rb +49 -48
  24. data/lib/byebug/commands/catch.rb +64 -0
  25. data/lib/byebug/commands/condition.rb +13 -9
  26. data/lib/byebug/commands/continue.rb +8 -4
  27. data/lib/byebug/commands/delete.rb +10 -4
  28. data/lib/byebug/commands/display.rb +33 -25
  29. data/lib/byebug/commands/edit.rb +18 -13
  30. data/lib/byebug/commands/enable_disable.rb +26 -24
  31. data/lib/byebug/commands/eval.rb +77 -35
  32. data/lib/byebug/commands/finish.rb +9 -5
  33. data/lib/byebug/commands/frame.rb +66 -125
  34. data/lib/byebug/commands/help.rb +14 -21
  35. data/lib/byebug/commands/history.rb +5 -1
  36. data/lib/byebug/commands/info.rb +41 -106
  37. data/lib/byebug/commands/interrupt.rb +6 -2
  38. data/lib/byebug/commands/irb.rb +5 -2
  39. data/lib/byebug/commands/kill.rb +6 -2
  40. data/lib/byebug/commands/list.rb +21 -14
  41. data/lib/byebug/commands/method.rb +17 -9
  42. data/lib/byebug/commands/pry.rb +13 -3
  43. data/lib/byebug/commands/quit.rb +10 -5
  44. data/lib/byebug/commands/restart.rb +12 -19
  45. data/lib/byebug/commands/save.rb +10 -6
  46. data/lib/byebug/commands/set.rb +15 -14
  47. data/lib/byebug/commands/show.rb +8 -8
  48. data/lib/byebug/commands/source.rb +14 -8
  49. data/lib/byebug/commands/stepping.rb +15 -29
  50. data/lib/byebug/commands/threads.rb +73 -49
  51. data/lib/byebug/commands/tracevar.rb +56 -0
  52. data/lib/byebug/commands/undisplay.rb +8 -4
  53. data/lib/byebug/commands/untracevar.rb +38 -0
  54. data/lib/byebug/commands/var.rb +107 -0
  55. data/lib/byebug/context.rb +78 -42
  56. data/lib/byebug/core.rb +78 -40
  57. data/lib/byebug/helper.rb +58 -42
  58. data/lib/byebug/history.rb +12 -1
  59. data/lib/byebug/interface.rb +91 -11
  60. data/lib/byebug/interfaces/local_interface.rb +12 -19
  61. data/lib/byebug/interfaces/remote_interface.rb +12 -15
  62. data/lib/byebug/interfaces/script_interface.rb +14 -18
  63. data/lib/byebug/interfaces/test_interface.rb +54 -0
  64. data/lib/byebug/printers/base.rb +64 -0
  65. data/lib/byebug/printers/plain.rb +53 -0
  66. data/lib/byebug/processor.rb +20 -1
  67. data/lib/byebug/processors/command_processor.rb +57 -172
  68. data/lib/byebug/processors/control_command_processor.rb +16 -43
  69. data/lib/byebug/remote.rb +13 -7
  70. data/lib/byebug/runner.rb +102 -54
  71. data/lib/byebug/setting.rb +45 -68
  72. data/lib/byebug/settings/autoeval.rb +2 -0
  73. data/lib/byebug/settings/autoirb.rb +3 -0
  74. data/lib/byebug/settings/autolist.rb +3 -0
  75. data/lib/byebug/settings/autosave.rb +2 -0
  76. data/lib/byebug/settings/basename.rb +2 -0
  77. data/lib/byebug/settings/callstyle.rb +2 -0
  78. data/lib/byebug/settings/fullpath.rb +2 -0
  79. data/lib/byebug/settings/histfile.rb +2 -0
  80. data/lib/byebug/settings/histsize.rb +2 -0
  81. data/lib/byebug/settings/linetrace.rb +2 -0
  82. data/lib/byebug/settings/listsize.rb +2 -0
  83. data/lib/byebug/settings/post_mortem.rb +7 -2
  84. data/lib/byebug/settings/stack_on_error.rb +2 -0
  85. data/lib/byebug/settings/verbose.rb +2 -0
  86. data/lib/byebug/settings/width.rb +2 -0
  87. data/lib/byebug/state.rb +12 -0
  88. data/lib/byebug/states/control_state.rb +26 -0
  89. data/lib/byebug/states/regular_state.rb +178 -0
  90. data/lib/byebug/version.rb +1 -1
  91. metadata +24 -109
  92. data/lib/byebug/commands/catchpoint.rb +0 -53
  93. data/lib/byebug/commands/reload.rb +0 -29
  94. data/lib/byebug/commands/trace.rb +0 -50
  95. data/lib/byebug/commands/variables.rb +0 -206
  96. data/lib/byebug/options.rb +0 -46
  97. data/lib/byebug/settings/autoreload.rb +0 -12
  98. data/lib/byebug/settings/forcestep.rb +0 -14
  99. data/lib/byebug/settings/testing.rb +0 -12
  100. data/lib/byebug/settings/tracing_plus.rb +0 -11
  101. data/test/commands/break_test.rb +0 -364
  102. data/test/commands/condition_test.rb +0 -85
  103. data/test/commands/continue_test.rb +0 -47
  104. data/test/commands/delete_test.rb +0 -26
  105. data/test/commands/display_test.rb +0 -37
  106. data/test/commands/edit_test.rb +0 -52
  107. data/test/commands/eval_test.rb +0 -89
  108. data/test/commands/finish_test.rb +0 -74
  109. data/test/commands/frame_test.rb +0 -223
  110. data/test/commands/help_test.rb +0 -66
  111. data/test/commands/history_test.rb +0 -61
  112. data/test/commands/info_test.rb +0 -238
  113. data/test/commands/interrupt_test.rb +0 -45
  114. data/test/commands/irb_test.rb +0 -28
  115. data/test/commands/kill_test.rb +0 -50
  116. data/test/commands/list_test.rb +0 -174
  117. data/test/commands/method_test.rb +0 -52
  118. data/test/commands/post_mortem_test.rb +0 -71
  119. data/test/commands/pry_test.rb +0 -26
  120. data/test/commands/quit_test.rb +0 -53
  121. data/test/commands/reload_test.rb +0 -39
  122. data/test/commands/restart_test.rb +0 -46
  123. data/test/commands/save_test.rb +0 -67
  124. data/test/commands/set_test.rb +0 -140
  125. data/test/commands/show_test.rb +0 -76
  126. data/test/commands/source_test.rb +0 -46
  127. data/test/commands/stepping_test.rb +0 -192
  128. data/test/commands/thread_test.rb +0 -164
  129. data/test/commands/trace_test.rb +0 -71
  130. data/test/commands/undisplay_test.rb +0 -75
  131. data/test/commands/variables_test.rb +0 -105
  132. data/test/debugger_alias_test.rb +0 -7
  133. data/test/runner_test.rb +0 -150
  134. data/test/support/matchers.rb +0 -65
  135. data/test/support/test_interface.rb +0 -59
  136. data/test/support/utils.rb +0 -122
  137. data/test/test_helper.rb +0 -58
@@ -1,67 +0,0 @@
1
- module Byebug
2
- class SaveTestCase < TestCase
3
- def setup
4
- @example = -> do
5
- byebug
6
- a = 2
7
- a = 3
8
- end
9
-
10
- super
11
-
12
- enter 'break 2', 'break 3 if true', 'catch NoMethodError',
13
- 'display 2 + 3', 'save save_output.txt'
14
- debug_proc(@example)
15
- end
16
-
17
- def teardown
18
- File.delete('save_output.txt')
19
- end
20
-
21
- def file_contents
22
- @file_contents ||= File.read('save_output.txt')
23
- end
24
-
25
- def test_save_records_regular_breakpoints
26
- assert_includes file_contents, "break #{__FILE__}:2"
27
- end
28
-
29
- def test_save_records_conditional_breakpoints
30
- assert_includes file_contents, "break #{__FILE__}:3 if true"
31
- end
32
-
33
- def test_save_records_catchpoints
34
- assert_includes file_contents, 'catch NoMethodError'
35
- end
36
-
37
- def test_save_records_displays
38
- assert_includes file_contents, 'display 2 + 3'
39
- end
40
-
41
- def test_save_records_current_state_of_settings
42
- assert_includes file_contents, 'set autoeval true'
43
- assert_includes file_contents, 'set basename false'
44
- assert_includes file_contents, 'set testing true'
45
- assert_includes file_contents, 'set autolist false'
46
- assert_includes file_contents, 'set autoirb false'
47
- end
48
-
49
- def test_save_shows_a_success_message
50
- check_output_includes "Saved to 'save_output.txt'"
51
- end
52
-
53
- def test_save_without_a_filename_uses_a_default_file
54
- enter 'save'
55
- debug_proc(@example)
56
- assert_includes File.read(RESTART_FILE), 'set autoirb false'
57
- File.delete(RESTART_FILE)
58
- end
59
-
60
- def test_save_without_a_filename_shows_a_message_with_the_file_used
61
- enter 'save'
62
- debug_proc(@example)
63
- check_output_includes "Saved to '#{RESTART_FILE}'"
64
- File.delete(RESTART_FILE)
65
- end
66
- end
67
- end
@@ -1,140 +0,0 @@
1
- module Byebug
2
- class SetTestCase < TestCase
3
- def setup
4
- @example = -> do
5
- byebug
6
- a = 2
7
- a += 1
8
- end
9
-
10
- super
11
- end
12
-
13
- [:autoeval, :autolist, :autoreload, :autosave, :basename, :forcestep,
14
- :fullpath, :post_mortem, :stack_on_error, :testing,
15
- :tracing_plus].each do |set|
16
- ['on', '1', 'true', ''].each do |key|
17
- define_method(:"test_enable_boolean_setting_#{set}_using_#{key}") do
18
- Setting[set] = false
19
- enter "set #{set} #{key}"
20
- debug_proc(@example)
21
- assert_equal true, Setting[set]
22
- end
23
- end
24
-
25
- ['off', '0', 'false'].each do |key|
26
- define_method(:"test_disable_boolean_setting_#{set}_using_#{key}") do
27
- Setting[set] = true
28
- enter "set #{set} #{key}"
29
- debug_proc(@example)
30
- assert_equal false, Setting[set]
31
- end
32
- end
33
-
34
- define_method(:"test_disable_boolean_setting_#{set}_using_no_prefix") do
35
- Setting[set] = true
36
- enter "set no#{set}"
37
- debug_proc(@example)
38
- assert_equal false, Setting[set]
39
- end
40
- end
41
-
42
- def test_set_enables_a_setting_using_shorcut_when_not_ambiguous
43
- Setting[:forcestep] = false
44
- enter 'set fo'
45
- debug_proc(@example)
46
- assert_equal true, Setting[:forcestep]
47
- end
48
-
49
- def test_set_does_not_enable_a_setting_using_shorcut_when_ambiguous
50
- Setting[:forcestep] = false
51
- Setting[:fullpath] = false
52
- enter 'set f'
53
- debug_proc(@example)
54
- assert_equal false, Setting[:forcestep]
55
- assert_equal false, Setting[:fullpath]
56
- end
57
-
58
- def test_set_disables_a_setting_using_shorcut_when_not_ambiguous
59
- Setting[:forcestep] = true
60
- enter 'set nofo'
61
- debug_proc(@example)
62
- assert_equal false, Setting[:forcestep]
63
- end
64
-
65
- def test_set_does_not_disable_a_setting_using_shorcut_when_ambiguous
66
- Setting[:forcestep] = true
67
- Setting[:fullpath] = true
68
- enter 'set nof'
69
- debug_proc(@example)
70
- assert_equal true, Setting[:forcestep]
71
- assert_equal true, Setting[:fullpath]
72
- end
73
-
74
- def test_set_testing_sets_the_thread_state_variable
75
- Setting[:testing] = false
76
- enter 'set testing', 'break 7', 'cont'
77
- debug_proc(@example) do
78
- assert_kind_of CommandProcessor::State, state
79
- end
80
- end
81
-
82
- def test_set_notesting_unsets_the_thread_state_variable
83
- Setting[:testing] = true
84
- enter 'set notesting', 'break 7', 'cont'
85
- debug_proc(@example) { assert_nil state }
86
- end
87
-
88
- def test_set_histsize_sets_maximum_history_size
89
- Setting[:histsize] = 1
90
- enter 'set histsize 250'
91
- debug_proc(@example)
92
- assert_equal 250, Setting[:histsize]
93
- check_output_includes "Maximum size of byebug's command history is 250"
94
- end
95
-
96
- def test_set_histsize_shows_an_error_message_if_no_size_is_provided
97
- enter 'set histsize'
98
- debug_proc(@example)
99
- check_error_includes 'You must specify a value for setting :histsize'
100
- end
101
-
102
- def test_set_histfile_sets_command_history_file
103
- filename = File.expand_path('.custom-byebug-hist')
104
- enter "set histfile #{filename}"
105
- debug_proc(@example)
106
- assert_equal filename, Setting[:histfile]
107
- check_output_includes "The command history file is #{filename}"
108
- Setting[:histfile] = HistfileSetting::DEFAULT
109
- end
110
-
111
- def test_set_histfile_shows_an_error_message_if_no_filename_is_provided
112
- enter 'set histfile'
113
- debug_proc(@example)
114
- check_error_includes 'You must specify a value for setting :histfile'
115
- end
116
-
117
- [:listsize, :width].each do |set|
118
- define_method(:"test_set_#{set}_changes_integer_setting_#{set}") do
119
- Setting[set] = 80
120
- enter "set #{set} 120"
121
- debug_proc(@example)
122
- assert_equal 120, Setting[set]
123
- end
124
- end
125
-
126
- def test_verbose_prints_tracepoint_api_event_information
127
- enter 'set verbose'
128
- debug_proc(@example)
129
- assert_equal true, Byebug.verbose?
130
- Byebug.verbose = false
131
- end
132
-
133
- def test_set_without_arguments_shows_help_for_set_command
134
- enter 'set'
135
- debug_proc(@example)
136
- check_output_includes(/Modifies parts of byebug environment./)
137
- check_output_includes(/List of settings supported in byebug/)
138
- end
139
- end
140
- end
@@ -1,76 +0,0 @@
1
- module Byebug
2
- class ShowTestCase < TestCase
3
- def setup
4
- @example = -> do
5
- byebug
6
- end
7
-
8
- super
9
- end
10
-
11
- [:autoeval, :autolist, :autoreload, :autosave, :basename, :forcestep,
12
- :fullpath, :post_mortem, :stack_on_error, :testing,
13
- :tracing_plus].each do |set|
14
- define_method(:"test_show_#{set}_shows_disabled_bool_setting_#{set}") do
15
- Setting[set] = false
16
- enter "show #{set}"
17
- debug_proc(@example)
18
- check_output_includes "#{set} is off"
19
- end
20
-
21
- define_method(:"test_show_#{set}_shows_enabled_bool_setting_#{set}") do
22
- Setting[set] = true
23
- enter "show #{set}"
24
- debug_proc(@example)
25
- check_output_includes "#{set} is on"
26
- end
27
- end
28
-
29
- def test_show_callstyle
30
- enter 'show callstyle'
31
- debug_proc(@example)
32
- check_output_includes "Frame display callstyle is 'long'"
33
- end
34
-
35
- def test_show_listsize
36
- enter 'show listsize'
37
- debug_proc(@example)
38
- check_output_includes 'Number of source lines to list is 10'
39
- end
40
-
41
- def test_show_width
42
- width = Setting[:width]
43
- enter 'show width'
44
- debug_proc(@example)
45
- check_output_includes "Maximum width of byebug's output is #{width}"
46
- end
47
-
48
- def test_show_unknown_setting
49
- enter 'show bla'
50
- debug_proc(@example)
51
- check_error_includes 'Unknown setting :bla'
52
- end
53
-
54
- def test_show_histfile
55
- filename = Setting[:histfile]
56
- enter 'show histfile'
57
- debug_proc(@example)
58
- check_output_includes "The command history file is #{filename}"
59
- end
60
-
61
- def test_show_histsize
62
- max_size = Setting[:histsize]
63
- enter 'show histsize'
64
- debug_proc(@example)
65
- check_output_includes \
66
- "Maximum size of byebug's command history is #{max_size}"
67
- end
68
-
69
- def test_show_without_arguments_displays_help_for_the_show_command
70
- enter 'show'
71
- debug_proc(@example)
72
- check_output_includes(/Generic command for showing byebug settings./)
73
- check_output_includes(/List of settings supported in byebug/)
74
- end
75
- end
76
- end
@@ -1,46 +0,0 @@
1
- module Byebug
2
- class SourceTestCase < TestCase
3
- def setup
4
- @example = -> do
5
- byebug
6
- a = 2
7
- a = 3
8
- end
9
-
10
- File.open('source_example.txt', 'w') do |f|
11
- f.puts 'break 2'
12
- f.puts 'break 3 if true'
13
- end
14
-
15
- super
16
- end
17
-
18
- def teardown
19
- File.delete('source_example.txt')
20
- end
21
-
22
- %w(source so).each do |cmd_alias|
23
- define_method(:"test_#{cmd_alias}_runs_byebug_commands_from_file") do
24
- enter "#{cmd_alias} source_example.txt"
25
- debug_proc(@example) do
26
- assert_equal 2, Byebug.breakpoints[0].pos
27
- assert_equal 3, Byebug.breakpoints[1].pos
28
- assert_equal 'true', Byebug.breakpoints[1].expr
29
- end
30
- end
31
-
32
- define_method(:"test_#{cmd_alias}_shows_an_error_if_file_not_found") do
33
- enter "#{cmd_alias} blabla"
34
- debug_proc(@example)
35
- check_error_includes(/File ".*blabla" not found/)
36
- end
37
-
38
- define_method(:"test_#{cmd_alias}_without_arguments_shows_help") do
39
- enter 'source'
40
- debug_proc(@example)
41
- check_output_includes(
42
- /Executes file <file> containing byebug commands./)
43
- end
44
- end
45
- end
46
- end
@@ -1,192 +0,0 @@
1
- module Byebug
2
- class Example
3
- def self.a(num)
4
- num += 2
5
- b(num)
6
- end
7
-
8
- def self.b(num)
9
- v2 = 5 if 1 == num ; [1, 2, v2].map { |t| t.to_f }
10
- c(num)
11
- end
12
-
13
- def self.c(num)
14
- num += 4
15
- num
16
- end
17
- end
18
-
19
- class BasicSteppingTestCase < TestCase
20
- def setup
21
- @example = -> do
22
- byebug
23
-
24
- ex = Example.c(7)
25
- ex
26
- end
27
-
28
- super
29
- end
30
-
31
- def test_next_goes_to_the_next_line
32
- enter 'next'
33
- debug_proc(@example) { assert_equal 25, state.line }
34
- end
35
-
36
- def test_n_goes_to_the_next_line
37
- enter 'n'
38
- debug_proc(@example) { assert_equal 25, state.line }
39
- end
40
-
41
- def test_step_goes_to_the_next_statement
42
- enter 'step'
43
- debug_proc(@example) { assert_equal 14, state.line }
44
- end
45
-
46
- def test_s_goes_to_the_next_statement
47
- enter 's'
48
- debug_proc(@example) { assert_equal 14, state.line }
49
- end
50
-
51
- def test_next_does_not_stop_at_byebug_internal_frames
52
- enter 'set forcestep', 'next 2'
53
- debug_proc(@example) { refute_match(/byebug.test.support/, state.file) }
54
- end
55
- end
56
-
57
- class AdvancedSteppingTestCase < TestCase
58
- def setup
59
- @example = -> do
60
- byebug
61
-
62
- ex = Example.a(7)
63
- 2.times do
64
- ex += 1
65
- end
66
-
67
- Example.b(ex)
68
- end
69
-
70
- super
71
-
72
- enter 'break 9', 'cont'
73
- end
74
-
75
- %w(next step).each do |cmd|
76
- define_method(:"test_#{cmd}_stays_by_default") do
77
- enter cmd
78
- debug_proc(@example) { assert_equal 9, state.line }
79
- end
80
-
81
- define_method(:"test_#{cmd}+_goes_2_next_line") do
82
- enter "#{cmd}+"
83
- debug_proc(@example) { assert_equal 10, state.line }
84
- end
85
-
86
- define_method(:"test_#{cmd}-_stays") do
87
- enter "#{cmd}-"
88
- debug_proc(@example) { assert_equal 9, state.line }
89
- end
90
-
91
- define_method(:"test_#{cmd}_goes_2_next_line_if_forcestep_is_set") do
92
- enter 'set forcestep', cmd
93
- debug_proc(@example) { assert_equal 10, state.line }
94
- end
95
-
96
- define_method(:"test_#{cmd}+_goes_2_next_line_regardless_forcestep") do
97
- enter 'set forcestep', "#{cmd}+"
98
- debug_proc(@example) { assert_equal 10, state.line }
99
- end
100
-
101
- define_method(:"test_#{cmd}-_stays_regardless_forcestep") do
102
- enter 'set forcestep', "#{cmd}-"
103
- debug_proc(@example) { assert_equal 9, state.line }
104
- end
105
- end
106
-
107
- def test_next_goes_the_specified_number_of_lines_forward_by_default
108
- enter 'set forcestep', 'next 2'
109
- debug_proc(@example) { assert_equal 63, state.line }
110
- end
111
-
112
- def test_next_informs_when_not_staying_in_the_same_frame
113
- enter 'set forcestep', 'next 2'
114
- debug_proc(@example)
115
- check_output_includes \
116
- 'Next went up a frame because previous frame finished'
117
- end
118
-
119
- def step_goes_the_specified_number_of_statements_forward_by_default
120
- enter 'set forcestep', 'step 2'
121
- debug_proc(@example) { assert_equal 63, state.line }
122
- end
123
-
124
- def test_next_steps_OVER_blocks
125
- enter 'break 63', 'cont', 'next'
126
- debug_proc(@example) { assert_equal 67, state.line }
127
- end
128
-
129
- def test_step_steps_INTO_blocks
130
- enter 'break 63', 'cont', 'step'
131
- debug_proc(@example) { assert_equal 64, state.line }
132
- end
133
- end
134
-
135
- class RaiseFromCMethodExample
136
- def a
137
- b
138
- rescue NameError
139
- 1
140
- end
141
-
142
- def b
143
- c
144
- end
145
-
146
- def c
147
- d
148
- end
149
- end
150
-
151
- class RaiseFromCMethodTestCase < TestCase
152
- def test_next_steps_over_rescue_when_raising_from_c_method
153
- example_raise = -> do
154
- byebug
155
-
156
- RaiseFromCMethodExample.new.a
157
- end
158
-
159
- enter 'break 137', 'cont', 'next'
160
- debug_proc(example_raise) { assert_equal 139, state.line }
161
- end
162
- end
163
-
164
- class RaiseFromRubyMethodExample
165
- def a
166
- b
167
- rescue
168
- 1
169
- end
170
-
171
- def b
172
- c
173
- end
174
-
175
- def c
176
- raise 'bang'
177
- end
178
- end
179
-
180
- class RaiseFromRubyMethodTestCase < TestCase
181
- def test_next_steps_over_rescue_when_raising_from_ruby_method
182
- example_raise = -> do
183
- byebug
184
-
185
- RaiseFromRubyMethodExample.new.a
186
- end
187
-
188
- enter 'break 166', 'cont', 'next'
189
- debug_proc(example_raise) { assert_equal 168, state.line }
190
- end
191
- end
192
- end