[Lldb-commits] [lldb] 126a260 - [lldb] Remove HostProcess:GetMainModule

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 22 07:01:15 PST 2022


Author: Pavel Labath
Date: 2022-02-22T16:00:58+01:00
New Revision: 126a2607a8458c7928aa1da880d45c36560017a6

URL: https://github.com/llvm/llvm-project/commit/126a2607a8458c7928aa1da880d45c36560017a6
DIFF: https://github.com/llvm/llvm-project/commit/126a2607a8458c7928aa1da880d45c36560017a6.diff

LOG: [lldb] Remove HostProcess:GetMainModule

the function is unused, and the posix implementation is only really correct on linux.

Added: 
    

Modified: 
    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

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Host/HostNativeProcessBase.h b/lldb/include/lldb/Host/HostNativeProcessBase.h
index 5469f8a50e263..349e3349183b5 100644
--- a/lldb/include/lldb/Host/HostNativeProcessBase.h
+++ b/lldb/include/lldb/Host/HostNativeProcessBase.h
@@ -30,7 +30,6 @@ class HostNativeProcessBase {
   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;

diff  --git a/lldb/include/lldb/Host/HostProcess.h b/lldb/include/lldb/Host/HostProcess.h
index 0b7c303642239..00cb6a212736c 100644
--- a/lldb/include/lldb/Host/HostProcess.h
+++ b/lldb/include/lldb/Host/HostProcess.h
@@ -37,7 +37,6 @@ class HostProcess {
   ~HostProcess();
 
   Status Terminate();
-  Status GetMainModule(FileSpec &file_spec) const;
 
   lldb::pid_t GetProcessId() const;
   bool IsRunning() const;

diff  --git a/lldb/include/lldb/Host/posix/HostProcessPosix.h b/lldb/include/lldb/Host/posix/HostProcessPosix.h
index 5def1b77eefe6..eec19b621a890 100644
--- a/lldb/include/lldb/Host/posix/HostProcessPosix.h
+++ b/lldb/include/lldb/Host/posix/HostProcessPosix.h
@@ -27,7 +27,6 @@ class HostProcessPosix : public HostNativeProcessBase {
   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;

diff  --git a/lldb/include/lldb/Host/windows/HostProcessWindows.h b/lldb/include/lldb/Host/windows/HostProcessWindows.h
index 925d565c275ef..dc27bdc46bb8f 100644
--- a/lldb/include/lldb/Host/windows/HostProcessWindows.h
+++ b/lldb/include/lldb/Host/windows/HostProcessWindows.h
@@ -25,7 +25,6 @@ class HostProcessWindows : public HostNativeProcessBase {
   void SetOwnsHandle(bool owns);
 
   Status Terminate() override;
-  Status GetMainModule(FileSpec &file_spec) const override;
 
   lldb::pid_t GetProcessId() const override;
   bool IsRunning() const override;

diff  --git a/lldb/source/Host/common/HostProcess.cpp b/lldb/source/Host/common/HostProcess.cpp
index 06dd192013ba4..83b856df36eb9 100644
--- a/lldb/source/Host/common/HostProcess.cpp
+++ b/lldb/source/Host/common/HostProcess.cpp
@@ -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();
 }

diff  --git a/lldb/source/Host/posix/HostProcessPosix.cpp b/lldb/source/Host/posix/HostProcessPosix.cpp
index 8599a94d22416..9889be07bca8b 100644
--- a/lldb/source/Host/posix/HostProcessPosix.cpp
+++ b/lldb/source/Host/posix/HostProcessPosix.cpp
@@ -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 {

diff  --git a/lldb/source/Host/windows/HostProcessWindows.cpp b/lldb/source/Host/windows/HostProcessWindows.cpp
index 0dc23e1a65629..741ec68d1d1ee 100644
--- a/lldb/source/Host/windows/HostProcessWindows.cpp
+++ b/lldb/source/Host/windows/HostProcessWindows.cpp
@@ -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);
 }


        


More information about the lldb-commits mailing list