byebug 1.1.0 → 1.1.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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/Rakefile +0 -1
  4. data/bin/byebug +51 -114
  5. data/byebug.gemspec +1 -1
  6. data/ext/byebug/byebug.c +23 -106
  7. data/ext/byebug/byebug.h +10 -30
  8. data/ext/byebug/context.c +16 -102
  9. data/ext/byebug/extconf.rb +0 -9
  10. data/lib/byebug.rb +8 -122
  11. data/lib/byebug/command.rb +35 -29
  12. data/lib/byebug/commands/breakpoints.rb +17 -12
  13. data/lib/byebug/commands/catchpoint.rb +5 -5
  14. data/lib/byebug/commands/condition.rb +9 -7
  15. data/lib/byebug/commands/continue.rb +7 -4
  16. data/lib/byebug/commands/control.rb +4 -32
  17. data/lib/byebug/commands/display.rb +15 -14
  18. data/lib/byebug/commands/edit.rb +14 -13
  19. data/lib/byebug/commands/enable.rb +33 -35
  20. data/lib/byebug/commands/eval.rb +22 -29
  21. data/lib/byebug/commands/finish.rb +11 -9
  22. data/lib/byebug/commands/frame.rb +24 -50
  23. data/lib/byebug/commands/help.rb +21 -27
  24. data/lib/byebug/commands/info.rb +29 -92
  25. data/lib/byebug/commands/irb.rb +9 -11
  26. data/lib/byebug/commands/jump.rb +4 -4
  27. data/lib/byebug/commands/kill.rb +8 -8
  28. data/lib/byebug/commands/list.rb +2 -2
  29. data/lib/byebug/commands/method.rb +6 -6
  30. data/lib/byebug/commands/quit.rb +8 -8
  31. data/lib/byebug/commands/reload.rb +3 -3
  32. data/lib/byebug/commands/save.rb +10 -9
  33. data/lib/byebug/commands/set.rb +29 -26
  34. data/lib/byebug/commands/show.rb +17 -18
  35. data/lib/byebug/commands/skip.rb +8 -8
  36. data/lib/byebug/commands/source.rb +15 -13
  37. data/lib/byebug/commands/stepping.rb +7 -7
  38. data/lib/byebug/commands/trace.rb +8 -13
  39. data/lib/byebug/commands/variables.rb +18 -18
  40. data/lib/byebug/context.rb +3 -3
  41. data/lib/byebug/interface.rb +2 -7
  42. data/lib/byebug/processor.rb +9 -22
  43. data/lib/byebug/version.rb +1 -1
  44. data/old_doc/byebug.1 +3 -35
  45. data/old_doc/byebug.texi +69 -201
  46. data/old_doc/test-tri2.rb +1 -1
  47. data/test/breakpoints_test.rb +8 -1
  48. data/test/frame_test.rb +0 -8
  49. data/test/help_test.rb +13 -19
  50. data/test/info_test.rb +8 -32
  51. data/test/irb_test.rb +3 -4
  52. data/test/jump_test.rb +4 -4
  53. data/test/save_test.rb +2 -2
  54. data/test/set_test.rb +16 -8
  55. data/test/source_test.rb +10 -1
  56. data/test/support/context.rb +1 -1
  57. data/test/support/mocha_extensions.rb +16 -15
  58. data/test/support/test_dsl.rb +2 -2
  59. data/test/trace_test.rb +0 -45
  60. metadata +4 -10
  61. data/ext/byebug/locker.c +0 -53
  62. data/lib/byebug/commands/threads.rb +0 -190
  63. data/test/examples/frame_threads.rb +0 -31
  64. data/test/examples/info_threads.rb +0 -48
  65. data/test/examples/thread.rb +0 -32
  66. data/test/examples/trace_threads.rb +0 -20
@@ -83,7 +83,7 @@ module Byebug
83
83
  @state.proceed
84
84
  when :step
85
85
  force = Command.settings[:force_stepping]
86
- @state.context.step 1, force
86
+ @state.context.step_into 1, force
87
87
  @state.proceed
88
88
  when :next
89
89
  force = Command.settings[:force_stepping]
@@ -103,20 +103,18 @@ module Byebug
103
103
  end
104
104
 
105
105
  class << self
106
- def help_command
107
- 'irb'
106
+ def names
107
+ %w(irb)
108
108
  end
109
109
 
110
- def help(cmd)
110
+ def description
111
111
  %{
112
- irb [-d]\tstarts an Interactive Ruby (IRB) session.
112
+ irb[ -d]\tstarts an Interactive Ruby (IRB) session.
113
113
 
114
- If -d is added you can get access to byebug's state via the global variable
115
- $byebug_state.
116
-
117
- irb is extended with methods "cont", "n" and "step" which
118
- run the corresponding byebug commands. In contrast to the real byebug
119
- commands these commands don't allow command arguments.
114
+ If -d is added you can get access to byebug's state via the global
115
+ variable $byebug_state. IRB is extended with methods "cont", "n" and
116
+ "step" which run the corresponding byebug commands. In contrast to the
117
+ real byebug commands these commands don't allow arguments.
120
118
  }
121
119
  end
122
120
  end
@@ -35,7 +35,7 @@ module Byebug
35
35
  file = @match[2]
36
36
  file = @state.context.frame_file(file.to_i) if numeric?(file)
37
37
  file = @state.context.frame_file(0) if !file
38
- case Byebug.current_context.jump(line, file)
38
+ case Byebug.context.jump(line, file)
39
39
  when 0
40
40
  @state.proceed
41
41
  when 1
@@ -48,11 +48,11 @@ module Byebug
48
48
  end
49
49
 
50
50
  class << self
51
- def help_command
52
- %w[jump]
51
+ def names
52
+ %w(jump)
53
53
  end
54
54
 
55
- def help(cmd)
55
+ def description
56
56
  %{
57
57
  j[ump] line\tjump to line number (absolute)
58
58
  j[ump] -line\tjump back to line (relative)
@@ -14,7 +14,7 @@ module Byebug
14
14
 
15
15
  def execute
16
16
  puts @match[1]
17
- if @match[1]
17
+ if @match[1]
18
18
  signame = @match[1]
19
19
  unless Signal.list.member?(signame)
20
20
  errmsg("signal name #{signame} is not a signal I know about\n")
@@ -26,7 +26,7 @@ module Byebug
26
26
  else
27
27
  if not confirm("Really kill? (y/n) ")
28
28
  return
29
- else
29
+ else
30
30
  signame = 'KILL'
31
31
  end
32
32
  end
@@ -34,17 +34,17 @@ module Byebug
34
34
  end
35
35
 
36
36
  class << self
37
- def help_command
38
- %w[kill]
37
+ def names
38
+ %w(kill)
39
39
  end
40
40
 
41
- def help(cmd)
41
+ def description
42
42
  %{
43
- kill [SIGNAL]
43
+ kill[ SIGNAL]
44
44
 
45
45
  Send [signal] to Process.pid
46
- Equivalent of Process.kill(Process.pid)
47
- }
46
+ Equivalent of Process.kill(Process.pid)
47
+ }
48
48
  end
49
49
  end
50
50
  end
@@ -34,8 +34,8 @@ module Byebug
34
34
  end
35
35
 
36
36
  class << self
37
- def help_command
38
- 'list'
37
+ def names
38
+ %w(list)
39
39
  end
40
40
 
41
41
  def help(cmd)
@@ -27,11 +27,11 @@ module Byebug
27
27
  end
28
28
 
29
29
  class << self
30
- def help_command
31
- 'method'
30
+ def names
31
+ %w(method)
32
32
  end
33
33
 
34
- def help(cmd)
34
+ def description
35
35
  %{
36
36
  m[ethod] sig[nature] <obj>\tshow the signature of a method
37
37
  }
@@ -68,11 +68,11 @@ module Byebug
68
68
  end
69
69
 
70
70
  class << self
71
- def help_command
72
- 'method'
71
+ def names
72
+ %w(method)
73
73
  end
74
74
 
75
- def help(cmd)
75
+ def description
76
76
  %{
77
77
  m[ethod] i[nstance] <obj>\tshow methods of object
78
78
  m[ethod] iv <obj>\t\tshow instance variables of object
@@ -13,25 +13,25 @@ module Byebug
13
13
  end
14
14
 
15
15
  def execute
16
- if @match[1] or confirm("Really quit? (y/n) ")
16
+ if @match[1] or confirm("Really quit? (y/n) ")
17
17
  @state.interface.finalize
18
- exit! # exit -> exit!: No graceful way to stop threads...
18
+ exit! # exit -> exit!: No graceful way to stop...
19
19
  end
20
20
  end
21
21
 
22
22
  class << self
23
- def help_command
24
- %w[quit exit]
23
+ def names
24
+ %w(quit exit)
25
25
  end
26
26
 
27
- def help(cmd)
27
+ def description
28
28
  %{
29
- q[uit] [!|unconditionally]\texit from byebug.
29
+ q[uit][ !| unconditionally]\texit from byebug.
30
30
  exit[!]\talias to quit
31
31
 
32
32
  Normally we prompt before exiting. However if the parameter
33
- "unconditionally" or is given or suffixed with !, we stop
34
- without asking further questions.
33
+ "unconditionally" is given or command is suffixed with !, we exit
34
+ without asking further questions.
35
35
  }
36
36
  end
37
37
  end
@@ -29,11 +29,11 @@ module Byebug
29
29
  end
30
30
 
31
31
  class << self
32
- def help_command
33
- 'reload'
32
+ def names
33
+ %w(reload)
34
34
  end
35
35
 
36
- def help(cmd)
36
+ def description
37
37
  %{
38
38
  r[eload]\tforces source code reloading
39
39
  }
@@ -38,7 +38,7 @@ module Byebug
38
38
 
39
39
  def save_settings(file)
40
40
  # FIXME put routine in set
41
- %w(autoeval basename byebugtesting).each do |setting|
41
+ %w(autoeval basename testing).each do |setting|
42
42
  on_off = show_onoff(Command.settings[setting.to_sym])
43
43
  file.puts "set #{setting} #{on_off}"
44
44
  end
@@ -72,18 +72,19 @@ module Byebug
72
72
  end
73
73
 
74
74
  class << self
75
- def help_command
76
- 'save'
75
+ def names
76
+ %w(save)
77
77
  end
78
78
 
79
- def help(cmd)
79
+ def description
80
80
  %{
81
- save [FILE]
82
- Saves current byebug state to FILE as a script file.
83
- This includes breakpoints, catchpoints, display expressions and some settings.
84
- If no filename is given, we will fabricate one.
81
+ save[ FILE]
85
82
 
86
- Use the 'source' command in another debug session to restore them.}
83
+ Saves current byebug state to FILE as a script file. This includes
84
+ breakpoints, catchpoints, display expressions and some settings. If
85
+ no filename is given, we will fabricate one.
86
+ Use the "source" command in another debug session to restore them.
87
+ }
87
88
  end
88
89
  end
89
90
  end
@@ -2,8 +2,12 @@ module Byebug
2
2
 
3
3
  # Implements byebug "set" command.
4
4
  class SetCommand < Command
5
- SubcmdStruct2=Struct.new(:name, :min, :is_bool, :short_help,
6
- :long_help) unless defined?(SubcmdStruct2)
5
+ SubcmdStruct2 = Struct.new(:name,
6
+ :min,
7
+ :is_bool,
8
+ :short_help,
9
+ :long_help) unless defined?(SubcmdStruct2)
10
+
7
11
  Subcommands =
8
12
  [
9
13
  ['annotate', 2, false, 'Set annotation level',
@@ -18,7 +22,7 @@ module Byebug
18
22
  ['autoreload', 4, true, 'Reload source code when changed'],
19
23
  ['basename', 1, true, 'Report file basename only showing file names'],
20
24
  ['callstyle', 2, false, 'Set how you want call parameters displayed'],
21
- ['byebugtesting', 8, false, 'Used when testing byebug'],
25
+ ['testing', 2, false, 'Used when testing byebug'],
22
26
  ['forcestep', 2, true,
23
27
  'Make sure "next/step" commands always move to a new line'],
24
28
  ['fullpath', 2, true, 'Display full file names in frames'],
@@ -46,8 +50,7 @@ module Byebug
46
50
  end
47
51
 
48
52
  def execute
49
- # "Set" alone just prints subcommands
50
- return print format_subcmds(Subcommands) unless @match[1]
53
+ return print SetCommand.help(nil) if SetCommand.names.include?(@match[0])
51
54
 
52
55
  args = @match[1].split(/[ \t]+/)
53
56
  try_subcmd = args.shift
@@ -105,11 +108,9 @@ module Byebug
105
108
  Command.settings[:reload_source_on_change] = set_on
106
109
  when /^autoirb$/
107
110
  Command.settings[:autoirb] = (set_on ? 1 : 0)
108
- when /^byebugtesting$/
109
- Command.settings[:byebugtesting] = set_on
110
- if set_on
111
- Command.settings[:basename] = true
112
- end
111
+ when /^testing$/
112
+ Command.settings[:testing] = set_on
113
+ Command.settings[:basename] = true if set_on
113
114
  when /^forcestep$/
114
115
  self.class.settings[:force_stepping] = set_on
115
116
  when /^history$/
@@ -153,27 +154,29 @@ module Byebug
153
154
  end
154
155
 
155
156
  class << self
156
- def help_command
157
- "set"
157
+ def names
158
+ %w(set)
158
159
  end
159
160
 
160
- def help(args)
161
- # specific subcommand help
162
- if args[1]
163
- subcmd = find(Subcommands, args[1])
164
- return "Invalid \"set\" subcommand \"#{args[1]}\"." unless subcmd
165
-
166
- str = subcmd.short_help + '.'
167
- return str += "\n" + subcmd.long_help if subcmd.long_help
168
- end
169
-
170
- # general help
171
- str = %{
161
+ def description
162
+ %{
172
163
  Modifies parts of byebug environment. Boolean values take on, off, 1
173
- or 0. You can see these environment settings with the "show" command.
164
+ or 0. You can see these environment settings with the "show" command
174
165
  }
175
- str += format_subcmds(Subcommands)
166
+ end
167
+
168
+ def help(args)
169
+ if args && args[1]
170
+ subcmd = SetCommand.new(nil).find(Subcommands, args[1])
171
+ if subcmd
172
+ return "#{subcmd.short_help}.\n#{subcmd.long_help ? subcmd.long_help : ''}"
173
+ else
174
+ return "Invalid \"set\" subcommand \"#{args[1]}\".\n"
175
+ end
176
+ end
177
+ description + SetCommand.new(nil).format_subcmds(Subcommands)
176
178
  end
177
179
  end
180
+
178
181
  end
179
182
  end
@@ -73,8 +73,8 @@ module Byebug
73
73
  s='No readline support'
74
74
  end
75
75
  return s
76
- when /^byebugtesting$/
77
- on_off = Command.settings[:byebugtesting]
76
+ when /^testing$/
77
+ on_off = Command.settings[:testing]
78
78
  return "Currently testing byebug is #{show_onoff(on_off)}."
79
79
  when /^forcestep$/
80
80
  on_off = self.class.settings[:force_stepping]
@@ -215,27 +215,26 @@ module Byebug
215
215
  end
216
216
  end
217
217
 
218
- class << self
219
- def help_command
220
- "show"
218
+ def help(args)
219
+ if args[1]
220
+ subcmd = find(Subcommands, args[1])
221
+ return "Invalid \"show\" subcommand \"#{args[1]}\"." unless subcmd
222
+ str = subcmd.short_help + '.'
223
+ str += "\n" + subcmd.long_help if subcmd.long_help
224
+ return str
221
225
  end
226
+ ShowCommad.description + format_subcmds(Subcommands)
227
+ end
222
228
 
223
- def help(args)
224
- # specific subcommand help
225
- if args[1]
226
- subcmd = find(Subcommands, args[1])
227
- return "Invalid \"show\" subcommand \"#{args[1]}\"." unless subcmd
228
-
229
- str = subcmd.short_help + '.'
230
- str += "\n" + subcmd.long_help if subcmd.long_help
231
- return str
232
- end
229
+ class << self
230
+ def names
231
+ %w(show)
232
+ end
233
233
 
234
- # general help
235
- s = %{
234
+ def description
235
+ %{
236
236
  Generic command for showing things about byebug.
237
237
  }
238
- s += format_subcmds(Subcommands)
239
238
  end
240
239
  end
241
240
  end
@@ -17,19 +17,19 @@ module Byebug
17
17
  end
18
18
 
19
19
  class << self
20
- def help_command
21
- %w[skip]
20
+ def names
21
+ %w(skip)
22
22
  end
23
23
 
24
- def help(cmd)
24
+ def description
25
25
  %{
26
26
  sk[ip]\tskip the next thrown exception
27
27
 
28
- This is useful if you've explicitly caught an exception through
29
- the "catch" command, and wish to pass the exception on to the
30
- code that you're debugging.
31
- }
32
- end
28
+ This is useful if you've explicitly caught an exception through the
29
+ "catch" command, and wish to pass the exception on to the code that
30
+ you're debugging.
31
+ }
32
+ end
33
33
  end
34
34
  end
35
35
  end
@@ -1,36 +1,38 @@
1
1
  module Byebug
2
+
2
3
  # Implements byebug "source" command.
3
4
  class SourceCommand < Command
4
5
  self.allow_in_control = true
5
-
6
+
6
7
  def regexp
7
- /^\s* so(?:urce)? \s+ (.+) $/x
8
+ /^\s* so(?:urce)? (?:\s+ (.+))? $/x
8
9
  end
9
-
10
+
10
11
  def execute
12
+ return print SourceCommand.help(nil) if
13
+ SourceCommand.names.include?(@match[0])
14
+
11
15
  file = File.expand_path(@match[1]).strip
12
- unless File.exist?(file)
13
- errmsg "Command file '#{file}' is not found\n"
14
- return
15
- end
16
+ return errmsg "File \"#{file}\" not found\n" unless File.exist?(file)
17
+
16
18
  if @state and @state.interface
17
19
  @state.interface.command_queue += File.open(file).readlines
18
20
  else
19
21
  Byebug.run_script(file, @state)
20
22
  end
21
23
  end
22
-
24
+
23
25
  class << self
24
- def help_command
25
- 'source'
26
+ def names
27
+ %w(source)
26
28
  end
27
-
28
- def help(cmd)
29
+
30
+ def description
29
31
  %{
30
32
  source FILE\texecutes a file containing byebug commands
31
33
  }
32
34
  end
33
35
  end
34
36
  end
35
-
37
+
36
38
  end