1//===-- OptionGroupArchitecture.cpp -----------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#include "lldb/Interpreter/OptionGroupArchitecture.h" 11 12// C Includes 13// C++ Includes 14// Other libraries and framework includes 15// Project includes 16#include "lldb/Utility/Utils.h" 17 18using namespace lldb; 19using namespace lldb_private; 20 21OptionGroupArchitecture::OptionGroupArchitecture() : 22 m_arch_str () 23{ 24} 25 26OptionGroupArchitecture::~OptionGroupArchitecture () 27{ 28} 29 30static OptionDefinition 31g_option_table[] = 32{ 33 { LLDB_OPT_SET_1 , false, "arch" , 'a', required_argument, NULL, 0, eArgTypeArchitecture , "Specify the architecture for the target."}, 34}; 35 36uint32_t 37OptionGroupArchitecture::GetNumDefinitions () 38{ 39 return llvm::array_lengthof(g_option_table); 40} 41 42const OptionDefinition * 43OptionGroupArchitecture::GetDefinitions () 44{ 45 return g_option_table; 46} 47 48bool 49OptionGroupArchitecture::GetArchitecture (Platform *platform, ArchSpec &arch) 50{ 51 if (m_arch_str.empty()) 52 arch.Clear(); 53 else 54 arch.SetTriple(m_arch_str.c_str(), platform); 55 return arch.IsValid(); 56} 57 58 59Error 60OptionGroupArchitecture::SetOptionValue (CommandInterpreter &interpreter, 61 uint32_t option_idx, 62 const char *option_arg) 63{ 64 Error error; 65 const int short_option = g_option_table[option_idx].short_option; 66 67 switch (short_option) 68 { 69 case 'a': 70 m_arch_str.assign (option_arg); 71 break; 72 73 default: 74 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option); 75 break; 76 } 77 78 return error; 79} 80 81void 82OptionGroupArchitecture::OptionParsingStarting (CommandInterpreter &interpreter) 83{ 84 m_arch_str.clear(); 85} 86 87