Greg Clayton | abe0fed | 2011-04-18 08:33:37 +0000 | [diff] [blame] | 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 "OptionGroupArchitecture.h" |
| 11 | |
| 12 | // C Includes |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
| 16 | |
| 17 | using namespace lldb; |
| 18 | using namespace lldb_private; |
| 19 | |
| 20 | OptionGroupArchitecture::OptionGroupArchitecture() : |
| 21 | m_arch_str () |
| 22 | { |
| 23 | } |
| 24 | |
| 25 | OptionGroupArchitecture::~OptionGroupArchitecture () |
| 26 | { |
| 27 | } |
| 28 | |
| 29 | OptionDefinition g_file_option_table[] = |
| 30 | { |
| 31 | { LLDB_OPT_SET_1 , false, "arch" , 'a', required_argument, NULL, 0, eArgTypeArchitecture , "Specify the architecture for the target."}, |
| 32 | }; |
| 33 | const uint32_t k_num_file_options = sizeof(g_file_option_table)/sizeof(OptionDefinition); |
| 34 | |
| 35 | uint32_t |
| 36 | OptionGroupArchitecture::GetNumDefinitions () |
| 37 | { |
| 38 | return k_num_file_options; |
| 39 | } |
| 40 | |
| 41 | const OptionDefinition * |
| 42 | OptionGroupArchitecture::GetDefinitions () |
| 43 | { |
| 44 | return g_file_option_table; |
| 45 | } |
| 46 | |
| 47 | bool |
| 48 | OptionGroupArchitecture::GetArchitecture (Platform *platform, ArchSpec &arch) |
| 49 | { |
| 50 | if (m_arch_str.empty()) |
| 51 | arch.Clear(); |
| 52 | else |
| 53 | arch.SetTriple(m_arch_str.c_str(), platform); |
| 54 | return arch.IsValid(); |
| 55 | } |
| 56 | |
| 57 | |
| 58 | Error |
| 59 | OptionGroupArchitecture::SetOptionValue (CommandInterpreter &interpreter, |
| 60 | uint32_t option_idx, |
| 61 | const char *option_arg) |
| 62 | { |
| 63 | Error error; |
| 64 | char short_option = (char) g_file_option_table[option_idx].short_option; |
| 65 | |
| 66 | switch (short_option) |
| 67 | { |
| 68 | case 'a': |
| 69 | m_arch_str.assign (option_arg); |
| 70 | break; |
| 71 | |
| 72 | default: |
| 73 | error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option); |
| 74 | break; |
| 75 | } |
| 76 | |
| 77 | return error; |
| 78 | } |
| 79 | |
| 80 | void |
| 81 | OptionGroupArchitecture::OptionParsingStarting (CommandInterpreter &interpreter) |
| 82 | { |
| 83 | m_arch_str.clear(); |
| 84 | } |
| 85 | |