diff options
Diffstat (limited to 'source/Commands/CommandObjectProcess.cpp')
-rw-r--r-- | source/Commands/CommandObjectProcess.cpp | 101 |
1 files changed, 15 insertions, 86 deletions
diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp index 5b0e6d784a026..b20a2d5333327 100644 --- a/source/Commands/CommandObjectProcess.cpp +++ b/source/Commands/CommandObjectProcess.cpp @@ -1,9 +1,8 @@ //===-- CommandObjectProcess.cpp --------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -101,9 +100,7 @@ protected: std::string m_new_process_action; }; -//------------------------------------------------------------------------- // CommandObjectProcessLaunch -//------------------------------------------------------------------------- #pragma mark CommandObjectProcessLaunch class CommandObjectProcessLaunch : public CommandObjectProcessLaunchOrAttach { public: @@ -150,7 +147,7 @@ public: protected: bool DoExecute(Args &launch_args, CommandReturnObject &result) override { - Debugger &debugger = m_interpreter.GetDebugger(); + Debugger &debugger = GetDebugger(); Target *target = debugger.GetSelectedTarget().get(); // If our listener is nullptr, users aren't allows to launch ModuleSP exe_module_sp = target->GetExecutableModule(); @@ -196,7 +193,10 @@ protected: if (target->GetDisableSTDIO()) m_options.launch_info.GetFlags().Set(eLaunchFlagDisableSTDIO); - m_options.launch_info.GetEnvironment() = target->GetEnvironment(); + // Merge the launch info environment with the target environment. + Environment target_env = target->GetEnvironment(); + m_options.launch_info.GetEnvironment().insert(target_env.begin(), + target_env.end()); if (!target_settings_argv0.empty()) { m_options.launch_info.GetArguments().AppendArgument( @@ -255,51 +255,6 @@ protected: ProcessLaunchCommandOptions m_options; }; -//#define SET1 LLDB_OPT_SET_1 -//#define SET2 LLDB_OPT_SET_2 -//#define SET3 LLDB_OPT_SET_3 -// -// OptionDefinition -// CommandObjectProcessLaunch::CommandOptions::g_option_table[] = -//{ -// // clang-format off -// {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 <path>."}, -// {SET1, false, "stdout", 'o', -// OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName, -// "Redirect stdout for the process to <path>."}, -// {SET1, false, "stderr", 'e', -// OptionParser::eRequiredArgument, nullptr, 0, eArgTypeDirectoryName, -// "Redirect stderr for the process to <path>."}, -// {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 <path> is specified, look for a terminal whose -// name contains <path>, 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 <path> when running the inferior."}, -// {0, false, nullptr, 0, 0, nullptr, 0, eArgTypeNone, nullptr} -// // clang-format on -//}; -// -//#undef SET1 -//#undef SET2 -//#undef SET3 - -//------------------------------------------------------------------------- -// CommandObjectProcessAttach -//------------------------------------------------------------------------- - static constexpr OptionDefinition g_process_attach_options[] = { // clang-format off { LLDB_OPT_SET_ALL, false, "continue", 'c', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Immediately continue the process once attached." }, @@ -435,9 +390,9 @@ public: protected: bool DoExecute(Args &command, CommandReturnObject &result) override { PlatformSP platform_sp( - m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); + GetDebugger().GetPlatformList().GetSelectedPlatform()); - Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = GetDebugger().GetSelectedTarget().get(); // N.B. The attach should be synchronous. It doesn't help much to get the // prompt back between initiating the attach and the target actually // stopping. So even if the interpreter is set to be asynchronous, we wait @@ -454,8 +409,8 @@ protected: TargetSP new_target_sp; Status error; - error = m_interpreter.GetDebugger().GetTargetList().CreateTarget( - m_interpreter.GetDebugger(), "", "", eLoadDependentsNo, + error = GetDebugger().GetTargetList().CreateTarget( + GetDebugger(), "", "", eLoadDependentsNo, nullptr, // No platform options new_target_sp); target = new_target_sp.get(); @@ -463,7 +418,7 @@ protected: result.AppendError(error.AsCString("Error creating target")); return false; } - m_interpreter.GetDebugger().GetTargetList().SetSelectedTarget(target); + GetDebugger().GetTargetList().SetSelectedTarget(target); } // Record the old executable module, we want to issue a warning if the @@ -548,9 +503,7 @@ protected: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectProcessContinue -//------------------------------------------------------------------------- static constexpr OptionDefinition g_process_continue_options[] = { // clang-format off @@ -712,9 +665,7 @@ protected: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectProcessDetach -//------------------------------------------------------------------------- static constexpr OptionDefinition g_process_detach_options[] = { // clang-format off { LLDB_OPT_SET_1, false, "keep-stopped", 's', OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeBoolean, "Whether or not the process should be kept stopped on detach (if possible)." }, @@ -810,9 +761,7 @@ protected: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectProcessConnect -//------------------------------------------------------------------------- static constexpr OptionDefinition g_process_connect_options[] = { // clang-format off @@ -900,7 +849,7 @@ protected: plugin_name = m_options.plugin_name.c_str(); Status error; - Debugger &debugger = m_interpreter.GetDebugger(); + Debugger &debugger = GetDebugger(); PlatformSP platform_sp = m_interpreter.GetPlatform(true); ProcessSP process_sp = platform_sp->ConnectProcess( command.GetArgumentAtIndex(0), plugin_name, debugger, @@ -916,9 +865,7 @@ protected: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectProcessPlugin -//------------------------------------------------------------------------- #pragma mark CommandObjectProcessPlugin class CommandObjectProcessPlugin : public CommandObjectProxy { @@ -939,9 +886,7 @@ public: } }; -//------------------------------------------------------------------------- // CommandObjectProcessLoad -//------------------------------------------------------------------------- static constexpr OptionDefinition g_process_load_options[] = { // clang-format off @@ -1055,9 +1000,7 @@ protected: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectProcessUnload -//------------------------------------------------------------------------- #pragma mark CommandObjectProcessUnload class CommandObjectProcessUnload : public CommandObjectParsed { @@ -1103,9 +1046,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectProcessSignal -//------------------------------------------------------------------------- #pragma mark CommandObjectProcessSignal class CommandObjectProcessSignal : public CommandObjectParsed { @@ -1170,9 +1111,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectProcessInterrupt -//------------------------------------------------------------------------- #pragma mark CommandObjectProcessInterrupt class CommandObjectProcessInterrupt : public CommandObjectParsed { @@ -1214,9 +1153,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectProcessKill -//------------------------------------------------------------------------- #pragma mark CommandObjectProcessKill class CommandObjectProcessKill : public CommandObjectParsed { @@ -1257,9 +1194,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectProcessSaveCore -//------------------------------------------------------------------------- #pragma mark CommandObjectProcessSaveCore class CommandObjectProcessSaveCore : public CommandObjectParsed { @@ -1303,9 +1238,7 @@ protected: } }; -//------------------------------------------------------------------------- // CommandObjectProcessStatus -//------------------------------------------------------------------------- #pragma mark CommandObjectProcessStatus class CommandObjectProcessStatus : public CommandObjectParsed { @@ -1337,9 +1270,7 @@ public: } }; -//------------------------------------------------------------------------- // CommandObjectProcessHandle -//------------------------------------------------------------------------- static constexpr OptionDefinition g_process_handle_options[] = { // clang-format off @@ -1489,7 +1420,7 @@ public: protected: bool DoExecute(Args &signal_args, CommandReturnObject &result) override { - TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget(); + TargetSP target_sp = GetDebugger().GetSelectedTarget(); if (!target_sp) { result.AppendError("No current target;" @@ -1596,9 +1527,7 @@ protected: CommandOptions m_options; }; -//------------------------------------------------------------------------- // CommandObjectMultiwordProcess -//------------------------------------------------------------------------- CommandObjectMultiwordProcess::CommandObjectMultiwordProcess( CommandInterpreter &interpreter) |