aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Interpreter
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Interpreter')
-rw-r--r--lldb/source/Interpreter/CommandAlias.cpp3
-rw-r--r--lldb/source/Interpreter/CommandHistory.cpp6
-rw-r--r--lldb/source/Interpreter/CommandInterpreter.cpp220
-rw-r--r--lldb/source/Interpreter/CommandObject.cpp26
-rw-r--r--lldb/source/Interpreter/CommandReturnObject.cpp50
-rw-r--r--lldb/source/Interpreter/InterpreterProperties.td7
-rw-r--r--lldb/source/Interpreter/OptionArgParser.cpp16
-rw-r--r--lldb/source/Interpreter/OptionGroupArchitecture.cpp4
-rw-r--r--lldb/source/Interpreter/OptionGroupBoolean.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupFile.cpp7
-rw-r--r--lldb/source/Interpreter/OptionGroupFormat.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupOutputFile.cpp5
-rw-r--r--lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp21
-rw-r--r--lldb/source/Interpreter/OptionGroupString.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupUInt64.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupUUID.cpp4
-rw-r--r--lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp4
-rw-r--r--lldb/source/Interpreter/OptionGroupVariable.cpp6
-rw-r--r--lldb/source/Interpreter/OptionGroupWatchpoint.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValue.cpp9
-rw-r--r--lldb/source/Interpreter/OptionValueArch.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValueArgs.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValueArray.cpp23
-rw-r--r--lldb/source/Interpreter/OptionValueBoolean.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValueChar.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValueDictionary.cpp23
-rw-r--r--lldb/source/Interpreter/OptionValueEnumeration.cpp9
-rw-r--r--lldb/source/Interpreter/OptionValueFileColonLine.cpp15
-rw-r--r--lldb/source/Interpreter/OptionValueFileSpec.cpp16
-rw-r--r--lldb/source/Interpreter/OptionValueFileSpecList.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValueFormat.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValueFormatEntity.cpp8
-rw-r--r--lldb/source/Interpreter/OptionValueLanguage.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValuePathMappings.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValueProperties.cpp120
-rw-r--r--lldb/source/Interpreter/OptionValueRegex.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValueSInt64.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValueString.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValueUInt64.cpp4
-rw-r--r--lldb/source/Interpreter/OptionValueUUID.cpp4
-rw-r--r--lldb/source/Interpreter/Options.cpp5
-rw-r--r--lldb/source/Interpreter/Property.cpp2
-rw-r--r--lldb/source/Interpreter/ScriptInterpreter.cpp50
43 files changed, 320 insertions, 403 deletions
diff --git a/lldb/source/Interpreter/CommandAlias.cpp b/lldb/source/Interpreter/CommandAlias.cpp
index a5e033937210..d55b3fdd44fa 100644
--- a/lldb/source/Interpreter/CommandAlias.cpp
+++ b/lldb/source/Interpreter/CommandAlias.cpp
@@ -47,7 +47,6 @@ static bool ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp,
if (!args_or) {
result.AppendError(toString(args_or.takeError()));
result.AppendError("Unable to create requested alias.\n");
- result.SetStatus(eReturnStatusFailed);
return false;
}
args = std::move(*args_or);
@@ -80,7 +79,7 @@ CommandAlias::CommandAlias(CommandInterpreter &interpreter,
llvm::StringRef help, llvm::StringRef syntax,
uint32_t flags)
: CommandObject(interpreter, name, help, syntax, flags),
- m_underlying_command_sp(), m_option_string(std::string(options_args)),
+ m_option_string(std::string(options_args)),
m_option_args_sp(new OptionArgVector),
m_is_dashdash_alias(eLazyBoolCalculate), m_did_set_help(false),
m_did_set_help_long(false) {
diff --git a/lldb/source/Interpreter/CommandHistory.cpp b/lldb/source/Interpreter/CommandHistory.cpp
index 9c7919ecc41f..8f399840b802 100644
--- a/lldb/source/Interpreter/CommandHistory.cpp
+++ b/lldb/source/Interpreter/CommandHistory.cpp
@@ -6,17 +6,13 @@
//
//===----------------------------------------------------------------------===//
-#include <inttypes.h>
+#include <cinttypes>
#include "lldb/Interpreter/CommandHistory.h"
using namespace lldb;
using namespace lldb_private;
-CommandHistory::CommandHistory() : m_mutex(), m_history() {}
-
-CommandHistory::~CommandHistory() {}
-
size_t CommandHistory::GetSize() const {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
return m_history.size();
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp
index fb503fe0afb0..00e9ccb762c3 100644
--- a/lldb/source/Interpreter/CommandInterpreter.cpp
+++ b/lldb/source/Interpreter/CommandInterpreter.cpp
@@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//
+#include <cstdlib>
#include <limits>
#include <memory>
-#include <stdlib.h>
#include <string>
#include <vector>
@@ -76,6 +76,7 @@
#include "lldb/Target/UnixSignals.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/FormatAdapters.h"
#include "llvm/Support/Path.h"
@@ -121,9 +122,8 @@ CommandInterpreter::CommandInterpreter(Debugger &debugger,
IOHandlerDelegate(IOHandlerDelegate::Completion::LLDBCommand),
m_debugger(debugger), m_synchronous_execution(true),
m_skip_lldbinit_files(false), m_skip_app_init_files(false),
- m_command_io_handler_sp(), m_comment_char('#'),
- m_batch_command_mode(false), m_truncation_warning(eNoTruncation),
- m_command_source_depth(0), m_result(), m_transcript_stream() {
+ m_comment_char('#'), m_batch_command_mode(false),
+ m_truncation_warning(eNoTruncation), m_command_source_depth(0) {
SetEventName(eBroadcastBitThreadShouldExit, "thread-should-exit");
SetEventName(eBroadcastBitResetPrompt, "reset-prompt");
SetEventName(eBroadcastBitQuitCommandReceived, "quit");
@@ -160,6 +160,16 @@ void CommandInterpreter::SetSaveSessionOnQuit(bool enable) {
m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, enable);
}
+FileSpec CommandInterpreter::GetSaveSessionDirectory() const {
+ const uint32_t idx = ePropertySaveSessionDirectory;
+ return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
+}
+
+void CommandInterpreter::SetSaveSessionDirectory(llvm::StringRef path) {
+ const uint32_t idx = ePropertySaveSessionDirectory;
+ m_collection_sp->SetPropertyAtIndexAsString(nullptr, idx, path);
+}
+
bool CommandInterpreter::GetEchoCommands() const {
const uint32_t idx = ePropertyEchoCommands;
return m_collection_sp->GetPropertyAtIndexAsBoolean(
@@ -223,6 +233,12 @@ bool CommandInterpreter::GetSpaceReplPrompts() const {
nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
}
+bool CommandInterpreter::GetRepeatPreviousCommand() const {
+ const uint32_t idx = ePropertyRepeatPreviousCommand;
+ return m_collection_sp->GetPropertyAtIndexAsBoolean(
+ nullptr, idx, g_interpreter_properties[idx].default_uint_value != 0);
+}
+
void CommandInterpreter::Initialize() {
LLDB_SCOPED_TIMER();
@@ -416,17 +432,14 @@ void CommandInterpreter::Initialize() {
cmd_obj_sp = GetCommandSPExact("process launch");
if (cmd_obj_sp) {
alias_arguments_vector_sp = std::make_shared<OptionArgVector>();
-#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
+#if defined(__APPLE__)
+#if defined(TARGET_OS_IPHONE)
AddAlias("r", cmd_obj_sp, "--");
AddAlias("run", cmd_obj_sp, "--");
#else
-#if defined(__APPLE__)
- std::string shell_option;
- shell_option.append("--shell-expand-args");
- shell_option.append(" true");
- shell_option.append(" --");
AddAlias("r", cmd_obj_sp, "--shell-expand-args true --");
AddAlias("run", cmd_obj_sp, "--shell-expand-args true --");
+#endif
#else
StreamString defaultshell;
defaultshell.Printf("--shell=%s --",
@@ -434,7 +447,6 @@ void CommandInterpreter::Initialize() {
AddAlias("r", cmd_obj_sp, defaultshell.GetString());
AddAlias("run", cmd_obj_sp, defaultshell.GetString());
#endif
-#endif
}
cmd_obj_sp = GetCommandSPExact("target symbols add");
@@ -1463,7 +1475,6 @@ CommandObject *CommandInterpreter::BuildAliasResult(
"need at least %d arguments to use "
"this alias.\n",
index);
- result.SetStatus(eReturnStatusFailed);
return nullptr;
} else {
size_t strpos = raw_input_string.find(cmd_args.GetArgumentAtIndex(index));
@@ -1631,12 +1642,18 @@ Status CommandInterpreter::PreprocessCommand(std::string &command) {
bool CommandInterpreter::HandleCommand(const char *command_line,
LazyBool lazy_add_to_history,
- CommandReturnObject &result,
- ExecutionContext *override_context,
- bool repeat_on_empty_command,
- bool no_context_switching)
+ const ExecutionContext &override_context,
+ CommandReturnObject &result) {
+
+ OverrideExecutionContext(override_context);
+ bool status = HandleCommand(command_line, lazy_add_to_history, result);
+ RestoreExecutionContext();
+ return status;
+}
-{
+bool CommandInterpreter::HandleCommand(const char *command_line,
+ LazyBool lazy_add_to_history,
+ CommandReturnObject &result) {
std::string command_string(command_line);
std::string original_command_string(command_line);
@@ -1648,12 +1665,8 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
LLDB_LOGF(log, "Processing command: %s", command_line);
LLDB_SCOPED_TIMERF("Processing command: %s.", command_line);
- if (!no_context_switching)
- UpdateExecutionContext(override_context);
-
if (WasInterrupted()) {
result.AppendError("interrupted");
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -1689,33 +1702,31 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
} else {
result.AppendErrorWithFormat("Could not find entry: %s in history",
command_string.c_str());
- result.SetStatus(eReturnStatusFailed);
return false;
}
}
}
if (empty_command) {
- if (repeat_on_empty_command) {
- if (m_command_history.IsEmpty()) {
- result.AppendError("empty command");
- result.SetStatus(eReturnStatusFailed);
- return false;
- } else {
- command_line = m_repeat_command.c_str();
- command_string = command_line;
- original_command_string = command_line;
- if (m_repeat_command.empty()) {
- result.AppendError("No auto repeat.");
- result.SetStatus(eReturnStatusFailed);
- return false;
- }
- }
- add_to_history = false;
- } else {
+ if (!GetRepeatPreviousCommand()) {
result.SetStatus(eReturnStatusSuccessFinishNoResult);
return true;
}
+
+ if (m_command_history.IsEmpty()) {
+ result.AppendError("empty command");
+ return false;
+ }
+
+ command_line = m_repeat_command.c_str();
+ command_string = command_line;
+ original_command_string = command_line;
+ if (m_repeat_command.empty()) {
+ result.AppendError("No auto repeat.");
+ return false;
+ }
+
+ add_to_history = false;
} else if (comment_command) {
result.SetStatus(eReturnStatusSuccessFinishNoResult);
return true;
@@ -1725,7 +1736,6 @@ bool CommandInterpreter::HandleCommand(const char *command_line,
if (error.Fail()) {
result.AppendError(error.AsCString());
- result.SetStatus(eReturnStatusFailed);
return false;
}
@@ -1852,8 +1862,6 @@ void CommandInterpreter::HandleCompletionMatches(CompletionRequest &request) {
void CommandInterpreter::HandleCompletion(CompletionRequest &request) {
- UpdateExecutionContext(nullptr);
-
// Don't complete comments, and if the line we are completing is just the
// history repeat character, substitute the appropriate history line.
llvm::StringRef first_arg = request.GetParsedLine().GetArgumentAtIndex(0);
@@ -1885,8 +1893,6 @@ CommandInterpreter::GetAutoSuggestionForCommand(llvm::StringRef line) {
return llvm::None;
}
-CommandInterpreter::~CommandInterpreter() {}
-
void CommandInterpreter::UpdatePrompt(llvm::StringRef new_prompt) {
EventSP prompt_change_event_sp(
new Event(eBroadcastBitResetPrompt, new EventDataBytes(new_prompt)));
@@ -1997,7 +2003,6 @@ void CommandInterpreter::BuildAliasCommandArgs(CommandObject *alias_cmd_obj,
"need at least %d arguments to use "
"this alias.\n",
index);
- result.SetStatus(eReturnStatusFailed);
return;
} else {
// Find and remove cmd_args.GetArgumentAtIndex(i) from raw_input_string
@@ -2128,13 +2133,12 @@ void CommandInterpreter::SourceInitFile(FileSpec file,
// broadcasting of the commands back to any appropriate listener (see
// CommandObjectSource::Execute for more details).
const bool saved_batch = SetBatchCommandMode(true);
- ExecutionContext *ctx = nullptr;
CommandInterpreterRunOptions options;
options.SetSilent(true);
options.SetPrintErrors(true);
options.SetStopOnError(false);
options.SetStopOnContinue(true);
- HandleCommandsFromFile(file, ctx, options, result);
+ HandleCommandsFromFile(file, options, result);
SetBatchCommandMode(saved_batch);
}
@@ -2168,7 +2172,6 @@ void CommandInterpreter::SourceInitFileCwd(CommandReturnObject &result) {
result.SetStatus(eReturnStatusSuccessFinishNoResult);
} else {
result.AppendError(InitFileWarning);
- result.SetStatus(eReturnStatusFailed);
}
}
}
@@ -2225,7 +2228,8 @@ PlatformSP CommandInterpreter::GetPlatform(bool prefer_target_platform) {
}
bool CommandInterpreter::DidProcessStopAbnormally() const {
- TargetSP target_sp = m_debugger.GetTargetList().GetSelectedTarget();
+ auto exe_ctx = GetExecutionContext();
+ TargetSP target_sp = exe_ctx.GetTargetSP();
if (!target_sp)
return false;
@@ -2242,7 +2246,9 @@ bool CommandInterpreter::DidProcessStopAbnormally() const {
return false;
const StopReason reason = stop_info->GetStopReason();
- if (reason == eStopReasonException || reason == eStopReasonInstrumentation)
+ if (reason == eStopReasonException ||
+ reason == eStopReasonInstrumentation ||
+ reason == eStopReasonProcessorTrace)
return true;
if (reason == eStopReasonSignal) {
@@ -2263,9 +2269,19 @@ bool CommandInterpreter::DidProcessStopAbnormally() const {
return false;
}
+void
+CommandInterpreter::HandleCommands(const StringList &commands,
+ const ExecutionContext &override_context,
+ const CommandInterpreterRunOptions &options,
+ CommandReturnObject &result) {
+
+ OverrideExecutionContext(override_context);
+ HandleCommands(commands, options, result);
+ RestoreExecutionContext();
+}
+
void CommandInterpreter::HandleCommands(const StringList &commands,
- ExecutionContext *override_context,
- CommandInterpreterRunOptions &options,
+ const CommandInterpreterRunOptions &options,
CommandReturnObject &result) {
size_t num_lines = commands.GetSize();
@@ -2275,13 +2291,6 @@ void CommandInterpreter::HandleCommands(const StringList &commands,
bool old_async_execution = m_debugger.GetAsyncExecution();
- // If we've been given an execution context, set it at the start, but don't
- // keep resetting it or we will cause series of commands that change the
- // context, then do an operation that relies on that context to fail.
-
- if (override_context != nullptr)
- UpdateExecutionContext(override_context);
-
if (!options.GetStopOnContinue()) {
m_debugger.SetAsyncExecution(false);
}
@@ -2299,20 +2308,14 @@ void CommandInterpreter::HandleCommands(const StringList &commands,
CommandReturnObject tmp_result(m_debugger.GetUseColor());
tmp_result.SetInteractive(result.GetInteractive());
-
- // If override_context is not NULL, pass no_context_switching = true for
- // HandleCommand() since we updated our context already.
+ tmp_result.SetSuppressImmediateOutput(true);
// We might call into a regex or alias command, in which case the
// add_to_history will get lost. This m_command_source_depth dingus is the
// way we turn off adding to the history in that case, so set it up here.
if (!options.GetAddToHistory())
m_command_source_depth++;
- bool success =
- HandleCommand(cmd, options.m_add_to_history, tmp_result,
- nullptr, /* override_context */
- true, /* repeat_on_empty_command */
- override_context != nullptr /* no_context_switching */);
+ bool success = HandleCommand(cmd, options.m_add_to_history, tmp_result);
if (!options.GetAddToHistory())
m_command_source_depth--;
@@ -2330,7 +2333,6 @@ void CommandInterpreter::HandleCommands(const StringList &commands,
"Aborting reading of commands after command #%" PRIu64
": '%s' failed with %s",
(uint64_t)idx, cmd, error_msg.str().c_str());
- result.SetStatus(eReturnStatusFailed);
m_debugger.SetAsyncExecution(old_async_execution);
return;
} else if (options.GetPrintResults()) {
@@ -2413,13 +2415,19 @@ enum {
};
void CommandInterpreter::HandleCommandsFromFile(
- FileSpec &cmd_file, ExecutionContext *context,
- CommandInterpreterRunOptions &options, CommandReturnObject &result) {
+ FileSpec &cmd_file, const ExecutionContext &context,
+ const CommandInterpreterRunOptions &options, CommandReturnObject &result) {
+ OverrideExecutionContext(context);
+ HandleCommandsFromFile(cmd_file, options, result);
+ RestoreExecutionContext();
+}
+
+void CommandInterpreter::HandleCommandsFromFile(FileSpec &cmd_file,
+ const CommandInterpreterRunOptions &options, CommandReturnObject &result) {
if (!FileSystem::Instance().Exists(cmd_file)) {
result.AppendErrorWithFormat(
"Error reading commands from file %s - file not found.\n",
cmd_file.GetFilename().AsCString("<Unknown>"));
- result.SetStatus(eReturnStatusFailed);
return;
}
@@ -2431,7 +2439,6 @@ void CommandInterpreter::HandleCommandsFromFile(
result.AppendErrorWithFormatv(
"error: an error occurred read file '{0}': {1}\n", cmd_file_path,
llvm::fmt_consume(input_file_up.takeError()));
- result.SetStatus(eReturnStatusFailed);
return;
}
FileSP input_file_sp = FileSP(std::move(input_file_up.get()));
@@ -2678,7 +2685,7 @@ void CommandInterpreter::FindCommandsForApropos(
const bool search_long_help = false;
const bool search_syntax = false;
const bool search_options = false;
- if (command_name.contains_lower(search_word) ||
+ if (command_name.contains_insensitive(search_word) ||
cmd_obj->HelpTextContainsWord(search_word, search_short_help,
search_long_help, search_syntax,
search_options)) {
@@ -2715,23 +2722,24 @@ void CommandInterpreter::FindCommandsForApropos(llvm::StringRef search_word,
m_alias_dict);
}
-void CommandInterpreter::UpdateExecutionContext(
- ExecutionContext *override_context) {
- if (override_context != nullptr) {
- m_exe_ctx_ref = *override_context;
- } else {
- const bool adopt_selected = true;
- m_exe_ctx_ref.SetTargetPtr(m_debugger.GetSelectedTarget().get(),
- adopt_selected);
- }
+ExecutionContext CommandInterpreter::GetExecutionContext() const {
+ return !m_overriden_exe_contexts.empty()
+ ? m_overriden_exe_contexts.top()
+ : m_debugger.GetSelectedExecutionContext();
}
-void CommandInterpreter::GetProcessOutput() {
- TargetSP target_sp(m_debugger.GetTargetList().GetSelectedTarget());
- if (!target_sp)
- return;
+void CommandInterpreter::OverrideExecutionContext(
+ const ExecutionContext &override_context) {
+ m_overriden_exe_contexts.push(override_context);
+}
+
+void CommandInterpreter::RestoreExecutionContext() {
+ if (!m_overriden_exe_contexts.empty())
+ m_overriden_exe_contexts.pop();
+}
- if (ProcessSP process_sp = target_sp->GetProcessSP())
+void CommandInterpreter::GetProcessOutput() {
+ if (ProcessSP process_sp = GetExecutionContext().GetProcessSP())
m_debugger.FlushProcessOutput(*process_sp, /*flush_stdout*/ true,
/*flush_stderr*/ true);
}
@@ -2831,6 +2839,11 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler,
StartHandlingCommand();
+ OverrideExecutionContext(m_debugger.GetSelectedExecutionContext());
+ auto finalize = llvm::make_scope_exit([this]() {
+ RestoreExecutionContext();
+ });
+
lldb_private::CommandReturnObject result(m_debugger.GetUseColor());
HandleCommand(line.c_str(), eLazyBoolCalculate, result);
@@ -2922,9 +2935,15 @@ bool CommandInterpreter::SaveTranscript(
std::string now = llvm::to_string(std::chrono::system_clock::now());
std::replace(now.begin(), now.end(), ' ', '_');
const std::string file_name = "lldb_session_" + now + ".log";
- FileSpec tmp = HostInfo::GetGlobalTempDir();
- tmp.AppendPathComponent(file_name);
- output_file = tmp.GetPath();
+
+ FileSpec save_location = GetSaveSessionDirectory();
+
+ if (!save_location)
+ save_location = HostInfo::GetGlobalTempDir();
+
+ FileSystem::Instance().Resolve(save_location);
+ save_location.AppendPathComponent(file_name);
+ output_file = save_location.GetPath();
}
auto error_out = [&](llvm::StringRef error_message, std::string description) {
@@ -2955,6 +2974,7 @@ bool CommandInterpreter::SaveTranscript(
return error_out("Unable to write to destination file",
"Bytes written do not match transcript size.");
+ result.SetStatus(eReturnStatusSuccessFinishNoResult);
result.AppendMessageWithFormat("Session's transcripts saved to %s\n",
output_file->c_str());
@@ -2973,9 +2993,9 @@ void CommandInterpreter::GetLLDBCommandsFromIOHandler(
IOHandlerSP io_handler_sp(
new IOHandlerEditline(debugger, IOHandler::Type::CommandList,
"lldb", // Name of input reader for history
- llvm::StringRef::withNullAsEmpty(prompt), // Prompt
- llvm::StringRef(), // Continuation prompt
- true, // Get multiple lines
+ llvm::StringRef(prompt), // Prompt
+ llvm::StringRef(), // Continuation prompt
+ true, // Get multiple lines
debugger.GetUseColor(),
0, // Don't show line numbers
delegate, // IOHandlerDelegate
@@ -2993,9 +3013,9 @@ void CommandInterpreter::GetPythonCommandsFromIOHandler(
IOHandlerSP io_handler_sp(
new IOHandlerEditline(debugger, IOHandler::Type::PythonCode,
"lldb-python", // Name of input reader for history
- llvm::StringRef::withNullAsEmpty(prompt), // Prompt
- llvm::StringRef(), // Continuation prompt
- true, // Get multiple lines
+ llvm::StringRef(prompt), // Prompt
+ llvm::StringRef(), // Continuation prompt
+ true, // Get multiple lines
debugger.GetUseColor(),
0, // Don't show line numbers
delegate, // IOHandlerDelegate
@@ -3088,7 +3108,6 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line,
CommandObject *cmd_obj = nullptr;
StreamString revised_command_line;
bool wants_raw_input = false;
- size_t actual_cmd_name_len = 0;
std::string next_word;
StringList matches;
bool done = false;
@@ -3110,12 +3129,10 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line,
revised_command_line.Printf("%s", alias_result.c_str());
if (cmd_obj) {
wants_raw_input = cmd_obj->WantsRawCommandString();
- actual_cmd_name_len = cmd_obj->GetCommandName().size();
}
} else {
if (cmd_obj) {
llvm::StringRef cmd_name = cmd_obj->GetCommandName();
- actual_cmd_name_len += cmd_name.size();
revised_command_line.Printf("%s", cmd_name.str().c_str());
wants_raw_input = cmd_obj->WantsRawCommandString();
} else {
@@ -3130,7 +3147,6 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line,
// The subcommand's name includes the parent command's name, so
// restart rather than append to the revised_command_line.
llvm::StringRef sub_cmd_name = sub_cmd_obj->GetCommandName();
- actual_cmd_name_len = sub_cmd_name.size() + 1;
revised_command_line.Clear();
revised_command_line.Printf("%s", sub_cmd_name.str().c_str());
cmd_obj = sub_cmd_obj;
@@ -3174,7 +3190,6 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line,
result.AppendErrorWithFormat("'%s' is not a valid command.\n",
next_word.c_str());
}
- result.SetStatus(eReturnStatusFailed);
return nullptr;
}
@@ -3186,7 +3201,6 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line,
cmd_obj->GetCommandName().str().c_str(),
next_word.empty() ? "" : next_word.c_str(),
next_word.empty() ? " -- " : " ", suffix.c_str());
- result.SetStatus(eReturnStatusFailed);
return nullptr;
}
} else {
@@ -3222,7 +3236,6 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line,
result.AppendErrorWithFormat(
"the '%s' command doesn't support the --gdb-format option\n",
cmd_obj->GetCommandName().str().c_str());
- result.SetStatus(eReturnStatusFailed);
return nullptr;
}
}
@@ -3231,7 +3244,6 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line,
default:
result.AppendErrorWithFormat(
"unknown command shorthand suffix: '%s'\n", suffix.c_str());
- result.SetStatus(eReturnStatusFailed);
return nullptr;
}
}
diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp
index 71adf8c39f1b..a7dcd5682701 100644
--- a/lldb/source/Interpreter/CommandObject.cpp
+++ b/lldb/source/Interpreter/CommandObject.cpp
@@ -12,8 +12,8 @@
#include <sstream>
#include <string>
-#include <ctype.h>
-#include <stdlib.h>
+#include <cctype>
+#include <cstdlib>
#include "lldb/Core/Address.h"
#include "lldb/Interpreter/Options.h"
@@ -42,15 +42,12 @@ CommandObject::CommandObject(CommandInterpreter &interpreter,
llvm::StringRef name, llvm::StringRef help,
llvm::StringRef syntax, uint32_t flags)
: m_interpreter(interpreter), m_cmd_name(std::string(name)),
- m_cmd_help_short(), m_cmd_help_long(), m_cmd_syntax(), m_flags(flags),
- m_arguments(), m_deprecated_command_override_callback(nullptr),
+ m_flags(flags), m_deprecated_command_override_callback(nullptr),
m_command_override_callback(nullptr), m_command_override_baton(nullptr) {
m_cmd_help_short = std::string(help);
m_cmd_syntax = std::string(syntax);
}
-CommandObject::~CommandObject() {}
-
Debugger &CommandObject::GetDebugger() { return m_interpreter.GetDebugger(); }
llvm::StringRef CommandObject::GetHelp() { return m_cmd_help_short; }
@@ -222,7 +219,6 @@ bool CommandObject::CheckRequirements(CommandReturnObject &result) {
// A process that is not running is considered paused.
if (GetFlags().Test(eCommandProcessMustBeLaunched)) {
result.AppendError("Process must exist.");
- result.SetStatus(eReturnStatusFailed);
return false;
}
} else {
@@ -242,7 +238,6 @@ bool CommandObject::CheckRequirements(CommandReturnObject &result) {
case eStateUnloaded:
if (GetFlags().Test(eCommandProcessMustBeLaunched)) {
result.AppendError("Process must be launched.");
- result.SetStatus(eReturnStatusFailed);
return false;
}
break;
@@ -252,7 +247,6 @@ bool CommandObject::CheckRequirements(CommandReturnObject &result) {
if (GetFlags().Test(eCommandProcessMustBePaused)) {
result.AppendError("Process is running. Use 'process interrupt' to "
"pause execution.");
- result.SetStatus(eReturnStatusFailed);
return false;
}
}
@@ -262,7 +256,7 @@ bool CommandObject::CheckRequirements(CommandReturnObject &result) {
if (GetFlags().Test(eCommandProcessMustBeTraced)) {
Target *target = m_exe_ctx.GetTargetPtr();
if (target && !target->GetTrace()) {
- result.SetError("Process is not being traced.");
+ result.AppendError("Process is not being traced.");
return false;
}
}
@@ -322,11 +316,11 @@ bool CommandObject::HelpTextContainsWord(llvm::StringRef search_word,
llvm::StringRef long_help = GetHelpLong();
llvm::StringRef syntax_help = GetSyntax();
- if (search_short_help && short_help.contains_lower(search_word))
+ if (search_short_help && short_help.contains_insensitive(search_word))
found_word = true;
- else if (search_long_help && long_help.contains_lower(search_word))
+ else if (search_long_help && long_help.contains_insensitive(search_word))
found_word = true;
- else if (search_syntax && syntax_help.contains_lower(search_word))
+ else if (search_syntax && syntax_help.contains_insensitive(search_word))
found_word = true;
if (!found_word && search_options && GetOptions() != nullptr) {
@@ -336,7 +330,7 @@ bool CommandObject::HelpTextContainsWord(llvm::StringRef search_word,
GetCommandInterpreter().GetDebugger().GetTerminalWidth());
if (!usage_help.Empty()) {
llvm::StringRef usage_text = usage_help.GetString();
- if (usage_text.contains_lower(search_word))
+ if (usage_text.contains_insensitive(search_word))
found_word = true;
}
}
@@ -354,7 +348,6 @@ bool CommandObject::ParseOptionsAndNotify(Args &args,
Status error(group_options.NotifyOptionParsingFinished(&exe_ctx));
if (error.Fail()) {
result.AppendError(error.AsCString());
- result.SetStatus(eReturnStatusFailed);
return false;
}
return true;
@@ -1129,7 +1122,8 @@ CommandObject::ArgumentTableEntry CommandObject::g_arguments_data[] = {
{ eArgRawInput, "raw-input", CommandCompletions::eNoCompletion, { nullptr, false }, "Free-form text passed to a command without prior interpretation, allowing spaces without requiring quotes. To pass arguments and free form text put two dashes ' -- ' between the last argument and any raw input." },
{ eArgTypeCommand, "command", CommandCompletions::eNoCompletion, { nullptr, false }, "An LLDB Command line command." },
{ eArgTypeColumnNum, "column", CommandCompletions::eNoCompletion, { nullptr, false }, "Column number in a source file." },
- { eArgTypeModuleUUID, "module-uuid", CommandCompletions::eModuleUUIDCompletion, { nullptr, false }, "A module UUID value." }
+ { eArgTypeModuleUUID, "module-uuid", CommandCompletions::eModuleUUIDCompletion, { nullptr, false }, "A module UUID value." },
+ { eArgTypeSaveCoreStyle, "corefile-style", CommandCompletions::eNoCompletion, { nullptr, false }, "The type of corefile that lldb will try to create, dependant on this target's capabilities." }
// clang-format on
};
diff --git a/lldb/source/Interpreter/CommandReturnObject.cpp b/lldb/source/Interpreter/CommandReturnObject.cpp
index 6f3732e35078..506b0d6e7cde 100644
--- a/lldb/source/Interpreter/CommandReturnObject.cpp
+++ b/lldb/source/Interpreter/CommandReturnObject.cpp
@@ -41,13 +41,11 @@ static void DumpStringToStreamWithNewline(Stream &strm, const std::string &s) {
}
CommandReturnObject::CommandReturnObject(bool colors)
- : m_out_stream(colors), m_err_stream(colors),
- m_status(eReturnStatusStarted), m_did_change_process_state(false),
- m_interactive(true) {}
-
-CommandReturnObject::~CommandReturnObject() {}
+ : m_out_stream(colors), m_err_stream(colors) {}
void CommandReturnObject::AppendErrorWithFormat(const char *format, ...) {
+ SetStatus(eReturnStatusFailed);
+
if (!format)
return;
va_list args;
@@ -90,52 +88,33 @@ void CommandReturnObject::AppendWarningWithFormat(const char *format, ...) {
void CommandReturnObject::AppendMessage(llvm::StringRef in_string) {
if (in_string.empty())
return;
- GetOutputStream() << in_string << "\n";
+ GetOutputStream() << in_string.rtrim() << '\n';
}
void CommandReturnObject::AppendWarning(llvm::StringRef in_string) {
if (in_string.empty())
return;
- warning(GetErrorStream()) << in_string << '\n';
-}
-
-// Similar to AppendWarning, but do not prepend 'warning: ' to message, and
-// don't append "\n" to the end of it.
-
-void CommandReturnObject::AppendRawWarning(llvm::StringRef in_string) {
- if (in_string.empty())
- return;
- GetErrorStream() << in_string;
+ warning(GetErrorStream()) << in_string.rtrim() << '\n';
}
void CommandReturnObject::AppendError(llvm::StringRef in_string) {
+ SetStatus(eReturnStatusFailed);
if (in_string.empty())
return;
- error(GetErrorStream()) << in_string << '\n';
+ error(GetErrorStream()) << in_string.rtrim() << '\n';
}
void CommandReturnObject::SetError(const Status &error,
const char *fallback_error_cstr) {
- const char *error_cstr = error.AsCString();
- if (error_cstr == nullptr)
- error_cstr = fallback_error_cstr;
- SetError(error_cstr);
-}
-
-void CommandReturnObject::SetError(llvm::StringRef error_str) {
- if (error_str.empty())
- return;
-
- AppendError(error_str);
- SetStatus(eReturnStatusFailed);
+ AppendError(error.AsCString(fallback_error_cstr));
}
// Similar to AppendError, but do not prepend 'Status: ' to message, and don't
// append "\n" to the end of it.
void CommandReturnObject::AppendRawError(llvm::StringRef in_string) {
- if (in_string.empty())
- return;
+ SetStatus(eReturnStatusFailed);
+ assert(!in_string.empty() && "Expected a non-empty error message");
GetErrorStream() << in_string;
}
@@ -162,6 +141,7 @@ void CommandReturnObject::Clear() {
static_cast<StreamString *>(stream_sp.get())->Clear();
m_status = eReturnStatusStarted;
m_did_change_process_state = false;
+ m_suppress_immediate_output = false;
m_interactive = true;
}
@@ -176,3 +156,11 @@ void CommandReturnObject::SetDidChangeProcessState(bool b) {
bool CommandReturnObject::GetInteractive() const { return m_interactive; }
void CommandReturnObject::SetInteractive(bool b) { m_interactive = b; }
+
+bool CommandReturnObject::GetSuppressImmediateOutput() const {
+ return m_suppress_immediate_output;
+}
+
+void CommandReturnObject::SetSuppressImmediateOutput(bool b) {
+ m_suppress_immediate_output = b;
+}
diff --git a/lldb/source/Interpreter/InterpreterProperties.td b/lldb/source/Interpreter/InterpreterProperties.td
index e5346d14a6e1..1c6f0206c489 100644
--- a/lldb/source/Interpreter/InterpreterProperties.td
+++ b/lldb/source/Interpreter/InterpreterProperties.td
@@ -13,6 +13,9 @@ let Definition = "interpreter" in {
Global,
DefaultFalse,
Desc<"If true, LLDB will save the session's transcripts before quitting.">;
+ def SaveSessionDirectory: Property<"save-session-directory", "FileSpec">,
+ DefaultStringValue<"">,
+ Desc<"A path where LLDB will save the session's transcripts. This is particularly useful when you can't set the session file, for example when using `save-session-on-quit`.">;
def StopCmdSourceOnError: Property<"stop-command-source-on-error", "Boolean">,
Global,
DefaultTrue,
@@ -29,4 +32,8 @@ let Definition = "interpreter" in {
Global,
DefaultTrue,
Desc<"If true, commands will be echoed even if they are pure comment lines.">;
+ def RepeatPreviousCommand: Property<"repeat-previous-command", "Boolean">,
+ Global,
+ DefaultTrue,
+ Desc<"If true, LLDB will repeat the previous command if no command was passed to the interpreter. If false, LLDB won't repeat the previous command but only return a new prompt.">;
}
diff --git a/lldb/source/Interpreter/OptionArgParser.cpp b/lldb/source/Interpreter/OptionArgParser.cpp
index 3dcb30e846d9..93b01abde4bb 100644
--- a/lldb/source/Interpreter/OptionArgParser.cpp
+++ b/lldb/source/Interpreter/OptionArgParser.cpp
@@ -20,11 +20,11 @@ bool OptionArgParser::ToBoolean(llvm::StringRef ref, bool fail_value,
if (success_ptr)
*success_ptr = true;
ref = ref.trim();
- if (ref.equals_lower("false") || ref.equals_lower("off") ||
- ref.equals_lower("no") || ref.equals_lower("0")) {
+ if (ref.equals_insensitive("false") || ref.equals_insensitive("off") ||
+ ref.equals_insensitive("no") || ref.equals_insensitive("0")) {
return false;
- } else if (ref.equals_lower("true") || ref.equals_lower("on") ||
- ref.equals_lower("yes") || ref.equals_lower("1")) {
+ } else if (ref.equals_insensitive("true") || ref.equals_insensitive("on") ||
+ ref.equals_insensitive("yes") || ref.equals_insensitive("1")) {
return true;
}
if (success_ptr)
@@ -125,13 +125,13 @@ lldb::ScriptLanguage OptionArgParser::ToScriptLanguage(
if (success_ptr)
*success_ptr = true;
- if (s.equals_lower("python"))
+ if (s.equals_insensitive("python"))
return eScriptLanguagePython;
- if (s.equals_lower("lua"))
+ if (s.equals_insensitive("lua"))
return eScriptLanguageLua;
- if (s.equals_lower("default"))
+ if (s.equals_insensitive("default"))
return eScriptLanguageDefault;
- if (s.equals_lower("none"))
+ if (s.equals_insensitive("none"))
return eScriptLanguageNone;
if (success_ptr)
diff --git a/lldb/source/Interpreter/OptionGroupArchitecture.cpp b/lldb/source/Interpreter/OptionGroupArchitecture.cpp
index baca1c6e8068..00541b7198d2 100644
--- a/lldb/source/Interpreter/OptionGroupArchitecture.cpp
+++ b/lldb/source/Interpreter/OptionGroupArchitecture.cpp
@@ -13,10 +13,6 @@
using namespace lldb;
using namespace lldb_private;
-OptionGroupArchitecture::OptionGroupArchitecture() : m_arch_str() {}
-
-OptionGroupArchitecture::~OptionGroupArchitecture() {}
-
static constexpr OptionDefinition g_option_table[] = {
{LLDB_OPT_SET_1, false, "arch", 'a', OptionParser::eRequiredArgument,
nullptr, {}, 0, eArgTypeArchitecture,
diff --git a/lldb/source/Interpreter/OptionGroupBoolean.cpp b/lldb/source/Interpreter/OptionGroupBoolean.cpp
index 3482e784ca0c..3f73893fca96 100644
--- a/lldb/source/Interpreter/OptionGroupBoolean.cpp
+++ b/lldb/source/Interpreter/OptionGroupBoolean.cpp
@@ -33,8 +33,6 @@ OptionGroupBoolean::OptionGroupBoolean(uint32_t usage_mask, bool required,
m_option_definition.usage_text = usage_text;
}
-OptionGroupBoolean::~OptionGroupBoolean() {}
-
Status OptionGroupBoolean::SetOptionValue(uint32_t option_idx,
llvm::StringRef option_value,
ExecutionContext *execution_context) {
diff --git a/lldb/source/Interpreter/OptionGroupFile.cpp b/lldb/source/Interpreter/OptionGroupFile.cpp
index 9d9be5b6f178..12ade1855829 100644
--- a/lldb/source/Interpreter/OptionGroupFile.cpp
+++ b/lldb/source/Interpreter/OptionGroupFile.cpp
@@ -17,8 +17,7 @@ OptionGroupFile::OptionGroupFile(uint32_t usage_mask, bool required,
const char *long_option, int short_option,
uint32_t completion_type,
lldb::CommandArgumentType argument_type,
- const char *usage_text)
- : m_file() {
+ const char *usage_text) {
m_option_definition.usage_mask = usage_mask;
m_option_definition.required = required;
m_option_definition.long_option = long_option;
@@ -31,8 +30,6 @@ OptionGroupFile::OptionGroupFile(uint32_t usage_mask, bool required,
m_option_definition.usage_text = usage_text;
}
-OptionGroupFile::~OptionGroupFile() {}
-
Status OptionGroupFile::SetOptionValue(uint32_t option_idx,
llvm::StringRef option_arg,
ExecutionContext *execution_context) {
@@ -62,7 +59,7 @@ OptionGroupFileList::OptionGroupFileList(
m_option_definition.usage_text = usage_text;
}
-OptionGroupFileList::~OptionGroupFileList() {}
+OptionGroupFileList::~OptionGroupFileList() = default;
Status
OptionGroupFileList::SetOptionValue(uint32_t option_idx,
diff --git a/lldb/source/Interpreter/OptionGroupFormat.cpp b/lldb/source/Interpreter/OptionGroupFormat.cpp
index 0052f72b0550..1cc5e70282c1 100644
--- a/lldb/source/Interpreter/OptionGroupFormat.cpp
+++ b/lldb/source/Interpreter/OptionGroupFormat.cpp
@@ -24,8 +24,6 @@ OptionGroupFormat::OptionGroupFormat(lldb::Format default_format,
m_count(default_count, default_count), m_prev_gdb_format('x'),
m_prev_gdb_size('w') {}
-OptionGroupFormat::~OptionGroupFormat() {}
-
static constexpr OptionDefinition g_option_table[] = {
{LLDB_OPT_SET_1, false, "format", 'f', OptionParser::eRequiredArgument,
nullptr, {}, 0, eArgTypeFormat,
diff --git a/lldb/source/Interpreter/OptionGroupOutputFile.cpp b/lldb/source/Interpreter/OptionGroupOutputFile.cpp
index 65105c3e0180..6a626bd63014 100644
--- a/lldb/source/Interpreter/OptionGroupOutputFile.cpp
+++ b/lldb/source/Interpreter/OptionGroupOutputFile.cpp
@@ -13,10 +13,7 @@
using namespace lldb;
using namespace lldb_private;
-OptionGroupOutputFile::OptionGroupOutputFile()
- : m_file(), m_append(false, false) {}
-
-OptionGroupOutputFile::~OptionGroupOutputFile() {}
+OptionGroupOutputFile::OptionGroupOutputFile() : m_append(false, false) {}
static const uint32_t SHORT_OPTION_APND = 0x61706e64; // 'apnd'
diff --git a/lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp b/lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp
index 217dab2ef63b..a01c190266dd 100644
--- a/lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp
+++ b/lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp
@@ -13,12 +13,10 @@
using namespace lldb;
using namespace lldb_private;
-OptionGroupPythonClassWithDict::OptionGroupPythonClassWithDict
- (const char *class_use,
- bool is_class,
- int class_option,
- int key_option,
- int value_option) : OptionGroup(), m_is_class(is_class) {
+OptionGroupPythonClassWithDict::OptionGroupPythonClassWithDict(
+ const char *class_use, bool is_class, int class_option, int key_option,
+ int value_option, uint16_t required_options)
+ : m_is_class(is_class), m_required_options(required_options) {
m_key_usage_text.assign("The key for a key/value pair passed to the "
"implementation of a ");
m_key_usage_text.append(class_use);
@@ -36,7 +34,7 @@ OptionGroupPythonClassWithDict::OptionGroupPythonClassWithDict
m_class_usage_text.append(".");
m_option_definition[0].usage_mask = LLDB_OPT_SET_1;
- m_option_definition[0].required = true;
+ m_option_definition[0].required = m_required_options.Test(eScriptClass);
m_option_definition[0].long_option = "script-class";
m_option_definition[0].short_option = class_option;
m_option_definition[0].validator = nullptr;
@@ -47,7 +45,7 @@ OptionGroupPythonClassWithDict::OptionGroupPythonClassWithDict
m_option_definition[0].usage_text = m_class_usage_text.data();
m_option_definition[1].usage_mask = LLDB_OPT_SET_2;
- m_option_definition[1].required = false;
+ m_option_definition[1].required = m_required_options.Test(eDictKey);
m_option_definition[1].long_option = "structured-data-key";
m_option_definition[1].short_option = key_option;
m_option_definition[1].validator = nullptr;
@@ -58,7 +56,7 @@ OptionGroupPythonClassWithDict::OptionGroupPythonClassWithDict
m_option_definition[1].usage_text = m_key_usage_text.data();
m_option_definition[2].usage_mask = LLDB_OPT_SET_2;
- m_option_definition[2].required = false;
+ m_option_definition[2].required = m_required_options.Test(eDictValue);
m_option_definition[2].long_option = "structured-data-value";
m_option_definition[2].short_option = value_option;
m_option_definition[2].validator = nullptr;
@@ -69,7 +67,7 @@ OptionGroupPythonClassWithDict::OptionGroupPythonClassWithDict
m_option_definition[2].usage_text = m_value_usage_text.data();
m_option_definition[3].usage_mask = LLDB_OPT_SET_3;
- m_option_definition[3].required = true;
+ m_option_definition[3].required = m_required_options.Test(ePythonFunction);
m_option_definition[3].long_option = "python-function";
m_option_definition[3].short_option = class_option;
m_option_definition[3].validator = nullptr;
@@ -78,11 +76,8 @@ OptionGroupPythonClassWithDict::OptionGroupPythonClassWithDict
m_option_definition[3].completion_type = 0;
m_option_definition[3].argument_type = eArgTypePythonFunction;
m_option_definition[3].usage_text = m_class_usage_text.data();
-
}
-OptionGroupPythonClassWithDict::~OptionGroupPythonClassWithDict() {}
-
Status OptionGroupPythonClassWithDict::SetOptionValue(
uint32_t option_idx,
llvm::StringRef option_arg,
diff --git a/lldb/source/Interpreter/OptionGroupString.cpp b/lldb/source/Interpreter/OptionGroupString.cpp
index c9f78eb953f4..75faaac9f6dd 100644
--- a/lldb/source/Interpreter/OptionGroupString.cpp
+++ b/lldb/source/Interpreter/OptionGroupString.cpp
@@ -32,8 +32,6 @@ OptionGroupString::OptionGroupString(uint32_t usage_mask, bool required,
m_option_definition.usage_text = usage_text;
}
-OptionGroupString::~OptionGroupString() {}
-
Status OptionGroupString::SetOptionValue(uint32_t option_idx,
llvm::StringRef option_arg,
ExecutionContext *execution_context) {
diff --git a/lldb/source/Interpreter/OptionGroupUInt64.cpp b/lldb/source/Interpreter/OptionGroupUInt64.cpp
index 309855d4718c..486941a7555a 100644
--- a/lldb/source/Interpreter/OptionGroupUInt64.cpp
+++ b/lldb/source/Interpreter/OptionGroupUInt64.cpp
@@ -32,8 +32,6 @@ OptionGroupUInt64::OptionGroupUInt64(uint32_t usage_mask, bool required,
m_option_definition.usage_text = usage_text;
}
-OptionGroupUInt64::~OptionGroupUInt64() {}
-
Status OptionGroupUInt64::SetOptionValue(uint32_t option_idx,
llvm::StringRef option_arg,
ExecutionContext *execution_context) {
diff --git a/lldb/source/Interpreter/OptionGroupUUID.cpp b/lldb/source/Interpreter/OptionGroupUUID.cpp
index dc6f4139896f..5b4c24a0a32b 100644
--- a/lldb/source/Interpreter/OptionGroupUUID.cpp
+++ b/lldb/source/Interpreter/OptionGroupUUID.cpp
@@ -13,10 +13,6 @@
using namespace lldb;
using namespace lldb_private;
-OptionGroupUUID::OptionGroupUUID() : m_uuid() {}
-
-OptionGroupUUID::~OptionGroupUUID() {}
-
static constexpr OptionDefinition g_option_table[] = {
{LLDB_OPT_SET_1, false, "uuid", 'u', OptionParser::eRequiredArgument,
nullptr, {}, 0, eArgTypeModuleUUID, "A module UUID value."},
diff --git a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
index e0401f8987ad..04861b539650 100644
--- a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
+++ b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
@@ -19,10 +19,6 @@
using namespace lldb;
using namespace lldb_private;
-OptionGroupValueObjectDisplay::OptionGroupValueObjectDisplay() {}
-
-OptionGroupValueObjectDisplay::~OptionGroupValueObjectDisplay() {}
-
static const OptionDefinition g_option_table[] = {
{LLDB_OPT_SET_1, false, "dynamic-type", 'd',
OptionParser::eRequiredArgument, nullptr, GetDynamicValueTypes(), 0,
diff --git a/lldb/source/Interpreter/OptionGroupVariable.cpp b/lldb/source/Interpreter/OptionGroupVariable.cpp
index 9f57dbbd073e..20a521b8e44f 100644
--- a/lldb/source/Interpreter/OptionGroupVariable.cpp
+++ b/lldb/source/Interpreter/OptionGroupVariable.cpp
@@ -67,10 +67,8 @@ static Status ValidateSummaryString(const char *str, void *) {
}
OptionGroupVariable::OptionGroupVariable(bool show_frame_options)
- : OptionGroup(), include_frame_options(show_frame_options),
- summary(ValidateNamedSummary), summary_string(ValidateSummaryString) {}
-
-OptionGroupVariable::~OptionGroupVariable() {}
+ : include_frame_options(show_frame_options), summary(ValidateNamedSummary),
+ summary_string(ValidateSummaryString) {}
Status
OptionGroupVariable::SetOptionValue(uint32_t option_idx,
diff --git a/lldb/source/Interpreter/OptionGroupWatchpoint.cpp b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
index 07013b5b78fe..eb9842add28c 100644
--- a/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
+++ b/lldb/source/Interpreter/OptionGroupWatchpoint.cpp
@@ -74,10 +74,6 @@ bool OptionGroupWatchpoint::IsWatchSizeSupported(uint32_t watch_size) {
return false;
}
-OptionGroupWatchpoint::OptionGroupWatchpoint() : OptionGroup() {}
-
-OptionGroupWatchpoint::~OptionGroupWatchpoint() {}
-
Status
OptionGroupWatchpoint::SetOptionValue(uint32_t option_idx,
llvm::StringRef option_arg,
diff --git a/lldb/source/Interpreter/OptionValue.cpp b/lldb/source/Interpreter/OptionValue.cpp
index 0bd9a591af67..79bdf74b6fd9 100644
--- a/lldb/source/Interpreter/OptionValue.cpp
+++ b/lldb/source/Interpreter/OptionValue.cpp
@@ -543,8 +543,7 @@ lldb::OptionValueSP OptionValue::CreateValueFromCStringForTypeMask(
}
if (value_sp)
- error = value_sp->SetValueFromString(
- llvm::StringRef::withNullAsEmpty(value_cstr), eVarSetOperationAssign);
+ error = value_sp->SetValueFromString(value_cstr, eVarSetOperationAssign);
else
error.SetErrorString("unsupported type mask");
return value_sp;
@@ -568,6 +567,12 @@ bool OptionValue::DumpQualifiedName(Stream &strm) const {
return dumped_something;
}
+OptionValueSP OptionValue::DeepCopy(const OptionValueSP &new_parent) const {
+ auto clone = Clone();
+ clone->SetParent(new_parent);
+ return clone;
+}
+
void OptionValue::AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request) {}
diff --git a/lldb/source/Interpreter/OptionValueArch.cpp b/lldb/source/Interpreter/OptionValueArch.cpp
index ac78ee64a9d7..4d1e2c7869f3 100644
--- a/lldb/source/Interpreter/OptionValueArch.cpp
+++ b/lldb/source/Interpreter/OptionValueArch.cpp
@@ -64,10 +64,6 @@ Status OptionValueArch::SetValueFromString(llvm::StringRef value,
return error;
}
-lldb::OptionValueSP OptionValueArch::DeepCopy() const {
- return OptionValueSP(new OptionValueArch(*this));
-}
-
void OptionValueArch::AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request) {
CommandCompletions::InvokeCommonCompletionCallbacks(
diff --git a/lldb/source/Interpreter/OptionValueArgs.cpp b/lldb/source/Interpreter/OptionValueArgs.cpp
index 9e7774a231c7..bdb5f486835a 100644
--- a/lldb/source/Interpreter/OptionValueArgs.cpp
+++ b/lldb/source/Interpreter/OptionValueArgs.cpp
@@ -13,9 +13,9 @@
using namespace lldb;
using namespace lldb_private;
-size_t OptionValueArgs::GetArgs(Args &args) {
+size_t OptionValueArgs::GetArgs(Args &args) const {
args.Clear();
- for (auto value : m_values) {
+ for (const auto &value : m_values) {
llvm::StringRef string_value = value->GetStringValue();
if (!string_value.empty())
args.AppendArgument(string_value);
diff --git a/lldb/source/Interpreter/OptionValueArray.cpp b/lldb/source/Interpreter/OptionValueArray.cpp
index 0b293ccfc248..b1545bdebf10 100644
--- a/lldb/source/Interpreter/OptionValueArray.cpp
+++ b/lldb/source/Interpreter/OptionValueArray.cpp
@@ -303,15 +303,16 @@ Status OptionValueArray::SetArgs(const Args &args, VarSetOperationType op) {
return error;
}
-lldb::OptionValueSP OptionValueArray::DeepCopy() const {
- OptionValueArray *copied_array =
- new OptionValueArray(m_type_mask, m_raw_value_dump);
- lldb::OptionValueSP copied_value_sp(copied_array);
- *static_cast<OptionValue *>(copied_array) = *this;
- copied_array->m_callback = m_callback;
- const uint32_t size = m_values.size();
- for (uint32_t i = 0; i < size; ++i) {
- copied_array->AppendValue(m_values[i]->DeepCopy());
- }
- return copied_value_sp;
+OptionValueSP
+OptionValueArray::DeepCopy(const OptionValueSP &new_parent) const {
+ auto copy_sp = OptionValue::DeepCopy(new_parent);
+ // copy_sp->GetAsArray cannot be used here as it doesn't work for derived
+ // types that override GetType returning a different value.
+ auto *array_value_ptr = static_cast<OptionValueArray *>(copy_sp.get());
+ lldbassert(array_value_ptr);
+
+ for (auto &value : array_value_ptr->m_values)
+ value = value->DeepCopy(copy_sp);
+
+ return copy_sp;
}
diff --git a/lldb/source/Interpreter/OptionValueBoolean.cpp b/lldb/source/Interpreter/OptionValueBoolean.cpp
index 24ae3f673bf9..62845c14bd13 100644
--- a/lldb/source/Interpreter/OptionValueBoolean.cpp
+++ b/lldb/source/Interpreter/OptionValueBoolean.cpp
@@ -67,10 +67,6 @@ Status OptionValueBoolean::SetValueFromString(llvm::StringRef value_str,
return error;
}
-lldb::OptionValueSP OptionValueBoolean::DeepCopy() const {
- return OptionValueSP(new OptionValueBoolean(*this));
-}
-
void OptionValueBoolean::AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request) {
llvm::StringRef autocomplete_entries[] = {"true", "false", "on", "off",
diff --git a/lldb/source/Interpreter/OptionValueChar.cpp b/lldb/source/Interpreter/OptionValueChar.cpp
index af9a371f46d4..7fe72c9aa221 100644
--- a/lldb/source/Interpreter/OptionValueChar.cpp
+++ b/lldb/source/Interpreter/OptionValueChar.cpp
@@ -57,7 +57,3 @@ Status OptionValueChar::SetValueFromString(llvm::StringRef value,
}
return error;
}
-
-lldb::OptionValueSP OptionValueChar::DeepCopy() const {
- return OptionValueSP(new OptionValueChar(*this));
-}
diff --git a/lldb/source/Interpreter/OptionValueDictionary.cpp b/lldb/source/Interpreter/OptionValueDictionary.cpp
index 79323f502d17..26fed4a987e1 100644
--- a/lldb/source/Interpreter/OptionValueDictionary.cpp
+++ b/lldb/source/Interpreter/OptionValueDictionary.cpp
@@ -311,15 +311,16 @@ bool OptionValueDictionary::DeleteValueForKey(ConstString key) {
return false;
}
-lldb::OptionValueSP OptionValueDictionary::DeepCopy() const {
- OptionValueDictionary *copied_dict =
- new OptionValueDictionary(m_type_mask, m_raw_value_dump);
- lldb::OptionValueSP copied_value_sp(copied_dict);
- collection::const_iterator pos, end = m_values.end();
- for (pos = m_values.begin(); pos != end; ++pos) {
- StreamString strm;
- strm.Printf("%s=", pos->first.GetCString());
- copied_dict->SetValueForKey(pos->first, pos->second->DeepCopy(), true);
- }
- return copied_value_sp;
+OptionValueSP
+OptionValueDictionary::DeepCopy(const OptionValueSP &new_parent) const {
+ auto copy_sp = OptionValue::DeepCopy(new_parent);
+ // copy_sp->GetAsDictionary cannot be used here as it doesn't work for derived
+ // types that override GetType returning a different value.
+ auto *dict_value_ptr = static_cast<OptionValueDictionary *>(copy_sp.get());
+ lldbassert(dict_value_ptr);
+
+ for (auto &value : dict_value_ptr->m_values)
+ value.second = value.second->DeepCopy(copy_sp);
+
+ return copy_sp;
}
diff --git a/lldb/source/Interpreter/OptionValueEnumeration.cpp b/lldb/source/Interpreter/OptionValueEnumeration.cpp
index 9a1e08d4fba0..f75519c577c5 100644
--- a/lldb/source/Interpreter/OptionValueEnumeration.cpp
+++ b/lldb/source/Interpreter/OptionValueEnumeration.cpp
@@ -15,13 +15,10 @@ using namespace lldb_private;
OptionValueEnumeration::OptionValueEnumeration(
const OptionEnumValues &enumerators, enum_type value)
- : OptionValue(), m_current_value(value), m_default_value(value),
- m_enumerations() {
+ : m_current_value(value), m_default_value(value) {
SetEnumerations(enumerators);
}
-OptionValueEnumeration::~OptionValueEnumeration() {}
-
void OptionValueEnumeration::DumpValue(const ExecutionContext *exe_ctx,
Stream &strm, uint32_t dump_mask) {
if (dump_mask & eDumpOptionType)
@@ -98,10 +95,6 @@ void OptionValueEnumeration::SetEnumerations(
m_enumerations.Sort();
}
-lldb::OptionValueSP OptionValueEnumeration::DeepCopy() const {
- return OptionValueSP(new OptionValueEnumeration(*this));
-}
-
void OptionValueEnumeration::AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request) {
const uint32_t num_enumerators = m_enumerations.GetSize();
diff --git a/lldb/source/Interpreter/OptionValueFileColonLine.cpp b/lldb/source/Interpreter/OptionValueFileColonLine.cpp
index dac557c4248a..fb0b516c8616 100644
--- a/lldb/source/Interpreter/OptionValueFileColonLine.cpp
+++ b/lldb/source/Interpreter/OptionValueFileColonLine.cpp
@@ -21,13 +21,10 @@ using namespace lldb_private;
// I set the completer to "source file" which isn't quite right, but we can
// only usefully complete in the file name part of it so it should be good
// enough.
-OptionValueFileColonLine::OptionValueFileColonLine()
- : OptionValue(), m_file_spec(), m_line_number(LLDB_INVALID_LINE_NUMBER),
- m_column_number(LLDB_INVALID_COLUMN_NUMBER),
- m_completion_mask(CommandCompletions::eSourceFileCompletion) {}
+OptionValueFileColonLine::OptionValueFileColonLine() = default;
OptionValueFileColonLine::OptionValueFileColonLine(llvm::StringRef input)
- : OptionValue(), m_file_spec(), m_line_number(LLDB_INVALID_LINE_NUMBER),
+ : m_line_number(LLDB_INVALID_LINE_NUMBER),
m_column_number(LLDB_INVALID_COLUMN_NUMBER),
m_completion_mask(CommandCompletions::eSourceFileCompletion) {
SetValueFromString(input, eVarSetOperationAssign);
@@ -92,8 +89,8 @@ Status OptionValueFileColonLine::SetValueFromString(llvm::StringRef value,
llvm::StringRef middle_piece;
std::tie(file_name, middle_piece) = left_of_last_piece.rsplit(':');
- if (middle_piece.empty() || !llvm::to_integer(middle_piece,
- m_line_number)) {
+ if (middle_piece.empty() ||
+ !llvm::to_integer(middle_piece, m_line_number)) {
// The middle piece was empty or not an integer, so there were only two
// legit pieces; our original division was right. Reassign the file
// name and pull out the line number:
@@ -134,10 +131,6 @@ Status OptionValueFileColonLine::SetValueFromString(llvm::StringRef value,
return error;
}
-lldb::OptionValueSP OptionValueFileColonLine::DeepCopy() const {
- return OptionValueSP(new OptionValueFileColonLine(*this));
-}
-
void OptionValueFileColonLine::AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request) {
CommandCompletions::InvokeCommonCompletionCallbacks(
diff --git a/lldb/source/Interpreter/OptionValueFileSpec.cpp b/lldb/source/Interpreter/OptionValueFileSpec.cpp
index a03fd55d0385..3987a36b1b65 100644
--- a/lldb/source/Interpreter/OptionValueFileSpec.cpp
+++ b/lldb/source/Interpreter/OptionValueFileSpec.cpp
@@ -18,23 +18,17 @@
using namespace lldb;
using namespace lldb_private;
-OptionValueFileSpec::OptionValueFileSpec(bool resolve)
- : OptionValue(), m_current_value(), m_default_value(), m_data_sp(),
- m_data_mod_time(),
- m_completion_mask(CommandCompletions::eDiskFileCompletion),
- m_resolve(resolve) {}
+OptionValueFileSpec::OptionValueFileSpec(bool resolve) : m_resolve(resolve) {}
OptionValueFileSpec::OptionValueFileSpec(const FileSpec &value, bool resolve)
- : OptionValue(), m_current_value(value), m_default_value(value),
- m_data_sp(), m_data_mod_time(),
+ : m_current_value(value), m_default_value(value),
m_completion_mask(CommandCompletions::eDiskFileCompletion),
m_resolve(resolve) {}
OptionValueFileSpec::OptionValueFileSpec(const FileSpec &current_value,
const FileSpec &default_value,
bool resolve)
- : OptionValue(), m_current_value(current_value),
- m_default_value(default_value), m_data_sp(), m_data_mod_time(),
+ : m_current_value(current_value), m_default_value(default_value),
m_completion_mask(CommandCompletions::eDiskFileCompletion),
m_resolve(resolve) {}
@@ -88,10 +82,6 @@ Status OptionValueFileSpec::SetValueFromString(llvm::StringRef value,
return error;
}
-lldb::OptionValueSP OptionValueFileSpec::DeepCopy() const {
- return OptionValueSP(new OptionValueFileSpec(*this));
-}
-
void OptionValueFileSpec::AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request) {
CommandCompletions::InvokeCommonCompletionCallbacks(
diff --git a/lldb/source/Interpreter/OptionValueFileSpecList.cpp b/lldb/source/Interpreter/OptionValueFileSpecList.cpp
index f2367b1941c9..2160fd61d428 100644
--- a/lldb/source/Interpreter/OptionValueFileSpecList.cpp
+++ b/lldb/source/Interpreter/OptionValueFileSpecList.cpp
@@ -164,7 +164,7 @@ Status OptionValueFileSpecList::SetValueFromString(llvm::StringRef value,
return error;
}
-lldb::OptionValueSP OptionValueFileSpecList::DeepCopy() const {
+OptionValueSP OptionValueFileSpecList::Clone() const {
std::lock_guard<std::recursive_mutex> lock(m_mutex);
- return OptionValueSP(new OptionValueFileSpecList(m_current_value));
+ return Cloneable::Clone();
}
diff --git a/lldb/source/Interpreter/OptionValueFormat.cpp b/lldb/source/Interpreter/OptionValueFormat.cpp
index b676bed50e62..76a446d1c3bc 100644
--- a/lldb/source/Interpreter/OptionValueFormat.cpp
+++ b/lldb/source/Interpreter/OptionValueFormat.cpp
@@ -56,7 +56,3 @@ Status OptionValueFormat::SetValueFromString(llvm::StringRef value,
}
return error;
}
-
-lldb::OptionValueSP OptionValueFormat::DeepCopy() const {
- return OptionValueSP(new OptionValueFormat(*this));
-}
diff --git a/lldb/source/Interpreter/OptionValueFormatEntity.cpp b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
index 509a21752e48..64fcaf2cbc85 100644
--- a/lldb/source/Interpreter/OptionValueFormatEntity.cpp
+++ b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
@@ -15,9 +15,7 @@
using namespace lldb;
using namespace lldb_private;
-OptionValueFormatEntity::OptionValueFormatEntity(const char *default_format)
- : OptionValue(), m_current_format(), m_default_format(), m_current_entry(),
- m_default_entry() {
+OptionValueFormatEntity::OptionValueFormatEntity(const char *default_format) {
if (default_format && default_format[0]) {
llvm::StringRef default_format_str(default_format);
Status error = FormatEntity::Parse(default_format_str, m_default_entry);
@@ -111,10 +109,6 @@ Status OptionValueFormatEntity::SetValueFromString(llvm::StringRef value_str,
return error;
}
-lldb::OptionValueSP OptionValueFormatEntity::DeepCopy() const {
- return OptionValueSP(new OptionValueFormatEntity(*this));
-}
-
void OptionValueFormatEntity::AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request) {
FormatEntity::AutoComplete(request);
diff --git a/lldb/source/Interpreter/OptionValueLanguage.cpp b/lldb/source/Interpreter/OptionValueLanguage.cpp
index 5b310782a1ba..d2fbe248300d 100644
--- a/lldb/source/Interpreter/OptionValueLanguage.cpp
+++ b/lldb/source/Interpreter/OptionValueLanguage.cpp
@@ -69,7 +69,3 @@ Status OptionValueLanguage::SetValueFromString(llvm::StringRef value,
}
return error;
}
-
-lldb::OptionValueSP OptionValueLanguage::DeepCopy() const {
- return OptionValueSP(new OptionValueLanguage(*this));
-}
diff --git a/lldb/source/Interpreter/OptionValuePathMappings.cpp b/lldb/source/Interpreter/OptionValuePathMappings.cpp
index 3b3f43d07293..4dceb5632716 100644
--- a/lldb/source/Interpreter/OptionValuePathMappings.cpp
+++ b/lldb/source/Interpreter/OptionValuePathMappings.cpp
@@ -196,7 +196,3 @@ Status OptionValuePathMappings::SetValueFromString(llvm::StringRef value,
}
return error;
}
-
-lldb::OptionValueSP OptionValuePathMappings::DeepCopy() const {
- return OptionValueSP(new OptionValuePathMappings(*this));
-}
diff --git a/lldb/source/Interpreter/OptionValueProperties.cpp b/lldb/source/Interpreter/OptionValueProperties.cpp
index 6c4e77f614f9..ae073798ca12 100644
--- a/lldb/source/Interpreter/OptionValueProperties.cpp
+++ b/lldb/source/Interpreter/OptionValueProperties.cpp
@@ -20,29 +20,7 @@
using namespace lldb;
using namespace lldb_private;
-OptionValueProperties::OptionValueProperties(ConstString name)
- : OptionValue(), m_name(name), m_properties(), m_name_to_index() {}
-
-OptionValueProperties::OptionValueProperties(
- const OptionValueProperties &global_properties)
- : OptionValue(global_properties),
- std::enable_shared_from_this<OptionValueProperties>(),
- m_name(global_properties.m_name),
- m_properties(global_properties.m_properties),
- m_name_to_index(global_properties.m_name_to_index) {
- // We now have an exact copy of "global_properties". We need to now find all
- // non-global settings and copy the property values so that all non-global
- // settings get new OptionValue instances created for them.
- const size_t num_properties = m_properties.size();
- for (size_t i = 0; i < num_properties; ++i) {
- // Duplicate any values that are not global when constructing properties
- // from a global copy
- if (!m_properties[i].IsGlobal()) {
- lldb::OptionValueSP new_value_sp(m_properties[i].GetValue()->DeepCopy());
- m_properties[i].SetOptionValue(new_value_sp);
- }
- }
-}
+OptionValueProperties::OptionValueProperties(ConstString name) : m_name(name) {}
size_t OptionValueProperties::GetNumProperties() const {
return m_properties.size();
@@ -250,38 +228,50 @@ OptionValueProperties::GetPropertyAtIndexAsOptionValueLanguage(
bool OptionValueProperties::GetPropertyAtIndexAsArgs(
const ExecutionContext *exe_ctx, uint32_t idx, Args &args) const {
const Property *property = GetPropertyAtIndex(exe_ctx, false, idx);
- if (property) {
- OptionValue *value = property->GetValue().get();
- if (value) {
- const OptionValueArray *array = value->GetAsArray();
- if (array)
- return array->GetArgs(args);
- else {
- const OptionValueDictionary *dict = value->GetAsDictionary();
- if (dict)
- return dict->GetArgs(args);
- }
- }
- }
+ if (!property)
+ return false;
+
+ OptionValue *value = property->GetValue().get();
+ if (!value)
+ return false;
+
+ const OptionValueArgs *arguments = value->GetAsArgs();
+ if (arguments)
+ return arguments->GetArgs(args);
+
+ const OptionValueArray *array = value->GetAsArray();
+ if (array)
+ return array->GetArgs(args);
+
+ const OptionValueDictionary *dict = value->GetAsDictionary();
+ if (dict)
+ return dict->GetArgs(args);
+
return false;
}
bool OptionValueProperties::SetPropertyAtIndexFromArgs(
const ExecutionContext *exe_ctx, uint32_t idx, const Args &args) {
const Property *property = GetPropertyAtIndex(exe_ctx, true, idx);
- if (property) {
- OptionValue *value = property->GetValue().get();
- if (value) {
- OptionValueArray *array = value->GetAsArray();
- if (array)
- return array->SetArgs(args, eVarSetOperationAssign).Success();
- else {
- OptionValueDictionary *dict = value->GetAsDictionary();
- if (dict)
- return dict->SetArgs(args, eVarSetOperationAssign).Success();
- }
- }
- }
+ if (!property)
+ return false;
+
+ OptionValue *value = property->GetValue().get();
+ if (!value)
+ return false;
+
+ OptionValueArgs *arguments = value->GetAsArgs();
+ if (arguments)
+ return arguments->SetArgs(args, eVarSetOperationAssign).Success();
+
+ OptionValueArray *array = value->GetAsArray();
+ if (array)
+ return array->SetArgs(args, eVarSetOperationAssign).Success();
+
+ OptionValueDictionary *dict = value->GetAsDictionary();
+ if (dict)
+ return dict->SetArgs(args, eVarSetOperationAssign).Success();
+
return false;
}
@@ -552,8 +542,32 @@ Status OptionValueProperties::DumpPropertyValue(const ExecutionContext *exe_ctx,
return error;
}
-lldb::OptionValueSP OptionValueProperties::DeepCopy() const {
- llvm_unreachable("this shouldn't happen");
+OptionValuePropertiesSP
+OptionValueProperties::CreateLocalCopy(const Properties &global_properties) {
+ auto global_props_sp = global_properties.GetValueProperties();
+ lldbassert(global_props_sp);
+
+ auto copy_sp = global_props_sp->DeepCopy(global_props_sp->GetParent());
+ return std::static_pointer_cast<OptionValueProperties>(copy_sp);
+}
+
+OptionValueSP
+OptionValueProperties::DeepCopy(const OptionValueSP &new_parent) const {
+ auto copy_sp = OptionValue::DeepCopy(new_parent);
+ // copy_sp->GetAsProperties cannot be used here as it doesn't work for derived
+ // types that override GetType returning a different value.
+ auto *props_value_ptr = static_cast<OptionValueProperties *>(copy_sp.get());
+ lldbassert(props_value_ptr);
+
+ for (auto &property : props_value_ptr->m_properties) {
+ // Duplicate any values that are not global when constructing properties
+ // from a global copy.
+ if (!property.IsGlobal()) {
+ auto value_sp = property.GetValue()->DeepCopy(copy_sp);
+ property.SetOptionValue(value_sp);
+ }
+ }
+ return copy_sp;
}
const Property *OptionValueProperties::GetPropertyAtPath(
@@ -616,11 +630,11 @@ void OptionValueProperties::Apropos(
} else {
bool match = false;
llvm::StringRef name = property->GetName();
- if (name.contains_lower(keyword))
+ if (name.contains_insensitive(keyword))
match = true;
else {
llvm::StringRef desc = property->GetDescription();
- if (desc.contains_lower(keyword))
+ if (desc.contains_insensitive(keyword))
match = true;
}
if (match) {
diff --git a/lldb/source/Interpreter/OptionValueRegex.cpp b/lldb/source/Interpreter/OptionValueRegex.cpp
index bec3942d9cb0..bbeca8da7714 100644
--- a/lldb/source/Interpreter/OptionValueRegex.cpp
+++ b/lldb/source/Interpreter/OptionValueRegex.cpp
@@ -59,7 +59,3 @@ Status OptionValueRegex::SetValueFromString(llvm::StringRef value,
}
return error;
}
-
-lldb::OptionValueSP OptionValueRegex::DeepCopy() const {
- return OptionValueSP(new OptionValueRegex(m_regex.GetText().str().c_str()));
-}
diff --git a/lldb/source/Interpreter/OptionValueSInt64.cpp b/lldb/source/Interpreter/OptionValueSInt64.cpp
index ada20b2139a3..b875ba8e3536 100644
--- a/lldb/source/Interpreter/OptionValueSInt64.cpp
+++ b/lldb/source/Interpreter/OptionValueSInt64.cpp
@@ -70,7 +70,3 @@ Status OptionValueSInt64::SetValueFromString(llvm::StringRef value_ref,
}
return error;
}
-
-lldb::OptionValueSP OptionValueSInt64::DeepCopy() const {
- return OptionValueSP(new OptionValueSInt64(*this));
-}
diff --git a/lldb/source/Interpreter/OptionValueString.cpp b/lldb/source/Interpreter/OptionValueString.cpp
index 22f5d08bf832..b4fec91bc33f 100644
--- a/lldb/source/Interpreter/OptionValueString.cpp
+++ b/lldb/source/Interpreter/OptionValueString.cpp
@@ -117,10 +117,6 @@ Status OptionValueString::SetValueFromString(llvm::StringRef value,
return error;
}
-lldb::OptionValueSP OptionValueString::DeepCopy() const {
- return OptionValueSP(new OptionValueString(*this));
-}
-
Status OptionValueString::SetCurrentValue(llvm::StringRef value) {
if (m_validator) {
Status error(m_validator(value.str().c_str(), m_validator_baton));
diff --git a/lldb/source/Interpreter/OptionValueUInt64.cpp b/lldb/source/Interpreter/OptionValueUInt64.cpp
index 98ef016e5f77..a2751a4d02eb 100644
--- a/lldb/source/Interpreter/OptionValueUInt64.cpp
+++ b/lldb/source/Interpreter/OptionValueUInt64.cpp
@@ -68,7 +68,3 @@ Status OptionValueUInt64::SetValueFromString(llvm::StringRef value_ref,
}
return error;
}
-
-lldb::OptionValueSP OptionValueUInt64::DeepCopy() const {
- return OptionValueSP(new OptionValueUInt64(*this));
-}
diff --git a/lldb/source/Interpreter/OptionValueUUID.cpp b/lldb/source/Interpreter/OptionValueUUID.cpp
index 2bd749773556..283f9c1b67b3 100644
--- a/lldb/source/Interpreter/OptionValueUUID.cpp
+++ b/lldb/source/Interpreter/OptionValueUUID.cpp
@@ -58,10 +58,6 @@ Status OptionValueUUID::SetValueFromString(llvm::StringRef value,
return error;
}
-lldb::OptionValueSP OptionValueUUID::DeepCopy() const {
- return OptionValueSP(new OptionValueUUID(*this));
-}
-
void OptionValueUUID::AutoComplete(CommandInterpreter &interpreter,
CompletionRequest &request) {
ExecutionContext exe_ctx(interpreter.GetExecutionContext());
diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp
index 9ecc9e229e0e..4aa298f0382b 100644
--- a/lldb/source/Interpreter/Options.cpp
+++ b/lldb/source/Interpreter/Options.cpp
@@ -25,9 +25,9 @@ using namespace lldb;
using namespace lldb_private;
// Options
-Options::Options() : m_getopt_table() { BuildValidOptionSets(); }
+Options::Options() { BuildValidOptionSets(); }
-Options::~Options() {}
+Options::~Options() = default;
void Options::NotifyOptionParsingStarting(ExecutionContext *execution_context) {
m_seen_options.clear();
@@ -137,7 +137,6 @@ bool Options::VerifyOptions(CommandReturnObject &result) {
result.SetStatus(eReturnStatusSuccessFinishNoResult);
} else {
result.AppendError("invalid combination of options for the given command");
- result.SetStatus(eReturnStatusFailed);
}
return options_are_valid;
diff --git a/lldb/source/Interpreter/Property.cpp b/lldb/source/Interpreter/Property.cpp
index a02497662ff5..55400a2bc42d 100644
--- a/lldb/source/Interpreter/Property.cpp
+++ b/lldb/source/Interpreter/Property.cpp
@@ -22,7 +22,7 @@ using namespace lldb_private;
Property::Property(const PropertyDefinition &definition)
: m_name(definition.name), m_description(definition.description),
- m_value_sp(), m_is_global(definition.global) {
+ m_is_global(definition.global) {
switch (definition.type) {
case OptionValue::eTypeInvalid:
case OptionValue::eTypeProperties:
diff --git a/lldb/source/Interpreter/ScriptInterpreter.cpp b/lldb/source/Interpreter/ScriptInterpreter.cpp
index 013ed6aecb80..f26474836a68 100644
--- a/lldb/source/Interpreter/ScriptInterpreter.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreter.cpp
@@ -18,37 +18,36 @@
#if defined(_WIN32)
#include "lldb/Host/windows/ConnectionGenericFileWindows.h"
#endif
+#include <cstdio>
+#include <cstdlib>
#include <memory>
-#include <stdio.h>
-#include <stdlib.h>
#include <string>
using namespace lldb;
using namespace lldb_private;
-ScriptInterpreter::ScriptInterpreter(Debugger &debugger,
- lldb::ScriptLanguage script_lang)
- : m_debugger(debugger), m_script_lang(script_lang) {}
-
-ScriptInterpreter::~ScriptInterpreter() {}
+ScriptInterpreter::ScriptInterpreter(
+ Debugger &debugger, lldb::ScriptLanguage script_lang,
+ lldb::ScriptedProcessInterfaceUP scripted_process_interface_up)
+ : m_debugger(debugger), m_script_lang(script_lang),
+ m_scripted_process_interface_up(
+ std::move(scripted_process_interface_up)) {}
void ScriptInterpreter::CollectDataForBreakpointCommandCallback(
- std::vector<BreakpointOptions *> &bp_options_vec,
+ std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
CommandReturnObject &result) {
- result.SetStatus(eReturnStatusFailed);
result.AppendError(
"This script interpreter does not support breakpoint callbacks.");
}
void ScriptInterpreter::CollectDataForWatchpointCommandCallback(
WatchpointOptions *bp_options, CommandReturnObject &result) {
- result.SetStatus(eReturnStatusFailed);
result.AppendError(
"This script interpreter does not support watchpoint callbacks.");
}
bool ScriptInterpreter::LoadScriptingModule(const char *filename,
- bool init_session,
+ const LoadScriptOptions &options,
lldb_private::Status &error,
StructuredData::ObjectSP *module_sp,
FileSpec extra_search_dir) {
@@ -71,22 +70,35 @@ std::string ScriptInterpreter::LanguageToString(lldb::ScriptLanguage language) {
llvm_unreachable("Unhandled ScriptInterpreter!");
}
+lldb::DataExtractorSP
+ScriptInterpreter::GetDataExtractorFromSBData(const lldb::SBData &data) const {
+ return data.m_opaque_sp;
+}
+
+Status
+ScriptInterpreter::GetStatusFromSBError(const lldb::SBError &error) const {
+ if (error.m_opaque_up)
+ return *error.m_opaque_up.get();
+
+ return Status();
+}
+
lldb::ScriptLanguage
ScriptInterpreter::StringToLanguage(const llvm::StringRef &language) {
- if (language.equals_lower(LanguageToString(eScriptLanguageNone)))
+ if (language.equals_insensitive(LanguageToString(eScriptLanguageNone)))
return eScriptLanguageNone;
- if (language.equals_lower(LanguageToString(eScriptLanguagePython)))
+ if (language.equals_insensitive(LanguageToString(eScriptLanguagePython)))
return eScriptLanguagePython;
- if (language.equals_lower(LanguageToString(eScriptLanguageLua)))
+ if (language.equals_insensitive(LanguageToString(eScriptLanguageLua)))
return eScriptLanguageLua;
return eScriptLanguageUnknown;
}
Status ScriptInterpreter::SetBreakpointCommandCallback(
- std::vector<BreakpointOptions *> &bp_options_vec,
+ std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
const char *callback_text) {
Status return_error;
- for (BreakpointOptions *bp_options : bp_options_vec) {
+ for (BreakpointOptions &bp_options : bp_options_vec) {
return_error = SetBreakpointCommandCallback(bp_options, callback_text);
if (return_error.Success())
break;
@@ -95,10 +107,10 @@ Status ScriptInterpreter::SetBreakpointCommandCallback(
}
Status ScriptInterpreter::SetBreakpointCommandCallbackFunction(
- std::vector<BreakpointOptions *> &bp_options_vec, const char *function_name,
- StructuredData::ObjectSP extra_args_sp) {
+ std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
+ const char *function_name, StructuredData::ObjectSP extra_args_sp) {
Status error;
- for (BreakpointOptions *bp_options : bp_options_vec) {
+ for (BreakpointOptions &bp_options : bp_options_vec) {
error = SetBreakpointCommandCallbackFunction(bp_options, function_name,
extra_args_sp);
if (!error.Success())