[lldb] Remove HostProcess:GetMainModule
authorPavel Labath <pavel@labath.sk>
Mon, 21 Feb 2022 14:38:52 +0000 (15:38 +0100)
committerPavel Labath <pavel@labath.sk>
Tue, 22 Feb 2022 15:00:58 +0000 (16:00 +0100)
the function is unused, and the posix implementation is only really correct on linux.

lldb/include/lldb/Host/HostNativeProcessBase.h
lldb/include/lldb/Host/HostProcess.h
lldb/include/lldb/Host/posix/HostProcessPosix.h
lldb/include/lldb/Host/windows/HostProcessWindows.h
lldb/source/Host/common/HostProcess.cpp
lldb/source/Host/posix/HostProcessPosix.cpp
lldb/source/Host/windows/HostProcessWindows.cpp

index 5469f8a..349e334 100644 (file)
@@ -30,7 +30,6 @@ public:
   virtual ~HostNativeProcessBase() = default;
 
   virtual Status Terminate() = 0;
-  virtual Status GetMainModule(FileSpec &file_spec) const = 0;
 
   virtual lldb::pid_t GetProcessId() const = 0;
   virtual bool IsRunning() const = 0;
index 0b7c303..00cb6a2 100644 (file)
@@ -37,7 +37,6 @@ public:
   ~HostProcess();
 
   Status Terminate();
-  Status GetMainModule(FileSpec &file_spec) const;
 
   lldb::pid_t GetProcessId() const;
   bool IsRunning() const;
index 5def1b7..eec19b6 100644 (file)
@@ -27,7 +27,6 @@ public:
   static Status Signal(lldb::process_t process, int signo);
 
   Status Terminate() override;
-  Status GetMainModule(FileSpec &file_spec) const override;
 
   lldb::pid_t GetProcessId() const override;
   bool IsRunning() const override;
index 925d565..dc27bdc 100644 (file)
@@ -25,7 +25,6 @@ public:
   void SetOwnsHandle(bool owns);
 
   Status Terminate() override;
-  Status GetMainModule(FileSpec &file_spec) const override;
 
   lldb::pid_t GetProcessId() const override;
   bool IsRunning() const override;
index 06dd192..83b856d 100644 (file)
@@ -22,10 +22,6 @@ HostProcess::~HostProcess() = default;
 
 Status HostProcess::Terminate() { return m_native_process->Terminate(); }
 
-Status HostProcess::GetMainModule(FileSpec &file_spec) const {
-  return m_native_process->GetMainModule(file_spec);
-}
-
 lldb::pid_t HostProcess::GetProcessId() const {
   return m_native_process->GetProcessId();
 }
index 8599a94..9889be0 100644 (file)
@@ -49,31 +49,6 @@ Status HostProcessPosix::Signal(lldb::process_t process, int signo) {
 
 Status HostProcessPosix::Terminate() { return Signal(SIGKILL); }
 
-Status HostProcessPosix::GetMainModule(FileSpec &file_spec) const {
-  Status error;
-
-  // Use special code here because proc/[pid]/exe is a symbolic link.
-  char link_path[PATH_MAX];
-  if (snprintf(link_path, PATH_MAX, "/proc/%" PRIu64 "/exe", m_process) != 1) {
-    error.SetErrorString("Unable to build /proc/<pid>/exe string");
-    return error;
-  }
-
-  error = FileSystem::Instance().Readlink(FileSpec(link_path), file_spec);
-  if (!error.Success())
-    return error;
-
-  // If the binary has been deleted, the link name has " (deleted)" appended.
-  // Remove if there.
-  if (file_spec.GetFilename().GetStringRef().endswith(" (deleted)")) {
-    const char *filename = file_spec.GetFilename().GetCString();
-    static const size_t deleted_len = strlen(" (deleted)");
-    const size_t len = file_spec.GetFilename().GetLength();
-    file_spec.GetFilename().SetCStringWithLength(filename, len - deleted_len);
-  }
-  return error;
-}
-
 lldb::pid_t HostProcessPosix::GetProcessId() const { return m_process; }
 
 bool HostProcessPosix::IsRunning() const {
index 0dc23e1..741ec68 100644 (file)
@@ -48,24 +48,6 @@ Status HostProcessWindows::Terminate() {
   return error;
 }
 
-Status HostProcessWindows::GetMainModule(FileSpec &file_spec) const {
-  Status error;
-  if (m_process == nullptr)
-    error.SetError(ERROR_INVALID_HANDLE, lldb::eErrorTypeWin32);
-
-  std::vector<wchar_t> wpath(PATH_MAX);
-  if (::GetProcessImageFileNameW(m_process, wpath.data(), wpath.size())) {
-    std::string path;
-    if (llvm::convertWideToUTF8(wpath.data(), path))
-      file_spec.SetFile(path, FileSpec::Style::native);
-    else
-      error.SetErrorString("Error converting path to UTF-8");
-  } else
-    error.SetError(::GetLastError(), lldb::eErrorTypeWin32);
-
-  return error;
-}
-
 lldb::pid_t HostProcessWindows::GetProcessId() const {
   return (m_process == LLDB_INVALID_PROCESS) ? -1 : ::GetProcessId(m_process);
 }