1 //===-- CommandOptionsProcessAttach.cpp -----------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "CommandOptionsProcessAttach.h"
11 #include "lldb/Host/FileSystem.h"
12 #include "lldb/Host/HostInfo.h"
13 #include "lldb/Host/OptionParser.h"
14 #include "lldb/Interpreter/CommandCompletions.h"
15 #include "lldb/Interpreter/CommandObject.h"
16 #include "lldb/Interpreter/CommandOptionArgumentTable.h"
17 #include "lldb/Interpreter/OptionArgParser.h"
18 #include "lldb/Target/ExecutionContext.h"
19 #include "lldb/Target/Platform.h"
20 #include "lldb/Target/Target.h"
22 #include "llvm/ADT/ArrayRef.h"
26 using namespace lldb_private
;
28 #define LLDB_OPTIONS_process_attach
29 #include "CommandOptions.inc"
31 Status
CommandOptionsProcessAttach::SetOptionValue(
32 uint32_t option_idx
, llvm::StringRef option_arg
,
33 ExecutionContext
*execution_context
) {
35 const int short_option
= g_process_attach_options
[option_idx
].short_option
;
36 switch (short_option
) {
38 attach_info
.SetContinueOnceAttached(true);
43 if (option_arg
.getAsInteger(0, pid
)) {
44 error
.SetErrorStringWithFormat("invalid process ID '%s'",
45 option_arg
.str().c_str());
47 attach_info
.SetProcessID(pid
);
52 attach_info
.SetProcessPluginName(option_arg
);
56 attach_info
.GetExecutableFile().SetFile(option_arg
,
57 FileSpec::Style::native
);
61 attach_info
.SetWaitForLaunch(true);
65 attach_info
.SetIgnoreExisting(false);
69 llvm_unreachable("Unimplemented option");
74 llvm::ArrayRef
<OptionDefinition
> CommandOptionsProcessAttach::GetDefinitions() {
75 return llvm::ArrayRef(g_process_attach_options
);