]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/lldb/source/Interpreter/OptionGroupArchitecture.cpp
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / tools / lldb / source / Interpreter / OptionGroupArchitecture.cpp
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
18 using namespace lldb;
19 using namespace lldb_private;
20
21 OptionGroupArchitecture::OptionGroupArchitecture() :
22     m_arch_str ()
23 {
24 }
25
26 OptionGroupArchitecture::~OptionGroupArchitecture ()
27 {
28 }
29
30 static OptionDefinition
31 g_option_table[] =
32 {
33     { LLDB_OPT_SET_1 , false, "arch"    , 'a', OptionParser::eRequiredArgument, NULL, 0, eArgTypeArchitecture , "Specify the architecture for the target."},
34 };
35
36 uint32_t
37 OptionGroupArchitecture::GetNumDefinitions ()
38 {
39     return llvm::array_lengthof(g_option_table);
40 }
41
42 const OptionDefinition *
43 OptionGroupArchitecture::GetDefinitions ()
44 {
45     return g_option_table;
46 }
47
48 bool
49 OptionGroupArchitecture::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
59 Error
60 OptionGroupArchitecture::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
81 void
82 OptionGroupArchitecture::OptionParsingStarting (CommandInterpreter &interpreter)
83 {
84     m_arch_str.clear();
85 }
86