byebug 1.0.1 → 1.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9de6831ec3ce9e27c6e2cca6a3e230f30d4c4498
4
- data.tar.gz: 80c1890643664250f76be3332437054636223e6d
3
+ metadata.gz: 9879e1bf4c99c2ce971bb11d2d0d9e1be2ab6b3f
4
+ data.tar.gz: 5402c4b2c35821bb2a594dff94b2fe8f5928fa16
5
5
  SHA512:
6
- metadata.gz: e57c240bc36528ad61d3e44be7819b9e72effe76f61e8895b9e24a8df9ee9a4eabbed01a6edfb6e42529128a02a0b1233761af4f2cf49e0119b49e2bfb4507a5
7
- data.tar.gz: 88ce74faec5aef2ae39487e9be5912b1da806e2c8b8fe4513fcb9b0859a1432cc4ab764f95522ba2f01df853ee1fe97d737dd849bc8b42a6b56497fb1986c567
6
+ metadata.gz: 500afcaa81db3c20f1e36a691d4599d29feeafa0670e7b37e134bd2a9e5afa8f7812caaa85b147ac72b1b870552ff655ffe767e10e4dd07e13359cebcd903039
7
+ data.tar.gz: f8ac3188a9cd9520f8bd3d3b440ad5f9c29e4ec4feb5fd83236eaa4a43920c81a0fa72a47c5092898bab539fc3fcf1b99fb1d518646444d4d8f6eb2d3c658888
@@ -1,8 +1,20 @@
1
- ## 0.0.1
1
+ ## 1.0.2
2
2
 
3
- * Initial release
3
+ * "autolist" and "autoeval" are default settings now
4
+ * Fixes bug which messed up the call-stack when manipulating backtrace
5
+ information and when nexting/stepping
6
+
7
+
8
+ ## 1.0.1
9
+
10
+ * Corrected small bug preventing byebug from loading
4
11
 
5
12
 
6
13
  ## 1.0.0
7
14
 
8
15
  * Green test suite
16
+
17
+
18
+ ## 0.0.1
19
+
20
+ * Initial release
data/bin/byebug CHANGED
@@ -292,15 +292,13 @@ end
292
292
 
293
293
  opts = process_options(options)
294
294
  begin
295
- if not defined? Byebug::ARGV
296
- Byebug::ARGV = ARGV.clone
297
- end
295
+ Byebug::ARGV = ARGV.clone if not defined? Byebug::ARGV
298
296
  byebug_path = File.expand_path($0)
299
297
  if RUBY_PLATFORM =~ /mswin/
300
298
  byebug_path += '.cmd' unless byebug_path =~ /\.cmd$/i
301
299
  end
302
300
  Byebug::RDEBUG_SCRIPT = byebug_path
303
- Byebug::RDEBUG_FILE = __FILE__
301
+ Byebug::BYEBUG_BIN = __FILE__
304
302
  Byebug::INITIAL_DIR = Dir.pwd
305
303
  opts.parse! ARGV
306
304
  rescue StandardError => e
@@ -158,13 +158,13 @@ process_line_event(VALUE trace_point, void *data)
158
158
 
159
159
  load_frame_info(
160
160
  trace_point, &path, &lineno, &method_id, &defined_class, &binding, &self);
161
+ update_frame(context_object, RSTRING_PTR(path), FIX2INT(lineno), method_id,
162
+ defined_class, binding, self);
163
+
161
164
  if (debug == Qtrue)
162
165
  print_debug_info(
163
166
  "line", path, lineno, method_id, defined_class, context->stack_size);
164
167
 
165
- update_frame(context_object, RSTRING_PTR(path), FIX2INT(lineno), method_id,
166
- defined_class, binding, self);
167
-
168
168
  if (context->last_line != FIX2INT(lineno) || context->last_file == NULL ||
169
169
  strcmp(context->last_file, RSTRING_PTR(path)))
170
170
  {
@@ -228,12 +228,12 @@ process_return_event(VALUE trace_point, void *data)
228
228
 
229
229
  load_frame_info(trace_point, &path, &lineno, &method_id, &defined_class,
230
230
  &binding, &self);
231
+ pop_frame(context_object);
232
+
231
233
  if (debug == Qtrue)
232
234
  print_debug_info("return", path, lineno, method_id, defined_class,
233
235
  context->stack_size);
234
-
235
236
  //rb_funcall(context_object, idAtReturn, 2, path, lineno);
236
- pop_frame(context_object);
237
237
 
238
238
  cleanup(context);
239
239
  }
@@ -252,13 +252,13 @@ process_call_event(VALUE trace_point, void *data)
252
252
 
253
253
  load_frame_info(trace_point, &path, &lineno, &method_id, &defined_class,
254
254
  &binding, &self);
255
+ push_frame(context_object, RSTRING_PTR(path), FIX2INT(lineno), method_id,
256
+ defined_class, binding, self);
257
+
255
258
  if (debug == Qtrue)
256
259
  print_debug_info("call", path, lineno, method_id, defined_class,
257
260
  context->stack_size);
258
261
 
259
- push_frame(context_object, RSTRING_PTR(path), FIX2INT(lineno), method_id,
260
- defined_class, binding, self);
261
-
262
262
  breakpoint = find_breakpoint_by_method(breakpoints, defined_class,
263
263
  SYM2ID(method_id),
264
264
  binding, self);
@@ -343,12 +343,12 @@ Byebug_setup_tracepoints(VALUE self)
343
343
  rb_tracepoint_enable(tpLine);
344
344
 
345
345
  tpReturn = rb_tracepoint_new(Qnil,
346
- RUBY_EVENT_RETURN | RUBY_EVENT_C_RETURN | RUBY_EVENT_B_RETURN | RUBY_EVENT_CLASS | RUBY_EVENT_END,
346
+ RUBY_EVENT_RETURN | RUBY_EVENT_C_RETURN | RUBY_EVENT_B_RETURN | RUBY_EVENT_END,
347
347
  process_return_event, NULL);
348
348
  rb_tracepoint_enable(tpReturn);
349
349
 
350
350
  tpCall = rb_tracepoint_new(Qnil,
351
- RUBY_EVENT_CALL | RUBY_EVENT_C_CALL | RUBY_EVENT_B_CALL,
351
+ RUBY_EVENT_CALL | RUBY_EVENT_C_CALL | RUBY_EVENT_B_CALL | RUBY_EVENT_CLASS,
352
352
  process_call_event, NULL);
353
353
  rb_tracepoint_enable(tpCall);
354
354
 
@@ -24,19 +24,26 @@ module Byebug
24
24
  SubcmdStruct = Struct.new(:name, :min, :short_help, :long_help) unless
25
25
  defined?(SubcmdStruct)
26
26
 
27
- def print_subcommands
28
- cmd_name = self.class.name.chomp("Command").downcase
29
- errmsg "#{cmd_name} must be followed by the name of a subcommand.\n"
30
- print "List of #{cmd_name} subcommands:\n\n"
31
- for subcmd in Subcommands do
27
+ ##
28
+ # Print list of subcmds
29
+ #
30
+ def print_subcmds(subcmds)
31
+ cmd_name = self.class.name[/Byebug::(.*)Command/, 1].downcase
32
+ errmsg "\"#{cmd_name}\" must be followed by the name of a subcommand.\n"
33
+ print "List of \"#{cmd_name}\" subcommands:\n"
34
+ for subcmd in subcmds do
32
35
  print "#{cmd_name} #{subcmd.name} -- #{subcmd.short_help}\n"
33
36
  end
34
37
  end
35
38
 
36
39
  include Columnize
37
40
 
38
- # Find param in subcmds. param id downcased and can be abbreviated
39
- # to the minimum length listed in the subcommands
41
+ ##
42
+ # Find param in subcmds.
43
+ #
44
+ # @param is downcased and can be abbreviated to the minimum length listed in
45
+ # the subcommands.
46
+ #
40
47
  def find(subcmds, param)
41
48
  param.downcase!
42
49
  for try_subcmd in subcmds do
@@ -55,7 +62,7 @@ module Byebug
55
62
 
56
63
  DEF_OPTIONS = {
57
64
  :allow_in_control => false,
58
- :allow_in_post_mortem => false ,
65
+ :allow_in_post_mortem => false,
59
66
  :event => true ,
60
67
  :always_run => 0 ,
61
68
  :unknown => false,
@@ -153,7 +160,6 @@ module Byebug
153
160
  register_setting_var(:byebugtesting, false)
154
161
  register_setting_var(:force_stepping, false)
155
162
  register_setting_var(:full_path, true)
156
- register_setting_var(:autolist, 1)
157
163
  register_setting_var(:listsize, 10)
158
164
  register_setting_var(:stack_trace_on_error, false)
159
165
  register_setting_var(:tracing_plus, false)
@@ -81,15 +81,16 @@ module Byebug
81
81
  end
82
82
  b = Byebug.add_breakpoint brkpt_filename, line, expr
83
83
  print "Created breakpoint #{b.id} at " \
84
- "#{CommandProcessor.canonic_file(brkpt_filename)}:#{line.to_s}"
84
+ "#{CommandProcessor.canonic_file(brkpt_filename)}:#{line.to_s}\n"
85
85
  unless syntax_valid?(expr)
86
- errmsg("Expression \"#{expr}\" syntactically incorrect; breakpoint disabled.\n")
86
+ errmsg "Expression \"#{expr}\" syntactically incorrect; breakpoint" \
87
+ " disabled.\n"
87
88
  b.enabled = false
88
89
  end
89
90
  else
90
91
  method = line.intern
91
92
  b = Byebug.add_breakpoint class_name, method, expr
92
- print "Created breakpoint #{b.id} at #{class_name}::#{method.to_s}"
93
+ print "Created breakpoint #{b.id} at #{class_name}::#{method.to_s}\n"
93
94
  end
94
95
  end
95
96
 
@@ -1,6 +1,7 @@
1
1
  module Byebug
2
+
2
3
  # Mix-in module to assist in command parsing.
3
- module EnableDisableFunctions # :nodoc:
4
+ module EnableDisableFunctions
4
5
  def enable_disable_breakpoints(is_enable, args)
5
6
  breakpoints = Byebug.breakpoints.sort_by{|b| b.id }
6
7
  largest = breakpoints.inject(0) do |tally, b|
@@ -14,7 +15,7 @@ module Byebug
14
15
  pos = get_int(pos, "#{is_enable} breakpoints", 1, largest)
15
16
  return nil unless pos
16
17
  breakpoints.each do |b|
17
- if b.id == pos
18
+ if b.id == pos
18
19
  enabled = ("Enable" == is_enable)
19
20
  if enabled
20
21
  unless syntax_valid?(b.expr)
@@ -30,7 +31,7 @@ module Byebug
30
31
  end
31
32
 
32
33
  def enable_disable_display(is_enable, args)
33
- if 0 == @state.display.size
34
+ if 0 == @state.display.size
34
35
  errmsg "No display expressions have been set.\n"
35
36
  return
36
37
  end
@@ -43,25 +44,25 @@ module Byebug
43
44
 
44
45
  end
45
46
 
46
- class EnableCommand < Command # :nodoc:
47
- Subcommands =
47
+ class EnableCommand < Command
48
+ Subcommands =
48
49
  [
49
- ['breakpoints', 2, "Enable specified breakpoints",
50
- "Give breakpoint numbers (separated by spaces) as arguments.
51
- This is used to cancel the effect of the \"disable\" command."
52
- ],
53
- ['display', 2,
54
- "Enable some expressions to be displayed when program stops",
55
- "Arguments are the code numbers of the expressions to resume displaying.
56
- Do \"info display\" to see current list of code numbers."],
57
- ].map do |name, min, short_help, long_help|
50
+ ['breakpoints', 2, 'Enable specified breakpoints',
51
+ 'Give breakpoint numbers (separated by spaces) as arguments. This is ' \
52
+ 'used to cancel the effect of the \"disable\" command.'],
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|
58
59
  SubcmdStruct.new(name, min, short_help, long_help)
59
60
  end unless defined?(Subcommands)
60
61
 
61
62
  def regexp
62
63
  /^\s* en(?:able)? (?:\s+(.*))?$/ix
63
64
  end
64
-
65
+
65
66
  def execute
66
67
  if not @match[1]
67
68
  errmsg "\"enable\" must be followed \"display\", \"breakpoints\"" +
@@ -77,41 +78,38 @@ Do \"info display\" to see current list of code numbers."],
77
78
  end
78
79
  end
79
80
  end
80
-
81
+
81
82
  def enable_breakpoints(args)
82
83
  enable_disable_breakpoints("Enable", args)
83
84
  end
84
-
85
+
85
86
  def enable_display(args)
86
87
  enable_disable_display("Enable", args)
87
88
  end
88
-
89
+
89
90
  class << self
90
91
  def help_command
91
92
  'enable'
92
93
  end
93
94
 
94
95
  def help(args)
95
- if args[1]
96
- s = args[1]
97
- subcmd = Subcommands.find do |try_subcmd|
98
- (s.size >= try_subcmd.min) and
99
- (try_subcmd.name[0..s.size-1] == s)
100
- end
101
- if subcmd
102
- str = subcmd.short_help + '.'
103
- str += "\n" + subcmd.long_help if subcmd.long_help
104
- return str
105
- else
106
- return "Invalid 'enable' subcommand '#{args[1]}'."
107
- end
96
+ # specific subcommand help
97
+ if args[1]
98
+ subcmd = find(Subcommands, args[1])
99
+ return "Invalid \"enable\" subcommand \"#{args[1]}\"." unless subcmd
100
+
101
+ str = subcmd.short_help + '.'
102
+ str += "\n" + subcmd.long_help if subcmd.long_help
103
+ return str
108
104
  end
105
+
106
+ # general help
109
107
  s = %{
110
108
  Enable some things.
111
109
  This is used to cancel the effect of the "disable" command.
112
- --
110
+ --
113
111
  List of enable subcommands:
114
- --
112
+ --
115
113
  }
116
114
  for subcmd in Subcommands do
117
115
  s += "enable #{subcmd.name} -- #{subcmd.short_help}\n"
@@ -121,23 +119,24 @@ Do \"info display\" to see current list of code numbers."],
121
119
  end
122
120
  end
123
121
 
124
- class DisableCommand < Command # :nodoc:
125
- Subcommands =
122
+ class DisableCommand < Command
123
+ Subcommands =
126
124
  [
127
- ['breakpoints', 1, "Disable some breakpoints",
128
- "Arguments are breakpoint numbers with spaces in between.
129
- A disabled breakpoint is not forgotten, but has no effect until reenabled."],
130
- ['display', 1, "Disable some display expressions when program stops",
131
- "Arguments are the code numbers of the expressions to stop displaying.
132
- Do \"info display\" to see current list of code numbers."],
133
- ].map do |name, min, short_help, long_help|
125
+ ['breakpoints', 1, 'Disable some breakpoints',
126
+ 'Arguments are breakpoint numbers with spaces in between. A disabled ' \
127
+ 'breakpoint is not forgotten, but has no effect until reenabled.'],
128
+ ['display', 1, 'Disable some display expressions when program stops',
129
+ 'Arguments are the code numbers of the expressions to stop ' \
130
+ 'displaying. Do \"info display\" to see the current list of code ' \
131
+ 'numbers.'],
132
+ ].map do |name, min, short_help, long_help|
134
133
  SubcmdStruct.new(name, min, short_help, long_help)
135
134
  end unless defined?(Subcommands)
136
135
 
137
136
  def regexp
138
137
  /^\s* dis(?:able)? (?:\s+(.*))?$/ix
139
138
  end
140
-
139
+
141
140
  def execute
142
141
  if not @match[1]
143
142
  errmsg "\"disable\" must be followed \"display\", \"breakpoints\"" +
@@ -153,43 +152,40 @@ Do \"info display\" to see current list of code numbers."],
153
152
  end
154
153
  end
155
154
  end
156
-
155
+
157
156
  def disable_breakpoints(args)
158
157
  enable_disable_breakpoints("Disable", args)
159
158
  end
160
-
159
+
161
160
  def disable_display(args)
162
161
  enable_disable_display("Disable", args)
163
162
  end
164
-
163
+
165
164
  class << self
166
165
  def help_command
167
166
  'disable'
168
167
  end
169
168
 
170
169
  def help(args)
171
- if args[1]
172
- s = args[1]
173
- subcmd = Subcommands.find do |try_subcmd|
174
- (s.size >= try_subcmd.min) and
175
- (try_subcmd.name[0..s.size-1] == s)
176
- end
177
- if subcmd
178
- str = subcmd.short_help + '.'
179
- str += "\n" + subcmd.long_help if subcmd.long_help
180
- return str
181
- else
182
- return "Invalid 'disable' subcommand '#{args[1]}'."
183
- end
170
+ # specific subcommand help
171
+ if args[1]
172
+ subcmd = find(Subcommands, args[1])
173
+ return "Invalid \"disable\" subcommand \"#{args[1]}\"." unless subcmd
174
+
175
+ str = subcmd.short_help + '.'
176
+ str += "\n" + subcmd.long_help if subcmd.long_help
177
+ return str
184
178
  end
179
+
180
+ # general help
185
181
  s = %{
186
182
  Disable some things.
187
183
 
188
184
  A disabled item is not forgotten, but has no effect until reenabled.
189
185
  Use the "enable" command to have it take effect again.
190
- --
186
+ --
191
187
  List of disable subcommands:
192
- --
188
+ --
193
189
  }
194
190
  for subcmd in Subcommands do
195
191
  s += "disable #{subcmd.name} -- #{subcmd.short_help}\n"
@@ -1,5 +1,6 @@
1
1
  module Byebug
2
- module EvalFunctions # :nodoc:
2
+
3
+ module EvalFunctions
3
4
  def run_with_binding
4
5
  binding = @state.context ? get_binding : TOPLEVEL_BINDING
5
6
  $__dbg_interface = @state.interface
@@ -21,10 +22,10 @@ module Byebug
21
22
  $__dbg_interface = nil
22
23
  end
23
24
  end
24
-
25
+
25
26
  class EvalCommand < Command # :nodoc:
26
27
  self.allow_in_control = true
27
-
28
+
28
29
  register_setting_get(:autoeval) do
29
30
  EvalCommand.unknown
30
31
  end
@@ -32,11 +33,14 @@ module Byebug
32
33
  EvalCommand.unknown = value
33
34
  end
34
35
 
36
+ # Set default value
37
+ Command.settings[:autoeval] = 1
38
+
35
39
  def match(input)
36
40
  @input = input
37
41
  super
38
42
  end
39
-
43
+
40
44
  def regexp
41
45
  /^\s*(p|e(?:val)?)\s+/
42
46
  end
@@ -44,7 +48,7 @@ module Byebug
44
48
  def execute
45
49
  expr = @match ? @match.post_match : @input
46
50
  run_with_binding do |b|
47
- print "%s\n", debug_eval(expr, b).inspect
51
+ print "#{debug_eval(expr, b).inspect}\n"
48
52
  end
49
53
  end
50
54
 
@@ -56,22 +60,22 @@ module Byebug
56
60
  def help(cmd)
57
61
  if cmd == 'p'
58
62
  %{
59
- p expression\tevaluate expression and print its value
60
- }
63
+ p expression\tevaluate expression and print its value
64
+ }
61
65
  else
62
66
  %{
63
- e[val] expression\tevaluate expression and print its value,
64
- \t\t\talias for p.
65
- * NOTE - to turn on autoeval, use 'set autoeval'
66
- }
67
+ e[val] expression\tevaluate expression and print its value,
68
+ \t\t\talias for p.
69
+ * NOTE - to turn on autoeval, use 'set autoeval'
70
+ }
67
71
  end
68
72
  end
69
73
  end
70
74
  end
71
75
 
72
- class PPCommand < Command # :nodoc:
76
+ class PPCommand < Command
73
77
  self.allow_in_control = true
74
-
78
+
75
79
  def regexp
76
80
  /^\s*pp\s+/
77
81
  end
@@ -82,7 +86,7 @@ module Byebug
82
86
  PP.pp(debug_eval(@match.post_match, b), out)
83
87
  end
84
88
  print out.string
85
- rescue
89
+ rescue
86
90
  out.puts $!.message
87
91
  end
88
92
 
@@ -93,15 +97,15 @@ module Byebug
93
97
 
94
98
  def help(cmd)
95
99
  %{
96
- pp expression\tevaluate expression and pretty-print its value
97
- }
100
+ pp expression\tevaluate expression and pretty-print its value
101
+ }
98
102
  end
99
103
  end
100
104
  end
101
105
 
102
- class PutLCommand < Command # :nodoc:
106
+ class PutLCommand < Command
103
107
  self.allow_in_control = true
104
-
108
+
105
109
  def regexp
106
110
  /^\s*putl\s+/
107
111
  end
@@ -112,13 +116,13 @@ module Byebug
112
116
  vals = debug_eval(@match.post_match, b)
113
117
  if vals.is_a?(Array)
114
118
  vals = vals.map{|item| item.to_s}
115
- print "%s\n", columnize(vals, self.class.settings[:width])
119
+ print "#{columnize(vals, self.class.settings[:width])}\n"
116
120
  else
117
121
  PP.pp(vals, out)
118
122
  print out.string
119
123
  end
120
124
  end
121
- rescue
125
+ rescue
122
126
  out.puts $!.message
123
127
  end
124
128
 
@@ -129,17 +133,17 @@ module Byebug
129
133
 
130
134
  def help(cmd)
131
135
  %{
132
- putl expression\t\tevaluate expression, an array, and columnize its value
133
- }
136
+ putl expression\tevaluate expression, an array, and columnize its value
137
+ }
134
138
  end
135
139
  end
136
140
  end
137
-
138
- class PSCommand < Command # :nodoc:
141
+
142
+ class PSCommand < Command
139
143
  self.allow_in_control = true
140
-
144
+
141
145
  include EvalFunctions
142
-
146
+
143
147
  def regexp
144
148
  /^\s*ps\s+/
145
149
  end
@@ -150,13 +154,13 @@ module Byebug
150
154
  vals = debug_eval(@match.post_match, b)
151
155
  if vals.is_a?(Array)
152
156
  vals = vals.map{|item| item.to_s}
153
- print "%s\n", columnize(vals.sort!, self.class.settings[:width])
157
+ print "#{columnize(vals.sort!, self.class.settings[:width])}\n"
154
158
  else
155
159
  PP.pp(vals, out)
156
160
  print out.string
157
161
  end
158
162
  end
159
- rescue
163
+ rescue
160
164
  out.puts $!.message
161
165
  end
162
166
 
@@ -167,10 +171,10 @@ module Byebug
167
171
 
168
172
  def help(cmd)
169
173
  %{
170
- ps expression\tevaluate expression, an array, sort, and columnize its value
171
- }
174
+ ps expression\tevaluate expression, an array, sort and columnize its value
175
+ }
172
176
  end
173
177
  end
174
178
  end
175
-
179
+
176
180
  end