20 "Save the current session transcripts to a file.\n"
21 "If no file if specified, transcripts will be "
22 "saved to a temporary file.",
23 "session save [file]") {
26 m_arguments.push_back(arg1);
34 CommandCompletions::InvokeCommonCompletionCallbacks(
35 GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
41 llvm::StringRef file_path;
44 file_path = args[0].ref();
46 if (m_interpreter.SaveTranscript(result, file_path.str()))
54 #define LLDB_OPTIONS_history
55 #include "CommandOptions.inc"
61 "Dump the history of commands in this session.\n"
62 "Commands in the history list can be run again "
63 "using \"!<INDEX>\". \"!-<OFFSET>\" will re-run "
64 "the command that is <OFFSET> commands from the end"
65 " of the list (counting the current command).",
76 : m_start_idx(0), m_stop_idx(0), m_count(0), m_clear(false) {}
83 const int short_option = m_getopt_table[option_idx].val;
85 switch (short_option) {
90 if (option_arg ==
"end") {
92 m_start_idx.SetOptionWasSet();
94 error = m_start_idx.SetValueFromString(option_arg,
102 m_clear.SetCurrentValue(
true);
103 m_clear.SetOptionWasSet();
106 llvm_unreachable(
"Unimplemented option");
120 return llvm::makeArrayRef(g_history_options);
132 if (m_options.m_clear.GetCurrentValue() &&
133 m_options.m_clear.OptionWasSet()) {
134 m_interpreter.GetCommandHistory().Clear();
137 if (m_options.m_start_idx.OptionWasSet() &&
138 m_options.m_stop_idx.OptionWasSet() &&
139 m_options.m_count.OptionWasSet()) {
140 result.
AppendError(
"--count, --start-index and --end-index cannot be "
141 "all specified in the same invocation");
144 std::pair<bool, uint64_t> start_idx(
145 m_options.m_start_idx.OptionWasSet(),
146 m_options.m_start_idx.GetCurrentValue());
147 std::pair<bool, uint64_t> stop_idx(
148 m_options.m_stop_idx.OptionWasSet(),
149 m_options.m_stop_idx.GetCurrentValue());
150 std::pair<bool, uint64_t> count(m_options.m_count.OptionWasSet(),
151 m_options.m_count.GetCurrentValue());
155 if (start_idx.first && start_idx.second ==
UINT64_MAX) {
157 start_idx.second = history.
GetSize() - count.second;
158 stop_idx.second = history.
GetSize() - 1;
159 }
else if (stop_idx.first) {
160 start_idx.second = stop_idx.second;
161 stop_idx.second = history.
GetSize() - 1;
163 start_idx.second = 0;
164 stop_idx.second = history.
GetSize() - 1;
167 if (!start_idx.first && !stop_idx.first && !count.first) {
168 start_idx.second = 0;
169 stop_idx.second = history.
GetSize() - 1;
170 }
else if (start_idx.first) {
172 stop_idx.second = start_idx.second + count.second - 1;
173 }
else if (!stop_idx.first) {
174 stop_idx.second = history.
GetSize() - 1;
176 }
else if (stop_idx.first) {
178 if (stop_idx.second >= count.second)
179 start_idx.second = stop_idx.second - count.second + 1;
181 start_idx.second = 0;
185 start_idx.second = 0;
186 stop_idx.second = count.second - 1;
201 "Commands controlling LLDB session.",
202 "session <subcommand> [<command-options>]") {