This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] configure: Fix test for fs_base/gs_base in <sys/user.h>
- From: Pedro Alves <palves at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 17 Jan 2018 13:10:51 -0000
- Subject: [binutils-gdb] configure: Fix test for fs_base/gs_base in <sys/user.h>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f517c1805ac50c64c2dbb086c16b3bcf33b15a89
commit f517c1805ac50c64c2dbb086c16b3bcf33b15a89
Author: Eldar Abusalimov <eldar.abusalimov@jetbrains.com>
Date: Mon Jan 15 16:57:42 2018 +0300
configure: Fix test for fs_base/gs_base in <sys/user.h>
Make <sys/types.h> be included prior to including <sys/user.h>.
glibc versions older than 2.14 use __uintNN_t types within certain
structures defined in <sys/user.h> probably assuming these types are
defined prior to including the header. This results in the following
`configure` feature test compilation error that makes it think that
`struct user_regs_struct` doesn't have `fs_base`/`gs_base` fields,
althouh it does.
configure:13617: checking for struct user_regs_struct.fs_base
configure:13617: gcc -c -g -O2 -I/linux/include conftest.c >&5
In file included from conftest.c:158:0:
/usr/include/sys/user.h:32:3: error: unknown type name '__uint16_t'
__uint16_t cwd;
^
/usr/include/sys/user.h:33:3: error: unknown type name '__uint16_t'
__uint16_t swd;
^
/usr/include/sys/user.h:34:3: error: unknown type name '__uint16_t'
__uint16_t ftw;
^
/usr/include/sys/user.h:35:3: error: unknown type name '__uint16_t'
__uint16_t fop;
^
/usr/include/sys/user.h:36:3: error: unknown type name '__uint64_t'
__uint64_t rip;
^
/usr/include/sys/user.h:37:3: error: unknown type name '__uint64_t'
__uint64_t rdp;
^
/usr/include/sys/user.h:38:3: error: unknown type name '__uint32_t'
__uint32_t mxcsr;
^
/usr/include/sys/user.h:39:3: error: unknown type name '__uint32_t'
__uint32_t mxcr_mask;
^
/usr/include/sys/user.h:40:3: error: unknown type name '__uint32_t'
__uint32_t st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
^
/usr/include/sys/user.h:41:3: error: unknown type name '__uint32_t'
__uint32_t xmm_space[64]; /* 16*16 bytes for each XMM-reg = 256 bytes */
^
/usr/include/sys/user.h:42:3: error: unknown type name '__uint32_t'
__uint32_t padding[24];
^
configure:13617: $? = 1
configure: failed program was:
| /* confdefs.h */
...
| /* end confdefs.h. */
| #include <sys/user.h>
|
| int
| main ()
| {
| static struct user_regs_struct ac_aggr;
| if (ac_aggr.fs_base)
| return 0;
| ;
| return 0;
| }
Recent glibc versions don't use typedef'ed int types in <sys/user.h>,
thus allowing it to be included as is
(glibc commit d79a9c949c84e7f0ba33e87447c47af833e9f11a).
However there're still some distros alive that use older glibc,
for instance, RHEL/CentOS 6 package glibc 2.12.
Also affects PR gdb/21559:
../../gdb/regcache.c:1087: internal-error: void regcache_raw_supply(regcache, int, const void): Assertion `regnum >= 0 && regnum < regcache->descr->nr_raw_registers' failed.
As noted by Andrew Paprocki, who submitted the PR
(https://sourceware.org/bugzilla/show_bug.cgi?id=21559#c3):
> It should be noted that modifying `configure` to force on
> `HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE` and
> `HAVE_STRUCT_USER_REGS_STRUCT_GS_BASE` fixes this issue. For some
> reason the `configure` tests for `fs_base` and `gs_base` fail
> even though `sys/user.h` on RHEL5 has the fields defined in
> `user_regs_struct`.
Note that this patch does NOT fix the root cause of PR gdb/21559,
although now that `configure` properly detects the presence of the
fields and sets HAVE_XXX accordingly, the execution takes another
path, which doesn't lead to the assertion failure in question.
gdb/ChangeLog:
2018-01-17 Eldar Abusalimov <eldar.abusalimov@jetbrains.com>
PR gdb/21559
* configure.ac: Include <sys/types.h> prior to <sys/user.h> when
checking for fs_base/gs_base fields in struct user_regs_struct.
* configure: Regenerate.
gdb/gdbserver/ChangeLog:
2018-01-17 Eldar Abusalimov <eldar.abusalimov@jetbrains.com>
PR gdb/21559
* configure.ac: Include <sys/types.h> prior to <sys/user.h> when
checking for fs_base/gs_base fields in struct user_regs_struct.
* configure: Regenerate.
Diff:
---
gdb/ChangeLog | 7 +++++++
gdb/configure | 6 ++++--
gdb/configure.ac | 3 ++-
gdb/gdbserver/ChangeLog | 7 +++++++
gdb/gdbserver/configure | 6 ++++--
gdb/gdbserver/configure.ac | 3 ++-
6 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a798d06..ad6174b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2018-01-17 Eldar Abusalimov <eldar.abusalimov@jetbrains.com>
+
+ PR gdb/21559
+ * configure.ac: Include <sys/types.h> prior to <sys/user.h> when
+ checking for fs_base/gs_base fields in struct user_regs_struct.
+ * configure: Regenerate.
+
2018-01-17 Yao Qi <yao.qi@linaro.org>
* aarch64-linux-tdep.c (aarch64_linux_gcc_target_options): New
diff --git a/gdb/configure b/gdb/configure
index 68b9aad..a61a73f 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -14132,7 +14132,8 @@ fi
# See if <sys/user.h> supports the %fs_base and %gs_bas amd64 segment registers.
# Older amd64 Linux's don't have the fs_base and gs_base members of
# `struct user_regs_struct'.
-ac_fn_c_check_member "$LINENO" "struct user_regs_struct" "fs_base" "ac_cv_member_struct_user_regs_struct_fs_base" "#include <sys/user.h>
+ac_fn_c_check_member "$LINENO" "struct user_regs_struct" "fs_base" "ac_cv_member_struct_user_regs_struct_fs_base" "#include <sys/types.h>
+#include <sys/user.h>
"
if test "x$ac_cv_member_struct_user_regs_struct_fs_base" = x""yes; then :
@@ -14142,7 +14143,8 @@ _ACEOF
fi
-ac_fn_c_check_member "$LINENO" "struct user_regs_struct" "gs_base" "ac_cv_member_struct_user_regs_struct_gs_base" "#include <sys/user.h>
+ac_fn_c_check_member "$LINENO" "struct user_regs_struct" "gs_base" "ac_cv_member_struct_user_regs_struct_gs_base" "#include <sys/types.h>
+#include <sys/user.h>
"
if test "x$ac_cv_member_struct_user_regs_struct_gs_base" = x""yes; then :
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 551afc7..e53dda0 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1464,7 +1464,8 @@ AC_CHECK_MEMBERS([struct reg.r_fs, struct reg.r_gs], [], [],
# Older amd64 Linux's don't have the fs_base and gs_base members of
# `struct user_regs_struct'.
AC_CHECK_MEMBERS([struct user_regs_struct.fs_base, struct user_regs_struct.gs_base],
- [], [], [#include <sys/user.h>])
+ [], [], [#include <sys/types.h>
+#include <sys/user.h>])
# See if <sys/ptrace.h> provides the PTRACE_GETREGS request.
AC_MSG_CHECKING(for PTRACE_GETREGS)
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index be8c48f..d91e004 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,10 @@
+2018-01-17 Eldar Abusalimov <eldar.abusalimov@jetbrains.com>
+
+ PR gdb/21559
+ * configure.ac: Include <sys/types.h> prior to <sys/user.h> when
+ checking for fs_base/gs_base fields in struct user_regs_struct.
+ * configure: Regenerate.
+
2018-01-16 Yao Qi <yao.qi@linaro.org>
PR gdb/18749
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index ca51321..340ca7a 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -7525,7 +7525,8 @@ fi
# See if <sys/user.h> supports the %fs_base and %gs_bas amd64 segment registers.
# Older amd64 Linux's don't have the fs_base and gs_base members of
# `struct user_regs_struct'.
-ac_fn_c_check_member "$LINENO" "struct user_regs_struct" "fs_base" "ac_cv_member_struct_user_regs_struct_fs_base" "#include <sys/user.h>
+ac_fn_c_check_member "$LINENO" "struct user_regs_struct" "fs_base" "ac_cv_member_struct_user_regs_struct_fs_base" "#include <sys/types.h>
+#include <sys/user.h>
"
if test "x$ac_cv_member_struct_user_regs_struct_fs_base" = x""yes; then :
@@ -7535,7 +7536,8 @@ _ACEOF
fi
-ac_fn_c_check_member "$LINENO" "struct user_regs_struct" "gs_base" "ac_cv_member_struct_user_regs_struct_gs_base" "#include <sys/user.h>
+ac_fn_c_check_member "$LINENO" "struct user_regs_struct" "gs_base" "ac_cv_member_struct_user_regs_struct_gs_base" "#include <sys/types.h>
+#include <sys/user.h>
"
if test "x$ac_cv_member_struct_user_regs_struct_gs_base" = x""yes; then :
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index 7ea3654..6727959 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -185,7 +185,8 @@ AC_CHECK_MEMBERS([struct stat.st_blocks, struct stat.st_blksize])
# Older amd64 Linux's don't have the fs_base and gs_base members of
# `struct user_regs_struct'.
AC_CHECK_MEMBERS([struct user_regs_struct.fs_base, struct user_regs_struct.gs_base],
- [], [], [#include <sys/user.h>])
+ [], [], [#include <sys/types.h>
+#include <sys/user.h>])
AC_CHECK_TYPES(socklen_t, [], [],