dev-debug/gdb: Sync with Gentoo

It's from Gentoo commit 6ca5c05218aebc2add4f0d690c03baf876cf40be.
This commit is contained in:
Flatcar Buildbot 2024-07-01 07:12:58 +00:00 committed by Mathieu Tortuyaux
parent d3bf0a6994
commit 5f8d25d394
No known key found for this signature in database
GPG Key ID: AC5CCFB52545D9B8
8 changed files with 21 additions and 411 deletions

View File

@ -1,3 +1,3 @@
DIST gdb-13.2.tar.xz 23664644 BLAKE2B bf5216ba2286448a46f9e0a405367c5a678e6d7540204722d355b618018b7b75a2ebc5b51353304c5ded02a3979223a81781d305f5afa5be82516cdc2863d49f SHA512 8185d3e11ab60dafff5860a5016577bfe7dd7547ef01ebc867bc247603d82b74ff74c4f29492c7d2aee57076f52be33e289f4c6b414a4b870d4b3004909f4c34
DIST gdb-14.1.tar.xz 24108624 BLAKE2B 52a07b4745f95561f360a597d6ec1d212dafc8e9134dc415cd7bcfb02c26934a60807c8400b545a756c68392e16e104178cdc1464430c53611973881e921a942 SHA512 575e198105076fc4a88f68591aa114ab9c1196e84386a3f7b9b58fe5f30cdeed33f6a5f957b68f08c47284ec922bb60c964627e238471419673fd913575ce427
DIST gdb-14.2-sim-modern-c99.patch.xz 5348 BLAKE2B f8039cdf1b49d12eead0dae7db88dbfad4c47eda696ee26b0bd140605d1d62d4a88557518d4e18c86fffb3c6194782d16e459f4392df71d2ec1af271ccb2838d SHA512 f44239871c584f5d6de98db8d6a6766103a8a6fc92dada7d37f04bdc53efe635cca7dfaa778d620348559814f4784a33e5f72a8dd376dc96fba8ec27032ab389
DIST gdb-14.2.tar.xz 24111936 BLAKE2B 65765dfd1ed08e19bb881fc7ae98d6ee4914f38a9a2bb0d0ca73bef472669664f807fe9c04e8dffd7025be98e736ac52f88ff5851ceddbb01a361885b18befc8 SHA512 7e07941f1fe661288cc571b4964012ceabc1760624fce20320db2f470c01439b2386f859b5288da13204b758e2e3b22a74c68c012178db93b9529b06f1e22ede
DIST gdb-15.0.91.tar.xz 24278716 BLAKE2B 8fbbabf40472e6414ef180a9a072db5fa12c9663e723f763c5ebc9583d160d0ca3dc5910e043dba8b12a494a12c202ad095e36e0a0ea2ba1e8e548c3ba1e5221 SHA512 a946b5a074cec93b06b175276c55614b306cfcabb1f467dc0c2f60085cb6853c6d62511a9570ae9ea778c05bad245d8e6e17b15a29b85d48e60d9c8a72086e2e

View File

@ -1,126 +0,0 @@
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=31a56a22c45d76df4c597439f337e3f75ac3065c
https://sourceware.org/bugzilla/show_bug.cgi?id=30525
https://bugs.gentoo.org/907906
From 31a56a22c45d76df4c597439f337e3f75ac3065c Mon Sep 17 00:00:00 2001
From: Pedro Alves <pedro@palves.net>
Date: Wed, 7 Jun 2023 10:38:14 +0100
Subject: [PATCH] Linux: Avoid pread64/pwrite64 for high memory addresses (PR
gdb/30525)
Since commit 05c06f318fd9 ("Linux: Access memory even if threads are
running"), GDB prefers pread64/pwrite64 to access inferior memory
instead of ptrace. That change broke reading shared libraries on
SPARC64 Linux, as reported by PR gdb/30525 ("gdb cannot read shared
libraries on SPARC64").
On SPARC64 Linux, surprisingly (to me), userspace shared libraries are
mapped at high 64-bit addresses:
(gdb) info sharedlibrary
Cannot access memory at address 0xfff80001002011e0
Cannot access memory at address 0xfff80001002011d8
Cannot access memory at address 0xfff80001002011d8
From To Syms Read Shared Object Library
0xfff80001000010a0 0xfff8000100021f80 Yes (*) /lib64/ld-linux.so.2
(*): Shared library is missing debugging information.
Those addresses are 64-bit addresses with the high bits set. When
interpreted as signed, they're negative.
The Linux kernel rejects pread64/pwrite64 if the offset argument of
type off_t (a signed type) is negative, which happens if the memory
address we're accessing has its high bit set. See
linux/fs/read_write.c sys_pread64 and sys_pwrite64 in Linux.
Thankfully, lseek does not fail in that situation. So the fix is to
use the 'lseek + read|write' path if the offset would be negative.
Fix this in both native GDB and GDBserver.
Tested on a SPARC64 GNU/Linux and x86-64 GNU/Linux.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30525
Change-Id: I79c724f918037ea67b7396fadb521bc9d1b10dc5
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -3909,18 +3909,26 @@ linux_proc_xfer_memory_partial_fd (int fd, int pid,
gdb_assert (fd != -1);
- /* Use pread64/pwrite64 if available, since they save a syscall and can
- handle 64-bit offsets even on 32-bit platforms (for instance, SPARC
- debugging a SPARC64 application). */
+ /* Use pread64/pwrite64 if available, since they save a syscall and
+ can handle 64-bit offsets even on 32-bit platforms (for instance,
+ SPARC debugging a SPARC64 application). But only use them if the
+ offset isn't so high that when cast to off_t it'd be negative, as
+ seen on SPARC64. pread64/pwrite64 outright reject such offsets.
+ lseek does not. */
#ifdef HAVE_PREAD64
- ret = (readbuf ? pread64 (fd, readbuf, len, offset)
- : pwrite64 (fd, writebuf, len, offset));
-#else
- ret = lseek (fd, offset, SEEK_SET);
- if (ret != -1)
- ret = (readbuf ? read (fd, readbuf, len)
- : write (fd, writebuf, len));
+ if ((off_t) offset >= 0)
+ ret = (readbuf != nullptr
+ ? pread64 (fd, readbuf, len, offset)
+ : pwrite64 (fd, writebuf, len, offset));
+ else
#endif
+ {
+ ret = lseek (fd, offset, SEEK_SET);
+ if (ret != -1)
+ ret = (readbuf != nullptr
+ ? read (fd, readbuf, len)
+ : write (fd, writebuf, len));
+ }
if (ret == -1)
{
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -5377,21 +5377,26 @@ proc_xfer_memory (CORE_ADDR memaddr, unsigned char *readbuf,
{
int bytes;
- /* If pread64 is available, use it. It's faster if the kernel
- supports it (only one syscall), and it's 64-bit safe even on
- 32-bit platforms (for instance, SPARC debugging a SPARC64
- application). */
+ /* Use pread64/pwrite64 if available, since they save a syscall
+ and can handle 64-bit offsets even on 32-bit platforms (for
+ instance, SPARC debugging a SPARC64 application). But only
+ use them if the offset isn't so high that when cast to off_t
+ it'd be negative, as seen on SPARC64. pread64/pwrite64
+ outright reject such offsets. lseek does not. */
#ifdef HAVE_PREAD64
- bytes = (readbuf != nullptr
- ? pread64 (fd, readbuf, len, memaddr)
- : pwrite64 (fd, writebuf, len, memaddr));
-#else
- bytes = -1;
- if (lseek (fd, memaddr, SEEK_SET) != -1)
+ if ((off_t) memaddr >= 0)
bytes = (readbuf != nullptr
- ? read (fd, readbuf, len)
- : write (fd, writebuf, len));
+ ? pread64 (fd, readbuf, len, memaddr)
+ : pwrite64 (fd, writebuf, len, memaddr));
+ else
#endif
+ {
+ bytes = -1;
+ if (lseek (fd, memaddr, SEEK_SET) != -1)
+ bytes = (readbuf != nullptr
+ ? read (fd, readbuf, len)
+ : write (fd, writebuf, len));
+ }
if (bytes < 0)
return errno;
--
2.39.3

View File

@ -1,60 +0,0 @@
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 <ssbssa@yahoo.de>
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 = {<text variable, no debug info>} 0x77644120 <UserHandleGrantAccess+36128>
```
gdb 13.2:
```
(gdb) p ExitProcess
$1 = {<text variable, no debug info>} 0x77734120 <ntdll!RtlExitUserProcess>
```
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 <tom@tromey.com>
(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

View File

@ -1,101 +0,0 @@
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 <blarsen@redhat.com>
To: gdb-patches@sourceware.org
Cc: Guinevere Larsen <blarsen@redhat.com>
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 <http://www.gnu.org/licenses/>. */
+
+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 <http://www.gnu.org/licenses/>.
+
+# 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

View File

@ -1,109 +0,0 @@
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 <ssbssa@yahoo.de>
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 = <incomplete type>
```
Bug: https://sourceware.org/PR31128
Approved-By: Tom Tromey <tom@tromey.com>
(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 <http://www.gnu.org/licenses/>. */
+
+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 <http://www.gnu.org/licenses/>.
+
+# 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" " = <incomplete type>"
--
2.39.3

View File

@ -6,7 +6,7 @@ EAPI=8
# See https://sourceware.org/gdb/wiki/DistroAdvice for general packaging
# tips & notes.
PYTHON_COMPAT=( python3_{10..11} )
PYTHON_COMPAT=( python3_{10..12} )
inherit flag-o-matic python-single-r1 strip-linguas toolchain-funcs
export CTARGET=${CTARGET:-${CHOST}}
@ -64,8 +64,8 @@ PATCH_DEV=""
PATCH_VER=""
DESCRIPTION="GNU debugger"
HOMEPAGE="https://sourceware.org/gdb/"
SRC_URI="
${SRC_URI}
SRC_URI+="
https://dev.gentoo.org/~sam/distfiles/${CATEGORY}/${PN}/${P}-sim-modern-c99.patch.xz
${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}
"
@ -74,7 +74,7 @@ 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"
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 )"
@ -111,9 +111,13 @@ BDEPEND="
test? ( dev-util/dejagnu )
"
QA_CONFIG_IMPL_DECL_SKIP=(
MIN # gnulib FP (bug #898688)
)
PATCHES=(
"${FILESDIR}"/${PN}-8.3.1-verbose-build.patch
"${FILESDIR}"/${P}-fix-sparc-debugging.patch
"${WORKDIR}"/${PN}-14.2-sim-modern-c99.patch
)
pkg_setup() {
@ -128,6 +132,14 @@ src_prepare() {
# Avoid using ancient termcap from host on Prefix systems
sed -i -e 's/termcap tinfow/tinfow/g' \
gdb/configure{.ac,} || die
if [[ ${CHOST} == *-solaris* ]] ; then
# code relies on C++11, so make sure we get that selected
# due to Python 3.11 pymacro.h doing stuff to work around
# versioning mess based on the C version, while we're compiling
# C++ here, so we need to make it clear we're doing C++11/C11
# because Solaris system headers act on these
sed -i -e 's/-x c++/-std=c++11/' gdb/Makefile.in || die
fi
}
gdb_branding() {
@ -145,9 +157,6 @@ gdb_branding() {
src_configure() {
strip-unsupported-flags
# https://sourceware.org/PR22395, bug #853898
filter-lto
# 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.

View File

@ -74,7 +74,7 @@ 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"
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 )"

View File

@ -74,7 +74,7 @@ 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"
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 )"
@ -117,9 +117,6 @@ QA_CONFIG_IMPL_DECL_SKIP=(
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() {