labath created this revision.

- GetFileWithUUID: All platforms except PlatformDarwin had this.

However, I see no reason why this code would not apply there as well.

- GetProcessInfo, FindProcesses: The implementation was the same in all classes.

- GetFullNameForDylib: This code should apply to all non-darwin

platforms. I've kept the PlatformDarwin override as the situation is
different there.


https://reviews.llvm.org/D29496

Files:
  source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
  source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
  source/Plugins/Platform/Kalimba/PlatformKalimba.cpp
  source/Plugins/Platform/Kalimba/PlatformKalimba.h
  source/Plugins/Platform/Linux/PlatformLinux.cpp
  source/Plugins/Platform/Linux/PlatformLinux.h
  source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  source/Plugins/Platform/MacOSX/PlatformDarwin.h
  source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
  source/Plugins/Platform/NetBSD/PlatformNetBSD.h
  source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  source/Plugins/Platform/POSIX/PlatformPOSIX.h

Index: source/Plugins/Platform/POSIX/PlatformPOSIX.h
===================================================================
--- source/Plugins/Platform/POSIX/PlatformPOSIX.h
+++ source/Plugins/Platform/POSIX/PlatformPOSIX.h
@@ -105,6 +105,14 @@
       lldb::ModuleSP &module_sp,
       const lldb_private::FileSpecList *module_search_paths_ptr) override;
 
+  lldb_private::Error GetFileWithUUID(const lldb_private::FileSpec &platform_file, const lldb_private::UUID *uuid,
+                        lldb_private::FileSpec &local_file) override;
+
+  bool GetProcessInfo(lldb::pid_t pid, lldb_private::ProcessInstanceInfo &proc_info) override;
+
+  uint32_t FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info,
+                         lldb_private::ProcessInstanceInfoList &process_infos) override;
+
   lldb_private::Error MakeDirectory(const lldb_private::FileSpec &file_spec,
                                     uint32_t mode) override;
 
@@ -169,6 +177,8 @@
   size_t ConnectToWaitingProcesses(lldb_private::Debugger &debugger,
                                    lldb_private::Error &error) override;
 
+  lldb_private::ConstString GetFullNameForDylib(lldb_private::ConstString basename) override;
+
 protected:
   std::unique_ptr<lldb_private::OptionGroupPlatformRSync>
       m_option_group_platform_rsync;
Index: source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
===================================================================
--- source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -250,6 +250,38 @@
   return error;
 }
 
+Error PlatformPOSIX::GetFileWithUUID(const FileSpec &platform_file,
+                                       const UUID *uuid_ptr,
+                                       FileSpec &local_file) {
+  if (IsRemote() && m_remote_platform_sp)
+      return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
+                                                   local_file);
+
+  // Default to the local case
+  local_file = platform_file;
+  return Error();
+}
+
+bool PlatformPOSIX::GetProcessInfo(lldb::pid_t pid,
+                                     ProcessInstanceInfo &process_info) {
+  if (IsHost())
+    return Platform::GetProcessInfo(pid, process_info);
+  if (m_remote_platform_sp)
+    return m_remote_platform_sp->GetProcessInfo(pid, process_info);
+  return false;
+}
+
+uint32_t
+PlatformPOSIX::FindProcesses(const ProcessInstanceInfoMatch &match_info,
+                               ProcessInstanceInfoList &process_infos) {
+  if (IsHost())
+    return Platform::FindProcesses(match_info, process_infos);
+  if (m_remote_platform_sp)
+    return
+      m_remote_platform_sp->FindProcesses(match_info, process_infos);
+  return 0;
+}
+
 Error PlatformPOSIX::MakeDirectory(const FileSpec &file_spec,
                                    uint32_t file_permissions) {
   if (m_remote_platform_sp)
@@ -1003,3 +1035,12 @@
     return m_remote_platform_sp->ConnectToWaitingProcesses(debugger, error);
   return Platform::ConnectToWaitingProcesses(debugger, error);
 }
+
+ConstString PlatformPOSIX::GetFullNameForDylib(ConstString basename) {
+  if (basename.IsEmpty())
+    return basename;
+
+  StreamString stream;
+  stream.Printf("lib%s.so", basename.GetCString());
+  return ConstString(stream.GetString());
+}
Index: source/Plugins/Platform/NetBSD/PlatformNetBSD.h
===================================================================
--- source/Plugins/Platform/NetBSD/PlatformNetBSD.h
+++ source/Plugins/Platform/NetBSD/PlatformNetBSD.h
@@ -81,23 +81,14 @@
 
   const char *GetGroupName(uint32_t gid) override;
 
-  bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override;
-
-  uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info,
-                         ProcessInstanceInfoList &process_infos) override;
-
   Error LaunchProcess(ProcessLaunchInfo &launch_info) override;
 
   lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger,
                          Target *target, Error &error) override;
 
   // NetBSD processes can not be launched by spawning and attaching.
   bool CanDebugProcess() override { return false; }
 
-  // Only on PlatformMacOSX:
-  Error GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid,
-                        FileSpec &local_file) override;
-
   Error GetSharedModule(const ModuleSpec &module_spec, Process *process,
                         lldb::ModuleSP &module_sp,
                         const FileSpecList *module_search_paths_ptr,
Index: source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
===================================================================
--- source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
+++ source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
@@ -126,21 +126,6 @@
   }
 }
 
-// From PlatformMacOSX only
-Error PlatformNetBSD::GetFileWithUUID(const FileSpec &platform_file,
-                                      const UUID *uuid_ptr,
-                                      FileSpec &local_file) {
-  if (IsRemote()) {
-    if (m_remote_platform_sp)
-      return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
-                                                   local_file);
-  }
-
-  // Default to the local case
-  local_file = platform_file;
-  return Error();
-}
-
 //------------------------------------------------------------------
 /// Default Constructor
 //------------------------------------------------------------------
@@ -238,33 +223,6 @@
   return error;
 }
 
-bool PlatformNetBSD::GetProcessInfo(lldb::pid_t pid,
-                                    ProcessInstanceInfo &process_info) {
-  bool success = false;
-  if (IsHost()) {
-    success = Platform::GetProcessInfo(pid, process_info);
-  } else if (m_remote_platform_sp) {
-    success = m_remote_platform_sp->GetProcessInfo(pid, process_info);
-  }
-  return success;
-}
-
-uint32_t
-PlatformNetBSD::FindProcesses(const ProcessInstanceInfoMatch &match_info,
-                              ProcessInstanceInfoList &process_infos) {
-  uint32_t match_count = 0;
-  if (IsHost()) {
-    // Let the base class figure out the host details
-    match_count = Platform::FindProcesses(match_info, process_infos);
-  } else {
-    // If we are remote, we can only return results if we are connected
-    if (m_remote_platform_sp)
-      match_count =
-          m_remote_platform_sp->FindProcesses(match_info, process_infos);
-  }
-  return match_count;
-}
-
 const char *PlatformNetBSD::GetUserName(uint32_t uid) {
   // Check the cache in Platform in case we have already looked this uid up
   const char *user_name = Platform::GetUserName(uid);
Index: source/Plugins/Platform/MacOSX/PlatformDarwin.h
===================================================================
--- source/Plugins/Platform/MacOSX/PlatformDarwin.h
+++ source/Plugins/Platform/MacOSX/PlatformDarwin.h
@@ -51,16 +51,9 @@
       lldb_private::Target &target,
       lldb_private::BreakpointSite *bp_site) override;
 
-  bool GetProcessInfo(lldb::pid_t pid,
-                      lldb_private::ProcessInstanceInfo &proc_info) override;
-
   lldb::BreakpointSP
   SetThreadCreationBreakpoint(lldb_private::Target &target) override;
 
-  uint32_t
-  FindProcesses(const lldb_private::ProcessInstanceInfoMatch &match_info,
-                lldb_private::ProcessInstanceInfoList &process_infos) override;
-
   bool ModuleIsExcludedForUnconstrainedSearches(
       lldb_private::Target &target, const lldb::ModuleSP &module_sp) override;
 
Index: source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
===================================================================
--- source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -489,34 +489,6 @@
   return 0;
 }
 
-bool PlatformDarwin::GetProcessInfo(lldb::pid_t pid,
-                                    ProcessInstanceInfo &process_info) {
-  bool success = false;
-  if (IsHost()) {
-    success = Platform::GetProcessInfo(pid, process_info);
-  } else {
-    if (m_remote_platform_sp)
-      success = m_remote_platform_sp->GetProcessInfo(pid, process_info);
-  }
-  return success;
-}
-
-uint32_t
-PlatformDarwin::FindProcesses(const ProcessInstanceInfoMatch &match_info,
-                              ProcessInstanceInfoList &process_infos) {
-  uint32_t match_count = 0;
-  if (IsHost()) {
-    // Let the base class figure out the host details
-    match_count = Platform::FindProcesses(match_info, process_infos);
-  } else {
-    // If we are remote, we can only return results if we are connected
-    if (m_remote_platform_sp)
-      match_count =
-          m_remote_platform_sp->FindProcesses(match_info, process_infos);
-  }
-  return match_count;
-}
-
 bool PlatformDarwin::ModuleIsExcludedForUnconstrainedSearches(
     lldb_private::Target &target, const lldb::ModuleSP &module_sp) {
   if (!module_sp)
Index: source/Plugins/Platform/Linux/PlatformLinux.h
===================================================================
--- source/Plugins/Platform/Linux/PlatformLinux.h
+++ source/Plugins/Platform/Linux/PlatformLinux.h
@@ -53,14 +53,6 @@
 
   void GetStatus(Stream &strm) override;
 
-  Error GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid,
-                        FileSpec &local_file) override;
-
-  bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override;
-
-  uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info,
-                         ProcessInstanceInfoList &process_infos) override;
-
   bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override;
 
   int32_t GetResumeCountForLaunchInfo(ProcessLaunchInfo &launch_info) override;
@@ -76,8 +68,6 @@
   uint64_t ConvertMmapFlagsToPlatform(const ArchSpec &arch,
                                       unsigned flags) override;
 
-  ConstString GetFullNameForDylib(ConstString basename) override;
-
 private:
   DISALLOW_COPY_AND_ASSIGN(PlatformLinux);
 };
Index: source/Plugins/Platform/Linux/PlatformLinux.cpp
===================================================================
--- source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -205,63 +205,15 @@
   PlatformPOSIX::Terminate();
 }
 
-Error PlatformLinux::GetFileWithUUID(const FileSpec &platform_file,
-                                     const UUID *uuid_ptr,
-                                     FileSpec &local_file) {
-  if (IsRemote()) {
-    if (m_remote_platform_sp)
-      return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
-                                                   local_file);
-  }
-
-  // Default to the local case
-  local_file = platform_file;
-  return Error();
-}
-
 //------------------------------------------------------------------
 /// Default Constructor
 //------------------------------------------------------------------
 PlatformLinux::PlatformLinux(bool is_host)
     : PlatformPOSIX(is_host) // This is the local host platform
 {}
 
-//------------------------------------------------------------------
-/// Destructor.
-///
-/// The destructor is virtual since this class is designed to be
-/// inherited from by the plug-in instance.
-//------------------------------------------------------------------
 PlatformLinux::~PlatformLinux() = default;
 
-bool PlatformLinux::GetProcessInfo(lldb::pid_t pid,
-                                   ProcessInstanceInfo &process_info) {
-  bool success = false;
-  if (IsHost()) {
-    success = Platform::GetProcessInfo(pid, process_info);
-  } else {
-    if (m_remote_platform_sp)
-      success = m_remote_platform_sp->GetProcessInfo(pid, process_info);
-  }
-  return success;
-}
-
-uint32_t
-PlatformLinux::FindProcesses(const ProcessInstanceInfoMatch &match_info,
-                             ProcessInstanceInfoList &process_infos) {
-  uint32_t match_count = 0;
-  if (IsHost()) {
-    // Let the base class figure out the host details
-    match_count = Platform::FindProcesses(match_info, process_infos);
-  } else {
-    // If we are remote, we can only return results if we are connected
-    if (m_remote_platform_sp)
-      match_count =
-          m_remote_platform_sp->FindProcesses(match_info, process_infos);
-  }
-  return match_count;
-}
-
 bool PlatformLinux::GetSupportedArchitectureAtIndex(uint32_t idx,
                                                     ArchSpec &arch) {
   if (IsHost()) {
@@ -582,11 +534,3 @@
   return flags_platform;
 }
 
-ConstString PlatformLinux::GetFullNameForDylib(ConstString basename) {
-  if (basename.IsEmpty())
-    return basename;
-
-  StreamString stream;
-  stream.Printf("lib%s.so", basename.GetCString());
-  return ConstString(stream.GetString());
-}
Index: source/Plugins/Platform/Kalimba/PlatformKalimba.h
===================================================================
--- source/Plugins/Platform/Kalimba/PlatformKalimba.h
+++ source/Plugins/Platform/Kalimba/PlatformKalimba.h
@@ -51,11 +51,6 @@
 
   void GetStatus(Stream &strm) override;
 
-  Error GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid,
-                        FileSpec &local_file) override;
-
-  bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override;
-
   bool GetSupportedArchitectureAtIndex(uint32_t idx, ArchSpec &arch) override;
 
   size_t GetSoftwareBreakpointTrapOpcode(Target &target,
Index: source/Plugins/Platform/Kalimba/PlatformKalimba.cpp
===================================================================
--- source/Plugins/Platform/Kalimba/PlatformKalimba.cpp
+++ source/Plugins/Platform/Kalimba/PlatformKalimba.cpp
@@ -84,12 +84,6 @@
   Platform::Terminate();
 }
 
-Error PlatformKalimba::GetFileWithUUID(const FileSpec & /*platform_file*/,
-                                       const UUID * /*uuid_ptr*/,
-                                       FileSpec & /*local_file*/) {
-  return Error();
-}
-
 //------------------------------------------------------------------
 /// Default Constructor
 //------------------------------------------------------------------
@@ -105,18 +99,6 @@
 //------------------------------------------------------------------
 PlatformKalimba::~PlatformKalimba() {}
 
-bool PlatformKalimba::GetProcessInfo(lldb::pid_t pid,
-                                     ProcessInstanceInfo &process_info) {
-  bool success = false;
-  if (IsHost()) {
-    success = false;
-  } else {
-    if (m_remote_platform_sp)
-      success = m_remote_platform_sp->GetProcessInfo(pid, process_info);
-  }
-  return success;
-}
-
 bool PlatformKalimba::GetSupportedArchitectureAtIndex(uint32_t idx,
                                                       ArchSpec &arch) {
   if (idx == 0) {
Index: source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
===================================================================
--- source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
+++ source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
@@ -84,23 +84,14 @@
 
   const char *GetGroupName(uint32_t gid) override;
 
-  bool GetProcessInfo(lldb::pid_t pid, ProcessInstanceInfo &proc_info) override;
-
-  uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info,
-                         ProcessInstanceInfoList &process_infos) override;
-
   Error LaunchProcess(ProcessLaunchInfo &launch_info) override;
 
   lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger,
                          Target *target, Error &error) override;
 
   // FreeBSD processes can not be launched by spawning and attaching.
   bool CanDebugProcess() override { return false; }
 
-  // Only on PlatformMacOSX:
-  Error GetFileWithUUID(const FileSpec &platform_file, const UUID *uuid,
-                        FileSpec &local_file) override;
-
   Error GetSharedModule(const ModuleSpec &module_spec, Process *process,
                         lldb::ModuleSP &module_sp,
                         const FileSpecList *module_search_paths_ptr,
Index: source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
===================================================================
--- source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
+++ source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
@@ -134,21 +134,6 @@
   }
 }
 
-// From PlatformMacOSX only
-Error PlatformFreeBSD::GetFileWithUUID(const FileSpec &platform_file,
-                                       const UUID *uuid_ptr,
-                                       FileSpec &local_file) {
-  if (IsRemote()) {
-    if (m_remote_platform_sp)
-      return m_remote_platform_sp->GetFileWithUUID(platform_file, uuid_ptr,
-                                                   local_file);
-  }
-
-  // Default to the local case
-  local_file = platform_file;
-  return Error();
-}
-
 //------------------------------------------------------------------
 /// Default Constructor
 //------------------------------------------------------------------
@@ -256,33 +241,6 @@
   return error;
 }
 
-bool PlatformFreeBSD::GetProcessInfo(lldb::pid_t pid,
-                                     ProcessInstanceInfo &process_info) {
-  bool success = false;
-  if (IsHost()) {
-    success = Platform::GetProcessInfo(pid, process_info);
-  } else if (m_remote_platform_sp) {
-    success = m_remote_platform_sp->GetProcessInfo(pid, process_info);
-  }
-  return success;
-}
-
-uint32_t
-PlatformFreeBSD::FindProcesses(const ProcessInstanceInfoMatch &match_info,
-                               ProcessInstanceInfoList &process_infos) {
-  uint32_t match_count = 0;
-  if (IsHost()) {
-    // Let the base class figure out the host details
-    match_count = Platform::FindProcesses(match_info, process_infos);
-  } else {
-    // If we are remote, we can only return results if we are connected
-    if (m_remote_platform_sp)
-      match_count =
-          m_remote_platform_sp->FindProcesses(match_info, process_infos);
-  }
-  return match_count;
-}
-
 const char *PlatformFreeBSD::GetUserName(uint32_t uid) {
   // Check the cache in Platform in case we have already looked this uid up
   const char *user_name = Platform::GetUserName(uid);
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to