byebug 0.0.1

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 (133) hide show
  1. data/.gitignore +10 -0
  2. data/.travis.yml +8 -0
  3. data/AUTHORS +10 -0
  4. data/CHANGELOG.md +2 -0
  5. data/CONTRIBUTING.md +1 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE +20 -0
  8. data/README.md +5 -0
  9. data/Rakefile +28 -0
  10. data/bin/byebug +395 -0
  11. data/byebug.gemspec +29 -0
  12. data/doc/hanoi.rb +35 -0
  13. data/doc/primes.rb +28 -0
  14. data/doc/rdebug-emacs.texi +1030 -0
  15. data/doc/test-tri2.rb +18 -0
  16. data/doc/tri3.rb +8 -0
  17. data/doc/triangle.rb +12 -0
  18. data/ext/byebug/breakpoint.c +476 -0
  19. data/ext/byebug/byebug.c +512 -0
  20. data/ext/byebug/byebug.h +131 -0
  21. data/ext/byebug/context.c +424 -0
  22. data/ext/byebug/extconf.rb +21 -0
  23. data/ext/byebug/locker.c +53 -0
  24. data/lib/byebug.rb +404 -0
  25. data/lib/byebug/command.rb +232 -0
  26. data/lib/byebug/commands/breakpoints.rb +153 -0
  27. data/lib/byebug/commands/catchpoint.rb +56 -0
  28. data/lib/byebug/commands/condition.rb +49 -0
  29. data/lib/byebug/commands/continue.rb +38 -0
  30. data/lib/byebug/commands/control.rb +110 -0
  31. data/lib/byebug/commands/display.rb +122 -0
  32. data/lib/byebug/commands/edit.rb +48 -0
  33. data/lib/byebug/commands/enable.rb +202 -0
  34. data/lib/byebug/commands/eval.rb +176 -0
  35. data/lib/byebug/commands/finish.rb +43 -0
  36. data/lib/byebug/commands/frame.rb +303 -0
  37. data/lib/byebug/commands/help.rb +56 -0
  38. data/lib/byebug/commands/info.rb +462 -0
  39. data/lib/byebug/commands/irb.rb +123 -0
  40. data/lib/byebug/commands/jump.rb +66 -0
  41. data/lib/byebug/commands/kill.rb +51 -0
  42. data/lib/byebug/commands/list.rb +94 -0
  43. data/lib/byebug/commands/method.rb +84 -0
  44. data/lib/byebug/commands/quit.rb +39 -0
  45. data/lib/byebug/commands/reload.rb +40 -0
  46. data/lib/byebug/commands/save.rb +90 -0
  47. data/lib/byebug/commands/set.rb +210 -0
  48. data/lib/byebug/commands/show.rb +246 -0
  49. data/lib/byebug/commands/skip.rb +35 -0
  50. data/lib/byebug/commands/source.rb +36 -0
  51. data/lib/byebug/commands/stepping.rb +83 -0
  52. data/lib/byebug/commands/threads.rb +189 -0
  53. data/lib/byebug/commands/tmate.rb +36 -0
  54. data/lib/byebug/commands/trace.rb +56 -0
  55. data/lib/byebug/commands/variables.rb +199 -0
  56. data/lib/byebug/context.rb +58 -0
  57. data/lib/byebug/helper.rb +69 -0
  58. data/lib/byebug/interface.rb +223 -0
  59. data/lib/byebug/processor.rb +468 -0
  60. data/lib/byebug/version.rb +3 -0
  61. data/man/rdebug.1 +241 -0
  62. data/test/breakpoints_test.rb +357 -0
  63. data/test/conditions_test.rb +77 -0
  64. data/test/continue_test.rb +44 -0
  65. data/test/display_test.rb +141 -0
  66. data/test/edit_test.rb +56 -0
  67. data/test/eval_test.rb +92 -0
  68. data/test/examples/breakpoint1.rb +15 -0
  69. data/test/examples/breakpoint2.rb +7 -0
  70. data/test/examples/conditions.rb +4 -0
  71. data/test/examples/continue.rb +4 -0
  72. data/test/examples/display.rb +5 -0
  73. data/test/examples/edit.rb +3 -0
  74. data/test/examples/edit2.rb +3 -0
  75. data/test/examples/eval.rb +4 -0
  76. data/test/examples/finish.rb +20 -0
  77. data/test/examples/frame.rb +20 -0
  78. data/test/examples/frame_threads.rb +31 -0
  79. data/test/examples/help.rb +2 -0
  80. data/test/examples/info.rb +38 -0
  81. data/test/examples/info2.rb +3 -0
  82. data/test/examples/info_threads.rb +48 -0
  83. data/test/examples/irb.rb +6 -0
  84. data/test/examples/jump.rb +14 -0
  85. data/test/examples/kill.rb +2 -0
  86. data/test/examples/list.rb +12 -0
  87. data/test/examples/method.rb +15 -0
  88. data/test/examples/post_mortem.rb +19 -0
  89. data/test/examples/quit.rb +2 -0
  90. data/test/examples/reload.rb +6 -0
  91. data/test/examples/restart.rb +6 -0
  92. data/test/examples/save.rb +3 -0
  93. data/test/examples/set.rb +3 -0
  94. data/test/examples/set_annotate.rb +12 -0
  95. data/test/examples/settings.rb +1 -0
  96. data/test/examples/show.rb +2 -0
  97. data/test/examples/source.rb +3 -0
  98. data/test/examples/stepping.rb +21 -0
  99. data/test/examples/thread.rb +32 -0
  100. data/test/examples/tmate.rb +10 -0
  101. data/test/examples/trace.rb +7 -0
  102. data/test/examples/trace_threads.rb +20 -0
  103. data/test/examples/variables.rb +26 -0
  104. data/test/finish_test.rb +48 -0
  105. data/test/frame_test.rb +143 -0
  106. data/test/help_test.rb +50 -0
  107. data/test/info_test.rb +313 -0
  108. data/test/irb_test.rb +81 -0
  109. data/test/jump_test.rb +70 -0
  110. data/test/kill_test.rb +48 -0
  111. data/test/list_test.rb +145 -0
  112. data/test/method_test.rb +70 -0
  113. data/test/post_mortem_test.rb +27 -0
  114. data/test/quit_test.rb +56 -0
  115. data/test/reload_test.rb +44 -0
  116. data/test/restart_test.rb +164 -0
  117. data/test/save_test.rb +92 -0
  118. data/test/set_test.rb +177 -0
  119. data/test/show_test.rb +293 -0
  120. data/test/source_test.rb +45 -0
  121. data/test/stepping_test.rb +130 -0
  122. data/test/support/breakpoint.rb +13 -0
  123. data/test/support/context.rb +14 -0
  124. data/test/support/matchers.rb +67 -0
  125. data/test/support/mocha_extensions.rb +72 -0
  126. data/test/support/processor.rb +7 -0
  127. data/test/support/test_dsl.rb +206 -0
  128. data/test/support/test_interface.rb +68 -0
  129. data/test/test_helper.rb +10 -0
  130. data/test/tmate_test.rb +44 -0
  131. data/test/trace_test.rb +159 -0
  132. data/test/variables_test.rb +119 -0
  133. metadata +265 -0
@@ -0,0 +1,293 @@
1
+ require_relative 'test_helper'
2
+
3
+ describe "Show Command" do
4
+ include TestDsl
5
+
6
+ describe "annotate" do
7
+ temporary_change_method_value(Byebug, :annotate, nil)
8
+
9
+ it "must show annotate setting" do
10
+ enter 'show annotate'
11
+ debug_file 'show'
12
+ check_output_includes "Annotation level is 0"
13
+ end
14
+
15
+ it "must show annotate setting" do
16
+ enter 'show annotate'
17
+ debug_file 'show'
18
+ Byebug.annotate.must_equal 0
19
+ end
20
+ end
21
+
22
+
23
+ describe "args" do
24
+ temporary_change_hash_value(Byebug::Command.settings, :argv, %w{foo bar})
25
+
26
+ it "must show args" do
27
+ Byebug.send(:remove_const, "RDEBUG_SCRIPT") if Byebug.const_defined?("RDEBUG_SCRIPT")
28
+ enter 'show args'
29
+ debug_file 'show'
30
+ check_output_includes 'Argument list to give program being debugged when it is started is "foo bar".'
31
+ end
32
+
33
+ it "must not show the first arg if RDEBUG_SCRIPT is defined" do
34
+ temporary_set_const(Byebug, "RDEBUG_SCRIPT", "bla") do
35
+ enter 'show args'
36
+ debug_file 'show'
37
+ check_output_includes 'Argument list to give program being debugged when it is started is "bar".'
38
+ end
39
+ end
40
+ end
41
+
42
+
43
+ it "must show autolist" do
44
+ temporary_change_hash_value(Byebug::Command.settings, :autolist, 1) do
45
+ enter 'show autolist'
46
+ debug_file 'show'
47
+ check_output_includes 'autolist is on.'
48
+ end
49
+ end
50
+
51
+ it "must show autoeval" do
52
+ temporary_change_hash_value(Byebug::Command.settings, :autoeval, true) do
53
+ enter 'show autoeval'
54
+ debug_file 'show'
55
+ check_output_includes 'autoeval is on.'
56
+ end
57
+ end
58
+
59
+ it "must show autoreload" do
60
+ temporary_change_hash_value(Byebug::Command.settings, :reload_source_on_change, true) do
61
+ enter 'show autoreload'
62
+ debug_file 'show'
63
+ check_output_includes 'autoreload is on.'
64
+ end
65
+ end
66
+
67
+ it "must show autoirb" do
68
+ Byebug::IRBCommand.any_instance.stubs(:execute)
69
+ temporary_change_hash_value(Byebug::Command.settings, :autoirb, 1) do
70
+ enter 'show autoirb'
71
+ debug_file 'show'
72
+ check_output_includes 'autoirb is on.'
73
+ end
74
+ end
75
+
76
+ it "must show basename" do
77
+ temporary_change_hash_value(Byebug::Command.settings, :basename, true) do
78
+ enter 'show basename'
79
+ debug_file 'show'
80
+ check_output_includes 'basename is on.'
81
+ end
82
+ end
83
+
84
+ it "must show callstyle" do
85
+ temporary_change_hash_value(Byebug::Command.settings, :callstyle, :short) do
86
+ enter 'show callstyle'
87
+ debug_file 'show'
88
+ check_output_includes 'Frame call-display style is short.'
89
+ end
90
+ end
91
+
92
+ it "must show forcestep" do
93
+ temporary_change_hash_value(Byebug::Command.settings, :force_stepping, true) do
94
+ enter 'show forcestep'
95
+ debug_file 'show'
96
+ check_output_includes 'force-stepping is on.'
97
+ end
98
+ end
99
+
100
+ it "must show fullpath" do
101
+ temporary_change_hash_value(Byebug::Command.settings, :full_path, true) do
102
+ enter 'show fullpath'
103
+ debug_file 'show'
104
+ check_output_includes "Displaying frame's full file names is on."
105
+ end
106
+ end
107
+
108
+ it "must show linetrace" do
109
+ temporary_change_method_value(context, :tracing, true) do
110
+ enter 'show linetrace'
111
+ debug_file 'show'
112
+ check_output_includes "line tracing is on."
113
+ end
114
+ end
115
+
116
+
117
+ describe "linetrace+" do
118
+ it "must show a message when linetrace+ is on" do
119
+ temporary_change_hash_value(Byebug::Command.settings, :tracing_plus, true) do
120
+ enter 'show linetrace+'
121
+ debug_file 'show'
122
+ check_output_includes "line tracing style is different consecutive lines."
123
+ end
124
+ end
125
+
126
+ it "must show a message when linetrace+ is off" do
127
+ temporary_change_hash_value(Byebug::Command.settings, :tracing_plus, false) do
128
+ enter 'show linetrace+'
129
+ debug_file 'show'
130
+ check_output_includes "line tracing style is every line."
131
+ end
132
+ end
133
+ end
134
+
135
+
136
+ it "must show listsize" do
137
+ temporary_change_hash_value(Byebug::Command.settings, :listsize, 10) do
138
+ enter 'show listsize'
139
+ debug_file 'show'
140
+ check_output_includes 'Number of source lines to list by default is 10.'
141
+ end
142
+ end
143
+
144
+ it "must show port" do
145
+ temporary_set_const(Byebug, "PORT", 12345) do
146
+ enter 'show port'
147
+ debug_file 'show'
148
+ check_output_includes 'server port is 12345.'
149
+ end
150
+ end
151
+
152
+ it "must show trace" do
153
+ temporary_change_hash_value(Byebug::Command.settings, :stack_trace_on_error, true) do
154
+ enter 'show trace'
155
+ debug_file 'show'
156
+ check_output_includes "Displaying stack trace is on."
157
+ end
158
+ end
159
+
160
+ it "must show version" do
161
+ enter 'show version'
162
+ debug_file 'show'
163
+ check_output_includes "byebug #{Byebug::VERSION}"
164
+ end
165
+
166
+ it "must show forcestep" do
167
+ temporary_change_hash_value(Byebug::Command.settings, :width, 35) do
168
+ enter 'show width'
169
+ debug_file 'show'
170
+ check_output_includes 'width is 35.'
171
+ end
172
+ end
173
+
174
+ it "must show a message about unknown command" do
175
+ enter 'show bla'
176
+ debug_file 'show'
177
+ check_output_includes 'Unknown show command bla'
178
+ end
179
+
180
+
181
+ describe "history" do
182
+ describe "without arguments" do
183
+ before do
184
+ interface.histfile = "hist_file.txt"
185
+ interface.history_save = true
186
+ interface.history_length = 25
187
+ enter 'show history'
188
+ debug_file 'show'
189
+ end
190
+
191
+ it "must show history file" do
192
+ check_output_includes /filename: The filename in which to record the command history is "hist_file\.txt"/
193
+ end
194
+
195
+ it "must show history save setting" do
196
+ check_output_includes /save: Saving of history save is on\./
197
+ end
198
+
199
+ it "must show history length" do
200
+ check_output_includes /size: Byebug history size is 25/
201
+ end
202
+ end
203
+
204
+ describe "with 'filename' argument" do
205
+ it "must show history filename" do
206
+ interface.histfile = "hist_file.txt"
207
+ enter 'show history filename'
208
+ debug_file 'show'
209
+ check_output_includes 'The filename in which to record the command history is "hist_file.txt"'
210
+ end
211
+
212
+ it "must show history save setting" do
213
+ interface.history_save = true
214
+ enter 'show history save'
215
+ debug_file 'show'
216
+ check_output_includes 'Saving of history save is on.'
217
+ end
218
+
219
+ it "must show history length" do
220
+ interface.history_length = 30
221
+ enter 'show history size'
222
+ debug_file 'show'
223
+ check_output_includes 'Byebug history size is 30'
224
+ end
225
+ end
226
+ end
227
+
228
+
229
+ describe "commands" do
230
+ before { interface.readline_support = true }
231
+
232
+ it "must not show records from readline if there is no readline support" do
233
+ interface.readline_support = false
234
+ enter 'show commands'
235
+ debug_file 'show'
236
+ check_output_includes "No readline support"
237
+ end
238
+
239
+ it "must show records from readline history" do
240
+ temporary_set_const(Readline, "HISTORY", %w{aaa bbb ccc ddd eee fff}) do
241
+ enter 'show commands'
242
+ debug_file 'show'
243
+ check_output_includes /1 aaa/
244
+ check_output_includes /6 fff/
245
+ end
246
+ end
247
+
248
+ it "must show last 10 records from readline history" do
249
+ temporary_set_const(Readline, "HISTORY", %w{aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm nnn}) do
250
+ enter 'show commands'
251
+ debug_file 'show'
252
+ check_output_doesnt_include /3 ccc/
253
+ check_output_includes /4 eee/
254
+ check_output_includes /13 nnn/
255
+ end
256
+ end
257
+
258
+ describe "with specified positions" do
259
+ it "must show records within boundaries" do
260
+ temporary_set_const(Readline, "HISTORY", %w{aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm nnn}) do
261
+ # Really don't know why it substracts 4, and shows starting from position 6
262
+ enter 'show commands 10'
263
+ debug_file 'show'
264
+ check_output_doesnt_include /5 fff/
265
+ check_output_includes /6 ggg/
266
+ check_output_includes /13 nnn/
267
+ end
268
+ end
269
+
270
+ it "must adjust first line if it is < 0" do
271
+ temporary_set_const(Readline, "HISTORY", %w{aaa bbb ccc ddd eee fff ggg hhh iii jjj kkk lll mmm nnn}) do
272
+ enter 'show commands 3'
273
+ debug_file 'show'
274
+ check_output_includes /1 bbb/
275
+ check_output_includes /8 iii/
276
+ check_output_doesnt_include /9 jjj/
277
+ end
278
+ end
279
+ end
280
+ end
281
+
282
+ describe "Post Mortem" do
283
+ temporary_change_hash_value(Byebug::Command.settings, :autolist, 0)
284
+
285
+ it "must work in post-mortem mode" do
286
+ skip("No post morten mode for now")
287
+ #enter 'cont', "show autolist"
288
+ #debug_file 'post_mortem'
289
+ #check_output_includes "autolist is off."
290
+ end
291
+ end
292
+
293
+ end
@@ -0,0 +1,45 @@
1
+ require_relative 'test_helper'
2
+
3
+ describe "Source Command" do
4
+ include TestDsl
5
+
6
+ let(:filename) { 'source_example.txt' }
7
+ before do
8
+ File.open(filename, 'w') do |f|
9
+ f.puts 'break 2'
10
+ f.puts 'break 3 if true'
11
+ end
12
+ end
13
+ after do
14
+ FileUtils.rm(filename)
15
+ end
16
+
17
+ it "must run commands from file" do
18
+ enter "source #{filename}"
19
+ debug_file 'source' do
20
+ Byebug.breakpoints[0].pos.must_equal 2
21
+ Byebug.breakpoints[1].pos.must_equal 3
22
+ Byebug.breakpoints[1].expr.must_equal "true"
23
+ end
24
+ end
25
+
26
+ it "must be able to use shortcut" do
27
+ enter "so #{filename}"
28
+ debug_file('source') { Byebug.breakpoints[0].pos.must_equal 2 }
29
+ end
30
+
31
+ it "must show an error if file is not found" do
32
+ enter "source blabla"
33
+ debug_file 'source'
34
+ check_output_includes /Command file '.*blabla' is not found/, interface.error_queue
35
+ end
36
+
37
+ describe "Post Mortem" do
38
+ it "must work in post-mortem mode" do
39
+ skip("No post morten mode for now")
40
+ #enter 'cont', "so #{filename}"
41
+ #debug_file('post_mortem') { Byebug.breakpoints[0].pos.must_equal 3 }
42
+ end
43
+ end
44
+
45
+ end
@@ -0,0 +1,130 @@
1
+ require_relative 'test_helper'
2
+
3
+ describe "Stepping Commands" do
4
+ include TestDsl
5
+
6
+ describe "Next Command" do
7
+
8
+ describe "Usual mode" do
9
+
10
+ before { enter 'break 10', 'cont' }
11
+
12
+ it "must go to the next line if forced by a setting" do
13
+ temporary_change_hash_value(
14
+ Byebug::Command.settings, :force_stepping, true) do
15
+ enter 'next'
16
+ debug_file('stepping') { state.line.must_equal 11 }
17
+ end
18
+ end
19
+
20
+ it "must go to the next line if forced by a setting (by shortcut)" do
21
+ temporary_change_hash_value(
22
+ Byebug::Command.settings, :force_stepping, true) do
23
+ enter 'n'
24
+ debug_file('stepping') { state.line.must_equal 11 }
25
+ end
26
+ end
27
+
28
+ it "must leave on the same line if forced by a setting" do
29
+ temporary_change_hash_value(
30
+ Byebug::Command.settings, :force_stepping, false) do
31
+ enter 'next'
32
+ debug_file('stepping') { state.line.must_equal 10 }
33
+ end
34
+ end
35
+
36
+ it "must go to the specified number of lines forward by default" do
37
+ temporary_change_hash_value(
38
+ Byebug::Command.settings, :force_stepping, true) do
39
+ enter 'next 2'
40
+ debug_file('stepping') { state.line.must_equal 21 }
41
+ end
42
+ end
43
+
44
+ it "must go to the next line if forced to do that by 'plus' sign" do
45
+ enter 'next+'
46
+ debug_file('stepping') { state.line.must_equal 11 }
47
+ end
48
+
49
+ it "must leave on the same line if forced to do that by 'minus' sign" do
50
+ enter 'next-'
51
+ debug_file('stepping') { state.line.must_equal 10 }
52
+ end
53
+
54
+ it "must ignore the setting if 'minus' is specified" do
55
+ enter 'next-'
56
+ debug_file('stepping') { state.line.must_equal 10 }
57
+ end
58
+ end
59
+
60
+ describe "Post Mortem" do
61
+ temporary_change_hash_value(Byebug::Command.settings, :autoeval, false)
62
+ it "must not work in post-mortem mode" do
63
+ skip("No post morten mode for now")
64
+ #enter 'cont', "next"
65
+ #debug_file('post_mortem')
66
+ #check_output_includes 'Unknown command: "next". Try "help".', interface.error_queue
67
+ end
68
+ end
69
+ end
70
+
71
+
72
+ describe "Step Command" do
73
+ describe "Usual mode" do
74
+ before { enter 'break 10', 'cont' }
75
+
76
+ it "must go to the step line if forced by a setting" do
77
+ temporary_change_hash_value(
78
+ Byebug::Command.settings, :force_stepping, true) do
79
+ enter 'step'
80
+ debug_file('stepping') { state.line.must_equal 11 }
81
+ end
82
+ end
83
+
84
+ it "must go to the next line by shortcut" do
85
+ temporary_change_hash_value(
86
+ Byebug::Command.settings, :force_stepping, true) do
87
+ enter 's'
88
+ debug_file('stepping') { state.line.must_equal 11 }
89
+ end
90
+ end
91
+
92
+ it "must leave on the same line if forced by a setting" do
93
+ temporary_change_hash_value(
94
+ Byebug::Command.settings, :force_stepping, false) do
95
+ enter 'step'
96
+ debug_file('stepping') { state.line.must_equal 10 }
97
+ end
98
+ end
99
+
100
+ it "must go to the specified number of lines forward by default" do
101
+ temporary_change_hash_value(
102
+ Byebug::Command.settings, :force_stepping, true) do
103
+ enter 'step 2'
104
+ debug_file('stepping') { state.line.must_equal 15 }
105
+ end
106
+ end
107
+
108
+ it "must go to the step line if forced to do that by 'plus' sign" do
109
+ enter 'step+'
110
+ debug_file('stepping') { state.line.must_equal 11 }
111
+ end
112
+
113
+ it "must leave on the same line if forced to do that by 'minus' sign" do
114
+ enter 'step-'
115
+ debug_file('stepping') { state.line.must_equal 10 }
116
+ end
117
+ end
118
+
119
+ describe "Post Mortem" do
120
+ temporary_change_hash_value(Byebug::Command.settings, :autoeval, false)
121
+ it "must not work in post-mortem mode" do
122
+ skip("No post morten mode for now")
123
+ #enter 'cont', "step"
124
+ #debug_file('post_mortem')
125
+ #check_output_includes 'Unknown command: "step". Try "help".', interface.error_queue
126
+ end
127
+ end
128
+ end
129
+
130
+ end