byebug 2.3.1 → 2.4.0
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 +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +3 -11
- data/Rakefile +10 -3
- data/bin/byebug +16 -2
- data/byebug.gemspec +1 -0
- data/ext/byebug/byebug.c +0 -54
- data/ext/byebug/byebug.h +3 -4
- data/ext/byebug/extconf.rb +1 -1
- data/lib/byebug.rb +15 -42
- data/lib/byebug/command.rb +12 -28
- data/lib/byebug/commands/breakpoints.rb +2 -0
- data/lib/byebug/commands/catchpoint.rb +1 -1
- data/lib/byebug/commands/condition.rb +1 -0
- data/lib/byebug/commands/display.rb +6 -0
- data/lib/byebug/commands/frame.rb +10 -3
- data/lib/byebug/commands/info.rb +5 -3
- data/lib/byebug/commands/reload.rb +1 -0
- data/lib/byebug/commands/set.rb +5 -1
- data/lib/byebug/commands/threads.rb +5 -4
- data/lib/byebug/commands/trace.rb +5 -5
- data/lib/byebug/context.rb +3 -3
- data/lib/byebug/interface.rb +3 -187
- data/lib/byebug/interfaces/local_interface.rb +88 -0
- data/lib/byebug/interfaces/remote_interface.rb +55 -0
- data/lib/byebug/interfaces/script_interface.rb +45 -0
- data/lib/byebug/processor.rb +15 -13
- data/lib/byebug/version.rb +1 -1
- data/test/breakpoints_test.rb +23 -25
- data/test/conditions_test.rb +6 -8
- data/test/continue_test.rb +4 -6
- data/test/debugger_alias_test.rb +5 -0
- data/test/display_test.rb +9 -11
- data/test/edit_test.rb +0 -2
- data/test/eval_test.rb +1 -3
- data/test/finish_test.rb +12 -12
- data/test/frame_test.rb +38 -40
- data/test/help_test.rb +1 -3
- data/test/info_test.rb +12 -14
- data/test/kill_test.rb +0 -2
- data/test/list_test.rb +1 -3
- data/test/method_test.rb +0 -2
- data/test/post_mortem_test.rb +77 -96
- data/test/quit_test.rb +0 -2
- data/test/reload_test.rb +0 -2
- data/test/repl_test.rb +3 -5
- data/test/restart_test.rb +0 -2
- data/test/save_test.rb +1 -3
- data/test/set_test.rb +3 -5
- data/test/show_test.rb +0 -2
- data/test/source_test.rb +0 -2
- data/test/stepping_test.rb +17 -19
- data/test/support/test_dsl.rb +21 -13
- data/test/test_helper.rb +23 -1
- data/test/thread_test.rb +19 -21
- data/test/trace_test.rb +12 -14
- data/test/variables_test.rb +6 -6
- metadata +22 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a40151455c8ac55d4a9ef4c78744ab3b84aa31c
|
4
|
+
data.tar.gz: c29114c8ea62f89f2e323d734fc75d2e611f7cb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8aba52de48ca4f73cb7f433a9a2b3c602d3fb345ccc32bdfc1ff9ebe5353f414c354f53d6490d0f13c852ff9837128285a1b876f80104abbec0ed6eff3b52465
|
7
|
+
data.tar.gz: 89d9717c9be932067b9405b5e2dd51f7d08a5e7857887b010206256cacffdd7663b3da1c90badafe903b87a5ccaa759534b21b7eae90182ac2e7d0c9ca7d05d5
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
# 2.4.0
|
2
|
+
|
3
|
+
* Use `require` instead of `require_relative` for loading byebug's extension
|
4
|
+
library (thanks @nobu)
|
5
|
+
* Adds back `debugger` as an alias to `byebug` (thanks @wallace)
|
6
|
+
* Adds -R option to byebug's binary to specify server's hostname:port for remote
|
7
|
+
debugging (thanks @mrkn)
|
8
|
+
* Fixes `thread list` showing too many threads
|
9
|
+
* Change in tracing global variables. Use `trace variable foo` instead of `trace
|
10
|
+
variable $foo`
|
11
|
+
* Fix setting post mortem mode with `set post_mortem`. Now this is the only
|
12
|
+
post mortem functionality available as specifying `Byebug.post_mortem` with a
|
13
|
+
block has been removed in this version.
|
14
|
+
|
15
|
+
|
1
16
|
# 2.3.1
|
2
17
|
|
3
18
|
* Fixes bug preventing users from deleting breakpoints
|
data/README.md
CHANGED
@@ -25,11 +25,6 @@ effects of one bug and go on to learn about another.
|
|
25
25
|
|
26
26
|
$ gem install byebug
|
27
27
|
|
28
|
-
**Please upgrade your ruby to 2.0.0-p247 or higher** - a bug in ruby core was
|
29
|
-
directly affecting byebug and a fix for it has been released with this
|
30
|
-
patchlevel (see [#5](https://github.com/deivid-rodriguez/byebug/issues/5) for
|
31
|
-
more information)
|
32
|
-
|
33
28
|
|
34
29
|
## Usage
|
35
30
|
|
@@ -47,11 +42,8 @@ Former [debugger](https://github.com/cldwalker/debugger) or
|
|
47
42
|
* Some gems (rails, rspec) implement debugging flags (-d, --debugger) that early
|
48
43
|
require and start the debugger. These flags are a performance penalty and Byebug
|
49
44
|
doesn't need them anymore so my recommendation is not to use them.
|
50
|
-
*
|
51
|
-
|
52
|
-
`.byebugrc` instead of `.rdebugrc`.
|
53
|
-
* `autoreload`, `autoeval` and `autolist` are default options in Byebug so you
|
54
|
-
no longer need to set them in the startup file.
|
45
|
+
* The startup configuration file is now called `.byebugrc` instead of
|
46
|
+
`.rdebugrc`.
|
55
47
|
|
56
48
|
|
57
49
|
## What's different from debugger
|
@@ -61,7 +53,7 @@ no longer need to set them in the startup file.
|
|
61
53
|
* Fixes all of debugger's open bugs in its issue tracker and provides some
|
62
54
|
enhancements, such as a markdown guide or the fact that `byebug` can now be
|
63
55
|
placed at the end of a block or method call.
|
64
|
-
*
|
56
|
+
* Actively mantained.
|
65
57
|
* Editor agnostic: no external editor built-in support.
|
66
58
|
* Pry command is built-in. No need of external gem like debugger-pry.
|
67
59
|
|
data/Rakefile
CHANGED
@@ -6,12 +6,19 @@ Rake::ExtensionTask.new('byebug')
|
|
6
6
|
|
7
7
|
SO_NAME = "byebug.so"
|
8
8
|
|
9
|
+
# Override default rake tests loader
|
10
|
+
class Rake::TestTask
|
11
|
+
def rake_loader
|
12
|
+
'test/test_helper.rb'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
9
16
|
desc "Run MiniTest suite"
|
10
17
|
task :test do
|
11
|
-
Rake::TestTask.new
|
12
|
-
t.test_files = FileList["test/*_test.rb"]
|
13
|
-
t.warning = true
|
18
|
+
Rake::TestTask.new do |t|
|
14
19
|
t.verbose = true
|
20
|
+
t.warning = true
|
21
|
+
t.pattern = 'test/*_test.rb'
|
15
22
|
end
|
16
23
|
end
|
17
24
|
|
data/bin/byebug
CHANGED
@@ -93,6 +93,7 @@ options = OpenStruct.new(
|
|
93
93
|
'quit' => true,
|
94
94
|
'restart_script' => nil,
|
95
95
|
'script' => nil,
|
96
|
+
'server' => nil,
|
96
97
|
'stop' => true,
|
97
98
|
'tracing' => false,
|
98
99
|
)
|
@@ -126,11 +127,18 @@ EOB
|
|
126
127
|
else
|
127
128
|
require name
|
128
129
|
end }
|
130
|
+
opts.on('-R', '--remote HOST[:PORT]', String, 'Specify byebug server spec') {
|
131
|
+
|server| host, port = server.split(':', 2)
|
132
|
+
host = 'localhost' if host.empty?
|
133
|
+
port = nil if port && port.empty?
|
134
|
+
port &&= port.to_i
|
135
|
+
options.server = [host, port].compact
|
136
|
+
}
|
129
137
|
opts.on('--restart-script FILE', String,
|
130
138
|
'Name of the script file to run. Erased after read') do
|
131
139
|
|restart_script|
|
132
140
|
options.restart_script = restart_script
|
133
|
-
unless File.
|
141
|
+
unless File.exist?(options.restart_script)
|
134
142
|
puts "Script file '#{options.restart_script}' is not found"
|
135
143
|
exit
|
136
144
|
end
|
@@ -138,7 +146,7 @@ EOB
|
|
138
146
|
opts.on('--script FILE', String, 'Name of the script file to run') do
|
139
147
|
|script|
|
140
148
|
options.script = script
|
141
|
-
unless File.
|
149
|
+
unless File.exist?(options.script)
|
142
150
|
puts "Script file '#{options.script}' is not found"
|
143
151
|
exit
|
144
152
|
end
|
@@ -191,6 +199,12 @@ rescue StandardError => e
|
|
191
199
|
exit(-1)
|
192
200
|
end
|
193
201
|
|
202
|
+
if options.server
|
203
|
+
puts "Connecting to byebug server #{options.server.join(':')}"
|
204
|
+
Byebug.start_client(*options.server)
|
205
|
+
exit
|
206
|
+
end
|
207
|
+
|
194
208
|
if ARGV.empty?
|
195
209
|
puts opts
|
196
210
|
puts
|
data/byebug.gemspec
CHANGED
data/ext/byebug/byebug.c
CHANGED
@@ -649,59 +649,6 @@ bb_set_verbose(VALUE self, VALUE value)
|
|
649
649
|
return value;
|
650
650
|
}
|
651
651
|
|
652
|
-
static VALUE
|
653
|
-
set_current_skipped_status(VALUE status)
|
654
|
-
{
|
655
|
-
VALUE context;
|
656
|
-
debug_context_t *dc;
|
657
|
-
|
658
|
-
context = bb_current_context(mByebug);
|
659
|
-
Data_Get_Struct(context, debug_context_t, dc);
|
660
|
-
|
661
|
-
if (status)
|
662
|
-
CTX_FL_SET(dc, CTX_FL_SKIPPED);
|
663
|
-
else
|
664
|
-
CTX_FL_UNSET(dc, CTX_FL_SKIPPED);
|
665
|
-
|
666
|
-
return Qnil;
|
667
|
-
}
|
668
|
-
|
669
|
-
static VALUE
|
670
|
-
debug_at_exit_c(VALUE proc)
|
671
|
-
{
|
672
|
-
return rb_funcall(proc, rb_intern("call"), 0);
|
673
|
-
}
|
674
|
-
|
675
|
-
static void
|
676
|
-
debug_at_exit_i(VALUE proc)
|
677
|
-
{
|
678
|
-
if (IS_STARTED)
|
679
|
-
{
|
680
|
-
set_current_skipped_status(Qtrue);
|
681
|
-
rb_ensure(debug_at_exit_c, proc, set_current_skipped_status, Qfalse);
|
682
|
-
}
|
683
|
-
else
|
684
|
-
debug_at_exit_c(proc);
|
685
|
-
}
|
686
|
-
|
687
|
-
/*
|
688
|
-
* call-seq:
|
689
|
-
* Byebug.debug_at_exit { block } -> proc
|
690
|
-
*
|
691
|
-
* Register <tt>at_exit</tt> hook which is escaped from byebug.
|
692
|
-
*/
|
693
|
-
static VALUE
|
694
|
-
bb_at_exit(VALUE self)
|
695
|
-
{
|
696
|
-
VALUE proc;
|
697
|
-
|
698
|
-
if (!rb_block_given_p()) rb_raise(rb_eArgError, "called without a block");
|
699
|
-
|
700
|
-
proc = rb_block_proc();
|
701
|
-
rb_set_end_proc(debug_at_exit_i, proc);
|
702
|
-
return proc;
|
703
|
-
}
|
704
|
-
|
705
652
|
/*
|
706
653
|
* call-seq:
|
707
654
|
* Byebug.tracing -> bool
|
@@ -810,7 +757,6 @@ Init_byebug()
|
|
810
757
|
rb_define_module_function(mByebug, "catchpoints" , bb_catchpoints , 0);
|
811
758
|
rb_define_module_function(mByebug, "contexts" , bb_contexts , 0);
|
812
759
|
rb_define_module_function(mByebug, "current_context", bb_current_context, 0);
|
813
|
-
rb_define_module_function(mByebug, "debug_at_exit" , bb_at_exit , 0);
|
814
760
|
rb_define_module_function(mByebug, "debug_load" , bb_load , -1);
|
815
761
|
rb_define_module_function(mByebug, "post_mortem?" , bb_post_mortem , 0);
|
816
762
|
rb_define_module_function(mByebug, "post_mortem=" , bb_set_post_mortem, 1);
|
data/ext/byebug/byebug.h
CHANGED
@@ -10,10 +10,9 @@
|
|
10
10
|
#define CTX_FL_ENABLE_BKPT (1<<3) /* cab check for breakpoints */
|
11
11
|
#define CTX_FL_FORCE_MOVE (1<<4) /* don't stop unless we've changed line */
|
12
12
|
#define CTX_FL_IGNORE (1<<5) /* this context belongs to ignored thread */
|
13
|
-
#define
|
14
|
-
#define
|
15
|
-
#define
|
16
|
-
#define CTX_FL_WAS_RUNNING (1<<9) /* thread was previously running */
|
13
|
+
#define CTX_FL_SUSPEND (1<<6) /* thread currently suspended */
|
14
|
+
#define CTX_FL_TRACING (1<<7) /* call at_tracing method */
|
15
|
+
#define CTX_FL_WAS_RUNNING (1<<8) /* thread was previously running */
|
17
16
|
|
18
17
|
/* macro functions */
|
19
18
|
#define CTX_FL_TEST(c,f) ((c)->flags & (f))
|
data/ext/byebug/extconf.rb
CHANGED
data/lib/byebug.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require 'byebug.so'
|
2
2
|
require_relative 'byebug/version'
|
3
3
|
require_relative 'byebug/context'
|
4
4
|
require_relative 'byebug/processor'
|
@@ -134,10 +134,10 @@ module Byebug
|
|
134
134
|
#
|
135
135
|
def run_init_script(out = handler.interface)
|
136
136
|
cwd_script = File.expand_path(File.join(".", INITFILE))
|
137
|
-
run_script(cwd_script, out) if File.
|
137
|
+
run_script(cwd_script, out) if File.exist?(cwd_script)
|
138
138
|
|
139
139
|
home_script = File.expand_path(File.join(ENV['HOME'].to_s, INITFILE))
|
140
|
-
if File.
|
140
|
+
if File.exist?(home_script) and cwd_script != home_script
|
141
141
|
run_script(home_script, out)
|
142
142
|
end
|
143
143
|
end
|
@@ -152,53 +152,24 @@ module Byebug
|
|
152
152
|
end
|
153
153
|
|
154
154
|
#
|
155
|
-
# Activates the post-mortem mode.
|
155
|
+
# Activates the post-mortem mode.
|
156
156
|
#
|
157
|
-
#
|
158
|
-
#
|
159
|
-
#
|
160
|
-
# and enables post-mortem mode.
|
157
|
+
# By calling Byebug.post_mortem method, you install an at_exit hook that
|
158
|
+
# intercepts any exception not handled by your script and enables
|
159
|
+
# post-mortem mode.
|
161
160
|
#
|
162
|
-
# == Local post-mortem mode
|
163
|
-
#
|
164
|
-
# If you know that a particular block of code raises an exception you can
|
165
|
-
# enable post-mortem mode by wrapping this block with Byebug.post_mortem,
|
166
|
-
# e.g.
|
167
|
-
#
|
168
|
-
# def offender
|
169
|
-
# raise 'error'
|
170
|
-
# end
|
171
|
-
# Byebug.post_mortem do
|
172
|
-
# ...
|
173
|
-
# offender
|
174
|
-
# ...
|
175
|
-
# end
|
176
161
|
def post_mortem
|
177
|
-
if
|
178
|
-
|
179
|
-
|
180
|
-
self.post_mortem = true
|
181
|
-
yield
|
182
|
-
rescue Exception => exp
|
183
|
-
handle_post_mortem(exp)
|
184
|
-
raise
|
185
|
-
ensure
|
186
|
-
self.post_mortem = old_post_mortem
|
187
|
-
end
|
188
|
-
else
|
189
|
-
return if self.post_mortem?
|
190
|
-
self.post_mortem = true
|
191
|
-
debug_at_exit do
|
192
|
-
handle_post_mortem($!) if post_mortem?
|
193
|
-
end
|
194
|
-
end
|
162
|
+
return if self.post_mortem?
|
163
|
+
at_exit { handle_post_mortem($!) if post_mortem? }
|
164
|
+
self.post_mortem = true
|
195
165
|
end
|
196
166
|
|
197
167
|
def handle_post_mortem(exp)
|
198
|
-
return if !exp
|
168
|
+
return if !exp
|
169
|
+
Byebug.last_exception = exp
|
170
|
+
return if !exp.__bb_context || !exp.__bb_context.calced_stack_size
|
199
171
|
orig_tracing = Byebug.tracing?
|
200
172
|
Byebug.tracing = false
|
201
|
-
Byebug.last_exception = exp
|
202
173
|
handler.at_line(exp.__bb_context, exp.__bb_file, exp.__bb_line)
|
203
174
|
ensure
|
204
175
|
Byebug.tracing = orig_tracing
|
@@ -224,4 +195,6 @@ module Kernel
|
|
224
195
|
end
|
225
196
|
Byebug.current_context.step_into steps_into if steps_into >= 0
|
226
197
|
end
|
198
|
+
|
199
|
+
alias_method :debugger, :byebug
|
227
200
|
end
|
data/lib/byebug/command.rb
CHANGED
@@ -23,12 +23,16 @@ module Byebug
|
|
23
23
|
@commands ||= []
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
attr_accessor :allow_in_control, :unknown, :need_context
|
27
|
+
attr_writer :allow_in_post_mortem, :always_run
|
28
|
+
|
29
|
+
def allow_in_post_mortem
|
30
|
+
@allow_in_post_mortem ||= !defined?(@allow_in_post_mortem) ? true : false
|
31
|
+
end
|
32
|
+
|
33
|
+
def always_run
|
34
|
+
@always_run ||= 0
|
35
|
+
end
|
32
36
|
|
33
37
|
def help(args)
|
34
38
|
if args && args[1]
|
@@ -73,9 +77,6 @@ module Byebug
|
|
73
77
|
end
|
74
78
|
|
75
79
|
def inherited(klass)
|
76
|
-
DEF_OPTIONS.each do |o, v|
|
77
|
-
klass.options[o] = v if klass.options[o].nil?
|
78
|
-
end
|
79
80
|
commands << klass
|
80
81
|
end
|
81
82
|
|
@@ -86,22 +87,6 @@ module Byebug
|
|
86
87
|
|name| Byebug.const_get(name) }.each { |mod| include mod }
|
87
88
|
end
|
88
89
|
|
89
|
-
def method_missing(meth, *args, &block)
|
90
|
-
if meth.to_s =~ /^(.+?)=$/
|
91
|
-
options[$1.intern] = args.first
|
92
|
-
else
|
93
|
-
if options.has_key?(meth)
|
94
|
-
options[meth]
|
95
|
-
else
|
96
|
-
super
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def options
|
102
|
-
@options ||= {}
|
103
|
-
end
|
104
|
-
|
105
90
|
def settings_map
|
106
91
|
@@settings_map ||= {}
|
107
92
|
end
|
@@ -143,7 +128,7 @@ module Byebug
|
|
143
128
|
|
144
129
|
def command_exists?(command)
|
145
130
|
ENV['PATH'].split(File::PATH_SEPARATOR).any? {
|
146
|
-
|d| File.
|
131
|
+
|d| File.exist? File.join(d, command) }
|
147
132
|
end
|
148
133
|
|
149
134
|
def terminal_width
|
@@ -155,7 +140,6 @@ module Byebug
|
|
155
140
|
nil
|
156
141
|
end
|
157
142
|
end
|
158
|
-
|
159
143
|
end
|
160
144
|
|
161
145
|
# Register default settings
|
@@ -193,7 +177,7 @@ module Byebug
|
|
193
177
|
begin
|
194
178
|
eval(str, b)
|
195
179
|
rescue StandardError, ScriptError => e
|
196
|
-
at = eval(
|
180
|
+
at = eval('Thread.current.backtrace_locations(1)', b)
|
197
181
|
print "#{at.shift}: #{e.class} Exception(#{e.message})\n"
|
198
182
|
for i in at
|
199
183
|
print "\tfrom #{i}\n"
|
@@ -2,6 +2,7 @@ module Byebug
|
|
2
2
|
|
3
3
|
# Implements byebug "break" command.
|
4
4
|
class BreakCommand < Command
|
5
|
+
self.allow_in_post_mortem = false
|
5
6
|
self.allow_in_control = true
|
6
7
|
|
7
8
|
def regexp
|
@@ -97,6 +98,7 @@ module Byebug
|
|
97
98
|
|
98
99
|
# Implements byebug "delete" command.
|
99
100
|
class DeleteCommand < Command
|
101
|
+
self.allow_in_post_mortem = false
|
100
102
|
self.allow_in_control = true
|
101
103
|
|
102
104
|
def regexp
|
@@ -19,7 +19,7 @@ module Byebug
|
|
19
19
|
print "Warning #{@match[1]} is not known to be a Class\n" unless
|
20
20
|
bb_eval "#{@match[1]}.is_a?(Class)", get_binding
|
21
21
|
Byebug.add_catchpoint @match[1]
|
22
|
-
print "
|
22
|
+
print "Catching exception #{@match[1]}.\n"
|
23
23
|
end
|
24
24
|
elsif @match[2] != 'off'
|
25
25
|
errmsg "Off expected. Got #{@match[2]}\n"
|
@@ -22,6 +22,8 @@ module Byebug
|
|
22
22
|
end
|
23
23
|
|
24
24
|
class AddDisplayCommand < Command
|
25
|
+
self.allow_in_post_mortem = false
|
26
|
+
|
25
27
|
def regexp
|
26
28
|
/^\s* disp(?:lay)? \s+ (.+) \s*$/x
|
27
29
|
end
|
@@ -45,6 +47,8 @@ module Byebug
|
|
45
47
|
end
|
46
48
|
|
47
49
|
class DisplayCommand < Command
|
50
|
+
self.allow_in_post_mortem = false
|
51
|
+
|
48
52
|
def self.always_run
|
49
53
|
2
|
50
54
|
end
|
@@ -69,6 +73,8 @@ module Byebug
|
|
69
73
|
end
|
70
74
|
|
71
75
|
class DeleteDisplayCommand < Command
|
76
|
+
self.allow_in_post_mortem = false
|
77
|
+
|
72
78
|
def regexp
|
73
79
|
/^\s* undisp(?:lay)? (?:\s+(\S+))? \s*$/x
|
74
80
|
end
|