LLDB  mainline
OptionGroupArchitecture.cpp
Go to the documentation of this file.
1 //===-- OptionGroupArchitecture.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-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(std::string(option_arg));
46  break;
47 
48  default:
49  llvm_unreachable("Unimplemented option");
50  }
51 
52  return error;
53 }
54 
56  ExecutionContext *execution_context) {
57  m_arch_str.clear();
58 }
A class that represents a running process on the host machine.
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
An architecture specification class.
Definition: ArchSpec.h:33
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:332
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:72
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
#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:382