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