From f3fbd1c0586ff6ec7895991e6c28f61a503c36a8 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 23 Jul 2016 20:50:09 +0000 Subject: Vendor import of lldb release_39 branch r276489: https://llvm.org/svn/llvm-project/lldb/branches/release_39@276489 --- source/Commands/CommandObjectProcess.cpp | 344 +++++++++++-------------------- 1 file changed, 126 insertions(+), 218 deletions(-) (limited to 'source/Commands/CommandObjectProcess.cpp') diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp index a85ea179abb8..106e2d86b18c 100644 --- a/source/Commands/CommandObjectProcess.cpp +++ b/source/Commands/CommandObjectProcess.cpp @@ -7,12 +7,11 @@ // //===----------------------------------------------------------------------===// -#include "CommandObjectProcess.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "CommandObjectProcess.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/BreakpointSite.h" @@ -46,8 +45,9 @@ public: const char *new_process_action) : CommandObjectParsed (interpreter, name, help, syntax, flags), m_new_process_action (new_process_action) {} - - ~CommandObjectProcessLaunchOrAttach () override {} + + ~CommandObjectProcessLaunchOrAttach() override = default; + protected: bool StopProcessIfNecessary (Process *process, StateType &state, CommandReturnObject &result) @@ -81,7 +81,7 @@ protected: if (detach_error.Success()) { result.SetStatus (eReturnStatusSuccessFinishResult); - process = NULL; + process = nullptr; } else { @@ -95,7 +95,7 @@ protected: if (destroy_error.Success()) { result.SetStatus (eReturnStatusSuccessFinishResult); - process = NULL; + process = nullptr; } else { @@ -108,8 +108,10 @@ protected: } return result.Succeeded(); } + std::string m_new_process_action; }; + //------------------------------------------------------------------------- // CommandObjectProcessLaunch //------------------------------------------------------------------------- @@ -117,14 +119,13 @@ protected: class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach { public: - CommandObjectProcessLaunch (CommandInterpreter &interpreter) : - CommandObjectProcessLaunchOrAttach (interpreter, - "process launch", - "Launch the executable in the debugger.", - NULL, - eCommandRequiresTarget, - "restart"), + CommandObjectProcessLaunchOrAttach(interpreter, + "process launch", + "Launch the executable in the debugger.", + nullptr, + eCommandRequiresTarget, + "restart"), m_options (interpreter) { CommandArgumentEntry arg; @@ -141,10 +142,7 @@ public: m_arguments.push_back (arg); } - - ~CommandObjectProcessLaunch () override - { - } + ~CommandObjectProcessLaunch() override = default; int HandleArgumentCompletion (Args &input, @@ -159,14 +157,14 @@ public: std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, - CommandCompletions::eDiskFileCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - NULL, - word_complete, - matches); + CommandCompletions::InvokeCommonCompletionCallbacks(m_interpreter, + CommandCompletions::eDiskFileCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + nullptr, + word_complete, + matches); return matches.GetSize(); } @@ -189,10 +187,10 @@ protected: { Debugger &debugger = m_interpreter.GetDebugger(); Target *target = debugger.GetSelectedTarget().get(); - // If our listener is NULL, users aren't allows to launch + // If our listener is nullptr, users aren't allows to launch ModuleSP exe_module_sp = target->GetExecutableModule(); - if (exe_module_sp == NULL) + if (exe_module_sp == nullptr) { result.AppendError ("no file in target, create a debug target using the 'target create' command"); result.SetStatus (eReturnStatusFailed); @@ -305,15 +303,15 @@ protected: //OptionDefinition //CommandObjectProcessLaunch::CommandOptions::g_option_table[] = //{ -//{ SET1 | SET2 | SET3, false, "stop-at-entry", 's', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Stop at the entry point of the program when launching a process."}, -//{ SET1 , false, "stdin", 'i', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Redirect stdin for the process to ."}, -//{ SET1 , false, "stdout", 'o', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Redirect stdout for the process to ."}, -//{ SET1 , false, "stderr", 'e', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Redirect stderr for the process to ."}, -//{ SET1 | SET2 | SET3, false, "plugin", 'p', OptionParser::eRequiredArgument, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."}, -//{ SET2 , false, "tty", 't', OptionParser::eOptionalArgument, NULL, 0, eArgTypeDirectoryName, "Start the process in a terminal. If is specified, look for a terminal whose name contains , else start the process in a new terminal."}, -//{ SET3, false, "no-stdio", 'n', OptionParser::eNoArgument, NULL, 0, eArgTypeNone, "Do not set up for terminal I/O to go to running process."}, -//{ SET1 | SET2 | SET3, false, "working-dir", 'w', OptionParser::eRequiredArgument, NULL, 0, eArgTypeDirectoryName, "Set the current working directory to when running the inferior."}, -//{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL } +//{ SET1 | SET2 | SET3, false, "stop-at-entry", 's', OptionParser::eNoArgument, nullptr, 0, eArgTypeNone, "Stop at the entry point of the program when launching a process."}, +//{ SET1 , false, "stdin", 'i', OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName, "Redirect stdin for the process to ."}, +//{ SET1 , false, "stdout", 'o', OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName, "Redirect stdout for the process to ."}, +//{ SET1 , false, "stderr", 'e', OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName, "Redirect stderr for the process to ."}, +//{ SET1 | SET2 | SET3, false, "plugin", 'p', OptionParser::eRequiredArgument, nullptr, 0, eArgTypePlugin, "Name of the process plugin you want to use."}, +//{ SET2 , false, "tty", 't', OptionParser::eOptionalArgument, nullptr, 0, eArgTypeDirectoryName, "Start the process in a terminal. If is specified, look for a terminal whose name contains , else start the process in a new terminal."}, +//{ SET3, false, "no-stdio", 'n', OptionParser::eNoArgument, nullptr, 0, eArgTypeNone, "Do not set up for terminal I/O to go to running process."}, +//{ SET1 | SET2 | SET3, false, "working-dir", 'w', OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName, "Set the current working directory to when running the inferior."}, +//{ 0, false, nullptr, 0, 0, nullptr, 0, eArgTypeNone, nullptr } //}; // //#undef SET1 @@ -327,11 +325,9 @@ protected: class CommandObjectProcessAttach : public CommandObjectProcessLaunchOrAttach { public: - class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { @@ -339,9 +335,7 @@ public: OptionParsingStarting (); } - ~CommandOptions () override - { - } + ~CommandOptions() override = default; Error SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -428,7 +422,7 @@ public: // Look to see if there is a -P argument provided, and if so use that plugin, otherwise // use the default plugin. - const char *partial_name = NULL; + const char *partial_name = nullptr; partial_name = input.GetArgumentAtIndex(opt_arg_pos); PlatformSP platform_sp (m_interpreter.GetPlatform (true)); @@ -445,7 +439,7 @@ public: const size_t num_matches = process_infos.GetSize(); if (num_matches > 0) { - for (size_t i=0; i to launch."}, -{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } +{ LLDB_OPT_SET_ALL, false, "continue",'c', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Immediately continue the process once attached."}, +{ LLDB_OPT_SET_ALL, false, "plugin", 'P', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePlugin, "Name of the process plugin you want to use."}, +{ LLDB_OPT_SET_1, false, "pid", 'p', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePid, "The process ID of an existing process to attach to."}, +{ LLDB_OPT_SET_2, false, "name", 'n', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeProcessName, "The name of the process to attach to."}, +{ LLDB_OPT_SET_2, false, "include-existing", 'i', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Include existing processes when doing attach -w."}, +{ LLDB_OPT_SET_2, false, "waitfor", 'w', OptionParser::eNoArgument, nullptr, nullptr, 0, eArgTypeNone, "Wait for the process with to launch."}, +{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; //------------------------------------------------------------------------- @@ -632,7 +623,6 @@ CommandObjectProcessAttach::CommandOptions::g_option_table[] = class CommandObjectProcessContinue : public CommandObjectParsed { public: - CommandObjectProcessContinue (CommandInterpreter &interpreter) : CommandObjectParsed (interpreter, "process continue", @@ -646,17 +636,12 @@ public: { } - - ~CommandObjectProcessContinue () override - { - } + ~CommandObjectProcessContinue() override = default; protected: - class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { @@ -664,9 +649,7 @@ protected: OptionParsingStarting (); } - ~CommandOptions () override - { - } + ~CommandOptions() override = default; Error SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -725,7 +708,7 @@ protected: if (m_options.m_ignore > 0) { - ThreadSP sel_thread_sp(process->GetThreadList().GetSelectedThread()); + ThreadSP sel_thread_sp(GetDefaultThread()->shared_from_this()); if (sel_thread_sp) { StopInfoSP stop_info_sp = sel_thread_sp->GetStopInfo(); @@ -750,7 +733,7 @@ protected: } { // Scope for thread list mutex: - Mutex::Locker locker (process->GetThreadList().GetMutex()); + std::lock_guard guard(process->GetThreadList().GetMutex()); const uint32_t num_threads = process->GetThreadList().GetSize(); // Set the actions that the threads should each take when resuming @@ -814,15 +797,14 @@ protected: } CommandOptions m_options; - }; OptionDefinition CommandObjectProcessContinue::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_ALL, false, "ignore-count",'i', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeUnsignedInteger, +{ LLDB_OPT_SET_ALL, false, "ignore-count",'i', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeUnsignedInteger, "Ignore crossings of the breakpoint (if it exists) for the currently selected thread."}, -{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } +{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; //------------------------------------------------------------------------- @@ -836,16 +818,13 @@ public: class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : Options (interpreter) { OptionParsingStarting (); } - ~CommandOptions () override - { - } + ~CommandOptions() override = default; Error SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -896,21 +875,15 @@ public: LazyBool m_keep_stopped; }; - CommandObjectProcessDetach (CommandInterpreter &interpreter) : - CommandObjectParsed (interpreter, - "process detach", - "Detach from the current process being debugged.", - "process detach", - eCommandRequiresProcess | - eCommandTryTargetAPILock | - eCommandProcessMustBeLaunched), - m_options(interpreter) + CommandObjectProcessDetach(CommandInterpreter &interpreter) + : CommandObjectParsed(interpreter, "process detach", "Detach from the current target process.", + "process detach", + eCommandRequiresProcess | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched), + m_options(interpreter) { } - ~CommandObjectProcessDetach () override - { - } + ~CommandObjectProcessDetach() override = default; Options * GetOptions () override @@ -918,7 +891,6 @@ public: return &m_options; } - protected: bool DoExecute (Args& command, CommandReturnObject &result) override @@ -929,10 +901,7 @@ protected: if (m_options.m_keep_stopped == eLazyBoolCalculate) { // Check the process default: - if (process->GetDetachKeepsStopped()) - keep_stopped = true; - else - keep_stopped = false; + keep_stopped = process->GetDetachKeepsStopped(); } else if (m_options.m_keep_stopped == eLazyBoolYes) keep_stopped = true; @@ -959,8 +928,8 @@ protected: OptionDefinition CommandObjectProcessDetach::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "keep-stopped", 's', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Whether or not the process should be kept stopped on detach (if possible)." }, -{ 0, false, NULL, 0, 0, NULL, NULL, 0, eArgTypeNone, NULL } +{ LLDB_OPT_SET_1, false, "keep-stopped", 's', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean, "Whether or not the process should be kept stopped on detach (if possible)." }, +{ 0, false, nullptr, 0, 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; //------------------------------------------------------------------------- @@ -971,22 +940,18 @@ CommandObjectProcessDetach::CommandOptions::g_option_table[] = class CommandObjectProcessConnect : public CommandObjectParsed { public: - class CommandOptions : public Options { public: - CommandOptions (CommandInterpreter &interpreter) : Options(interpreter) { // Keep default values of all options in one place: OptionParsingStarting () OptionParsingStarting (); } - - ~CommandOptions () override - { - } - + + ~CommandOptions() override = default; + Error SetOptionValue (uint32_t option_idx, const char *option_arg) override { @@ -1036,12 +1001,9 @@ public: m_options (interpreter) { } - - ~CommandObjectProcessConnect () override - { - } - + ~CommandObjectProcessConnect() override = default; + Options * GetOptions () override { @@ -1061,7 +1023,6 @@ protected: return false; } - Process *process = m_exe_ctx.GetProcessPtr(); if (process && process->IsAlive()) { @@ -1098,8 +1059,8 @@ protected: OptionDefinition CommandObjectProcessConnect::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_ALL, false, "plugin", 'p', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypePlugin, "Name of the process plugin you want to use."}, - { 0, false, NULL, 0 , 0, NULL, NULL, 0, eArgTypeNone, NULL } + { LLDB_OPT_SET_ALL, false, "plugin", 'p', OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypePlugin, "Name of the process plugin you want to use."}, + { 0, false, nullptr, 0 , 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } }; //------------------------------------------------------------------------- @@ -1110,31 +1071,24 @@ CommandObjectProcessConnect::CommandOptions::g_option_table[] = class CommandObjectProcessPlugin : public CommandObjectProxy { public: - - CommandObjectProcessPlugin (CommandInterpreter &interpreter) : - CommandObjectProxy (interpreter, - "process plugin", - "Send a custom command to the current process plug-in.", - "process plugin ", - 0) - { - } - - ~CommandObjectProcessPlugin () override + CommandObjectProcessPlugin(CommandInterpreter &interpreter) + : CommandObjectProxy(interpreter, "process plugin", + "Send a custom command to the current target process plug-in.", "process plugin ", 0) { } + ~CommandObjectProcessPlugin() override = default; + CommandObject * GetProxyCommandObject() override { Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); if (process) return process->GetPluginCommandObject(); - return NULL; + return nullptr; } }; - //------------------------------------------------------------------------- // CommandObjectProcessLoad //------------------------------------------------------------------------- @@ -1153,7 +1107,7 @@ public: OptionParsingStarting (); } - ~CommandOptions () override = default; + ~CommandOptions() override = default; Error SetOptionValue (uint32_t option_idx, const char *option_arg) override @@ -1208,7 +1162,7 @@ public: { } - ~CommandObjectProcessLoad () override = default; + ~CommandObjectProcessLoad() override = default; Options * GetOptions () override @@ -1223,7 +1177,7 @@ protected: Process *process = m_exe_ctx.GetProcessPtr(); const size_t argc = command.GetArgumentCount(); - for (uint32_t i=0; iGetTarget().GetPlatform(); @@ -1293,9 +1247,7 @@ public: { } - ~CommandObjectProcessUnload () override - { - } + ~CommandObjectProcessUnload() override = default; protected: bool @@ -1305,7 +1257,7 @@ protected: const size_t argc = command.GetArgumentCount(); - for (uint32_t i=0; i []") +CommandObjectMultiwordProcess::CommandObjectMultiwordProcess(CommandInterpreter &interpreter) + : CommandObjectMultiword(interpreter, "process", "Commands for interacting with processes on the current platform.", + "process []") { LoadSubCommand ("attach", CommandObjectSP (new CommandObjectProcessAttach (interpreter))); LoadSubCommand ("launch", CommandObjectSP (new CommandObjectProcessLaunch (interpreter))); @@ -1977,7 +1888,4 @@ CommandObjectMultiwordProcess::CommandObjectMultiwordProcess (CommandInterpreter LoadSubCommand ("save-core", CommandObjectSP (new CommandObjectProcessSaveCore (interpreter))); } -CommandObjectMultiwordProcess::~CommandObjectMultiwordProcess () -{ -} - +CommandObjectMultiwordProcess::~CommandObjectMultiwordProcess() = default; -- cgit v1.2.3