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 static constexpr OptionDefinition g_option_table[] = {
17  {LLDB_OPT_SET_1, false, "arch", 'a', OptionParser::eRequiredArgument,
18  nullptr, {}, 0, eArgTypeArchitecture,
19  "Specify the architecture for the target."},
20 };
21 
22 llvm::ArrayRef<OptionDefinition> OptionGroupArchitecture::GetDefinitions() {
23  return llvm::makeArrayRef(g_option_table);
24 }
25 
26 bool OptionGroupArchitecture::GetArchitecture(Platform *platform,
27  ArchSpec &arch) {
28  arch = Platform::GetAugmentedArchSpec(platform, m_arch_str);
29  return arch.IsValid();
30 }
31 
32 Status
33 OptionGroupArchitecture::SetOptionValue(uint32_t option_idx,
34  llvm::StringRef option_arg,
35  ExecutionContext *execution_context) {
36  Status error;
37  const int short_option = g_option_table[option_idx].short_option;
38 
39  switch (short_option) {
40  case 'a':
41  m_arch_str.assign(std::string(option_arg));
42  break;
43 
44  default:
45  llvm_unreachable("Unimplemented option");
46  }
47 
48  return error;
49 }
50 
51 void OptionGroupArchitecture::OptionParsingStarting(
52  ExecutionContext *execution_context) {
53  m_arch_str.clear();
54 }
lldb_private::ExecutionContext
Definition: ExecutionContext.h:291
lldb_private::ArchSpec
Definition: ArchSpec.h:33
OptionGroupArchitecture.h
lldb::eArgTypeArchitecture
@ eArgTypeArchitecture
Definition: lldb-enumerations.h:520
g_option_table
static constexpr OptionDefinition g_option_table[]
Definition: OptionGroupArchitecture.cpp:16
Platform.h
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
LLDB_OPT_SET_1
#define LLDB_OPT_SET_1
Definition: lldb-defines.h:112
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:38
lldb_private::ArchSpec::IsValid
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:342
lldb_private::Status
Definition: Status.h:44
uint32_t
lldb_private::Platform
Definition: Platform.h:72
OptionParser.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::OptionDefinition
Definition: OptionDefinition.h:20
lldb_private::OptionDefinition::short_option
int short_option
Single character for this option.
Definition: OptionDefinition.h:32
lldb
Definition: SBAddress.h:15