summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/source/Host/common/PseudoTerminal.cpp2
-rw-r--r--lldb/source/Host/common/Socket.cpp7
-rw-r--r--lldb/source/Host/common/TCPSocket.cpp5
-rw-r--r--lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp2
-rw-r--r--lldb/source/Host/posix/DomainSocket.cpp5
-rw-r--r--lldb/source/Host/posix/FileSystem.cpp5
-rw-r--r--lldb/source/Host/posix/LockFilePosix.cpp4
-rw-r--r--lldb/source/Host/posix/PipePosix.cpp9
-rw-r--r--lldb/source/Host/posix/ProcessLauncherPosixFork.cpp5
-rw-r--r--lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp3
-rw-r--r--lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp12
-rw-r--r--lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp3
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp3
-rw-r--r--lldb/tools/lldb-mi/MIUtilFileStd.cpp7
-rw-r--r--lldb/tools/lldb-vscode/lldb-vscode.cpp6
15 files changed, 52 insertions, 26 deletions
diff --git a/lldb/source/Host/common/PseudoTerminal.cpp b/lldb/source/Host/common/PseudoTerminal.cpp
index 19c7ba9fd25..c95c1aa3829 100644
--- a/lldb/source/Host/common/PseudoTerminal.cpp
+++ b/lldb/source/Host/common/PseudoTerminal.cpp
@@ -147,7 +147,7 @@ bool PseudoTerminal::OpenSlave(int oflag, char *error_str, size_t error_len) {
if (slave_name == nullptr)
return false;
- m_slave_fd = ::open(slave_name, oflag);
+ m_slave_fd = llvm::sys::RetryAfterSignal(-1, ::open, slave_name, oflag);
if (m_slave_fd < 0) {
if (error_str)
diff --git a/lldb/source/Host/common/Socket.cpp b/lldb/source/Host/common/Socket.cpp
index 7bafee57f5f..70502ebe3bf 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -18,6 +18,7 @@
#include "lldb/Utility/RegularExpression.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Errno.h"
#ifndef LLDB_DISABLE_POSIX
#include "lldb/Host/posix/DomainSocket.h"
@@ -450,9 +451,11 @@ NativeSocket Socket::AcceptSocket(NativeSocket sockfd, struct sockaddr *addr,
if (!child_processes_inherit) {
flags |= SOCK_CLOEXEC;
}
- NativeSocket fd = ::accept4(sockfd, addr, addrlen, flags);
+ NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept4,
+ sockfd, addr, addrlen, flags);
#else
- NativeSocket fd = ::accept(sockfd, addr, addrlen);
+ NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept,
+ sockfd, addr, addrlen);
#endif
if (fd == kInvalidSocketValue)
SetLastError(error);
diff --git a/lldb/source/Host/common/TCPSocket.cpp b/lldb/source/Host/common/TCPSocket.cpp
index 7a99167f3e8..3f11e4e3b49 100644
--- a/lldb/source/Host/common/TCPSocket.cpp
+++ b/lldb/source/Host/common/TCPSocket.cpp
@@ -17,6 +17,7 @@
#include "lldb/Utility/Log.h"
#include "llvm/Config/llvm-config.h"
+#include "llvm/Support/Errno.h"
#include "llvm/Support/raw_ostream.h"
#ifndef LLDB_DISABLE_POSIX
@@ -150,8 +151,8 @@ Status TCPSocket::Connect(llvm::StringRef name) {
address.SetPort(port);
- if (-1 == ::connect(GetNativeSocket(), &address.sockaddr(),
- address.GetLength())) {
+ if (-1 == llvm::sys::RetryAfterSignal(-1, ::connect,
+ GetNativeSocket(), &address.sockaddr(), address.GetLength())) {
CLOSE_SOCKET(GetNativeSocket());
continue;
}
diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index 6d3d1eae2c8..4bbebd627d4 100644
--- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -262,7 +262,7 @@ ConnectionStatus ConnectionFileDescriptor::Connect(llvm::StringRef path,
options.c_cc[VMIN] = 1;
options.c_cc[VTIME] = 0;
- ::tcsetattr(fd, TCSANOW, &options);
+ llvm::sys::RetryAfterSignal(-1, ::tcsetattr, fd, TCSANOW, &options);
}
int flags = ::fcntl(fd, F_GETFL, 0);
diff --git a/lldb/source/Host/posix/DomainSocket.cpp b/lldb/source/Host/posix/DomainSocket.cpp
index 5d21f800fb0..c6366e44e79 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -8,6 +8,7 @@
#include "lldb/Host/posix/DomainSocket.h"
+#include "llvm/Support/Errno.h"
#include "llvm/Support/FileSystem.h"
#include <stddef.h>
@@ -81,8 +82,8 @@ Status DomainSocket::Connect(llvm::StringRef name) {
m_socket = CreateSocket(kDomain, kType, 0, m_child_processes_inherit, error);
if (error.Fail())
return error;
- if (::connect(GetNativeSocket(), (struct sockaddr *)&saddr_un, saddr_un_len) <
- 0)
+ if (llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),
+ (struct sockaddr *)&saddr_un, saddr_un_len) < 0)
SetLastError(error);
return error;
diff --git a/lldb/source/Host/posix/FileSystem.cpp b/lldb/source/Host/posix/FileSystem.cpp
index 65791cb4c42..32fae68abb4 100644
--- a/lldb/source/Host/posix/FileSystem.cpp
+++ b/lldb/source/Host/posix/FileSystem.cpp
@@ -25,6 +25,7 @@
#include "lldb/Utility/Status.h"
#include "lldb/Utility/StreamString.h"
+#include "llvm/Support/Errno.h"
#include "llvm/Support/FileSystem.h"
using namespace lldb;
@@ -71,9 +72,9 @@ Status FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst) {
}
FILE *FileSystem::Fopen(const char *path, const char *mode) {
- return ::fopen(path, mode);
+ return llvm::sys::RetryAfterSignal(nullptr, ::fopen, path, mode);
}
int FileSystem::Open(const char *path, int flags, int mode) {
- return ::open(path, flags, mode);
+ return llvm::sys::RetryAfterSignal(-1, ::open, path, flags, mode);
}
diff --git a/lldb/source/Host/posix/LockFilePosix.cpp b/lldb/source/Host/posix/LockFilePosix.cpp
index 0dc9bd5e34f..a6eae95c333 100644
--- a/lldb/source/Host/posix/LockFilePosix.cpp
+++ b/lldb/source/Host/posix/LockFilePosix.cpp
@@ -8,6 +8,8 @@
#include "lldb/Host/posix/LockFilePosix.h"
+#include "llvm/Support/Errno.h"
+
#include <fcntl.h>
#include <unistd.h>
@@ -27,7 +29,7 @@ Status fileLock(int fd, int cmd, int lock_type, const uint64_t start,
fl.l_pid = ::getpid();
Status error;
- if (::fcntl(fd, cmd, &fl) == -1)
+ if (llvm::sys::RetryAfterSignal(-1, ::fcntl, fd, cmd, &fl) == -1)
error.SetErrorToErrno();
return error;
diff --git a/lldb/source/Host/posix/PipePosix.cpp b/lldb/source/Host/posix/PipePosix.cpp
index 40d616e15ba..efdc151e376 100644
--- a/lldb/source/Host/posix/PipePosix.cpp
+++ b/lldb/source/Host/posix/PipePosix.cpp
@@ -10,6 +10,7 @@
#include "lldb/Host/HostInfo.h"
#include "lldb/Utility/SelectHelper.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/Errno.h"
#include "llvm/Support/FileSystem.h"
#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8))
@@ -157,7 +158,7 @@ Status PipePosix::OpenAsReader(llvm::StringRef name,
flags |= O_CLOEXEC;
Status error;
- int fd = ::open(name.data(), flags);
+ int fd = llvm::sys::RetryAfterSignal(-1, ::open, name.data(), flags);
if (fd != -1)
m_fds[READ] = fd;
else
@@ -192,7 +193,7 @@ PipePosix::OpenAsWriterWithTimeout(llvm::StringRef name,
if (fd == -1) {
const auto errno_copy = errno;
// We may get ENXIO if a reader side of the pipe hasn't opened yet.
- if (errno_copy != ENXIO)
+ if (errno_copy != ENXIO && errno_copy != EINTR)
return Status(errno_copy, eErrorTypePOSIX);
std::this_thread::sleep_for(
@@ -275,6 +276,8 @@ Status PipePosix::ReadWithTimeout(void *buf, size_t size,
bytes_read += result;
if (bytes_read == size || result == 0)
break;
+ } else if (errno == EINTR) {
+ continue;
} else {
error.SetErrorToErrno();
break;
@@ -305,6 +308,8 @@ Status PipePosix::Write(const void *buf, size_t size, size_t &bytes_written) {
bytes_written += result;
if (bytes_written == size)
break;
+ } else if (errno == EINTR) {
+ continue;
} else {
error.SetErrorToErrno();
}
diff --git a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
index 3edb4861a2f..6dd3a2b193c 100644
--- a/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
+++ b/lldb/source/Host/posix/ProcessLauncherPosixFork.cpp
@@ -72,7 +72,8 @@ static void DisableASLRIfRequested(int error_fd, const ProcessLaunchInfo &info)
static void DupDescriptor(int error_fd, const FileSpec &file_spec, int fd,
int flags) {
- int target_fd = ::open(file_spec.GetCString(), flags, 0666);
+ int target_fd = llvm::sys::RetryAfterSignal(-1, ::open,
+ file_spec.GetCString(), flags, 0666);
if (target_fd == -1)
ExitWithError(error_fd, "DupDescriptor-open");
@@ -211,7 +212,7 @@ ProcessLauncherPosixFork::LaunchProcess(const ProcessLaunchInfo &launch_info,
error.SetErrorString(buf);
- waitpid(pid, nullptr, 0);
+ llvm::sys::RetryAfterSignal(-1, waitpid, pid, nullptr, 0);
return HostProcess();
}
diff --git a/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp b/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
index 440b1274e89..959e5f0dfd8 100644
--- a/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
+++ b/lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
@@ -1387,7 +1387,8 @@ lldb_private::Status ProcessMonitor::Detach(lldb::tid_t tid) {
bool ProcessMonitor::DupDescriptor(const FileSpec &file_spec, int fd,
int flags) {
- int target_fd = open(file_spec.GetCString(), flags, 0666);
+ int target_fd = llvm::sys::RetryAfterSignal(-1, open,
+ file_spec.GetCString(), flags, 0666);
if (target_fd == -1)
return false;
diff --git a/lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp b/lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp
index 01d8ef9d33a..bd1f099f5d4 100644
--- a/lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp
+++ b/lldb/source/Plugins/Process/Linux/SingleStepCheck.cpp
@@ -51,8 +51,10 @@ struct ChildDeleter {
~ChildDeleter() {
int status;
- kill(pid, SIGKILL); // Kill the child.
- waitpid(pid, &status, __WALL); // Pick up the remains.
+ // Kill the child.
+ kill(pid, SIGKILL);
+ // Pick up the remains.
+ llvm::sys::RetryAfterSignal(-1, waitpid, pid, &status, __WALL);
}
};
@@ -81,7 +83,8 @@ bool WorkaroundNeeded() {
}
int status;
- ::pid_t wpid = waitpid(child_pid, &status, __WALL);
+ ::pid_t wpid = llvm::sys::RetryAfterSignal(-1, waitpid,
+ child_pid, &status, __WALL);
if (wpid != child_pid || !WIFSTOPPED(status)) {
LLDB_LOG(log, "waitpid() failed (status = {0:x}): {1}", status,
Status(errno, eErrorTypePOSIX));
@@ -110,7 +113,8 @@ bool WorkaroundNeeded() {
break;
}
- wpid = waitpid(child_pid, &status, __WALL);
+ wpid = llvm::sys::RetryAfterSignal(-1, waitpid,
+ child_pid, &status, __WALL);
if (wpid != child_pid || !WIFSTOPPED(status)) {
LLDB_LOG(log, "waitpid() failed (status = {0:x}): {1}", status,
Status(errno, eErrorTypePOSIX));
diff --git a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
index b0ae54841b1..5ccd5a35f75 100644
--- a/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
+++ b/lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
@@ -665,7 +665,8 @@ Status NativeProcessNetBSD::Attach() {
int wstatus;
// Need to use WALLSIG otherwise we receive an error with errno=ECHLD At this
// point we should have a thread stopped if waitpid succeeds.
- if ((wstatus = waitpid(m_pid, NULL, WALLSIG)) < 0)
+ if ((wstatus = llvm::sys::RetryAfterSignal(-1, waitpid,
+ m_pid, NULL, WALLSIG)) < 0)
return Status(errno, eErrorTypePOSIX);
/* Initialize threads */
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
index f82fe612f68..62421238fb0 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -21,6 +21,7 @@
#include "lldb/Utility/Stream.h"
#include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/Errno.h"
#include <stdio.h>
@@ -39,7 +40,7 @@ void StructuredPythonObject::Dump(Stream &s, bool pretty_print) const {
void PythonObject::Dump(Stream &strm) const {
if (m_py_obj) {
- FILE *file = ::tmpfile();
+ FILE *file = llvm::sys::RetryAfterSignal(nullptr, ::tmpfile);
if (file) {
::PyObject_Print(m_py_obj, file, 0);
const long length = ftell(file);
diff --git a/lldb/tools/lldb-mi/MIUtilFileStd.cpp b/lldb/tools/lldb-mi/MIUtilFileStd.cpp
index 4aabd53b22b..1af9a5871d6 100644
--- a/lldb/tools/lldb-mi/MIUtilFileStd.cpp
+++ b/lldb/tools/lldb-mi/MIUtilFileStd.cpp
@@ -18,6 +18,7 @@
#include "lldb/Host/FileSystem.h"
#include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/Errno.h"
//++
//------------------------------------------------------------------------------------
@@ -83,7 +84,8 @@ bool CMIUtilFileStd::CreateWrite(const CMIUtilString &vFileNamePath,
#if !defined(_MSC_VER)
// Open with 'write' and 'binary' mode
- m_pFileHandle = ::fopen(vFileNamePath.c_str(), "wb");
+ m_pFileHandle = llvm::sys::RetryAfterSignal(nullptr, ::fopen,
+ vFileNamePath.c_str(), "wb");
#else
// Open a file with exclusive write and shared read permissions
std::wstring path;
@@ -226,7 +228,8 @@ bool CMIUtilFileStd::IsFileExist(const CMIUtilString &vFileNamePath) const {
return false;
FILE *pTmp = nullptr;
- pTmp = ::fopen(vFileNamePath.c_str(), "wb");
+ pTmp = llvm::sys::RetryAfterSignal(nullptr, ::fopen,
+ vFileNamePath.c_str(), "wb");
if (pTmp != nullptr) {
::fclose(pTmp);
return true;
diff --git a/lldb/tools/lldb-vscode/lldb-vscode.cpp b/lldb/tools/lldb-vscode/lldb-vscode.cpp
index 040657a0231..2cad12f8d5c 100644
--- a/lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ b/lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -41,6 +41,7 @@
#include <thread>
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/Errno.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/raw_ostream.h"
@@ -90,7 +91,8 @@ SOCKET AcceptConnection(int portno) {
} else {
listen(sockfd, 5);
socklen_t clilen = sizeof(cli_addr);
- newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr, &clilen);
+ newsockfd = llvm::sys::RetryAfterSignal(-1, accept,
+ sockfd, (struct sockaddr *)&cli_addr, &clilen);
if (newsockfd < 0)
if (g_vsc.log)
*g_vsc.log << "error: accept (" << strerror(errno) << ")"
@@ -1074,7 +1076,7 @@ void request_initialize(const llvm::json::Object &request) {
// before we are given an executable to launch in a "launch" request, or a
// executable when attaching to a process by process ID in a "attach"
// request.
- FILE *out = fopen(dev_null_path, "w");
+ FILE *out = llvm::sys::RetryAfterSignal(nullptr, fopen, dev_null_path, "w");
if (out) {
// Set the output and error file handles to redirect into nothing otherwise
// if any code in LLDB prints to the debugger file handles, the output and
OpenPOWER on IntegriCloud