cmake: Put PROCESS_VM_READV detection results into Config.h

Reviewers: beanz, eugene

Subscribers: mgorny, lldb-commits

Differential Revision: https://reviews.llvm.org/D33771

llvm-svn: 304544
This commit is contained in:
Pavel Labath 2017-06-02 12:29:08 +00:00
parent 726c28f8c4
commit 090b8616e2
5 changed files with 19 additions and 27 deletions

View File

@ -334,28 +334,6 @@ if (HAVE_LIBDL)
list(APPEND system_libs ${CMAKE_DL_LIBS})
endif()
# Check for syscall used by lldb-server on linux.
# If these are not found, it will fall back to ptrace (slow) for memory reads.
check_cxx_source_compiles("
#include <sys/uio.h>
int main() { process_vm_readv(0, nullptr, 0, nullptr, 0, 0); return 0; }"
HAVE_PROCESS_VM_READV)
if (HAVE_PROCESS_VM_READV)
add_definitions(-DHAVE_PROCESS_VM_READV)
else()
# If we don't have the syscall wrapper function, but we know the syscall number, we can
# still issue the syscall manually
check_cxx_source_compiles("
#include <sys/syscall.h>
int main() { return __NR_process_vm_readv; }"
HAVE_NR_PROCESS_VM_READV)
if (HAVE_NR_PROCESS_VM_READV)
add_definitions(-DHAVE_NR_PROCESS_VM_READV)
endif()
endif()
# Figure out if lldb could use lldb-server. If so, then we'll
# ensure we build lldb-server when an lldb target is being built.
if (CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|FreeBSD|Linux|NetBSD")

View File

@ -12,6 +12,15 @@ check_symbol_exists(sigaction signal.h HAVE_SIGACTION)
check_include_file(termios.h HAVE_TERMIOS_H)
check_include_files("sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
check_cxx_source_compiles("
#include <sys/uio.h>
int main() { process_vm_readv(0, nullptr, 0, nullptr, 0, 0); return 0; }"
HAVE_PROCESS_VM_READV)
check_cxx_source_compiles("
#include <sys/syscall.h>
int main() { return __NR_process_vm_readv; }"
HAVE_NR_PROCESS_VM_READV)
# These checks exist in LLVM's configuration, so I want to match the LLVM names
# so that the check isn't duplicated, but we translate them into the LLDB names
# so that I don't have to change all the uses at the moment.

View File

@ -20,4 +20,8 @@
#cmakedefine01 HAVE_SIGACTION
#cmakedefine01 HAVE_PROCESS_VM_READV
#cmakedefine01 HAVE_NR_PROCESS_VM_READV
#endif // #ifndef LLDB_HOST_CONFIG_H

View File

@ -10,11 +10,12 @@
#ifndef liblldb_Host_linux_Uio_h_
#define liblldb_Host_linux_Uio_h_
#include "lldb/Host/Config.h"
#include <sys/uio.h>
// We shall provide our own implementation of process_vm_readv if it is not
// present
#ifndef HAVE_PROCESS_VM_READV
#if !HAVE_PROCESS_VM_READV
ssize_t process_vm_readv(::pid_t pid, const struct iovec *local_iov,
unsigned long liovcnt, const struct iovec *remote_iov,
unsigned long riovcnt, unsigned long flags);

View File

@ -14,13 +14,13 @@
#include <sys/syscall.h>
#include <unistd.h>
#ifndef HAVE_PROCESS_VM_READV // If the syscall wrapper is not available,
// provide one.
#if !HAVE_PROCESS_VM_READV
// If the syscall wrapper is not available, provide one.
ssize_t process_vm_readv(::pid_t pid, const struct iovec *local_iov,
unsigned long liovcnt, const struct iovec *remote_iov,
unsigned long riovcnt, unsigned long flags) {
#ifdef HAVE_NR_PROCESS_VM_READV // If we have the syscall number, we can issue
// the syscall ourselves.
#if HAVE_NR_PROCESS_VM_READV
// If we have the syscall number, we can issue the syscall ourselves.
return syscall(__NR_process_vm_readv, pid, local_iov, liovcnt, remote_iov,
riovcnt, flags);
#else // If not, let's pretend the syscall is not present.