byebug 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +125 -99
- data/CONTRIBUTING.md +4 -6
- data/GUIDE.md +42 -20
- data/Gemfile +5 -3
- data/README.md +2 -3
- data/Rakefile +11 -7
- data/bin/byebug +2 -252
- data/byebug.gemspec +7 -4
- data/ext/byebug/byebug.c +17 -18
- data/ext/byebug/byebug.h +4 -5
- data/ext/byebug/context.c +37 -39
- data/ext/byebug/threads.c +39 -18
- data/lib/byebug.rb +2 -110
- data/lib/byebug/attacher.rb +23 -0
- data/lib/byebug/breakpoint.rb +60 -0
- data/lib/byebug/command.rb +62 -70
- data/lib/byebug/commands/break.rb +24 -24
- data/lib/byebug/commands/catchpoint.rb +18 -10
- data/lib/byebug/commands/condition.rb +18 -17
- data/lib/byebug/commands/continue.rb +17 -9
- data/lib/byebug/commands/delete.rb +19 -13
- data/lib/byebug/commands/display.rb +19 -53
- data/lib/byebug/commands/edit.rb +7 -4
- data/lib/byebug/commands/enable_disable.rb +130 -0
- data/lib/byebug/commands/eval.rb +40 -22
- data/lib/byebug/commands/finish.rb +13 -4
- data/lib/byebug/commands/frame.rb +65 -45
- data/lib/byebug/commands/help.rb +17 -18
- data/lib/byebug/commands/history.rb +14 -8
- data/lib/byebug/commands/info.rb +160 -182
- data/lib/byebug/commands/interrupt.rb +4 -1
- data/lib/byebug/commands/irb.rb +30 -0
- data/lib/byebug/commands/kill.rb +7 -8
- data/lib/byebug/commands/list.rb +71 -66
- data/lib/byebug/commands/method.rb +14 -6
- data/lib/byebug/commands/pry.rb +35 -0
- data/lib/byebug/commands/quit.rb +9 -6
- data/lib/byebug/commands/reload.rb +5 -2
- data/lib/byebug/commands/restart.rb +13 -9
- data/lib/byebug/commands/save.rb +17 -17
- data/lib/byebug/commands/set.rb +16 -15
- data/lib/byebug/commands/show.rb +10 -11
- data/lib/byebug/commands/source.rb +11 -5
- data/lib/byebug/commands/stepping.rb +38 -24
- data/lib/byebug/commands/threads.rb +45 -31
- data/lib/byebug/commands/trace.rb +22 -9
- data/lib/byebug/commands/undisplay.rb +45 -0
- data/lib/byebug/commands/variables.rb +83 -27
- data/lib/byebug/context.rb +25 -22
- data/lib/byebug/core.rb +82 -0
- data/lib/byebug/helper.rb +37 -28
- data/lib/byebug/history.rb +8 -4
- data/lib/byebug/interface.rb +12 -17
- data/lib/byebug/interfaces/local_interface.rb +11 -8
- data/lib/byebug/interfaces/remote_interface.rb +11 -8
- data/lib/byebug/interfaces/script_interface.rb +9 -6
- data/lib/byebug/options.rb +46 -0
- data/lib/byebug/processor.rb +7 -1
- data/lib/byebug/processors/command_processor.rb +135 -125
- data/lib/byebug/processors/control_command_processor.rb +23 -23
- data/lib/byebug/remote.rb +17 -26
- data/lib/byebug/runner.rb +100 -0
- data/lib/byebug/setting.rb +33 -8
- data/lib/byebug/settings/autoeval.rb +5 -15
- data/lib/byebug/settings/autoirb.rb +4 -1
- data/lib/byebug/settings/autolist.rb +5 -2
- data/lib/byebug/settings/autoreload.rb +5 -2
- data/lib/byebug/settings/autosave.rb +6 -2
- data/lib/byebug/settings/basename.rb +7 -2
- data/lib/byebug/settings/callstyle.rb +4 -1
- data/lib/byebug/settings/forcestep.rb +6 -3
- data/lib/byebug/settings/fullpath.rb +5 -2
- data/lib/byebug/settings/histfile.rb +5 -3
- data/lib/byebug/settings/histsize.rb +5 -3
- data/lib/byebug/settings/linetrace.rb +4 -1
- data/lib/byebug/settings/listsize.rb +5 -1
- data/lib/byebug/settings/post_mortem.rb +21 -13
- data/lib/byebug/settings/stack_on_error.rb +6 -2
- data/lib/byebug/settings/testing.rb +6 -1
- data/lib/byebug/settings/tracing_plus.rb +5 -1
- data/lib/byebug/settings/verbose.rb +13 -2
- data/lib/byebug/settings/width.rb +4 -1
- data/lib/byebug/version.rb +1 -1
- data/test/{break_test.rb → commands/break_test.rb} +41 -53
- data/test/{condition_test.rb → commands/condition_test.rb} +14 -14
- data/test/{continue_test.rb → commands/continue_test.rb} +0 -0
- data/test/{delete_test.rb → commands/delete_test.rb} +2 -2
- data/test/commands/display_test.rb +37 -0
- data/test/{edit_test.rb → commands/edit_test.rb} +0 -0
- data/test/{eval_test.rb → commands/eval_test.rb} +1 -0
- data/test/{finish_test.rb → commands/finish_test.rb} +11 -1
- data/test/{frame_test.rb → commands/frame_test.rb} +12 -16
- data/test/{help_test.rb → commands/help_test.rb} +21 -4
- data/test/{history_test.rb → commands/history_test.rb} +0 -0
- data/test/{info_test.rb → commands/info_test.rb} +5 -55
- data/test/{interrupt_test.rb → commands/interrupt_test.rb} +0 -0
- data/test/commands/irb_test.rb +28 -0
- data/test/{kill_test.rb → commands/kill_test.rb} +1 -1
- data/test/{list_test.rb → commands/list_test.rb} +1 -1
- data/test/{method_test.rb → commands/method_test.rb} +0 -0
- data/test/{post_mortem_test.rb → commands/post_mortem_test.rb} +6 -10
- data/test/{pry_test.rb → commands/pry_test.rb} +4 -13
- data/test/{quit_test.rb → commands/quit_test.rb} +4 -4
- data/test/{reload_test.rb → commands/reload_test.rb} +0 -0
- data/test/{restart_test.rb → commands/restart_test.rb} +6 -0
- data/test/{save_test.rb → commands/save_test.rb} +2 -2
- data/test/{set_test.rb → commands/set_test.rb} +9 -2
- data/test/{show_test.rb → commands/show_test.rb} +1 -1
- data/test/{source_test.rb → commands/source_test.rb} +3 -3
- data/test/{stepping_test.rb → commands/stepping_test.rb} +44 -35
- data/test/{thread_test.rb → commands/thread_test.rb} +0 -0
- data/test/{trace_test.rb → commands/trace_test.rb} +0 -0
- data/test/{display_test.rb → commands/undisplay_test.rb} +7 -45
- data/test/{variables_test.rb → commands/variables_test.rb} +10 -1
- data/test/debugger_alias_test.rb +2 -2
- data/test/runner_test.rb +127 -0
- data/test/support/matchers.rb +27 -25
- data/test/support/test_interface.rb +9 -5
- data/test/support/utils.rb +96 -101
- data/test/test_helper.rb +32 -20
- metadata +93 -68
- data/lib/byebug/commands/enable.rb +0 -154
- data/lib/byebug/commands/repl.rb +0 -126
- data/test/irb_test.rb +0 -47
- data/test/support/breakpoint.rb +0 -13
data/Gemfile
CHANGED
@@ -6,10 +6,12 @@ gem 'rake', '~> 10.3'
|
|
6
6
|
|
7
7
|
group :development do
|
8
8
|
gem 'rake-compiler', '~> 0.9'
|
9
|
-
gem '
|
10
|
-
gem 'minitest', '~> 5.4'
|
9
|
+
gem 'rubocop', '~> 0.25'
|
11
10
|
end
|
12
11
|
|
13
12
|
group :test do
|
14
|
-
gem '
|
13
|
+
gem 'mocha', '~> 1.1'
|
14
|
+
gem 'minitest', '~> 5.4'
|
15
|
+
gem 'simplecov', '~> 0.9', require: false
|
16
|
+
gem 'codeclimate-test-reporter', '~> 0.4', require: false
|
15
17
|
end
|
data/README.md
CHANGED
@@ -71,7 +71,7 @@ both rails and rspec have deprecated these flags in their latest versions.
|
|
71
71
|
`frame` | |
|
72
72
|
`help` | |
|
73
73
|
`history` | |
|
74
|
-
`info` | | `args` `breakpoints` `catch` `display` `file` `files` `
|
74
|
+
`info` | | `args` `breakpoints` `catch` `display` `file` `files` `line` `program`
|
75
75
|
`irb` | |
|
76
76
|
`kill` | |
|
77
77
|
`list` | |
|
@@ -95,7 +95,7 @@ both rails and rspec have deprecated these flags in their latest versions.
|
|
95
95
|
`tracevar` | |
|
96
96
|
`undisplay` | |
|
97
97
|
`up` | |
|
98
|
-
`var` | | `class` `constant` `global` `instance` `local`
|
98
|
+
`var` | | `all` `class` `constant` `global` `instance` `local`
|
99
99
|
|
100
100
|
|
101
101
|
## Semantic Versioning
|
@@ -130,7 +130,6 @@ for ruby debugging on Sublime Text.
|
|
130
130
|
|
131
131
|
* Write tests for remote debugging support.
|
132
132
|
* Add printers support.
|
133
|
-
* Libify and test byebug's executable.
|
134
133
|
* Support rubies other than MRI.
|
135
134
|
|
136
135
|
## Credits
|
data/Rakefile
CHANGED
@@ -6,10 +6,14 @@ Rake::ExtensionTask.new('byebug') do |ext|
|
|
6
6
|
ext.lib_dir = 'lib/byebug'
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
module Rake
|
10
|
+
#
|
11
|
+
# Overrides default rake tests loader
|
12
|
+
#
|
13
|
+
class TestTask
|
14
|
+
def rake_loader
|
15
|
+
'test/test_helper.rb'
|
16
|
+
end
|
13
17
|
end
|
14
18
|
end
|
15
19
|
|
@@ -18,7 +22,7 @@ task :test do
|
|
18
22
|
Rake::TestTask.new do |t|
|
19
23
|
t.verbose = true
|
20
24
|
t.warning = true
|
21
|
-
t.pattern = 'test
|
25
|
+
t.pattern = 'test/**/*_test.rb'
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
@@ -26,8 +30,8 @@ task default: :test
|
|
26
30
|
|
27
31
|
desc 'Run a test in looped mode so that you can look for memory leaks'
|
28
32
|
task 'test_loop' do
|
29
|
-
code = %
|
30
|
-
cmd = %
|
33
|
+
code = %(loop{ require '#{$ARGV[1]}' })
|
34
|
+
cmd = %(ruby -Itest -e "#{ code }")
|
31
35
|
system cmd
|
32
36
|
end
|
33
37
|
|
data/bin/byebug
CHANGED
@@ -1,255 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
#
|
5
|
-
#A command-line front-end to <tt>byebug</tt>
|
6
|
-
#
|
7
|
-
#Command invocation:
|
8
|
-
#
|
9
|
-
# byebug [options] [--] [script-options] ruby-script-to-debug
|
10
|
-
# byebug [options] [script-options]
|
11
|
-
# byebug [--version | --help]
|
12
|
-
#
|
13
|
-
#=== Options
|
14
|
-
#
|
15
|
-
#<tt>-d | --debug</tt>::
|
16
|
-
# Set $DEBUG true.
|
17
|
-
#
|
18
|
-
#<tt>--help</tt>::
|
19
|
-
# Show invocation help and exit.
|
20
|
-
#
|
21
|
-
#<tt>-I | --include</tt> <i>path</i>
|
22
|
-
# Add <i>path</i> to <tt>$LOAD_PATH</tt>. Like the <tt>ruby -I</tt> command,
|
23
|
-
# it supports multiple load paths separated by colons.
|
24
|
-
#
|
25
|
-
#<tt>--post-mortem</tt>::
|
26
|
-
# Activate post-mortem mode.
|
27
|
-
#
|
28
|
-
#<tt>--no-quit</tt>::
|
29
|
-
# Do not quit when script terminates. Instead rerun the program.
|
30
|
-
#
|
31
|
-
#<tt>--no-stop</tt>::
|
32
|
-
# Do not stop when script is loaded.
|
33
|
-
#
|
34
|
-
#<tt>--nx</tt>::
|
35
|
-
# Don’t execute commands found in any initialization files like
|
36
|
-
# <tt>.byebugrc</tt>.
|
37
|
-
#
|
38
|
-
#<tt>-r | --require</tt><i>script</i>::
|
39
|
-
# Require the library, before executing your script.
|
40
|
-
#
|
41
|
-
#<tt>--script</tt>=<i>file</i>::
|
42
|
-
# Run script file <i>file</i>
|
43
|
-
#
|
44
|
-
#<tt>--v</tt>::
|
45
|
-
# Print the version number, then turn on verbose mode if a script name is
|
46
|
-
# given. If no script name is given just exit after printing the version
|
47
|
-
# number.
|
48
|
-
#
|
49
|
-
#<tt>--verbose</tt>::
|
50
|
-
# Turn on verbose mode.
|
51
|
-
#
|
52
|
-
#<tt>--version</tt>::
|
53
|
-
# Show the version number and exit.
|
54
|
-
#
|
55
|
-
#<tt>-x | --trace</tt>::
|
56
|
-
# Show lines before executing them.
|
57
|
-
#
|
3
|
+
require 'byebug/runner'
|
58
4
|
|
59
|
-
|
60
|
-
require 'ostruct'
|
61
|
-
require File.dirname(__FILE__) + "/../lib/byebug"
|
62
|
-
|
63
|
-
def debug_program(options)
|
64
|
-
# Make sure Ruby script syntax checks okay.
|
65
|
-
output = `ruby -c "#{Byebug::PROG_SCRIPT}" 2>&1`
|
66
|
-
if $?.exitstatus != 0
|
67
|
-
puts output
|
68
|
-
exit $?.exitstatus
|
69
|
-
end
|
70
|
-
if bt = Byebug.debug_load(Byebug::PROG_SCRIPT, options.stop)
|
71
|
-
p bt, bt.backtrace
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
#
|
76
|
-
# Do a shell-like path lookup for prog_script and return the results. If we
|
77
|
-
# can't find anything return prog_script.
|
78
|
-
#
|
79
|
-
def whence_file(prog_script)
|
80
|
-
if prog_script.index(File::SEPARATOR)
|
81
|
-
# Don't search since this name has path separator components
|
82
|
-
return prog_script
|
83
|
-
end
|
84
|
-
|
85
|
-
for dirname in ENV['PATH'].split(File::PATH_SEPARATOR) do
|
86
|
-
prog_script_try = File.join(dirname, prog_script)
|
87
|
-
return prog_script_try if File.exist?(prog_script_try)
|
88
|
-
end
|
89
|
-
|
90
|
-
# Failure
|
91
|
-
return prog_script
|
92
|
-
end
|
93
|
-
|
94
|
-
options = OpenStruct.new(
|
95
|
-
'nx' => false,
|
96
|
-
'post_mortem' => false,
|
97
|
-
'quit' => true,
|
98
|
-
'restart_script' => nil,
|
99
|
-
'script' => nil,
|
100
|
-
'server' => nil,
|
101
|
-
'stop' => true,
|
102
|
-
'tracing' => false,
|
103
|
-
)
|
104
|
-
|
105
|
-
def process_options(options)
|
106
|
-
program = File.basename($0)
|
107
|
-
opts = OptionParser.new do |opts|
|
108
|
-
opts.banner = <<EOB
|
109
|
-
#{program} #{Byebug::VERSION}
|
110
|
-
Usage: #{program} [options] <script.rb> -- <script.rb parameters>
|
111
|
-
EOB
|
112
|
-
opts.separator ""
|
113
|
-
opts.separator "Options:"
|
114
|
-
|
115
|
-
opts.on("-d", "--debug", "Set $DEBUG=true") {
|
116
|
-
$DEBUG = true }
|
117
|
-
opts.on('-I', '--include PATH', String,
|
118
|
-
'Add PATH (single or multiple:path:list) to $LOAD_PATH.') {
|
119
|
-
|path| $LOAD_PATH.unshift(*path.split(':')) }
|
120
|
-
opts.on('--no-quit', 'Do not quit when script finishes') {
|
121
|
-
options.quit = false }
|
122
|
-
opts.on('--no-stop', 'Do not stop when script is loaded') {
|
123
|
-
options.stop = false }
|
124
|
-
opts.on('-nx', 'Don\'t run any byebug initialization files') {
|
125
|
-
options.nx = true }
|
126
|
-
opts.on('--post-mortem', 'Run byebug in post-mortem mode') {
|
127
|
-
options.post_mortem = true }
|
128
|
-
opts.on('-r', '--require SCRIPT', String, 'Require library before script') {
|
129
|
-
|name| if name == 'debug'
|
130
|
-
puts 'byebug not compatible with Ruby\'s \'debug\' lib, option ignored'
|
131
|
-
else
|
132
|
-
require name
|
133
|
-
end }
|
134
|
-
opts.on('-R', '--remote HOST[:PORT]', String, 'Specify byebug server spec') {
|
135
|
-
|server| host, port = server.split(':', 2)
|
136
|
-
host = 'localhost' if host.empty?
|
137
|
-
port = nil if port && port.empty?
|
138
|
-
port &&= port.to_i
|
139
|
-
options.server = [host, port].compact
|
140
|
-
}
|
141
|
-
opts.on('--restart-script FILE', String,
|
142
|
-
'Name of the script file to run. Erased after read') do
|
143
|
-
|restart_script|
|
144
|
-
options.restart_script = restart_script
|
145
|
-
unless File.exist?(options.restart_script)
|
146
|
-
puts "Script file '#{options.restart_script}' is not found"
|
147
|
-
exit
|
148
|
-
end
|
149
|
-
end
|
150
|
-
opts.on('--script FILE', String, 'Name of the script file to run') do
|
151
|
-
|script|
|
152
|
-
options.script = script
|
153
|
-
unless File.exist?(options.script)
|
154
|
-
puts "Script file '#{options.script}' is not found"
|
155
|
-
exit
|
156
|
-
end
|
157
|
-
end
|
158
|
-
opts.on('-x', '--trace', 'Turn on line tracing') {
|
159
|
-
options.tracing = true }
|
160
|
-
|
161
|
-
opts.separator ''
|
162
|
-
opts.separator 'Common options:'
|
163
|
-
opts.on_tail('--help', 'Show this message') do
|
164
|
-
puts opts
|
165
|
-
exit
|
166
|
-
end
|
167
|
-
opts.on_tail('--version', 'Print program version') do
|
168
|
-
puts "byebug #{Byebug::VERSION}"
|
169
|
-
exit
|
170
|
-
end
|
171
|
-
opts.on_tail('-v', 'Print version number, then turn on verbose mode') do
|
172
|
-
puts "byebug #{Byebug::VERSION}"
|
173
|
-
$VERBOSE = true
|
174
|
-
end
|
175
|
-
end
|
176
|
-
return opts
|
177
|
-
end
|
178
|
-
|
179
|
-
# What file is used for byebug startup commands.
|
180
|
-
unless defined?(OPTS_INITFILE)
|
181
|
-
OPTS_INITFILE = '.byebugoptrc'
|
182
|
-
HOME_DIR = ENV['HOME'].to_s
|
183
|
-
end
|
184
|
-
|
185
|
-
begin
|
186
|
-
initfile = File.join(HOME_DIR, OPTS_INITFILE)
|
187
|
-
eval(File.read(initfile)) if File.exist?(initfile)
|
188
|
-
rescue
|
189
|
-
end
|
190
|
-
|
191
|
-
opts = process_options(options)
|
192
|
-
|
193
|
-
begin
|
194
|
-
Byebug::BYEBUG_SCRIPT = File.expand_path(__FILE__)
|
195
|
-
Byebug::IGNORED_FILES << Byebug::BYEBUG_SCRIPT
|
196
|
-
opts.parse! ARGV
|
197
|
-
rescue StandardError => e
|
198
|
-
puts opts
|
199
|
-
puts
|
200
|
-
puts e.message
|
201
|
-
exit(-1)
|
202
|
-
end
|
203
|
-
|
204
|
-
if options.server
|
205
|
-
puts "Connecting to byebug server #{options.server.join(':')}"
|
206
|
-
Byebug.start_client(*options.server)
|
207
|
-
exit
|
208
|
-
end
|
209
|
-
|
210
|
-
if ARGV.empty?
|
211
|
-
puts opts
|
212
|
-
puts
|
213
|
-
puts 'Must specify a script to run'
|
214
|
-
exit(-1)
|
215
|
-
end
|
216
|
-
|
217
|
-
# Save debugged program
|
218
|
-
prog_script = ARGV.shift
|
219
|
-
prog_script = whence_file(prog_script) unless File.exist?(prog_script)
|
220
|
-
Byebug::PROG_SCRIPT = File.expand_path prog_script
|
221
|
-
|
222
|
-
# Set up trace hook for byebug
|
223
|
-
Byebug.start
|
224
|
-
|
225
|
-
# load initrc script (e.g. .byebugrc)
|
226
|
-
Byebug.run_init_script(StringIO.new) unless options.nx
|
227
|
-
|
228
|
-
Byebug::Setting[:post_mortem] = options.post_mortem
|
229
|
-
|
230
|
-
# run restore-settings startup script if specified
|
231
|
-
if options.restart_script
|
232
|
-
require 'fileutils'
|
233
|
-
Byebug.run_script(options.restart_script)
|
234
|
-
FileUtils.rm(options.restart_script)
|
235
|
-
end
|
236
|
-
|
237
|
-
# run startup script if specified
|
238
|
-
if options.script
|
239
|
-
Byebug.run_script(options.script)
|
240
|
-
end
|
241
|
-
|
242
|
-
options.stop = false if options.tracing
|
243
|
-
Byebug::Setting[:linetrace] = options.tracing
|
244
|
-
|
245
|
-
loop do
|
246
|
-
debug_program(options)
|
247
|
-
|
248
|
-
break if options.quit
|
249
|
-
|
250
|
-
interface = Byebug::LocalInterface.new
|
251
|
-
# Not sure if ControlCommandProcessor is really the right
|
252
|
-
# thing to use. CommandProcessor requires a state.
|
253
|
-
processor = Byebug::ControlCommandProcessor.new(interface)
|
254
|
-
processor.process_commands
|
255
|
-
end
|
5
|
+
Byebug::Runner.new.run
|
data/byebug.gemspec
CHANGED
@@ -7,22 +7,25 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.email = 'deivid.rodriguez@mail.com'
|
8
8
|
s.license = 'BSD'
|
9
9
|
s.homepage = 'http://github.com/deivid-rodriguez/byebug'
|
10
|
-
s.summary =
|
11
|
-
s.description =
|
10
|
+
s.summary = 'Ruby 2.0 fast debugger - base + CLI'
|
11
|
+
s.description = "Byebug is a Ruby 2 debugger. It's implemented using the
|
12
12
|
Ruby 2 TracePoint C API for execution control and the Debug Inspector C API
|
13
13
|
for call stack navigation. The core component provides support that
|
14
14
|
front-ends can build on. It provides breakpoint handling and bindings for
|
15
15
|
stack frames among other things and it comes with an easy to use command
|
16
|
-
line interface.
|
16
|
+
line interface."
|
17
17
|
|
18
18
|
s.required_ruby_version = '>= 2.0.0'
|
19
19
|
|
20
20
|
s.files = `git ls-files`.split("\n")
|
21
21
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
22
|
+
s.bindir = 'bin'
|
22
23
|
s.executables = ['byebug']
|
23
|
-
s.extra_rdoc_files =
|
24
|
+
s.extra_rdoc_files = %w(README.md GUIDE.md)
|
24
25
|
s.extensions = ['ext/byebug/extconf.rb']
|
26
|
+
s.require_path = 'lib'
|
25
27
|
|
26
28
|
s.add_dependency 'columnize', '~> 0.8'
|
29
|
+
s.add_dependency 'slop', '~> 3.6'
|
27
30
|
s.add_dependency 'debugger-linecache', '~> 1.2'
|
28
31
|
end
|
data/ext/byebug/byebug.c
CHANGED
@@ -12,12 +12,11 @@ static VALUE tracepoints = Qnil;
|
|
12
12
|
|
13
13
|
static VALUE raised_exception = Qnil;
|
14
14
|
|
15
|
-
/*
|
15
|
+
/* To allow thread syncronization, we must stop threads when debugging */
|
16
16
|
VALUE locker = Qnil;
|
17
17
|
|
18
|
-
/*
|
18
|
+
/* Hash table with active threads and their associated contexts */
|
19
19
|
VALUE threads = Qnil;
|
20
|
-
VALUE cThreadsTable;
|
21
20
|
|
22
21
|
#define IS_STARTED (catchpoints != Qnil)
|
23
22
|
static void
|
@@ -34,15 +33,13 @@ trace_print(rb_trace_arg_t *trace_arg, debug_context_t *dc)
|
|
34
33
|
{
|
35
34
|
if (trace_arg)
|
36
35
|
{
|
37
|
-
int i = 0;
|
38
36
|
const char *event = rb_id2name(SYM2ID(rb_tracearg_event(trace_arg)));
|
39
37
|
char *path = RSTRING_PTR(rb_tracearg_path(trace_arg));
|
40
38
|
int line = NUM2INT(rb_tracearg_lineno(trace_arg));
|
41
|
-
VALUE
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
printf("(%d)->[#%d] %s@%s:%d %s\n",
|
39
|
+
VALUE v_mid_sym = rb_tracearg_method_id(trace_arg);
|
40
|
+
VALUE v_mid_id = NIL_P(v_mid_sym) ? Qnil : SYM2ID(v_mid_sym);
|
41
|
+
const char *mid = NIL_P(v_mid_id) ? "" : rb_id2name(v_mid_id);
|
42
|
+
printf("%*s (%d)->[#%d] %s@%s:%d %s\n", dc->calced_stack_size, "",
|
46
43
|
dc->calced_stack_size, dc->thnum, event, path, line, mid);
|
47
44
|
}
|
48
45
|
}
|
@@ -55,7 +52,7 @@ cleanup(debug_context_t *dc)
|
|
55
52
|
dc->stop_reason = CTX_STOP_NONE;
|
56
53
|
|
57
54
|
/* checks for dead threads */
|
58
|
-
|
55
|
+
check_threads_table();
|
59
56
|
|
60
57
|
/* release a lock */
|
61
58
|
locker = Qnil;
|
@@ -72,9 +69,10 @@ cleanup(debug_context_t *dc)
|
|
72
69
|
VALUE context; \
|
73
70
|
thread_context_lookup(rb_thread_current(), &context); \
|
74
71
|
Data_Get_Struct(context, debug_context_t, dc); \
|
75
|
-
if (verbose == Qtrue) trace_print(trace_arg, dc); \
|
76
72
|
|
77
|
-
#define EVENT_COMMON
|
73
|
+
#define EVENT_COMMON \
|
74
|
+
if (verbose == Qtrue) trace_print(trace_arg, dc); \
|
75
|
+
if (!trace_common(trace_arg, dc)) { return; } \
|
78
76
|
|
79
77
|
static int
|
80
78
|
trace_common(rb_trace_arg_t *trace_arg, debug_context_t *dc)
|
@@ -216,7 +214,7 @@ line_event(VALUE trace_point, void *data)
|
|
216
214
|
if (dc->calced_stack_size < dc->dest_frame)
|
217
215
|
{
|
218
216
|
dc->dest_frame = dc->calced_stack_size;
|
219
|
-
rb_funcall(mByebug, rb_intern("
|
217
|
+
rb_funcall(mByebug, rb_intern("puts"), 1,
|
220
218
|
rb_str_new2("Next went up a frame because previous frame finished\n"));
|
221
219
|
}
|
222
220
|
}
|
@@ -458,8 +456,8 @@ bb_contexts(VALUE self)
|
|
458
456
|
rb_ary_push(new_list, context);
|
459
457
|
}
|
460
458
|
|
461
|
-
threads_clear(threads);
|
462
459
|
Data_Get_Struct(threads, threads_table_t, t_tbl);
|
460
|
+
st_clear(t_tbl->tbl);
|
463
461
|
|
464
462
|
for (i = 0; i < RARRAY_LENINT(new_list); i++)
|
465
463
|
{
|
@@ -569,7 +567,7 @@ bb_start(VALUE self)
|
|
569
567
|
locker = Qnil;
|
570
568
|
breakpoints = rb_ary_new();
|
571
569
|
catchpoints = rb_hash_new();
|
572
|
-
threads =
|
570
|
+
threads = create_threads_table();
|
573
571
|
|
574
572
|
register_tracepoints(self);
|
575
573
|
result = Qtrue;
|
@@ -606,6 +604,8 @@ bb_load(int argc, VALUE *argv, VALUE self)
|
|
606
604
|
context = bb_current_context(self);
|
607
605
|
Data_Get_Struct(context, debug_context_t, dc);
|
608
606
|
|
607
|
+
dc->calced_stack_size = 1;
|
608
|
+
|
609
609
|
if (RTEST(stop)) dc->steps = 1;
|
610
610
|
|
611
611
|
/* Initializing $0 to the script's path */
|
@@ -709,7 +709,7 @@ bb_set_post_mortem(VALUE self, VALUE value)
|
|
709
709
|
static VALUE
|
710
710
|
bb_breakpoints(VALUE self)
|
711
711
|
{
|
712
|
-
return breakpoints;
|
712
|
+
return NIL_P(breakpoints) ? rb_ary_new() : breakpoints;
|
713
713
|
}
|
714
714
|
|
715
715
|
/*
|
@@ -783,8 +783,7 @@ Init_byebug()
|
|
783
783
|
rb_define_module_function(mByebug, "verbose?" , bb_verbose , 0);
|
784
784
|
rb_define_module_function(mByebug, "verbose=" , bb_set_verbose , 1);
|
785
785
|
|
786
|
-
|
787
|
-
|
786
|
+
Init_threads_table(mByebug);
|
788
787
|
Init_context(mByebug);
|
789
788
|
Init_breakpoint(mByebug);
|
790
789
|
|