byebug 2.1.1 → 2.2.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 (81) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +9 -0
  4. data/CONTRIBUTING.md +13 -1
  5. data/GUIDE.md +181 -1
  6. data/README.md +67 -211
  7. data/Rakefile +1 -0
  8. data/bin/byebug +1 -8
  9. data/ext/byebug/byebug.c +66 -25
  10. data/ext/byebug/context.c +16 -20
  11. data/ext/byebug/extconf.rb +2 -1
  12. data/lib/byebug.rb +16 -9
  13. data/lib/byebug/command.rb +3 -3
  14. data/lib/byebug/commands/condition.rb +2 -2
  15. data/lib/byebug/commands/edit.rb +12 -9
  16. data/lib/byebug/commands/eval.rb +0 -16
  17. data/lib/byebug/commands/frame.rb +7 -17
  18. data/lib/byebug/commands/info.rb +2 -9
  19. data/lib/byebug/commands/list.rb +1 -1
  20. data/lib/byebug/commands/reload.rb +11 -0
  21. data/lib/byebug/commands/repl.rb +3 -6
  22. data/lib/byebug/commands/set.rb +5 -5
  23. data/lib/byebug/commands/show.rb +5 -0
  24. data/lib/byebug/commands/threads.rb +4 -4
  25. data/lib/byebug/commands/trace.rb +2 -1
  26. data/lib/byebug/context.rb +14 -5
  27. data/lib/byebug/interface.rb +1 -1
  28. data/lib/byebug/processor.rb +1 -1
  29. data/lib/byebug/remote.rb +1 -24
  30. data/lib/byebug/version.rb +1 -1
  31. data/old_doc/byebug.1 +0 -3
  32. data/old_doc/byebug.texi +2 -3
  33. data/test/breakpoints_test.rb +75 -52
  34. data/test/conditions_test.rb +2 -3
  35. data/test/continue_test.rb +6 -0
  36. data/test/edit_test.rb +3 -3
  37. data/test/eval_test.rb +14 -5
  38. data/test/examples/breakpoint.rb +4 -13
  39. data/test/examples/breakpoint_deep.rb +1 -21
  40. data/test/examples/conditions.rb +1 -1
  41. data/test/examples/continue.rb +2 -1
  42. data/test/examples/edit.rb +1 -0
  43. data/test/examples/eval.rb +1 -11
  44. data/test/examples/finish.rb +0 -17
  45. data/test/examples/frame.rb +2 -26
  46. data/test/examples/frame_deep.rb +0 -19
  47. data/test/examples/help.rb +0 -1
  48. data/test/examples/info.rb +4 -36
  49. data/test/examples/kill.rb +1 -1
  50. data/test/examples/list.rb +1 -1
  51. data/test/examples/method.rb +2 -13
  52. data/test/examples/post_mortem.rb +1 -16
  53. data/test/examples/quit.rb +1 -1
  54. data/test/examples/reload.rb +1 -1
  55. data/test/examples/restart.rb +1 -1
  56. data/test/examples/show.rb +0 -1
  57. data/test/examples/stepping.rb +2 -19
  58. data/test/examples/thread.rb +0 -27
  59. data/test/examples/variables.rb +0 -22
  60. data/test/finish_test.rb +22 -6
  61. data/test/frame_test.rb +89 -56
  62. data/test/info_test.rb +71 -46
  63. data/test/kill_test.rb +6 -1
  64. data/test/list_test.rb +1 -2
  65. data/test/method_test.rb +32 -13
  66. data/test/post_mortem_test.rb +34 -21
  67. data/test/quit_test.rb +0 -1
  68. data/test/restart_test.rb +6 -0
  69. data/test/set_test.rb +1 -1
  70. data/test/show_test.rb +17 -17
  71. data/test/source_test.rb +2 -3
  72. data/test/stepping_test.rb +31 -7
  73. data/test/support/test_dsl.rb +11 -1
  74. data/test/test_helper.rb +9 -0
  75. data/test/thread_test.rb +57 -23
  76. data/test/trace_test.rb +0 -1
  77. data/test/variables_test.rb +36 -17
  78. metadata +3 -9
  79. data/test/examples/breakpoint2.rb +0 -7
  80. data/test/examples/jump.rb +0 -14
  81. data/test/examples/set_annotate.rb +0 -12
@@ -6,19 +6,18 @@ class TestConditions < TestDsl::TestCase
6
6
  before { enter 'break 3' }
7
7
 
8
8
  describe 'successfully' do
9
+ before { enter ->{ "cond #{Byebug.breakpoints.first.id} b == 5" }, 'cont'}
10
+
9
11
  it 'must assign the expression to breakpoint' do
10
- enter ->{ "cond #{Byebug.breakpoints.first.id} b == 5" }, 'cont'
11
12
  debug_file('conditions') {
12
13
  Byebug.breakpoints.first.expr.must_equal 'b == 5' }
13
14
  end
14
15
 
15
16
  it 'must stop at the breakpoint if condition is true' do
16
- enter ->{ "cond #{Byebug.breakpoints.first.id} b == 5" }, 'cont'
17
17
  debug_file('conditions') { $state.line.must_equal 3 }
18
18
  end
19
19
 
20
20
  it 'must work with full command name too' do
21
- enter ->{ "condition #{Byebug.breakpoints.first.id} b == 5" }, 'cont'
22
21
  debug_file('conditions') { $state.line.must_equal 3 }
23
22
  end
24
23
  end
@@ -1,5 +1,11 @@
1
1
  require_relative 'test_helper'
2
2
 
3
+ class ContinueExample
4
+ def self.a(num)
5
+ num + 4
6
+ end
7
+ end
8
+
3
9
  class TestContinue < TestDsl::TestCase
4
10
 
5
11
  describe "successful" do
@@ -16,9 +16,9 @@ class TestEdit < TestDsl::TestCase
16
16
  describe 'open default editor' do
17
17
  temporary_change_hash ENV, 'EDITOR', nil
18
18
 
19
- it 'must call "ex" with current line and file if EDITOR env not set' do
19
+ it 'must call "vim" with current line and file if EDITOR env not set' do
20
20
  Byebug::Edit.any_instance.expects(:system).
21
- with("ex +2 #{fullpath('edit')}")
21
+ with("vim +2 #{fullpath('edit')}")
22
22
  enter 'edit'
23
23
  debug_file 'edit'
24
24
  end
@@ -44,6 +44,6 @@ class TestEdit < TestDsl::TestCase
44
44
  it 'must show an error if there is incorrect syntax' do
45
45
  enter 'edit blabla'
46
46
  debug_file 'edit'
47
- check_error_includes 'Invalid file/line number specification: blabla'
47
+ check_error_includes 'Invalid file[:line] number specification: blabla'
48
48
  end
49
49
  end
@@ -1,7 +1,16 @@
1
1
  require_relative 'test_helper'
2
2
 
3
- class TestEval < TestDsl::TestCase
3
+ class EvalTest
4
+ def sum(a,b)
5
+ a + b
6
+ end
7
+
8
+ def inspect
9
+ raise "Broken"
10
+ end
11
+ end
4
12
 
13
+ class TestEval < TestDsl::TestCase
5
14
  it 'must evaluate an expression' do
6
15
  enter 'eval 3 + 2'
7
16
  debug_file 'eval'
@@ -21,8 +30,8 @@ class TestEval < TestDsl::TestCase
21
30
  end
22
31
 
23
32
  it 'must work when inspect raises an exception' do
24
- enter 'c 14', 'p @foo'
25
- debug_file('eval') { $state.line.must_equal 14 }
33
+ enter 'c 4', 'p @foo'
34
+ debug_file('eval') { $state.line.must_equal 4 }
26
35
  check_output_includes 'RuntimeError Exception: Broken'
27
36
  end
28
37
 
@@ -49,7 +58,7 @@ class TestEval < TestDsl::TestCase
49
58
  it 'must show a stack trace' do
50
59
  enter 'eval 2 / 0'
51
60
  debug_file 'eval'
52
- check_output_includes /\s*from \S+:in \`eval\'/
61
+ check_output_includes(/\s*from \S+:in \`eval\'/)
53
62
  check_output_doesnt_include 'ZeroDivisionError Exception: divided by 0'
54
63
  end
55
64
  end
@@ -61,7 +70,7 @@ class TestEval < TestDsl::TestCase
61
70
  enter 'eval 2 / 0'
62
71
  debug_file 'eval'
63
72
  check_output_includes 'ZeroDivisionError Exception: divided by 0'
64
- check_output_doesnt_include /\S+:\d+:in `eval':divided by 0/
73
+ check_output_doesnt_include(/\S+:\d+:in `eval':divided by 0/)
65
74
  end
66
75
  end
67
76
  end
@@ -1,15 +1,6 @@
1
- class BreakpointExample
2
- def self.a
3
- 4
4
- end
5
- def b
6
- 3
7
- end
8
- end
9
-
10
- a = 3
1
+ y = 3
11
2
  # A comment
12
3
  byebug
13
- b = 5
14
- c = a + b
15
- load Pathname.new(__FILE__ + "/../breakpoint2.rb").cleanpath
4
+ z = 5
5
+ BreakpointExample.new.b
6
+ BreakpointExample.a(y+z)
@@ -1,24 +1,4 @@
1
- class SteppingExample
2
- def a
3
- z = 2
4
- b
5
- end
6
-
7
- def b
8
- v2 = 5 if 1 == 2 ; [1,2,3].map { |a| a.to_f }
9
- c
10
- end
11
-
12
- def c
13
- z = 4
14
- 5
15
- byebug
16
- end
17
- end
18
-
19
- ex = SteppingExample.new.a
1
+ ex = BreakpointDeepExample.new.a
20
2
  2.times do
21
3
  ex += 1
22
4
  end
23
-
24
- ex
@@ -1,4 +1,4 @@
1
1
  byebug
2
2
  b = 5
3
3
  c = b + 5
4
- c
4
+ c = Object.new
@@ -1,4 +1,5 @@
1
1
  byebug
2
+
2
3
  b = 5
3
4
  c = b + 5
4
- c
5
+ ContinueExample.a(c)
@@ -1,3 +1,4 @@
1
1
  byebug
2
2
  d = 1
3
3
  b = 2
4
+ DummyObject.new(b, d)
@@ -1,14 +1,4 @@
1
1
  byebug
2
2
 
3
- b = 5
4
- c = b + 5
5
- c
6
-
7
- class EvalTest
8
- def inspect
9
- raise "Broken"
10
- end
11
- end
12
-
13
3
  @foo = EvalTest.new
14
- b = 6
4
+ @foo.sum(1, 2)
@@ -1,20 +1,3 @@
1
1
  byebug
2
2
 
3
- class FinishExample
4
- def a
5
- b
6
- end
7
- def b
8
- c
9
- 2
10
- end
11
- def c
12
- d
13
- 3
14
- end
15
- def d
16
- 5
17
- end
18
- end
19
-
20
3
  FinishExample.new.a
@@ -1,28 +1,4 @@
1
1
  byebug
2
2
 
3
- class FrameExample
4
- def initialize(f)
5
- @f = f
6
- end
7
-
8
- def a
9
- b
10
- end
11
-
12
- def b
13
- c
14
- 2
15
- end
16
-
17
- def c
18
- d('a')
19
- 3
20
- end
21
-
22
- def d(e)
23
- 5
24
- end
25
- end
26
-
27
- local_var = "hola"
28
- FrameExample.new('f').a
3
+ fr_ex = FrameExample.new('f')
4
+ fr_ex.a()
@@ -1,20 +1 @@
1
- class FrameDeepExample
2
- def a
3
- z = 1
4
- z += b
5
- end
6
- def b
7
- z = 2
8
- z += c
9
- end
10
- def c
11
- z = 3
12
- byebug
13
- z += d('a')
14
- end
15
- def d(e)
16
- z = 4
17
- end
18
- end
19
-
20
1
  FrameDeepExample.new.a
@@ -1,2 +1 @@
1
1
  byebug
2
- 1
@@ -1,38 +1,6 @@
1
1
  byebug
2
- def bla(a, b)
3
- a + b
4
- end
5
- z = 5
6
- z = 6
7
- z = 7
8
- z = 8
9
- z = 9
10
- bla("a" * 30, "b")
11
2
 
12
- class InfoExample
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
- InfoExample.new.b
37
- InfoExample.new.a
38
- InfoExample.new.c
3
+ i = InfoExample.new
4
+ i.b
5
+ i.c
6
+ i.d
@@ -1,2 +1,2 @@
1
1
  byebug
2
- 1
2
+ KillExample.kill_me
@@ -20,4 +20,4 @@ a = 19
20
20
  a = 20
21
21
  a = 21
22
22
  a = 22
23
- a = '%23'
23
+ a = '%23'
@@ -1,15 +1,4 @@
1
1
  byebug
2
- class MethodExample
3
- def initialize
4
- @a = 'b'
5
- @c = 'd'
6
- end
7
- def self.foo
8
- "asdf"
9
- end
10
- def bla
11
- "asdf"
12
- end
13
- end
2
+
14
3
  a = MethodExample.new
15
- a
4
+ a.bla
@@ -1,19 +1,4 @@
1
1
  byebug
2
2
 
3
- class CatchExample
4
- def a
5
- begin
6
- Byebug.post_mortem do
7
- z = 4
8
- raise 'blabla'
9
- x = 6
10
- end
11
- rescue => e
12
- e
13
- end
14
- end
15
- end
16
-
17
- c = CatchExample.new
3
+ c = PostMortemExample.new
18
4
  c.a
19
- c
@@ -1,2 +1,2 @@
1
1
  byebug
2
- 1
2
+ DummyObject.new
@@ -3,4 +3,4 @@ a = 2
3
3
  a = 3
4
4
  a = 4
5
5
  a = 5
6
- a = 6
6
+ a = 6
@@ -3,4 +3,4 @@ byebug
3
3
  a = ARGV[0]
4
4
  b = ARGV[1]
5
5
  c = ARGV[2]
6
- d = a.to_s + b.to_s + c.to_s
6
+ RestartExample.new.concat_args(a, b, c)
@@ -1,2 +1 @@
1
1
  byebug
2
- 2
@@ -1,25 +1,8 @@
1
1
  byebug
2
2
 
3
- class SteppingExample
4
- def a
5
- z = 2
6
- b
7
- end
8
-
9
- def b
10
- v2 = 5 if 1 == 2 ; [1,2,3].map { |a| a.to_f }
11
- c
12
- end
13
-
14
- def c
15
- z = 4
16
- 5
17
- end
18
- end
19
-
20
- ex = SteppingExample.new.a
3
+ ex = SteppingExample.a(7)
21
4
  2.times do
22
5
  ex += 1
23
6
  end
24
7
 
25
- ex
8
+ SteppingExample.b(ex)
@@ -1,31 +1,4 @@
1
1
  byebug
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
2
 
30
3
  t = ThreadExample.new
31
4
  t.launch
@@ -1,26 +1,4 @@
1
1
  byebug
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
2
 
24
3
  v = VariablesExample.new
25
4
  v.run
26
- v