byebug 4.0.5 → 5.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 (96) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +72 -34
  3. data/CONTRIBUTING.md +26 -31
  4. data/README.md +3 -3
  5. data/lib/byebug/breakpoint.rb +2 -1
  6. data/lib/byebug/command.rb +27 -49
  7. data/lib/byebug/commands/break.rb +21 -15
  8. data/lib/byebug/commands/catch.rb +9 -15
  9. data/lib/byebug/commands/condition.rb +12 -15
  10. data/lib/byebug/commands/continue.rb +8 -11
  11. data/lib/byebug/commands/delete.rb +9 -12
  12. data/lib/byebug/commands/disable.rb +32 -0
  13. data/lib/byebug/commands/disable/breakpoints.rb +38 -0
  14. data/lib/byebug/commands/disable/display.rb +39 -0
  15. data/lib/byebug/commands/display.rb +18 -51
  16. data/lib/byebug/commands/down.rb +39 -0
  17. data/lib/byebug/commands/edit.rb +8 -14
  18. data/lib/byebug/commands/enable.rb +25 -0
  19. data/lib/byebug/commands/enable/breakpoints.rb +38 -0
  20. data/lib/byebug/commands/enable/display.rb +39 -0
  21. data/lib/byebug/commands/eval.rb +10 -192
  22. data/lib/byebug/commands/finish.rb +11 -12
  23. data/lib/byebug/commands/frame.rb +17 -182
  24. data/lib/byebug/commands/help.rb +18 -18
  25. data/lib/byebug/commands/history.rb +9 -10
  26. data/lib/byebug/commands/info.rb +17 -190
  27. data/lib/byebug/commands/info/args.rb +39 -0
  28. data/lib/byebug/commands/info/breakpoints.rb +59 -0
  29. data/lib/byebug/commands/info/catch.rb +39 -0
  30. data/lib/byebug/commands/info/display.rb +42 -0
  31. data/lib/byebug/commands/info/file.rb +81 -0
  32. data/lib/byebug/commands/info/line.rb +31 -0
  33. data/lib/byebug/commands/info/program.rb +51 -0
  34. data/lib/byebug/commands/interrupt.rb +5 -9
  35. data/lib/byebug/commands/irb.rb +5 -9
  36. data/lib/byebug/commands/kill.rb +6 -12
  37. data/lib/byebug/commands/list.rb +47 -19
  38. data/lib/byebug/commands/method.rb +8 -14
  39. data/lib/byebug/commands/next.rb +36 -0
  40. data/lib/byebug/commands/pp.rb +41 -0
  41. data/lib/byebug/commands/pry.rb +5 -9
  42. data/lib/byebug/commands/ps.rb +44 -0
  43. data/lib/byebug/commands/putl.rb +43 -0
  44. data/lib/byebug/commands/quit.rb +8 -12
  45. data/lib/byebug/commands/restart.rb +6 -12
  46. data/lib/byebug/commands/save.rb +30 -39
  47. data/lib/byebug/commands/set.rb +19 -21
  48. data/lib/byebug/commands/show.rb +10 -16
  49. data/lib/byebug/commands/source.rb +6 -12
  50. data/lib/byebug/commands/step.rb +36 -0
  51. data/lib/byebug/commands/thread.rb +13 -130
  52. data/lib/byebug/commands/thread/current.rb +35 -0
  53. data/lib/byebug/commands/thread/list.rb +41 -0
  54. data/lib/byebug/commands/thread/resume.rb +45 -0
  55. data/lib/byebug/commands/thread/stop.rb +41 -0
  56. data/lib/byebug/commands/thread/switch.rb +43 -0
  57. data/lib/byebug/commands/tracevar.rb +8 -14
  58. data/lib/byebug/commands/undisplay.rb +12 -15
  59. data/lib/byebug/commands/untracevar.rb +5 -11
  60. data/lib/byebug/commands/up.rb +39 -0
  61. data/lib/byebug/commands/var.rb +15 -94
  62. data/lib/byebug/commands/var/all.rb +37 -0
  63. data/lib/byebug/commands/var/const.rb +38 -0
  64. data/lib/byebug/commands/var/global.rb +33 -0
  65. data/lib/byebug/commands/var/instance.rb +35 -0
  66. data/lib/byebug/commands/var/local.rb +35 -0
  67. data/lib/byebug/commands/where.rb +47 -0
  68. data/lib/byebug/core.rb +10 -0
  69. data/lib/byebug/helpers/eval.rb +47 -0
  70. data/lib/byebug/helpers/file.rb +46 -0
  71. data/lib/byebug/helpers/frame.rb +76 -0
  72. data/lib/byebug/helpers/parse.rb +74 -0
  73. data/lib/byebug/helpers/string.rb +24 -0
  74. data/lib/byebug/helpers/thread.rb +53 -0
  75. data/lib/byebug/helpers/toggle.rb +56 -0
  76. data/lib/byebug/helpers/var.rb +45 -0
  77. data/lib/byebug/history.rb +2 -4
  78. data/lib/byebug/interface.rb +5 -3
  79. data/lib/byebug/interfaces/local_interface.rb +3 -1
  80. data/lib/byebug/interfaces/remote_interface.rb +3 -1
  81. data/lib/byebug/interfaces/test_interface.rb +6 -2
  82. data/lib/byebug/printers/plain.rb +1 -1
  83. data/lib/byebug/processors/command_processor.rb +9 -11
  84. data/lib/byebug/processors/control_command_processor.rb +1 -1
  85. data/lib/byebug/remote.rb +3 -0
  86. data/lib/byebug/runner.rb +5 -3
  87. data/lib/byebug/setting.rb +2 -18
  88. data/lib/byebug/settings/savefile.rb +21 -0
  89. data/lib/byebug/states/regular_state.rb +15 -6
  90. data/lib/byebug/subcommand_list.rb +33 -0
  91. data/lib/byebug/subcommands.rb +53 -0
  92. data/lib/byebug/version.rb +1 -1
  93. metadata +45 -6
  94. data/lib/byebug/commands/enable_disable.rb +0 -132
  95. data/lib/byebug/commands/stepping.rb +0 -75
  96. data/lib/byebug/helper.rb +0 -131
@@ -0,0 +1,36 @@
1
+ require 'byebug/command'
2
+ require 'byebug/helpers/parse'
3
+
4
+ module Byebug
5
+ #
6
+ # Implements the step functionality.
7
+ #
8
+ # Allows the user the continue execution until the next instruction, possibily
9
+ # in a different frame. Use step to step into method calls or blocks.
10
+ #
11
+ class StepCommand < Command
12
+ include Helpers::ParseHelper
13
+
14
+ self.allow_in_post_mortem = false
15
+
16
+ def regexp
17
+ /^\s* s(?:tep)? (?:\s+(\S+))? \s*$/x
18
+ end
19
+
20
+ def execute
21
+ steps, err = parse_steps(@match[1], 'Steps')
22
+ return errmsg(err) unless steps
23
+
24
+ @state.context.step_into(steps, @state.frame)
25
+ @state.proceed
26
+ end
27
+
28
+ def description
29
+ <<-EOD
30
+ s[tep][ nnn]
31
+
32
+ Steps (into methods) once or nnn times.
33
+ EOD
34
+ end
35
+ end
36
+ end
@@ -1,145 +1,28 @@
1
- require 'byebug/command'
1
+ require 'byebug/subcommands'
2
+
3
+ require 'byebug/commands/thread/current'
4
+ require 'byebug/commands/thread/list'
5
+ require 'byebug/commands/thread/resume'
6
+ require 'byebug/commands/thread/stop'
7
+ require 'byebug/commands/thread/switch'
2
8
 
3
9
  module Byebug
4
10
  #
5
11
  # Manipulation of Ruby threads
6
12
  #
7
13
  class ThreadCommand < Command
8
- Subcommands = [
9
- ['current', 1, 'Shows current thread'],
10
- ['list', 1, 'Lists all threads'],
11
- ['resume', 1, 'Resumes execution of specified thread number'],
12
- ['stop', 2, 'Stops execution of specified thread number'],
13
- ['switch', 2, 'Switches execution to specified thread']
14
- ].map do |name, min, help|
15
- Subcmd.new(name, min, help)
16
- end
14
+ include Subcommands
17
15
 
18
16
  def regexp
19
17
  /^\s* th(?:read)? (?:\s+ (.+))? \s*$/x
20
18
  end
21
19
 
22
- def execute
23
- return puts(self.class.help) unless @match[1]
24
-
25
- name, thnum = @match[1].split(/ +/)[0..1]
26
- subcmd = Command.find(Subcommands, name)
27
- return errmsg("Unknown thread command '#{name}'\n") unless subcmd
28
-
29
- send("thread_#{subcmd.name}", thnum)
30
- end
31
-
32
- class << self
33
- def names
34
- %w(thread)
35
- end
36
-
37
- def description
38
- prettify <<-EOD
39
- Commands to manipulate threads.
40
- EOD
41
- end
42
- end
43
-
44
- private
45
-
46
- def thread_list(thnum)
47
- return errmsg("thread list doesn't need params") unless thnum.nil?
48
-
49
- contexts = Byebug.contexts.sort_by(&:thnum)
50
-
51
- thread_list = prc('thread.context', contexts) do |context, _|
52
- thread_arguments(context)
53
- end
54
-
55
- print(thread_list)
56
- end
57
-
58
- def thread_current(thnum)
59
- return errmsg("thread current doesn't need params") unless thnum.nil?
60
-
61
- display_context(@state.context)
62
- end
63
-
64
- def thread_stop(thnum)
65
- ctx, err = parse_thread_num_for_cmd('thread stop', thnum)
66
- return errmsg(err) if err
67
-
68
- ctx.suspend
69
- display_context(ctx)
70
- end
71
-
72
- def thread_resume(thnum)
73
- ctx, err = parse_thread_num_for_cmd('thread resume', thnum)
74
- return errmsg(err) if err
75
- return errmsg(pr('thread.errors.already_running')) unless ctx.suspended?
76
-
77
- ctx.resume
78
- display_context(ctx)
79
- end
80
-
81
- def thread_switch(thnum)
82
- ctx, err = parse_thread_num_for_cmd('thread switch', thnum)
83
- return errmsg(err) if err
84
-
85
- display_context(ctx)
86
-
87
- ctx.switch
88
- @state.proceed
89
- end
90
-
91
- def display_context(context)
92
- puts pr('thread.context', thread_arguments(context))
93
- end
94
-
95
- def thread_arguments(context)
96
- status_flag = if context.suspended?
97
- '$'
98
- else
99
- context.thread == Thread.current ? '+' : ' '
100
- end
101
- debug_flag = context.ignored? ? '!' : ' '
102
-
103
- if context == Byebug.current_context
104
- file_line = "#{@state.file}:#{@state.line}"
105
- else
106
- backtrace = context.thread.backtrace_locations
107
- if backtrace && backtrace[0]
108
- file_line = "#{backtrace[0].path}:#{backtrace[0].lineno}"
109
- end
110
- end
111
-
112
- {
113
- status_flag: status_flag,
114
- debug_flag: debug_flag,
115
- id: context.thnum,
116
- thread: context.thread.inspect,
117
- file_line: file_line || ''
118
- }
119
- end
120
-
121
- def parse_thread_num(subcmd, arg)
122
- thnum, err = get_int(arg, subcmd, 1)
123
- return [nil, err] unless thnum
124
-
125
- Byebug.contexts.find { |c| c.thnum == thnum }
126
- end
127
-
128
- def parse_thread_num_for_cmd(subcmd, arg)
129
- c, err = parse_thread_num(subcmd, arg)
20
+ def description
21
+ <<-EOD
22
+ th]read <subcommand>
130
23
 
131
- case
132
- when err
133
- [c, err]
134
- when c.nil?
135
- [nil, pr('thread.errors.no_thread')]
136
- when @state.context == c
137
- [c, pr('thread.errors.current_thread')]
138
- when c.ignored?
139
- [c, pr('thread.errors.wrong_action', subcmd: subcmd, arg: arg)]
140
- else
141
- [c, nil]
142
- end
24
+ Commands to manipulate threads.
25
+ EOD
143
26
  end
144
27
  end
145
28
  end
@@ -0,0 +1,35 @@
1
+ require 'byebug/helpers/thread'
2
+
3
+ module Byebug
4
+ #
5
+ # Reopens the +thread+ command to define the +current+ subcommand
6
+ #
7
+ class ThreadCommand < Command
8
+ #
9
+ # Information about the current thread
10
+ #
11
+ class CurrentSubcommand < Command
12
+ include Helpers::ThreadHelper
13
+
14
+ def regexp
15
+ /^\s* c(?:urrent)? \s*$/x
16
+ end
17
+
18
+ def execute
19
+ display_context(@state.context)
20
+ end
21
+
22
+ def short_description
23
+ 'Shows current thread information'
24
+ end
25
+
26
+ def description
27
+ <<-EOD
28
+ th[read] c[urrent]
29
+
30
+ #{short_description}
31
+ EOD
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,41 @@
1
+ require 'byebug/helpers/thread'
2
+
3
+ module Byebug
4
+ #
5
+ # Reopens the +thread+ command to define the +list+ subcommand
6
+ #
7
+ class ThreadCommand < Command
8
+ #
9
+ # Information about threads
10
+ #
11
+ class ListSubcommand < Command
12
+ include Helpers::ThreadHelper
13
+
14
+ def regexp
15
+ /^\s* l(?:ist)? \s*$/x
16
+ end
17
+
18
+ def execute
19
+ contexts = Byebug.contexts.sort_by(&:thnum)
20
+
21
+ thread_list = prc('thread.context', contexts) do |context, _|
22
+ thread_arguments(context)
23
+ end
24
+
25
+ print(thread_list)
26
+ end
27
+
28
+ def short_description
29
+ 'Lists all threads'
30
+ end
31
+
32
+ def description
33
+ <<-EOD
34
+ th[read] l[ist] <thnum>
35
+
36
+ #{short_description}
37
+ EOD
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,45 @@
1
+ require 'byebug/helpers/thread'
2
+
3
+ module Byebug
4
+ #
5
+ # Reopens the +thread+ command to define the +resume+ subcommand
6
+ #
7
+ class ThreadCommand < Command
8
+ #
9
+ # Resumes the specified thread
10
+ #
11
+ class ResumeSubcommand < Command
12
+ include Helpers::ThreadHelper
13
+
14
+ def regexp
15
+ /^\s* r(?:esume)? (?: \s* (\d+))? \s*$/x
16
+ end
17
+
18
+ def execute
19
+ return puts(help) unless @match[1]
20
+
21
+ context, err = context_from_thread(@match[1])
22
+ return errmsg(err) if err
23
+
24
+ unless context.suspended?
25
+ return errmsg(pr('thread.errors.already_running'))
26
+ end
27
+
28
+ context.resume
29
+ display_context(context)
30
+ end
31
+
32
+ def short_description
33
+ 'Resumes execution of the specified thread'
34
+ end
35
+
36
+ def description
37
+ <<-EOD
38
+ th[read] r[esume] <thnum>
39
+
40
+ #{short_description}
41
+ EOD
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,41 @@
1
+ require 'byebug/helpers/thread'
2
+
3
+ module Byebug
4
+ #
5
+ # Reopens the +thread+ command to define the +stop+ subcommand
6
+ #
7
+ class ThreadCommand < Command
8
+ #
9
+ # Stops the specified thread
10
+ #
11
+ class StopSubcommand < Command
12
+ include Helpers::ThreadHelper
13
+
14
+ def regexp
15
+ /^\s* st(?:op)? (?: \s* (\d+))? \s*$/x
16
+ end
17
+
18
+ def execute
19
+ return puts(help) unless @match[1]
20
+
21
+ context, err = context_from_thread(@match[1])
22
+ return errmsg(err) if err
23
+
24
+ context.suspend
25
+ display_context(context)
26
+ end
27
+
28
+ def short_description
29
+ 'Stops the execution of the specified thread'
30
+ end
31
+
32
+ def description
33
+ <<-EOD
34
+ th[read] st[op] <thnum>
35
+
36
+ #{short_description}
37
+ EOD
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,43 @@
1
+ require 'byebug/helpers/thread'
2
+
3
+ module Byebug
4
+ #
5
+ # Reopens the +thread+ command to define the +switch+ subcommand
6
+ #
7
+ class ThreadCommand < Command
8
+ #
9
+ # Switches to the specified thread
10
+ #
11
+ class SwitchSubcommand < Command
12
+ include Helpers::ThreadHelper
13
+
14
+ def regexp
15
+ /^\s* sw(?:itch)? (?: \s* (\d+))? \s*$/x
16
+ end
17
+
18
+ def execute
19
+ return puts(help) unless @match[1]
20
+
21
+ context, err = context_from_thread(@match[1])
22
+ return errmsg(err) if err
23
+
24
+ display_context(context)
25
+
26
+ context.switch
27
+ @state.proceed
28
+ end
29
+
30
+ def short_description
31
+ 'Switches execution to the specified thread'
32
+ end
33
+
34
+ def description
35
+ <<-EOD
36
+ th[read] sw[itch] <thnum>
37
+
38
+ #{short_description}
39
+ EOD
40
+ end
41
+ end
42
+ end
43
+ end
@@ -36,22 +36,16 @@ module Byebug
36
36
  @state.context.step_out(1, false) if stop
37
37
  end
38
38
 
39
- class << self
40
- def names
41
- %w(tracevar)
42
- end
43
-
44
- def description
45
- prettify <<-EOD
46
- tr[acevar] <variable> [[no]stop]
39
+ def description
40
+ <<-EOD
41
+ tr[acevar] <variable> [[no]stop]
47
42
 
48
- Start tracing variable <variable>.
43
+ Start tracing variable <variable>.
49
44
 
50
- If "stop" is specified, execution will stop every time the variable
51
- changes its value. If nothing or "nostop" is specified, execution
52
- won't stop, changes will just be logged in byebug's output.
53
- EOD
54
- end
45
+ If "stop" is specified, execution will stop every time the variable
46
+ changes its value. If nothing or "nostop" is specified, execution won't
47
+ stop, changes will just be logged in byebug's output.
48
+ EOD
55
49
  end
56
50
  end
57
51
  end
@@ -1,10 +1,13 @@
1
1
  require 'byebug/command'
2
+ require 'byebug/helpers/parse'
2
3
 
3
4
  module Byebug
4
5
  #
5
6
  # Remove expressions from display list.
6
7
  #
7
8
  class UndisplayCommand < Command
9
+ include Helpers::ParseHelper
10
+
8
11
  self.allow_in_post_mortem = false
9
12
 
10
13
  def regexp
@@ -28,22 +31,16 @@ module Byebug
28
31
  end
29
32
  end
30
33
 
31
- class << self
32
- def names
33
- %w(undisplay)
34
- end
35
-
36
- def description
37
- prettify <<-EOD
38
- undisp[lay][ nnn]
34
+ def description
35
+ <<-EOD
36
+ undisp[lay][ nnn]
39
37
 
40
- Cancel some expressions to be displayed when program stops. Arguments
41
- are the code numbers of the expressions to stop displaying. No
42
- argument means cancel all automatic-display expressions. "delete
43
- display" has the same effect as this command. Do "info display" to see
44
- the current list of code numbers.
45
- EOD
46
- end
38
+ Cancel some expressions to be displayed when program stops. Arguments
39
+ are the code numbers of the expressions to stop displaying. No argument
40
+ means cancel all automatic-display expressions. "delete display" has the
41
+ same effect as this command. Do "info display" to see the current list
42
+ of code numbers.
43
+ EOD
47
44
  end
48
45
  end
49
46
  end