Class: Byebug::SaveCommand
Overview
Save current settings to use them in another debug session.
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match
Class Method Details
.description ⇒ Object
70
71
72
73
74
75
76
77
78
|
# File 'lib/byebug/commands/save.rb', line 70
def description
%(save[ FILE]
Saves current byebug state to FILE as a script file. This includes
breakpoints, catchpoints, display expressions and some settings. If
no filename is given, we will fabricate one.
Use the "source" command in another debug session to restore them.)
end
|
.names ⇒ Object
66
67
68
|
# File 'lib/byebug/commands/save.rb', line 66
def names
%w(save)
end
|
Instance Method Details
#execute ⇒ Object
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/byebug/commands/save.rb', line 50
def execute
if !@match[1]
file = open_save
else
file = open(@match[1], 'w')
end
save_breakpoints(file)
save_catchpoints(file)
save_displays(file)
save_settings(file)
puts "Saved to '#{file.path}'"
@state.interface.restart_file = file.path if @state && @state.interface
file.close
end
|
#regexp ⇒ Object
46
47
48
|
# File 'lib/byebug/commands/save.rb', line 46
def regexp
/^\s* sa(?:ve)? (?:\s+(\S+))? \s*$/x
end
|
#save_breakpoints(file) ⇒ Object
24
25
26
27
28
|
# File 'lib/byebug/commands/save.rb', line 24
def save_breakpoints(file)
Byebug.breakpoints.each do |b|
file.puts "break #{b.source}:#{b.pos}#{" if #{b.expr}" if b.expr}"
end
end
|
#save_catchpoints(file) ⇒ Object
30
31
32
33
34
|
# File 'lib/byebug/commands/save.rb', line 30
def save_catchpoints(file)
Byebug.catchpoints.keys.each do |c|
file.puts "catch #{c}"
end
end
|
#save_displays(file) ⇒ Object
36
37
38
|
# File 'lib/byebug/commands/save.rb', line 36
def save_displays(file)
@state.display.each { |d| file.puts "display #{d[1]}" if d[0] }
end
|
#save_settings(file) ⇒ Object
40
41
42
43
44
|
# File 'lib/byebug/commands/save.rb', line 40
def save_settings(file)
%w(autoeval autoirb autolist basename testing).each do |setting|
file.puts "set #{setting} #{Setting[setting.to_sym]}"
end
end
|