byebug 3.2.0 → 3.3.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 (127) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/CHANGELOG.md +125 -99
  4. data/CONTRIBUTING.md +4 -6
  5. data/GUIDE.md +42 -20
  6. data/Gemfile +5 -3
  7. data/README.md +2 -3
  8. data/Rakefile +11 -7
  9. data/bin/byebug +2 -252
  10. data/byebug.gemspec +7 -4
  11. data/ext/byebug/byebug.c +17 -18
  12. data/ext/byebug/byebug.h +4 -5
  13. data/ext/byebug/context.c +37 -39
  14. data/ext/byebug/threads.c +39 -18
  15. data/lib/byebug.rb +2 -110
  16. data/lib/byebug/attacher.rb +23 -0
  17. data/lib/byebug/breakpoint.rb +60 -0
  18. data/lib/byebug/command.rb +62 -70
  19. data/lib/byebug/commands/break.rb +24 -24
  20. data/lib/byebug/commands/catchpoint.rb +18 -10
  21. data/lib/byebug/commands/condition.rb +18 -17
  22. data/lib/byebug/commands/continue.rb +17 -9
  23. data/lib/byebug/commands/delete.rb +19 -13
  24. data/lib/byebug/commands/display.rb +19 -53
  25. data/lib/byebug/commands/edit.rb +7 -4
  26. data/lib/byebug/commands/enable_disable.rb +130 -0
  27. data/lib/byebug/commands/eval.rb +40 -22
  28. data/lib/byebug/commands/finish.rb +13 -4
  29. data/lib/byebug/commands/frame.rb +65 -45
  30. data/lib/byebug/commands/help.rb +17 -18
  31. data/lib/byebug/commands/history.rb +14 -8
  32. data/lib/byebug/commands/info.rb +160 -182
  33. data/lib/byebug/commands/interrupt.rb +4 -1
  34. data/lib/byebug/commands/irb.rb +30 -0
  35. data/lib/byebug/commands/kill.rb +7 -8
  36. data/lib/byebug/commands/list.rb +71 -66
  37. data/lib/byebug/commands/method.rb +14 -6
  38. data/lib/byebug/commands/pry.rb +35 -0
  39. data/lib/byebug/commands/quit.rb +9 -6
  40. data/lib/byebug/commands/reload.rb +5 -2
  41. data/lib/byebug/commands/restart.rb +13 -9
  42. data/lib/byebug/commands/save.rb +17 -17
  43. data/lib/byebug/commands/set.rb +16 -15
  44. data/lib/byebug/commands/show.rb +10 -11
  45. data/lib/byebug/commands/source.rb +11 -5
  46. data/lib/byebug/commands/stepping.rb +38 -24
  47. data/lib/byebug/commands/threads.rb +45 -31
  48. data/lib/byebug/commands/trace.rb +22 -9
  49. data/lib/byebug/commands/undisplay.rb +45 -0
  50. data/lib/byebug/commands/variables.rb +83 -27
  51. data/lib/byebug/context.rb +25 -22
  52. data/lib/byebug/core.rb +82 -0
  53. data/lib/byebug/helper.rb +37 -28
  54. data/lib/byebug/history.rb +8 -4
  55. data/lib/byebug/interface.rb +12 -17
  56. data/lib/byebug/interfaces/local_interface.rb +11 -8
  57. data/lib/byebug/interfaces/remote_interface.rb +11 -8
  58. data/lib/byebug/interfaces/script_interface.rb +9 -6
  59. data/lib/byebug/options.rb +46 -0
  60. data/lib/byebug/processor.rb +7 -1
  61. data/lib/byebug/processors/command_processor.rb +135 -125
  62. data/lib/byebug/processors/control_command_processor.rb +23 -23
  63. data/lib/byebug/remote.rb +17 -26
  64. data/lib/byebug/runner.rb +100 -0
  65. data/lib/byebug/setting.rb +33 -8
  66. data/lib/byebug/settings/autoeval.rb +5 -15
  67. data/lib/byebug/settings/autoirb.rb +4 -1
  68. data/lib/byebug/settings/autolist.rb +5 -2
  69. data/lib/byebug/settings/autoreload.rb +5 -2
  70. data/lib/byebug/settings/autosave.rb +6 -2
  71. data/lib/byebug/settings/basename.rb +7 -2
  72. data/lib/byebug/settings/callstyle.rb +4 -1
  73. data/lib/byebug/settings/forcestep.rb +6 -3
  74. data/lib/byebug/settings/fullpath.rb +5 -2
  75. data/lib/byebug/settings/histfile.rb +5 -3
  76. data/lib/byebug/settings/histsize.rb +5 -3
  77. data/lib/byebug/settings/linetrace.rb +4 -1
  78. data/lib/byebug/settings/listsize.rb +5 -1
  79. data/lib/byebug/settings/post_mortem.rb +21 -13
  80. data/lib/byebug/settings/stack_on_error.rb +6 -2
  81. data/lib/byebug/settings/testing.rb +6 -1
  82. data/lib/byebug/settings/tracing_plus.rb +5 -1
  83. data/lib/byebug/settings/verbose.rb +13 -2
  84. data/lib/byebug/settings/width.rb +4 -1
  85. data/lib/byebug/version.rb +1 -1
  86. data/test/{break_test.rb → commands/break_test.rb} +41 -53
  87. data/test/{condition_test.rb → commands/condition_test.rb} +14 -14
  88. data/test/{continue_test.rb → commands/continue_test.rb} +0 -0
  89. data/test/{delete_test.rb → commands/delete_test.rb} +2 -2
  90. data/test/commands/display_test.rb +37 -0
  91. data/test/{edit_test.rb → commands/edit_test.rb} +0 -0
  92. data/test/{eval_test.rb → commands/eval_test.rb} +1 -0
  93. data/test/{finish_test.rb → commands/finish_test.rb} +11 -1
  94. data/test/{frame_test.rb → commands/frame_test.rb} +12 -16
  95. data/test/{help_test.rb → commands/help_test.rb} +21 -4
  96. data/test/{history_test.rb → commands/history_test.rb} +0 -0
  97. data/test/{info_test.rb → commands/info_test.rb} +5 -55
  98. data/test/{interrupt_test.rb → commands/interrupt_test.rb} +0 -0
  99. data/test/commands/irb_test.rb +28 -0
  100. data/test/{kill_test.rb → commands/kill_test.rb} +1 -1
  101. data/test/{list_test.rb → commands/list_test.rb} +1 -1
  102. data/test/{method_test.rb → commands/method_test.rb} +0 -0
  103. data/test/{post_mortem_test.rb → commands/post_mortem_test.rb} +6 -10
  104. data/test/{pry_test.rb → commands/pry_test.rb} +4 -13
  105. data/test/{quit_test.rb → commands/quit_test.rb} +4 -4
  106. data/test/{reload_test.rb → commands/reload_test.rb} +0 -0
  107. data/test/{restart_test.rb → commands/restart_test.rb} +6 -0
  108. data/test/{save_test.rb → commands/save_test.rb} +2 -2
  109. data/test/{set_test.rb → commands/set_test.rb} +9 -2
  110. data/test/{show_test.rb → commands/show_test.rb} +1 -1
  111. data/test/{source_test.rb → commands/source_test.rb} +3 -3
  112. data/test/{stepping_test.rb → commands/stepping_test.rb} +44 -35
  113. data/test/{thread_test.rb → commands/thread_test.rb} +0 -0
  114. data/test/{trace_test.rb → commands/trace_test.rb} +0 -0
  115. data/test/{display_test.rb → commands/undisplay_test.rb} +7 -45
  116. data/test/{variables_test.rb → commands/variables_test.rb} +10 -1
  117. data/test/debugger_alias_test.rb +2 -2
  118. data/test/runner_test.rb +127 -0
  119. data/test/support/matchers.rb +27 -25
  120. data/test/support/test_interface.rb +9 -5
  121. data/test/support/utils.rb +96 -101
  122. data/test/test_helper.rb +32 -20
  123. metadata +93 -68
  124. data/lib/byebug/commands/enable.rb +0 -154
  125. data/lib/byebug/commands/repl.rb +0 -126
  126. data/test/irb_test.rb +0 -47
  127. data/test/support/breakpoint.rb +0 -13
@@ -1,154 +0,0 @@
1
- module Byebug
2
- #
3
- # Mixin to assist command parsing
4
- #
5
- module EnableDisableFunctions
6
- def enable_disable_breakpoints(is_enable, args)
7
- return errmsg "No breakpoints have been set" if Byebug.breakpoints.empty?
8
-
9
- all_breakpoints = Byebug.breakpoints.sort_by {|b| b.id }
10
- if args.empty?
11
- selected_breakpoints = all_breakpoints
12
- else
13
- selected_ids = []
14
- args.each do |pos|
15
- pos = get_int(pos, "#{is_enable} breakpoints", 1, all_breakpoints.last.id)
16
- return nil unless pos
17
- selected_ids << pos
18
- end
19
- selected_breakpoints = all_breakpoints.select {
20
- |b| selected_ids.include?(b.id) }
21
- end
22
-
23
- selected_breakpoints.each do |b|
24
- enabled = ('enable' == is_enable)
25
- if enabled && !syntax_valid?(b.expr)
26
- errmsg "Expression \"#{b.expr}\" syntactically incorrect; " \
27
- "breakpoint remains disabled.\n"
28
- else
29
- b.enabled = enabled
30
- end
31
- end
32
- end
33
-
34
- def enable_disable_display(is_enable, args)
35
- if 0 == @state.display.size
36
- return errmsg "No display expressions have been set\n"
37
- end
38
- args.each do |pos|
39
- pos = get_int(pos, "#{is_enable} display", 1, @state.display.size)
40
- return nil unless pos
41
- @state.display[pos-1][0] = ('enable' == is_enable)
42
- end
43
- end
44
- end
45
-
46
- class EnableCommand < Command
47
- Subcommands = [
48
- ['breakpoints', 2, 'Enable breakpoints. This is used to cancel the ' \
49
- 'effect of the "disable" command. Give breakpoint' \
50
- ' numbers (separated by spaces) as arguments or ' \
51
- 'no argument at all if you want to reenable ' \
52
- 'every breakpoint' ],
53
- ['display' , 2, 'Enable some expressions to be displayed when ' \
54
- 'program stops. Arguments are the code numbers of' \
55
- ' the expressions to resume displaying. Do "info ' \
56
- 'display" to see the current list of code numbers' ]
57
- ].map do |name, min, help|
58
- Subcmd.new(name, min, help)
59
- end unless defined?(Subcommands)
60
-
61
- def regexp
62
- /^\s* en(?:able)? (?:\s+(.+))? \s*$/x
63
- end
64
-
65
- def execute
66
- return errmsg "\"enable\" must be followed by \"display\", " \
67
- "\"breakpoints\" or breakpoint ids\n" unless @match[1]
68
-
69
- args = @match[1].split(/[ \t]+/)
70
- param = args.shift
71
- subcmd = Command.find(Subcommands, param)
72
- if subcmd
73
- send("enable_#{subcmd.name}", args)
74
- else
75
- send('enable_breakpoints', args.unshift(param))
76
- end
77
- end
78
-
79
- def enable_breakpoints(args)
80
- enable_disable_breakpoints('enable', args)
81
- end
82
-
83
- def enable_display(args)
84
- enable_disable_display('enable', args)
85
- end
86
-
87
- class << self
88
- def names
89
- %w(enable)
90
- end
91
-
92
- def description
93
- %{Enable breakpoints or displays.
94
-
95
- This is used to cancel the effect of the "disable" command.}
96
- end
97
- end
98
- end
99
-
100
- class DisableCommand < Command
101
- Subcommands = [
102
- ['breakpoints', 1, 'Disable breakpoints. A disabled breakpoint is ' \
103
- 'not forgotten, but has no effect until ' \
104
- 'reenabled. Give breakpoint numbers (separated by' \
105
- 'spaces) as arguments or no argument at all if ' \
106
- 'you want to disable every breakpoint' ],
107
- ['display' , 1, 'Disable some display expressions when program ' \
108
- 'stops. Arguments are the code numbers of the ' \
109
- 'expressions to stop displaying. Do "info ' \
110
- 'display" to see the current list of code numbers.' ]
111
- ].map do |name, min, help|
112
- Subcmd.new(name, min, help)
113
- end unless defined?(Subcommands)
114
-
115
- def regexp
116
- /^\s* dis(?:able)? (?:\s+(.+))? \s*$/x
117
- end
118
-
119
- def execute
120
- return errmsg "\"disable\" must be followed by \"display\", " \
121
- "\"breakpoints\" or breakpoint ids\n" unless @match[1]
122
-
123
- args = @match[1].split(/[ \t]+/)
124
- param = args.shift
125
- subcmd = Command.find(Subcommands, param)
126
- if subcmd
127
- send("disable_#{subcmd.name}", args)
128
- else
129
- send('disable_breakpoints', args.unshift(param))
130
- end
131
- end
132
-
133
- def disable_breakpoints(args)
134
- enable_disable_breakpoints('disable', args)
135
- end
136
-
137
- def disable_display(args)
138
- enable_disable_display('disable', args)
139
- end
140
-
141
- class << self
142
- def names
143
- %w(disable)
144
- end
145
-
146
- def description
147
- %{Disable breakpoints or displays.
148
-
149
- A disabled item is not forgotten, but has no effect until reenabled.
150
- Use the "enable" command to have it take effect again.}
151
- end
152
- end
153
- end
154
- end
@@ -1,126 +0,0 @@
1
- module IRB
2
- module ExtendCommand
3
- class Continue
4
- def self.execute(conf)
5
- throw :IRB_EXIT, :cont
6
- end
7
- end
8
- class Next
9
- def self.execute(conf)
10
- throw :IRB_EXIT, :next
11
- end
12
- end
13
- class Step
14
- def self.execute(conf)
15
- throw :IRB_EXIT, :step
16
- end
17
- end
18
- end
19
-
20
- require 'irb'
21
- ExtendCommandBundle.def_extend_command 'cont', :Continue
22
- ExtendCommandBundle.def_extend_command 'next', :Next
23
- ExtendCommandBundle.def_extend_command 'step', :Step
24
-
25
- def self.start_session(binding)
26
- unless @__initialized ||= false
27
- args = ARGV.dup
28
- ARGV.replace([])
29
- IRB.setup(nil)
30
- ARGV.replace(args)
31
- @__initialized = true
32
- end
33
-
34
- workspace = WorkSpace.new(binding)
35
- irb = Irb.new(workspace)
36
-
37
- @CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
38
- @CONF[:MAIN_CONTEXT] = irb.context
39
-
40
- trap('SIGINT') do
41
- irb.signal_handle
42
- end
43
-
44
- catch(:IRB_EXIT) do
45
- irb.eval_input
46
- end
47
- end
48
- end
49
-
50
- module Byebug
51
- class IrbCommand < Command
52
- def regexp
53
- /^\s* irb \s*$/x
54
- end
55
-
56
- def execute
57
- unless @state.interface.kind_of?(LocalInterface)
58
- print "Command is available only in local mode.\n"
59
- throw :debug_error
60
- end
61
-
62
- cont = IRB.start_session(get_binding)
63
- case cont
64
- when :cont
65
- @state.proceed
66
- when :step
67
- force = Setting[:forcestep]
68
- @state.context.step_into 1, force
69
- @state.proceed
70
- when :next
71
- force = Setting[:forcestep]
72
- @state.context.step_over 1, @state.frame_pos, force
73
- @state.proceed
74
- else
75
- print @state.location
76
- @state.previous_line = nil
77
- end
78
- end
79
-
80
- class << self
81
- def names
82
- %w(irb)
83
- end
84
-
85
- def description
86
- %{irb\tstarts an Interactive Ruby (IRB) session.
87
-
88
- IRB is extended with methods "cont", "n" and "step" which run the
89
- corresponding byebug commands. In contrast to the real byebug commands
90
- these commands don't allow arguments.}
91
- end
92
- end
93
- end
94
-
95
- begin
96
- require 'pry'
97
- has_pry = true
98
- rescue LoadError
99
- has_pry = false
100
- end
101
-
102
- class PryCommand < Command
103
- def regexp
104
- /^\s* pry \s*$/x
105
- end
106
-
107
- def execute
108
- unless @state.interface.kind_of?(LocalInterface)
109
- print "Command is available only in local mode.\n"
110
- throw :debug_error
111
- end
112
-
113
- get_binding.pry
114
- end
115
-
116
- class << self
117
- def names
118
- %w(pry)
119
- end
120
-
121
- def description
122
- %{pry\tstarts a Pry session.}
123
- end
124
- end
125
- end if has_pry
126
- end
@@ -1,47 +0,0 @@
1
- module Byebug
2
- class IrbTestCase < TestCase
3
- def setup
4
- @example = -> do
5
- byebug
6
- a = 2
7
- a = 3
8
- a = 4
9
- a = 5
10
- a = 6
11
- end
12
-
13
- super
14
-
15
- interface.stubs(:kind_of?).with(LocalInterface).returns(true)
16
- IRB::Irb.stubs(:new).returns(irb)
17
- end
18
-
19
- def irb
20
- @irb ||= stub(context: -> {})
21
- end
22
-
23
- def test_irb_supports_next_command
24
- irb.stubs(:eval_input).throws(:IRB_EXIT, :next)
25
- enter 'irb'
26
- debug_proc(@example) { assert_equal 7, state.line }
27
- end
28
-
29
- def test_irb_supports_step_command
30
- irb.stubs(:eval_input).throws(:IRB_EXIT, :step)
31
- enter 'irb'
32
- debug_proc(@example) { assert_equal 7, state.line }
33
- end
34
-
35
- def test_irb_supports_cont_command
36
- irb.stubs(:eval_input).throws(:IRB_EXIT, :cont)
37
- enter 'break 8', 'irb'
38
- debug_proc(@example) { assert_equal 8, state.line }
39
- end
40
-
41
- def test_autoirb_calls_irb_automatically_after_every_stop
42
- irb.expects(:eval_input)
43
- enter 'set autoirb', 'break 8', 'cont'
44
- debug_proc(@example)
45
- end
46
- end
47
- end
@@ -1,13 +0,0 @@
1
- module Byebug
2
-
3
- class Breakpoint
4
-
5
- def inspect
6
- values = %w{id pos source expr hit_condition hit_count hit_value enabled?}.map do |field|
7
- "#{field}: #{send(field)}"
8
- end.join(", ")
9
- "#<Byebug::Breakpoint #{values}>"
10
- end
11
-
12
- end
13
- end