[Lldb-commits] [PATCH] D152712: [lldb][Android] Use a lambda for calls to ::open in RetryAfterSignal
Kazuki Sakamoto via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Jun 12 09:01:10 PDT 2023
splhack created this revision.
Herald added a subscriber: danielkiss.
Herald added a project: All.
splhack added reviewers: clayborg, hans.
splhack published this revision for review.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
lldb-server for Android does not build with NDK r21 and above due to
RetryAfterSignal and Bionic ::open mismatch.
https://github.com/llvm/llvm-project/issues/54727
Apply the LLVM patch to LLDB.
https://github.com/llvm/llvm-project/commit/0a0e411204a2baa520fd73a8d69b664f98b428ba
> In Bionic, open can be overloaded for _FORTIFY_SOURCE support, causing
> compile errors of RetryAfterSignal due to overload resolution. Wrapping
> the call in a lambda avoids this.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D152712
Files:
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
@@ -71,7 +71,10 @@
}
static void DupDescriptor(int error_fd, const char *file, int fd, int flags) {
- int target_fd = llvm::sys::RetryAfterSignal(-1, ::open, file, flags, 0666);
+ // Call ::open in a lambda to avoid overload resolution in RetryAfterSignal
+ // when open is overloaded, such as in Bionic.
+ auto Open = [&]() { return ::open(file, flags, 0666); };
+ int target_fd = llvm::sys::RetryAfterSignal(-1, Open);
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
@@ -148,7 +148,10 @@
flags |= O_CLOEXEC;
Status error;
- int fd = llvm::sys::RetryAfterSignal(-1, ::open, name.str().c_str(), flags);
+ // Call ::open in a lambda to avoid overload resolution in RetryAfterSignal
+ // when open is overloaded, such as in Bionic.
+ auto Open = [&]() { return ::open(name.str().c_str(), flags); };
+ int fd = llvm::sys::RetryAfterSignal(-1, Open);
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
@@ -77,5 +77,8 @@
}
int FileSystem::Open(const char *path, int flags, int mode) {
- return llvm::sys::RetryAfterSignal(-1, ::open, path, flags, mode);
+ // Call ::open in a lambda to avoid overload resolution in RetryAfterSignal
+ // when open is overloaded, such as in Bionic.
+ auto Open = [&]() { return ::open(path, flags, mode); };
+ return llvm::sys::RetryAfterSignal(-1, Open);
}
Index: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
===================================================================
--- lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -726,7 +726,10 @@
#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);
+ // Call ::open in a lambda to avoid overload resolution in RetryAfterSignal
+ // when open is overloaded, such as in Bionic.
+ auto Open = [&]() { return ::open(addr_str.c_str(), O_RDWR); };
+ int fd = llvm::sys::RetryAfterSignal(-1, Open);
if (fd == -1) {
if (error_ptr)
error_ptr->SetErrorToErrno();
@@ -776,7 +779,10 @@
return eConnectionStatusError;
}
- int fd = llvm::sys::RetryAfterSignal(-1, ::open, path.str().c_str(), O_RDWR);
+ // Call ::open in a lambda to avoid overload resolution in RetryAfterSignal
+ // when open is overloaded, such as in Bionic.
+ auto Open = [&]() { return ::open(path.str().c_str(), O_RDWR); };
+ int fd = llvm::sys::RetryAfterSignal(-1, Open);
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
@@ -95,7 +95,10 @@
CloseSecondaryFileDescriptor();
std::string name = GetSecondaryName();
- m_secondary_fd = llvm::sys::RetryAfterSignal(-1, ::open, name.c_str(), oflag);
+ // Call ::open in a lambda to avoid overload resolution in RetryAfterSignal
+ // when open is overloaded, such as in Bionic.
+ auto Open = [&]() { return ::open(name.c_str(), oflag); };
+ m_secondary_fd = llvm::sys::RetryAfterSignal(-1, Open);
if (m_secondary_fd >= 0)
return llvm::Error::success();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152712.530522.patch
Type: text/x-patch
Size: 3923 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230612/11b48cda/attachment.bin>
More information about the lldb-commits
mailing list