This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH v2] gdb: btrace: fix build errors on older glibc builds
- From: Mike Frysinger <vapier at gentoo dot org>
- To: gdb-patches at sourceware dot org
- Date: Thu, 12 Sep 2013 14:40:30 -0400
- Subject: [PATCH v2] gdb: btrace: fix build errors on older glibc builds
- Authentication-results: sourceware.org; auth=none
- References: <1378190232-13873-1-git-send-email-vapier at gentoo dot org>
It is possible to have a build of glibc where SYS_perf_event_open is not
defined (because when the glibc was compiled, the syscall did not exist),
but have newer kernel headers installed so that linux/perf_event.h is
available. In this setup, you get a build failure:
./common/linux-btrace.c: In function 'kernel_supports_btrace':
./common/linux-btrace.c:316:23: error: 'SYS_perf_event_open' undeclared (first use in this function)
Update the ifdef check to also see if the syscall is available.
URL: https://bugs.gentoo.org/473522
Reported-by: William Throwe <wtt6@cornell.edu>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
gdb/:
2013-09-12 Mike Frysinger <vapier@gentoo.org>
* common/linux-btrace.c: Move sys/syscall.h out of the
HAVE_LINUX_PERF_EVENT_H check and wrap it in HAVE_SYS_SYSCALL_H.
Also check for SYS_perf_event_open before attempting to buid.
gdbserver/:
2013-09-12 Mike Frysinger <vapier@gentoo.org>
* configure.ac (AC_CHECK_HEADERS): Add sys/syscall.h
* config.in, configure: Regenerated.
---
v2
- update gdbserver to search for sys/syscall.h too
gdb/common/linux-btrace.c | 7 +++++--
gdb/gdbserver/config.in | 3 +++
gdb/gdbserver/configure | 2 +-
gdb/gdbserver/configure.ac | 2 +-
4 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/gdb/common/linux-btrace.c b/gdb/common/linux-btrace.c
index b874c84..7e20745 100644
--- a/gdb/common/linux-btrace.c
+++ b/gdb/common/linux-btrace.c
@@ -33,13 +33,16 @@
#include "gdb_wait.h"
#include "i386-cpuid.h"
-#if HAVE_LINUX_PERF_EVENT_H
+#ifdef HAVE_SYS_SYSCALL_H
+#include <sys/syscall.h>
+#endif
+
+#if HAVE_LINUX_PERF_EVENT_H && defined(SYS_perf_event_open)
#include <errno.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
-#include <sys/syscall.h>
#include <sys/mman.h>
#include <sys/user.h>
#include <sys/ptrace.h>
diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in
index 7f23a31..1154df2 100644
--- a/gdb/gdbserver/config.in
+++ b/gdb/gdbserver/config.in
@@ -199,6 +199,9 @@
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
+/* Define to 1 if you have the <sys/syscall.h> header file. */
+#undef HAVE_SYS_SYSCALL_H 1
+
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index 193aedc..55dba84 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -4873,7 +4873,7 @@ $as_echo "$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cach
cd "$ac_popdir"
-for ac_header in sgtty.h termio.h termios.h sys/reg.h string.h proc_service.h sys/procfs.h thread_db.h linux/elf.h stdlib.h errno.h fcntl.h signal.h sys/file.h malloc.h sys/ioctl.h netinet/in.h sys/socket.h netdb.h netinet/tcp.h arpa/inet.h sys/wait.h wait.h sys/un.h linux/perf_event.h
+for ac_header in sgtty.h termio.h termios.h sys/reg.h string.h proc_service.h sys/procfs.h thread_db.h linux/elf.h stdlib.h errno.h fcntl.h signal.h sys/file.h malloc.h sys/ioctl.h netinet/in.h sys/socket.h netdb.h netinet/tcp.h arpa/inet.h sys/wait.h wait.h sys/un.h linux/perf_event.h sys/syscall.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index 456a1f7..c167508 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -84,7 +84,7 @@ AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
errno.h fcntl.h signal.h sys/file.h malloc.h dnl
sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
netinet/tcp.h arpa/inet.h sys/wait.h wait.h sys/un.h dnl
- linux/perf_event.h)
+ linux/perf_event.h sys/syscall.h)
AC_CHECK_FUNCS(pread pwrite pread64 readlink fdwalk pipe2)
AC_REPLACE_FUNCS(vasprintf vsnprintf)
--
1.8.3.2