From 1804d2ae908b26fe4e3d3a38646c7d6ffa733d92 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Wed, 24 Jan 2024 10:45:40 +0000 Subject: gentoo auto-resync : 24:01:2024 - 10:45:40 --- dev-debug/gdb/Manifest | 4 + .../files/gdb-14.1-fix-dll-export-forwarding.patch | 60 ++++ .../gdb/files/gdb-14.1-fix-list-segfault.patch | 101 +++++++ .../gdb-14.1-fix-print-global-variable-stubs.patch | 109 +++++++ dev-debug/gdb/gdb-14.1-r1.ebuild | 317 +++++++++++++++++++++ 5 files changed, 591 insertions(+) create mode 100644 dev-debug/gdb/files/gdb-14.1-fix-dll-export-forwarding.patch create mode 100644 dev-debug/gdb/files/gdb-14.1-fix-list-segfault.patch create mode 100644 dev-debug/gdb/files/gdb-14.1-fix-print-global-variable-stubs.patch create mode 100644 dev-debug/gdb/gdb-14.1-r1.ebuild (limited to 'dev-debug/gdb') diff --git a/dev-debug/gdb/Manifest b/dev-debug/gdb/Manifest index 09fedc3eec2c..252b0eccaa05 100644 --- a/dev-debug/gdb/Manifest +++ b/dev-debug/gdb/Manifest @@ -1,8 +1,12 @@ AUX gdb-13.2-fix-sparc-debugging.patch 4736 BLAKE2B 1c6161bca2b29cf035e68231d1c44ff96fead25c6bbaf39aa45daa61be8672b61c7375980f200bdc9787405bd61708b5499764708c4fea6ed41370f9f0f7f18f SHA512 9bb802ddc69fc8d3791590948c4283492665187c7d6eb44bd646176eede2fa1a743e36aa3aba9a60229b2baec9d1cd2ebce1489f84c197694d1a19f48af0b590 +AUX gdb-14.1-fix-dll-export-forwarding.patch 1991 BLAKE2B 4ebc8ad29ce57760b7b2a2ae000f66e1339ad694586d4a89137d922e22e12835340e886c0d0fa3eaec5a74bd889c226d0e46bc9bc5a020e211e8094578b92eb5 SHA512 ec049f5a019707422ddf715dec31a6cb50dd9cb772fcdad8ac8c542cb0e87dff3c7ec1ab990be56a37a2cf789ed3f13f24ac4df49d5cc808537f311f4253a510 +AUX gdb-14.1-fix-list-segfault.patch 3774 BLAKE2B 2ce82892ab66411756d618f8a78d408be18d2d497d54743b8f42c9c02a15d29ed7c45c7837c91319f3ad0a10d7e01be0beb91de86934b4a728ac5031bbaea8df SHA512 d2057d68c3e692e73e863e7cbd0577032d375197f549a87e119c4896b9b55832203a0af8f925e2523ea869be8ed9eb26b8b5ddd6205957b3c1e8c31850f004ac +AUX gdb-14.1-fix-print-global-variable-stubs.patch 3387 BLAKE2B ff3adebf74c8b9ca37071182462b03e753bcc5161d84a53bea418780f4615327459e6dc876a37622b4c3fdeac356bcc09c93a852dc2e54e7b59de465948101d2 SHA512 bcee16dc6f8cd0b0a422bea86e0d90414a17b9779c48bc1ccd41414863141a3591a6b2970dcb0426d847a605d7a8cfef6b83fce0353e7a423acea34057b6ac4d AUX gdb-8.3.1-verbose-build.patch 395 BLAKE2B e2e82307ceae64d16aa9b57a5e639eb5d217c4d977aed0847fdf125bb13ebc004906d9afb8e3f629c41efccca88df0040015e7799c1fd24de5fb50f62f5bbd90 SHA512 c2bb013e4fcabefddcd8042bd3cbb53471f83182cc8769fe0d19eed80ccc4a83bd84d120006fa25b3b7d0310dc2f2ec6b44a6ff74909cd312b7e491f371777a3 DIST gdb-13.2.tar.xz 23664644 BLAKE2B bf5216ba2286448a46f9e0a405367c5a678e6d7540204722d355b618018b7b75a2ebc5b51353304c5ded02a3979223a81781d305f5afa5be82516cdc2863d49f SHA512 8185d3e11ab60dafff5860a5016577bfe7dd7547ef01ebc867bc247603d82b74ff74c4f29492c7d2aee57076f52be33e289f4c6b414a4b870d4b3004909f4c34 DIST gdb-14.1.tar.xz 24108624 BLAKE2B 52a07b4745f95561f360a597d6ec1d212dafc8e9134dc415cd7bcfb02c26934a60807c8400b545a756c68392e16e104178cdc1464430c53611973881e921a942 SHA512 575e198105076fc4a88f68591aa114ab9c1196e84386a3f7b9b58fe5f30cdeed33f6a5f957b68f08c47284ec922bb60c964627e238471419673fd913575ce427 EBUILD gdb-13.2-r2.ebuild 8704 BLAKE2B 1d68e7432fe90bfa0a894edc545da4c8620f7a58ae8fd34f821b38903d28012b276bbf14bd20088639130762a9b9560fb3ee523b1a3073fb54e6ebe0febf4cae SHA512 19a36ac139e714e021dc24c8c9825d60458ea6ff3b03a495d8995fc70a40bb771f1b75acae43f082dc9c467b07d8dc11f8122c0911b335eb1b8d560cf58b1167 +EBUILD gdb-14.1-r1.ebuild 8839 BLAKE2B 52c8ef522357902ad741d91cc7a1599df7683b0d92b8cf419ac825f6407b1a5949eba9576eba1152c75c6c1e3bd661a2c4fce33f5df8a910860bad77199f3301 SHA512 44bf46221eee7a7cfd42a3eb54981dfed039ba24bba1f8d5bf39f29077f54c5c873611c0f86d8724e3e9bad97d53034fa6bad6034ec4d355d5ac884b77f725ba EBUILD gdb-14.1.ebuild 8667 BLAKE2B ecde5bcd03dc14a1ed4ea13ee93ffa29817f6dd4795b1fd1173dd0cc001a73fcf1cc2addef8895a201cab41b83d1e66a6a541acf509108dec60cba334222e0e9 SHA512 2276c8000a3ee66bf9aa8ba7a3f896b368e24ad223fa7540a2558e9257ab5732cffa470006ac339f1fa16b4e9b15f3c125b42a1cc48581522462063d1e33f2a9 EBUILD gdb-9999.ebuild 8667 BLAKE2B ecde5bcd03dc14a1ed4ea13ee93ffa29817f6dd4795b1fd1173dd0cc001a73fcf1cc2addef8895a201cab41b83d1e66a6a541acf509108dec60cba334222e0e9 SHA512 2276c8000a3ee66bf9aa8ba7a3f896b368e24ad223fa7540a2558e9257ab5732cffa470006ac339f1fa16b4e9b15f3c125b42a1cc48581522462063d1e33f2a9 MISC metadata.xml 1348 BLAKE2B 61eb80efbf21b4d0ededbe138710ef7ce69d4c2c137448d780a0a18db13b1b80ccfc41adf9cd825358bb952dae3a627f07d2cb89845ca52383d05fe32c494b49 SHA512 b50fe1fd5fccf7eddac4eff4fd7be955e02227763725b8e00d8e3606346afa978079ed8b754948b9a3ee065441acba4787b48c2b2d55535e0f8b9405fb4f2e90 diff --git a/dev-debug/gdb/files/gdb-14.1-fix-dll-export-forwarding.patch b/dev-debug/gdb/files/gdb-14.1-fix-dll-export-forwarding.patch new file mode 100644 index 000000000000..8c2a49f8042f --- /dev/null +++ b/dev-debug/gdb/files/gdb-14.1-fix-dll-export-forwarding.patch @@ -0,0 +1,60 @@ +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31112 + +From https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=43a608adb04251be8999304cf724f55b2d840ac3 +From: Hannes Domani +Date: Wed, 6 Dec 2023 20:52:06 +0100 +Subject: [PATCH] Fix DLL export forwarding + +I noticed it when I was trying to set a breakpoint at ExitProcess: +``` +(gdb) b ExitProcess +Breakpoint 1 at 0x14001fdd0 +(gdb) r +Starting program: C:\qiewer\heob\heob64.exe +Warning: +Cannot insert breakpoint 1. +Cannot access memory at address 0x3dbf4120 +Cannot insert breakpoint 1. +Cannot access memory at address 0x77644120 +``` + +The problem doesn't exist in gdb 13.2, and the difference can easily be +seen when printing ExitProcess. +gdb 14.1: +``` +(gdb) p ExitProcess +$1 = {} 0x77644120 +``` +gdb 13.2: +``` +(gdb) p ExitProcess +$1 = {} 0x77734120 +``` + +The new behavior started with 9675da25357c7a3f472731ddc6eb3becc65b469a, +where VMA was then calculated relative to FORWARD_DLL_NAME, while it was +relative to DLL_NAME before. + +Fixed by calculating VMA relative to DLL_NAME again. + +Bug: https://sourceware.org/PR31112 +Approved-By: Tom Tromey + +(cherry picked from commit 2574cd903dd84e7081506e24c2e232ecda11a736) +--- a/gdb/coff-pe-read.c ++++ b/gdb/coff-pe-read.c +@@ -210,7 +210,10 @@ add_pe_forwarded_sym (minimal_symbol_reader &reader, + " \"%s\" in dll \"%s\", pointing to \"%s\"\n"), + sym_name, dll_name, forward_qualified_name.c_str ()); + +- unrelocated_addr vma = msymbol.minsym->unrelocated_address (); ++ /* Calculate VMA as if it were relative to DLL_NAME/OBJFILE, even though ++ it actually points inside another dll (FORWARD_DLL_NAME). */ ++ unrelocated_addr vma = unrelocated_addr (msymbol.value_address () ++ - objfile->text_section_offset ()); + msymtype = msymbol.minsym->type (); + section = msymbol.minsym->section_index (); + +-- +2.39.3 + diff --git a/dev-debug/gdb/files/gdb-14.1-fix-list-segfault.patch b/dev-debug/gdb/files/gdb-14.1-fix-list-segfault.patch new file mode 100644 index 000000000000..76557b5a7e00 --- /dev/null +++ b/dev-debug/gdb/files/gdb-14.1-fix-list-segfault.patch @@ -0,0 +1,101 @@ +Bug: https://bugs.gentoo.org/922336 +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31256 + +From https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0068bd6fb3579dd8df7561e038cb3fe27f122b0e +From: Guinevere Larsen +To: gdb-patches@sourceware.org +Cc: Guinevere Larsen +Subject: [PATCH] gdb: fix "list ." related crash +Date: Tue, 23 Jan 2024 11:50:43 +0100 + +When a user attempts to use the "list ." command with an inferior that +doesn't have debug symbols, GDB would crash. This was reported as PR +gdb/31256. + +The crash would happen when attempting to get the current symtab_and_line +for the stop location, because the symtab would return a null pointer +and we'd attempt to dereference it to print the line. + +This commit fixes that by checking for an empty symtab and erroring out +of the function if it happens. + +Bug: https://sourceware.org/PR31256 +--- a/gdb/cli/cli-cmds.c ++++ b/gdb/cli/cli-cmds.c +@@ -1291,6 +1291,8 @@ list_command (const char *arg, int from_tty) + set_default_source_symtab_and_line (); + cursal = get_current_source_symtab_and_line (); + } ++ if (cursal.symtab == nullptr) ++ error (_("No debug information available to print source lines.")); + list_around_line (arg, cursal); + /* Set the repeat args so just pressing "enter" after using "list ." + will print the following lines instead of the same lines again. */ +--- /dev/null ++++ b/gdb/testsuite/gdb.base/list-nodebug.c +@@ -0,0 +1,21 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2024 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++int main () ++{ ++ return 0; ++} +--- /dev/null ++++ b/gdb/testsuite/gdb.base/list-nodebug.exp +@@ -0,0 +1,37 @@ ++# Copyright 2024 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# Test that using the command "list" in a file with no debug information ++# will not crash GDB and will give reasonable output. ++ ++standard_testfile .c ++ ++if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \ ++ {nodebug}]} { ++ return -1 ++} ++ ++if {![runto_main]} { ++ untested "couldn't run to main" ++ return ++} ++ ++# Check that GDB doesn't crash when we use list . on an inferior with ++# no debug information ++gdb_test "list ." "No debug.*" "first 'list .'" ++# This should be called twice because the first list invocation since ++# printing a frame may take a different codepath, which wouldn't ++# trigger the crash. ++gdb_test "list ." "No debug.*" "second 'list .'" +-- +2.43.0 + + diff --git a/dev-debug/gdb/files/gdb-14.1-fix-print-global-variable-stubs.patch b/dev-debug/gdb/files/gdb-14.1-fix-print-global-variable-stubs.patch new file mode 100644 index 000000000000..ff0ff7bfb0c3 --- /dev/null +++ b/dev-debug/gdb/files/gdb-14.1-fix-print-global-variable-stubs.patch @@ -0,0 +1,109 @@ +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31128 + +From https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=bc23ea51f8a83e9524dfb553baa8baacb29e68a9 +From: Hannes Domani +Date: Fri, 8 Dec 2023 19:06:14 +0100 +Subject: [PATCH] Fix printing of global variable stubs if no inferior is + running + +Since 3c45e9f915ae4aeab7312d6fc55a947859057572 gdb crashes when trying +to print a global variable stub without a running inferior, because of +a missing nullptr-check (the block_scope function took care of that +check before it was converted to a method). + +With this check it works again: +``` +(gdb) print s +$1 = +``` + +Bug: https://sourceware.org/PR31128 +Approved-By: Tom Tromey +(cherry picked from commit 576745e26c0ec76a53ba45b20af464628a50b3e4) +--- a/gdb/cp-namespace.c ++++ b/gdb/cp-namespace.c +@@ -1026,7 +1026,11 @@ cp_lookup_transparent_type (const char *name) + + /* If that doesn't work and we're within a namespace, look there + instead. */ +- scope = get_selected_block (0)->scope (); ++ const block *block = get_selected_block (0); ++ if (block == nullptr) ++ return nullptr; ++ ++ scope = block->scope (); + + if (scope[0] == '\0') + return NULL; +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/print-global-stub.cc +@@ -0,0 +1,31 @@ ++/* This testcase is part of GDB, the GNU debugger. ++ ++ Copyright 2023 Free Software Foundation, Inc. ++ ++ This program is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++struct S ++{ ++ S (int); ++ virtual ~S (); ++ ++ int m_i; ++}; ++ ++S s (5); ++ ++int main () ++{ ++ return 0; ++} +--- /dev/null ++++ b/gdb/testsuite/gdb.cp/print-global-stub.exp +@@ -0,0 +1,32 @@ ++# Copyright (C) 2023 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++# This file is part of the GDB testsuite. ++# It tests printing of a global stub without inferior. ++ ++require allow_cplus_tests ++ ++standard_testfile .cc ++set objfile [standard_output_file ${testfile}.o] ++ ++if { [gdb_compile $srcdir/$subdir/$srcfile $objfile object \ ++ {c++ debug}] != "" } { ++ untested "failed to compile" ++ return -1 ++} ++ ++clean_restart $objfile ++ ++gdb_test "print s" " = " +-- +2.39.3 + diff --git a/dev-debug/gdb/gdb-14.1-r1.ebuild b/dev-debug/gdb/gdb-14.1-r1.ebuild new file mode 100644 index 000000000000..2dc97192ac57 --- /dev/null +++ b/dev-debug/gdb/gdb-14.1-r1.ebuild @@ -0,0 +1,317 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +# See https://sourceware.org/gdb/wiki/DistroAdvice for general packaging +# tips & notes. + +PYTHON_COMPAT=( python3_{10..12} ) +inherit flag-o-matic python-single-r1 strip-linguas toolchain-funcs + +export CTARGET=${CTARGET:-${CHOST}} + +if [[ ${CTARGET} == ${CHOST} ]] ; then + if [[ ${CATEGORY} == cross-* ]] ; then + export CTARGET=${CATEGORY#cross-} + fi +fi + +is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; } + +case ${PV} in + 9999*) + # live git tree + EGIT_REPO_URI="https://sourceware.org/git/binutils-gdb.git" + inherit git-r3 + SRC_URI="" + ;; + *.*.50_p2???????|*.*.90_p2???????) + # Weekly snapshots + MY_PV="${PV/_p/.}" + SRC_URI=" + https://sourceware.org/pub/gdb/snapshots/branch/gdb-weekly-${MY_PV}.tar.xz + https://sourceware.org/pub/gdb/snapshots/current/gdb-weekly-${MY_PV}.tar.xz + https://dev.gentoo.org/~sam/distfiles/${CATEGORY}/${PN}/gdb-weekly-${MY_PV}.tar.xz + " + S="${WORKDIR}/${PN}-${MY_PV}" + + # e.g. 13.1.90_p20230325 is a snapshot on the stable branch, so it's fine + if [[ ${PV} == *.[123456789].9?_p2??????? ]] ; then + REGULAR_RELEASE=1 + fi + ;; + *.*.9?) + # Prereleases + MY_PV="${PV/_p/.}" + SRC_URI=" + https://sourceware.org/pub/gdb/snapshots/branch/gdb-${MY_PV}.tar.xz + https://dev.gentoo.org/~sam/distfiles/${CATEGORY}/${PN}/gdb-${MY_PV}.tar.xz + " + S="${WORKDIR}/${PN}-${MY_PV}" + ;; + *) + # Normal upstream release + SRC_URI=" + mirror://gnu/gdb/${P}.tar.xz + https://sourceware.org/pub/gdb/releases/${P}.tar.xz + " + + REGULAR_RELEASE=1 +esac + +PATCH_DEV="" +PATCH_VER="" +DESCRIPTION="GNU debugger" +HOMEPAGE="https://sourceware.org/gdb/" +SRC_URI=" + ${SRC_URI} + ${PATCH_DEV:+https://dev.gentoo.org/~${PATCH_DEV}/distfiles/${CATEGORY}/${PN}/${P}-patches-${PATCH_VER}.tar.xz} + ${PATCH_VER:+mirror://gentoo/${P}-patches-${PATCH_VER}.tar.xz} +" + +LICENSE="GPL-3+ LGPL-2.1+" +SLOT="0" +IUSE="cet debuginfod guile lzma multitarget nls +python +server sim source-highlight test vanilla xml xxhash zstd" +if [[ -n ${REGULAR_RELEASE} ]] ; then + KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris" +fi +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" +RESTRICT="!test? ( test )" + +RDEPEND=" + dev-libs/mpfr:= + dev-libs/gmp:= + >=sys-libs/ncurses-5.2-r2:= + >=sys-libs/readline-7:= + sys-libs/zlib + elibc_glibc? ( net-libs/libnsl:= ) + debuginfod? ( + dev-libs/elfutils[debuginfod(-)] + ) + lzma? ( app-arch/xz-utils ) + python? ( ${PYTHON_DEPS} ) + guile? ( >=dev-scheme/guile-2.0 ) + xml? ( dev-libs/expat ) + source-highlight? ( + dev-util/source-highlight + ) + xxhash? ( + dev-libs/xxhash + ) + zstd? ( app-arch/zstd:= ) +" +DEPEND="${RDEPEND}" +BDEPEND=" + app-arch/xz-utils + sys-apps/texinfo + app-alternatives/yacc + nls? ( sys-devel/gettext ) + source-highlight? ( virtual/pkgconfig ) + test? ( dev-util/dejagnu ) +" + +QA_CONFIG_IMPL_DECL_SKIP=( + MIN # gnulib FP (bug #898688) +) + +PATCHES=( + "${FILESDIR}"/${PN}-8.3.1-verbose-build.patch + "${FILESDIR}"/${PN}-14.1-fix-list-segfault.patch + "${FILESDIR}"/${PN}-14.1-fix-print-global-variable-stubs.patch + "${FILESDIR}"/${PN}-14.1-fix-dll-export-forwarding.patch +) + +pkg_setup() { + use python && python-single-r1_pkg_setup +} + +src_prepare() { + default + + strip-linguas -u bfd/po opcodes/po + + # Avoid using ancient termcap from host on Prefix systems + sed -i -e 's/termcap tinfow/tinfow/g' \ + gdb/configure{.ac,} || die +} + +gdb_branding() { + printf "Gentoo ${PV} " + + if ! use vanilla && [[ -n ${PATCH_VER} ]] ; then + printf "p${PATCH_VER}" + else + printf "vanilla" + fi + + [[ -n ${EGIT_COMMIT} ]] && printf " ${EGIT_COMMIT}" +} + +src_configure() { + strip-unsupported-flags + + # See https://www.gnu.org/software/make/manual/html_node/Parallel-Output.html + # Avoid really confusing logs from subconfigure spam, makes logs far + # more legible. + MAKEOPTS="--output-sync=line ${MAKEOPTS}" + + local myconf=( + # portage's econf() does not detect presence of --d-d-t + # because it greps only top-level ./configure. But not + # libiberty's or gdb's configure. + --disable-dependency-tracking + --disable-silent-rules + + --with-pkgversion="$(gdb_branding)" + --with-bugurl='https://bugs.gentoo.org/' + --disable-werror + # Disable modules that are in a combined binutils/gdb tree. bug #490566 + --disable-{binutils,etc,gas,gold,gprof,gprofng,ld} + + $(use_with debuginfod) + + $(use_enable test unit-tests) + + # Allow user to opt into CET for host libraries. + # Ideally we would like automagic-or-disabled here. + # But the check does not quite work on i686: bug #760926. + $(use_enable cet) + + # Helps when cross-compiling. Not to be confused with --with-sysroot. + --with-build-sysroot="${ESYSROOT}" + ) + + is_cross && myconf+=( + --with-sysroot="\${prefix}/${CTARGET}" + --includedir="\${prefix}/include/${CTARGET}" + --with-gdb-datadir="\${datadir}/gdb/${CTARGET}" + ) + + # gdbserver only works for native targets (CHOST==CTARGET). + # it also doesn't support all targets, so rather than duplicate + # the target list (which changes between versions), use the + # "auto" value when things are turned on, which is triggered + # whenever no --enable or --disable is given + if is_cross || use !server ; then + myconf+=( --disable-gdbserver ) + fi + + myconf+=( + --enable-64-bit-bfd + --disable-install-libbfd + --disable-install-libiberty + --enable-obsolete + # This only disables building in the readline subdir. + # For gdb itself, it'll use the system version. + --disable-readline + --with-system-readline + # This only disables building in the zlib subdir. + # For gdb itself, it'll use the system version. + --without-zlib + --with-system-zlib + --with-separate-debug-dir="${EPREFIX}"/usr/lib/debug + $(use_with xml expat) + $(use_with lzma) + $(use_enable nls) + $(use_enable sim) + $(use_enable source-highlight) + $(use multitarget && echo --enable-targets=all) + $(use_with python python "${EPYTHON}") + $(use_with xxhash) + $(use_with guile) + $(use_with zstd) + + # Find libraries using the toolchain sysroot rather than the configured + # prefix. Needed when cross-compiling. + # + # Check which libraries to apply this to with: + # "${S}"/gdb/configure --help | grep without-lib | sort + --without-lib{babeltrace,expat,gmp,iconv,ipt,lzma,mpfr,xxhash}-prefix + ) + + # source-highlight is detected with pkg-config: bug #716558 + export ac_cv_path_pkg_config_prog_path="$(tc-getPKG_CONFIG)" + + export CC_FOR_BUILD="$(tc-getBUILD_CC)" + + # ensure proper compiler is detected for Clang builds: bug #831202 + export GCC_FOR_TARGET="${CC_FOR_TARGET:-$(tc-getCC)}" + + econf "${myconf[@]}" +} + +src_test() { + # Run the unittests (nabbed invocation from Fedora's spec file) at least + emake -k -C gdb run GDBFLAGS='-batch -ex "maintenance selftest"' + + # Too many failures + # In fact, gdb's test suite needs some work to get passing. + # See e.g. https://sourceware.org/gdb/wiki/TestingGDB. + # As of 11.2, on amd64: "# of unexpected failures 8600" + # Also, ia64 kernel crashes when gdb testsuite is running. + #emake -k check +} + +src_install() { + emake DESTDIR="${D}" install + + find "${ED}"/usr -name libiberty.a -delete || die + + # Delete translations that conflict with binutils-libs. bug #528088 + # Note: Should figure out how to store these in an internal gdb dir. + if use nls ; then + find "${ED}" \ + -regextype posix-extended -regex '.*/(bfd|opcodes)[.]g?mo$' \ + -delete || die + fi + + # Don't install docs when building a cross-gdb + if [[ ${CTARGET} != ${CHOST} ]] ; then + rm -rf "${ED}"/usr/share/{doc,info,locale} || die + local f + for f in "${ED}"/usr/share/man/*/* ; do + if [[ ${f##*/} != ${CTARGET}-* ]] ; then + mv "${f}" "${f%/*}/${CTARGET}-${f##*/}" || die + fi + done + return 0 + fi + + # Install it by hand for now: + # https://sourceware.org/ml/gdb-patches/2011-12/msg00915.html + # Only install if it exists due to the twisted behavior (see + # notes in src_configure above). + [[ -e gdbserver/gdbreplay ]] && dobin gdbserver/gdbreplay + + docinto gdb + dodoc gdb/CONTRIBUTE gdb/README gdb/MAINTAINERS \ + gdb/NEWS gdb/PROBLEMS + docinto sim + dodoc sim/{MAINTAINERS,README-HACKING} + + if use server ; then + docinto gdbserver + dodoc gdbserver/README + fi + + # Remove shared info pages + rm -f "${ED}"/usr/share/info/{annotate,bfd,configure,ctf-spec,standards}.info* + + if use python ; then + python_optimize "${ED}"/usr/share/gdb/python/gdb + fi +} + +pkg_postinst() { + # Portage doesn't unmerge files in /etc + rm -vf "${EROOT}"/etc/skel/.gdbinit + + if use prefix && [[ ${CHOST} == *-darwin* ]] ; then + ewarn "gdb is unable to get a mach task port when installed by Prefix" + ewarn "Portage, unprivileged. To make gdb fully functional you'll" + ewarn "have to perform the following steps:" + ewarn " % sudo chgrp procmod ${EPREFIX}/usr/bin/gdb" + ewarn " % sudo chmod g+s ${EPREFIX}/usr/bin/gdb" + fi +} -- cgit v1.2.3