• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
9 #include "lldb/Interpreter/OptionGroupArchitecture.h"
10 #include "lldb/Host/OptionParser.h"
11 #include "lldb/Target/Platform.h"
12 
13 using namespace lldb;
14 using namespace lldb_private;
15 
OptionGroupArchitecture()16 OptionGroupArchitecture::OptionGroupArchitecture() : m_arch_str() {}
17 
~OptionGroupArchitecture()18 OptionGroupArchitecture::~OptionGroupArchitecture() {}
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 
GetDefinitions()26 llvm::ArrayRef<OptionDefinition> OptionGroupArchitecture::GetDefinitions() {
27   return llvm::makeArrayRef(g_option_table);
28 }
29 
GetArchitecture(Platform * platform,ArchSpec & arch)30 bool OptionGroupArchitecture::GetArchitecture(Platform *platform,
31                                               ArchSpec &arch) {
32   arch = Platform::GetAugmentedArchSpec(platform, m_arch_str);
33   return arch.IsValid();
34 }
35 
36 Status
SetOptionValue(uint32_t option_idx,llvm::StringRef option_arg,ExecutionContext * execution_context)37 OptionGroupArchitecture::SetOptionValue(uint32_t option_idx,
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 
OptionParsingStarting(ExecutionContext * execution_context)55 void OptionGroupArchitecture::OptionParsingStarting(
56     ExecutionContext *execution_context) {
57   m_arch_str.clear();
58 }
59