byebug 11.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 (132) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +897 -0
  3. data/CONTRIBUTING.md +58 -0
  4. data/GUIDE.md +1806 -0
  5. data/LICENSE +23 -0
  6. data/README.md +199 -0
  7. data/exe/byebug +6 -0
  8. data/ext/byebug/breakpoint.c +517 -0
  9. data/ext/byebug/byebug.c +905 -0
  10. data/ext/byebug/byebug.h +143 -0
  11. data/ext/byebug/context.c +673 -0
  12. data/ext/byebug/extconf.rb +12 -0
  13. data/ext/byebug/locker.c +96 -0
  14. data/ext/byebug/threads.c +230 -0
  15. data/lib/byebug.rb +3 -0
  16. data/lib/byebug/attacher.rb +48 -0
  17. data/lib/byebug/breakpoint.rb +111 -0
  18. data/lib/byebug/command.rb +111 -0
  19. data/lib/byebug/command_list.rb +34 -0
  20. data/lib/byebug/commands.rb +40 -0
  21. data/lib/byebug/commands/break.rb +112 -0
  22. data/lib/byebug/commands/catch.rb +78 -0
  23. data/lib/byebug/commands/condition.rb +55 -0
  24. data/lib/byebug/commands/continue.rb +68 -0
  25. data/lib/byebug/commands/debug.rb +38 -0
  26. data/lib/byebug/commands/delete.rb +55 -0
  27. data/lib/byebug/commands/disable.rb +33 -0
  28. data/lib/byebug/commands/disable/breakpoints.rb +42 -0
  29. data/lib/byebug/commands/disable/display.rb +43 -0
  30. data/lib/byebug/commands/display.rb +66 -0
  31. data/lib/byebug/commands/down.rb +45 -0
  32. data/lib/byebug/commands/edit.rb +69 -0
  33. data/lib/byebug/commands/enable.rb +33 -0
  34. data/lib/byebug/commands/enable/breakpoints.rb +42 -0
  35. data/lib/byebug/commands/enable/display.rb +43 -0
  36. data/lib/byebug/commands/finish.rb +57 -0
  37. data/lib/byebug/commands/frame.rb +57 -0
  38. data/lib/byebug/commands/help.rb +64 -0
  39. data/lib/byebug/commands/history.rb +39 -0
  40. data/lib/byebug/commands/info.rb +37 -0
  41. data/lib/byebug/commands/info/breakpoints.rb +65 -0
  42. data/lib/byebug/commands/info/display.rb +49 -0
  43. data/lib/byebug/commands/info/file.rb +80 -0
  44. data/lib/byebug/commands/info/line.rb +35 -0
  45. data/lib/byebug/commands/info/program.rb +49 -0
  46. data/lib/byebug/commands/interrupt.rb +34 -0
  47. data/lib/byebug/commands/irb.rb +50 -0
  48. data/lib/byebug/commands/kill.rb +45 -0
  49. data/lib/byebug/commands/list.rb +159 -0
  50. data/lib/byebug/commands/method.rb +53 -0
  51. data/lib/byebug/commands/next.rb +40 -0
  52. data/lib/byebug/commands/pry.rb +41 -0
  53. data/lib/byebug/commands/quit.rb +42 -0
  54. data/lib/byebug/commands/restart.rb +64 -0
  55. data/lib/byebug/commands/save.rb +72 -0
  56. data/lib/byebug/commands/set.rb +79 -0
  57. data/lib/byebug/commands/show.rb +45 -0
  58. data/lib/byebug/commands/skip.rb +85 -0
  59. data/lib/byebug/commands/source.rb +40 -0
  60. data/lib/byebug/commands/step.rb +40 -0
  61. data/lib/byebug/commands/thread.rb +34 -0
  62. data/lib/byebug/commands/thread/current.rb +37 -0
  63. data/lib/byebug/commands/thread/list.rb +43 -0
  64. data/lib/byebug/commands/thread/resume.rb +45 -0
  65. data/lib/byebug/commands/thread/stop.rb +43 -0
  66. data/lib/byebug/commands/thread/switch.rb +46 -0
  67. data/lib/byebug/commands/tracevar.rb +54 -0
  68. data/lib/byebug/commands/undisplay.rb +51 -0
  69. data/lib/byebug/commands/untracevar.rb +36 -0
  70. data/lib/byebug/commands/up.rb +45 -0
  71. data/lib/byebug/commands/var.rb +37 -0
  72. data/lib/byebug/commands/var/all.rb +41 -0
  73. data/lib/byebug/commands/var/args.rb +39 -0
  74. data/lib/byebug/commands/var/const.rb +49 -0
  75. data/lib/byebug/commands/var/global.rb +37 -0
  76. data/lib/byebug/commands/var/instance.rb +39 -0
  77. data/lib/byebug/commands/var/local.rb +39 -0
  78. data/lib/byebug/commands/where.rb +53 -0
  79. data/lib/byebug/context.rb +157 -0
  80. data/lib/byebug/core.rb +115 -0
  81. data/lib/byebug/errors.rb +29 -0
  82. data/lib/byebug/frame.rb +185 -0
  83. data/lib/byebug/helpers/bin.rb +47 -0
  84. data/lib/byebug/helpers/eval.rb +126 -0
  85. data/lib/byebug/helpers/file.rb +63 -0
  86. data/lib/byebug/helpers/frame.rb +75 -0
  87. data/lib/byebug/helpers/parse.rb +75 -0
  88. data/lib/byebug/helpers/path.rb +40 -0
  89. data/lib/byebug/helpers/reflection.rb +19 -0
  90. data/lib/byebug/helpers/string.rb +33 -0
  91. data/lib/byebug/helpers/thread.rb +67 -0
  92. data/lib/byebug/helpers/toggle.rb +62 -0
  93. data/lib/byebug/helpers/var.rb +54 -0
  94. data/lib/byebug/history.rb +130 -0
  95. data/lib/byebug/interface.rb +146 -0
  96. data/lib/byebug/interfaces/local_interface.rb +44 -0
  97. data/lib/byebug/interfaces/remote_interface.rb +50 -0
  98. data/lib/byebug/interfaces/script_interface.rb +33 -0
  99. data/lib/byebug/interfaces/test_interface.rb +67 -0
  100. data/lib/byebug/option_setter.rb +95 -0
  101. data/lib/byebug/printers/base.rb +68 -0
  102. data/lib/byebug/printers/plain.rb +44 -0
  103. data/lib/byebug/printers/texts/base.yml +115 -0
  104. data/lib/byebug/printers/texts/plain.yml +33 -0
  105. data/lib/byebug/processors/command_processor.rb +173 -0
  106. data/lib/byebug/processors/control_processor.rb +24 -0
  107. data/lib/byebug/processors/post_mortem_processor.rb +18 -0
  108. data/lib/byebug/processors/script_processor.rb +49 -0
  109. data/lib/byebug/remote.rb +85 -0
  110. data/lib/byebug/remote/client.rb +57 -0
  111. data/lib/byebug/remote/server.rb +47 -0
  112. data/lib/byebug/runner.rb +198 -0
  113. data/lib/byebug/setting.rb +79 -0
  114. data/lib/byebug/settings/autoirb.rb +29 -0
  115. data/lib/byebug/settings/autolist.rb +29 -0
  116. data/lib/byebug/settings/autopry.rb +29 -0
  117. data/lib/byebug/settings/autosave.rb +17 -0
  118. data/lib/byebug/settings/basename.rb +16 -0
  119. data/lib/byebug/settings/callstyle.rb +20 -0
  120. data/lib/byebug/settings/fullpath.rb +16 -0
  121. data/lib/byebug/settings/histfile.rb +20 -0
  122. data/lib/byebug/settings/histsize.rb +20 -0
  123. data/lib/byebug/settings/linetrace.rb +22 -0
  124. data/lib/byebug/settings/listsize.rb +21 -0
  125. data/lib/byebug/settings/post_mortem.rb +27 -0
  126. data/lib/byebug/settings/savefile.rb +20 -0
  127. data/lib/byebug/settings/stack_on_error.rb +15 -0
  128. data/lib/byebug/settings/width.rb +20 -0
  129. data/lib/byebug/source_file_formatter.rb +71 -0
  130. data/lib/byebug/subcommands.rb +54 -0
  131. data/lib/byebug/version.rb +8 -0
  132. metadata +199 -0
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "byebug/subcommands"
4
+
5
+ require "byebug/commands/var/all"
6
+ require "byebug/commands/var/args"
7
+ require "byebug/commands/var/const"
8
+ require "byebug/commands/var/instance"
9
+ require "byebug/commands/var/local"
10
+ require "byebug/commands/var/global"
11
+
12
+ module Byebug
13
+ #
14
+ # Shows variables and its values
15
+ #
16
+ class VarCommand < Command
17
+ include Subcommands
18
+
19
+ self.allow_in_post_mortem = true
20
+
21
+ def self.regexp
22
+ /^\s* v(?:ar)? (?:\s+ (.+))? \s*$/x
23
+ end
24
+
25
+ def self.description
26
+ <<-DESCRIPTION
27
+ [v]ar <subcommand>
28
+
29
+ #{short_description}
30
+ DESCRIPTION
31
+ end
32
+
33
+ def self.short_description
34
+ "Shows variables and its values"
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "byebug/helpers/var"
4
+
5
+ module Byebug
6
+ #
7
+ # Reopens the +var+ command to define the +all+ subcommand
8
+ #
9
+ class VarCommand < Command
10
+ #
11
+ # Shows global, instance and local variables
12
+ #
13
+ class AllCommand < Command
14
+ include Helpers::VarHelper
15
+
16
+ self.allow_in_post_mortem = true
17
+
18
+ def self.regexp
19
+ /^\s* a(?:ll)? \s*$/x
20
+ end
21
+
22
+ def self.description
23
+ <<-DESCRIPTION
24
+ v[ar] a[ll]
25
+
26
+ #{short_description}
27
+ DESCRIPTION
28
+ end
29
+
30
+ def self.short_description
31
+ "Shows local, global and instance variables of self."
32
+ end
33
+
34
+ def execute
35
+ var_global
36
+ var_instance("self")
37
+ var_local
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "byebug/helpers/var"
4
+
5
+ module Byebug
6
+ #
7
+ # Reopens the +var+ command to define the +args+ subcommand
8
+ #
9
+ class VarCommand < Command
10
+ #
11
+ # Information about arguments of the current method/block
12
+ #
13
+ class ArgsCommand < Command
14
+ include Helpers::VarHelper
15
+
16
+ self.allow_in_post_mortem = true
17
+
18
+ def self.regexp
19
+ /^\s* a(?:rgs)? \s*$/x
20
+ end
21
+
22
+ def self.description
23
+ <<-DESCRIPTION
24
+ v[ar] a[args]
25
+
26
+ #{short_description}
27
+ DESCRIPTION
28
+ end
29
+
30
+ def self.short_description
31
+ "Information about arguments of the current scope"
32
+ end
33
+
34
+ def execute
35
+ var_args
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "byebug/helpers/eval"
4
+
5
+ module Byebug
6
+ #
7
+ # Reopens the +var+ command to define the +const+ subcommand
8
+ #
9
+ class VarCommand < Command
10
+ #
11
+ # Shows constants
12
+ #
13
+ class ConstCommand < Command
14
+ include Helpers::EvalHelper
15
+
16
+ self.allow_in_post_mortem = true
17
+
18
+ def self.regexp
19
+ /^\s* c(?:onst)? (?:\s+ (.+))? \s*$/x
20
+ end
21
+
22
+ def self.description
23
+ <<-DESCRIPTION
24
+ v[ar] c[onstant]
25
+
26
+ #{short_description}
27
+ DESCRIPTION
28
+ end
29
+
30
+ def self.short_description
31
+ "Shows constants of an object."
32
+ end
33
+
34
+ def execute
35
+ obj = warning_eval(str_obj)
36
+ return errmsg(pr("variable.errors.not_module", object: str_obj)) unless obj.is_a?(Module)
37
+
38
+ constants = warning_eval("#{str_obj}.constants")
39
+ puts prv(constants.sort.map { |c| [c, obj.const_get(c)] }, "constant")
40
+ end
41
+
42
+ private
43
+
44
+ def str_obj
45
+ @str_obj ||= @match[1] || "self.class"
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Byebug
4
+ #
5
+ # Reopens the +var+ command to define the +global+ subcommand
6
+ #
7
+ class VarCommand < Command
8
+ #
9
+ # Shows global variables
10
+ #
11
+ class GlobalCommand < Command
12
+ include Helpers::VarHelper
13
+
14
+ self.allow_in_post_mortem = true
15
+
16
+ def self.regexp
17
+ /^\s* g(?:lobal)? \s*$/x
18
+ end
19
+
20
+ def self.description
21
+ <<-DESCRIPTION
22
+ v[ar] g[lobal]
23
+
24
+ #{short_description}
25
+ DESCRIPTION
26
+ end
27
+
28
+ def self.short_description
29
+ "Shows global variables."
30
+ end
31
+
32
+ def execute
33
+ var_global
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "byebug/helpers/var"
4
+
5
+ module Byebug
6
+ #
7
+ # Reopens the +var+ command to define the +instance+ subcommand
8
+ #
9
+ class VarCommand < Command
10
+ #
11
+ # Shows instance variables
12
+ #
13
+ class InstanceCommand < Command
14
+ include Helpers::VarHelper
15
+
16
+ self.allow_in_post_mortem = true
17
+
18
+ def self.regexp
19
+ /^\s* i(?:nstance)? (?:\s+ (.+))? \s*$/x
20
+ end
21
+
22
+ def self.description
23
+ <<-DESCRIPTION
24
+ v[ar] i[nstance][ <object>]
25
+
26
+ #{short_description}
27
+ DESCRIPTION
28
+ end
29
+
30
+ def self.short_description
31
+ "Shows instance variables of self or a specific object."
32
+ end
33
+
34
+ def execute
35
+ var_instance(@match[1])
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "byebug/helpers/var"
4
+
5
+ module Byebug
6
+ #
7
+ # Reopens the +var+ command to define the +local+ subcommand
8
+ #
9
+ class VarCommand < Command
10
+ #
11
+ # Shows local variables in current scope
12
+ #
13
+ class LocalCommand < Command
14
+ include Helpers::VarHelper
15
+
16
+ self.allow_in_post_mortem = true
17
+
18
+ def self.regexp
19
+ /^\s* l(?:ocal)? \s*$/x
20
+ end
21
+
22
+ def self.description
23
+ <<-DESCRIPTION
24
+ v[ar] l[ocal]
25
+
26
+ #{short_description}
27
+ DESCRIPTION
28
+ end
29
+
30
+ def self.short_description
31
+ "Shows local variables in current scope."
32
+ end
33
+
34
+ def execute
35
+ var_local
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+ require "byebug/command"
5
+ require "byebug/helpers/frame"
6
+
7
+ module Byebug
8
+ #
9
+ # Show current backtrace.
10
+ #
11
+ class WhereCommand < Command
12
+ include Helpers::FrameHelper
13
+
14
+ self.allow_in_post_mortem = true
15
+
16
+ def self.regexp
17
+ /^\s* (?:w(?:here)?|bt|backtrace) \s*$/x
18
+ end
19
+
20
+ def self.description
21
+ <<-DESCRIPTION
22
+ w[here]|bt|backtrace
23
+
24
+ #{short_description}
25
+
26
+ Print the entire stack frame. Each frame is numbered; the most recent
27
+ frame is 0. A frame number can be referred to in the "frame" command.
28
+ "up" and "down" add or subtract respectively to frame numbers shown.
29
+ The position of the current frame is marked with -->. C-frames hang
30
+ from their most immediate Ruby frame to indicate that they are not
31
+ navigable.
32
+ DESCRIPTION
33
+ end
34
+
35
+ def self.short_description
36
+ "Displays the backtrace"
37
+ end
38
+
39
+ def execute
40
+ print_backtrace
41
+ end
42
+
43
+ private
44
+
45
+ def print_backtrace
46
+ bt = prc("frame.line", (0...context.stack_size)) do |_, index|
47
+ Frame.new(context, index).to_hash
48
+ end
49
+
50
+ print(bt)
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,157 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "byebug/frame"
4
+ require "byebug/helpers/path"
5
+ require "byebug/helpers/file"
6
+ require "byebug/processors/command_processor"
7
+
8
+ module Byebug
9
+ #
10
+ # Mantains context information for the debugger and it's the main
11
+ # communication point between the library and the C-extension through the
12
+ # at_breakpoint, at_catchpoint, at_tracing, at_line and at_return callbacks
13
+ #
14
+ class Context
15
+ include Helpers::FileHelper
16
+
17
+ class << self
18
+ include Helpers::PathHelper
19
+
20
+ attr_writer :ignored_files
21
+
22
+ #
23
+ # List of files byebug will ignore while debugging
24
+ #
25
+ def ignored_files
26
+ @ignored_files ||=
27
+ Byebug.mode == :standalone ? lib_files + [bin_file] : lib_files
28
+ end
29
+
30
+ attr_writer :interface
31
+
32
+ def interface
33
+ @interface ||= LocalInterface.new
34
+ end
35
+
36
+ attr_writer :processor
37
+
38
+ def processor
39
+ @processor ||= CommandProcessor
40
+ end
41
+ end
42
+
43
+ #
44
+ # Reader for the current frame
45
+ #
46
+ def frame
47
+ @frame ||= Frame.new(self, 0)
48
+ end
49
+
50
+ #
51
+ # Writer for the current frame
52
+ #
53
+ def frame=(pos)
54
+ @frame = Frame.new(self, pos)
55
+ end
56
+
57
+ extend Forwardable
58
+ def_delegators :frame, :file, :line
59
+
60
+ #
61
+ # Current file & line information
62
+ #
63
+ def location
64
+ "#{normalize(file)}:#{line}"
65
+ end
66
+
67
+ #
68
+ # Current file, line and source code information
69
+ #
70
+ def full_location
71
+ return location if virtual_file?(file)
72
+
73
+ "#{location} #{get_line(file, line)}"
74
+ end
75
+
76
+ #
77
+ # Context's stack size
78
+ #
79
+ def stack_size
80
+ return 0 unless backtrace
81
+
82
+ backtrace.drop_while { |l| ignored_file?(l.first.path) }
83
+ .take_while { |l| !ignored_file?(l.first.path) }
84
+ .size
85
+ end
86
+
87
+ def interrupt
88
+ step_into 1
89
+ end
90
+
91
+ #
92
+ # Line handler
93
+ #
94
+ def at_line
95
+ self.frame = 0
96
+ return if ignored_file?(file)
97
+
98
+ processor.at_line
99
+ end
100
+
101
+ #
102
+ # Tracing handler
103
+ #
104
+ def at_tracing
105
+ return if ignored_file?(file)
106
+
107
+ processor.at_tracing
108
+ end
109
+
110
+ #
111
+ # Breakpoint handler
112
+ #
113
+ def at_breakpoint(breakpoint)
114
+ processor.at_breakpoint(breakpoint)
115
+ end
116
+
117
+ #
118
+ # Catchpoint handler
119
+ #
120
+ def at_catchpoint(exception)
121
+ processor.at_catchpoint(exception)
122
+ end
123
+
124
+ #
125
+ # Return handler
126
+ #
127
+ def at_return(return_value)
128
+ return if ignored_file?(file)
129
+
130
+ processor.at_return(return_value)
131
+ end
132
+
133
+ #
134
+ # End of class definition handler
135
+ #
136
+ def at_end
137
+ return if ignored_file?(file)
138
+
139
+ processor.at_end
140
+ end
141
+
142
+ private
143
+
144
+ def processor
145
+ @processor ||= self.class.processor.new(self, self.class.interface)
146
+ end
147
+
148
+ #
149
+ # Tells whether a file is ignored by the debugger.
150
+ #
151
+ # @param path [String] filename to be checked.
152
+ #
153
+ def ignored_file?(path)
154
+ self.class.ignored_files.include?(path)
155
+ end
156
+ end
157
+ end