1 //===-- OptionGroupPlatform.cpp ---------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/lldb-python.h"
12 #include "lldb/Interpreter/OptionGroupPlatform.h"
16 // Other libraries and framework includes
18 #include "lldb/Interpreter/CommandInterpreter.h"
19 #include "lldb/Target/Platform.h"
20 #include "lldb/Utility/Utils.h"
23 using namespace lldb_private;
26 OptionGroupPlatform::CreatePlatformWithOptions (CommandInterpreter &interpreter,
30 ArchSpec &platform_arch) const
32 PlatformSP platform_sp;
34 if (!m_platform_name.empty())
36 platform_sp = Platform::Create (m_platform_name.c_str(), error);
39 if (platform_arch.IsValid() && !platform_sp->IsCompatibleArchitecture(arch, false, &platform_arch))
41 error.SetErrorStringWithFormat ("platform '%s' doesn't support '%s'",
42 platform_sp->GetName().GetCString(),
43 arch.GetTriple().getTriple().c_str());
49 else if (arch.IsValid())
51 platform_sp = Platform::Create (arch, &platform_arch, error);
56 interpreter.GetDebugger().GetPlatformList().Append (platform_sp, make_selected);
57 if (m_os_version_major != UINT32_MAX)
59 platform_sp->SetOSVersion (m_os_version_major,
65 platform_sp->SetSDKRootDirectory (m_sdk_sysroot);
68 platform_sp->SetSDKBuild (m_sdk_build);
75 OptionGroupPlatform::OptionParsingStarting (CommandInterpreter &interpreter)
77 m_platform_name.clear();
78 m_sdk_sysroot.Clear();
80 m_os_version_major = UINT32_MAX;
81 m_os_version_minor = UINT32_MAX;
82 m_os_version_update = UINT32_MAX;
85 static OptionDefinition
88 { LLDB_OPT_SET_ALL, false, "platform", 'p', required_argument, NULL, 0, eArgTypePlatform, "Specify name of the platform to use for this target, creating the platform if necessary."},
89 { LLDB_OPT_SET_ALL, false, "version" , 'v', required_argument, NULL, 0, eArgTypeNone, "Specify the initial SDK version to use prior to connecting." },
90 { LLDB_OPT_SET_ALL, false, "build" , 'b', required_argument, NULL, 0, eArgTypeNone, "Specify the initial SDK build number." },
91 { LLDB_OPT_SET_ALL, false, "sysroot" , 'S', required_argument, NULL, 0, eArgTypeFilename, "Specify the SDK root directory that contains a root of all remote system files." }
94 const OptionDefinition*
95 OptionGroupPlatform::GetDefinitions ()
97 if (m_include_platform_option)
98 return g_option_table;
99 return g_option_table + 1;
103 OptionGroupPlatform::GetNumDefinitions ()
105 if (m_include_platform_option)
106 return llvm::array_lengthof(g_option_table);
107 return llvm::array_lengthof(g_option_table) - 1;
112 OptionGroupPlatform::SetOptionValue (CommandInterpreter &interpreter,
114 const char *option_arg)
117 if (!m_include_platform_option)
120 const int short_option = g_option_table[option_idx].short_option;
122 switch (short_option)
125 m_platform_name.assign (option_arg);
129 if (Args::StringToVersion (option_arg,
132 m_os_version_update) == option_arg)
133 error.SetErrorStringWithFormat ("invalid version string '%s'", option_arg);
137 m_sdk_build.SetCString (option_arg);
141 m_sdk_sysroot.SetCString (option_arg);
145 error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);