byebug 1.0.0 → 1.0.1
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 +7 -0
- data/.gitignore +2 -0
- data/README.md +36 -4
- data/Rakefile +1 -3
- data/bin/byebug +26 -30
- data/byebug.gemspec +8 -2
- data/lib/byebug.rb +6 -5
- data/lib/byebug/command.rb +30 -18
- data/lib/byebug/commands/control.rb +4 -4
- data/lib/byebug/commands/frame.rb +12 -11
- data/lib/byebug/commands/info.rb +43 -56
- data/lib/byebug/commands/irb.rb +3 -3
- data/lib/byebug/commands/list.rb +26 -25
- data/lib/byebug/commands/save.rb +11 -11
- data/lib/byebug/commands/set.rb +32 -38
- data/lib/byebug/commands/show.rb +3 -7
- data/lib/byebug/commands/variables.rb +6 -6
- data/lib/byebug/helper.rb +1 -1
- data/lib/byebug/interface.rb +6 -5
- data/lib/byebug/processor.rb +9 -9
- data/lib/byebug/version.rb +1 -1
- data/old_doc/byebug.1 +16 -16
- data/old_doc/byebug.texi +155 -163
- data/test/info_test.rb +11 -10
- data/test/list_test.rb +45 -22
- data/test/restart_test.rb +1 -1
- data/test/set_test.rb +6 -5
- data/test/support/matchers.rb +2 -3
- data/test/support/mocha_extensions.rb +2 -4
- data/test/support/test_dsl.rb +4 -0
- data/test/test_helper.rb +5 -0
- data/test/variables_test.rb +5 -5
- metadata +9 -26
data/lib/byebug/commands/irb.rb
CHANGED
@@ -71,12 +71,12 @@ module Byebug
|
|
71
71
|
end
|
72
72
|
|
73
73
|
save_trap = trap("SIGINT") do
|
74
|
-
throw :IRB_EXIT, :cont if $
|
74
|
+
throw :IRB_EXIT, :cont if $byebug_in_irb
|
75
75
|
end
|
76
76
|
|
77
77
|
add_debugging = @match.is_a?(MatchData) && '-d' == @match[1]
|
78
78
|
$byebug_state = @state if add_debugging
|
79
|
-
$
|
79
|
+
$byebug_in_irb = true
|
80
80
|
cont = IRB.start_session(get_binding)
|
81
81
|
case cont
|
82
82
|
when :cont
|
@@ -97,7 +97,7 @@ module Byebug
|
|
97
97
|
end
|
98
98
|
|
99
99
|
ensure
|
100
|
-
$
|
100
|
+
$byebug_in_irb = nil
|
101
101
|
$byebug_state = nil if add_debugging
|
102
102
|
trap("SIGINT", save_trap) if save_trap
|
103
103
|
end
|
data/lib/byebug/commands/list.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module Byebug
|
2
|
+
|
2
3
|
# Implements byebug "list" command.
|
3
4
|
class ListCommand < Command
|
4
5
|
|
5
6
|
register_setting_get(:autolist) do
|
6
|
-
ListCommand.always_run
|
7
|
+
ListCommand.always_run
|
7
8
|
end
|
8
9
|
register_setting_set(:autolist) do |value|
|
9
10
|
ListCommand.always_run = value
|
@@ -16,17 +17,17 @@ module Byebug
|
|
16
17
|
def execute
|
17
18
|
listsize = Command.settings[:listsize]
|
18
19
|
if !@match || !(@match[1] || @match[2])
|
19
|
-
b = @state.previous_line ?
|
20
|
+
b = @state.previous_line ?
|
20
21
|
@state.previous_line + listsize : @state.line - (listsize/2)
|
21
22
|
e = b + listsize - 1
|
22
23
|
elsif @match[1] == '-'
|
23
24
|
b = if @state.previous_line
|
24
25
|
if @state.previous_line > 0
|
25
|
-
@state.previous_line - listsize
|
26
|
+
@state.previous_line - listsize
|
26
27
|
else
|
27
28
|
@state.previous_line
|
28
29
|
end
|
29
|
-
else
|
30
|
+
else
|
30
31
|
@state.line - (listsize/2)
|
31
32
|
end
|
32
33
|
e = b + listsize - 1
|
@@ -65,30 +66,30 @@ module Byebug
|
|
65
66
|
|
66
67
|
private
|
67
68
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
69
|
+
# Show FILE from line B to E where CURRENT is the current line number.
|
70
|
+
# If we can show from B to E then we return B, otherwise we return the
|
71
|
+
# previous line @state.previous_line.
|
72
|
+
def display_list(b, e, file, current)
|
73
|
+
print "[%d, %d] in %s\n", b, e, file
|
74
|
+
lines = LineCache::getlines(file,
|
75
|
+
Command.settings[:reload_source_on_change])
|
76
|
+
if lines
|
77
|
+
return @state.previous_line if b >= lines.size
|
78
|
+
e = lines.size if lines.size < e
|
79
|
+
[b, 1].max.upto(e) do |n|
|
80
|
+
if n > 0 && lines[n-1]
|
81
|
+
if n == current
|
82
|
+
print "=> %d %s\n", n, lines[n-1].chomp
|
83
|
+
else
|
84
|
+
print " %d %s\n", n, lines[n-1].chomp
|
85
|
+
end
|
84
86
|
end
|
85
87
|
end
|
88
|
+
else
|
89
|
+
errmsg "No sourcefile available for %s\n", file
|
90
|
+
return @state.previous_line
|
86
91
|
end
|
87
|
-
|
88
|
-
errmsg "No sourcefile available for %s\n", file
|
89
|
-
return @state.previous_line
|
92
|
+
return e == lines.size ? @state.previous_line : b
|
90
93
|
end
|
91
|
-
return e == lines.size ? @state.previous_line : b
|
92
|
-
end
|
93
94
|
end
|
94
95
|
end
|
data/lib/byebug/commands/save.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module Byebug
|
2
|
-
module SaveFunctions # :nodoc:
|
3
2
|
|
3
|
+
module SaveFunctions
|
4
4
|
# Create a temporary file to write in if file is nil
|
5
5
|
def open_save
|
6
6
|
require "tempfile"
|
7
|
-
file = Tempfile.new("
|
7
|
+
file = Tempfile.new("byebug-save")
|
8
8
|
# We want close to not unlink, so redefine.
|
9
9
|
def file.close
|
10
10
|
@tmpfile.close if @tmpfile
|
@@ -13,9 +13,9 @@ module Byebug
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
class SaveCommand < Command
|
16
|
+
class SaveCommand < Command
|
17
17
|
self.allow_in_control = true
|
18
|
-
|
18
|
+
|
19
19
|
def save_breakpoints(file)
|
20
20
|
Byebug.breakpoints.each do |b|
|
21
21
|
file.puts "break #{b.source}:#{b.pos}#{" if #{b.expr}" if b.expr}"
|
@@ -24,10 +24,10 @@ module Byebug
|
|
24
24
|
|
25
25
|
def save_catchpoints(file)
|
26
26
|
Byebug.catchpoints.keys.each do |c|
|
27
|
-
file.puts "catch #{c}"
|
27
|
+
file.puts "catch #{c}"
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def save_displays(file)
|
32
32
|
for d in @state.display
|
33
33
|
if d[0]
|
@@ -35,7 +35,7 @@ module Byebug
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
def save_settings(file)
|
40
40
|
# FIXME put routine in set
|
41
41
|
%w(autoeval basename byebugtesting).each do |setting|
|
@@ -47,13 +47,13 @@ module Byebug
|
|
47
47
|
file.puts "set #{setting} #{on_off}"
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
def regexp
|
52
52
|
/^\s* sa(?:ve)?
|
53
|
-
(?:\s+(.+))?
|
53
|
+
(?:\s+(.+))?
|
54
54
|
\s*$/ix
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
def execute
|
58
58
|
if not @match[1] or @match[1].strip.empty?
|
59
59
|
file = open_save()
|
@@ -75,7 +75,7 @@ module Byebug
|
|
75
75
|
def help_command
|
76
76
|
'save'
|
77
77
|
end
|
78
|
-
|
78
|
+
|
79
79
|
def help(cmd)
|
80
80
|
%{
|
81
81
|
save [FILE]
|
data/lib/byebug/commands/set.rb
CHANGED
@@ -4,37 +4,35 @@ module Byebug
|
|
4
4
|
class SetCommand < Command
|
5
5
|
SubcmdStruct2=Struct.new(:name, :min, :is_bool, :short_help,
|
6
6
|
:long_help) unless defined?(SubcmdStruct2)
|
7
|
-
Subcommands =
|
8
|
-
[
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
['width', 1, false,
|
37
|
-
'Number of characters per line for byebug\'s output']
|
7
|
+
Subcommands = [
|
8
|
+
['annotate', 2, false, "Set annotation level",
|
9
|
+
'0 == normal. ' \
|
10
|
+
'2 == output annotated suitably for use by programs that control ' \
|
11
|
+
'byebug.'],
|
12
|
+
['args', 2, false,
|
13
|
+
'Set argument list to give program being debugged when it is started'],
|
14
|
+
['autoeval', 4, true, "Evaluate every unrecognized command"],
|
15
|
+
['autolist', 4, true, "Execute 'list' command on every breakpoint"],
|
16
|
+
['autoirb', 4, true, "Invoke IRB on every stop"],
|
17
|
+
['autoreload', 4, true, "Reload source code when changed"],
|
18
|
+
['basename', 1, true, "Report file basename only showing file names"],
|
19
|
+
['callstyle', 2, false, "Set how you want call parameters displayed"],
|
20
|
+
['byebugtesting', 8, false, "Used when testing byebug"],
|
21
|
+
['forcestep', 2, true,
|
22
|
+
'Make sure \'next/step\' commands always move to a new line'],
|
23
|
+
['fullpath', 2, true, "Display full file names in frames"],
|
24
|
+
['history', 2, false,
|
25
|
+
'Generic command for setting command history parameters',
|
26
|
+
'set history filename -- Set the filename in which to record the ' \
|
27
|
+
'command history. ' \
|
28
|
+
'set history save -- Set saving of the history record on exit. ' \
|
29
|
+
'set history size -- Set the size of the command history'],
|
30
|
+
['linetrace+', 10, true,
|
31
|
+
'Set line execution tracing to show different lines'],
|
32
|
+
['linetrace', 3, true, "Set line execution tracing"],
|
33
|
+
['listsize', 3, false, "Set number of source lines to list by default"],
|
34
|
+
['trace', 1, true, "Display stack trace when 'eval' raises exception"],
|
35
|
+
['width', 1, false, 'Number of characters per line for byebug\'s output']
|
38
36
|
].map do |name, min, is_bool, short_help, long_help|
|
39
37
|
SubcmdStruct2.new(name, min, is_bool, short_help, long_help)
|
40
38
|
end unless defined?(Subcommands)
|
@@ -47,11 +45,7 @@ module Byebug
|
|
47
45
|
|
48
46
|
def execute
|
49
47
|
if not @match[1]
|
50
|
-
|
51
|
-
print "List of set subcommands:\n\n"
|
52
|
-
for subcmd in Subcommands do
|
53
|
-
print "set #{subcmd.name} -- #{subcmd.short_help}\n"
|
54
|
-
end
|
48
|
+
print_subcommands
|
55
49
|
else
|
56
50
|
args = @match[1].split(/[ \t]+/)
|
57
51
|
subcmd = args.shift
|
@@ -80,10 +74,10 @@ module Byebug
|
|
80
74
|
return
|
81
75
|
end
|
82
76
|
if defined?(Byebug::RDEBUG_SCRIPT)
|
83
|
-
#
|
77
|
+
# byebug was called initially. 1st arg is script name.
|
84
78
|
Command.settings[:argv][1..-1] = args
|
85
79
|
else
|
86
|
-
#
|
80
|
+
# byebug wasn't called initially. 1st arg is not script name.
|
87
81
|
Command.settings[:argv] = args
|
88
82
|
end
|
89
83
|
when /^args$/
|
data/lib/byebug/commands/show.rb
CHANGED
@@ -11,10 +11,10 @@ module Byebug
|
|
11
11
|
when /^args$/
|
12
12
|
if Command.settings[:argv] and Command.settings[:argv].size > 0
|
13
13
|
if defined?(Byebug::RDEBUG_SCRIPT)
|
14
|
-
#
|
14
|
+
# byebug was called initially. 1st arg is script name.
|
15
15
|
args = Command.settings[:argv][1..-1].join(' ')
|
16
16
|
else
|
17
|
-
#
|
17
|
+
# byebug wasn't called initially. 1st arg is not script name.
|
18
18
|
args = Command.settings[:argv].join(' ')
|
19
19
|
end
|
20
20
|
else
|
@@ -194,11 +194,7 @@ show history size -- Show the size of the command history"],
|
|
194
194
|
|
195
195
|
def execute
|
196
196
|
if not @match[1]
|
197
|
-
|
198
|
-
print "List of show subcommands:\n\n"
|
199
|
-
for subcmd in Subcommands do
|
200
|
-
print "show #{subcmd.name} -- #{subcmd.short_help}\n"
|
201
|
-
end
|
197
|
+
print_subcommands
|
202
198
|
else
|
203
199
|
args = @match[1].split(/[ \t]+/)
|
204
200
|
param = args.shift
|
@@ -5,8 +5,7 @@ module Byebug
|
|
5
5
|
ary.sort!
|
6
6
|
for v in ary
|
7
7
|
begin
|
8
|
-
s = debug_eval(v.to_s, b).inspect
|
9
|
-
v == :$KCODE || v == :$-K || v == :$=
|
8
|
+
s = debug_eval(v.to_s, b).inspect
|
10
9
|
rescue
|
11
10
|
begin
|
12
11
|
s = debug_eval(v.to_s, b).to_s
|
@@ -14,9 +13,7 @@ module Byebug
|
|
14
13
|
s = "*Error in evaluation*"
|
15
14
|
end
|
16
15
|
end
|
17
|
-
|
18
|
-
s[self.class.settings[:width]-3 .. -1] = "..."
|
19
|
-
end
|
16
|
+
pad_with_dots(s)
|
20
17
|
print "%s = %s\n", v, s
|
21
18
|
end
|
22
19
|
end
|
@@ -24,6 +21,9 @@ module Byebug
|
|
24
21
|
obj = debug_eval('self')
|
25
22
|
var_list(obj.class.class_variables, get_binding)
|
26
23
|
end
|
24
|
+
def var_global
|
25
|
+
var_list(global_variables.reject { |v| [:$=, :$KCODE, :$-K].include?(v) })
|
26
|
+
end
|
27
27
|
end
|
28
28
|
|
29
29
|
# Implements byebug's 'var class' command
|
@@ -92,7 +92,7 @@ module Byebug
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def execute
|
95
|
-
|
95
|
+
var_global
|
96
96
|
end
|
97
97
|
|
98
98
|
class << self
|
data/lib/byebug/helper.rb
CHANGED
data/lib/byebug/interface.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Byebug
|
2
2
|
|
3
|
-
class Interface
|
3
|
+
class Interface
|
4
4
|
attr_writer :have_readline
|
5
5
|
|
6
6
|
def initialize
|
@@ -31,13 +31,14 @@ module Byebug
|
|
31
31
|
|
32
32
|
end
|
33
33
|
|
34
|
-
class LocalInterface < Interface
|
34
|
+
class LocalInterface < Interface
|
35
35
|
attr_accessor :command_queue, :history_length, :history_save, :histfile
|
36
36
|
attr_accessor :restart_file
|
37
37
|
|
38
38
|
unless defined?(FILE_HISTORY)
|
39
|
-
FILE_HISTORY = ".
|
39
|
+
FILE_HISTORY = ".byebug_hist"
|
40
40
|
end
|
41
|
+
|
41
42
|
def initialize()
|
42
43
|
super
|
43
44
|
@command_queue = []
|
@@ -126,7 +127,7 @@ module Byebug
|
|
126
127
|
end
|
127
128
|
end
|
128
129
|
|
129
|
-
class RemoteInterface < Interface
|
130
|
+
class RemoteInterface < Interface
|
130
131
|
attr_accessor :command_queue, :history_length, :history_save, :histfile
|
131
132
|
attr_accessor :restart_file
|
132
133
|
|
@@ -180,7 +181,7 @@ module Byebug
|
|
180
181
|
end
|
181
182
|
end
|
182
183
|
|
183
|
-
class ScriptInterface < Interface
|
184
|
+
class ScriptInterface < Interface
|
184
185
|
attr_accessor :command_queue, :history_length, :history_save, :histfile
|
185
186
|
attr_accessor :restart_file
|
186
187
|
|
data/lib/byebug/processor.rb
CHANGED
@@ -86,7 +86,8 @@ module Byebug
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def self.print_location_and_text(file, line)
|
89
|
-
file_line = "#{canonic_file(file)}:#{line}\n
|
89
|
+
file_line = "#{canonic_file(file)}:#{line}\n" \
|
90
|
+
"#{Byebug.line_at(file, line)}\n"
|
90
91
|
|
91
92
|
# FIXME: use annotations routines
|
92
93
|
if Byebug.annotate.to_i > 2
|
@@ -132,7 +133,7 @@ module Byebug
|
|
132
133
|
aprint 'stopped' if Byebug.annotate.to_i > 2
|
133
134
|
file = CommandProcessor.canonic_file(context.frame_file(0))
|
134
135
|
line = context.frame_line(0)
|
135
|
-
print afmt("%s:%d" % [file, line]) if ENV['EMACS']
|
136
|
+
#print afmt("%s:%d" % [file, line]) if ENV['EMACS']
|
136
137
|
print "Catchpoint at %s:%d: `%s' (%s)\n", file, line, excpt, excpt.class
|
137
138
|
fs = context.stack_size
|
138
139
|
tb = caller(0)[-fs..-1]
|
@@ -148,10 +149,9 @@ module Byebug
|
|
148
149
|
# Don't trace ourselves
|
149
150
|
return if defined?(Byebug::RDEBUG_FILE) && Byebug::RDEBUG_FILE == file
|
150
151
|
|
151
|
-
#@last_file = CommandProcessor.canonic_file(file)
|
152
152
|
file = CommandProcessor.canonic_file(file)
|
153
|
-
|
154
|
-
|
153
|
+
tracing_plus = Command.settings[:tracing_plus]
|
154
|
+
if file != @last_file || line != @last_line || tracing_plus
|
155
155
|
@last_file = file
|
156
156
|
@last_line = line
|
157
157
|
print "Tracing: #{file}:#{line} #{Byebug.line_at(file, line)}"
|
@@ -356,8 +356,8 @@ module Byebug
|
|
356
356
|
end
|
357
357
|
|
358
358
|
class State
|
359
|
-
attr_accessor :binding, :commands, :context, :display, :file
|
360
|
-
attr_accessor :interface, :line, :previous_line
|
359
|
+
attr_accessor :binding, :commands, :context, :display, :file
|
360
|
+
attr_accessor :frame_pos, :interface, :line, :previous_line
|
361
361
|
|
362
362
|
def initialize
|
363
363
|
super()
|
@@ -382,7 +382,7 @@ module Byebug
|
|
382
382
|
end # end class CommandProcessor
|
383
383
|
|
384
384
|
|
385
|
-
class ControlCommandProcessor < Processor
|
385
|
+
class ControlCommandProcessor < Processor
|
386
386
|
|
387
387
|
def initialize(interface)
|
388
388
|
super()
|
@@ -426,7 +426,7 @@ module Byebug
|
|
426
426
|
# The prompt shown before reading a command.
|
427
427
|
# Note: have an unused 'context' parameter to match the local interface.
|
428
428
|
def prompt(context)
|
429
|
-
p = '(
|
429
|
+
p = '(byebug:ctrl) '
|
430
430
|
p = afmt("pre-prompt")+p+"\n"+afmt("prompt") if
|
431
431
|
Byebug.annotate.to_i > 2
|
432
432
|
return p
|
data/lib/byebug/version.rb
CHANGED