Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package gdb for openSUSE:Factory checked in at 2025-11-28 16:50:34 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/gdb (Old) and /work/SRC/openSUSE:Factory/.gdb.new.14147 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "gdb" Fri Nov 28 16:50:34 2025 rev:190 rq:1320297 version:16.3 Changes: -------- --- /work/SRC/openSUSE:Factory/gdb/gdb.changes 2025-10-08 18:14:19.961928798 +0200 +++ /work/SRC/openSUSE:Factory/.gdb.new.14147/gdb.changes 2025-11-28 16:50:42.228655635 +0100 @@ -1,0 +2,61 @@ +Wed Nov 26 13:48:35 UTC 2025 - Tom de Vries <[email protected]> + +- Maintenance script qa.sh: + * Fix grep: warning: stray \ before -. + +------------------------------------------------------------------- +Tue Nov 25 09:49:13 UTC 2025 - Tom de Vries <[email protected]> + +- Patches added: + * avoid-crash-with-length.patch + * correct-bounds-check-when-working-around-gas-dwarf-5.patch + * fix-crash-in-f-typeprint.c.patch +- Patches added (swo#33560, bsc#1251213): + * bfd-elf-handle-prstatus-of-156-bytes-in-elf32_arm_na.patch + * gdb-corefiles-fix-segfault-in-add_thread_silent.patch +- Patches added (swo#32542, swo#33354): + * change-return-value-of-_bfd_mmap_temporary.patch +- Patches added (swo#33068, swo#33069): + * gdb-fix-handling-of-aborted-inferior-call.patch +- Patches added (swo#33620): + * gdb-rust-fix-handling-of-unsigned-discriminant.patch +- Patches added (swo#33444): + * have-gdb.threadexitedevent-inherit-from-gdb.threadev.patch +- Patches added (swo#33617): + * mark-pascal-as-case-insensitive.patch +- Patches added (testsuite): + * check-gnatmake-version-in-gnat_version_compare.patch + * gdb-testsuite-fix-build-id-check-in-gdb.python-py-mi.patch + * gdb-testsuite-fix-gdb.mi-mi-sym-info.exp.patch + * gdb-testsuite-fix-gdb.rust-methods.exp-on-i686-linux.patch + * gdb-testsuite-fix-main-in-gdb.trace-mi-trace-frame-c.patch + * gdb-testsuite-fix-possible-tcl-errors-in-gdb.threads.patch + * gdb-testsuite-fix-sizeof-test-in-gdb.rust-simple.exp.patch + * gdb-testsuite-fix-xfail-in-gdb.ada-array_of_variant..patch + * gdb-testsuite-fix-xfail-in-gdb.ada-variant_record_fi.patch + * gdb-testsuite-force-dwarf-in-gdb.pascal.patch + * gdb-testsuite-rust-fix-for-empty-array.patch + * gdb-testsuite-use-expect_build_id_in_core_file-a-bit.patch + * gdb-testsuite-use-std-c99-in-gdb.base-callfuncs.exp.patch + * gdb-testsuite-use-std-c99-in-gdb.base-nodebug.exp.patch + * powerpc-mark-rtti-typeid-tests-as-expected-fail-befo.patch +- Maintenance script import-patches.sh: + * Use git instead of osc. +- Maintenance script qa.sh: + * Add PR32893 kfail. + +------------------------------------------------------------------- +Wed Oct 22 07:55:19 UTC 2025 - Tom de Vries <[email protected]> + +- Patch added (swo#32688): + * gdb-testsuite-yet-another-attempt-to-fix-gdb.threads.patch +- Maintenance script qa.sh: + * Remove PR32688 kfail. + +------------------------------------------------------------------- +Tue Oct 21 14:07:07 UTC 2025 - Tom de Vries <[email protected]> + +- Work around recursively defined sle_version on openSUSE Leap 16.0 + (bsc#1238724). + +------------------------------------------------------------------- New: ---- avoid-crash-with-length.patch bfd-elf-handle-prstatus-of-156-bytes-in-elf32_arm_na.patch change-return-value-of-_bfd_mmap_temporary.patch check-gnatmake-version-in-gnat_version_compare.patch correct-bounds-check-when-working-around-gas-dwarf-5.patch fix-crash-in-f-typeprint.c.patch gdb-corefiles-fix-segfault-in-add_thread_silent.patch gdb-fix-handling-of-aborted-inferior-call.patch gdb-rust-fix-handling-of-unsigned-discriminant.patch gdb-testsuite-fix-build-id-check-in-gdb.python-py-mi.patch gdb-testsuite-fix-gdb.mi-mi-sym-info.exp.patch gdb-testsuite-fix-gdb.rust-methods.exp-on-i686-linux.patch gdb-testsuite-fix-main-in-gdb.trace-mi-trace-frame-c.patch gdb-testsuite-fix-possible-tcl-errors-in-gdb.threads.patch gdb-testsuite-fix-sizeof-test-in-gdb.rust-simple.exp.patch gdb-testsuite-fix-xfail-in-gdb.ada-array_of_variant..patch gdb-testsuite-fix-xfail-in-gdb.ada-variant_record_fi.patch gdb-testsuite-force-dwarf-in-gdb.pascal.patch gdb-testsuite-rust-fix-for-empty-array.patch gdb-testsuite-use-expect_build_id_in_core_file-a-bit.patch gdb-testsuite-use-std-c99-in-gdb.base-callfuncs.exp.patch gdb-testsuite-use-std-c99-in-gdb.base-nodebug.exp.patch gdb-testsuite-yet-another-attempt-to-fix-gdb.threads.patch have-gdb.threadexitedevent-inherit-from-gdb.threadev.patch mark-pascal-as-case-insensitive.patch powerpc-mark-rtti-typeid-tests-as-expected-fail-befo.patch ----------(New B)---------- New:- Patches added: * avoid-crash-with-length.patch * correct-bounds-check-when-working-around-gas-dwarf-5.patch New:- Patches added (swo#33560, bsc#1251213): * bfd-elf-handle-prstatus-of-156-bytes-in-elf32_arm_na.patch * gdb-corefiles-fix-segfault-in-add_thread_silent.patch New:- Patches added (swo#32542, swo#33354): * change-return-value-of-_bfd_mmap_temporary.patch - Patches added (swo#33068, swo#33069): New:- Patches added (testsuite): * check-gnatmake-version-in-gnat_version_compare.patch * gdb-testsuite-fix-build-id-check-in-gdb.python-py-mi.patch New: * avoid-crash-with-length.patch * correct-bounds-check-when-working-around-gas-dwarf-5.patch * fix-crash-in-f-typeprint.c.patch New: * correct-bounds-check-when-working-around-gas-dwarf-5.patch * fix-crash-in-f-typeprint.c.patch - Patches added (swo#33560, bsc#1251213): New: * bfd-elf-handle-prstatus-of-156-bytes-in-elf32_arm_na.patch * gdb-corefiles-fix-segfault-in-add_thread_silent.patch - Patches added (swo#32542, swo#33354): New:- Patches added (swo#33068, swo#33069): * gdb-fix-handling-of-aborted-inferior-call.patch - Patches added (swo#33620): New:- Patches added (swo#33620): * gdb-rust-fix-handling-of-unsigned-discriminant.patch - Patches added (swo#33444): New: * check-gnatmake-version-in-gnat_version_compare.patch * gdb-testsuite-fix-build-id-check-in-gdb.python-py-mi.patch * gdb-testsuite-fix-gdb.mi-mi-sym-info.exp.patch New: * gdb-testsuite-fix-build-id-check-in-gdb.python-py-mi.patch * gdb-testsuite-fix-gdb.mi-mi-sym-info.exp.patch * gdb-testsuite-fix-gdb.rust-methods.exp-on-i686-linux.patch New: * gdb-testsuite-fix-gdb.mi-mi-sym-info.exp.patch * gdb-testsuite-fix-gdb.rust-methods.exp-on-i686-linux.patch * gdb-testsuite-fix-main-in-gdb.trace-mi-trace-frame-c.patch New: * gdb-testsuite-fix-gdb.rust-methods.exp-on-i686-linux.patch * gdb-testsuite-fix-main-in-gdb.trace-mi-trace-frame-c.patch * gdb-testsuite-fix-possible-tcl-errors-in-gdb.threads.patch New: * gdb-testsuite-fix-main-in-gdb.trace-mi-trace-frame-c.patch * gdb-testsuite-fix-possible-tcl-errors-in-gdb.threads.patch * gdb-testsuite-fix-sizeof-test-in-gdb.rust-simple.exp.patch New: * gdb-testsuite-fix-possible-tcl-errors-in-gdb.threads.patch * gdb-testsuite-fix-sizeof-test-in-gdb.rust-simple.exp.patch * gdb-testsuite-fix-xfail-in-gdb.ada-array_of_variant..patch New: * gdb-testsuite-fix-sizeof-test-in-gdb.rust-simple.exp.patch * gdb-testsuite-fix-xfail-in-gdb.ada-array_of_variant..patch * gdb-testsuite-fix-xfail-in-gdb.ada-variant_record_fi.patch New: * gdb-testsuite-fix-xfail-in-gdb.ada-array_of_variant..patch * gdb-testsuite-fix-xfail-in-gdb.ada-variant_record_fi.patch * gdb-testsuite-force-dwarf-in-gdb.pascal.patch New: * gdb-testsuite-fix-xfail-in-gdb.ada-variant_record_fi.patch * gdb-testsuite-force-dwarf-in-gdb.pascal.patch * gdb-testsuite-rust-fix-for-empty-array.patch New: * gdb-testsuite-force-dwarf-in-gdb.pascal.patch * gdb-testsuite-rust-fix-for-empty-array.patch * gdb-testsuite-use-expect_build_id_in_core_file-a-bit.patch New: * gdb-testsuite-rust-fix-for-empty-array.patch * gdb-testsuite-use-expect_build_id_in_core_file-a-bit.patch * gdb-testsuite-use-std-c99-in-gdb.base-callfuncs.exp.patch New: * gdb-testsuite-use-expect_build_id_in_core_file-a-bit.patch * gdb-testsuite-use-std-c99-in-gdb.base-callfuncs.exp.patch * gdb-testsuite-use-std-c99-in-gdb.base-nodebug.exp.patch New: * gdb-testsuite-use-std-c99-in-gdb.base-callfuncs.exp.patch * gdb-testsuite-use-std-c99-in-gdb.base-nodebug.exp.patch * powerpc-mark-rtti-typeid-tests-as-expected-fail-befo.patch New:- Patch added (swo#32688): * gdb-testsuite-yet-another-attempt-to-fix-gdb.threads.patch - Maintenance script qa.sh: New:- Patches added (swo#33444): * have-gdb.threadexitedevent-inherit-from-gdb.threadev.patch - Patches added (swo#33617): New:- Patches added (swo#33617): * mark-pascal-as-case-insensitive.patch - Patches added (testsuite): New: * gdb-testsuite-use-std-c99-in-gdb.base-nodebug.exp.patch * powerpc-mark-rtti-typeid-tests-as-expected-fail-befo.patch - Maintenance script import-patches.sh: ----------(New E)---------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ gdb.spec ++++++ --- /var/tmp/diff_new_pack.AfS8SK/_old 2025-11-28 16:50:45.972813296 +0100 +++ /var/tmp/diff_new_pack.AfS8SK/_new 2025-11-28 16:50:45.976813464 +0100 @@ -16,6 +16,11 @@ # Please submit bugfixes or comments via https://bugs.opensuse.org/ # +%if 0%{?suse_version} >= 1600 +# Workaround recursively defined sle_version, see this PR ( +# https://bugzilla.suse.com/show_bug.cgi?id=1238724 ). +%undefine sle_version +%endif %define flavor @BUILD_FLAVOR@%{nil} @@ -256,10 +261,32 @@ Patch2146: gdb-testsuite-don-t-run-to-main-in-gdb.cp-cplusfuncs.patch Patch2147: gdb-testsuite-fix-timeout-in-gdb.multi-attach-while-.patch Patch2148: gdb-fix-assertion-failure-due-to-null-frame.patch +Patch2149: check-gnatmake-version-in-gnat_version_compare.patch +Patch2150: gdb-fix-handling-of-aborted-inferior-call.patch +Patch2151: gdb-testsuite-fix-possible-tcl-errors-in-gdb.threads.patch +Patch2152: gdb-testsuite-fix-xfail-in-gdb.ada-array_of_variant..patch +Patch2153: gdb-testsuite-fix-gdb.mi-mi-sym-info.exp.patch # Backports from master, available in GDB 18. Patch2500: fix-gdb.server-server-kill.exp.patch +Patch2501: avoid-crash-with-length.patch +Patch2502: correct-bounds-check-when-working-around-gas-dwarf-5.patch +Patch2503: gdb-testsuite-rust-fix-for-empty-array.patch +Patch2504: gdb-testsuite-use-expect_build_id_in_core_file-a-bit.patch +Patch2505: gdb-testsuite-use-std-c99-in-gdb.base-callfuncs.exp.patch +Patch2506: gdb-testsuite-use-std-c99-in-gdb.base-nodebug.exp.patch +Patch2507: change-return-value-of-_bfd_mmap_temporary.patch +Patch2508: fix-crash-in-f-typeprint.c.patch +Patch2509: have-gdb.threadexitedevent-inherit-from-gdb.threadev.patch +Patch2510: gdb-testsuite-fix-gdb.rust-methods.exp-on-i686-linux.patch +Patch2511: gdb-testsuite-fix-sizeof-test-in-gdb.rust-simple.exp.patch +Patch2512: gdb-testsuite-fix-xfail-in-gdb.ada-variant_record_fi.patch +Patch2513: gdb-corefiles-fix-segfault-in-add_thread_silent.patch +Patch2514: gdb-rust-fix-handling-of-unsigned-discriminant.patch +Patch2515: gdb-testsuite-force-dwarf-in-gdb.pascal.patch +Patch2516: gdb-testsuite-fix-main-in-gdb.trace-mi-trace-frame-c.patch +Patch2517: mark-pascal-as-case-insensitive.patch # Backport from gdb-patches @@ -287,6 +314,15 @@ Patch3015: gdb-python-reimplement-gdb.interrupt-race-fix.patch # https://sourceware.org/pipermail/gdb-patches/2025-September/221285.html Patch3016: gdb-c-fix-hang-on-whatis-std-string-npos.patch +# https://sourceware.org/pipermail/gdb-patches/2025-October/221953.html +Patch3017: gdb-testsuite-yet-another-attempt-to-fix-gdb.threads.patch +# https://sourceware.org/pipermail/gdb-patches/2025-November/222840.html +Patch3018: gdb-testsuite-fix-build-id-check-in-gdb.python-py-mi.patch +# https://sourceware.org/pipermail/gdb-patches/2025-November/222874.html +Patch3019: bfd-elf-handle-prstatus-of-156-bytes-in-elf32_arm_na.patch +# https://sourceware.org/pipermail/gdb-patches/2025-November/222919.html +# Todo: submit arm part. +Patch3020: powerpc-mark-rtti-typeid-tests-as-expected-fail-befo.patch # Debug patches. @@ -674,8 +710,30 @@ %patch -P 2146 -p1 %patch -P 2147 -p1 %patch -P 2148 -p1 +%patch -P 2149 -p1 +%patch -P 2150 -p1 +%patch -P 2151 -p1 +%patch -P 2152 -p1 +%patch -P 2153 -p1 %patch -P 2500 -p1 +%patch -P 2501 -p1 +%patch -P 2502 -p1 +%patch -P 2503 -p1 +%patch -P 2504 -p1 +%patch -P 2505 -p1 +%patch -P 2506 -p1 +%patch -P 2507 -p1 +%patch -P 2508 -p1 +%patch -P 2509 -p1 +%patch -P 2510 -p1 +%patch -P 2511 -p1 +%patch -P 2512 -p1 +%patch -P 2513 -p1 +%patch -P 2514 -p1 +%patch -P 2515 -p1 +%patch -P 2516 -p1 +%patch -P 2517 -p1 %patch -P 3000 -p1 %patch -P 3001 -p1 @@ -687,6 +745,10 @@ %patch -P 3014 -p1 %patch -P 3015 -p1 %patch -P 3016 -p1 +%patch -P 3017 -p1 +%patch -P 3018 -p1 +%patch -P 3019 -p1 +%patch -P 3020 -p1 #unpack libipt %if 0%{have_libipt} ++++++ _scmsync.obsinfo ++++++ --- /var/tmp/diff_new_pack.AfS8SK/_old 2025-11-28 16:50:46.096818517 +0100 +++ /var/tmp/diff_new_pack.AfS8SK/_new 2025-11-28 16:50:46.100818686 +0100 @@ -1,5 +1,5 @@ -mtime: 1759806427 -commit: f2af35aae0db03839bb63978ebfacc91fe36bf48ed0aa222dd6c8db86b65ff6c +mtime: 1764171409 +commit: 23d498ecd78ce78144946aaed8510ac9d4d9ecc9d4300ed26691f6235eb5da46 url: https://src.opensuse.org/gcc/gdb.git revision: main ++++++ avoid-crash-with-length.patch ++++++ >From 357a5282a9a6fba1eccb5fb1111f5ae9dbe35b1f Mon Sep 17 00:00:00 2001 From: Tom Tromey <[email protected]> Date: Tue, 21 Jan 2025 10:49:07 -0700 Subject: [PATCH 01/25] Avoid crash with 'length While testing gnat-llvm, I found a gdb crash when applying 'length to a non-array type. This patch fixes the crash. --- gdb/ada-lang.c | 5 ++-- gdb/testsuite/gdb.ada/p-bounds.exp | 36 +++++++++++++++++++++++++ gdb/testsuite/gdb.ada/p-bounds/main.adb | 22 +++++++++++++++ gdb/testsuite/gdb.ada/p-bounds/pck.adb | 21 +++++++++++++++ gdb/testsuite/gdb.ada/p-bounds/pck.ads | 24 +++++++++++++++++ 5 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 gdb/testsuite/gdb.ada/p-bounds.exp create mode 100644 gdb/testsuite/gdb.ada/p-bounds/main.adb create mode 100644 gdb/testsuite/gdb.ada/p-bounds/pck.adb create mode 100644 gdb/testsuite/gdb.ada/p-bounds/pck.ads diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index e9311c179b9..1689989d0f8 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -1819,7 +1819,8 @@ desc_bounds_type (struct type *type) } /* If ARR is an array descriptor (fat or thin pointer), or pointer to - one, a pointer to its bounds data. Otherwise NULL. */ + one, a pointer to its bounds data. Otherwise, throw an + exception. */ static struct value * desc_bounds (struct value *arr) @@ -1870,7 +1871,7 @@ desc_bounds (struct value *arr) return p_bounds; } else - return NULL; + error (_("Not an array")); } /* If TYPE is the type of an array-descriptor (fat pointer), the bit diff --git a/gdb/testsuite/gdb.ada/p-bounds.exp b/gdb/testsuite/gdb.ada/p-bounds.exp new file mode 100644 index 00000000000..d075491152a --- /dev/null +++ b/gdb/testsuite/gdb.ada/p-bounds.exp @@ -0,0 +1,36 @@ +# Copyright 2025 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/>. + +# Check for a crash with a type that looks vaguely like an array +# descriptor. + +load_lib "ada.exp" + +require allow_ada_tests + +standard_ada_testfile main + +if {[gdb_compile_ada "${srcfile}" "${binfile}" executable debug] != ""} { + return -1 +} + +clean_restart ${testfile} + +set bp_location [gdb_get_line_number "STOP" ${testdir}/main.adb] +if {![runto "main.adb:$bp_location"]} { + return +} + +gdb_test "print not_an_array'length" "Not an array" diff --git a/gdb/testsuite/gdb.ada/p-bounds/main.adb b/gdb/testsuite/gdb.ada/p-bounds/main.adb new file mode 100644 index 00000000000..d6654aee240 --- /dev/null +++ b/gdb/testsuite/gdb.ada/p-bounds/main.adb @@ -0,0 +1,22 @@ +-- Copyright 2025 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/>. + +with Pck; use Pck; + +procedure Main is + Not_An_Array : Counfounding := (p_array => 23, p_bounds => 27); +begin + Do_Nothing (Not_An_Array'Address); -- STOP +end Main; diff --git a/gdb/testsuite/gdb.ada/p-bounds/pck.adb b/gdb/testsuite/gdb.ada/p-bounds/pck.adb new file mode 100644 index 00000000000..a175b7bdc5a --- /dev/null +++ b/gdb/testsuite/gdb.ada/p-bounds/pck.adb @@ -0,0 +1,21 @@ +-- Copyright 2014-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/>. + +package body Pck is + procedure Do_Nothing (A : System.Address) is + begin + null; + end Do_Nothing; +end Pck; diff --git a/gdb/testsuite/gdb.ada/p-bounds/pck.ads b/gdb/testsuite/gdb.ada/p-bounds/pck.ads new file mode 100644 index 00000000000..56685773bb9 --- /dev/null +++ b/gdb/testsuite/gdb.ada/p-bounds/pck.ads @@ -0,0 +1,24 @@ +-- Copyright 2014-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/>. + +with System; +package Pck is + type Counfounding is record + p_array: integer; + p_bounds: integer; + end record; + + procedure Do_Nothing (A : System.Address); +end Pck; -- 2.51.0 ++++++ bfd-elf-handle-prstatus-of-156-bytes-in-elf32_arm_na.patch ++++++ >From 7f89abca702d04b67e5018ba89b74867a80ab675 Mon Sep 17 00:00:00 2001 From: Tom de Vries <[email protected]> Date: Sat, 22 Nov 2025 16:19:14 +0100 Subject: [PATCH 16/25] bfd/ELF: Handle prstatus of 156 bytes in elf32_arm_nabi_grok_prstatus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For a corefile generated on openSUSE Leap 15.2 armv7l with linux version 5.3.18, we get: ... $ gdb -q --core core ... Core was generated by `/usr/bin/rs_scope -d'. ⚠️ warning: Couldn't find general-purpose registers in core file. (gdb) ... The warning is emitted because the pseudo-section .reg is missing, because elf32_arm_nabi_grok_prstatus expects the PRSTATUS note to have size 148, but instead we have: ... $ eu-readelf -n core | grep -i prstatus CORE 156 PRSTATUS CORE 156 PRSTATUS CORE 156 PRSTATUS CORE 156 PRSTATUS ... This is a bug for CONFIG_BINFMT_ELF_FDPIC=y configurations, fixed by v5.9 linux kernel commit 16aead81018c ("take fdpic-related parts of elf_prstatus out"). The bug causes the FDPIC-specific unsigned long fields pr_exec_fdpic_loadmap and pr_interp_fdpic_loadmap to be added to struct elf_prstatus in case the FDPIC ABI is not used. Work around this bug in elf32_arm_nabi_grok_prstatus, by ignoring the extra fields, which gets us instead: ... Core was generated by `/usr/bin/rs_scope -d'. Program terminated with signal SIGSEGV, Segmentation fault. [Current thread is 1 (LWP 30047)] (gdb) ... Tested gdb, gas, binutils and ld on x86_64-linux and arm-linux with --enable-targets=all. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33560 --- bfd/elf32-arm.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index 77510687150..838ad43abda 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -2151,6 +2151,16 @@ elf32_arm_nabi_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) default: return false; + case 156: /* Linux/ARM 32-bit, some pre-v5.9 linux kernels. */ + /* There's a linux kernel bug for CONFIG_BINFMT_ELF_FDPIC=y + configurations, fixed by v5.9 linux kernel commit 16aead81018c + ("take fdpic-related parts of elf_prstatus out"). + The bug causes the FDPIC-specific unsigned long fields + pr_exec_fdpic_loadmap and pr_interp_fdpic_loadmap to be added to + struct elf_prstatus in case the FDPIC ABI is not used. + The two fields are added after pr_reg, so just ignore them. */ + + /* Fall through. */ case 148: /* Linux/ARM 32-bit. */ /* pr_cursig */ elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12); -- 2.51.0 ++++++ build.specials.obscpio ++++++ ++++++ build.specials.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.gitignore new/.gitignore --- old/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/.gitignore 2025-11-26 16:37:32.000000000 +0100 @@ -0,0 +1 @@ +.osc ++++++ change-return-value-of-_bfd_mmap_temporary.patch ++++++ >From a8b8576e54323add0cd7d239ea3e7f5cbb4f4bdc Mon Sep 17 00:00:00 2001 From: Tom Tromey <[email protected]> Date: Thu, 4 Sep 2025 14:12:52 -0600 Subject: [PATCH 08/25] Change return value of _bfd_mmap_temporary _bfd_mmap_temporary will return MAP_FAILED in some cases, but only one caller was prepared for this. This caused a couple of issues in gdb. This patch chnages _bfd_mmap_temporary to always return NULL on failure. It also changes the logic to fall back to bfd_malloc if mmap fails. I took the opportunity to change some "(void *) -1" to MAP_FAILED where appropriate. Tested by "make check" in binutils, and also by applying a hack from bug 33354 to gdb and testing something approximating the original report. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32542 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33354 (cherry picked from commit 8b50cc76f19d129b3887dbcb58f8286a7b36099f) --- bfd/bfdio.c | 5 +++-- bfd/libbfd.c | 33 +++++++++++++++------------------ bfd/libbfd.h | 2 +- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/bfd/bfdio.c b/bfd/bfdio.c index 2a7f77fa8d4..1602743c7e2 100644 --- a/bfd/bfdio.c +++ b/bfd/bfdio.c @@ -293,7 +293,7 @@ DESCRIPTION . int (*bstat) (struct bfd *abfd, struct stat *sb); . {* Mmap a part of the files. ADDR, LEN, PROT, FLAGS and OFFSET are the usual . mmap parameter, except that LEN and OFFSET do not need to be page -. aligned. Returns (void *)-1 on failure, mmapped address on success. +. aligned. Returns MAP_FAILED on failure, mmapped address on success. . Also write in MAP_ADDR the address of the page aligned buffer and in . MAP_LEN the size mapped (a page multiple). Use unmap with MAP_ADDR and . MAP_LEN to unmap. *} @@ -725,6 +725,7 @@ DESCRIPTION Return mmap()ed region of the file, if possible and implemented. LEN and OFFSET do not need to be page aligned. The page aligned address and length are written to MAP_ADDR and MAP_LEN. + Returns MAP_FAILED on failure. */ @@ -898,7 +899,7 @@ memory_bmmap (bfd *abfd ATTRIBUTE_UNUSED, void *addr ATTRIBUTE_UNUSED, void **map_addr ATTRIBUTE_UNUSED, size_t *map_len ATTRIBUTE_UNUSED) { - return (void *)-1; + return MAP_FAILED; } const struct bfd_iovec _bfd_memory_iovec = diff --git a/bfd/libbfd.c b/bfd/libbfd.c index 4ab5bf498fd..3488bd09abe 100644 --- a/bfd/libbfd.c +++ b/bfd/libbfd.c @@ -1098,24 +1098,26 @@ bfd_mmap_local (bfd *abfd, size_t rsize, void **map_addr, size_t *map_size) /* Mmap a memory region of RSIZE bytes at the current offset. Return mmap address and size in MAP_ADDR and MAP_SIZE. Return NULL - on invalid input and MAP_FAILED for mmap failure. */ + on invalid input. */ void * _bfd_mmap_temporary (bfd *abfd, size_t rsize, void **map_addr, size_t *map_size) { /* Use mmap only if section size >= the minimum mmap section size. */ - if (rsize < _bfd_minimum_mmap_size) + if (rsize >= _bfd_minimum_mmap_size) { - void *mem = _bfd_malloc_and_read (abfd, rsize, rsize); - /* NB: Set *MAP_ADDR to MEM and *MAP_SIZE to 0 to indicate that - _bfd_malloc_and_read is called. */ - *map_addr = mem; - *map_size = 0; - return mem; + void *result = bfd_mmap_local (abfd, rsize, map_addr, map_size); + if (result != MAP_FAILED) + return result; } - return bfd_mmap_local (abfd, rsize, map_addr, map_size); + void *mem = _bfd_malloc_and_read (abfd, rsize, rsize); + /* NB: Set *MAP_ADDR to MEM and *MAP_SIZE to 0 to indicate that + _bfd_malloc_and_read is called. */ + *map_addr = mem; + *map_size = 0; + return mem; } /* Munmap RSIZE bytes at PTR. */ @@ -1213,15 +1215,10 @@ _bfd_mmap_read_temporary (void **data_p, size_t *size_p, if (use_mmmap) { void *mmaped = _bfd_mmap_temporary (abfd, size, mmap_base, size_p); - /* MAP_FAILED is returned when called from GDB on an object with - opncls_iovec. Use bfd_read in this case. */ - if (mmaped != MAP_FAILED) - { - if (mmaped == NULL) - abort (); - *data_p = mmaped; - return true; - } + if (mmaped == NULL) + return false; + *data_p = mmaped; + return true; } #endif diff --git a/bfd/libbfd.h b/bfd/libbfd.h index d4be334bf87..fa09e3c656e 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -1022,7 +1022,7 @@ struct bfd_iovec int (*bstat) (struct bfd *abfd, struct stat *sb); /* Mmap a part of the files. ADDR, LEN, PROT, FLAGS and OFFSET are the usual mmap parameter, except that LEN and OFFSET do not need to be page - aligned. Returns (void *)-1 on failure, mmapped address on success. + aligned. Returns MAP_FAILED on failure, mmapped address on success. Also write in MAP_ADDR the address of the page aligned buffer and in MAP_LEN the size mapped (a page multiple). Use unmap with MAP_ADDR and MAP_LEN to unmap. */ -- 2.51.0 ++++++ check-gnatmake-version-in-gnat_version_compare.patch ++++++ >From f0aa64a18995ba181aa975804934e9b4b02bf076 Mon Sep 17 00:00:00 2001 From: Tom Tromey <[email protected]> Date: Mon, 31 Mar 2025 11:53:53 -0600 Subject: [PATCH 14/25] Check gnatmake version in gnat_version_compare Tom de Vries pointed out that my earlier change to gnat_version_compare made it actually test gcc's version -- not gnat's. This patch changes gnat_version_compare to examine gnatmake's version, while preserving the nicer API. Approved-By: Tom de Vries <[email protected]> --- gdb/testsuite/lib/ada.exp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gdb/testsuite/lib/ada.exp b/gdb/testsuite/lib/ada.exp index 4d04d597474..3d18e6ad82c 100644 --- a/gdb/testsuite/lib/ada.exp +++ b/gdb/testsuite/lib/ada.exp @@ -223,12 +223,16 @@ proc gnatmake_version_at_least { major } { # compiler does not appear to be GCC, this will always return false. proc gnat_version_compare {op l2} { - set gccvers [gcc_major_version] - if {$gccvers == -1} { + set gnatmake [find_gnatmake] + set gnatmake [lindex [split $gnatmake] 0] + if {[catch {exec $gnatmake --version} output]} { + return 0 + } + if {![regexp {GNATMAKE ([0-9]+(\.[0-9]+)*)} $output match version]} { return 0 } - return [version_compare [split $gccvers .] $op $l2] + return [version_compare [split $version .] $op $l2] } # Return 1 if the GNAT runtime appears to have debug info. -- 2.51.0 ++++++ correct-bounds-check-when-working-around-gas-dwarf-5.patch ++++++ >From c91de4aa70627bd3c33788d90597c1b787c8d905 Mon Sep 17 00:00:00 2001 From: Keith Seitz <[email protected]> Date: Fri, 19 Sep 2025 09:50:46 -0700 Subject: [PATCH 02/25] Correct bounds check when working around GAS DWARF 5 directory table bug Recent Go toolchains are causing GDB to crash on a relatively recent workaround for a GAS bug: commit a833790a626d9620319d0ca6aee23daa584d445c Date: Wed Nov 1 00:33:12 2023 +0100 [gdb/symtab] Work around gas PR28629 In the original GAS bug, the first directory table entry did not contain the current directory of the compilation. So the above commit added a workaround fix to prepend the second directory table entry. However recent Go toolchain compilations (specifically on aarch64) only output a single directory table entry. Looking at the workaround: if (lh->version == 5 && lh->is_valid_file_index (1)) { std::string dir = lh->include_dir_at (1); fnd.set_comp_dir (std::move (dir)); } `lh->is_valid_file_index (1)' is true, but since the directory table only has one entry, `include_dir_at (1)' returns nullptr. Consequently the std::string ctor will segfault. Since there are no guarantees that the file and directory tables are the same size, a better bounds check is to simply rely on `include_dir_at' to ensure a valid directory table entry. I have updated the workaround commit's test, gdb.dwarf2/dw2-gas-workaround.exp and tested on x86_64 and aarch64 RHEL 9 and Fedora 41. Approved-By: Andrew Burgess <[email protected]> --- gdb/dwarf2/read.c | 2 +- .../gdb.dwarf2/dw2-gas-workaround.exp | 92 ++++++++++++------- 2 files changed, 58 insertions(+), 36 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 5fe92c24559..19a46425f84 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -7520,7 +7520,7 @@ read_file_scope (struct die_info *die, struct dwarf2_cu *cu) sect_offset line_offset = (sect_offset) attr->as_unsigned (); line_header_up lh = dwarf_decode_line_header (line_offset, cu, fnd.get_comp_dir ()); - if (lh->version == 5 && lh->is_valid_file_index (1)) + if (lh->version == 5 && lh->include_dir_at (1) != nullptr) { std::string dir = lh->include_dir_at (1); fnd.set_comp_dir (std::move (dir)); diff --git a/gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp b/gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp index 5d6e13a9ae0..4155358f50e 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-gas-workaround.exp @@ -20,7 +20,7 @@ load_lib dwarf.exp # This test can only be run on targets which support DWARF-2 and use gas. require dwarf2_support -standard_testfile dw2-lines.c -dw2.S +standard_testfile dw2-lines.c -dw2.S -dw2-one-diridx.S with_shared_gdb { set func_info_vars [get_func_info bar] @@ -33,49 +33,61 @@ proc line_for { l } { return [expr $line + 1] } -set asm_file [standard_output_file $srcfile2] -Dwarf::assemble $asm_file { - declare_labels Llines - global srcdir subdir srcfile objdir - global func_info_vars - foreach var $func_info_vars { - global $var - } +# A helper proc to create the DWARF assembly for the test. +# If ONE_DIRIDX is true, then the directory table will be limited +# to one entry. +proc create_dwarf_assembly {source_file one_diridx} { + set asm_file [standard_output_file $source_file] + Dwarf::assemble $asm_file { + declare_labels Llines + global srcdir subdir srcfile objdir + global func_info_vars + upvar one_diridx one_diridx + foreach var $func_info_vars { + global $var + } - cu { version 5 } { - compile_unit { - {language @DW_LANG_Mips_Assembler} - {name $srcfile} - {comp_dir $objdir} - {stmt_list $Llines DW_FORM_sec_offset} - {producer "GNU AS 2.35.2"} - } { - subprogram { - {external 1 flag} - {name bar} - {low_pc $bar_start addr} - {high_pc "$bar_start + $bar_len" addr} + cu { version 5 } { + compile_unit { + {DW_AT_language @DW_LANG_Mips_Assembler} + {DW_AT_name $srcfile} + {DW_AT_comp_dir $objdir} + {DW_AT_stmt_list $Llines DW_FORM_sec_offset} + {DW_AT_producer "GNU AS 2.35.2"} + } { + subprogram { + {DW_AT_external 1 flag} + {DW_AT_name bar} + {DW_AT_low_pc $bar_start addr} + {DW_AT_high_pc "$bar_start + $bar_len" addr} + } } } - } - lines [list version 5] Llines { - set diridx1 [include_dir "${srcdir}/${subdir}"] - set diridx2 [include_dir "${srcdir}/${subdir}"] - file_name "$srcfile" $diridx1 - file_name "$srcfile" $diridx2 - - program { - DW_LNE_set_address bar_label - line [line_for bar_label] - DW_LNS_copy + lines [list version 5] Llines { + set diridx1 [include_dir "${srcdir}/${subdir}"] + file_name "$srcfile" $diridx1 + if {!$one_diridx} { + set diridx2 [include_dir "${srcdir}/${subdir}"] + file_name "$srcfile" $diridx2 + } else { + file_name "$srcfile" $diridx1 + } + program { + DW_LNE_set_address bar_label + line [line_for bar_label] + DW_LNS_copy - DW_LNE_set_address $bar_end - DW_LNE_end_sequence + DW_LNE_set_address $bar_end + DW_LNE_end_sequence + } } } + + return $asm_file } +set asm_file [create_dwarf_assembly $srcfile2 false] if { [prepare_for_testing "failed to prepare" ${testfile} \ [list $srcfile $asm_file] {nodebug}] } { return -1 @@ -90,3 +102,13 @@ gdb_test_multiple "ptype bar" "" { pass $gdb_test_name } } + +# Test whether gdb crashes in the case where the number of +# directory indexes is only one. +set asm_file [create_dwarf_assembly $srcfile3 true] +if {[prepare_for_testing "failed to prepare" ${testfile}-one-diridx \ + [list $srcfile $asm_file] {nodebug}] } { + return -1 +} + +gdb_test "ptype bar" ".*" "do not crash with only one directory table entry" -- 2.51.0 ++++++ fix-crash-in-f-typeprint.c.patch ++++++ >From a69161a5cbdd93ccd27ea6e07139611039ff3b56 Mon Sep 17 00:00:00 2001 From: Tom Tromey <[email protected]> Date: Sat, 13 Sep 2025 13:44:10 -0600 Subject: [PATCH 09/25] Fix crash in f-typeprint.c I noticed a crash in f-typeprint.c that was hidden by an xfail: XFAIL: gdb.fortran/vla-array.exp: print variable length string array type (GDB internal error) (PRMS gcc/101826) I think this was introduced by commit 6594ca4a ("do not handle a NULL linebuffer in pager_file::puts") but not detected due to the xfail. It seems bad for an xfail to cover up a crash but I haven't investigated that. Meanwhile, this patch fixes the crash by checking for a NULL pointer when calling gdb_puts. Approved-by: Kevin Buettner <[email protected]> (cherry picked from commit 18400a9cdf6b3d84996a99697a97774f268576c2) --- gdb/f-typeprint.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c index 36e434ae5c2..cba7099c0db 100644 --- a/gdb/f-typeprint.c +++ b/gdb/f-typeprint.c @@ -414,9 +414,11 @@ f_language::f_type_print_base (struct type *type, struct ui_file *stream, if (show > 0) f_type_print_derivation_info (type, stream); - gdb_puts (" ", stream); - - gdb_puts (type->name (), stream); + if (type->name () != nullptr) + { + gdb_puts (" ", stream); + gdb_puts (type->name (), stream); + } /* According to the definition, we only print structure elements in case show > 0. */ @@ -435,7 +437,8 @@ f_language::f_type_print_base (struct type *type, struct ui_file *stream, gdb_puts ("\n", stream); } gdb_printf (stream, "%*sEnd Type ", level, ""); - gdb_puts (type->name (), stream); + if (type->name () != nullptr) + gdb_puts (type->name (), stream); } break; -- 2.51.0 ++++++ gdb-corefiles-fix-segfault-in-add_thread_silent.patch ++++++ >From 01a9516fcbec4ac8d4cafab711d22d4396094694 Mon Sep 17 00:00:00 2001 From: Tom de Vries <[email protected]> Date: Fri, 21 Nov 2025 14:38:01 +0100 Subject: [PATCH 15/25] [gdb/corefiles] Fix segfault in add_thread_silent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A user reported a segfault when loading a core file [1]. The core file is from arm-linux, but I reproduced the segfault on x86_64-linux: ... $ gdb -q --core core warning: Can't open file /usr/bin/rs_scope during file-backed mapping note processing warning: Can't open file /lib/libc-2.26.so during file-backed mapping note processing warning: File /lib/libgcc_s.so.1 doesn't match build-id from core-file during file-backed mapping processing warning: Can't open file /lib/libm-2.26.so during file-backed mapping note processing warning: Can't open file /usr/lib/libstdc++.so.6.0.28 during file-backed mapping note processing warning: Can't open file /lib/libpthread-2.26.so during file-backed mapping note processing warning: Can't open file /lib/ld-2.26.so during file-backed mapping note processing Fatal signal: Segmentation fault ----- Backtrace ----- 0x64a4ff gdb_internal_backtrace_1 gdb/bt-utils.c:122 0x64a59d _Z22gdb_internal_backtracev gdb/bt-utils.c:175 0x9429e7 handle_fatal_signal gdb/event-top.c:1013 0x942b96 handle_sigsegv gdb/event-top.c:1090 0x7fbf6a64708f ??? /usr/src/debug/glibc-2.40/signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0 0x5eb453 _ZN9__gnu_cxx17__normal_iteratorIPKSt4pairI6ptid_tP11thread_infoESt6vectorIS5_SaIS5_EEEC4ERKS7_ /usr/include/c++/15/bits/stl_iterator.h:1059 0x5eb453 _ZNKSt6vectorISt4pairI6ptid_tP11thread_infoESaIS4_EE3endEv /usr/include/c++/15/bits/stl_vector.h:1029 0x5eae9e _ZNKSt6vectorISt4pairI6ptid_tP11thread_infoESaIS4_EE5emptyEv /usr/include/c++/15/bits/stl_vector.h:1224 0xa77588 _ZNK6ankerl15unordered_dense6v4_4_06detail5tableI6ptid_tP11thread_infoNS1_4hashIS4_vEESt8equal_toIS4_ESaISt4pairIS4_S6_EENS1_11bucket_type8standardELb0EE5emptyEv gdb/../gdbsupport/unordered_dense.h:1351 0xa76533 _ZN6ankerl15unordered_dense6v4_4_06detail5tableI6ptid_tP11thread_infoNS1_4hashIS4_vEESt8equal_toIS4_ESaISt4pairIS4_S6_EENS1_11bucket_type8standardELb0EE7do_findIS4_EEN9__gnu_cxx17__normal_iteratorIPSC_St6vectorISC_SD_EEERKT_ gdb/../gdbsupport/unordered_dense.h:1119 0xa74fef _ZN6ankerl15unordered_dense6v4_4_06detail5tableI6ptid_tP11thread_infoNS1_4hashIS4_vEESt8equal_toIS4_ESaISt4pairIS4_S6_EENS1_11bucket_type8standardELb0EE4findERKS4_ gdb/../gdbsupport/unordered_dense.h:1773 0xa6f787 _ZN8inferior11find_threadE6ptid_t gdb/inferior.c:253 0xfc852a _Z17add_thread_silentP22process_stratum_target6ptid_t gdb/thread.c:310 0x73b995 core_target_open gdb/corelow.c:1111 0x73a095 _Z17core_file_commandPKci gdb/corelow.c:708 0xb6cb38 catch_command_errors gdb/main.c:510 0xb6e354 captured_main_1 gdb/main.c:1279 0xb6e9a2 captured_main gdb/main.c:1372 0xb6eaa3 _Z8gdb_mainP18captured_main_args gdb/main.c:1401 0x419704 main gdb/gdb.c:38 ... The problem happens as follows. In core_target_open, we do: ... if (thread == NULL) thread = add_thread_silent (target, ptid_t (CORELOW_PID)); ... and then in add_thread_silent: ... struct thread_info * add_thread_silent (process_stratum_target *targ, ptid_t ptid) { gdb_assert (targ != nullptr); inferior *inf = find_inferior_ptid (targ, ptid); ... find_inferior_ptid returns nullptr, which eventually causes the segfault. So, why can't we find an inferior with CORELOW_PID? A bit earlier in core_target_open, we do: ... /* Find (or fake) the pid for the process in this core file, and initialise the current inferior with that pid. */ bool fake_pid_p = false; int pid = bfd_core_file_pid (target->core_bfd ()); if (pid == 0) { fake_pid_p = true; pid = CORELOW_PID; } inferior *inf = current_inferior (); gdb_assert (inf->pid == 0); inferior_appeared (inf, pid); inf->fake_pid_p = fake_pid_p; ... The problem is that looking for an inferior using CORELOW_PID is correct in case fake_pid_p == true, but otherwise not. Fix this by using inf->pid instead: ... - thread = add_thread_silent (target, ptid_t (CORELOW_PID)); + thread = add_thread_silent (target, ptid_t (inf->pid)); ... Doing so enables us to continue to a gdb prompt: ... Core was generated by `/usr/bin/rs_scope -d'. ⚠️ warning: Couldn't find general-purpose registers in core file. (gdb) ... The warning is emitted because the pseudo-section .reg is missing, because elf32_arm_nabi_grok_prstatus expects the PRSTATUS note to have size 148, but instead we have: ... $ eu-readelf -n core | grep -i prstatus CORE 156 PRSTATUS CORE 156 PRSTATUS CORE 156 PRSTATUS CORE 156 PRSTATUS ... I'm assuming this is a bug for CONFIG_BINFMT_ELF_FDPIC=y configurations, fixed by v5.9 linux kernel commit 16aead81018c ("take fdpic-related parts of elf_prstatus out"). The core was generated using a kernel with CONFIG_BINFMT_ELF_FDPIC=y and v5.3.18. We can try to work around this bug in elf32_arm_nabi_grok_prstatus, but that's out of scope for this commit, which focuses on fixing the segfault. Tested on x86_64-linux. Approved-By: Andrew Burgess <[email protected]> PR corefiles/33560 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33560 [1] https://bugzilla.suse.com/show_bug.cgi?id=1251213 --- gdb/corelow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/corelow.c b/gdb/corelow.c index 59c16677109..69bb7e4f163 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -1120,7 +1120,7 @@ core_target_open (const char *arg, int from_tty) thread_info *thread = first_thread_of_inferior (inf); if (thread == NULL) - thread = add_thread_silent (target, ptid_t (CORELOW_PID)); + thread = add_thread_silent (target, ptid_t (inf->pid)); switch_to_thread (thread); } -- 2.51.0 ++++++ gdb-fix-handling-of-aborted-inferior-call.patch ++++++ >From a8669ab2846396a2eb310e969250b39bd8116920 Mon Sep 17 00:00:00 2001 From: Tom de Vries <[email protected]> Date: Mon, 1 Sep 2025 09:07:11 +0200 Subject: [PATCH 21/25] [gdb] Fix handling of aborted inferior call PR gdb/33069 reports the following behavior: ... $ gdb -q ls -ex starti -ex "b *1" Reading symbols from ls... (No debugging symbols found in ls) Starting program: /usr/bin/ls Program stopped. 0x00007ffff7fe4f00 in _start () from /lib64/ld-linux-x86-64.so.2 Breakpoint 1 at 0x1 (gdb) p (int)strlen("abc") Warning: Cannot insert breakpoint 1. Cannot access memory at address 0x1 Command aborted. An error occurred while in a function called from GDB. Evaluation of the expression containing the function (malloc@plt) will be abandoned. When the function is done executing, GDB will silently stop. [1]+ Stopped gdb -q ls -ex starti -ex "b *1" $ fg gdb -q ls -ex starti -ex "b *1" (gdb) ... with gdb being unresponsive to further input. PR gdb/33068 reports a similar problem, but using gdbserver, and in that case gdb doesn't go into the background, but is likewise unresponsive. This is a regression since commit b1c0ab20809 ("gdb: avoid double stop after failed breakpoint condition check"), and consequently since release gdb 14.1. The commit changed this in run_inferior_call: ... if (current_ui->prompt_state == PROMPT_BLOCKED) - current_ui->unregister_file_handler (); - else - current_ui->register_file_handler (); + { + if (call_thread->thread_fsm ()->finished_p ()) + async_disable_stdin (); + else + async_enable_stdin (); + } ... which means current_ui->register_file_handler is no longer called in the current_ui->prompt_state == PROMPT_NEEDED case. Fix this by: - restoring this behavior, fixing the unresponsiveness, and - adding target_terminal::ours alongside it, fixing the problem that gdb goes into the background. Add a new test-case gdb.base/infcall-failure-2.exp, a regression test for the unresponsiveness issue. The problem of gdb going into the background did not reproduce in the test-case. Tested on x86_64-linux. Reviewed-By: Keith Seitz <[email protected]> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33068 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33069 --- gdb/infcall.c | 12 +++++-- gdb/testsuite/gdb.base/infcall-failure-2.exp | 37 ++++++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 gdb/testsuite/gdb.base/infcall-failure-2.exp diff --git a/gdb/infcall.c b/gdb/infcall.c index 6399278c6ae..d0c6517e84a 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -887,9 +887,9 @@ run_inferior_call (std::unique_ptr<call_thread_fsm> sm, call async_enable_stdin. This changes the prompt state to PROMPT_NEEDED. - If the previous prompt state was PROMPT_NEEDED, then as - async_enable_stdin has already been called, nothing additional - needs to be done here. */ + If the previous prompt state was PROMPT_NEEDED, then async_enable_stdin + may or may not have been called, so do the same changes as in + async_enable_stdin. */ if (current_ui->prompt_state == PROMPT_BLOCKED) { if (call_thread->thread_fsm ()->finished_p ()) @@ -897,6 +897,12 @@ run_inferior_call (std::unique_ptr<call_thread_fsm> sm, else async_enable_stdin (); } + else if (current_ui->prompt_state == PROMPT_NEEDED) + { + /* Copied from async_enable_stdin. */ + target_terminal::ours (); + current_ui->register_file_handler (); + } /* If the infcall does NOT succeed, normal_stop will have already finished the thread states. However, on success, normal_stop diff --git a/gdb/testsuite/gdb.base/infcall-failure-2.exp b/gdb/testsuite/gdb.base/infcall-failure-2.exp new file mode 100644 index 00000000000..2a7d7844acf --- /dev/null +++ b/gdb/testsuite/gdb.base/infcall-failure-2.exp @@ -0,0 +1,37 @@ +# Copyright 2025 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/>. + +standard_testfile infcall-failure.c + +if { [prepare_for_testing "failed to prepare" $testfile $srcfile] == -1 } { + return +} + +if { ![runto_main] } { + return +} + +if { ![gdb_breakpoint "*0x1" message] } { + return +} + +gdb_test "p foo ()" \ + [multi_line \ + [string_to_regexp "Command aborted."] \ + ".*" ] + +# Check that gdb is still responsive. Regression test for PR gdb/33068. +gdb_test "p 1 + 1" \ + " = 2" -- 2.51.0 ++++++ gdb-rust-fix-handling-of-unsigned-discriminant.patch ++++++ >From aba0fa2aacf1f2a82e4d7e3482a48f8d7216d7d8 Mon Sep 17 00:00:00 2001 From: Tom de Vries <[email protected]> Date: Tue, 11 Nov 2025 22:34:24 +0100 Subject: [PATCH 17/25] [gdb/rust] Fix handling of unsigned discriminant On i686-linux, with test-case gdb.rust/simple.exp, we get: ... (gdb) print str_none^M $71 = core::option::Option<alloc::string::String>::Some(alloc::string::String {vec: alloc::vec::Vec<u8, alloc::alloc::Global> {buf: alloc::raw_vec::RawVec<u8, alloc::alloc::Global> {inner: alloc::raw_vec::RawVecInner<alloc::alloc::Global> {ptr: core::ptr::unique::Unique<u8> {pointer: core::ptr::non_null::NonNull<u8> {pointer: 0xbfffe6e8}, _marker: core::marker::PhantomData<u8>}, cap: core::num::niche_types::UsizeNoHighBit (2147483648), alloc: alloc::alloc::Global}, _marker: core::marker::PhantomData<u8>}, len: 4321411}})^M (gdb) FAIL: $exp: print str_none ... while this is expected: ... (gdb) print str_none^M $71 = core::option::Option<alloc::string::String>::None^M (gdb) PASS: $exp: print str_none ... Printing the variable in C mode: ... $ gdb -q -batch outputs/gdb.rust/simple/simple \ -ex "b 161" \ -ex run \ -ex "set language c" \ -ex "p /x str_none" ... $1 = {0x80000000, Some = {__0 = {vec = {buf = {inner = {ptr = {pointer = {pointer = 0xbfffedd8}, _marker = {<No data fields>}}, cap = {__0 = 0x80000000}, alloc = {<No data fields>}}, _marker = {<No data fields>}}, len = 0x41f083}}}} ... shows us that the discriminant value is 0x80000000, which matches the "None" variant: ... <3><1427>: Abbrev Number: 16 (DW_TAG_structure_type) <1428> DW_AT_name : Option<alloc::string::String> <142c> DW_AT_byte_size : 12 <142d> DW_AT_accessibility: 1 (public) <142e> DW_AT_alignment : 4 <4><142f>: Abbrev Number: 47 (DW_TAG_variant_part) <1430> DW_AT_discr : <0x1434> <5><1434>: Abbrev Number: 48 (DW_TAG_member) <1435> DW_AT_type : <0x2cba> <1439> DW_AT_alignment : 4 <143a> DW_AT_data_member_location: 0 <143b> DW_AT_artificial : 1 <5><143b>: Abbrev Number: 52 (DW_TAG_variant) <143c> DW_AT_discr_value : 0x80000000 <6><1440>: Abbrev Number: 4 (DW_TAG_member) <1441> DW_AT_name : None <1445> DW_AT_type : <0x145a> <1449> DW_AT_alignment : 4 <144a> DW_AT_data_member_location: 0 <6><144b>: Abbrev Number: 0 <5><144c>: Abbrev Number: 51 (DW_TAG_variant) <6><144d>: Abbrev Number: 4 (DW_TAG_member) <144e> DW_AT_name : Some <1452> DW_AT_type : <0x146c> <1456> DW_AT_alignment : 4 <1457> DW_AT_data_member_location: 0 <6><1458>: Abbrev Number: 0 <5><1459>: Abbrev Number: 0 ... but the dynamic type resolves to the "Some" variant instead. This is caused by signedness confusion. The DW_AT_discr_value 0x80000000 is encoded as an LEB128 number, and the signedness is determined by the "tag type for the variant part", which in this case is unsigned: ... <1><2cba>: Abbrev Number: 6 (DW_TAG_base_type) <2cbb> DW_AT_name : u32 <2cbf> DW_AT_encoding : 7 (unsigned) <2cc0> DW_AT_byte_size : 4 ... However, the value gets interpreted as signed instead (value printed in resolve_dynamic_struct): ... (gdb) p /x variant_prop.m_data.variant_parts.m_array.variants.m_array[0].discriminants.m_array[0] $3 = {low = 0xffffffff80000000, high = 0xffffffff80000000} ... and then compared against an unsigned 0x80000000 in variant::matches(). Fix this in create_one_variant_part, by passing the required signedness as a parameter to create_one_variant. Tested on i686-linux and x86_64-linux. Approved-By: Tom Tromey <[email protected]> PR rust/33620 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33620 --- gdb/dwarf2/read.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 19a46425f84..f8f411c195a 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -12126,14 +12126,16 @@ static const gdb::array_view<variant_part> create_variant_parts the variant to fill in. OBSTACK is where any needed allocations will be done. OFFSET_MAP holds the mapping from section offsets to fields for the type. FI describes the fields of the type we're - processing. FIELD is the variant field we're converting. */ + processing. FIELD is the variant field we're converting. IS_UNSIGNED + contains the signedness of the discriminant. */ static void create_one_variant (variant &result, struct obstack *obstack, const offset_map_type &offset_map, - struct field_info *fi, const variant_field &field) + struct field_info *fi, const variant_field &field, + bool is_unsigned) { - result.discriminants = convert_variant_range (obstack, field, false); + result.discriminants = convert_variant_range (obstack, field, is_unsigned); result.first_field = field.first_field + fi->baseclasses.size (); result.last_field = field.last_field + fi->baseclasses.size (); result.parts = create_variant_parts (obstack, offset_map, fi, @@ -12172,7 +12174,7 @@ create_one_variant_part (variant_part &result, variant *output = new (obstack) variant[n]; for (size_t i = 0; i < n; ++i) create_one_variant (output[i], obstack, offset_map, fi, - builder.variants[i]); + builder.variants[i], result.is_unsigned); result.variants = gdb::array_view<variant> (output, n); } -- 2.51.0 ++++++ gdb-testsuite-fix-build-id-check-in-gdb.python-py-mi.patch ++++++ >From b29fe2547e14caabc04ff35f0dc3b2ed9043bbd0 Mon Sep 17 00:00:00 2001 From: Tom de Vries <[email protected]> Date: Thu, 20 Nov 2025 21:54:47 +0100 Subject: [PATCH 07/25] [gdb/testsuite] Fix build-id check in gdb.python/py-missing-objfile.exp I recently added two requires in test-case gdb.python/py-missing-objfile.exp: ... require {expect_build_id_in_core_file $binfile} require {expect_build_id_in_core_file $libfile} ... However, at the point where the check is done, the files are no longer available at that location, which makes the require fail. First, make the problem visible, by making proc expect_build_id_in_core_file throw an error if the filename argument specifies a non-existing file. Then, fix test-case gdb.python/py-missing-objfile.exp by moving the calls to expect_build_id_in_core_file to a point where the files exist. Tested on x86_64-linux. --- gdb/testsuite/gdb.python/py-missing-objfile.exp | 9 +++++++-- gdb/testsuite/lib/gdb.exp | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.python/py-missing-objfile.exp b/gdb/testsuite/gdb.python/py-missing-objfile.exp index 2786bdfb2ed..9ecf53a7024 100644 --- a/gdb/testsuite/gdb.python/py-missing-objfile.exp +++ b/gdb/testsuite/gdb.python/py-missing-objfile.exp @@ -34,6 +34,11 @@ if { [build_executable "build exec" $binfile $srcfile $opts] == -1} { return } +set expect_build_id_in_core_file_binfile \ + [expect_build_id_in_core_file $binfile] +set expect_build_id_in_core_file_libfile \ + [expect_build_id_in_core_file $libfile] + # The cc-with-gnu-debuglink board will split the debug out into the # .debug directory. This test script relies on having GDB lookup the # objfile and debug via the build-id, which this test sets up. Trying @@ -185,8 +190,8 @@ with_test_prefix "no objfiles available" { # The following tests assume that the build-ids of binfile and libfile can be # found in the core file. -require {expect_build_id_in_core_file $binfile} -require {expect_build_id_in_core_file $libfile} +require {expr $expect_build_id_in_core_file_binfile} +require {expr $expect_build_id_in_core_file_libfile} with_test_prefix "all objfiles available" { # Another sanity check that GDB can find the files via the diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 47cff389a41..ac1de76a696 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -11057,6 +11057,10 @@ gdb_caching_proc root_user {} { # Otherwise, return false. proc expect_build_id_in_core_file { filename } { + if {![file exists $filename]} { + error "File not found: $filename" + } + # I'm not sure if other kernels take care to add the first page of # each ELF into the core file. If they do then this test can be # relaxed. -- 2.51.0 ++++++ gdb-testsuite-fix-gdb.mi-mi-sym-info.exp.patch ++++++ >From 58257123680969c03a46d7e877e6a7143bd134c5 Mon Sep 17 00:00:00 2001 From: Tom de Vries <[email protected]> Date: Tue, 25 Nov 2025 09:27:01 +0100 Subject: [PATCH 25/25] [gdb/testsuite] Fix gdb.mi/mi-sym-info.exp This is the testsuite part of commit 13ab441fb40 ("gdb/dwarf: create multiple cooked index shards when reading .debug_names"). This fixes FAILs on i686-linux. --- gdb/testsuite/gdb.mi/mi-sym-info.exp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/gdb.mi/mi-sym-info.exp b/gdb/testsuite/gdb.mi/mi-sym-info.exp index b8db2af0d0b..47ca515956a 100644 --- a/gdb/testsuite/gdb.mi/mi-sym-info.exp +++ b/gdb/testsuite/gdb.mi/mi-sym-info.exp @@ -245,22 +245,34 @@ mi_gdb_test "120-symbol-info-types --name _int_" \ "120\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile\",fullname=\"\[^\"\]+$srcfile\",symbols=\\\[$my_int_re\\\]\},\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[$another_int_re\\\]\}\\\]\}" \ "List all types matching _int_" +# Return the number of matched symbols in the last match. + +proc count_symbol_matches { } { + # `0,string`, `1,string` and `2,string` respectively contain the + # command + result, command and result. The symbols match is at + # `3,string`. + return [regexp -all $::fun_re $::expect_out(3,string)] +} + # Test the --max-results parameter. mi_gdb_test "121-symbol-info-functions --max-results 0" \ "121\\^done,symbols=\{\}" \ "-symbol-info-functions --max-results 0" mi_gdb_test "122-symbol-info-functions --max-results 1 --name ^\[^_\]" \ - "122\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[(?:$f2_re|$f3_re)\\\]\}\\\]\}" \ + "122\\^done,($debug_only_syms)" \ "-symbol-info-functions --max-results 1" +gdb_assert {[count_symbol_matches] == 1} "-symbol-info-functions --max-results 1, result count" mi_gdb_test "123-symbol-info-functions --max-results 2 --name ^\[^_\]" \ - "123\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[$f2_re,$f3_re\\\]\}\\\]\}" \ + "123\\^done,($debug_only_syms)" \ "-symbol-info-functions --max-results 2" +gdb_assert {[count_symbol_matches] == 2} "-symbol-info-functions --max-results 2, result count" mi_gdb_test "124-symbol-info-variables --max-results 3 --name ^\[^_\]" \ - "124\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[$global_f2_re,$global_i2_re,(?:$global_i1_re|$global_f1_s2_re)\\\]\}\\\]\}" \ - "-symbol-info-types --max-results 3" + "124\\^done,($debug_only_syms)" \ + "-symbol-info-variables --max-results 3" +gdb_assert {[count_symbol_matches] == 3} "-symbol-info-variables --max-results 3, result count" mi_gdb_test "125-symbol-info-types --max-results 4 --name another_" \ "125\\^done,symbols=\{debug=\\\[\{filename=\"\[^\"\]*$srcfile2\",fullname=\"\[^\"\]+$srcfile2\",symbols=\\\[$another_char_re,$another_float_re,$another_int_re,$another_short_re\\\]\}\\\]\}" \ -- 2.51.0 ++++++ gdb-testsuite-fix-gdb.rust-methods.exp-on-i686-linux.patch ++++++ >From 48a16bfbf7967663621f7e9ae3f05841ae64eb37 Mon Sep 17 00:00:00 2001 From: Tom de Vries <[email protected]> Date: Fri, 14 Nov 2025 11:43:44 +0100 Subject: [PATCH 11/25] [gdb/testsuite] Fix gdb.rust/methods.exp on i686-linux On i686-linux, with test-case gdb.rust/methods.exp I get: ... (gdb) print x.take() $5 = methods::HasMethods {value: 4} (gdb) FAIL: $exp: print x.take() ... The instructions for the function methods::HasMethods::take look like this: ... 00007b90 <_ZN7methods10HasMethods4take17hf373500ea3bd6e27E>: 7b90: 8b 44 24 04 mov 0x4(%esp),%eax 7b94: c3 ret ... which is equivalent to what you get for: ... $ cat test.c int foo (int val) { return val; } $ gcc test.c -O2 -S -o- ... movl 4(%esp), %eax ret ... $ ... The inferior call mechanism however decides that this is a return_method_struct function, and adds an implicit first parameter pointing to the return value location. Then two things go wrong: - the argument is written to a place where the code doesn't read from, and - the return value is read from a place where the code doesn't write to. AFAIU, both gdb and rustc are behaving correctly: - there's no stable ABI and consequently rustc is at liberty to optimize this function how it wants, and - gdb cannot be expected to target an unstable ABI. The solution is to mark the function for interoperability using 'extern "C"'. Doing so causes a compilation warning: ... warning: `extern` fn uses type `HasMethods`, which is not FFI-safe --> gdb.rust/methods.rs:50:28 | 50 | pub extern "C" fn take(self) -> HasMethods { | ^^^^ not FFI-safe | = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct = note: this struct has unspecified layout ... which we fix by using '#[repr(C)]'. Likewise in gdb.rust/generics.exp. Tested on i686-linux and x86_64-linux. Approved-By: Tom Tromey <[email protected]> --- gdb/testsuite/gdb.rust/generics.rs | 5 ++++- gdb/testsuite/gdb.rust/methods.rs | 12 +++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.rust/generics.rs b/gdb/testsuite/gdb.rust/generics.rs index da269991781..ad6a10944dd 100644 --- a/gdb/testsuite/gdb.rust/generics.rs +++ b/gdb/testsuite/gdb.rust/generics.rs @@ -17,11 +17,14 @@ #![allow(unused_variables)] #![allow(unused_assignments)] +// Use repr(C) and extern "C" to force the compiler to present a +// C-like interface, facilitating inferior calls. +#[repr(C)] #[derive(Clone, Copy)] struct Hold<T>(T); -pub fn identity<T>(x: T) -> T { x } +pub extern "C" fn identity<T>(x: T) -> T { x } fn dowhatever() { () } diff --git a/gdb/testsuite/gdb.rust/methods.rs b/gdb/testsuite/gdb.rust/methods.rs index eaeb5ef41e8..bb77d9873dc 100644 --- a/gdb/testsuite/gdb.rust/methods.rs +++ b/gdb/testsuite/gdb.rust/methods.rs @@ -33,6 +33,16 @@ impl Whatever for i32 { } } +// On i686-linux, for hasMethods::take the rust compiler generates code +// similar to what a c compiler generates for: +// int foo (int val) { return val; } +// but gdb calls it as if it were: +// void foo (int *res, int *val) { *res = *val; } +// By default, the rust compiler is free to optimize functions and data +// layout, so use repr(C) and extern "C" to force the compiler to present a +// C-like interface. + +#[repr(C)] pub struct HasMethods { value: i32 } @@ -47,7 +57,7 @@ impl HasMethods { self } - pub fn take(self) -> HasMethods { + pub extern "C" fn take(self) -> HasMethods { self } } -- 2.51.0 ++++++ gdb-testsuite-fix-main-in-gdb.trace-mi-trace-frame-c.patch ++++++ >From 016b0fdd8f4bd7bebb08bb034b0461722c2229ad Mon Sep 17 00:00:00 2001 From: Tom de Vries <[email protected]> Date: Sun, 9 Nov 2025 09:18:43 +0100 Subject: [PATCH 19/25] [gdb/testsuite] Fix main in gdb.trace/mi-trace-frame-collected.exp With test-case gdb.trace/mi-trace-frame-collected.exp I run into: ... gdb compile failed, gdb.trace/actions.c: In function 'main': gdb.trace/actions.c:139:1: warning: old-style function definition \ [-Wold-style-definition] 139 | main (argc, argv, envp) | ^~~~ ... Fix this by rewriting main into a prototyped function. Tested on x86_64-linux. PR testsuite/32756 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32756 --- gdb/testsuite/gdb.trace/actions.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gdb/testsuite/gdb.trace/actions.c b/gdb/testsuite/gdb.trace/actions.c index 56906b680fc..bd0b546bb00 100644 --- a/gdb/testsuite/gdb.trace/actions.c +++ b/gdb/testsuite/gdb.trace/actions.c @@ -136,9 +136,7 @@ static void end () /* called after everything else */ } int -main (argc, argv, envp) - int argc; - char *argv[], **envp; +main (int argc, char *argv[], char **envp) { int i; unsigned long myparms[10]; -- 2.51.0 ++++++ gdb-testsuite-fix-possible-tcl-errors-in-gdb.threads.patch ++++++ >From 4596ae47782b249e4989e136632037b1cef0fcb5 Mon Sep 17 00:00:00 2001 From: Guinevere Larsen <[email protected]> Date: Mon, 1 Sep 2025 11:48:30 -0300 Subject: [PATCH 22/25] gdb/testsuite: fix possible TCL errors in gdb.threads/threadcrash.exp The test gdb.threads/threadcrash.exp, among other things, creates a list of the threads seen in the order that the "thread apply all backtrace" would generate them, tests that this list is the same size as GDB's count of threads, and then loops over the list to check that each thread has the expected backtrace. A problem occurs because the loop iterates on GDB's internal count of threads, rather than the size of the list, but then attempts to acces the n-th element of the list. If the list size is smaller than GDB's internal thread count, it'll access past the end of the list and generate TCL errors. This commit fixes this by using the list's length instead. Approved-By: Tom Tromey <[email protected]> --- gdb/testsuite/gdb.threads/threadcrash.exp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.threads/threadcrash.exp b/gdb/testsuite/gdb.threads/threadcrash.exp index 6da70736983..9da3bda2a3c 100644 --- a/gdb/testsuite/gdb.threads/threadcrash.exp +++ b/gdb/testsuite/gdb.threads/threadcrash.exp @@ -132,8 +132,9 @@ proc do_full_test {} { set pthread_kill ".*" } - for {set i 0} {$i < $thread_count } {incr i} { - set thread_num [expr [llength $test_list] - $i] + set loop_iterations [llength $test_list] + for {set i 0} {$i < $loop_iterations } {incr i} { + set thread_num [expr $loop_iterations - $i] set type [lindex $test_list $i] if { $type == 1 } { -- 2.51.0 ++++++ gdb-testsuite-fix-sizeof-test-in-gdb.rust-simple.exp.patch ++++++ >From 71e7e116b5a76314a4db6d272de3169e1d77696e Mon Sep 17 00:00:00 2001 From: Tom de Vries <[email protected]> Date: Tue, 11 Nov 2025 20:47:33 +0100 Subject: [PATCH 12/25] [gdb/testsuite] Fix sizeof test in gdb.rust/simple.exp On x86_64-linux, with test-case gdb.rust/simple.exp I get: ... (gdb) print sizeof(e)^M $52 = 24^M (gdb) PASS: $exp: print sizeof(e) ... but on i686-linux I get instead: ... (gdb) print sizeof(e)^M $52 = 20^M (gdb) FAIL: $exp: print sizeof(e) ... The variable e for which we print the size: ... let e = MoreComplicated::Two(73); ... has type MoreComplicated which is defined like this: ... pub struct HiBob { pub field1: i32, field2: u64, } ... enum MoreComplicated { One, Two(i32), Three(HiBob), Four{this: bool, is: u8, a: char, struct_: u64, variant: u32}, } ... The answer to the question what the size of the enum should be seems to be non-trivial [1][2], but AFAICT it doesn't seem to be illegal that the size can differ between different platforms. Fix this by accepting both 20 and 24 as valid size. Tested on x86_64-linux and i686-linux. Approved-By: Tom Tromey <[email protected]> [1] https://doc.rust-lang.org/reference/types/enum.html [2] https://doc.rust-lang.org/reference/type-layout.html#the-rust-representation --- gdb/testsuite/gdb.rust/simple.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp index 37a2e079b6c..dc057bfd7c5 100644 --- a/gdb/testsuite/gdb.rust/simple.exp +++ b/gdb/testsuite/gdb.rust/simple.exp @@ -188,7 +188,7 @@ gdb_test "print simple::HiBob{field1: 99, .. y}" \ gdb_test "print e" " = simple::MoreComplicated::Two\\(73\\)" gdb_test "print e2" \ " = simple::MoreComplicated::Four\\{this: true, is: 8, a: 109 'm', struct_: 100, variant: 10\\}" -gdb_test "print sizeof(e)" " = 24" +gdb_test "print sizeof(e)" " = (20|24)" gdb_test_sequence "ptype e" "" { " = enum simple::MoreComplicated \\{" " One," -- 2.51.0 ++++++ gdb-testsuite-fix-xfail-in-gdb.ada-array_of_variant..patch ++++++ >From 00d4ad62ee46f0f217bd8347b05588a108fbc54b Mon Sep 17 00:00:00 2001 From: Tom de Vries <[email protected]> Date: Thu, 3 Apr 2025 17:13:12 +0200 Subject: [PATCH 24/25] [gdb/testsuite] Fix xfail in gdb.ada/array_of_variant.exp In commit af2b87e649b ("[gdb/testsuite] Add xfail for PR gcc/101633"), I added an xfail that was controlled by variable old_gcc, triggering the xfail for gcc 7 and before, but not for gcc 8 onwards: ... set old_gcc [expr [test_compiler_info {gcc-[0-7]-*}]] ... In commit 1411185a57e ("Introduce and use gnat_version_compare"), this changed to: ... set old_gcc [gnat_version_compare <= 7] ... which still triggered the xfail for gcc 7, because of a bug in gnat_version_compare. After that bug got fixed, the xfail was no longer triggered because the gnatmake version is 7.5.0, and [version_compare {7 5 0} <= {7}] == 0. We could have the semantics for version_compare where we clip the input arguments to the length of the shortest, and so we'd have [version_compare {7 5 0} <= {7}] == [version_compare {7} <= {7}] == 1. But let's stick with the current version-sort semantics, and fix this by using [gnat_version_compare < 8] instead. Tested on x86_64-linux. Approved-By: Tom Tromey <[email protected]> --- gdb/testsuite/gdb.ada/array_of_variant.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.ada/array_of_variant.exp b/gdb/testsuite/gdb.ada/array_of_variant.exp index 8b83f4ed22a..83b626cb6d1 100644 --- a/gdb/testsuite/gdb.ada/array_of_variant.exp +++ b/gdb/testsuite/gdb.ada/array_of_variant.exp @@ -20,7 +20,7 @@ require allow_ada_tests standard_ada_testfile p -set old_gcc [gnat_version_compare <= 7] +set old_gcc [gnat_version_compare < 8] proc gdb_test_with_xfail { cmd re re_xfail msg } { global scenario old_gcc -- 2.51.0 ++++++ gdb-testsuite-fix-xfail-in-gdb.ada-variant_record_fi.patch ++++++ >From edaf039af83893fc6c32b812560d4170f94de430 Mon Sep 17 00:00:00 2001 From: Tom de Vries <[email protected]> Date: Tue, 14 Oct 2025 18:00:48 +0200 Subject: [PATCH 13/25] [gdb/testsuite] Fix xfail in gdb.ada/variant_record_field.exp On ppc64-linux (debian 14) I run into: ... (gdb) print p_record^M $1 = (kind => five, i => <error reading variable: \ access outside bounds of object>^M (gdb) gdb_do_cache: get_compiler_info_1 ( c ) get_compiler_info: gcc-15-2-0 gdb_do_cache: get_compiler_info_1 ( c ) FAIL: gdb.ada/variant_record_field.exp: print p_record ... The test-case contains an xfail for "[gcc_major_version] <= 14", which doesn't trigger because gcc has version 15.2.0, while gnatmake does have version 14.3.0: ... $ gcc --version gcc (Debian 15.2.0-4) 15.2.0 ... $ gnatmake --version GNATMAKE 14.3.0 ... Fix this by using "[gnat_version_compare < 15]" instead. Tested on ppc64-linux and x86_64-linux. Approved-By: Tom Tromey <[email protected]> --- gdb/testsuite/gdb.ada/variant_record_field.exp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/testsuite/gdb.ada/variant_record_field.exp b/gdb/testsuite/gdb.ada/variant_record_field.exp index f3baa25f020..101f91f416f 100644 --- a/gdb/testsuite/gdb.ada/variant_record_field.exp +++ b/gdb/testsuite/gdb.ada/variant_record_field.exp @@ -42,7 +42,7 @@ gdb_test_multiple "$test" "$test" { pass $test } -re "\\(kind => five, i => <error reading variable: access outside bounds of object>" { - if { [gcc_major_version] <= 14 } { + if { [gnat_version_compare < 15] } { setup_xfail *-*-* } fail $test -- 2.51.0 ++++++ gdb-testsuite-force-dwarf-in-gdb.pascal.patch ++++++ >From 4361e02cc1aaf367e09f66a03ab9f5621a59486b Mon Sep 17 00:00:00 2001 From: Tom de Vries <[email protected]> Date: Mon, 10 Nov 2025 19:36:46 +0100 Subject: [PATCH 18/25] [gdb/testsuite] Force DWARF in gdb.pascal On i686-linux (and likewise arm-linux), I run into: ... (gdb) file str-chars^M Reading symbols from str-chars...^M warning: stabs debug information is not supported.^M (No debugging symbols found in str-chars)^M (gdb) delete breakpoints^M ... Fix this by using fpc option -gw2. Tested on i686-linux. Approved-By: Simon Marchi <[email protected]> PR testsuite/33564 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33564 --- gdb/testsuite/lib/pascal.exp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/lib/pascal.exp b/gdb/testsuite/lib/pascal.exp index 236eca17dcb..31a8ae64d73 100644 --- a/gdb/testsuite/lib/pascal.exp +++ b/gdb/testsuite/lib/pascal.exp @@ -128,7 +128,9 @@ proc fpc_compile {source destfile type options} { if [board_info $dest exists debug_flags] { append add_flags " [board_info $dest debug_flags]" } else { - append add_flags " -g" + # GDB no longer supports STABS, so force DWARF debug info. + # Use v2 assuming support is more mature than later versions. + append add_flags " -g -gw2" } } if { $i == "class" } { -- 2.51.0 ++++++ gdb-testsuite-rust-fix-for-empty-array.patch ++++++ >From 772b7c2a75f392589518a0ee17a48914f1395c67 Mon Sep 17 00:00:00 2001 From: "Rudnicki, Piotr" <[email protected]> Date: Wed, 12 Feb 2025 10:50:37 +0100 Subject: [PATCH 03/25] gdb, testsuite, rust: fix for empty array For the Rust language, to avoid segmentation fault in case of an empty array, do not try to copy any elements, but allocate and return the empty array immediately. With the command before the change, gdb crashes with message: (gdb) set lang rust (gdb) p [1;0] Fatal signal: Segmentation fault After the fix in this commit, gdb shows following message: (gdb) set lang rust (gdb) p [1;0] $1 = [] Update the existing test case gdb.rust/expr.exp to verify the change. Approved-By: Tom Tromey <[email protected]> --- gdb/rust-lang.c | 2 +- gdb/testsuite/gdb.rust/expr.exp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index d4cd8802fa5..8bec934983e 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -1455,7 +1455,7 @@ eval_op_rust_array (struct type *expect_type, struct expression *exp, if (copies < 0) error (_("Array with negative number of elements")); - if (noside == EVAL_NORMAL) + if (noside == EVAL_NORMAL && copies > 0) return value_array (0, std::vector<value *> (copies, elt)); else { diff --git a/gdb/testsuite/gdb.rust/expr.exp b/gdb/testsuite/gdb.rust/expr.exp index 97db748abf6..ca01c5feb36 100644 --- a/gdb/testsuite/gdb.rust/expr.exp +++ b/gdb/testsuite/gdb.rust/expr.exp @@ -115,6 +115,10 @@ gdb_test "print \[1,2 3" "',' or ']' expected" gdb_test "print \[1 2" "',', ';', or ']' expected" gdb_test "print \[23\]" " = \\\[23\\\]" +gdb_test "print \[0;0\]" " = \\\[\\\]" +gdb_test "print \[1;0\]" " = \\\[\\\]" +gdb_test "print \[0;1\]" " = \\\[0\\\]" + gdb_test "print b\"hi rust\"" " = b\"hi rust\"" # This isn't rusty syntax yet, but that's another bug -- this is just # testing that byte escapes work properly. -- 2.51.0 ++++++ gdb-testsuite-use-expect_build_id_in_core_file-a-bit.patch ++++++ >From 26fdff8f7404ee0f9ae957fd5640d43eb6d86820 Mon Sep 17 00:00:00 2001 From: Tom de Vries <[email protected]> Date: Mon, 13 Oct 2025 20:54:43 +0200 Subject: [PATCH 04/25] [gdb/testsuite] Use expect_build_id_in_core_file a bit more Recent commit c1950dcc04c ("gdb/testsuite: fix failure from gdb.python/py-corefile.exp") introduced proc expect_build_id_in_core_file, which detects the problem that: ... ... some versions of the linker didn't place the build-id within the first page of an ELF. As a result, the Linux kernel would not include the build-id in the generated core file, ... ... Use this proc in a few more test-cases, to deal with the same problem. Tested on x86_64-linux, openSUSE Tumbleweed with ld 2.43.1. Approved-By: Andrew Burgess <[email protected]> PR testsuite/33528 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33528 --- .../gdb.debuginfod/corefile-mapped-file.exp | 3 + .../gdb.debuginfod/solib-with-soname.exp | 4 ++ .../gdb.python/py-missing-objfile.exp | 5 ++ gdb/testsuite/lib/gdb.exp | 58 +++++++++++++++++++ 4 files changed, 70 insertions(+) diff --git a/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp b/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp index f02876e1453..af143b7d506 100644 --- a/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp +++ b/gdb/testsuite/gdb.debuginfod/corefile-mapped-file.exp @@ -81,6 +81,9 @@ if {[prepare_for_testing_full "build exec which loads the shared library" \ return } +require {expect_build_id_in_core_file $binfile2} +require {expect_build_id_in_core_file $library_filename} + if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.debuginfod/solib-with-soname.exp b/gdb/testsuite/gdb.debuginfod/solib-with-soname.exp index 98c4535fca7..07f0a0f170b 100644 --- a/gdb/testsuite/gdb.debuginfod/solib-with-soname.exp +++ b/gdb/testsuite/gdb.debuginfod/solib-with-soname.exp @@ -96,6 +96,10 @@ if { [build_executable "build executable" ${binfile} ${srcfile2} \ return } +require {expect_build_id_in_core_file $library_1_filename} +require {expect_build_id_in_core_file $library_2_filename} +require {expect_build_id_in_core_file $binfile} + # If the board file is automatically splitting the debug information # into a separate file (e.g. the cc-with-gnu-debuglink.exp board) then # this test isn't going to work. diff --git a/gdb/testsuite/gdb.python/py-missing-objfile.exp b/gdb/testsuite/gdb.python/py-missing-objfile.exp index 8488047d105..2786bdfb2ed 100644 --- a/gdb/testsuite/gdb.python/py-missing-objfile.exp +++ b/gdb/testsuite/gdb.python/py-missing-objfile.exp @@ -183,6 +183,11 @@ with_test_prefix "no objfiles available" { check_loaded_debug false false } +# The following tests assume that the build-ids of binfile and libfile can be +# found in the core file. +require {expect_build_id_in_core_file $binfile} +require {expect_build_id_in_core_file $libfile} + with_test_prefix "all objfiles available" { # Another sanity check that GDB can find the files via the # debug-file-directory. diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index b103c117258..47cff389a41 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -11044,5 +11044,63 @@ gdb_caching_proc root_user {} { return [expr $uid == 0] } +# Return true if we expect the build-id from FILENAME to be included +# in a core file. +# +# On GNU/Linux, when creating a core file, the kernel places the first +# page of an ELF into the core file. If the build-id is within that +# page then GDB can find the build-id from the core file. +# +# This proc checks that the target is GNU/Linux, and then uses readelf +# to find the offset of the build-id within the ELF. If there is a +# build-id, and it is within the first page, then return true. +# Otherwise, return false. + +proc expect_build_id_in_core_file { filename } { + # I'm not sure if other kernels take care to add the first page of + # each ELF into the core file. If they do then this test can be + # relaxed. + if {![istarget *-*-linux*]} { + return false + } + + # Use readelf to find the build-id note in FILENAME. + set readelf_program [gdb_find_readelf] + set cmd [list $readelf_program -WS $filename | grep ".note.gnu.build-id"] + set res [catch {exec {*}$cmd} output] + verbose -log "running: $cmd" + verbose -log "result: $res" + verbose -log "output: $output" + if { $res != 0 } { + return false + } + + # Extract the OFFSET from the readelf output. + set res [regexp {NOTE[ \t]+([0-9a-f]+)[ \t]+([0-9a-f]+)} \ + $output dummy addr offset] + if { $res != 1 } { + return false + } + + # Convert OFFSET to decimal. + set offset [expr {[subst 0x$offset]}] + + # Now figure out the page size. This should be fine for Linux + # hosts, see the istarget check above. + if {[catch {exec getconf PAGESIZE} page_size]} { + # Failed to fetch page size. + return false + } + + # If the build-id is within the first page, then we expect the + # kernel to include it in the core file. There is actually a + # kernel setting (see coredump_filter) that could prevent this, + # but the default behaviour is to include the first page of the + # ELF, so for now, we just assume this is on. + verbose -log "Page size is $page_size, Offset is $offset" + return [expr {$offset < $page_size}] +} + + # Always load compatibility stuff. load_lib future.exp -- 2.51.0 ++++++ gdb-testsuite-use-std-c99-in-gdb.base-callfuncs.exp.patch ++++++ >From 24f5907ddb7fd5157ce3cc938bb5b5bcdeb54460 Mon Sep 17 00:00:00 2001 From: Tom de Vries <[email protected]> Date: Sun, 9 Nov 2025 08:07:57 +0100 Subject: [PATCH 05/25] [gdb/testsuite] Use -std=c99 in gdb.base/callfuncs.exp In test-case gdb.base/callfuncs.exp I run into: ... gdb compile failed, gdb.base/callfuncs.c: In function 't_func_values': gdb.base/callfuncs.c:611:12: error: too many arguments to function \ 'func_arg1'; expected 0, have 2 611 | return ((*func_arg1) (5,5) == (*func_val1) (5,5) | ~^~~~~~~~~~~ ~ ... Fix this by using -std=c99. Tested on x86_64-linux. Approved-By: Tom Tromey <[email protected]> PR testsuite/32756 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32756 --- gdb/testsuite/gdb.base/callfuncs.exp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp index 494b6dfa96f..ed979603a26 100644 --- a/gdb/testsuite/gdb.base/callfuncs.exp +++ b/gdb/testsuite/gdb.base/callfuncs.exp @@ -18,10 +18,20 @@ standard_testfile +set compile_flags {} +lappend compile_flags debug + # We still want to test non-prototype functions for now, which is why # we disable compilers warning about them. -set compile_flags {debug additional_flags=-Wno-deprecated-non-prototype} -if [support_complex_tests] { +lappend compile_flags additional_flags=-Wno-deprecated-non-prototype + +if {[have_compile_flag -std=c99]} { + # Gcc 15 defaults to c23, which no longer supports unprototyped functions. + # Use a c dialect that does support this. + lappend compile_flags additional_flags=-std=c99 +} + +if {[support_complex_tests]} { lappend compile_flags "additional_flags=-DTEST_COMPLEX" } -- 2.51.0 ++++++ gdb-testsuite-use-std-c99-in-gdb.base-nodebug.exp.patch ++++++ >From 7ff7fb4184861f31c624aafab433462ecafb4321 Mon Sep 17 00:00:00 2001 From: Tom de Vries <[email protected]> Date: Wed, 12 Nov 2025 11:08:31 +0100 Subject: [PATCH 06/25] [gdb/testsuite] Use -std=c99 in gdb.base/nodebug.exp With test-case gdb.base/nodebug.exp I run into: ... gdb compile failed, gdb.base/nodebug.c: In function 'multf_noproto': gdb.base/nodebug.c:63:1: warning: old-style function definition \ [-Wold-style-definition] 63 | multf_noproto (v1, v2) | ^~~~~~~~~~~~~ ... Fix this using -std=c99. Tested on x86_64-linux. PR testsuite/32756 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32756 --- gdb/testsuite/gdb.base/nodebug.exp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gdb/testsuite/gdb.base/nodebug.exp b/gdb/testsuite/gdb.base/nodebug.exp index 4c07d2ea9db..999c4217aa8 100644 --- a/gdb/testsuite/gdb.base/nodebug.exp +++ b/gdb/testsuite/gdb.base/nodebug.exp @@ -18,12 +18,17 @@ standard_testfile .c -if [test_compiler_info "xlc-*"] { +set exec_opts {} +if {[have_compile_flag -std=c99]} { + # Gcc 15 defaults to c23, which no longer supports unprototyped functions. + # Use a c dialect that does support this. + lappend exec_opts additional_flags=-std=c99 +} + +if {[test_compiler_info "xlc-*"]} { # By default, IBM'x xlc compiler doesn't add static variables into the symtab. - # Use "-qstatsym" to do so. - set exec_opts additional_flags=-qstatsym -} else { - set exec_opts "" + # Use "-qstatsym" to do so. + lappend exec_opts additional_flags=-qstatsym } if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "" } { -- 2.51.0 ++++++ gdb-testsuite-yet-another-attempt-to-fix-gdb.threads.patch ++++++ >From 6256bcf098ccf5737dbb8e379d2c0251647aec43 Mon Sep 17 00:00:00 2001 From: Tom de Vries <[email protected]> Date: Wed, 22 Oct 2025 08:46:06 +0200 Subject: [PATCH] [gdb/testsuite] Yet another attempt to fix gdb.threads/thread-specific-bp.exp When running test-case gdb.threads/thread-specific-bp.exp using taskset to select an Efficient-core in a loop, it fails 19 out of 100 runs. For example, like this: ... (gdb) continue -a^M Continuing.^M ^M Thread 1 "thread-specific" hit Breakpoint 4, end () at thread-specific-bp.c:29^M 29 }^M (gdb) FAIL: $exp: non_stop=on: continue to end [Thread 0x7ffff7cbe6c0 (LWP 2348848) exited]^M Thread-specific breakpoint 3 deleted - thread 2 no longer in the thread list.^M ... The way we're trying to match this gdb output is: ... gdb_test_multiple "$cmd" "continue to end" { -re "$\r\n${gdb_prompt} .*${msg_re}\r\n" { pass $gdb_test_name } -re "\r\n${msg_re}\r\n.*$gdb_prompt " { pass $gdb_test_name } } ... The problem is that the two -re clauses above do not match the output ending in a prompt, so the default fail in gdb_test_multiple triggers. Fix this by splitting this up in two gdb_test_multiple calls: - the first matches a prompt (with or without preceding $msg_re), making sure that the default fail doesn't trigger, and - the second matches $msg_re, if that was not already matched by the first call. Using this approach, the test-case passes 100 out of 100 runs. Tested on x86_64-linux, also with make-check-all.sh. PR testsuite/32688 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32688 --- .../gdb.threads/thread-specific-bp.exp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/gdb.threads/thread-specific-bp.exp b/gdb/testsuite/gdb.threads/thread-specific-bp.exp index e7641d2c9b4..dc7a8fbfa76 100644 --- a/gdb/testsuite/gdb.threads/thread-specific-bp.exp +++ b/gdb/testsuite/gdb.threads/thread-specific-bp.exp @@ -95,12 +95,21 @@ proc check_thread_specific_breakpoint {non_stop} { "-" \ "thread 2 no longer in the thread list\\."]] - gdb_test_multiple "$cmd" "continue to end" { - -re "$\r\n${gdb_prompt} .*${msg_re}\r\n" { + set test "continue to end" + set try_again 0 + gdb_test_multiple $cmd $test -no-prompt-anchor { + -re -wrap "\r\n${msg_re}(?=\r\n).*" { pass $gdb_test_name } - -re "\r\n${msg_re}\r\n.*$gdb_prompt " { - pass $gdb_test_name + -re -wrap "" { + set try_again 1 + } + } + if { $try_again } { + gdb_test_multiple "" $test { + -re "\r\n${msg_re}(?=\r\n)" { + pass $gdb_test_name + } } } base-commit: 77f7bf5700b2b9be1172c7b5d05d03ee025c5d2c -- 2.51.0 ++++++ have-gdb.threadexitedevent-inherit-from-gdb.threadev.patch ++++++ >From 5e756961d8907915bd46e3a97078851169a9fdc7 Mon Sep 17 00:00:00 2001 From: Tom Tromey <[email protected]> Date: Wed, 17 Sep 2025 08:49:27 -0600 Subject: [PATCH 10/25] Have gdb.ThreadExitedEvent inherit from gdb.ThreadEvent The documentation says that ThreadExitedEvent is derived from ThreadEvent, but the code does not actually implement this. This patch fixes the problem. I propose applying this to gdb 17 as well. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33444 Approved-By: Simon Marchi <[email protected]> (cherry picked from commit 3a9f5df6ea8adcae7769f271cccbc2da8553c08d) --- gdb/python/py-event-types.def | 2 +- gdb/testsuite/gdb.python/py-thread-exited.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gdb/python/py-event-types.def b/gdb/python/py-event-types.def index e22f042bd6b..bef5fe2eb00 100644 --- a/gdb/python/py-event-types.def +++ b/gdb/python/py-event-types.def @@ -54,7 +54,7 @@ GDB_PY_DEFINE_EVENT_TYPE (new_thread, GDB_PY_DEFINE_EVENT_TYPE (thread_exited, "ThreadExitedEvent", "GDB thread exited event object", - event_object_type); + thread_event_object_type); GDB_PY_DEFINE_EVENT_TYPE (new_inferior, "NewInferiorEvent", diff --git a/gdb/testsuite/gdb.python/py-thread-exited.py b/gdb/testsuite/gdb.python/py-thread-exited.py index f813271bc3c..953e7cb8c70 100644 --- a/gdb/testsuite/gdb.python/py-thread-exited.py +++ b/gdb/testsuite/gdb.python/py-thread-exited.py @@ -26,6 +26,8 @@ def thread_exited_handler(event): global threadOneExit, threadTwoExit, mainThreadExit print("{}".format(event)) assert isinstance(event, gdb.ThreadExitedEvent) + # Also check the inheritance. + assert isinstance(event, gdb.ThreadEvent) if threadOneExit == "": threadOneExit = "event type: thread-exited. global num: {}".format( event.inferior_thread.global_num -- 2.51.0 ++++++ import-patches.sh ++++++ --- /var/tmp/diff_new_pack.AfS8SK/_old 2025-11-28 16:50:47.024857596 +0100 +++ /var/tmp/diff_new_pack.AfS8SK/_new 2025-11-28 16:50:47.032857932 +0100 @@ -99,7 +99,7 @@ for f in $files; do mv tmp.patches/"$f" . - osc add "$f" + git add "$f" done rmdir tmp.patches ++++++ mark-pascal-as-case-insensitive.patch ++++++ >From f580f6862fb9c408f73c815b1d431911deb81cf3 Mon Sep 17 00:00:00 2001 From: Tom Tromey <[email protected]> Date: Thu, 13 Nov 2025 09:26:58 -0700 Subject: [PATCH 20/25] Mark Pascal as case-insensitive The Pascal language is not case-sensitive, so implement the appropriate language method. This fixes gdb.pascal failures with -gw3. I wasn't sure if -gw3 should be the default so I've left it as-is. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33617 Approved-By: Tom de Vries <[email protected]> --- gdb/p-lang.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gdb/p-lang.h b/gdb/p-lang.h index abb981aeaed..bcac81d8cac 100644 --- a/gdb/p-lang.h +++ b/gdb/p-lang.h @@ -154,6 +154,9 @@ class pascal_language : public language_defn bool range_checking_on_by_default () const override { return true; } + enum case_sensitivity case_sensitivity () const override + { return case_sensitive_off; } + private: /* Print the character C on STREAM as part of the contents of a literal -- 2.51.0 ++++++ powerpc-mark-rtti-typeid-tests-as-expected-fail-befo.patch ++++++ >From 9504544659b7215bce811876c1a4e4491b3d70df Mon Sep 17 00:00:00 2001 From: Abhay Kandpal <[email protected]> Date: Mon, 24 Nov 2025 04:49:44 -0600 Subject: [PATCH 23/25] PowerPC: Mark RTTI typeid tests as expected fail before inferior start On PowerPC targets, the RTTI typeinfo objects for base types may not be emitted until the inferior has been started. As a result, the `gdb.cp/typeid.exp` test fails when checking typeid results before program execution begins. This patch marks these specific cases as expected failures on PowerPC when the inferior has not yet started, aligning the behavior with other targets (such as Clang) where RTTI emission is deferred until runtime. gdb/testsuite/ * gdb.cp/typeid.exp (do_typeid_tests): Mark PowerPC pre-start RTTI typeinfo checks as expected failures for `i`, `cp`, and `ccp`. --- gdb/testsuite/gdb.cp/typeid.exp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/gdb/testsuite/gdb.cp/typeid.exp b/gdb/testsuite/gdb.cp/typeid.exp index 3ba82f6f001..4dbd9729b54 100644 --- a/gdb/testsuite/gdb.cp/typeid.exp +++ b/gdb/testsuite/gdb.cp/typeid.exp @@ -28,11 +28,22 @@ proc do_typeid_tests {started} { set type_re "(std::type_info|gdb_gnu_v3_type_info)" set var {ca b} - if {$started || ![test_compiler_info clang-*-* c++]} { - # Clang doesn't place type information for the base types in - # the executable, and relies on this being linked in from the - # standard library. As a result, type information for these - # variables is only available once the inferior is started. + + set have_base_types 1 + if {!$started} { + if {[test_compiler_info clang-*-* c++]} { + # Clang doesn't place type information for the base types in + # the executable, and relies on this being linked in from the + # standard library. As a result, type information for these + # variables is only available once the inferior is started. + set have_base_types 0 + } elseif {[istarget "powerpc*-*-*"] || [is_aarch32_target]} { + # On PowerPC, RTTI typeinfo for base types (i, cp, ccp) may not be + # emitted until the inferior is started. + set have_base_types 0 + } + } + if { $have_base_types } { lappend var i cp ccp } -- 2.51.0 ++++++ qa.sh ++++++ --- /var/tmp/diff_new_pack.AfS8SK/_old 2025-11-28 16:50:47.132862143 +0100 +++ /var/tmp/diff_new_pack.AfS8SK/_new 2025-11-28 16:50:47.144862649 +0100 @@ -332,10 +332,6 @@ "FAIL: gdb.debuginfod/fetch_src_and_symbols.exp: local_url: file corefile" "FAIL: gdb.debuginfod/crc_mismatch.exp: local_debuginfod: debuginfod running, info downloaded, no CRC mismatch" - # Fixed by commit 17f6581c36a ("gdb/testsuite: another attempt to fix - # gdb.threads/thread-specific-bp.exp"). - "FAIL: gdb.threads/thread-specific-bp.exp: non_stop=on: continue to end \(timeout\)" - # https://sourceware.org/bugzilla/show_bug.cgi?id=31811 "FAIL: gdb.threads/threads-after-exec.exp:" @@ -361,12 +357,12 @@ # https://sourceware.org/bugzilla/show_bug.cgi?id=32619 "FAIL: gdb.dap/eof.exp: exceptions in log file" - # https://sourceware.org/bugzilla/show_bug.cgi?id=32688 - "FAIL: gdb.threads/thread-specific-bp.exp: non_stop=on: continue to end" - # https://sourceware.org/bugzilla/show_bug.cgi?id=31308 "FAIL: gdb.arch/amd64-init-x87-values.exp: check_setting_mxcsr_before_enable: check new value of MXCSR is still in place" + # https://sourceware.org/bugzilla/show_bug.cgi?id=32893 + "FAIL: gdb.multi/attach-no-multi-process.exp: target_non_stop=off: info threads \(timeout\)" + ) # kfail kfail_sle12=( @@ -836,7 +832,7 @@ kfail_re=$(join "|" "${kfail[@]}") grep -A1 "ERROR:.*no longer" binaries-testsuite*/gdb-testresults/*.sum \ - | grep -E -v "ERROR|\--" | grep -E -v "$kfail_re" + | grep -E -v "ERROR|--" | grep -E -v "$kfail_re" ;; 3)
