splhack updated this revision to Diff 531381.
splhack added a comment.
rebase onto main
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152712/new/
https://reviews.llvm.org/D152712
Files:
lldb/include/lldb/Host/common/RetryAfterSignal.h
lldb/source/Host/common/PseudoTerminal.cpp
lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
lldb/source/Host/posix/FileSystemPosix.cpp
lldb/source/Host/posix/PipePosix.cpp
lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
Index: lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
===================================================================
--- lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
+++ lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
@@ -11,6 +11,7 @@
#include "lldb/Host/HostProcess.h"
#include "lldb/Host/Pipe.h"
#include "lldb/Host/ProcessLaunchInfo.h"
+#include "lldb/Host/common/RetryAfterSignal.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Log.h"
#include "llvm/Support/Errno.h"
@@ -71,7 +72,7 @@
}
static void DupDescriptor(int error_fd, const char *file, int fd, int flags) {
- int target_fd = llvm::sys::RetryAfterSignal(-1, ::open, file, flags, 0666);
+ int target_fd = RetryAfterSignal::Open(file, flags, 0666);
if (target_fd == -1)
ExitWithError(error_fd, "DupDescriptor-open");
Index: lldb/source/Host/posix/PipePosix.cpp
===================================================================
--- lldb/source/Host/posix/PipePosix.cpp
+++ lldb/source/Host/posix/PipePosix.cpp
@@ -8,6 +8,7 @@
#include "lldb/Host/posix/PipePosix.h"
#include "lldb/Host/HostInfo.h"
+#include "lldb/Host/common/RetryAfterSignal.h"
#include "lldb/Utility/SelectHelper.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Errno.h"
@@ -148,7 +149,7 @@
flags |= O_CLOEXEC;
Status error;
- int fd = llvm::sys::RetryAfterSignal(-1, ::open, name.str().c_str(), flags);
+ int fd = RetryAfterSignal::Open(name.str().c_str(), flags);
if (fd != -1)
m_fds[READ] = fd;
else
Index: lldb/source/Host/posix/FileSystemPosix.cpp
===================================================================
--- lldb/source/Host/posix/FileSystemPosix.cpp
+++ lldb/source/Host/posix/FileSystemPosix.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/common/RetryAfterSignal.h"
// C includes
#include <dirent.h>
@@ -77,5 +78,5 @@
}
int FileSystem::Open(const char *path, int flags, int mode) {
- return llvm::sys::RetryAfterSignal(-1, ::open, path, flags, mode);
+ return RetryAfterSignal::Open(path, flags, mode);
}
Index: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
===================================================================
--- lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -13,6 +13,7 @@
#define _DARWIN_UNLIMITED_SELECT
#endif
+#include "lldb/Host/common/RetryAfterSignal.h"
#include "lldb/Host/posix/ConnectionFileDescriptorPosix.h"
#include "lldb/Host/Config.h"
#include "lldb/Host/Socket.h"
@@ -726,7 +727,7 @@
#if LLDB_ENABLE_POSIX
std::string addr_str = s.str();
// file:///PATH
- int fd = llvm::sys::RetryAfterSignal(-1, ::open, addr_str.c_str(), O_RDWR);
+ int fd = RetryAfterSignal::Open(addr_str.c_str(), O_RDWR);
if (fd == -1) {
if (error_ptr)
error_ptr->SetErrorToErrno();
@@ -776,7 +777,7 @@
return eConnectionStatusError;
}
- int fd = llvm::sys::RetryAfterSignal(-1, ::open, path.str().c_str(), O_RDWR);
+ int fd = RetryAfterSignal::Open(path.str().c_str(), O_RDWR);
if (fd == -1) {
if (error_ptr)
error_ptr->SetErrorToErrno();
Index: lldb/source/Host/common/PseudoTerminal.cpp
===================================================================
--- lldb/source/Host/common/PseudoTerminal.cpp
+++ lldb/source/Host/common/PseudoTerminal.cpp
@@ -8,6 +8,7 @@
#include "lldb/Host/PseudoTerminal.h"
#include "lldb/Host/Config.h"
+#include "lldb/Host/common/RetryAfterSignal.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Errno.h"
#include <cassert>
@@ -95,7 +96,7 @@
CloseSecondaryFileDescriptor();
std::string name = GetSecondaryName();
- m_secondary_fd = llvm::sys::RetryAfterSignal(-1, ::open, name.c_str(), oflag);
+ m_secondary_fd = RetryAfterSignal::Open(name.c_str(), oflag);
if (m_secondary_fd >= 0)
return llvm::Error::success();
Index: lldb/include/lldb/Host/common/RetryAfterSignal.h
===================================================================
--- /dev/null
+++ lldb/include/lldb/Host/common/RetryAfterSignal.h
@@ -0,0 +1,35 @@
+//===-- RetryAfterSignal.h --------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_HOST_COMMON_RETRYAFTERSIGNAL_H
+#define LLDB_HOST_COMMON_RETRYAFTERSIGNAL_H
+
+#include "llvm/Support/Errno.h"
+#include <fcntl.h>
+
+namespace lldb_private {
+
+// Call ::open in a lambda to avoid overload resolution in RetryAfterSignal
+// when open is overloaded, such as in Bionic.
+
+class RetryAfterSignal {
+public:
+ static int Open(const char *path, int oflag) {
+ auto lambda = [&]() { return ::open(path, oflag); };
+ return llvm::sys::RetryAfterSignal(-1, lambda);
+ }
+
+ static int Open(const char *path, int oflag, int mode) {
+ auto lambda = [&]() { return ::open(path, oflag, mode); };
+ return llvm::sys::RetryAfterSignal(-1, lambda);
+ }
+};
+
+} // end of namespace lldb_private
+
+#endif // LLDB_HOST_COMMON_RETRYAFTERSIGNAL_H
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits