brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 2a19862 Raw
77 lines · cpp
1//===-- CommandOptionsProcessAttach.cpp -----------------------------------===//2//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-exception6//7//===----------------------------------------------------------------------===//8 9#include "CommandOptionsProcessAttach.h"10 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"21 22#include "llvm/ADT/ArrayRef.h"23 24using namespace llvm;25using namespace lldb;26using namespace lldb_private;27 28#define LLDB_OPTIONS_process_attach29#include "CommandOptions.inc"30 31Status CommandOptionsProcessAttach::SetOptionValue(32    uint32_t option_idx, llvm::StringRef option_arg,33    ExecutionContext *execution_context) {34  Status error;35  const int short_option = g_process_attach_options[option_idx].short_option;36  switch (short_option) {37  case 'c':38    attach_info.SetContinueOnceAttached(true);39    break;40 41  case 'p': {42    lldb::pid_t pid;43    if (option_arg.getAsInteger(0, pid)) {44      return Status::FromErrorStringWithFormatv("invalid process ID '{0}'",45                                                option_arg);46    } else {47      attach_info.SetProcessID(pid);48    }49  } break;50 51  case 'P':52    attach_info.SetProcessPluginName(option_arg);53    break;54 55  case 'n':56    attach_info.GetExecutableFile().SetFile(option_arg,57                                            FileSpec::Style::native);58    break;59 60  case 'w':61    attach_info.SetWaitForLaunch(true);62    break;63 64  case 'i':65    attach_info.SetIgnoreExisting(false);66    break;67 68  default:69    llvm_unreachable("Unimplemented option");70  }71  return error;72}73 74llvm::ArrayRef<OptionDefinition> CommandOptionsProcessAttach::GetDefinitions() {75  return llvm::ArrayRef(g_process_attach_options);76}77