From 5db2df9a364b9fee7402c0bf0e2eaa2ecd7bee48 Mon Sep 17 00:00:00 2001 From: Mark Hatle Date: Thu, 6 Apr 2023 14:50:45 -0700 Subject: gdb: Bring in last OE version of gdb 12.1 Patches are not yet ported to GDB 13.x. gdb 12.1 as of OE-Core commit: 131c753e000bf3c8814823d36d18e82f4dee26f2 Signed-off-by: Mark Hatle --- meta-microblaze/conf/layer.conf | 2 + .../recipes-devtools/gdb/gdb-common.inc | 66 ++++++++++++++++++++++ .../recipes-devtools/gdb/gdb-cross-canadian.inc | 44 +++++++++++++++ .../gdb/gdb-cross-canadian_12.1.bb | 3 + meta-microblaze/recipes-devtools/gdb/gdb-cross.inc | 31 ++++++++++ .../recipes-devtools/gdb/gdb-cross_12.1.bb | 2 + meta-microblaze/recipes-devtools/gdb/gdb.inc | 20 +++++++ ...0001-make-man-install-relative-to-DESTDIR.patch | 28 +++++++++ ...s-linux-nat-Define-_ABIO32-if-not-defined.patch | 35 ++++++++++++ ...Define-pt_regs-uapi_pt_regs-on-GLIBC-syst.patch | 52 +++++++++++++++++ ...e-libreadline.a-when-using-disable-static.patch | 50 ++++++++++++++++ .../gdb/gdb/0005-use-asm-sgidefs.h.patch | 36 ++++++++++++ .../gdb/gdb/0006-Change-order-of-CFLAGS.patch | 30 ++++++++++ .../0007-resolve-restrict-keyword-conflict.patch | 48 ++++++++++++++++ ...nof-using-_Alignof-when-using-C11-or-newe.patch | 55 ++++++++++++++++++ .../gdb/0008-Fix-invalid-sigprocmask-call.patch | 49 ++++++++++++++++ .../gdb/gdb/0009-gdbserver-ctrl-c-handling.patch | 40 +++++++++++++ .../recipes-devtools/gdb/gdb/readline-8.2.patch | 39 +++++++++++++ meta-microblaze/recipes-devtools/gdb/gdb_12.1.bb | 39 +++++++++++++ 19 files changed, 669 insertions(+) create mode 100644 meta-microblaze/recipes-devtools/gdb/gdb-common.inc create mode 100644 meta-microblaze/recipes-devtools/gdb/gdb-cross-canadian.inc create mode 100644 meta-microblaze/recipes-devtools/gdb/gdb-cross-canadian_12.1.bb create mode 100644 meta-microblaze/recipes-devtools/gdb/gdb-cross.inc create mode 100644 meta-microblaze/recipes-devtools/gdb/gdb-cross_12.1.bb create mode 100644 meta-microblaze/recipes-devtools/gdb/gdb.inc create mode 100644 meta-microblaze/recipes-devtools/gdb/gdb/0001-make-man-install-relative-to-DESTDIR.patch create mode 100644 meta-microblaze/recipes-devtools/gdb/gdb/0002-mips-linux-nat-Define-_ABIO32-if-not-defined.patch create mode 100644 meta-microblaze/recipes-devtools/gdb/gdb/0003-ppc-ptrace-Define-pt_regs-uapi_pt_regs-on-GLIBC-syst.patch create mode 100644 meta-microblaze/recipes-devtools/gdb/gdb/0004-Dont-disable-libreadline.a-when-using-disable-static.patch create mode 100644 meta-microblaze/recipes-devtools/gdb/gdb/0005-use-asm-sgidefs.h.patch create mode 100644 meta-microblaze/recipes-devtools/gdb/gdb/0006-Change-order-of-CFLAGS.patch create mode 100644 meta-microblaze/recipes-devtools/gdb/gdb/0007-resolve-restrict-keyword-conflict.patch create mode 100644 meta-microblaze/recipes-devtools/gdb/gdb/0008-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch create mode 100644 meta-microblaze/recipes-devtools/gdb/gdb/0008-Fix-invalid-sigprocmask-call.patch create mode 100644 meta-microblaze/recipes-devtools/gdb/gdb/0009-gdbserver-ctrl-c-handling.patch create mode 100644 meta-microblaze/recipes-devtools/gdb/gdb/readline-8.2.patch create mode 100644 meta-microblaze/recipes-devtools/gdb/gdb_12.1.bb diff --git a/meta-microblaze/conf/layer.conf b/meta-microblaze/conf/layer.conf index 08d17129..4f389bc3 100644 --- a/meta-microblaze/conf/layer.conf +++ b/meta-microblaze/conf/layer.conf @@ -19,3 +19,5 @@ SECURITY_STACK_PROTECTOR:microblaze = "" OLDEST_KERNEL:microblaze = "3.15" INHERIT += "rust_microblaze" + +GDBVERSION:microblaze = "12.1" diff --git a/meta-microblaze/recipes-devtools/gdb/gdb-common.inc b/meta-microblaze/recipes-devtools/gdb/gdb-common.inc new file mode 100644 index 00000000..925b0c2f --- /dev/null +++ b/meta-microblaze/recipes-devtools/gdb/gdb-common.inc @@ -0,0 +1,66 @@ +SUMMARY = "GNU debugger" +HOMEPAGE = "http://www.gnu.org/software/gdb/" +DESCRIPTION = "GDB, the GNU Project debugger, allows you to see what is going on inside another program while it executes -- or what another program was doing at the moment it crashed." +SECTION = "devel" +DEPENDS = "expat gmp zlib ncurses virtual/libiconv ${LTTNGUST} bison-native" + +LTTNGUST = "lttng-ust" +LTTNGUST:arc = "" +LTTNGUST:aarch64 = "" +LTTNGUST:mipsarch = "" +LTTNGUST:sh4 = "" + +inherit autotools texinfo + +UPSTREAM_CHECK_GITTAGREGEX = "gdb\-(?P.+)\-release" + +B = "${WORKDIR}/build-${TARGET_SYS}" + +EXPAT = "--with-expat --with-libexpat-prefix=${STAGING_DIR_HOST}" + +EXTRA_OECONF = "--disable-gdbtk --disable-x --disable-werror \ + --with-curses --disable-multilib --disable-sim \ + --without-guile \ + ${GDBPROPREFIX} ${EXPAT} \ + ${@bb.utils.contains('DISTRO_FEATURES', 'multiarch', '--enable-64-bit-bfd', '', d)} \ + --disable-rpath \ + --disable-gas --disable-binutils \ + --disable-ld --disable-gold \ + --disable-gprof \ + --with-libgmp-prefix=${STAGING_EXECPREFIXDIR} \ +" + +PACKAGECONFIG ??= "readline ${@bb.utils.filter('DISTRO_FEATURES', 'debuginfod', d)}" +# Use --without-system-readline to compile with readline 5. +PACKAGECONFIG[readline] = "--with-system-readline,--without-system-readline,readline" +PACKAGECONFIG[python] = "--with-python=${WORKDIR}/python,--without-python,python3,python3 python3-codecs" +PACKAGECONFIG[babeltrace] = "--with-babeltrace,--without-babeltrace,babeltrace" +# ncurses is already a hard DEPENDS, but would be added here if it weren't +PACKAGECONFIG[tui] = "--enable-tui,--disable-tui" +PACKAGECONFIG[xz] = "--with-lzma --with-liblzma-prefix=${STAGING_DIR_HOST},--without-lzma,xz" +PACKAGECONFIG[debuginfod] = "--with-debuginfod, --without-debuginfod, elfutils" + +GDBPROPREFIX = "--program-prefix=''" + +DISABLE_STATIC = "" + +do_configure () { + # override this function to avoid the autoconf/automake/aclocal/autoheader + # calls for now + (cd ${S} && gnu-configize) || die "failure in running gnu-configize" + oe_runconf +} + +# we don't want gdb to provide bfd/iberty/opcodes, which instead will override the +# right bits installed by binutils. Same for bfd.info -- also from binutils. +do_install:append() { + rm -rf ${D}${libdir} + rm -rf ${D}${includedir} + rm -rf ${D}${datadir}/locale + rm -f ${D}${infodir}/bfd.info +} + +RRECOMMENDS:gdb:append:linux = " glibc-thread-db " +RRECOMMENDS:gdb:append:linux-gnueabi = " glibc-thread-db " +RRECOMMENDS:gdbserver:append:linux = " glibc-thread-db " +RRECOMMENDS:gdbserver:append:linux-gnueabi = " glibc-thread-db " diff --git a/meta-microblaze/recipes-devtools/gdb/gdb-cross-canadian.inc b/meta-microblaze/recipes-devtools/gdb/gdb-cross-canadian.inc new file mode 100644 index 00000000..8e926e81 --- /dev/null +++ b/meta-microblaze/recipes-devtools/gdb/gdb-cross-canadian.inc @@ -0,0 +1,44 @@ +inherit cross-canadian +inherit python3-dir +inherit pkgconfig + +SUMMARY = "GNU debugger (cross-canadian gdb for ${TARGET_ARCH} target)" +PN = "gdb-cross-canadian-${TRANSLATED_TARGET_ARCH}" +BPN = "gdb" + +DEPENDS = "nativesdk-ncurses nativesdk-expat nativesdk-gettext nativesdk-gmp \ + virtual/${HOST_PREFIX}gcc-crosssdk virtual/${HOST_PREFIX}binutils-crosssdk virtual/nativesdk-libc" + +GDBPROPREFIX = "--program-prefix='${TARGET_PREFIX}'" + +# Overrides PACKAGECONFIG variables in gdb-common.inc +PACKAGECONFIG ??= "python readline ${@bb.utils.filter('DISTRO_FEATURES', 'debuginfod', d)}" +PACKAGECONFIG[python] = "--with-python=${WORKDIR}/python,--without-python,nativesdk-python3, \ + nativesdk-python3-core \ + nativesdk-python3-codecs nativesdk-python3-netclient \ + " +PACKAGECONFIG[readline] = "--with-system-readline,--without-system-readline,nativesdk-readline" +PACKAGECONFIG[debuginfod] = "--with-debuginfod, --without-debuginfod, nativesdk-elfutils" + +SSTATE_ALLOW_OVERLAP_FILES += "${STAGING_DATADIR}/gdb" + +do_configure:prepend() { +cat > ${WORKDIR}/python << EOF +#! /bin/sh +case "\$2" in + --includes) echo "-I${STAGING_INCDIR}/${PYTHON_DIR}${PYTHON_ABI}/" ;; + --ldflags) echo "-Wl,-rpath-link,${STAGING_LIBDIR}/.. -Wl,-rpath,${libdir}/.. -lpthread -ldl -lutil -lm -lpython${PYTHON_BASEVERSION}${PYTHON_ABI}" ;; + --exec-prefix) echo "${exec_prefix}" ;; + *) exit 1 ;; +esac +exit 0 +EOF + chmod +x ${WORKDIR}/python +} + +# we don't want gdb to provide bfd/iberty/opcodes, which instead will override the +# right bits installed by binutils. +do_install:append() { + rm -rf ${D}${exec_prefix}/lib + cross_canadian_bindirlinks +} diff --git a/meta-microblaze/recipes-devtools/gdb/gdb-cross-canadian_12.1.bb b/meta-microblaze/recipes-devtools/gdb/gdb-cross-canadian_12.1.bb new file mode 100644 index 00000000..4ab2b715 --- /dev/null +++ b/meta-microblaze/recipes-devtools/gdb/gdb-cross-canadian_12.1.bb @@ -0,0 +1,3 @@ +require gdb-common.inc +require gdb-cross-canadian.inc +require gdb.inc diff --git a/meta-microblaze/recipes-devtools/gdb/gdb-cross.inc b/meta-microblaze/recipes-devtools/gdb/gdb-cross.inc new file mode 100644 index 00000000..9f9675c1 --- /dev/null +++ b/meta-microblaze/recipes-devtools/gdb/gdb-cross.inc @@ -0,0 +1,31 @@ +require gdb-common.inc + +DEPENDS = "expat-native gmp-native ncurses-native flex-native bison-native" + +inherit python3native pkgconfig + +# Overrides PACKAGECONFIG variables in gdb-common.inc +PACKAGECONFIG ??= "python readline ${@bb.utils.filter('DISTRO_FEATURES', 'debuginfod', d)}" +PACKAGECONFIG[python] = "--with-python=${PYTHON},--without-python,python3-native" +PACKAGECONFIG[readline] = "--with-system-readline,--without-system-readline,readline-native" +PACKAGECONFIG[debuginfod] = "--with-debuginfod, --without-debuginfod, elfutils-native" + +do_compile:prepend() { + export STAGING_LIBDIR="${STAGING_LIBDIR_NATIVE}" + export STAGING_INCDIR="${STAGING_INCDIR_NATIVE}" +} + +#EXTRA_OEMAKE += "LDFLAGS='${BUILD_LDFLAGS}'" + +GDBPROPREFIX = "" + +PN = "gdb-cross-${TARGET_ARCH}" +BPN = "gdb" + +# Ignore how TARGET_ARCH is computed. +TARGET_ARCH[vardepvalue] = "${TARGET_ARCH}" + +inherit cross +inherit gettext + +datadir .= "/gdb-${TARGET_SYS}${TARGET_VENDOR}-${TARGET_OS}" diff --git a/meta-microblaze/recipes-devtools/gdb/gdb-cross_12.1.bb b/meta-microblaze/recipes-devtools/gdb/gdb-cross_12.1.bb new file mode 100644 index 00000000..3b654a2f --- /dev/null +++ b/meta-microblaze/recipes-devtools/gdb/gdb-cross_12.1.bb @@ -0,0 +1,2 @@ +require gdb-cross.inc +require gdb.inc diff --git a/meta-microblaze/recipes-devtools/gdb/gdb.inc b/meta-microblaze/recipes-devtools/gdb/gdb.inc new file mode 100644 index 00000000..a5dc5545 --- /dev/null +++ b/meta-microblaze/recipes-devtools/gdb/gdb.inc @@ -0,0 +1,20 @@ +LICENSE = "GPL-2.0-only & GPL-3.0-only & LGPL-2.0-only & LGPL-3.0-only" +LIC_FILES_CHKSUM = "file://COPYING;md5=59530bdf33659b29e73d4adb9f9f6552 \ + file://COPYING3;md5=d32239bcb673463ab874e80d47fae504 \ + file://COPYING3.LIB;md5=6a6a8e020838b23406c81b19c1d46df6 \ + file://COPYING.LIB;md5=9f604d8a4f8e74f4f5140845a21b6674" + +SRC_URI = "${GNU_MIRROR}/gdb/gdb-${PV}.tar.xz \ + file://0001-make-man-install-relative-to-DESTDIR.patch \ + file://0002-mips-linux-nat-Define-_ABIO32-if-not-defined.patch \ + file://0003-ppc-ptrace-Define-pt_regs-uapi_pt_regs-on-GLIBC-syst.patch \ + file://0004-Dont-disable-libreadline.a-when-using-disable-static.patch \ + file://0005-use-asm-sgidefs.h.patch \ + file://0006-Change-order-of-CFLAGS.patch \ + file://0007-resolve-restrict-keyword-conflict.patch \ + file://0008-Fix-invalid-sigprocmask-call.patch \ + file://0009-gdbserver-ctrl-c-handling.patch \ + file://readline-8.2.patch \ + file://0008-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch \ + " +SRC_URI[sha256sum] = "0e1793bf8f2b54d53f46dea84ccfd446f48f81b297b28c4f7fc017b818d69fed" diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0001-make-man-install-relative-to-DESTDIR.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0001-make-man-install-relative-to-DESTDIR.patch new file mode 100644 index 00000000..16d6cf19 --- /dev/null +++ b/meta-microblaze/recipes-devtools/gdb/gdb/0001-make-man-install-relative-to-DESTDIR.patch @@ -0,0 +1,28 @@ +From 8eca28eddcda4ce8a345ca031f43ff1ed6f37089 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Mon, 2 Mar 2015 02:27:55 +0000 +Subject: [PATCH 1/9] make man install relative to DESTDIR + +Upstream-Status: Pending + +Signed-off-by: Khem Raj +--- + sim/common/Make-common.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in +index 74e5dad3049..9e95c224ba4 100644 +--- a/sim/common/Make-common.in ++++ b/sim/common/Make-common.in +@@ -70,7 +70,7 @@ tooldir = $(libdir)/$(target_alias) + datadir = @datadir@ + datarootdir = @datarootdir@ + mandir = @mandir@ +-man1dir = $(mandir)/man1 ++man1dir = $(DESTDIR)$(mandir)/man1 + infodir = @infodir@ + includedir = @includedir@ + +-- +2.36.1 + diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0002-mips-linux-nat-Define-_ABIO32-if-not-defined.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0002-mips-linux-nat-Define-_ABIO32-if-not-defined.patch new file mode 100644 index 00000000..8d263de8 --- /dev/null +++ b/meta-microblaze/recipes-devtools/gdb/gdb/0002-mips-linux-nat-Define-_ABIO32-if-not-defined.patch @@ -0,0 +1,35 @@ +From 37d3afd2eaa95c89ad7cb5d0079b017752e4d0ea Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Wed, 23 Mar 2016 06:30:09 +0000 +Subject: [PATCH 2/9] mips-linux-nat: Define _ABIO32 if not defined + +This helps building gdb on mips64 on musl, since +musl does not provide sgidefs.h this define is +only defined when GCC is using o32 ABI, in that +case gcc emits it as built-in define and hence +it works ok for mips32 + +Upstream-Status: Pending +Signed-off-by: Khem Raj +--- + gdb/mips-linux-nat.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c +index 20e12b6889e..6adc61235aa 100644 +--- a/gdb/mips-linux-nat.c ++++ b/gdb/mips-linux-nat.c +@@ -41,6 +41,10 @@ + #ifndef PTRACE_GET_THREAD_AREA + #define PTRACE_GET_THREAD_AREA 25 + #endif ++/* musl does not define and relies on compiler built-in macros for it */ ++#ifndef _ABIO32 ++#define _ABIO32 1 ++#endif + + class mips_linux_nat_target final : public linux_nat_trad_target + { +-- +2.36.1 + diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0003-ppc-ptrace-Define-pt_regs-uapi_pt_regs-on-GLIBC-syst.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0003-ppc-ptrace-Define-pt_regs-uapi_pt_regs-on-GLIBC-syst.patch new file mode 100644 index 00000000..7e09404b --- /dev/null +++ b/meta-microblaze/recipes-devtools/gdb/gdb/0003-ppc-ptrace-Define-pt_regs-uapi_pt_regs-on-GLIBC-syst.patch @@ -0,0 +1,52 @@ +From e689eec672ee8c53b3adb2ade2b5deb9b7cd99d4 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sat, 30 Apr 2016 18:32:14 -0700 +Subject: [PATCH 3/9] ppc/ptrace: Define pt_regs uapi_pt_regs on !GLIBC systems + +Upstream-Status: Pending + +Signed-off-by: Khem Raj +--- + gdb/nat/ppc-linux.h | 6 ++++++ + gdbserver/linux-ppc-low.cc | 6 ++++++ + 2 files changed, 12 insertions(+) + +diff --git a/gdb/nat/ppc-linux.h b/gdb/nat/ppc-linux.h +index 1094f6b0be3..d8588a646c2 100644 +--- a/gdb/nat/ppc-linux.h ++++ b/gdb/nat/ppc-linux.h +@@ -18,7 +18,13 @@ + #ifndef NAT_PPC_LINUX_H + #define NAT_PPC_LINUX_H + ++#if !defined(__GLIBC__) ++# define pt_regs uapi_pt_regs ++#endif + #include ++#if !defined(__GLIBC__) ++# undef pt_regs ++#endif + #include + + /* This sometimes isn't defined. */ +diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc +index 08824887003..69afbae5359 100644 +--- a/gdbserver/linux-ppc-low.cc ++++ b/gdbserver/linux-ppc-low.cc +@@ -23,7 +23,13 @@ + #include "elf/common.h" + #include + #include ++#if !defined(__GLIBC__) ++# define pt_regs uapi_pt_regs ++#endif + #include ++#if !defined(__GLIBC__) ++# undef pt_regs ++#endif + + #include "arch/ppc-linux-common.h" + #include "arch/ppc-linux-tdesc.h" +-- +2.36.1 + diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0004-Dont-disable-libreadline.a-when-using-disable-static.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0004-Dont-disable-libreadline.a-when-using-disable-static.patch new file mode 100644 index 00000000..a1e85e91 --- /dev/null +++ b/meta-microblaze/recipes-devtools/gdb/gdb/0004-Dont-disable-libreadline.a-when-using-disable-static.patch @@ -0,0 +1,50 @@ +From 15ee6a626242efb8f367be49c13e00d0b72317f0 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sat, 30 Apr 2016 15:25:03 -0700 +Subject: [PATCH 4/9] Dont disable libreadline.a when using --disable-static + +If gdb is configured with --disable-static then this is dutifully passed to +readline which then disables libreadline.a, which causes a problem when gdb +tries to link against that. + +To ensure that readline always builds static libraries, pass --enable-static to +the sub-configure. + +Upstream-Status: Pending +Signed-off-by: Ross Burton +Signed-off-by: Khem Raj +--- + Makefile.def | 3 ++- + Makefile.in | 2 +- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/Makefile.def b/Makefile.def +index acdcd625ed6..78fc31e1199 100644 +--- a/Makefile.def ++++ b/Makefile.def +@@ -120,7 +120,8 @@ host_modules= { module= libiconv; + missing= install-html; + missing= install-info; }; + host_modules= { module= m4; }; +-host_modules= { module= readline; }; ++host_modules= { module= readline; ++ extra_configure_flags='--enable-static';}; + host_modules= { module= sid; }; + host_modules= { module= sim; }; + host_modules= { module= texinfo; no_install= true; }; +diff --git a/Makefile.in b/Makefile.in +index 3aacd2daac9..aa58adada4a 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -32791,7 +32791,7 @@ configure-readline: + $$s/$$module_srcdir/configure \ + --srcdir=$${topdir}/$$module_srcdir \ + $(HOST_CONFIGARGS) --build=${build_alias} --host=${host_alias} \ +- --target=${target_alias} \ ++ --target=${target_alias} --enable-static \ + || exit 1 + @endif readline + +-- +2.36.1 + diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0005-use-asm-sgidefs.h.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0005-use-asm-sgidefs.h.patch new file mode 100644 index 00000000..242099b9 --- /dev/null +++ b/meta-microblaze/recipes-devtools/gdb/gdb/0005-use-asm-sgidefs.h.patch @@ -0,0 +1,36 @@ +From 25a75aaf29791f4302f0e4452f7ebaf735d4f083 Mon Sep 17 00:00:00 2001 +From: Andre McCurdy +Date: Sat, 30 Apr 2016 15:29:06 -0700 +Subject: [PATCH 5/9] use + +Build fix for MIPS with musl libc + +The MIPS specific header is provided by glibc and uclibc +but not by musl. Regardless of the libc, the kernel headers provide + which provides the same definitions, so use that +instead. + +Upstream-Status: Pending + +Signed-off-by: Andre McCurdy +Signed-off-by: Khem Raj +--- + gdb/mips-linux-nat.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c +index 6adc61235aa..afb40066744 100644 +--- a/gdb/mips-linux-nat.c ++++ b/gdb/mips-linux-nat.c +@@ -31,7 +31,7 @@ + #include "gdb_proc_service.h" + #include "gregset.h" + +-#include ++#include + #include "nat/gdb_ptrace.h" + #include + #include "inf-ptrace.h" +-- +2.36.1 + diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0006-Change-order-of-CFLAGS.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0006-Change-order-of-CFLAGS.patch new file mode 100644 index 00000000..58c9b1d0 --- /dev/null +++ b/meta-microblaze/recipes-devtools/gdb/gdb/0006-Change-order-of-CFLAGS.patch @@ -0,0 +1,30 @@ +From c0e7c34134aa1f9644075c596a2338a50d3d923e Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sat, 30 Apr 2016 15:35:39 -0700 +Subject: [PATCH 6/9] Change order of CFLAGS + +Lets us override Werror if need be + +Upstream-Status: Inappropriate + +Signed-off-by: Khem Raj +--- + gdbserver/Makefile.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in +index 47648b8d962..5599779de57 100644 +--- a/gdbserver/Makefile.in ++++ b/gdbserver/Makefile.in +@@ -156,7 +156,7 @@ WIN32APILIBS = @WIN32APILIBS@ + INTERNAL_CFLAGS_BASE = ${GLOBAL_CFLAGS} \ + ${PROFILE_CFLAGS} ${INCLUDE_CFLAGS} ${CPPFLAGS} $(PTHREAD_CFLAGS) + INTERNAL_WARN_CFLAGS = ${INTERNAL_CFLAGS_BASE} $(WARN_CFLAGS) +-INTERNAL_CFLAGS = ${INTERNAL_WARN_CFLAGS} $(WERROR_CFLAGS) -DGDBSERVER ++INTERNAL_CFLAGS = ${INTERNAL_WARN_CFLAGS} $(WERROR_CFLAGS) ${COMPILER_CFLAGS} -DGDBSERVER + + # LDFLAGS is specifically reserved for setting from the command line + # when running make. +-- +2.36.1 + diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0007-resolve-restrict-keyword-conflict.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0007-resolve-restrict-keyword-conflict.patch new file mode 100644 index 00000000..bbd1f0b2 --- /dev/null +++ b/meta-microblaze/recipes-devtools/gdb/gdb/0007-resolve-restrict-keyword-conflict.patch @@ -0,0 +1,48 @@ +From 44fa1ecfbd8a5fe0cfea12a175fa041686842a0c Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Tue, 10 May 2016 08:47:05 -0700 +Subject: [PATCH 7/9] resolve restrict keyword conflict + +GCC detects that we call 'restrict' as param name in function +signatures and complains since both params are called 'restrict' +therefore we use __restrict to denote the C99 keywork + +Upstream-Status: Pending + +Signed-off-by: Khem Raj +--- + gnulib/import/sys_time.in.h | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/gnulib/import/sys_time.in.h b/gnulib/import/sys_time.in.h +index 90a67d18426..664641a1fe8 100644 +--- a/gnulib/import/sys_time.in.h ++++ b/gnulib/import/sys_time.in.h +@@ -93,20 +93,20 @@ struct timeval + # define gettimeofday rpl_gettimeofday + # endif + _GL_FUNCDECL_RPL (gettimeofday, int, +- (struct timeval *restrict, void *restrict) ++ (struct timeval *__restrict, void *__restrict) + _GL_ARG_NONNULL ((1))); + _GL_CXXALIAS_RPL (gettimeofday, int, +- (struct timeval *restrict, void *restrict)); ++ (struct timeval *__restrict, void *__restrict)); + # else + # if !@HAVE_GETTIMEOFDAY@ + _GL_FUNCDECL_SYS (gettimeofday, int, +- (struct timeval *restrict, void *restrict) ++ (struct timeval *__restrict, void *__restrict) + _GL_ARG_NONNULL ((1))); + # endif + /* Need to cast, because on glibc systems, by default, the second argument is + struct timezone *. */ + _GL_CXXALIAS_SYS_CAST (gettimeofday, int, +- (struct timeval *restrict, void *restrict)); ++ (struct timeval *__restrict, void *__restrict)); + # endif + _GL_CXXALIASWARN (gettimeofday); + # if defined __cplusplus && defined GNULIB_NAMESPACE +-- +2.36.1 + diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0008-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0008-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch new file mode 100644 index 00000000..3e293276 --- /dev/null +++ b/meta-microblaze/recipes-devtools/gdb/gdb/0008-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch @@ -0,0 +1,55 @@ +From 48906e1038e469b429aa35d0f967730a929c3880 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sun, 15 Jan 2023 00:16:25 -0800 +Subject: [PATCH 8/8] Define alignof using _Alignof when using C11 or newer + +WG14 N2350 made very clear that it is an UB having type definitions +within "offsetof" [1]. This patch enhances the implementation of macro +alignof_slot to use builtin "_Alignof" to avoid undefined behavior on +when using std=c11 or newer + +clang 16+ has started to flag this [2] + +Fixes build when using -std >= gnu11 and using clang16+ + +Older compilers gcc < 4.9 or clang < 8 has buggy _Alignof even though it +may support C11, exclude those compilers too + +gnulib needs this fix and then it will be applied to downstream packages +like gdb [3] + +[1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm +[2] https://reviews.llvm.org/D133574 +[3] https://public-inbox.org/bug-gnulib/20230114232744.215167-1-raj.khem@gmail.com/T/#u + +Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=2d404c7dd974cc65f894526f4a1b76bc1dcd8d82] +Signed-off-by: Khem Raj +--- + libiberty/sha1.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/libiberty/sha1.c b/libiberty/sha1.c +index 504f06d3b9b..790ada82443 100644 +--- a/libiberty/sha1.c ++++ b/libiberty/sha1.c +@@ -229,7 +229,17 @@ sha1_process_bytes (const void *buffer, size_t len, struct sha1_ctx *ctx) + if (len >= 64) + { + #if !_STRING_ARCH_unaligned ++/* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023 ++ . ++ clang versions < 8.0.0 have the same bug. */ ++#if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \ ++ || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \ ++ && !defined __clang__) \ ++ || (defined __clang__ && __clang_major__ < 8)) + # define alignof(type) offsetof (struct { char c; type x; }, x) ++#else ++# define alignof(type) _Alignof(type) ++#endif + # define UNALIGNED_P(p) (((size_t) p) % alignof (sha1_uint32) != 0) + if (UNALIGNED_P (buffer)) + while (len > 64) +-- +2.39.0 + diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0008-Fix-invalid-sigprocmask-call.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0008-Fix-invalid-sigprocmask-call.patch new file mode 100644 index 00000000..ed1310ce --- /dev/null +++ b/meta-microblaze/recipes-devtools/gdb/gdb/0008-Fix-invalid-sigprocmask-call.patch @@ -0,0 +1,49 @@ +From 5bdd15553daef7370ca3c1f12d8f14247fdd4907 Mon Sep 17 00:00:00 2001 +From: Yousong Zhou +Date: Fri, 24 Mar 2017 10:36:03 +0800 +Subject: [PATCH 8/9] Fix invalid sigprocmask call +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The POSIX document says + + The pthread_sigmask() and sigprocmask() functions shall fail if: + + [EINVAL] + The value of the how argument is not equal to one of the defined values. + +and this is how musl-libc is currently doing. Fix the call to be safe +and correct + + [1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_sigmask.html + +gdb/ChangeLog: +2017-03-24 Yousong Zhou + + * common/signals-state-save-restore.c (save_original_signals_state): + Fix invalid sigprocmask call. + +Upstream-Status: Pending [not author, cherry-picked from LEDE https://bugs.lede-project.org/index.php?do=details&task_id=637&openedfrom=-1%2Bweek] +Signed-off-by: André Draszik +Signed-off-by: Khem Raj +--- + gdbsupport/signals-state-save-restore.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gdbsupport/signals-state-save-restore.cc b/gdbsupport/signals-state-save-restore.cc +index 92e799d3551..a4a0234272a 100644 +--- a/gdbsupport/signals-state-save-restore.cc ++++ b/gdbsupport/signals-state-save-restore.cc +@@ -38,7 +38,7 @@ save_original_signals_state (bool quiet) + int i; + int res; + +- res = gdb_sigmask (0, NULL, &original_signal_mask); ++ res = gdb_sigmask (SIG_BLOCK, NULL, &original_signal_mask); + if (res == -1) + perror_with_name (("sigprocmask")); + +-- +2.36.1 + diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/0009-gdbserver-ctrl-c-handling.patch b/meta-microblaze/recipes-devtools/gdb/gdb/0009-gdbserver-ctrl-c-handling.patch new file mode 100644 index 00000000..f53d3bd1 --- /dev/null +++ b/meta-microblaze/recipes-devtools/gdb/gdb/0009-gdbserver-ctrl-c-handling.patch @@ -0,0 +1,40 @@ +From bc3b1f6aacf2d8fe66b022fbfcf28cd82c76e52f Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Thu, 29 Nov 2018 18:00:23 -0800 +Subject: [PATCH 9/9] gdbserver ctrl-c handling + +This problem was created by the upstream commit 78708b7c8c +After applying the commit, it will send SIGINT to the process +group(-signal_pid). +But if we use gdbserver send SIGINT, and the attached process is not a +process +group leader, then the "kill (-signal_pid, SIGINT)" returns error and +fails to +interrupt the attached process. + +Upstream-Status: Submitted +[https://sourceware.org/bugzilla/show_bug.cgi?id=18945] + +Author: Josh Gao +Signed-off-by: Zhixiong Chi +Signed-off-by: Khem Raj +--- + gdbserver/linux-low.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc +index 7726a4a0c36..f750e074a03 100644 +--- a/gdbserver/linux-low.cc ++++ b/gdbserver/linux-low.cc +@@ -5496,7 +5496,7 @@ linux_process_target::request_interrupt () + { + /* Send a SIGINT to the process group. This acts just like the user + typed a ^C on the controlling terminal. */ +- ::kill (-signal_pid, SIGINT); ++ ::kill (signal_pid, SIGINT); + } + + bool +-- +2.36.1 + diff --git a/meta-microblaze/recipes-devtools/gdb/gdb/readline-8.2.patch b/meta-microblaze/recipes-devtools/gdb/gdb/readline-8.2.patch new file mode 100644 index 00000000..c2db4c0d --- /dev/null +++ b/meta-microblaze/recipes-devtools/gdb/gdb/readline-8.2.patch @@ -0,0 +1,39 @@ +From 1add37b567a7dee39d99f37b37802034c3fce9c4 Mon Sep 17 00:00:00 2001 +From: Andreas Schwab +Date: Sun, 20 Mar 2022 14:01:54 +0100 +Subject: [PATCH] Add support for readline 8.2 + +In readline 8.2 the type of rl_completer_word_break_characters changed to +include const. + +Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=1add37b567a7dee39d99f37b37802034c3fce9c4] +Signed-off-by: Alexander Kanavin +--- + gdb/completer.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/gdb/completer.c b/gdb/completer.c +index d3900ae2014..a51c16ac7f8 100644 +--- a/gdb/completer.c ++++ b/gdb/completer.c +@@ -36,7 +36,7 @@ + calling a hook instead so we eliminate the CLI dependency. */ + #include "gdbcmd.h" + +-/* Needed for rl_completer_word_break_characters() and for ++/* Needed for rl_completer_word_break_characters and for + rl_filename_completion_function. */ + #include "readline/readline.h" + +@@ -2011,7 +2011,7 @@ gdb_completion_word_break_characters_throw () + rl_basic_quote_characters = NULL; + } + +- return rl_completer_word_break_characters; ++ return (char *) rl_completer_word_break_characters; + } + + char * +-- +2.31.1 + diff --git a/meta-microblaze/recipes-devtools/gdb/gdb_12.1.bb b/meta-microblaze/recipes-devtools/gdb/gdb_12.1.bb new file mode 100644 index 00000000..9c6db4ca --- /dev/null +++ b/meta-microblaze/recipes-devtools/gdb/gdb_12.1.bb @@ -0,0 +1,39 @@ +require gdb-common.inc + +inherit gettext pkgconfig + +#LDFLAGS:append = " -s" +#export CFLAGS:append=" -L${STAGING_LIBDIR}" + +# cross-canadian must not see this +PACKAGES =+ "gdbserver" +FILES:gdbserver = "${bindir}/gdbserver" + +require gdb.inc + +inherit python3-dir + +EXTRA_OEMAKE:append:libc-musl = "\ + gt_cv_func_gnugettext1_libc=yes \ + gt_cv_func_gnugettext2_libc=yes \ + gl_cv_func_working_strerror=yes \ + gl_cv_func_strerror_0_works=yes \ + gl_cv_func_gettimeofday_clobber=no \ + " + +do_configure:prepend() { + if [ "${@bb.utils.filter('PACKAGECONFIG', 'python', d)}" ]; then + cat > ${WORKDIR}/python << EOF +#!/bin/sh +case "\$2" in + --includes) echo "-I${STAGING_INCDIR}/${PYTHON_DIR}${PYTHON_ABI}/" ;; + --ldflags) echo "-Wl,-rpath-link,${STAGING_LIBDIR}/.. -Wl,-rpath,${libdir}/.. -lpthread -ldl -lutil -lm -lpython${PYTHON_BASEVERSION}${PYTHON_ABI}" ;; + --exec-prefix) echo "${exec_prefix}" ;; + *) exit 1 ;; +esac +exit 0 +EOF + chmod +x ${WORKDIR}/python + fi +} + -- cgit v1.2.3-54-g00ecf