From e9c5cd3a9230f2f3f5980a5ca0c4ec20c099c7ed Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Wed, 10 Aug 2022 14:18:01 +0100 Subject: gentoo auto-resync : 10:08:2022 - 14:18:00 --- sys-devel/gdb/Manifest | 2 + .../gdb/files/gdb-12.1-core-file-detach.patch | 155 +++++++++++ sys-devel/gdb/gdb-12.1-r2.ebuild | 297 +++++++++++++++++++++ 3 files changed, 454 insertions(+) create mode 100644 sys-devel/gdb/files/gdb-12.1-core-file-detach.patch create mode 100644 sys-devel/gdb/gdb-12.1-r2.ebuild (limited to 'sys-devel/gdb') diff --git a/sys-devel/gdb/Manifest b/sys-devel/gdb/Manifest index c2e2f81e09f8..d8baeb70b950 100644 --- a/sys-devel/gdb/Manifest +++ b/sys-devel/gdb/Manifest @@ -1,10 +1,12 @@ AUX gdb-11.2-glibc-2.35-fsqrt.patch 2212 BLAKE2B c0b9e6e9f27f791d197691ff5bc1e5083b7acb3197312ce5c9afdad02756b69b47f308f85d2b94d3695e8869db8925298bc808468c36c29ddfb289009fb038c4 SHA512 4b8d9ffcd178c0a028b29d8ba2ecb6eedf7a8d67ea1a8bb39276a5d36582502604d7cb1585671e82169539f6a4317224ce61ca4e95b455221340f70a4f1360e0 +AUX gdb-12.1-core-file-detach.patch 5853 BLAKE2B 4442a9d6357f751f9953236a068ffc5e8a1f57eef1bf9e118d572614164486197db44cb6e5f1ab20906ae97ca1c4805a01ce5c2c3cbd1509bb383c108b6b8b1e SHA512 e044053dec340e6373b4a3546adf36ea121bb63a5277d6a1f24f5551edb0cf408f3f862076d6760b27501d54025063afd4a9375914c3f2321f5410466a89f75b AUX gdb-12.1-readline-8.2-build.patch 926 BLAKE2B f483dd1054b019d44dd4731ba22113551d3530a9da1af8c5e83aeae3ba820d96b8a1c2cb7758ecc3fbe8a56cdc7232cdece809d15c30dbfffadc30d81738a7ca SHA512 f865349953181fe3502abbe6042ebab249e2ebbc4c0017ebad756aadfd63e72f57b009fe2e7d036543f326e54518a656101bef572d03a7a7170c9ec305807ed8 AUX gdb-8.3.1-verbose-build.patch 395 BLAKE2B e2e82307ceae64d16aa9b57a5e639eb5d217c4d977aed0847fdf125bb13ebc004906d9afb8e3f629c41efccca88df0040015e7799c1fd24de5fb50f62f5bbd90 SHA512 c2bb013e4fcabefddcd8042bd3cbb53471f83182cc8769fe0d19eed80ccc4a83bd84d120006fa25b3b7d0310dc2f2ec6b44a6ff74909cd312b7e491f371777a3 DIST gdb-11.2.tar.xz 22039420 BLAKE2B 66ce7e12c99c33c8b4e6ababa673204aab525e72c90ba54cc34a5fd69948a09dc2a9ef2050764b2464544231b1d1a6431279c2877388551ca6fbf384a3f9b464 SHA512 07e9026423438049b11f4f784d57401ece4e940570f613bd6958b3714fe7fbc2c048470bcce3e7d7d9f93331cdf3881d30dcc964cb113a071143a02b28e5b127 DIST gdb-12.1.tar.xz 22470332 BLAKE2B 7f6f853d1640908cf2c79932cdc1ba02549a07721c005d9c7ce2946a715761719cc164a4e68235a18664ec8a029afe3a2a0cfb57e1635f280076d6bed91317fd SHA512 425568d2e84672177d0fb87b1ad7daafdde097648d605e30cf0656970f66adc6a82ca2d83375ea4be583e9683a340e5bfdf5819668ddf66728200141ae50ff2d EBUILD gdb-11.2.ebuild 7722 BLAKE2B 1bcbff793ff193619bb8a8d0fc066b4feadb66fde7561386b7cee2a4a21a2589e19581beaad9730d2d39542e34e62e030b4dcf0a27f3494963c61e890873e70b SHA512 2ec73b48268062d058757656a76a3b8c8934cf474850c0f580f7e6a0931c775cf649cbfa812aa2a70c707efb0ae74d0fef78c3faa7780499764adb5f04333e59 EBUILD gdb-12.1-r1.ebuild 8182 BLAKE2B fa5f02ee9d8ca485ec0f3e3c8f59977669cf1bb4ac1317b44dcab292c1a394d826029199d78859206c2e3816af01d3fdcbf077c7bce67a9cd47c8e7e4818e752 SHA512 f2c12426f28e36183009f314ab7164512a6367b4c344f418d00c80279b0a348dacabc1ca6af4c971a4ea949273e9b9e96458a4850a362c1629aa6650f67a4825 +EBUILD gdb-12.1-r2.ebuild 8225 BLAKE2B 3bf43b7d87029a0ec4319c00a177e4df8b4d23a68862b0b1692481e9ed817947ddd9da32d281641772db270d8daee2674696a550be348cde4364d826fc7974a4 SHA512 bd17ae458284a1aca545e4cdb81f0243e942d010d01263bf223a2f542b150bf1ddff90fcb849f00cafad56412910b045d9562785fc64aa1c6819c3a34b420d46 EBUILD gdb-12.1.ebuild 7708 BLAKE2B 13e0a83a1f30c21d973c8bdaa018406b7a60563fec76e73052ccb388308f88acbd613a3c0e115a02f2fa61ff1c2733d79203750e93c815ef85f5f75bd76b23b4 SHA512 3e9e0fd46b7680daf8c8a67200af8fcfb1d0422d372820e758d5a5e8bc0d674b7ae977e600446e2201d645be7e2a930a2165bcb6a09fce5113088aaa2f7bb2ca EBUILD gdb-9999.ebuild 8137 BLAKE2B 5674afcc2ba558478269300ecb18efc14abb528d1d9a9a2175e813b9f110ee29ea63b8a68e10c0e657691b165cc8852b577ed1b504786a0cc651d60edfc5c337 SHA512 d5f2888f77d1f4595d5c2497730ce0900189e02c4b793b4636c607d28f663657a040ba20eb792597bbb8b27d6f39679e5c596b95e62ccfeaaa3b0777449ca3b3 MISC metadata.xml 1103 BLAKE2B e63ea2e52649ac2f4ac21381cadb7cc76525792e99a4a6581535475480b6c45e654c8222b0b58585435d4c858cf3eef00dcaecf7edecae2b2fd336f1b56e6e56 SHA512 f7f1b4da71b18cb68a2f32aa6faae6251528047069071c9bee1be504267d0baf2cbac4fb928e0cbe9df100e3a681e2c3b6c7be14514a45a2f52d30364a8626f4 diff --git a/sys-devel/gdb/files/gdb-12.1-core-file-detach.patch b/sys-devel/gdb/files/gdb-12.1-core-file-detach.patch new file mode 100644 index 000000000000..c0f8a8ee0269 --- /dev/null +++ b/sys-devel/gdb/files/gdb-12.1-core-file-detach.patch @@ -0,0 +1,155 @@ +https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=0fe74cb9ad35add9c6da4df5c9879f254d918a6a + +From: Pedro Alves +Date: Wed, 22 Jun 2022 18:44:37 +0100 +Subject: [PATCH] Fix core-file -> detach -> crash (corefiles/29275) + +After loading a core file, you're supposed to be able to use "detach" +to unload the core file. That unfortunately regressed starting with +GDB 11, with these commits: + + 1192f124a308 - gdb: generalize commit_resume, avoid commit-resuming when threads have pending statuses + 408f66864a1a - detach in all-stop with threads running + +resulting in a GDB crash: + + ... + Thread 1 "gdb" received signal SIGSEGV, Segmentation fault. + 0x0000555555e842bf in maybe_set_commit_resumed_all_targets () at ../../src/gdb/infrun.c:2899 + 2899 if (proc_target->commit_resumed_state) + (top-gdb) bt + #0 0x0000555555e842bf in maybe_set_commit_resumed_all_targets () at ../../src/gdb/infrun.c:2899 + #1 0x0000555555e848bf in scoped_disable_commit_resumed::reset (this=0x7fffffffd440) at ../../src/gdb/infrun.c:3023 + #2 0x0000555555e84a0c in scoped_disable_commit_resumed::reset_and_commit (this=0x7fffffffd440) at ../../src/gdb/infrun.c:3049 + #3 0x0000555555e739cd in detach_command (args=0x0, from_tty=1) at ../../src/gdb/infcmd.c:2791 + #4 0x0000555555c0ba46 in do_simple_func (args=0x0, from_tty=1, c=0x55555662a600) at ../../src/gdb/cli/cli-decode.c:95 + #5 0x0000555555c112b0 in cmd_func (cmd=0x55555662a600, args=0x0, from_tty=1) at ../../src/gdb/cli/cli-decode.c:2514 + #6 0x0000555556173b1f in execute_command (p=0x5555565c5916 "", from_tty=1) at ../../src/gdb/top.c:699 + +The code that crashes looks like: + + static void + maybe_set_commit_resumed_all_targets () + { + scoped_restore_current_thread restore_thread; + + for (inferior *inf : all_non_exited_inferiors ()) + { + process_stratum_target *proc_target = inf->process_target (); + + if (proc_target->commit_resumed_state) + ^^^^^^^^^^^ + +With 'proc_target' above being null. all_non_exited_inferiors filters +out inferiors that have pid==0. We get here at the end of +detach_command, after core_target::detach has already run, at which +point the inferior _should_ have pid==0 and no process target. It is +clear it no longer has a process target, but, it still has a pid!=0 +somehow. + +The reason the inferior still has pid!=0, is that core_target::detach +just unpushes, and relies on core_target::close to actually do the +getting rid of the core and exiting the inferior. The problem with +that is that detach_command grabs an extra strong reference to the +process stratum target, so the unpush_target inside +core_target::detach doesn't actually result in a call to +core_target::close. + +Fix this my moving the cleaning up the core inferior to a shared +routine called by both core_target::close and core_target::detach. We +still need to cleanup the inferior from within core_file::close +because there are paths to it that want to get rid of the core without +going through detach. E.g., "core-file" -> "run". + +This commit includes a new test added to gdb.base/corefile.exp to +cover the "core-file core" -> "detach" scenario. + +Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29275 + +Change-Id: Ic42bdd03182166b19f598428b0dbc2ce6f67c893 +--- a/gdb/corelow.c ++++ b/gdb/corelow.c +@@ -120,6 +120,9 @@ public: + + private: /* per-core data */ + ++ /* Get rid of the core inferior. */ ++ void clear_core (); ++ + /* The core's section table. Note that these target sections are + *not* mapped in the current address spaces' set of target + sections --- those should come only from pure executable or +@@ -290,10 +293,8 @@ core_target::build_file_mappings () + /* An arbitrary identifier for the core inferior. */ + #define CORELOW_PID 1 + +-/* Close the core target. */ +- + void +-core_target::close () ++core_target::clear_core () + { + if (core_bfd) + { +@@ -307,6 +308,14 @@ core_target::close () + + current_program_space->cbfd.reset (nullptr); + } ++} ++ ++/* Close the core target. */ ++ ++void ++core_target::close () ++{ ++ clear_core (); + + /* Core targets are heap-allocated (see core_target_open), so here + we delete ourselves. */ +@@ -592,9 +601,15 @@ core_target_open (const char *arg, int from_tty) + void + core_target::detach (inferior *inf, int from_tty) + { +- /* Note that 'this' is dangling after this call. unpush_target +- closes the target, and our close implementation deletes +- 'this'. */ ++ /* Get rid of the core. Don't rely on core_target::close doing it, ++ because target_detach may be called with core_target's refcount > 1, ++ meaning core_target::close may not be called yet by the ++ unpush_target call below. */ ++ clear_core (); ++ ++ /* Note that 'this' may be dangling after this call. unpush_target ++ closes the target if the refcount reaches 0, and our close ++ implementation deletes 'this'. */ + inf->unpush_target (this); + + /* Clear the register cache and the frame cache. */ +--- a/gdb/testsuite/gdb.base/corefile.exp ++++ b/gdb/testsuite/gdb.base/corefile.exp +@@ -207,6 +207,16 @@ gdb_test "up" "#\[0-9\]* *\[0-9xa-fH'\]* in .* \\(.*\\).*" "up in corefile.exp ( + + gdb_test "core" "No core file now." + ++# Test that we can unload the core with the "detach" command. ++ ++proc_with_prefix corefile_detach {} { ++ clean_restart $::binfile ++ ++ gdb_test "core-file $::corefile" "Core was generated by .*" "load core" ++ gdb_test "detach" "No core file now\\." "detach core" ++} ++ ++corefile_detach + + # Test a run (start) command will clear any loaded core file. + +@@ -222,6 +232,8 @@ proc corefile_test_run {} { + return + } + ++ clean_restart $::binfile ++ + gdb_test "core-file $corefile" "Core was generated by .*" "run: load core again" + gdb_test "info files" "\r\nLocal core dump file:\r\n.*" "run: sanity check we see the core file" + diff --git a/sys-devel/gdb/gdb-12.1-r2.ebuild b/sys-devel/gdb/gdb-12.1-r2.ebuild new file mode 100644 index 000000000000..9da927c79e77 --- /dev/null +++ b/sys-devel/gdb/gdb-12.1-r2.ebuild @@ -0,0 +1,297 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +PYTHON_COMPAT=( python3_{8..11} ) +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.2???????) + # weekly snapshots + SRC_URI="ftp://sourceware.org/pub/gdb/snapshots/current/gdb-weekly-${PV}.tar.xz" + ;; + *) + # Normal upstream release + SRC_URI="mirror://gnu/gdb/${P}.tar.xz + ftp://sourceware.org/pub/gdb/releases/${P}.tar.xz" + ;; +esac + +PATCH_VER="" +PATCH_DEV="" +DESCRIPTION="GNU debugger" +HOMEPAGE="https://sourceware.org/gdb/" +SRC_URI="${SRC_URI} + ${PATCH_DEV:+https://dev.gentoo.org/~${PATCH_DEV}/distfiles/${P}-patches-${PATCH_VER}.tar.xz} + ${PATCH_VER:+mirror://gentoo/${P}-patches-${PATCH_VER}.tar.xz} +" + +LICENSE="GPL-3+ LGPL-2.1+" +SLOT="0" + +if [[ ${PV} != 9999* ]] ; then + KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-cygwin ~amd64-linux ~x86-linux ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris" +fi + +IUSE="cet guile lzma multitarget nls +python +server source-highlight test vanilla xml xxhash" +REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" + +# 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" +# ia64 kernel crashes when gdb testsuite is running +# 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" +RESTRICT=" + ia64? ( test ) + !test? ( test ) + test +" + +RDEPEND=" + dev-libs/mpfr:0= + dev-libs/gmp:= + >=sys-libs/ncurses-5.2-r2:0= + >=sys-libs/readline-7:0= + sys-libs/zlib + elibc_glibc? ( net-libs/libnsl:= ) + 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 + ) +" +DEPEND="${RDEPEND}" +BDEPEND=" + app-arch/xz-utils + sys-apps/texinfo + virtual/yacc + nls? ( sys-devel/gettext ) + source-highlight? ( virtual/pkgconfig ) + test? ( dev-util/dejagnu ) +" + +PATCHES=( + "${FILESDIR}"/${PN}-8.3.1-verbose-build.patch + "${FILESDIR}"/${P}-readline-8.2-build.patch + "${FILESDIR}"/${P}-core-file-detach.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 + # gnulib's or gdb's configure. + --disable-dependency-tracking + + --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,ld} + + # avoid automagic dependency on (currently prefix) systems + # systems with debuginfod library, bug #754753 + --without-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) + + # We need to set both configure options, --with-sysroot and --libdir, + # to fix cross build issues that happen when configuring gmp. + # We explicitly need --libdir. Having only --with-sysroot without + # --libdir would not fix the build issues. + # For some reason, it is not enough to set only --with-sysroot, + # also not enough to pass --with-gmp-xxx options. + --with-sysroot="${ESYSROOT}" + --libdir="${ESYSROOT}/usr/$(get_libdir)" + ) + + local sysroot="${EPREFIX}/usr/${CTARGET}" + + is_cross && myconf+=( + --with-sysroot="${sysroot}" + --includedir="${sysroot}/usr/include" + --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 source-highlight) + $(use multitarget && echo --enable-targets=all) + $(use_with python python "${EPYTHON}") + $(use_with xxhash) + $(use_with guile) + ) + + if use sparc-solaris || use x86-solaris ; then + # Disable largefile support + # https://sourceware.org/ml/gdb-patches/2014-12/msg00058.html + myconf+=( --disable-largefile ) + fi + + # 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_compile() { + emake V=1 +} + +src_install() { + emake V=1 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 + + if [[ -n ${PATCH_VER} ]] ; then + dodoc "${WORKDIR}"/extra/gdbinit.sample + 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