byebug 8.0.1 → 8.1.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: d7ebb05ed06b0a41e17825cbe8b946f70b7778eb
4
- data.tar.gz: a0f18c28ca31209d72bb95c979fb5de138d0769d
3
+ metadata.gz: c94e35f817b35598528398f89bf25b1eb6be58cd
4
+ data.tar.gz: 835bd30d2e482817798f87c0ff6c96a1ee2ee44d
5
5
  SHA512:
6
- metadata.gz: 0f3e3edd460a1fa7748f603dc9e6e4e5993fd7ef64872f4bf46b5768c94086a60a0544fd3a76e425fcc5458e0ba650fd29c72f5c58b2827bcae9f498fdf48032
7
- data.tar.gz: 832bb3c1c505a040168ada9f6a7858b4aa00af29ab6f2040fdeb2d704ad807f71739039bd2cbe00ab4e7777b389e1539c9f3a67451df41873b4657ca8011565b
6
+ metadata.gz: f51b7abcaf7771ef033323ab1bd37c0795c5445d18b0266d29110e61f1f2d433f894d221113c793375040c3832e16f6af3a4f0fea0a55cbdb3dba285cf3658fc
7
+ data.tar.gz: fc49688e24e43f16d091c27c6e642dc1943ae0d00db65431c50f18399049a6bd29b486eac934509360fba8e60a30bcd151bd03250d93a9da9b3583724a079f31
@@ -1,3 +1,16 @@
1
+ ## Master (Unreleased)
2
+
3
+ ## 8.1.0 - 2015-11-09
4
+ ### Fixed
5
+ * Command history should be specific per project.
6
+ * Better error message in certain edge cases when printing the backtrace.
7
+ * Bug in evaluator which would show information about having stopped at a
8
+ breakpoint in some cases.
9
+
10
+ ### Added
11
+ * Ability to autolist source code after `frame` command.
12
+ * Ability to stop at lines where methods return.
13
+
1
14
  ## 8.0.1 - 2015-11-07
2
15
  ### Fixed
3
16
  * Error stream wouldn't be properly reset when using standalone `byebug`.
@@ -342,7 +342,7 @@ classname_cmp(VALUE name, VALUE klass)
342
342
  return 0;
343
343
 
344
344
  mod_name = rb_mod_name(klass);
345
- return (mod_name != Qnil && rb_str_cmp(class_name, mod_name) == 0);
345
+ return (!NIL_P(mod_name) && rb_str_cmp(class_name, mod_name) == 0);
346
346
  }
347
347
 
348
348
  static int
@@ -63,7 +63,7 @@ Raised_exception(VALUE self)
63
63
  return raised_exception;
64
64
  }
65
65
 
66
- #define IS_STARTED (catchpoints != Qnil)
66
+ #define IS_STARTED (!NIL_P(catchpoints))
67
67
 
68
68
  static void
69
69
  check_started()
@@ -149,15 +149,15 @@ cleanup(debug_context_t * dc)
149
149
  thread_context_lookup(rb_thread_current(), &context); \
150
150
  Data_Get_Struct(context, debug_context_t, dc); \
151
151
  \
152
+ trace_arg = rb_tracearg_from_tracepoint(trace_point); \
153
+ if (verbose == Qtrue) \
154
+ trace_print(trace_arg, dc, 0, 0); \
155
+ \
152
156
  if (CTX_FL_TEST(dc, CTX_FL_IGNORE)) \
153
157
  return; \
154
158
  \
155
159
  acquire_lock(dc); \
156
160
  \
157
- trace_arg = rb_tracearg_from_tracepoint(trace_point); \
158
- if (verbose == Qtrue) \
159
- trace_print(trace_arg, dc, 0, 0); \
160
-
161
161
 
162
162
  #define CALL_EVENT_SETUP \
163
163
  dc->calced_stack_size++; \
@@ -241,7 +241,7 @@ call_at_line_check(VALUE ctx, debug_context_t * dc, VALUE breakpoint)
241
241
  {
242
242
  dc->stop_reason = CTX_STOP_STEP;
243
243
 
244
- if (breakpoint != Qnil)
244
+ if (!NIL_P(breakpoint))
245
245
  call_at_breakpoint(ctx, dc, breakpoint);
246
246
 
247
247
  reset_stepping_stop_points(dc);
@@ -279,14 +279,16 @@ line_event(VALUE trace_point, void *data)
279
279
 
280
280
  if (dc->steps == 0 || dc->lines == 0)
281
281
  call_at_line_check(context, dc, Qnil);
282
+ else
283
+ {
284
+ brkpnt = Qnil;
282
285
 
283
- brkpnt = Qnil;
284
-
285
- if (!NIL_P(breakpoints))
286
- brkpnt = find_breakpoint_by_pos(breakpoints, file, line, binding);
286
+ if (!NIL_P(breakpoints))
287
+ brkpnt = find_breakpoint_by_pos(breakpoints, file, line, binding);
287
288
 
288
- if (!NIL_P(brkpnt))
289
- call_at_line_check(context, dc, brkpnt);
289
+ if (!NIL_P(brkpnt))
290
+ call_at_line_check(context, dc, brkpnt);
291
+ }
290
292
 
291
293
  EVENT_TEARDOWN;
292
294
  }
@@ -334,6 +336,8 @@ call_event(VALUE trace_point, void *data)
334
336
  static void
335
337
  return_event(VALUE trace_point, void *data)
336
338
  {
339
+ VALUE brkpnt, file, line, binding;
340
+
337
341
  EVENT_SETUP;
338
342
 
339
343
  RETURN_EVENT_SETUP;
@@ -344,6 +348,36 @@ return_event(VALUE trace_point, void *data)
344
348
 
345
349
  call_at_return(context, dc, rb_tracearg_return_value(trace_arg));
346
350
  }
351
+ else if (!NIL_P(breakpoints))
352
+ {
353
+ file = rb_tracearg_path(trace_arg);
354
+ /*
355
+ * TODO: Sometimes the TracePoint API gives some return events without
356
+ * file:line information, so we need to guard for nil until we know what's
357
+ * going on. This happens, for example, with active_support core extensions:
358
+ *
359
+ * [#7] call@.../core_ext/numeric/conversions.rb:124 Fixnum#to_s
360
+ * [#7] b_call@.../core_ext/numeric/conversions.rb:124 BigDecimal#to_s
361
+ * [#7] line@.../core_ext/numeric/conversions.rb:125 BigDecimal#to_s
362
+ * [#7] c_call@.../core_ext/numeric/conversions.rb:125 Kernel#is_a?
363
+ * [#7] c_return@.../core_ext/numeric/conversions.rb:125 Kernel#is_a?
364
+ * [#7] line@.../core_ext/numeric/conversions.rb:131 BigDecimal#to_s
365
+ * [#7] c_call@.../core_ext/numeric/conversions.rb:131 Fixnum#to_default_s
366
+ * [#7] c_return@.../core_ext/numeric/conversions.rb:131 Fixnum#to_default_s
367
+ * [#7] b_return@/hort/core_ext/numeric/conversions.rb:133 BigDecimal#to_s
368
+ * [#7] return@:0 Fixnum#to_s # => This guy...
369
+ */
370
+ if (!NIL_P(file))
371
+ {
372
+ line = rb_tracearg_lineno(trace_arg);
373
+ binding = rb_tracearg_binding(trace_arg);
374
+
375
+ brkpnt = find_breakpoint_by_pos(breakpoints, file, line, binding);
376
+
377
+ if (!NIL_P(brkpnt))
378
+ call_at_return(context, dc, rb_tracearg_return_value(trace_arg));
379
+ }
380
+ }
347
381
 
348
382
  RETURN_EVENT_TEARDOWN;
349
383
 
@@ -411,7 +445,7 @@ raise_event(VALUE trace_point, void *data)
411
445
  rb_debug_inspector_open(context_backtrace_set, (void *)new_dc);
412
446
  }
413
447
 
414
- if (catchpoints == Qnil || dc->calced_stack_size == 0
448
+ if (NIL_P(catchpoints) || dc->calced_stack_size == 0
415
449
  || RHASH_TBL(catchpoints)->num_entries == 0)
416
450
  {
417
451
  EVENT_TEARDOWN;
@@ -429,7 +463,7 @@ raise_event(VALUE trace_point, void *data)
429
463
  hit_count = rb_hash_aref(catchpoints, module_name);
430
464
 
431
465
  /* increment exception */
432
- if (hit_count != Qnil)
466
+ if (!NIL_P(hit_count))
433
467
  {
434
468
  rb_hash_aset(catchpoints, module_name, INT2FIX(FIX2INT(hit_count) + 1));
435
469
 
@@ -633,17 +667,17 @@ Stoppable(VALUE self)
633
667
  if (!IS_STARTED)
634
668
  return Qfalse;
635
669
 
636
- if (breakpoints != Qnil && rb_funcall(breakpoints, idEmpty, 0) == Qfalse)
670
+ if (!NIL_P(breakpoints) && rb_funcall(breakpoints, idEmpty, 0) == Qfalse)
637
671
  return Qfalse;
638
672
 
639
- if (catchpoints != Qnil && rb_funcall(catchpoints, idEmpty, 0) == Qfalse)
673
+ if (!NIL_P(catchpoints) && rb_funcall(catchpoints, idEmpty, 0) == Qfalse)
640
674
  return Qfalse;
641
675
 
642
676
  if (post_mortem == Qtrue)
643
677
  return Qfalse;
644
678
 
645
679
  context = Current_context(self);
646
- if (context != Qnil)
680
+ if (!NIL_P(context))
647
681
  {
648
682
  Data_Get_Struct(context, debug_context_t, dc);
649
683
 
@@ -745,6 +779,35 @@ Set_tracing(VALUE self, VALUE value)
745
779
  return value;
746
780
  }
747
781
 
782
+ /*
783
+ * call-seq:
784
+ * Byebug.verbose? -> bool
785
+ *
786
+ * Returns +true+ if global verbose flag for TracePoint API events is enabled.
787
+ */
788
+ static VALUE
789
+ Verbose(VALUE self)
790
+ {
791
+ UNUSED(self);
792
+
793
+ return verbose;
794
+ }
795
+
796
+ /*
797
+ * call-seq:
798
+ * Byebug.verbose = bool
799
+ *
800
+ * Sets the global verbose flag for TracePoint API events is enabled.
801
+ */
802
+ static VALUE
803
+ Set_verbose(VALUE self, VALUE value)
804
+ {
805
+ UNUSED(self);
806
+
807
+ verbose = RTEST(value) ? Qtrue : Qfalse;
808
+ return value;
809
+ }
810
+
748
811
  /*
749
812
  * call-seq:
750
813
  * Byebug.post_mortem? -> bool
@@ -821,6 +884,8 @@ Init_byebug()
821
884
  rb_define_module_function(mByebug, "thread_context", Thread_context, 1);
822
885
  rb_define_module_function(mByebug, "tracing?", Tracing, 0);
823
886
  rb_define_module_function(mByebug, "tracing=", Set_tracing, 1);
887
+ rb_define_module_function(mByebug, "verbose?", Verbose, 0);
888
+ rb_define_module_function(mByebug, "verbose=", Set_verbose, 1);
824
889
 
825
890
  Init_threads_table(mByebug);
826
891
  Init_context(mByebug);
@@ -164,10 +164,8 @@ release_lock(void)
164
164
  {
165
165
  remove_from_locked(next_thread);
166
166
  thread = next_thread;
167
- }
168
-
169
- if (thread == next_thread)
170
167
  next_thread = Qnil;
168
+ }
171
169
 
172
170
  if (!NIL_P(thread) && is_living_thread(thread))
173
171
  rb_thread_run(thread);
@@ -48,6 +48,8 @@ module Byebug
48
48
  return errmsg(err) unless pos
49
49
 
50
50
  switch_to_frame(pos)
51
+
52
+ ListCommand.new(processor).execute if Setting[:autolist]
51
53
  end
52
54
  end
53
55
  end
@@ -161,10 +161,13 @@ module Byebug
161
161
  end
162
162
 
163
163
  def ruby_args
164
- return [] unless _binding.eval('__method__')
165
- return [] unless _binding.eval('method(__method__)')
164
+ meth_name = _binding.eval('__method__')
165
+ return [] unless meth_name
166
166
 
167
- _binding.eval('method(__method__).parameters')
167
+ meth_obj = _self.method(meth_name)
168
+ return [] unless meth_obj
169
+
170
+ meth_obj.parameters
168
171
  end
169
172
 
170
173
  def use_short_style?(arg)
@@ -49,7 +49,7 @@ module Byebug
49
49
  private
50
50
 
51
51
  def safe_eval(str, binding)
52
- binding.eval(str)
52
+ binding.eval(str, '(byebug)', 1)
53
53
  rescue StandardError, ScriptError => e
54
54
  yield(e)
55
55
  end
@@ -54,7 +54,7 @@ module Byebug
54
54
  # True for special files like -e, false otherwise
55
55
  #
56
56
  def virtual_file?(name)
57
- ['(irb)', '-e'].include?(name)
57
+ ['(irb)', '-e', '(byebug)'].include?(name)
58
58
  end
59
59
  end
60
60
  end
@@ -8,13 +8,34 @@ module Byebug
8
8
  @bin_file ||= Gem.bin_path('byebug', 'byebug')
9
9
  end
10
10
 
11
+ def root_path
12
+ @root_path ||= File.expand_path('../..', bin_file)
13
+ end
14
+
11
15
  def lib_files
12
- @lib_files ||= Dir.glob(File.expand_path('../../../**/*.rb', __FILE__))
16
+ @lib_files ||= expand_from_root('lib/**/*.{rb,yml}')
17
+ end
18
+
19
+ def ext_files
20
+ @ext_files ||= expand_from_root('ext/**/*.{c,h,rb}')
21
+ end
22
+
23
+ def test_files
24
+ @test_files ||= expand_from_root('test/**/*.rb')
25
+ end
26
+
27
+ def gem_files
28
+ @gem_files ||= [bin_file] + lib_files + ext_files
13
29
  end
14
30
 
15
31
  def all_files
16
- @all_files ||=
17
- Dir.glob(File.expand_path('../../../../**/*.rb', __FILE__))
32
+ @all_files ||= gem_files + test_files
33
+ end
34
+
35
+ private
36
+
37
+ def expand_from_root(glob)
38
+ Dir.glob(File.expand_path(glob, root_path))
18
39
  end
19
40
  end
20
41
  end
@@ -5,10 +5,10 @@ module Byebug
5
5
  # Setting to customize the file where byebug's history is saved.
6
6
  #
7
7
  class HistfileSetting < Setting
8
- DEFAULT = File.expand_path("#{ENV['HOME'] || '.'}/.byebug_hist")
8
+ DEFAULT = File.expand_path('.byebug_history')
9
9
 
10
10
  def banner
11
- 'File where cmd history is saved to. Default: ~/.byebug_hist'
11
+ 'File where cmd history is saved to. Default: ./.byebug_history'
12
12
  end
13
13
 
14
14
  def to_s
@@ -2,5 +2,5 @@
2
2
  # Reopen main module to define the library version
3
3
  #
4
4
  module Byebug
5
- VERSION = '8.0.1'
5
+ VERSION = '8.1.0'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: byebug
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.1
4
+ version: 8.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rodriguez
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-11-07 00:00:00.000000000 Z
13
+ date: 2015-11-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
188
  version: '0'
189
189
  requirements: []
190
190
  rubyforge_project:
191
- rubygems_version: 2.5.0
191
+ rubygems_version: 2.4.5.1
192
192
  signing_key:
193
193
  specification_version: 4
194
194
  summary: Ruby 2.0 fast debugger - base + CLI