byebug 2.2.2 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6541893328ba036ff5ed811670bfc940b9fa1222
4
- data.tar.gz: 1f61523cfd0e13a95a2a051a7b259ac1635c36c6
3
+ metadata.gz: 544a00d567861047f8cf035bf512491bb07f1fd9
4
+ data.tar.gz: e039ab4629df9d2b91e27af76678d234895bef3e
5
5
  SHA512:
6
- metadata.gz: bff6dbb90362f18ef5ccc5bc5e64d5d60d420932dfd9ac71a1fcdaa5f263c91a9bbe987044410d9f49c1c82e9e7ce43c9f3ce67d45263f135d58fe15323644df
7
- data.tar.gz: bdffa66981b5155c2327719fd25bb1ab0c154e4006be076577128670c5765f711b2b7b18178e2f69fb54cb9c2934c5aeb670ebeed43c6cbaedcb59bdaa166a9a
6
+ metadata.gz: 9e93823cb12a8f356ebd30f481661f296c82ced481d845c140fc399d07ed4aad8af44ab7e269a7b22b41b5f6d1627ab3bb505c695d7352dc0747778544e8ced7
7
+ data.tar.gz: 2b40aaa1e2e0b7d468fc1435d077328068c4d5cbfc218f87067bf377bffc30484fd38704ab04e9970656bcacf9a0764e86df9f6ddae64fec8ca6bec68bd5fca9
@@ -1,3 +1,9 @@
1
+ # 2.3.0
2
+
3
+ * Compatibility with Phusion Passenger Enterprise (thanks @FooBarWidget)
4
+ * More minimalist help system
5
+
6
+
1
7
  # 2.2.2
2
8
 
3
9
  * Fix another compilation issue in 64 bit systems
data/README.md CHANGED
@@ -68,7 +68,7 @@ placed at the end of a block or method call.
68
68
 
69
69
  ## Semantic Versioning
70
70
 
71
- Byebug tries to follow [semantic versioning](semver.org). Backwards
71
+ Byebug tries to follow [semantic versioning](http://semver.org). Backwards
72
72
  compatibility doesn't seem like a critic issue for a debugger because it's not
73
73
  supposed to be used permanently by any program, let alone in production
74
74
  environments. However, I still like the idea of giving some meaning to version
@@ -16,7 +16,7 @@ module Byebug
16
16
  end
17
17
 
18
18
  class Command
19
- Subcmd = Struct.new(:name, :min, :short_help, :long_help)
19
+ Subcmd = Struct.new(:name, :min, :help)
20
20
 
21
21
  class << self
22
22
  def commands
@@ -31,14 +31,13 @@ module Byebug
31
31
  need_context: false } unless defined?(DEF_OPTIONS)
32
32
 
33
33
  def help(args)
34
- output = description.gsub(/^ +/, '') + "\n"
35
-
36
- if defined? self::Subcommands
37
- return output += format_subcmds unless args and args[1]
38
- output += format_subcmd(args[1])
34
+ if args && args[1]
35
+ output = format_subcmd(args[1])
36
+ else
37
+ output = description.gsub(/^ +/, '') + "\n"
38
+ output += format_subcmds if defined? self::Subcommands
39
39
  end
40
-
41
- return output
40
+ output
42
41
  end
43
42
 
44
43
  def find(subcmds, param)
@@ -57,8 +56,7 @@ module Byebug
57
56
  return "Invalid \"#{names.join("|")}\" " \
58
57
  "subcommand \"#{args[1]}\"." unless subcmd
59
58
 
60
- return "#{subcmd.short_help}.\n" \
61
- "#{subcmd.long_help || '' }"
59
+ return "#{subcmd.help}.\n"
62
60
  end
63
61
 
64
62
  def format_subcmds
@@ -67,10 +65,9 @@ module Byebug
67
65
  "--\n" \
68
66
  "List of \"#{cmd_name}\" subcommands:\n" \
69
67
  "--\n"
70
- width = self::Subcommands.map(&:name).max_by(&:size).size
68
+ w = self::Subcommands.map(&:name).max_by(&:size).size
71
69
  for subcmd in self::Subcommands do
72
- s += sprintf \
73
- "%s %-#{width}s -- %s\n", cmd_name, subcmd.name, subcmd.short_help
70
+ s += sprintf "%s %-#{w}s -- %s\n", cmd_name, subcmd.name, subcmd.help
74
71
  end
75
72
  return s
76
73
  end
@@ -91,10 +88,10 @@ module Byebug
91
88
 
92
89
  def method_missing(meth, *args, &block)
93
90
  if meth.to_s =~ /^(.+?)=$/
94
- @options[$1.intern] = args.first
91
+ options[$1.intern] = args.first
95
92
  else
96
- if @options.has_key?(meth)
97
- @options[meth]
93
+ if options.has_key?(meth)
94
+ options[meth]
98
95
  else
99
96
  super
100
97
  end
@@ -192,36 +189,25 @@ module Byebug
192
189
  @state.confirm(msg) == 'y'
193
190
  end
194
191
 
195
- def debug_eval(str, b = get_binding)
192
+ def bb_eval(str, b = get_binding)
196
193
  begin
197
194
  eval(str, b)
198
195
  rescue StandardError, ScriptError => e
199
- if Command.settings[:stack_on_error]
200
- at = eval("Thread.current.backtrace_locations", b)
201
- print "#{at.shift}: #{e.class} Exception(#{e.message})\n"
202
- for i in at
203
- print "\tfrom #{i}\n"
204
- end
205
- else
206
- print "#{e.class} Exception: #{e.message}\n"
196
+ at = eval("Thread.current.backtrace_locations", b)
197
+ print "#{at.shift}: #{e.class} Exception(#{e.message})\n"
198
+ for i in at
199
+ print "\tfrom #{i}\n"
207
200
  end
208
201
  nil
209
202
  end
210
203
  end
211
204
 
212
- def debug_silent_eval(str, b = get_binding)
213
- begin
214
- eval(str, b)
215
- rescue StandardError, ScriptError
216
- nil
217
- end
218
- end
219
-
220
- def debug_warning_eval(str, b = get_binding)
205
+ def bb_warning_eval(str, b = get_binding)
221
206
  begin
222
207
  eval(str, b)
223
208
  rescue StandardError, ScriptError => e
224
209
  print "#{e.class} Exception: #{e.message}\n"
210
+ nil
225
211
  end
226
212
  end
227
213
 
@@ -42,7 +42,7 @@ module Byebug
42
42
  end
43
43
  elsif line !~ /^\d+$/
44
44
  # See if "line" is a method/function name
45
- klass = debug_silent_eval(file)
45
+ klass = bb_warning_eval(file)
46
46
  if klass && klass.kind_of?(Module)
47
47
  class_name = klass.name if klass
48
48
  else
@@ -17,7 +17,7 @@ module Byebug
17
17
  confirm("Delete all catchpoints? (y or n) ")
18
18
  else
19
19
  print "Warning #{@match[1]} is not known to be a Class\n" unless
20
- debug_eval "#{@match[1]}.is_a?(Class)", get_binding
20
+ bb_eval "#{@match[1]}.is_a?(Class)", get_binding
21
21
  Byebug.add_catchpoint @match[1]
22
22
  print "Catch exception #{@match[1]}.\n"
23
23
  end
@@ -2,7 +2,7 @@ module Byebug
2
2
 
3
3
  module DisplayFunctions
4
4
  def display_expression(exp)
5
- print "#{exp} = #{debug_silent_eval(exp).inspect}\n"
5
+ print "#{exp} = #{bb_warning_eval(exp).inspect}\n"
6
6
  end
7
7
 
8
8
  def active_display_expressions?
@@ -44,19 +44,18 @@ module Byebug
44
44
  end
45
45
 
46
46
  class EnableCommand < Command
47
- Subcommands =
48
- [
49
- ['breakpoints', 2, 'Enable breakpoints',
50
- 'This is used to cancel the effect of the "disable" command. Give ' \
51
- 'breakpoint numbers (separated by spaces) as arguments or no ' \
52
- 'argument at all if you want to reenable every breakpoint'],
53
- ['display', 2,
54
- 'Enable some expressions to be displayed when program stops',
55
- 'Arguments are the code numbers of the expressions to resume ' \
56
- 'displaying. Do "info display" to see the current list of code ' \
57
- 'numbers.'],
58
- ].map do |name, min, short_help, long_help|
59
- Subcmd.new(name, min, short_help, long_help)
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)
60
59
  end unless defined?(Subcommands)
61
60
 
62
61
  def regexp
@@ -99,19 +98,18 @@ module Byebug
99
98
  end
100
99
 
101
100
  class DisableCommand < Command
102
- Subcommands =
103
- [
104
- ['breakpoints', 1, 'Disable breakpoints',
105
- 'A disabled breakpoint is not forgotten, but has no effect until ' \
106
- 'reenabled. Give breakpoint numbers (separated by spaces) as ' \
107
- 'arguments or no argument at all if you want to disable every ' \
108
- 'breakpoint'],
109
- ['display', 1, 'Disable some display expressions when program stops',
110
- 'Arguments are the code numbers of the expressions to stop ' \
111
- 'displaying. Do "info display" to see the current list of code ' \
112
- 'numbers.'],
113
- ].map do |name, min, short_help, long_help|
114
- Subcmd.new(name, min, short_help, long_help)
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)
115
113
  end unless defined?(Subcommands)
116
114
 
117
115
  def regexp
@@ -33,7 +33,11 @@ module Byebug
33
33
  def execute
34
34
  expr = @match ? @match.post_match : @input
35
35
  run_with_binding do |b|
36
- print "#{debug_eval(expr, b).inspect}\n"
36
+ if Command.settings[:stack_on_error]
37
+ print "#{bb_eval(expr, b).inspect}\n"
38
+ else
39
+ print "#{bb_warning_eval(expr, b).inspect}\n"
40
+ end
37
41
  end
38
42
  rescue
39
43
  print "#{$!.class} Exception: #{$!.message}\n"
@@ -64,7 +68,11 @@ module Byebug
64
68
  def execute
65
69
  out = StringIO.new
66
70
  run_with_binding do |b|
67
- PP.pp(debug_eval(@match.post_match, b), out)
71
+ if Command.settings[:stack_on_error]
72
+ PP.pp(bb_eval(@match.post_match, b), out)
73
+ else
74
+ PP.pp(bb_warning_eval(@match.post_match, b), out)
75
+ end
68
76
  end
69
77
  print out.string
70
78
  rescue
@@ -93,7 +101,11 @@ module Byebug
93
101
  def execute
94
102
  out = StringIO.new
95
103
  run_with_binding do |b|
96
- vals = debug_eval(@match.post_match, b)
104
+ if Command.settings[:stack_on_error]
105
+ vals = bb_eval(@match.post_match, b)
106
+ else
107
+ vals = bb_warning_eval(@match.post_match, b)
108
+ end
97
109
  if vals.is_a?(Array)
98
110
  vals = vals.map{|item| item.to_s}
99
111
  print "#{columnize(vals, Command.settings[:width])}\n"
@@ -130,7 +142,11 @@ module Byebug
130
142
  def execute
131
143
  out = StringIO.new
132
144
  run_with_binding do |b|
133
- vals = debug_eval(@match.post_match, b)
145
+ if Command.settings[:stack_on_error]
146
+ vals = bb_eval(@match.post_match, b)
147
+ else
148
+ vals = bb_warning_eval(@match.post_match, b)
149
+ end
134
150
  if vals.is_a?(Array)
135
151
  vals = vals.map{|item| item.to_s}
136
152
  print "#{columnize(vals.sort!, Command.settings[:width])}\n"
@@ -19,48 +19,49 @@ module Byebug
19
19
  include Columnize
20
20
  self.allow_in_control = true
21
21
 
22
- Subcommands =
23
- [
24
- ['args', 1, 'Argument variables of current stack frame'],
25
- ['breakpoints', 1, 'Status of user-settable breakpoints',
26
- 'Without argument, list info about all breakpoints. With an integer ' \
27
- 'argument, list info on that breakpoint.'],
28
- ['catch', 3,
29
- 'Exceptions that can be caught in the current stack frame'],
30
- ['display', 2, 'Expressions to display when program stops'],
31
- ['file', 4, 'Info about a particular file read in',
32
- 'After the file name is supplied, you can list file attributes that ' \
33
- 'you wish to see. Attributes include: "all", "basic", "breakpoint", ' \
34
- '"lines", "mtime", "path" and "sha1".'],
35
- ['files', 5, 'File names and timestamps of files read in'],
36
- ['global_variables', 2, 'Global variables'],
37
- ['instance_variables', 2,
38
- 'Instance variables of the current stack frame'],
39
- ['line', 2,
40
- 'Line number and file name of current position in source file'],
41
- ['locals', 2, 'Local variables of the current stack frame'],
42
- ['program', 2, 'Execution status of the program'],
43
- ['stack', 2, 'Backtrace of the stack'],
44
- ['variables', 1,
45
- 'Local and instance variables of the current stack frame']
46
- ].map do |name, min, short_help, long_help|
47
- Subcmd.new(name, min, short_help, long_help)
22
+ Subcommands = [
23
+ ['args' , 1, 'Argument variables of current stack frame' ],
24
+ ['breakpoints' , 1, 'Status of user-settable breakpoints',
25
+ 'Without argument, list info about all ' \
26
+ 'breakpoints. With an integer argument, ' \
27
+ 'list info on that breakpoint.' ],
28
+ ['catch' , 3, 'Exceptions that can be caught in the ' \
29
+ 'current stack frame' ],
30
+ ['display' , 2, 'Expressions to display when program stops' ],
31
+ ['file' , 4, 'Info about a particular file read in',
32
+ 'After the file name is supplied, you can' \
33
+ 'list file attributes that you wish to ' \
34
+ 'see. Attributes include: "all", "basic",' \
35
+ ' "breakpoint", "lines", "mtime", "path" ' \
36
+ 'and "sha1".' ],
37
+ ['files' , 5, 'File names and timestamps of files read in' ],
38
+ ['global_variables' , 2, 'Global variables' ],
39
+ ['instance_variables', 2, 'Instance variables in current stack frame' ],
40
+ ['line' , 2, 'Line number and file name of current ' \
41
+ 'position in source file' ],
42
+ ['locals' , 2, 'Local variables of the current stack frame' ],
43
+ ['program' , 2, 'Execution status of the program' ],
44
+ ['stack' , 2, 'Backtrace of the stack' ],
45
+ ['variables' , 1, 'Local and instance variables of the ' \
46
+ 'current stack frame' ]
47
+ ].map do |name, min, help|
48
+ Subcmd.new(name, min, help)
48
49
  end unless defined?(Subcommands)
49
50
 
50
- InfoFileSubcommands =
51
- [
52
- ['all', 1, 'All file information available - breakpoints, lines, ' \
53
- 'mtime, path and sha1'],
54
- ['basic', 2, 'basic information - path, number of lines'],
55
- ['breakpoints', 2, 'Show trace line numbers',
56
- 'These are the line number where a breakpoint can be set.'],
57
- ['lines', 1, 'Show number of lines in the file'],
58
- ['mtime', 1, 'Show modification time of file'],
59
- ['path', 4, 'Show full file path name for file'],
60
- ['sha1', 1, 'Show SHA1 hash of contents of the file']
61
- ].map do |name, min, short_help, long_help|
62
- Subcmd.new(name, min, short_help, long_help)
63
- end unless defined?(InfoFileSubcommands)
51
+ InfoFileSubcommands = [
52
+ ['all' , 1, 'All file information available - breakpoints, ' \
53
+ 'lines, mtime, path and sha1' ],
54
+ ['basic' , 2, 'basic information - path, number of lines' ],
55
+ ['breakpoints', 2, 'Show trace line numbers',
56
+ 'These are the line number where a breakpoint ' \
57
+ 'can be set.' ],
58
+ ['lines' , 1, 'Show number of lines in the file' ],
59
+ ['mtime' , 1, 'Show modification time of file' ],
60
+ ['path' , 4, 'Show full file path name for file' ],
61
+ ['sha1' , 1, 'Show SHA1 hash of contents of the file' ]
62
+ ].map do |name, min, help|
63
+ Subcmd.new(name, min, help)
64
+ end unless defined?(InfoFileSubcommands)
64
65
 
65
66
  def regexp
66
67
  /^\s* i(?:nfo)? (?:\s+(.+))? \s*$/x
@@ -194,7 +195,7 @@ module Byebug
194
195
  end
195
196
 
196
197
  def info_instance_variables(*args)
197
- obj = debug_eval('self')
198
+ obj = bb_eval('self')
198
199
  var_list(obj.instance_variables)
199
200
  end
200
201
 
@@ -260,7 +261,7 @@ module Byebug
260
261
  locals[:self] = @state.context.frame_self(@state.frame_pos)
261
262
  print_hash(locals)
262
263
 
263
- obj = debug_eval('self')
264
+ obj = bb_eval('self')
264
265
  var_list(obj.instance_variables, obj.instance_eval{binding()})
265
266
  var_class_self
266
267
  end
@@ -14,7 +14,7 @@ module Byebug
14
14
  end
15
15
 
16
16
  def execute
17
- obj = debug_eval('method(:%s)' % @match[1])
17
+ obj = bb_eval('method(:%s)' % @match[1])
18
18
  if obj.is_a?(Method)
19
19
  begin
20
20
  print "%s\n", obj.signature.to_s
@@ -46,7 +46,7 @@ module Byebug
46
46
  end
47
47
 
48
48
  def execute
49
- obj = debug_eval(@match.post_match)
49
+ obj = bb_eval(@match.post_match)
50
50
  if @match[1] == "iv"
51
51
  obj.instance_variables.sort.each do |v|
52
52
  print "#{v} = #{obj.instance_variable_get(v).inspect}\n"
@@ -63,51 +63,49 @@ module Byebug
63
63
 
64
64
  # Implements byebug "set" command.
65
65
  class SetCommand < Command
66
- SubcmdStruct2 = Struct.new(:name,
67
- :min,
68
- :is_bool,
69
- :short_help,
70
- :long_help) unless defined?(SubcmdStruct2)
71
-
72
- Subcommands =
73
- [
74
- ['args', 2, false,
75
- 'Set argument list to the program being debugged when it is started'],
76
- ['autoeval', 4, true, 'Evaluate every unrecognized command'],
77
- ['autolist', 4, true, 'Execute "list" command on every breakpoint'],
78
- ['autoirb', 4, true, 'Invoke IRB on every stop'],
79
- ['autoreload', 4, true, 'Reload source code when changed'],
80
- ['basename', 1, true, 'Set filename display style'],
81
- ['callstyle', 2, false, 'Set how you want call parameters displayed'],
82
- ['testing', 2, false, 'Used when testing byebug'],
83
- ['forcestep', 2, true,
84
- 'Make sure "next/step" commands always move to a new line'],
85
- ['fullpath', 2, true, 'Display full file names in frames'],
86
- ['history', 2, false, 'Command for setting command history parameters',
87
- 'History parameters are "filename", "save" and "size"'],
88
- ['linetrace', 3, true, 'Enable line execution tracing'],
89
- ['linetrace_plus', 10, true,
90
- 'Set line execution tracing to show different lines'],
91
- ['listsize', 3, false, 'Set number of source lines to list by default'],
92
- ['post_mortem', 2, true, 'Enable post-mortem mode'],
93
- ['stack_on_error', 1, true,
94
- 'Display stack trace when "eval" raises exception'],
95
- ['verbose', 1, true,
96
- 'Enable verbose output of TracePoint API events is enabled'],
97
- ['width', 1, false,
98
- 'Number of characters per line for byebug\'s output']
99
- ].map do |name, min, is_bool, short_help, long_help|
100
- SubcmdStruct2.new(name, min, is_bool, short_help, long_help)
66
+ Subcmd2 = Struct.new(:name, :min, :is_bool, :help) unless defined?(Subcmd2)
67
+
68
+ Subcommands = [
69
+ ['args' , 2 , false, 'Set argument list to the program ' \
70
+ 'being debugged when it is started' ],
71
+ ['autoeval' , 4 , true , 'Evaluate every unrecognized command' ],
72
+ ['autolist' , 4 , true , 'Execute "list" command on every ' \
73
+ 'breakpoint' ],
74
+ ['autoirb' , 4 , true , 'Invoke IRB on every stop' ],
75
+ ['autoreload' , 4 , true , 'Reload source code when changed' ],
76
+ ['basename' , 1 , true , 'Set filename display style' ],
77
+ ['callstyle' , 2 , false, 'Set how you want call parameters ' \
78
+ 'displayed' ],
79
+ ['testing' , 2 , false, 'Used when testing byebug' ],
80
+ ['forcestep' , 2 , true , 'Make sure "next/step" commands always' \
81
+ 'move to a new line' ],
82
+ ['fullpath' , 2 , true , 'Display full file names in frames' ],
83
+ ['history' , 2 , false, 'Command for setting command history ' \
84
+ 'parameters, namely, "filename", ' \
85
+ '"save" and "size"' ],
86
+ ['linetrace' , 3 , true , 'Enable line execution tracing' ],
87
+ ['linetrace_plus', 10, true , 'Set line execution tracing to show' \
88
+ 'different lines' ],
89
+ ['listsize' , 3 , false, 'Set number of source lines to list by' \
90
+ 'default' ],
91
+ ['post_mortem' , 2 , true , 'Enable post-mortem mode' ],
92
+ ['stack_on_error', 1 , true , 'Display stack trace when "eval" ' \
93
+ 'raises exception' ],
94
+ ['verbose' , 1 , true , 'Enable verbose output of TracePoint ' \
95
+ 'API events is enabled' ],
96
+ ['width' , 1 , false, 'Number of characters per line for ' \
97
+ 'byebug\'s output' ]
98
+ ].map do |name, min, is_bool, help|
99
+ Subcmd2.new(name, min, is_bool, help)
101
100
  end unless defined?(Subcommands)
102
101
 
103
- SetHistorySubcommands =
104
- [
105
- ['filename', 1, 'Set the filename in which to record command history'],
106
- ['save', 1, 'Set saving of the history record on exit'],
107
- ['size', 1, 'Set the size of the command history']
108
- ].map do |name, min, short_help, long_help|
109
- Subcmd.new(name, min, short_help, long_help)
110
- end unless defined?(SetHistorySubcommands)
102
+ SetHistorySubcommands = [
103
+ ['filename', 1, 'Set the filename in which to record command history'],
104
+ ['save' , 1, 'Set saving of the history record on exit' ],
105
+ ['size' , 1, 'Set the size of the command history' ]
106
+ ].map do |name, min, help|
107
+ Subcmd.new(name, min, help)
108
+ end unless defined?(SetHistorySubcommands)
111
109
 
112
110
  self.allow_in_control = true
113
111
 
@@ -152,6 +150,6 @@ module Byebug
152
150
  or 0. You can see these environment settings with the "show" command.}
153
151
  end
154
152
  end
155
-
156
153
  end
154
+
157
155
  end