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, #match
#camelize, #prettify
#get_line, #get_lines, #n_lines, #normalize
#get_int, #parse_steps, #syntax_valid?, #without_stderr
Class Method Details
.description ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/byebug/commands/save.rb', line 58
def description
prettify <<-EOD
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.
EOD
end
|
.names ⇒ Object
54
55
56
|
# File 'lib/byebug/commands/save.rb', line 54
def names
%w(save)
end
|
Instance Method Details
#execute ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/byebug/commands/save.rb', line 41
def execute
file = File.open(@match[1] || RESTART_FILE, 'w')
save_breakpoints(file)
save_catchpoints(file)
save_displays(file)
save_settings(file)
print pr('save.messages.done', path: file.path)
file.close
end
|
#regexp ⇒ Object
37
38
39
|
# File 'lib/byebug/commands/save.rb', line 37
def regexp
/^\s* sa(?:ve)? (?:\s+(\S+))? \s*$/x
end
|
#save_breakpoints(file) ⇒ Object
15
16
17
18
19
|
# File 'lib/byebug/commands/save.rb', line 15
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
21
22
23
24
25
|
# File 'lib/byebug/commands/save.rb', line 21
def save_catchpoints(file)
Byebug.catchpoints.keys.each do |c|
file.puts "catch #{c}"
end
end
|
#save_displays(file) ⇒ Object
27
28
29
|
# File 'lib/byebug/commands/save.rb', line 27
def save_displays(file)
@state.display.each { |d| file.puts "display #{d[1]}" if d[0] }
end
|
#save_settings(file) ⇒ Object
31
32
33
34
35
|
# File 'lib/byebug/commands/save.rb', line 31
def save_settings(file)
%w(autoeval autoirb autolist basename).each do |setting|
file.puts "set #{setting} #{Setting[setting.to_sym]}"
end
end
|