aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectProcess.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-02-16 20:13:02 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-02-16 20:13:02 +0000
commitb60736ec1405bb0a8dd40989f67ef4c93da068ab (patch)
tree5c43fbb7c9fc45f0f87e0e6795a86267dbd12f9d /lldb/source/Commands/CommandObjectProcess.cpp
parentcfca06d7963fa0909f90483b42a6d7d194d01e08 (diff)
downloadsrc-b60736ec1405bb0a8dd40989f67ef4c93da068ab.tar.gz
src-b60736ec1405bb0a8dd40989f67ef4c93da068ab.zip
Vendor import of llvm-project main 8e464dd76bef, the last commit beforevendor/llvm-project/llvmorg-12-init-17869-g8e464dd76bef
the upstream release/12.x branch was created.
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp99
1 files changed, 44 insertions, 55 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index f86779d85b5f..35835f638557 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "CommandObjectProcess.h"
+#include "CommandOptionsProcessLaunch.h"
#include "lldb/Breakpoint/Breakpoint.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Breakpoint/BreakpointSite.h"
@@ -48,19 +49,19 @@ protected:
state = process->GetState();
if (process->IsAlive() && state != eStateConnected) {
- char message[1024];
+ std::string message;
if (process->GetState() == eStateAttaching)
- ::snprintf(message, sizeof(message),
- "There is a pending attach, abort it and %s?",
- m_new_process_action.c_str());
+ message =
+ llvm::formatv("There is a pending attach, abort it and {0}?",
+ m_new_process_action);
else if (process->GetShouldDetach())
- ::snprintf(message, sizeof(message),
- "There is a running process, detach from it and %s?",
- m_new_process_action.c_str());
+ message = llvm::formatv(
+ "There is a running process, detach from it and {0}?",
+ m_new_process_action);
else
- ::snprintf(message, sizeof(message),
- "There is a running process, kill it and %s?",
- m_new_process_action.c_str());
+ message =
+ llvm::formatv("There is a running process, kill it and {0}?",
+ m_new_process_action);
if (!m_interpreter.Confirm(message, true)) {
result.SetStatus(eReturnStatusFailed);
@@ -184,6 +185,9 @@ protected:
else
m_options.launch_info.GetFlags().Clear(eLaunchFlagDisableASLR);
+ if (target->GetInheritTCC())
+ m_options.launch_info.GetFlags().Set(eLaunchFlagInheritTCCFromParent);
+
if (target->GetDetachOnError())
m_options.launch_info.GetFlags().Set(eLaunchFlagDetachOnError);
@@ -248,7 +252,7 @@ protected:
return result.Succeeded();
}
- ProcessLaunchCommandOptions m_options;
+ CommandOptionsProcessLaunch m_options;
};
#define LLDB_OPTIONS_process_attach
@@ -317,49 +321,6 @@ public:
return llvm::makeArrayRef(g_process_attach_options);
}
- void HandleOptionArgumentCompletion(
- CompletionRequest &request, OptionElementVector &opt_element_vector,
- int opt_element_index, CommandInterpreter &interpreter) override {
- int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos;
- int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index;
-
- switch (GetDefinitions()[opt_defs_index].short_option) {
- case 'n': {
- // 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 = nullptr;
- partial_name = request.GetParsedLine().GetArgumentAtIndex(opt_arg_pos);
-
- PlatformSP platform_sp(interpreter.GetPlatform(true));
- if (!platform_sp)
- return;
- ProcessInstanceInfoList process_infos;
- ProcessInstanceInfoMatch match_info;
- if (partial_name) {
- match_info.GetProcessInfo().GetExecutableFile().SetFile(
- partial_name, FileSpec::Style::native);
- match_info.SetNameMatchType(NameMatch::StartsWith);
- }
- platform_sp->FindProcesses(match_info, process_infos);
- const size_t num_matches = process_infos.size();
- if (num_matches == 0)
- return;
- for (size_t i = 0; i < num_matches; ++i) {
- request.AddCompletion(process_infos[i].GetNameAsStringRef());
- }
- } break;
-
- case 'P':
- CommandCompletions::InvokeCommonCompletionCallbacks(
- interpreter, CommandCompletions::eProcessPluginCompletion, request,
- nullptr);
- break;
- }
- }
-
- // Instance variables to hold the values for command options.
-
ProcessAttachInfo attach_info;
};
@@ -404,7 +365,6 @@ protected:
result.AppendError(error.AsCString("Error creating target"));
return false;
}
- GetDebugger().GetTargetList().SetSelectedTarget(target);
}
// Record the old executable module, we want to issue a warning if the
@@ -920,6 +880,17 @@ public:
~CommandObjectProcessLoad() override = default;
+ void
+ HandleArgumentCompletion(CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+ if (!m_exe_ctx.HasProcessScope())
+ return;
+
+ CommandCompletions::InvokeCommonCompletionCallbacks(
+ GetCommandInterpreter(), CommandCompletions::eDiskFileCompletion,
+ request, nullptr);
+ }
+
Options *GetOptions() override { return &m_options; }
protected:
@@ -985,6 +956,24 @@ public:
~CommandObjectProcessUnload() override = default;
+ void
+ HandleArgumentCompletion(CompletionRequest &request,
+ OptionElementVector &opt_element_vector) override {
+
+ if (request.GetCursorIndex() || !m_exe_ctx.HasProcessScope())
+ return;
+
+ Process *process = m_exe_ctx.GetProcessPtr();
+
+ const std::vector<lldb::addr_t> &tokens = process->GetImageTokens();
+ const size_t token_num = tokens.size();
+ for (size_t i = 0; i < token_num; ++i) {
+ if (tokens[i] == LLDB_INVALID_IMAGE_TOKEN)
+ continue;
+ request.TryCompleteCurrentArg(std::to_string(i));
+ }
+ }
+
protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
Process *process = m_exe_ctx.GetProcessPtr();