blob: a523f3c8e35114aaac5045f35a0ff3f0a9b22514 [file] [log] [blame]
Greg Claytonabe0fed2011-04-18 08:33:37 +00001//===-- 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
17using namespace lldb;
18using namespace lldb_private;
19
20OptionGroupArchitecture::OptionGroupArchitecture() :
21 m_arch_str ()
22{
23}
24
25OptionGroupArchitecture::~OptionGroupArchitecture ()
26{
27}
28
Greg Clayton57b3c6b2011-04-27 22:04:39 +000029static OptionDefinition
30g_option_table[] =
Greg Claytonabe0fed2011-04-18 08:33:37 +000031{
Greg Clayton57b3c6b2011-04-27 22:04:39 +000032{ LLDB_OPT_SET_1 , false, "arch" , 'a', required_argument, NULL, 0, eArgTypeArchitecture , "Specify the architecture for the target."},
Greg Claytonabe0fed2011-04-18 08:33:37 +000033};
Greg Clayton57b3c6b2011-04-27 22:04:39 +000034
35const uint32_t k_num_file_options = sizeof(g_option_table)/sizeof(OptionDefinition);
Greg Claytonabe0fed2011-04-18 08:33:37 +000036
37uint32_t
38OptionGroupArchitecture::GetNumDefinitions ()
39{
40 return k_num_file_options;
41}
42
43const OptionDefinition *
44OptionGroupArchitecture::GetDefinitions ()
45{
Greg Clayton57b3c6b2011-04-27 22:04:39 +000046 return g_option_table;
Greg Claytonabe0fed2011-04-18 08:33:37 +000047}
48
49bool
50OptionGroupArchitecture::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
60Error
61OptionGroupArchitecture::SetOptionValue (CommandInterpreter &interpreter,
62 uint32_t option_idx,
63 const char *option_arg)
64{
65 Error error;
Greg Clayton57b3c6b2011-04-27 22:04:39 +000066 char short_option = (char) g_option_table[option_idx].short_option;
Greg Claytonabe0fed2011-04-18 08:33:37 +000067
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
82void
83OptionGroupArchitecture::OptionParsingStarting (CommandInterpreter &interpreter)
84{
85 m_arch_str.clear();
86}
87