public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Gary Benson <gbenson@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/5] Add workaround from gdbserver's gdb_proc_service.h to GDB
Date: Fri, 28 Sep 2018 14:50:00 -0000	[thread overview]
Message-ID: <1538146201-16374-3-git-send-email-gbenson@redhat.com> (raw)
In-Reply-To: <1538146201-16374-1-git-send-email-gbenson@redhat.com>

This commit adds a workaround from gdbserver's gdb_proc_service.h
to GDB's.  It doesn't seem to have been needed on any glibc as far
back as 2001, but it's possibly required for other C libraries so
I've retained it.

gdb/ChangeLog:

	* configure.ac: Check if sys/procfs.h defines elf_fpregset_t.
	(AC_CHECK_HEADERS): Check for linux/elf.h.
	* configure, config.in: Rebuild.
	* gdb_proc_service.h: Include linux/elf.h if sys/procfs.h
	doesn't define elf_fpregset_t.
---
 gdb/ChangeLog          |  8 ++++++++
 gdb/config.in          |  6 ++++++
 gdb/configure          | 39 ++++++++++++++++++++++++++++++++++++++-
 gdb/configure.ac       |  3 ++-
 gdb/gdb_proc_service.h |  9 +++++++++
 5 files changed, 63 insertions(+), 2 deletions(-)

diff --git a/gdb/config.in b/gdb/config.in
index 01acda1..fc7c859 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -156,6 +156,9 @@
 /* Define if ELF support should be included. */
 #undef HAVE_ELF
 
+/* Define if <sys/procfs.h> has elf_fpregset_t. */
+#undef HAVE_ELF_FPREGSET_T
+
 /* Define to 1 if you have the <elf_hp.h> header file. */
 #undef HAVE_ELF_HP_H
 
@@ -261,6 +264,9 @@
 /* Define to 1 if you have the <libunwind-ia64.h> header file. */
 #undef HAVE_LIBUNWIND_IA64_H
 
+/* Define to 1 if you have the <linux/elf.h> header file. */
+#undef HAVE_LINUX_ELF_H
+
 /* Define to 1 if you have the <linux/perf_event.h> header file. */
 #undef HAVE_LINUX_PERF_EVENT_H
 
diff --git a/gdb/configure b/gdb/configure
index a5d6e74..4a725f6 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -12165,7 +12165,7 @@ fi
 
 # elf_hp.h is for HP/UX 64-bit shared library support.
 for ac_header in nlist.h machine/reg.h poll.h sys/poll.h proc_service.h \
-                  thread_db.h \
+                  thread_db.h linux/elf.h \
 		  sys/file.h sys/filio.h sys/ioctl.h sys/param.h \
 		  sys/resource.h sys/procfs.h sys/ptrace.h ptrace.h \
 		  sys/reg.h sys/debugreg.h sys/select.h \
@@ -14636,6 +14636,43 @@ $as_echo "#define HAVE_PSADDR_T 1" >>confdefs.h
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_have_sys_procfs_type_psaddr_t" >&5
 $as_echo "$bfd_cv_have_sys_procfs_type_psaddr_t" >&6; }
 
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for elf_fpregset_t in sys/procfs.h" >&5
+$as_echo_n "checking for elf_fpregset_t in sys/procfs.h... " >&6; }
+ if ${bfd_cv_have_sys_procfs_type_elf_fpregset_t+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#define _SYSCALL32
+/* Needed for new procfs interface on sparc-solaris.  */
+#define _STRUCTURED_PROC 1
+#include <sys/procfs.h>
+int
+main ()
+{
+elf_fpregset_t avar
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  bfd_cv_have_sys_procfs_type_elf_fpregset_t=yes
+else
+  bfd_cv_have_sys_procfs_type_elf_fpregset_t=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+ if test $bfd_cv_have_sys_procfs_type_elf_fpregset_t = yes; then
+
+$as_echo "#define HAVE_ELF_FPREGSET_T 1" >>confdefs.h
+
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bfd_cv_have_sys_procfs_type_elf_fpregset_t" >&5
+$as_echo "$bfd_cv_have_sys_procfs_type_elf_fpregset_t" >&6; }
+
 
 
 
diff --git a/gdb/configure.ac b/gdb/configure.ac
index 66fc6c6..a469d0a 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -1296,7 +1296,7 @@ fi
 AC_HEADER_STDC
 # elf_hp.h is for HP/UX 64-bit shared library support.
 AC_CHECK_HEADERS([nlist.h machine/reg.h poll.h sys/poll.h proc_service.h \
-                  thread_db.h \
+                  thread_db.h linux/elf.h \
 		  sys/file.h sys/filio.h sys/ioctl.h sys/param.h \
 		  sys/resource.h sys/procfs.h sys/ptrace.h ptrace.h \
 		  sys/reg.h sys/debugreg.h sys/select.h \
@@ -1528,6 +1528,7 @@ if test "$ac_cv_header_sys_procfs_h" = yes; then
   BFD_HAVE_SYS_PROCFS_TYPE(prgregset32_t)
   BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t)
   BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t)
+  BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t)
 
   dnl Check for broken prfpregset_t type
 
diff --git a/gdb/gdb_proc_service.h b/gdb/gdb_proc_service.h
index 39f0e03..ee9358d 100644
--- a/gdb/gdb_proc_service.h
+++ b/gdb/gdb_proc_service.h
@@ -64,6 +64,15 @@ EXTERN_C_POP
 #include <sys/procfs.h>
 #endif
 
+/* Not all platforms bring in <linux/elf.h> via <sys/procfs.h>.  If
+   <sys/procfs.h> wasn't enough to find elf_fpregset_t, try the kernel
+   headers also (but don't if we don't need to).  */
+#ifndef HAVE_ELF_FPREGSET_T
+# ifdef HAVE_LINUX_ELF_H
+#  include <linux/elf.h>
+# endif
+#endif
+
 EXTERN_C_PUSH
 
 /* Functions in this interface return one of these status codes.  */
-- 
1.8.3.1

  parent reply	other threads:[~2018-09-28 14:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-28 14:50 [PATCH 0/5] Merge common proc_service headers Gary Benson
2018-09-28 14:50 ` [PATCH 3/5] Update GDB gdb_proc_service.h workaround to match gdbserver Gary Benson
2018-09-28 19:36   ` Tom Tromey
2018-09-28 14:50 ` [PATCH 1/5] gdb_proc_service.h comment and whitespace synchronization Gary Benson
2018-09-28 19:28   ` Tom Tromey
2018-09-28 14:50 ` Gary Benson [this message]
2018-09-28 19:34   ` [PATCH 2/5] Add workaround from gdbserver's gdb_proc_service.h to GDB Tom Tromey
2018-09-28 14:58 ` [PATCH 4/5] Move duplicated code to common/gdb_proc_service.h Gary Benson
2018-09-28 19:40   ` Tom Tromey
2018-09-28 14:59 ` [PATCH 5/5][OPTIONAL] Remove ancient workaround Gary Benson
2018-09-28 19:44   ` Tom Tromey
2018-09-28 19:33 ` [PATCH 0/5] Merge common proc_service headers Tom Tromey
2018-09-28 19:46   ` Tom Tromey
2018-10-01  8:27     ` Gary Benson
2018-10-05 14:23       ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1538146201-16374-3-git-send-email-gbenson@redhat.com \
    --to=gbenson@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).