All other platforms use GetSupportedArchitectures now.
/// 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);
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;
+}
/// 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);
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;
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,
// 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
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) {
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());
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());
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)));