Class: Byebug::SaveCommand
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
command_exists?, commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, load_commands, #match, register_setting_get, register_setting_set, register_setting_var, settings, settings_map, terminal_width
Class Method Details
.description ⇒ Object
77
78
79
80
81
82
83
84
|
# File 'lib/byebug/commands/save.rb', line 77
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
73
74
75
|
# File 'lib/byebug/commands/save.rb', line 73
def names
%w(save)
end
|
Instance Method Details
#execute ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/byebug/commands/save.rb', line 55
def execute
if not @match[1]
file = open_save()
else
file = open(@match[1], 'w')
end
save_breakpoints(file)
save_catchpoints(file)
save_displays(file)
save_settings(file)
print "Saved to '#{file.path}'\n"
if @state and @state.interface
@state.interface.restart_file = file.path
end
file.close
end
|
#regexp ⇒ Object
51
52
53
|
# File 'lib/byebug/commands/save.rb', line 51
def regexp
/^\s* sa(?:ve)? (?:\s+(\S+))? \s*$/x
end
|
#save_breakpoints(file) ⇒ Object
19
20
21
22
23
|
# File 'lib/byebug/commands/save.rb', line 19
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
25
26
27
28
29
|
# File 'lib/byebug/commands/save.rb', line 25
def save_catchpoints(file)
Byebug.catchpoints.keys.each do |c|
file.puts "catch #{c}"
end
end
|
#save_displays(file) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/byebug/commands/save.rb', line 31
def save_displays(file)
for d in @state.display
if d[0]
file.puts "display #{d[1]}"
end
end
end
|
#save_settings(file) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/byebug/commands/save.rb', line 39
def save_settings(file)
%w(autoeval basename testing).each do |setting|
on_off = show_onoff(Command.settings[setting.to_sym])
file.puts "set #{setting} #{on_off}"
end
%w(autolist autoirb).each do |setting|
on_off = show_onoff(Command.settings[setting.to_sym] > 0)
file.puts "set #{setting} #{on_off}"
end
end
|