blob: f96d704e3f1f5c72aa1b9f307adc465a7220aecc [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
29OptionDefinition 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};
33const uint32_t k_num_file_options = sizeof(g_file_option_table)/sizeof(OptionDefinition);
34
35uint32_t
36OptionGroupArchitecture::GetNumDefinitions ()
37{
38 return k_num_file_options;
39}
40
41const OptionDefinition *
42OptionGroupArchitecture::GetDefinitions ()
43{
44 return g_file_option_table;
45}
46
47bool
48OptionGroupArchitecture::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
58Error
59OptionGroupArchitecture::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
80void
81OptionGroupArchitecture::OptionParsingStarting (CommandInterpreter &interpreter)
82{
83 m_arch_str.clear();
84}
85