From f517c1805ac50c64c2dbb086c16b3bcf33b15a89 Mon Sep 17 00:00:00 2001 From: Eldar Abusalimov Date: Mon, 15 Jan 2018 16:57:42 +0300 Subject: [PATCH] configure: Fix test for fs_base/gs_base in Make be included prior to including . glibc versions older than 2.14 use __uintNN_t types within certain structures defined in 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 | | 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 , 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 PR gdb/21559 * configure.ac: Include prior to when checking for fs_base/gs_base fields in struct user_regs_struct. * configure: Regenerate. gdb/gdbserver/ChangeLog: 2018-01-17 Eldar Abusalimov PR gdb/21559 * configure.ac: Include prior to when checking for fs_base/gs_base fields in struct user_regs_struct. * configure: Regenerate. --- 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 a798d061839..ad6174ba927 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2018-01-17 Eldar Abusalimov + + PR gdb/21559 + * configure.ac: Include prior to when + checking for fs_base/gs_base fields in struct user_regs_struct. + * configure: Regenerate. + 2018-01-17 Yao Qi * aarch64-linux-tdep.c (aarch64_linux_gcc_target_options): New diff --git a/gdb/configure b/gdb/configure index 68b9aad02d2..a61a73f6e2c 100755 --- a/gdb/configure +++ b/gdb/configure @@ -14132,7 +14132,8 @@ fi # See if 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 +ac_fn_c_check_member "$LINENO" "struct user_regs_struct" "fs_base" "ac_cv_member_struct_user_regs_struct_fs_base" "#include +#include " 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 +ac_fn_c_check_member "$LINENO" "struct user_regs_struct" "gs_base" "ac_cv_member_struct_user_regs_struct_gs_base" "#include +#include " 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 551afc727e7..e53dda00d24 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 ]) + [], [], [#include +#include ]) # See if provides the PTRACE_GETREGS request. AC_MSG_CHECKING(for PTRACE_GETREGS) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index be8c48f0f79..d91e004a69d 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,10 @@ +2018-01-17 Eldar Abusalimov + + PR gdb/21559 + * configure.ac: Include prior to when + checking for fs_base/gs_base fields in struct user_regs_struct. + * configure: Regenerate. + 2018-01-16 Yao Qi PR gdb/18749 diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure index ca51321c846..340ca7a19e5 100755 --- a/gdb/gdbserver/configure +++ b/gdb/gdbserver/configure @@ -7525,7 +7525,8 @@ fi # See if 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 +ac_fn_c_check_member "$LINENO" "struct user_regs_struct" "fs_base" "ac_cv_member_struct_user_regs_struct_fs_base" "#include +#include " 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 +ac_fn_c_check_member "$LINENO" "struct user_regs_struct" "gs_base" "ac_cv_member_struct_user_regs_struct_gs_base" "#include +#include " 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 7ea3654f63a..6727959e61b 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 ]) + [], [], [#include +#include ]) AC_CHECK_TYPES(socklen_t, [], [], -- 2.30.2