summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Neyman <stilor@att.net>2019-03-11 07:33:22 (GMT)
committerAlexey Neyman <stilor@att.net>2019-03-11 07:33:22 (GMT)
commitde36f78f898940e7611b177e9ccd97516f131caf (patch)
tree468264dc671077e05270674518d3cbcea083dc58
parent5332f480e44d2eed46faf3290b385d141ccc2df8 (diff)
Allow older GDB to build against newer glibc
Also, fix the subdir used when only gdbserver is built (without native GDB). Signed-off-by: Alexey Neyman <stilor@att.net>
-rw-r--r--config/debug/gdb.in7
-rw-r--r--packages/gdb/7.11.1/0005-include-gregset.h.patch73
-rw-r--r--scripts/build/debug/300-gdb.sh18
3 files changed, 95 insertions, 3 deletions
diff --git a/config/debug/gdb.in b/config/debug/gdb.in
index 32170c1..7fc539e 100644
--- a/config/debug/gdb.in
+++ b/config/debug/gdb.in
@@ -33,7 +33,10 @@ config GDB_DEP_CXX11
select GDB_REQUIRE_older_than_8_0
config GDB_HAS_IPA_LIB
- bool
+ def_bool y
depends on GDB_7_2_or_later
- default y
+# Does GDB need ps_get_thread_area with const qualifier?
+config GDB_CONST_GET_THREAD_AREA
+ bool
+ default y if GDB_older_than_7_12
diff --git a/packages/gdb/7.11.1/0005-include-gregset.h.patch b/packages/gdb/7.11.1/0005-include-gregset.h.patch
new file mode 100644
index 0000000..9a588ba
--- /dev/null
+++ b/packages/gdb/7.11.1/0005-include-gregset.h.patch
@@ -0,0 +1,73 @@
+commit 31925464a80970e37c06192a0c49f8948a2f5da0
+Author: Matthew Wahab <matthew.wahab@arm.com>
+Date: Mon Aug 15 13:09:04 2016 +0100
+
+ [GDB] Fix builds broken by proc-service changes.
+
+ GLIBC BZ#20311 introduced a change to install proc_service.h so that gdb
+ didn't have to use the version it embeds in gdb_proc_service.h. The
+ embedded version is guarded by HAVE_PROC_SERVICE_H and
+ gdb_proc_service.h has a number other of includes and definitions, all
+ of which are uncondional except for an include for gregset.h. This is
+ only included if HAVE_PROC_SERIVCE_H is not defined.
+
+ This causes a build failure when cross compiling gdb with the latest
+ glibc because type definitions in gregset are used independently of
+ HAVE_PROC_SERIVCE_H. In particular, they are used in gdb_proc_service.h
+ when PRFPREGSET_T_BROKEN is set.
+
+ The error messages on the failure are
+ ----
+ binutils-gdb/gdb/gdb_proc_service.h:173:9: error: ‘gdb_fpregset_t’ does
+ not name a type; did you mean ‘elf_fpregset_t’?
+ typedef gdb_fpregset_t gdb_prfpregset_t;
+ ^~~~~~~~~~~~~~
+ elf_fpregset_t
+
+ binutils-gdb/gdb/gdb_proc_service.h:173:9: error: ‘gdb_fpregset_t’ does
+ not name a type; did you mean ‘elf_fpregset_t’?
+ typedef gdb_fpregset_t gdb_prfpregset_t;
+ ^~~~~~~~~~~~~~
+ elf_fpregset_t
+
+ binutils-gdb/gdb/proc-service.c:218:15: error: ‘gdb_prfpregset_t’ does
+ not name a type; did you mean ‘gdb_fpregset_t’?
+ const gdb_prfpregset_t *fpregset)
+ ^~~~~~~~~~~~~~~~
+ gdb_fpregset_t
+ ----
+
+ This patch moves the include for gregset.h to before the code guarded by
+ HAVE_PROC_SERIVCE_H, so that it is always included. This is enough to
+ fix the build.
+
+ 2016-08-15 Matthew Wahab <matthew.wahab@arm.com>
+
+ PR gdb/20457
+ * gdb_proc_service.h: Add an include of gregset.h
+ [!HAVE_PROC_SERVICE_H]: Remove the include of gregset.h.
+
+---
+ gdb/gdb_proc_service.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/gdb/gdb_proc_service.h
++++ b/gdb/gdb_proc_service.h
+@@ -21,6 +21,8 @@
+
+ #include <sys/types.h>
+
++#include "gregset.h"
++
+ #ifdef HAVE_PROC_SERVICE_H
+
+ /* glibc's proc_service.h doesn't wrap itself with extern "C". Need
+@@ -60,8 +62,6 @@
+ #include <sys/procfs.h>
+ #endif
+
+-#include "gregset.h"
+-
+ EXTERN_C_PUSH
+
+ /* Functions in this interface return one of these status codes. */
diff --git a/scripts/build/debug/300-gdb.sh b/scripts/build/debug/300-gdb.sh
index 1438912..e62e5df 100644
--- a/scripts/build/debug/300-gdb.sh
+++ b/scripts/build/debug/300-gdb.sh
@@ -122,7 +122,7 @@ do_debug_gdb_build()
gdbserver_extra_config+=("--disable-inprocess-agent")
fi
if [ "${CT_GDB_NATIVE}" != "y" ]; then
- subdir=gdbserver/
+ subdir=gdb/gdbserver/
fi
fi
@@ -175,6 +175,22 @@ do_gdb_backend()
esac
done
+ # Starting with glibc 2.25, it now provides a <proc_service.h> header. The
+ # problem is that GDB releases prior to 7.12 used to implement one of the
+ # interfaces, ps_get_thread_are with a const qualifier on one of the arguments.
+ # Therefore, such older versions cannot be compiled against a newer glibc.
+ # If we detect such a combination, mitigate by creating a local proc_service.h
+ # with a prototype adjusted for GDB requirements.
+ if [ -r "${CT_HEADERS_DIR}/proc_service.h" -a "${CT_GDB_CONST_GET_THREAD_AREA}" = "y" ]; then
+ CT_DoLog DEBUG "Fixing up the prototype in <proc_service.h>"
+ CT_DoExecLog ALL mkdir -p gdb/gdbserver
+ CT_DoExecLog ALL cp "${CT_HEADERS_DIR}/proc_service.h" gdb/proc_service.h
+ CT_DoExecLog ALL sed -i \
+ "s/\(ps_get_thread_area *(\).*\(struct ps_prochandle\)/\1const \2/" \
+ gdb/proc_service.h
+ CT_DoExecLog ALL cp gdb/proc_service.h gdb/gdbserver/proc_service.h
+ fi
+
if [ "${CT_GDB_HAS_PKGVERSION_BUGURL}" = "y" ]; then
[ -n "${CT_PKGVERSION}" ] && extra_config+=("--with-pkgversion=${CT_PKGVERSION}")
[ -n "${CT_TOOLCHAIN_BUGURL}" ] && extra_config+=("--with-bugurl=${CT_TOOLCHAIN_BUGURL}")