forked from OSchip/llvm-project
[lldb] Move GetSupportedArchitectureAtIndex to PlatformDarwin
All other platforms use GetSupportedArchitectures now.
This commit is contained in:
parent
5ba795c6e8
commit
96beb30fbb
|
@ -310,25 +310,7 @@ public:
|
|||
|
||||
/// Get the platform's supported architectures in the order in which they
|
||||
/// should be searched.
|
||||
///
|
||||
/// \param[in] idx
|
||||
/// A zero based architecture index
|
||||
///
|
||||
/// \param[out] arch
|
||||
/// A copy of the architecture at index if the return value is
|
||||
/// \b true.
|
||||
///
|
||||
/// \return
|
||||
/// \b true if \a arch was filled in and is valid, \b false
|
||||
/// otherwise.
|
||||
virtual bool GetSupportedArchitectureAtIndex(uint32_t idx,
|
||||
ArchSpec &arch);
|
||||
|
||||
/// Get the platform's supported architectures in the order in which they
|
||||
/// should be searched.
|
||||
/// NB: This implementation is mutually recursive with
|
||||
/// GetSupportedArchitectureAtIndex. Subclasses should implement one of them.
|
||||
virtual std::vector<ArchSpec> GetSupportedArchitectures();
|
||||
virtual std::vector<ArchSpec> GetSupportedArchitectures() = 0;
|
||||
|
||||
virtual size_t GetSoftwareBreakpointTrapOpcode(Target &target,
|
||||
BreakpointSite *bp_site);
|
||||
|
|
|
@ -1367,3 +1367,11 @@ FileSpec PlatformDarwin::GetCurrentCommandLineToolsDirectory() {
|
|||
return FileSpec(FindComponentInPath(fspec.GetPath(), "CommandLineTools"));
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<ArchSpec> PlatformDarwin::GetSupportedArchitectures() {
|
||||
std::vector<ArchSpec> result;
|
||||
ArchSpec arch;
|
||||
for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(idx, arch); ++idx)
|
||||
result.push_back(arch);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -102,6 +102,8 @@ public:
|
|||
/// located in.
|
||||
static lldb_private::FileSpec GetCurrentCommandLineToolsDirectory();
|
||||
|
||||
std::vector<lldb_private::ArchSpec> GetSupportedArchitectures() override;
|
||||
|
||||
protected:
|
||||
static const char *GetCompatibleArch(lldb_private::ArchSpec::Core core,
|
||||
size_t idx);
|
||||
|
@ -172,6 +174,10 @@ protected:
|
|||
static std::string FindComponentInPath(llvm::StringRef path,
|
||||
llvm::StringRef component);
|
||||
|
||||
virtual bool
|
||||
GetSupportedArchitectureAtIndex(uint32_t idx,
|
||||
lldb_private::ArchSpec &arch) = 0;
|
||||
|
||||
std::string m_developer_directory;
|
||||
llvm::StringMap<std::string> m_sdk_path;
|
||||
std::mutex m_sdk_path_mutex;
|
||||
|
|
|
@ -1222,22 +1222,6 @@ Platform::CreateArchList(llvm::ArrayRef<llvm::Triple::ArchType> archs,
|
|||
return list;
|
||||
}
|
||||
|
||||
bool Platform::GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) {
|
||||
const auto &archs = GetSupportedArchitectures();
|
||||
if (idx >= archs.size())
|
||||
return false;
|
||||
arch = archs[idx];
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<ArchSpec> Platform::GetSupportedArchitectures() {
|
||||
std::vector<ArchSpec> result;
|
||||
ArchSpec arch;
|
||||
for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(idx, arch); ++idx)
|
||||
result.push_back(arch);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Lets a platform answer if it is compatible with a given
|
||||
/// architecture and the target triple contained within.
|
||||
bool Platform::IsCompatibleArchitecture(const ArchSpec &arch,
|
||||
|
|
|
@ -131,9 +131,9 @@ Status RemoteAwarePlatform::ResolveExecutable(
|
|||
// architectures that we should be using (in the correct order) and see
|
||||
// if we can find a match that way
|
||||
StreamString arch_names;
|
||||
for (uint32_t idx = 0; GetSupportedArchitectureAtIndex(
|
||||
idx, resolved_module_spec.GetArchitecture());
|
||||
++idx) {
|
||||
llvm::ListSeparator LS;
|
||||
for (const ArchSpec &arch : GetSupportedArchitectures()) {
|
||||
resolved_module_spec.GetArchitecture() = arch;
|
||||
error = ModuleList::GetSharedModule(resolved_module_spec, exe_module_sp,
|
||||
module_search_paths_ptr, nullptr, nullptr);
|
||||
// Did we find an executable using one of the
|
||||
|
@ -144,10 +144,7 @@ Status RemoteAwarePlatform::ResolveExecutable(
|
|||
error.SetErrorToGenericError();
|
||||
}
|
||||
|
||||
if (idx > 0)
|
||||
arch_names.PutCString(", ");
|
||||
arch_names.PutCString(
|
||||
resolved_module_spec.GetArchitecture().GetArchitectureName());
|
||||
arch_names << LS << arch.GetArchitectureName();
|
||||
}
|
||||
|
||||
if (error.Fail() || !exe_module_sp) {
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
|
||||
MOCK_METHOD0(GetDescription, llvm::StringRef());
|
||||
MOCK_METHOD0(GetPluginName, llvm::StringRef());
|
||||
MOCK_METHOD2(GetSupportedArchitectureAtIndex, bool(uint32_t, ArchSpec &));
|
||||
MOCK_METHOD0(GetSupportedArchitectures, std::vector<ArchSpec>());
|
||||
MOCK_METHOD4(Attach,
|
||||
ProcessSP(ProcessAttachInfo &, Debugger &, Target *, Status &));
|
||||
MOCK_METHOD0(CalculateTrapHandlerSymbolNames, void());
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
|
||||
MOCK_METHOD0(GetDescription, llvm::StringRef());
|
||||
MOCK_METHOD0(GetPluginName, llvm::StringRef());
|
||||
MOCK_METHOD2(GetSupportedArchitectureAtIndex, bool(uint32_t, ArchSpec &));
|
||||
MOCK_METHOD0(GetSupportedArchitectures, std::vector<ArchSpec>());
|
||||
MOCK_METHOD4(Attach,
|
||||
ProcessSP(ProcessAttachInfo &, Debugger &, Target *, Status &));
|
||||
MOCK_METHOD0(CalculateTrapHandlerSymbolNames, void());
|
||||
|
@ -73,8 +73,8 @@ TEST_F(RemoteAwarePlatformTest, TestResolveExecutabelOnClientByPlatform) {
|
|||
ModuleSP expected_executable(new Module(executable_spec));
|
||||
|
||||
RemoteAwarePlatformTester platform(false);
|
||||
EXPECT_CALL(platform, GetSupportedArchitectureAtIndex(_, _))
|
||||
.WillRepeatedly(Return(false));
|
||||
EXPECT_CALL(platform, GetSupportedArchitectures())
|
||||
.WillRepeatedly(Return(std::vector<ArchSpec>()));
|
||||
EXPECT_CALL(platform, ResolveRemoteExecutable(_, _))
|
||||
.WillRepeatedly(Return(std::make_pair(Status(), expected_executable)));
|
||||
|
||||
|
|
Loading…
Reference in New Issue