1 //===-- OptionGroupArchitecture.cpp -----------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/Interpreter/OptionGroupArchitecture.h"
10 #include "lldb/Host/OptionParser.h"
11 #include "lldb/Target/Platform.h"
14 using namespace lldb_private;
16 OptionGroupArchitecture::OptionGroupArchitecture() : m_arch_str() {}
18 OptionGroupArchitecture::~OptionGroupArchitecture() {}
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."},
26 llvm::ArrayRef<OptionDefinition> OptionGroupArchitecture::GetDefinitions() {
27 return llvm::makeArrayRef(g_option_table);
30 bool OptionGroupArchitecture::GetArchitecture(Platform *platform,
32 arch = Platform::GetAugmentedArchSpec(platform, m_arch_str);
33 return arch.IsValid();
37 OptionGroupArchitecture::SetOptionValue(uint32_t option_idx,
38 llvm::StringRef option_arg,
39 ExecutionContext *execution_context) {
41 const int short_option = g_option_table[option_idx].short_option;
43 switch (short_option) {
45 m_arch_str.assign(option_arg);
49 error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
56 void OptionGroupArchitecture::OptionParsingStarting(
57 ExecutionContext *execution_context) {