forked from OSchip/llvm-project
[lldb] Remove HostProcess:GetMainModule
the function is unused, and the posix implementation is only really correct on linux.
This commit is contained in:
parent
02571f86bb
commit
126a2607a8
|
@ -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;
|
||||
|
|
|
@ -37,7 +37,6 @@ public:
|
|||
~HostProcess();
|
||||
|
||||
Status Terminate();
|
||||
Status GetMainModule(FileSpec &file_spec) const;
|
||||
|
||||
lldb::pid_t GetProcessId() const;
|
||||
bool IsRunning() const;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue