LLDB  mainline
OptionGroupArchitecture.cpp
Go to the documentation of this file.
1 //===-- OptionGroupArchitecture.cpp -----------------------------*- C++ -*-===//
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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 #include "lldb/Host/OptionParser.h"
11 #include "lldb/Target/Platform.h"
12 
13 using namespace lldb;
14 using namespace lldb_private;
15 
16 OptionGroupArchitecture::OptionGroupArchitecture() : m_arch_str() {}
17 
19 
20 static constexpr OptionDefinition g_option_table[] = {
21  {LLDB_OPT_SET_1, false, "arch", 'a', OptionParser::eRequiredArgument,
22  nullptr, {}, 0, eArgTypeArchitecture,
23  "Specify the architecture for the target."},
24 };
25 
26 llvm::ArrayRef<OptionDefinition> OptionGroupArchitecture::GetDefinitions() {
27  return llvm::makeArrayRef(g_option_table);
28 }
29 
31  ArchSpec &arch) {
33  return arch.IsValid();
34 }
35 
36 Status
38  llvm::StringRef option_arg,
39  ExecutionContext *execution_context) {
40  Status error;
41  const int short_option = g_option_table[option_idx].short_option;
42 
43  switch (short_option) {
44  case 'a':
45  m_arch_str.assign(option_arg);
46  break;
47 
48  default:
49  error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
50  break;
51  }
52 
53  return error;
54 }
55 
57  ExecutionContext *execution_context) {
58  m_arch_str.clear();
59 }
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
An architecture specification class.
Definition: ArchSpec.h:32
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:329
static constexpr OptionDefinition g_option_table[]
A plug-in interface definition class for debug platform that includes many platform abilities such as...
Definition: Platform.h:67
void OptionParsingStarting(ExecutionContext *execution_context) override
bool GetArchitecture(Platform *platform, ArchSpec &arch)
Definition: SBAddress.h:15
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Set the current error string to a formatted error string.
Definition: Status.cpp:255
#define LLDB_OPT_SET_1
Definition: lldb-defines.h:111
An error handling class.
Definition: Status.h:44
static ArchSpec GetAugmentedArchSpec(Platform *platform, llvm::StringRef triple)
Augments the triple either with information from platform or the host system (if platform is null)...
Definition: Platform.cpp:372