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.\n"
23 "Note: transcripts will only be saved if "
24 "interpreter.save-transcript is true.\n",
25 "session save [file]") {
33 llvm::StringRef file_path;
36 file_path = args[0].ref();
45#define LLDB_OPTIONS_history
46#include "CommandOptions.inc"
52 "Dump the history of commands in this session.\n"
53 "Commands in the history list can be run again "
54 "using \"!<INDEX>\". \"!-<OFFSET>\" will re-run "
55 "the command that is <OFFSET> commands from the end"
56 " of the list (counting the current command).",
76 switch (short_option) {
81 if (option_arg ==
"end") {
97 llvm_unreachable(
"Unimplemented option");
111 return llvm::ArrayRef(g_history_options);
131 result.
AppendError(
"--count, --start-index and --end-index cannot be "
132 "all specified in the same invocation");
135 std::pair<bool, uint64_t> start_idx(
138 std::pair<bool, uint64_t> stop_idx(
146 if (start_idx.first && start_idx.second ==
UINT64_MAX) {
148 start_idx.second = history.
GetSize() - count.second;
149 stop_idx.second = history.
GetSize() - 1;
150 }
else if (stop_idx.first) {
151 start_idx.second = stop_idx.second;
152 stop_idx.second = history.
GetSize() - 1;
154 start_idx.second = 0;
155 stop_idx.second = history.
GetSize() - 1;
158 if (!start_idx.first && !stop_idx.first && !count.first) {
159 start_idx.second = 0;
160 stop_idx.second = history.
GetSize() - 1;
161 }
else if (start_idx.first) {
163 stop_idx.second = start_idx.second + count.second - 1;
164 }
else if (!stop_idx.first) {
165 stop_idx.second = history.
GetSize() - 1;
167 }
else if (stop_idx.first) {
169 if (stop_idx.second >= count.second)
170 start_idx.second = stop_idx.second - count.second + 1;
172 start_idx.second = 0;
176 start_idx.second = 0;
177 stop_idx.second = count.second - 1;
191 "Commands controlling LLDB session.",
192 "session <subcommand> [<command-options>]") {
static llvm::raw_ostream & error(Stream &strm)
OptionValueBoolean m_clear
OptionValueUInt64 m_stop_idx
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
~CommandOptions() override=default
void OptionParsingStarting(ExecutionContext *execution_context) override
OptionValueUInt64 m_start_idx
OptionValueUInt64 m_count
CommandObjectSessionHistory(CommandInterpreter &interpreter)
~CommandObjectSessionHistory() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
Options * GetOptions() override
~CommandObjectSessionSave() override=default
void DoExecute(Args &args, CommandReturnObject &result) override
CommandObjectSessionSave(CommandInterpreter &interpreter)
A command line argument class.
void Dump(Stream &stream, size_t start_idx=0, size_t stop_idx=SIZE_MAX) const
bool SaveTranscript(CommandReturnObject &result, std::optional< std::string > output_file=std::nullopt)
Save the current debugger session transcript to a file on disk.
CommandHistory & GetCommandHistory()
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
CommandObjectSession(CommandInterpreter &interpreter)
void AddSimpleArgumentList(lldb::CommandArgumentType arg_type, ArgumentRepetitionType repetition_type=eArgRepeatPlain)
CommandInterpreter & m_interpreter
void void AppendError(llvm::StringRef in_string)
void SetStatus(lldb::ReturnStatus status)
Stream & GetOutputStream()
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
void SetCurrentValue(bool value)
bool GetCurrentValue() const
uint64_t GetCurrentValue() const
bool SetCurrentValue(uint64_t value)
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
bool OptionWasSet() const
A command line option parsing protocol class.
std::vector< Option > m_getopt_table
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
@ eReturnStatusSuccessFinishNoResult