]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Interpreter/OptionGroupArchitecture.cpp
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Interpreter / OptionGroupArchitecture.cpp
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
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
16 OptionGroupArchitecture::OptionGroupArchitecture() : m_arch_str() {}
17
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
26 llvm::ArrayRef<OptionDefinition> OptionGroupArchitecture::GetDefinitions() {
27   return llvm::makeArrayRef(g_option_table);
28 }
29
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
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(option_arg);
46     break;
47
48   default:
49     error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
50     break;
51   }
52
53   return error;
54 }
55
56 void OptionGroupArchitecture::OptionParsingStarting(
57     ExecutionContext *execution_context) {
58   m_arch_str.clear();
59 }