byebug 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/GUIDE.md +2 -2
  4. data/LICENSE +3 -3
  5. data/README.md +5 -4
  6. data/byebug.gemspec +1 -1
  7. data/ext/byebug/byebug.c +20 -19
  8. data/lib/byebug.rb +2 -53
  9. data/lib/byebug/command.rb +9 -109
  10. data/lib/byebug/commands/breakpoints.rb +1 -1
  11. data/lib/byebug/commands/control.rb +20 -21
  12. data/lib/byebug/commands/display.rb +2 -3
  13. data/lib/byebug/commands/eval.rb +6 -16
  14. data/lib/byebug/commands/finish.rb +1 -1
  15. data/lib/byebug/commands/frame.rb +9 -9
  16. data/lib/byebug/commands/help.rb +2 -3
  17. data/lib/byebug/commands/history.rb +28 -0
  18. data/lib/byebug/commands/info.rb +3 -3
  19. data/lib/byebug/commands/list.rb +2 -13
  20. data/lib/byebug/commands/method.rb +5 -45
  21. data/lib/byebug/commands/reload.rb +1 -12
  22. data/lib/byebug/commands/repl.rb +6 -15
  23. data/lib/byebug/commands/save.rb +2 -7
  24. data/lib/byebug/commands/set.rb +45 -116
  25. data/lib/byebug/commands/show.rb +22 -126
  26. data/lib/byebug/commands/stepping.rb +1 -1
  27. data/lib/byebug/commands/trace.rb +14 -25
  28. data/lib/byebug/commands/variables.rb +3 -41
  29. data/lib/byebug/helper.rb +11 -42
  30. data/lib/byebug/history.rb +5 -13
  31. data/lib/byebug/processors/command_processor.rb +6 -6
  32. data/lib/byebug/setting.rb +82 -0
  33. data/lib/byebug/settings/autoeval.rb +20 -0
  34. data/lib/byebug/settings/autoirb.rb +19 -0
  35. data/lib/byebug/settings/autolist.rb +19 -0
  36. data/lib/byebug/settings/autoreload.rb +11 -0
  37. data/lib/byebug/settings/autosave.rb +11 -0
  38. data/lib/byebug/settings/basename.rb +7 -0
  39. data/lib/byebug/settings/callstyle.rb +15 -0
  40. data/lib/byebug/settings/forcestep.rb +11 -0
  41. data/lib/byebug/settings/fullpath.rb +11 -0
  42. data/lib/byebug/settings/histfile.rb +16 -0
  43. data/lib/byebug/settings/histsize.rb +18 -0
  44. data/lib/byebug/settings/linetrace.rb +15 -0
  45. data/lib/byebug/settings/listsize.rb +15 -0
  46. data/lib/byebug/settings/post_mortem.rb +15 -0
  47. data/lib/byebug/settings/stack_on_error.rb +7 -0
  48. data/lib/byebug/settings/testing.rb +7 -0
  49. data/lib/byebug/settings/tracing_plus.rb +7 -0
  50. data/lib/byebug/settings/verbose.rb +7 -0
  51. data/lib/byebug/settings/width.rb +29 -0
  52. data/lib/byebug/version.rb +1 -1
  53. data/test/breakpoints_test.rb +345 -324
  54. data/test/conditions_test.rb +61 -48
  55. data/test/continue_test.rb +38 -27
  56. data/test/debugger_alias_test.rb +5 -3
  57. data/test/display_test.rb +103 -92
  58. data/test/edit_test.rb +42 -34
  59. data/test/eval_test.rb +91 -75
  60. data/test/finish_test.rb +51 -40
  61. data/test/frame_test.rb +197 -184
  62. data/test/help_test.rb +47 -38
  63. data/test/history_test.rb +54 -0
  64. data/test/info_test.rb +306 -293
  65. data/test/interrupt_test.rb +44 -38
  66. data/test/kill_test.rb +40 -31
  67. data/test/list_test.rb +166 -133
  68. data/test/method_test.rb +67 -60
  69. data/test/post_mortem_test.rb +56 -48
  70. data/test/quit_test.rb +44 -35
  71. data/test/reload_test.rb +36 -24
  72. data/test/repl_test.rb +57 -47
  73. data/test/restart_test.rb +56 -69
  74. data/test/save_test.rb +62 -53
  75. data/test/set_test.rb +140 -118
  76. data/test/show_test.rb +68 -201
  77. data/test/source_test.rb +39 -29
  78. data/test/stepping_test.rb +163 -136
  79. data/test/support/test_dsl.rb +9 -11
  80. data/test/test_helper.rb +2 -7
  81. data/test/thread_test.rb +121 -107
  82. data/test/trace_test.rb +86 -83
  83. data/test/variables_test.rb +104 -98
  84. metadata +27 -86
  85. data/test/examples/breakpoint.rb +0 -6
  86. data/test/examples/breakpoint_deep.rb +0 -4
  87. data/test/examples/conditions.rb +0 -4
  88. data/test/examples/continue.rb +0 -5
  89. data/test/examples/display.rb +0 -5
  90. data/test/examples/edit.rb +0 -4
  91. data/test/examples/eval.rb +0 -4
  92. data/test/examples/finish.rb +0 -3
  93. data/test/examples/frame.rb +0 -4
  94. data/test/examples/frame_deep.rb +0 -1
  95. data/test/examples/gcd.rb +0 -15
  96. data/test/examples/hanoi.rb +0 -34
  97. data/test/examples/help.rb +0 -1
  98. data/test/examples/info.rb +0 -6
  99. data/test/examples/info2.rb +0 -3
  100. data/test/examples/interrupt.rb +0 -8
  101. data/test/examples/kill.rb +0 -2
  102. data/test/examples/list.rb +0 -23
  103. data/test/examples/method.rb +0 -4
  104. data/test/examples/post_mortem.rb +0 -4
  105. data/test/examples/primes.rb +0 -25
  106. data/test/examples/quit.rb +0 -2
  107. data/test/examples/reload.rb +0 -6
  108. data/test/examples/repl.rb +0 -6
  109. data/test/examples/restart.rb +0 -6
  110. data/test/examples/save.rb +0 -3
  111. data/test/examples/set.rb +0 -3
  112. data/test/examples/settings.rb +0 -1
  113. data/test/examples/show.rb +0 -1
  114. data/test/examples/source.rb +0 -3
  115. data/test/examples/stepping.rb +0 -8
  116. data/test/examples/stepping_raise_from_c_method.rb +0 -3
  117. data/test/examples/stepping_raise_from_ruby_method.rb +0 -3
  118. data/test/examples/test-triangle.rb +0 -14
  119. data/test/examples/thread.rb +0 -5
  120. data/test/examples/tmate.rb +0 -10
  121. data/test/examples/trace.rb +0 -8
  122. data/test/examples/tri3.rb +0 -6
  123. data/test/examples/triangle.rb +0 -13
  124. data/test/examples/variables.rb +0 -4
  125. data/test/timeout_test.rb +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aefd49bb6a9a42bed03f3bfd3e5c05b260460e16
4
- data.tar.gz: 2123202331fe1df741b263453e287273383aeb3f
3
+ metadata.gz: 07f6616707d3f841c7c580f1f5e04ef9534a801d
4
+ data.tar.gz: e443182d786d0a652fa2166257727e3fb6298431
5
5
  SHA512:
6
- metadata.gz: 27cb2714d6b8d457aed200e9c5beabaad6d94912e4ecc78c2bbdd3e809d8dce76834d49fdb02fbd89814c3e9bdeb01df5c9346ec777f5a9f4ca3f1fbab94b908
7
- data.tar.gz: 72a02e12800f4b7b39d8b6f6b54615046ca80b7a774109ef60c5f18cfc4a959785a804f5ab204e926d984d7421c2c7f430f56a6f273c45ed1643a76627ea9398
6
+ metadata.gz: 6ef519a0d284a6e4b2b7524569d2e164258e9105850366dc73938e1fbf0602ecd008f3d5f67f799529009d7de1bdd0f3389908dc979edaa8184631336ea20333
7
+ data.tar.gz: 9f305fd5c78c3a7c8b29ef7e302acc230686986c44a72d3f5e903d4ab4f4df2f99d032bceb67ae00e5ae04302dbbecce92bc86a421549a45346355ff04c7755a
@@ -1,3 +1,18 @@
1
+ # 3.1.0
2
+
3
+ * `show commands` moved to a separate `history` command.
4
+ * Byebug.start can't recieve options any more. Any program settings you
5
+ want applied from the start should be set in .byebugrc.
6
+ * `trace` command has been removed. Line tracing functionality should be
7
+ enabled through the `linetrace` setting whereas the global variable
8
+ tracing functionality is now provided through the `tracevar` command.
9
+ * `version` setting has been removed. It was not really a setting because it
10
+ couldn't be set. Use `byebug --version` to check byebug's version.
11
+ * `arg` setting removed. Program restart arguments should be set through
12
+ `restart` command from now on.
13
+ * `linetrace_plus` setting has been renamed to `tracing_plus`.
14
+
15
+
1
16
  # 3.0.0
2
17
 
3
18
  - Bugfixes
data/GUIDE.md CHANGED
@@ -104,7 +104,7 @@ to be displayed when tracing, we can turn on _basename_.
104
104
  ```
105
105
  (byebug) display i
106
106
  2: i =
107
- (byebug) set linetrace on
107
+ (byebug) set tracing on
108
108
  line tracing is on.
109
109
  (byebug) set basename on
110
110
  basename is on.
@@ -638,7 +638,7 @@ $ byebug primes.rb
638
638
  8: candidate += 1
639
639
  9: while true do
640
640
  10: @@odd_primes.each do |p|
641
- (byebug) set linetrace
641
+ (byebug) set tracing
642
642
  line tracing is on.
643
643
  (byebug) set basename
644
644
  basename in on.
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- Copyright (C) 2013 David Rodríguez <deivid.rodriguez@gmail.com>
1
+ Copyright (C) 2014 David Rodríguez <deivid.rodriguez@gmail.com>
2
2
  All rights reserved.
3
- *
3
+
4
4
  Redistribution and use in source and binary forms, with or without
5
5
  modification, are permitted provided that the following conditions
6
6
  are met:
@@ -9,7 +9,7 @@ are met:
9
9
  2. Redistributions in binary form must reproduce the above copyright
10
10
  notice, this list of conditions and the following disclaimer in the
11
11
  documentation and/or other materials provided with the distribution.
12
- *
12
+
13
13
  THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
14
14
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
15
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
data/README.md CHANGED
@@ -82,6 +82,7 @@ can now be placed at the end of a block or method call.
82
82
  `finish` | |
83
83
  `frame` | |
84
84
  `help` | |
85
+ `history` | |
85
86
  `info` | | `args` `breakpoints` `catch` `display` `file` `files` `global_variables` `instance_variables` `line` `locals` `program` `stack` `variables`
86
87
  `irb` | |
87
88
  `kill` | |
@@ -97,16 +98,16 @@ can now be placed at the end of a block or method call.
97
98
  `reload` | |
98
99
  `restart` | |
99
100
  `save` | |
100
- `set` | | `args` `autoeval` `autoirb` `autolist` `autoreload` `autosave` `basename` `callstyle` `callstyle` `forcestep` `fullpath` `histfile` `histsize` `linetrace` `linetrace_plus` `listsize` `post_mortem` `stack_on_error` `testing` `verbose` `width`
101
- `show` | | `args` `autoeval` `autoirb` `autolist` `autoreload` `autosave` `basename` `callstyle` `callstyle` `commands` `forcestep` `fullpath` `histfile` `histsize` `linetrace` `linetrace_plus` `listsize` `post_mortem` `stack_on_error` `verbose` `width`
101
+ `set` | | `autoeval` `autoirb` `autolist` `autoreload` `autosave` `basename` `callstyle` `forcestep` `fullpath` `histfile` `histsize` `linetrace` `tracing_plus` `listsize` `post_mortem` `stack_on_error` `testing` `verbose` `width`
102
+ `show` | | `autoeval` `autoirb` `autolist` `autoreload` `autosave` `basename` `callstyle` `forcestep` `fullpath` `histfile` `histsize` `linetrace` `tracing_plus` `listsize` `post_mortem` `stack_on_error` `testing` `verbose` `width`
102
103
  `skip` | |
103
104
  `source` | |
104
105
  `step` | |
105
106
  `thread` | | `current` `list` `resume` `stop` `switch`
106
- `trace` | |
107
+ `tracevar` | |
107
108
  `undisplay` | |
108
109
  `up` | |
109
- `var` | | `class` `constant` `global` `instance` `local` `ct`
110
+ `var` | | `class` `constant` `global` `instance` `local`
110
111
 
111
112
 
112
113
  ## Semantic Versioning
@@ -23,6 +23,6 @@ Gem::Specification.new do |s|
23
23
  s.extra_rdoc_files = ['README.md']
24
24
  s.extensions = ['ext/byebug/extconf.rb']
25
25
 
26
- s.add_dependency 'columnize', '~> 0.3'
26
+ s.add_dependency 'columnize', '~> 0.8'
27
27
  s.add_dependency 'debugger-linecache', '~> 1.2'
28
28
  end
@@ -35,14 +35,15 @@ trace_print(rb_trace_arg_t *trace_arg, debug_context_t *dc)
35
35
  if (trace_arg)
36
36
  {
37
37
  int i = 0;
38
- VALUE path = rb_tracearg_path(trace_arg);
39
- VALUE line = rb_tracearg_lineno(trace_arg);
40
- VALUE event = rb_tracearg_event(trace_arg);
41
- VALUE mid = rb_tracearg_method_id(trace_arg);
42
- for (i=0; i<dc->calced_stack_size; i++) putc('|', stderr);
43
- fprintf(stderr, "[#%d] %s@%s:%d %s\n", dc->thnum,
44
- rb_id2name(SYM2ID(event)), RSTRING_PTR(path), NUM2INT(line),
45
- NIL_P(mid) ? "" : rb_id2name(SYM2ID(mid)));
38
+ const char *event = rb_id2name(SYM2ID(rb_tracearg_event(trace_arg)));
39
+ char *path = RSTRING_PTR(rb_tracearg_path(trace_arg));
40
+ int line = NUM2INT(rb_tracearg_lineno(trace_arg));
41
+ VALUE v_mid = rb_tracearg_method_id(trace_arg);
42
+ const char *mid = NIL_P(v_mid) ? "" : rb_id2name(SYM2ID(v_mid));
43
+
44
+ for (i = 0; i < dc->calced_stack_size; i++) putc('-', stdout);
45
+ printf("(%d)->[#%d] %s@%s:%d %s\n",
46
+ dc->calced_stack_size, dc->thnum, event, path, line, mid);
46
47
  }
47
48
  }
48
49
 
@@ -543,17 +544,17 @@ bb_stop(VALUE self)
543
544
 
544
545
  /*
545
546
  * call-seq:
546
- * Byebug.start_ -> bool
547
- * Byebug.start_ { ... } -> bool
547
+ * Byebug.start -> bool
548
+ * Byebug.start { ... } -> bool
548
549
  *
549
- * This method is internal and activates the debugger. Use Byebug.start (from
550
- * <tt>lib/byebug.rb</tt>) instead.
550
+ * If a block is given, it starts byebug and yields block. After the block is
551
+ * executed it stops byebug with Byebug.stop method. Inside the block you
552
+ * will probably want to have a call to Byebug.byebug. For example:
553
+ *
554
+ * Byebug.start { byebug; foo } # Stop inside of foo
551
555
  *
552
556
  * The return value is the value of !Byebug.started? <i>before</i> issuing the
553
557
  * +start+; That is, +true+ is returned, unless byebug was previously started.
554
- *
555
- * If a block is given, it starts byebug and yields to block. When the block
556
- * is finished executing it stops the debugger with Byebug.stop method.
557
558
  */
558
559
  static VALUE
559
560
  bb_start(VALUE self)
@@ -624,7 +625,7 @@ bb_load(int argc, VALUE *argv, VALUE self)
624
625
 
625
626
  /*
626
627
  * call-seq:
627
- * Byebug.verbose -> bool
628
+ * Byebug.verbose? -> bool
628
629
  *
629
630
  * Returns +true+ if verbose output of TracePoint API events is enabled.
630
631
  */
@@ -650,7 +651,7 @@ bb_set_verbose(VALUE self, VALUE value)
650
651
 
651
652
  /*
652
653
  * call-seq:
653
- * Byebug.tracing -> bool
654
+ * Byebug.tracing? -> bool
654
655
  *
655
656
  * Returns +true+ if global tracing is enabled.
656
657
  */
@@ -772,13 +773,13 @@ Init_byebug()
772
773
  rb_define_module_function(mByebug, "post_mortem?" , bb_post_mortem , 0);
773
774
  rb_define_module_function(mByebug, "post_mortem=" , bb_set_post_mortem , 1);
774
775
  rb_define_module_function(mByebug, "raised_exception" , bb_raised_exception, 0);
775
- rb_define_module_function(mByebug, "_start" , bb_start , 0);
776
+ rb_define_module_function(mByebug, "start" , bb_start , 0);
776
777
  rb_define_module_function(mByebug, "started?" , bb_started , 0);
777
778
  rb_define_module_function(mByebug, "stop" , bb_stop , 0);
778
779
  rb_define_module_function(mByebug, "thread_context" , bb_thread_context , 1);
779
780
  rb_define_module_function(mByebug, "tracing?" , bb_tracing , 0);
780
781
  rb_define_module_function(mByebug, "tracing=" , bb_set_tracing , 1);
781
- rb_define_module_function(mByebug, "verbose" , bb_verbose , 0);
782
+ rb_define_module_function(mByebug, "verbose?" , bb_verbose , 0);
782
783
  rb_define_module_function(mByebug, "verbose=" , bb_set_verbose , 1);
783
784
 
784
785
  cThreadsTable = rb_define_class_under(mByebug, "ThreadsTable", rb_cObject);
@@ -3,6 +3,7 @@ require 'byebug/version'
3
3
  require 'byebug/context'
4
4
  require 'byebug/interface'
5
5
  require 'byebug/processor'
6
+ require 'byebug/setting'
6
7
  require 'byebug/remote'
7
8
  require 'stringio'
8
9
  require 'tracer'
@@ -13,18 +14,10 @@ module Byebug
13
14
  # List of files byebug will ignore while debugging
14
15
  IGNORED_FILES = Dir.glob(File.expand_path('../**/*.rb', __FILE__))
15
16
 
16
- # Default options to Byebug.start
17
- unless defined?(DEFAULT_START_SETTINGS)
18
- DEFAULT_START_SETTINGS = { post_mortem: false,
19
- tracing: false,
20
- save_history: true }
21
- end
22
-
23
17
  # Configuration file used for startup commands. Default value is .byebugrc
24
18
  INITFILE = '.byebugrc' unless defined?(INITFILE)
25
19
 
26
20
  # Original ARGV, command line and initial directory to make restarts possible
27
- ARGV = ARGV.clone unless defined?(ARGV)
28
21
  PROG_SCRIPT = $0 unless defined?(PROG_SCRIPT)
29
22
  INITIAL_DIR = Dir.pwd unless defined?(INITIAL_DIR)
30
23
 
@@ -83,46 +76,6 @@ module Byebug
83
76
  extend Forwardable
84
77
  def_delegators :"handler.interface", :print
85
78
 
86
- #
87
- # Byebug.start(options) -> bool
88
- # Byebug.start(options) { ... } -> obj
89
- #
90
- # If it's called without a block, it returns +true+ unless byebug was
91
- # already started.
92
- #
93
- # If a block is given, it starts byebug and yields block. After the block is
94
- # executed it stops byebug with Byebug.stop method. Inside the block you
95
- # will probably want to have a call to Byebug.byebug. For example:
96
- #
97
- # Byebug.start { byebug; foo } # Stop inside of foo
98
- #
99
- # Also, byebug only allows one invocation of byebug at a time; nested
100
- # Byebug.start's have no effect and you can't use this inside byebug itself.
101
- #
102
- # <i>Note that if you want to stop byebug, you must call Byebug.stop as
103
- # many times as you called Byebug.start method.</i>
104
- #
105
- # +options+ is a hash used to set various debugging options.
106
- # :post_mortem - true if you want to enter post-mortem debugging on an
107
- # uncaught exception, false otherwise. Default: false.
108
- # :tracing - true if line tracing should be enabled, false otherwise.
109
- # Default: false.
110
- # :save_history - true if byebug's command history should be saved to a
111
- # file on program termination so that it can be reloaded
112
- # later.
113
- #
114
- def start(options={}, &block)
115
- options = Byebug::DEFAULT_START_SETTINGS.merge(options)
116
- Byebug.tracing = options[:tracing]
117
-
118
- retval = Byebug._start(&block)
119
-
120
- post_mortem if options[:post_mortem]
121
- at_exit { Byebug::History.save } if options[:save_history]
122
-
123
- return retval
124
- end
125
-
126
79
  #
127
80
  # Runs normal byebug initialization scripts.
128
81
  #
@@ -168,11 +121,7 @@ module Byebug
168
121
  context = raised_exception.__bb_context
169
122
  file = raised_exception.__bb_file
170
123
  line = raised_exception.__bb_line
171
- orig_tracing = Byebug.tracing?
172
- Byebug.tracing = false
173
124
  handler.at_line(context, file, line)
174
- ensure
175
- Byebug.tracing = orig_tracing
176
125
  end
177
126
  private :handle_post_mortem
178
127
  end
@@ -188,8 +137,8 @@ module Kernel
188
137
  # events occur. Before entering byebug the init script is read.
189
138
  #
190
139
  def byebug(steps_out = 1, before = true)
191
- Byebug.start
192
140
  Byebug.run_init_script(StringIO.new)
141
+ Byebug.start
193
142
  Byebug.current_context.step_out(steps_out, before)
194
143
  end
195
144
 
@@ -3,26 +3,10 @@ require 'forwardable'
3
3
  require 'byebug/helper'
4
4
 
5
5
  module Byebug
6
-
7
- module CommandFunctions
8
- #
9
- # Pad a string with dots at the end to fit :width setting
10
- #
11
- def pad_with_dots(string)
12
- if string.size > Command.settings[:width]
13
- string[Command.settings[:width]-3 .. -1] = "..."
14
- end
15
- end
16
- end
17
-
18
6
  class Command
19
7
  Subcmd = Struct.new(:name, :min, :help)
20
8
 
21
9
  class << self
22
- def commands
23
- @commands ||= []
24
- end
25
-
26
10
  attr_accessor :allow_in_control, :unknown
27
11
  attr_writer :allow_in_post_mortem, :always_run
28
12
 
@@ -76,87 +60,25 @@ module Byebug
76
60
  return s
77
61
  end
78
62
 
63
+ def commands
64
+ @commands ||= []
65
+ end
66
+
79
67
  def inherited(klass)
80
68
  commands << klass
81
69
  end
82
70
 
83
71
  def load_commands
84
- Dir[File.join(File.dirname(__FILE__), 'commands', '*')].each {
85
- |file| require file }
86
- Byebug.constants.grep(/Functions$/).map {
87
- |name| Byebug.const_get(name) }.each { |mod| include mod }
88
- end
89
-
90
- def settings_map
91
- @@settings_map ||= {}
92
- end
93
- private :settings_map
94
-
95
- def settings
96
- unless defined? @settings and @settings
97
- @settings = Object.new
98
- map = settings_map
99
- c = class << @settings; self end
100
- c.send(:define_method, :[]) do |name|
101
- raise "No such setting #{name}" unless map.has_key?(name)
102
- map[name][:getter].call
103
- end
104
- c.send(:define_method, :[]=) do |name, value|
105
- raise "No such setting #{name}" unless map.has_key?(name)
106
- map[name][:setter].call(value)
107
- end
72
+ Dir.glob(File.expand_path('../commands/*.rb', __FILE__)).each do |file|
73
+ require file
108
74
  end
109
- @settings
110
- end
111
75
 
112
- def register_setting_var(name, default)
113
- var_name = "@@#{name}"
114
- class_variable_set(var_name, default)
115
- register_setting_get(name) { class_variable_get(var_name) }
116
- register_setting_set(name) { |value| class_variable_set(var_name, value) }
117
- end
118
-
119
- def register_setting_get(name, &block)
120
- settings_map[name] ||= {}
121
- settings_map[name][:getter] = block
122
- end
123
-
124
- def register_setting_set(name, &block)
125
- settings_map[name] ||= {}
126
- settings_map[name][:setter] = block
127
- end
128
-
129
- def command_exists?(command)
130
- ENV['PATH'].split(File::PATH_SEPARATOR).any? {
131
- |d| File.exist? File.join(d, command) }
132
- end
133
-
134
- def terminal_width
135
- if ENV['COLUMNS'] =~ /^\d+$/
136
- ENV['COLUMNS'].to_i
137
- elsif STDIN.tty? && command_exists?('stty')
138
- `stty size`.scan(/\d+/)[1].to_i
139
- else
140
- nil
141
- end
76
+ Byebug.constants.grep(/Functions$/).map {
77
+ |name| Byebug.const_get(name)
78
+ }.each { |mod| include mod }
142
79
  end
143
80
  end
144
81
 
145
- # Register default settings
146
- register_setting_var(:autosave, true)
147
- register_setting_var(:basename, false)
148
- register_setting_var(:callstyle, :long)
149
- register_setting_var(:testing, false)
150
- register_setting_var(:forcestep, false)
151
- register_setting_var(:fullpath, true)
152
- register_setting_var(:listsize, 10)
153
- register_setting_var(:stack_on_error, false)
154
- register_setting_var(:linetrace_plus, false)
155
- cols = terminal_width || 160
156
- register_setting_var(:width, cols > 10 ? cols : 160)
157
- Byebug::ARGV = ARGV.clone unless defined? Byebug::ARGV
158
- register_setting_var(:argv, Byebug::ARGV)
159
-
160
82
  def initialize(state)
161
83
  @match, @state = nil, state
162
84
  end
@@ -206,26 +128,4 @@ module Byebug
206
128
  end
207
129
 
208
130
  Command.load_commands
209
-
210
- ##
211
- # Returns ths settings object.
212
- # Use Byebug.settings[] and Byebug.settings[]= methods to query and set
213
- # byebug settings. These settings are available:
214
- #
215
- # :autoeval - evaluates input in the current binding if it's not
216
- # recognized as a byebug command
217
- # :autoirb - automatically calls 'irb' command on breakpoint
218
- # :autolist - automatically calls 'list' command on breakpoint
219
- # :autoreload - makes 'list' command always display up-to-date source
220
- # code
221
- # :autosave - automatic saving of command history on exit
222
- # :frame_class_names - displays method's class name when showing frame stack
223
- # :forcestep - stepping command always move to the new line
224
- # :fullpath - displays full paths when showing frame stack
225
- # :stack_on_error - shows full stack trace if eval command results in an
226
- # exception
227
- #
228
- def self.settings
229
- Command.settings
230
- end
231
131
  end
@@ -54,7 +54,7 @@ module Byebug
54
54
 
55
55
  if line =~ /^\d+$/
56
56
  line = line.to_i
57
- if LineCache.cache(brkpt_filename, Command.settings[:autoreload])
57
+ if LineCache.cache(brkpt_filename, Setting[:autoreload])
58
58
  last_line = LineCache.size(brkpt_filename)
59
59
  return errmsg "There are only #{last_line} lines in file " \
60
60
  "#{brkpt_filename}\n" if line > last_line
@@ -1,30 +1,31 @@
1
1
  module Byebug
2
-
3
2
  class RestartCommand < Command
4
3
  self.allow_in_control = true
5
4
 
6
5
  def regexp
7
- /^\s* (?:restart|R) (?:\s+(.+))? \s*$/x
6
+ /^\s* (?:restart|R) (?:\s+(?<args>.+))? \s*$/x
8
7
  end
9
8
 
10
9
  def execute
11
- return errmsg "Don't know name of debugged program\n" unless
12
- defined? Byebug::PROG_SCRIPT
10
+ prog = Byebug::PROG_SCRIPT if defined?(Byebug::PROG_SCRIPT)
11
+ byebug_script = Byebug::BYEBUG_SCRIPT if defined?(Byebug::BYEBUG_SCRIPT)
12
+
13
+ return errmsg "Don't know name of debugged program\n" unless prog
13
14
 
14
- return errmsg "Ruby program #{Byebug::PROG_SCRIPT} doesn't exist\n" unless
15
- File.exist?(File.expand_path(Byebug::PROG_SCRIPT))
15
+ unless File.exist?(File.expand_path(prog))
16
+ return errmsg "Ruby program #{prog} doesn't exist\n"
17
+ end
16
18
 
17
- if not defined? Byebug::BYEBUG_SCRIPT
19
+ if byebug_script
20
+ cmd = "#{byebug_script} #{prog}"
21
+ else
18
22
  print "Byebug was not called from the outset...\n"
19
- if not File.executable?(Byebug::PROG_SCRIPT)
20
- print "Ruby program #{Byebug::PROG_SCRIPT} not executable... " \
21
- "We'll add a call to Ruby.\n"
22
- cmd = "ruby -rbyebug -I#{$:.join(' -I')} #{Byebug::PROG_SCRIPT}"
23
+ if File.executable?(prog)
24
+ cmd = prog
23
25
  else
24
- cmd = Byebug::PROG_SCRIPT
26
+ print "Ruby program #{prog} not executable... We'll wrap it in a ruby call\n"
27
+ cmd = "ruby -rbyebug -I#{$:.join(' -I')} #{prog}"
25
28
  end
26
- else
27
- cmd = "#{Byebug::BYEBUG_SCRIPT} #{Byebug::PROG_SCRIPT}"
28
29
  end
29
30
 
30
31
  begin
@@ -33,13 +34,11 @@ module Byebug
33
34
  print "Failed to change initial directory #{Byebug::INITIAL_DIR}"
34
35
  end
35
36
 
36
- if @match[1]
37
- cmd += " #{@match[1]}"
38
- elsif not defined? Command.settings[:argv]
39
- return errmsg "Arguments not set. Use 'set args' to set them.\n"
37
+ if @match[:args]
38
+ cmd += " #{@match[:args]}"
40
39
  else
41
40
  require 'shellwords'
42
- cmd += " #{Command.settings[:argv].compact.shelljoin}"
41
+ cmd += " #{ARGV.compact.shelljoin}"
43
42
  end
44
43
 
45
44
  # An execv would be preferable to the "exec" below.
@@ -72,8 +71,8 @@ module Byebug
72
71
  end
73
72
 
74
73
  def execute
75
- context = Byebug.thread_context(Thread.main)
76
- context.interrupt
74
+ context = Byebug.thread_context(Thread.main)
75
+ context.interrupt
77
76
  end
78
77
 
79
78
  class << self