Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package gdb for openSUSE:Factory checked in 
at 2023-03-04 22:42:22
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/gdb (Old)
 and      /work/SRC/openSUSE:Factory/.gdb.new.31432 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "gdb"

Sat Mar  4 22:42:22 2023 rev:168 rq:1069165 version:12.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/gdb/gdb.changes  2022-10-27 13:54:37.212704580 
+0200
+++ /work/SRC/openSUSE:Factory/.gdb.new.31432/gdb.changes       2023-03-04 
22:42:32.055555564 +0100
@@ -1,0 +2,139 @@
+Fri Mar  3 12:41:21 UTC 2023 - Tom de Vries <tdevr...@suse.com>
+
+- Maintenance script qa.sh:
+  * Expand kfail pattern for PR29897.
+  * Add PR29965 kfail.
+
+-------------------------------------------------------------------
+Thu Mar  2 08:28:32 UTC 2023 - Tom de Vries <tdevr...@suse.com>
+
+- Re-enable testing all test-cases, undoing accidental change in
+  previous commit.
+- Add --with=for_chroot.
+
+-------------------------------------------------------------------
+Thu Feb 16 10:57:10 UTC 2023 - Tom de Vries <tdevr...@suse.com>
+
+- Patches dropped (bsc#1207712):
+  * gdb-container-rh-pkg.patch
+- Patches added (bsc#1207712):
+  * gdb-testsuite-add-gdb.suse-debranding.exp.patch
+- Patches added (test-case fix):
+  * gdb-testsuite-fix-gdb.dwarf2-dw2-dir-file-name.exp-w.patch
+- Patches added (fedora patch fixup):
+  * fixup-gdb-test-dw2-aranges.patch
+- Patches added (master backports):
+  * gdb-testsuite-add-xfail-in-gdb.arch-i386-pkru.exp.patch
+  * gdb-testsuite-add-xfail-in-gdb.python-py-record-btra.patch
+  * gdb-testsuite-factor-out-proc-linux_kernel_version.patch
+  * gdb-testsuite-fix-gdb.base-infoline-reloc-main-from-.patch
+  * gdb-testsuite-fix-gdb.base-nested-subp-2-3-.exp-with.patch
+  * gdb-testsuite-fix-gdb.threads-schedlock.exp-on-fast-.patch
+  * gdb-testsuite-handle-missing-.note.gnu-stack.patch
+  * gdb-testsuite-simplify-gdb.arch-amd64-disp-step-avx..patch
+  * gdb-testsuite-fix-gdb.threads-schedlock.exp-for-gcc-.patch
+  * gdb-testsuite-add-xfail-case-in-gdb.python-py-record.patch
+  * add-elfcompress_zstd.patch
+  * binutils-gdb-support-zstd-compressed-debug-section.patch
+  * fix-gdb-build-elf-support-check-lzstd.patch
+- Patches removed (dropped by fedora):
+  * gdb-test-ivy-bridge.patch
+- Disable "BuildRequires: %{gcc}-fortran" for SLE-11.
+- Maintenance script qa-local.sh:
+  * Add SLE-11 to configs.
+  * Build with --no-verify.
+- Maintenance script qa.sh:
+  * Add -sle11.
+
+-------------------------------------------------------------------
+Tue Dec 13 10:39:19 UTC 2022 - Tom de Vries <tdevr...@suse.com>
+
+- Maintenance script qa.sh:
+  * Re-enable PR26284 kfails.
+  * Remove mention of PR28275.
+  * Add PR29897 kfail.
+- Mention CVE-2018-7208 and CVE-2017-16829.
+
+-------------------------------------------------------------------
+Tue Dec 13 09:52:56 UTC 2022 - Tom de Vries <tdevr...@suse.com>
+
+- Mention SLE-21561, bnc#1081527, and bnc#1068950.
+
+-------------------------------------------------------------------
+Thu Dec  1 15:20:21 UTC 2022 - Tom de Vries <tdevr...@suse.com>
+
+- Patches added (gdb 12 release branch backports):
+  * gdb-disable-commit-resumed-in-target_kill.patch
+  * gdb-fix-assert-when-quitting-gdb-while-a-thread-is-stepping.patch
+  * gdb-testsuite-add-new-gdb_attach-to-check-attach-command.patch
+  * gdb-testsuite-refactor-gdb.threads-detach-step-over.exp.patch
+  * 
gdb-testsuite-remove-global-declarations-in-gdb.threads-detach-step-over.exp.patch
+  * gdbserver-switch-to-right-process-in-find_one_thread.patch  
+- Patches removed:
+  * gdb-testsuite-fix-race-in-gdb.threads-detach-step-over.exp.patch
+- Maintenance script qa.sh:
+  * Disable PR26284 kfails.
+  * Add PR29841 kfails.
+  * Add kfail_powerpc64le_sle12, kfail_s390 and kfail_s390x.
+  * Add -s390 and -s390x.
+  * Add gdb.base/gdb-rhbz1156192-recursive-dlopen.exp kfail.
+  * Add PR26967 kfails.
+  * Move PR27027 kfails from kfail_factory to kfail.
+  * Add -ppc64le alias for -powerpc64le.
+  * Add gdb.threads/interrupt-while-step-over.exp kfail.
+  * Add gdb.tui/tui-layout-asm-short-prog.exp kfail.
+  * Add unix/-fPIE/-fpie overrides -static kfails.
+  * Add gdb.guile/scm-disasm.exp kfail.
+  * Add gdb.base/gnu_vector.exp to existing kfail.
+  * Add gdb.guile/scm-symtab.exp kfail.
+  * Add gdb.base/write_mem.exp kfail.
+
+-------------------------------------------------------------------
+Tue Nov 22 15:03:04 UTC 2022 - Tom de Vries <tdevr...@suse.com>
+
+- Maintenance script qa.sh:
+  - Add openSUSE Leap 15.4 ppc64le to known clean configs.
+
+-------------------------------------------------------------------
+Wed Nov 16 13:49:01 UTC 2022 - Tom de Vries <tdevr...@suse.com>
+
+- Maintenance script qa.sh:
+  - Update PR26363 internal error pattern.
+  - Add PR29790 kfail.
+  - Add -powerpc64le option.
+  - Generalize PR26915 kfail patterns.
+  - Move PR28478 patterns from kfail_factory to kfail.
+  - Add PR29781 and PR27813 kfails.
+  - Add SLE-15 ppc64le to known clean configs.
+
+-------------------------------------------------------------------
+Tue Nov 15 08:14:11 UTC 2022 - Tom de Vries <tdevr...@suse.com>
+
+- Maintenance script qa-remote.sh:
+  * Use qa.sh alongside qa-remote.sh.
+- Maintenance script qa.sh:
+  * Add PR29783 internal error.
+- Patch removed (intended effect not observed):
+  * gdb-fix-watchpoints-triggered.patch
+
+-------------------------------------------------------------------
+Fri Nov 11 12:06:44 UTC 2022 - Tom de Vries <tdevr...@suse.com>
+
+- Maintenance script qa.sh:
+  * Handle librpm == "" and nolibrpm == "".
+- Maintenance script qa-remote.sh:
+  * Make "Get remote testsuite results" even more verbose.
+  * Make hardcoded pattern gdb-testresults-12.1-*.*.rpm more
+    generic.
+  * Add missing setting of rpm variable in "Getting rpms" case.
+- Patches added (backport from trunk):
+  * gdb-testsuite-fix-gdb.base-break-idempotent.exp-on-ppc.patch
+  * powerpc-fix-gdb.base-watchpoint.exp-on-power-9.patch
+
+-------------------------------------------------------------------
+Fri Oct 21 08:03:27 UTC 2022 - Tom de Vries <tdevr...@suse.com>
+
+- Maintenance script qa-remote.sh:
+  * Make "Get remote testsuite results" more verbose.
+
+-------------------------------------------------------------------
@@ -893,0 +1033 @@
+  * Implements SLE-21561.
@@ -1988,0 +2129 @@
+  * Contains fix for bnc#1081527, CVE-2018-7208.
@@ -2046,0 +2188 @@
+  * Contains fix for bnc#1068950, CVE-2017-16829.

Old:
----
  gdb-container-rh-pkg.patch
  gdb-fix-watchpoints-triggered.patch
  gdb-test-ivy-bridge.patch
  gdb-testsuite-fix-race-in-gdb.threads-detach-step-over.exp.patch

New:
----
  add-elfcompress_zstd.patch
  binutils-gdb-support-zstd-compressed-debug-section.patch
  fix-gdb-build-elf-support-check-lzstd.patch
  fixup-gdb-test-dw2-aranges.patch
  gdb-disable-commit-resumed-in-target_kill.patch
  gdb-fix-assert-when-quitting-gdb-while-a-thread-is-stepping.patch
  gdb-testsuite-add-gdb.suse-debranding.exp.patch
  gdb-testsuite-add-new-gdb_attach-to-check-attach-command.patch
  gdb-testsuite-add-xfail-case-in-gdb.python-py-record.patch
  gdb-testsuite-add-xfail-in-gdb.arch-i386-pkru.exp.patch
  gdb-testsuite-add-xfail-in-gdb.python-py-record-btra.patch
  gdb-testsuite-factor-out-proc-linux_kernel_version.patch
  gdb-testsuite-fix-gdb.base-break-idempotent.exp-on-ppc.patch
  gdb-testsuite-fix-gdb.base-infoline-reloc-main-from-.patch
  gdb-testsuite-fix-gdb.base-nested-subp-2-3-.exp-with.patch
  gdb-testsuite-fix-gdb.dwarf2-dw2-dir-file-name.exp-w.patch
  gdb-testsuite-fix-gdb.threads-schedlock.exp-for-gcc-.patch
  gdb-testsuite-fix-gdb.threads-schedlock.exp-on-fast-.patch
  gdb-testsuite-handle-missing-.note.gnu-stack.patch
  gdb-testsuite-refactor-gdb.threads-detach-step-over.exp.patch
  
gdb-testsuite-remove-global-declarations-in-gdb.threads-detach-step-over.exp.patch
  gdb-testsuite-simplify-gdb.arch-amd64-disp-step-avx..patch
  gdbserver-switch-to-right-process-in-find_one_thread.patch
  powerpc-fix-gdb.base-watchpoint.exp-on-power-9.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ gdb.spec ++++++
--- /var/tmp/diff_new_pack.Q5281J/_old  2023-03-04 22:42:34.891569197 +0100
+++ /var/tmp/diff_new_pack.Q5281J/_new  2023-03-04 22:42:34.895569217 +0100
@@ -1,7 +1,7 @@
 #
 # spec file
 #
-# Copyright (c) 2022 SUSE LLC
+# Copyright (c) 2023 SUSE LLC
 # Copyright (c) 2012 RedHat
 #
 # All modifications and additions to the file contributed by third parties
@@ -20,6 +20,7 @@
 %define flavor @BUILD_FLAVOR@%{nil}
 
 %bcond_with ringdisabled
+%bcond_with for_chroot
 
 %if "%flavor" == "testsuite"
 %if %{with ringdisabled}
@@ -210,7 +211,6 @@
 Patch48:        gdb-test-expr-cumulative-archer.patch
 Patch49:        gdb-physname-pr11734-test.patch
 Patch50:        gdb-physname-pr12273-test.patch
-Patch51:        gdb-test-ivy-bridge.patch
 Patch52:        gdb-runtest-pie-override.patch
 Patch53:        gdb-glibc-strstr-workaround.patch
 Patch54:        gdb-rhel5.9-testcase-xlf-var-inside-mod.patch
@@ -227,7 +227,6 @@
 Patch66:        gdb-opcodes-clflushopt-test.patch
 Patch67:        gdb-6.6-buildid-locate-rpm-scl.patch
 Patch68:        gdb-rhbz1261564-aarch64-hw-watchpoint-test.patch
-Patch69:        gdb-container-rh-pkg.patch
 Patch70:        gdb-rhbz1325795-framefilters-test.patch
 Patch71:        gdb-linux_perf-bundle.patch
 Patch73:        gdb-rhbz1398387-tab-crash-test.patch
@@ -241,6 +240,7 @@
 # - gdb-6.3-rh-testversion-20041202.patch
 # - 
gdb-6.6-buildid-locate-misleading-warning-missing-debuginfo-rhbz981154.patch
 # - gdb-6.8-bz466901-backtrace-full-prelinked.patch
+# - gdb-container-rh-pkg.patch
 #
 # Broken:
 # - gdb-6.5-BEA-testsuite.patch
@@ -251,6 +251,7 @@
 # Obsolete:
 # - gdb-6.7-charsign-test.patch
 # - gdb-6.7-ppc-clobbered-registers-O2-test.patch
+# - gdb-test-ivy-bridge.patch (dropped by fedora)
 
 # Fedora patches fixup
 
@@ -261,6 +262,7 @@
 Patch504:       fixup-gdb-6.5-bz243845-stale-testing-zombie-test.patch
 Patch505:       fixup-gdb-test-bt-cfi-without-die.patch
 Patch506:       fixup-2-gdb-rhbz1553104-s390x-arch12-test.patch
+Patch507:       fixup-gdb-test-dw2-aranges.patch
 
 # openSUSE specific
 
@@ -283,6 +285,8 @@
 Patch1102:      gdb-testsuite-fix-gdb-server-ext-run-exp-for-obs.patch
 # Tests the zypper install hints.
 Patch1103:      gdb-testsuite-add-gdb.suse-zypper-hint.exp.patch
+# Tests that no branding is leaked from sourcing the fedora package.
+Patch1104:      gdb-testsuite-add-gdb.suse-debranding.exp.patch
 
 # Patches to upstream
 
@@ -299,15 +303,16 @@
 # FAIL: gdb.base/step-over-syscall.exp: fork: displaced=off: \
 # pc after stepi matches insn addr after syscall
 Patch1505:      
gdb-testsuite-fix-gdb.base-step-over-syscall.exp-with-m32-amd-case.patch
-# Fixes:
-# FAIL: gdb.threads/detach-step-over.exp: \
-#   breakpoint-condition-evaluation=host: target-non-stop=off: non-stop=off: \
-#   displaced=off: iter 1: all threads running
-Patch1506:      
gdb-testsuite-fix-race-in-gdb.threads-detach-step-over.exp.patch
 
 # Backports from release branch
 
 Patch1700:      fix-core-file-detach-crash-corefiles-29275.patch
+Patch1701:      gdb-testsuite-add-new-gdb_attach-to-check-attach-command.patch
+Patch1702:      
gdb-testsuite-remove-global-declarations-in-gdb.threads-detach-step-over.exp.patch
+Patch1703:      gdb-testsuite-refactor-gdb.threads-detach-step-over.exp.patch
+Patch1704:      
gdb-fix-assert-when-quitting-gdb-while-a-thread-is-stepping.patch
+Patch1705:      gdbserver-switch-to-right-process-in-find_one_thread.patch
+Patch1706:      gdb-disable-commit-resumed-in-target_kill.patch
 
 # Backports from master, available in next release.
 
@@ -348,10 +353,24 @@
 Patch2034:      
gdb-testsuite-fix-gdb.dwarf2-dw2-unspecified-type-foo.c-with-m32.patch
 Patch2035:      gdb-add-support-for-readline-8.2.patch
 Patch2036:      gdb-fix-assert-in-handle_jit_event.patch
+Patch2037:      gdb-testsuite-fix-gdb.base-break-idempotent.exp-on-ppc.patch
+Patch2038:      powerpc-fix-gdb.base-watchpoint.exp-on-power-9.patch
+Patch2039:      gdb-testsuite-handle-missing-.note.gnu-stack.patch
+Patch2040:      gdb-testsuite-fix-gdb.base-infoline-reloc-main-from-.patch
+Patch2041:      gdb-testsuite-fix-gdb.base-nested-subp-2-3-.exp-with.patch
+Patch2042:      add-elfcompress_zstd.patch
+Patch2043:      binutils-gdb-support-zstd-compressed-debug-section.patch
+Patch2044:      fix-gdb-build-elf-support-check-lzstd.patch
 
 # Backports from master, not yet available in next release.
 
-#
+Patch2075:      gdb-testsuite-add-xfail-in-gdb.arch-i386-pkru.exp.patch
+Patch2076:      gdb-testsuite-factor-out-proc-linux_kernel_version.patch
+Patch2077:      gdb-testsuite-add-xfail-in-gdb.python-py-record-btra.patch
+Patch2078:      gdb-testsuite-fix-gdb.threads-schedlock.exp-on-fast-.patch
+Patch2079:      gdb-testsuite-simplify-gdb.arch-amd64-disp-step-avx..patch
+Patch2080:      gdb-testsuite-fix-gdb.threads-schedlock.exp-for-gcc-.patch
+Patch2081:      gdb-testsuite-add-xfail-case-in-gdb.python-py-record.patch
 
 # Backport from gdb-patches
 
@@ -383,8 +402,6 @@
 Patch2112:      
gdb-testsuite-fix-gdb.reverse-i387-env-reverse.exp-for-pie.patch
 # https://sourceware.org/pipermail/gdb-patches/2022-July/191107.html
 Patch2113:      gdb-testsuite-fix-gdb.ada-literals.exp-with-aarch64.patch
-# https://sourceware.org/bugzilla/show_bug.cgi?id=29423#c8
-Patch2114:      gdb-fix-watchpoints-triggered.patch
 # https://sourceware.org/pipermail/gdb-patches/2022-September/192172.html
 Patch2115:      
gdb-testsuite-fix-gdb.mi-mi-sym-info.exp-on-opensuse-tumbleweed.patch
 
@@ -392,6 +409,12 @@
 
 #
 
+# Other.  Needs comment for each patch.
+
+# Not a backport, but no need to upstream either.  Should be able to drop
+# it in next release.
+Patch3000:      gdb-testsuite-fix-gdb.dwarf2-dw2-dir-file-name.exp-w.patch
+
 BuildRequires:  bison
 BuildRequires:  flex
 %if 0%{suse_version} > 1110
@@ -471,6 +494,10 @@
 BuildRequires:  libsource-highlight-devel
 %endif
 
+%if 0%{?suse_version} >= 1500
+BuildRequires:  libzstd-devel
+%endif
+
 %if %{build_testsuite}
 
 # Copied from gcc9/gcc.spec.in
@@ -506,7 +533,15 @@
 BuildRequires:  dejagnu
 BuildRequires:  sharutils
 # gcc-objc++ is not covered by the GDB testsuite.
+
+%if 0%{?suse_version} >= 1200
+# Skip for SLE-11 due to:
+#   unresolvable: conflict for providers of libquadmath0
+#   needed by libgfortran3
+#   (provider libquadmath0-gcc5 is in conflict with libquadmath0)
 BuildRequires:  %{gcc}-fortran
+%endif
+
 BuildRequires:  %{gcc}-objc
 %ifarch %ada_arch
 BuildRequires:  %{gcc}-ada
@@ -699,7 +734,6 @@
 %patch48 -p1
 %patch49 -p1
 %patch50 -p1
-%patch51 -p1
 %patch52 -p1
 %patch53 -p1
 %patch54 -p1
@@ -716,7 +750,6 @@
 %patch66 -p1
 %patch67 -p1
 %patch68 -p1
-%patch69 -p1
 %patch70 -p1
 %patch71 -p1
 %patch73 -p1
@@ -730,6 +763,7 @@
 %patch504 -p1
 %patch505 -p1
 %patch506 -p1
+%patch507 -p1
 
 %patch1000 -p1
 %patch1001 -p1
@@ -738,15 +772,21 @@
 %patch1101 -p1
 %patch1102 -p1
 %patch1103 -p1
+%patch1104 -p1
 
 %patch1500 -p1
 %patch1501 -p1
 %patch1503 -p1
 %patch1504 -p1
 %patch1505 -p1
-%patch1506 -p1
 
 %patch1700 -p1
+%patch1701 -p1
+%patch1702 -p1
+%patch1703 -p1
+%patch1704 -p1
+%patch1705 -p1
+%patch1706 -p1
 
 %patch2000 -p1
 %patch2001 -p1
@@ -785,6 +825,22 @@
 %patch2034 -p1
 %patch2035 -p1
 %patch2036 -p1
+%patch2037 -p1
+%patch2038 -p1
+%patch2039 -p1
+%patch2040 -p1
+%patch2041 -p1
+%patch2042 -p1
+%patch2043 -p1
+%patch2044 -p1
+
+%patch2075 -p1
+%patch2076 -p1
+%patch2077 -p1
+%patch2078 -p1
+%patch2079 -p1
+%patch2080 -p1
+%patch2081 -p1
 
 %patch2100 -p1
 %patch2101 -p1
@@ -800,9 +856,10 @@
 %patch2111 -p1
 %patch2112 -p1
 %patch2113 -p1
-%patch2114 -p1
 %patch2115 -p1
 
+%patch3000 -p1
+
 #unpack libipt
 %if 0%{have_libipt}
 tar xzf %{SOURCE7}
@@ -1145,7 +1202,15 @@
       CHECK="$(echo $CHECK | sed 's#check//unix/[^ ]*#& &/-fPIE/-pie#g')"
   fi
 
+%if %{with for_chroot}
+  # When we want to chroot into a local osc build and run a test-case, we
+  # need -M testsuite to add all the buildrequires, but there's no need
+  # to run the testsuite.  Instead, fail %check to make sure %clean doesn't
+  # remove buildroot.
+  false
+%else
   ./orphanripper make %{?_smp_mflags} -k $CHECK || :
+%endif
 )
 for t in sum log
 do

++++++ add-elfcompress_zstd.patch ++++++
>From f41928feb3e44fb27776afa062a1cd06263b7d1d Mon Sep 17 00:00:00 2001
From: Cary Coutant <ccout...@gmail.com>
Date: Tue, 2 Aug 2022 16:19:43 -0700
Subject: [PATCH 1/2] Add ELFCOMPRESS_ZSTD.

include/elf/
        * common.h: Add ELFCOMPRESS_ZSTD.
---
 include/elf/common.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/elf/common.h b/include/elf/common.h
index 70d63e3299c..c409da2bd16 100644
--- a/include/elf/common.h
+++ b/include/elf/common.h
@@ -588,6 +588,8 @@
 
 /* Compression types.  */
 #define ELFCOMPRESS_ZLIB   1           /* Compressed with zlib.  */
+#define ELFCOMPRESS_ZSTD   2           /* Compressed with zstd  */
+                                       /* (see http://www.zstandard.org). */
 #define ELFCOMPRESS_LOOS   0x60000000  /* OS-specific semantics, lo */
 #define ELFCOMPRESS_HIOS   0x6FFFFFFF  /* OS-specific semantics, hi */
 #define ELFCOMPRESS_LOPROC 0x70000000  /* Processor-specific semantics, lo */

base-commit: 835a10f8541c7c4150098c82e097c4f606475cfa
-- 
2.35.3


++++++ binutils-gdb-support-zstd-compressed-debug-section.patch ++++++
++++ 1289 lines (skipped)

++++++ fix-gdb-build-elf-support-check-lzstd.patch ++++++
>From 1907d04cb6cb94052369995cf8373f2670908e2a Mon Sep 17 00:00:00 2001
From: Pedro Alves <pe...@palves.net>
Date: Wed, 28 Sep 2022 11:33:30 +0100
Subject: [PATCH] Fix GDB build: ELF support check & -lzstd

GDB fails to build for me, on Ubuntu 20.04.  I get:

 ...
   CXXLD  gdb
 /usr/bin/ld: linux-tdep.o: in function `linux_corefile_thread(thread_info*, 
linux_corefile_thread_data*)':
 /home/pedro/gdb/binutils-gdb/src/gdb/linux-tdep.c:1831: undefined reference to 
`gcore_elf_build_thread_register_notes(gdbarch*, thread_info*, gdb_signal, 
bfd*, std::unique_ptr<char, gdb::xfree_deleter<char> >*, int*)'
 /usr/bin/ld: linux-tdep.o: in function `linux_make_corefile_notes(gdbarch*, 
bfd*, int*)':
 /home/pedro/gdb/binutils-gdb/src/gdb/linux-tdep.c:2117: undefined reference to 
`gcore_elf_make_tdesc_note(bfd*, std::unique_ptr<char, gdb::xfree_deleter<char> 
>*, int*)'
 collect2: error: ld returned 1 exit status
 make[2]: *** [Makefile:2149: gdb] Error 1
 make[2]: Leaving directory '/home/pedro/gdb/binutils-gdb/build/gdb'
 make[1]: *** [Makefile:11847: all-gdb] Error 2
 make[1]: Leaving directory '/home/pedro/gdb/binutils-gdb/build'
 make: *** [Makefile:1004: all] Error 2

Those undefined functions exist in gdb/gcore-elf.c, which is only
included in the build if GDB's configure thinks that the target you're
configuring for is an ELF target.  GDB's configure thinks my system
isn't ELF, which is incorrect.

For the ELF support check, gdb/config.log shows:

 configure:17387: checking for ELF support in BFD
 configure:17407: gcc -o conftest 
-I/home/pedro/gdb/binutils-gdb/src/gdb/../include -I../bfd 
-I/home/pedro/gdb/binutils-gdb/src/gdb/../bfd -g3 -O0      -L../bfd 
-L../libiberty  -lzstd   conftest.c -lbfd -liberty -lz  -lncursesw -lm -ldl  >&5
 /usr/bin/ld: ../bfd/libbfd.a(compress.o): in function `decompress_contents':
 /home/pedro/gdb/binutils-gdb/src/bfd/compress.c:42: undefined reference to 
`ZSTD_decompress'
 /usr/bin/ld: /home/pedro/gdb/binutils-gdb/src/bfd/compress.c:44: undefined 
reference to `ZSTD_isError'
 /usr/bin/ld: ../bfd/libbfd.a(compress.o): in function 
`bfd_compress_section_contents':
 /home/pedro/gdb/binutils-gdb/src/bfd/compress.c:195: undefined reference to 
`ZSTD_compress'
 /usr/bin/ld: /home/pedro/gdb/binutils-gdb/src/bfd/compress.c:198: undefined 
reference to `ZSTD_isError'
 collect2: error: ld returned 1 exit status
 configure:17407: $? = 1
 ...
 configure:17417: result: no

Note how above, in the gcc command line, "-lzstd" appears before
"-lbfd".  That explain the link failure.  It should appear after, like
-lz does.

This commit fixes it, by moving ZSTD_LIBS from LDFLAGS to LIBS, next
to -lz, in GDB_AC_CHECK_BFD, and regenerating gdb/configure.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29630
Change-Id: I1f4128dde634e8ea04c9002904f1005a8b3a6863
---
 gdb/acinclude.m4 | 4 ++--
 gdb/configure    | 8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index 28846119dcb..62fa66c7af3 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -234,9 +234,9 @@ AC_DEFUN([GDB_AC_CHECK_BFD], [
   # always want our bfd.
   CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
   ZLIBDIR=`echo $zlibdir | sed 's,\$(top_builddir)/,,g'`
-  LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $ZSTD_LIBS $LDFLAGS"
+  LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS"
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
-  LIBS="-lbfd -liberty -lz $intl $LIBS"
+  LIBS="-lbfd -liberty -lz $ZSTD_LIBS $intl $LIBS"
   AC_CACHE_CHECK(
     [$1],
     [$2],
diff --git a/gdb/configure b/gdb/configure
index 2fcba76b5e8..a5f33ce65d9 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -17963,9 +17963,9 @@ WIN32LIBS="$WIN32LIBS $WIN32APILIBS"
   # always want our bfd.
   CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
   ZLIBDIR=`echo $zlibdir | sed 's,\$(top_builddir)/,,g'`
-  LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $ZSTD_LIBS $LDFLAGS"
+  LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS"
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
-  LIBS="-lbfd -liberty -lz $intl $LIBS"
+  LIBS="-lbfd -liberty -lz $ZSTD_LIBS $intl $LIBS"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ELF support in BFD" >&5
 $as_echo_n "checking for ELF support in BFD... " >&6; }
 if ${gdb_cv_var_elf+:} false; then :
@@ -18078,9 +18078,9 @@ fi
   # always want our bfd.
   CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
   ZLIBDIR=`echo $zlibdir | sed 's,\$(top_builddir)/,,g'`
-  LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $ZSTD_LIBS $LDFLAGS"
+  LDFLAGS="-L../bfd -L../libiberty $ZLIBDIR $LDFLAGS"
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
-  LIBS="-lbfd -liberty -lz $intl $LIBS"
+  LIBS="-lbfd -liberty -lz $ZSTD_LIBS $intl $LIBS"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mach-O support in BFD" 
>&5
 $as_echo_n "checking for Mach-O support in BFD... " >&6; }
 if ${gdb_cv_var_macho+:} false; then :
-- 
2.35.3


++++++ fixup-gdb-test-dw2-aranges.patch ++++++
>From 81a7585502092b3c133534ac6ecb34fd56d05337 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevr...@suse.de>
Date: Thu, 16 Feb 2023 12:56:41 +0100
Subject: [PATCH 09/11] fixup gdb-test-dw2-aranges.patch

---
 gdb/testsuite/gdb.dwarf2/dw2-aranges.S | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gdb/testsuite/gdb.dwarf2/dw2-aranges.S 
b/gdb/testsuite/gdb.dwarf2/dw2-aranges.S
index d5b9ca5a3c6..b811f6644cb 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-aranges.S
+++ b/gdb/testsuite/gdb.dwarf2/dw2-aranges.S
@@ -138,3 +138,4 @@ main:
        .byte           0                       /* aranges segment_size */
 
 .Laranges_end:
+       .section        .note.GNU-stack,"",@progbits
-- 
2.35.3


++++++ gdb-disable-commit-resumed-in-target_kill.patch ++++++
gdb: disable commit resumed in target_kill

New in this version:

 - Better comment in target_kill
 - Uncomment line in test to avoid hanging when exiting, when testing on
   native-extended-gdbserver

PR 28275 shows that doing a sequence of:

 - Run inferior in background (run &)
 - kill that inferior
 - Run again

We get into this assertion:

    /home/smarchi/src/binutils-gdb/gdb/target.c:2590: internal-error: 
target_wait: Assertion `!proc_target->commit_resumed_state' failed.

    #0  internal_error_loc (file=0x5606b344e740 
"/home/smarchi/src/binutils-gdb/gdb/target.c", line=2590, fmt=0x5606b344d6a0 
"%s: Assertion `%s' failed.") at 
/home/smarchi/src/binutils-gdb/gdbsupport/errors.cc:54
    #1  0x00005606b6296475 in target_wait (ptid=..., status=0x7fffb9390630, 
options=...) at /home/smarchi/src/binutils-gdb/gdb/target.c:2590
    #2  0x00005606b5767a98 in startup_inferior (proc_target=0x5606bfccb2a0 
<the_amd64_linux_nat_target>, pid=3884857, ntraps=1, last_waitstatus=0x0, 
last_ptid=0x0) at /home/smarchi/src/binutils-gdb/gdb/nat/fork-inferior.c:482
    #3  0x00005606b4e6c9c5 in gdb_startup_inferior (pid=3884857, num_traps=1) 
at /home/smarchi/src/binutils-gdb/gdb/fork-child.c:132
    #4  0x00005606b50f14a5 in inf_ptrace_target::create_inferior 
(this=0x5606bfccb2a0 <the_amd64_linux_nat_target>, exec_file=0x604000039f50 
"/home/smarchi/build/binutils-gdb/gdb/test", allargs="", env=0x61500000a580, 
from_tty=1)
        at /home/smarchi/src/binutils-gdb/gdb/inf-ptrace.c:105
    #5  0x00005606b53b6d23 in linux_nat_target::create_inferior 
(this=0x5606bfccb2a0 <the_amd64_linux_nat_target>, exec_file=0x604000039f50 
"/home/smarchi/build/binutils-gdb/gdb/test", allargs="", env=0x61500000a580, 
from_tty=1)
        at /home/smarchi/src/binutils-gdb/gdb/linux-nat.c:978
    #6  0x00005606b512b79b in run_command_1 (args=0x0, from_tty=1, 
run_how=RUN_NORMAL) at /home/smarchi/src/binutils-gdb/gdb/infcmd.c:468
    #7  0x00005606b512c236 in run_command (args=0x0, from_tty=1) at 
/home/smarchi/src/binutils-gdb/gdb/infcmd.c:526

When running the kill command, commit_resumed_state for the
process_stratum_target (linux-nat, here) is true.  After the kill, when
there are no more threads, commit_resumed_state is still true, as
nothing touches this flag during the kill operation.  During the
subsequent run command, run_command_1 does:

    scoped_disable_commit_resumed disable_commit_resumed ("running");

We would think that this would clear the commit_resumed_state flag of
our native target, but that's not the case, because
scoped_disable_commit_resumed iterates on non-exited inferiors in order
to find active process targets.  And after the kill, the inferior is
exited, and the native target was unpushed from it anyway.  So
scoped_disable_commit_resumed doesn't touch the commit_resumed_state
flag of the native target, it stays true.  When reaching target_wait, in
startup_inferior (to consume the initial expect stop events while the
inferior is starting up and working its way through the shell),
commit_resumed_state is true, breaking the contract saying that
commit_resumed_state is always false when calling the targets' wait
method.

(note: to be correct, I think that startup_inferior should toggle
commit_resumed between the target_wait and target_resume calls, but I'll
ignore that for now)

I can see multiple ways to fix this.  In the end, we need
commit_resumed_state to be cleared by the time we get to that
target_wait.  It could be done at the end of the kill command, or at the
beginning of the run command.

To keep things in a coherent state, I'd like to make it so that after
the kill command, when the target is left with no threads, its
commit_resumed_state flag is left to false.  This way, we can keep
working with the assumption that a target with no threads (and therefore
no running threads) has commit_resumed_state == false.

Do this by adding a scoped_disable_commit_resumed in target_kill.  It
clears the target's commit_resumed_state on entry, and leaves it false
if the target does not have any resumed thread on exit.  That means,
even if the target has another inferior with stopped threads,
commit_resumed_state will be left to false, which makes sense.

Add a test that tries to cover various combinations of actions done
while an inferior is running (and therefore while commit_resumed_state
is true on the process target).

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28275
Change-Id: I8e6fe6dc1f475055921520e58cab68024039a1e9
Approved-By: Andrew Burgess <aburg...@redhat.com>

---
 gdb/target.c                                       |   9 ++
 .../gdb.base/run-control-while-bg-execution.c      |  33 ++++++
 .../gdb.base/run-control-while-bg-execution.exp    | 122 +++++++++++++++++++++
 3 files changed, 164 insertions(+)

diff --git a/gdb/target.c b/gdb/target.c
index 0c86b571e1c..0eae5307785 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -908,6 +908,15 @@ add_deprecated_target_alias (const target_info &tinfo, 
const char *alias)
 void
 target_kill (void)
 {
+
+  /* If the commit_resume_state of the to-be-killed-inferior's process stratum
+     is true, and this inferior is the last live inferior with resumed threads
+     of that target, then we want to leave commit_resume_state to false, as the
+     target won't have any resumed threads anymore.  We achieve this with
+     this scoped_disable_commit_resumed.  On construction, it will set the flag
+     to false.  On destruction, it will only set it to true if there are 
resumed
+     threads left.  */
+  scoped_disable_commit_resumed disable ("killing");
   current_inferior ()->top_target ()->kill ();
 }
 
diff --git a/gdb/testsuite/gdb.base/run-control-while-bg-execution.c 
b/gdb/testsuite/gdb.base/run-control-while-bg-execution.c
new file mode 100644
index 00000000000..8092fadc8b9
--- /dev/null
+++ b/gdb/testsuite/gdb.base/run-control-while-bg-execution.c
@@ -0,0 +1,33 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2020-2022 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/>.  */
+                                              //
+#include <unistd.h>
+
+static pid_t mypid = -1;
+
+static void
+after_getpid (void)
+{
+}
+
+int
+main (void)
+{
+  mypid = getpid ();
+  after_getpid ();
+  sleep (30);
+}
diff --git a/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp 
b/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp
new file mode 100644
index 00000000000..5b4834f0b32
--- /dev/null
+++ b/gdb/testsuite/gdb.base/run-control-while-bg-execution.exp
@@ -0,0 +1,122 @@
+# Copyright 2022 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 test aims at testing various operations after getting rid of an inferior
+# that was running in background, or while we have an inferior running in
+# background.  The original intent was to expose cases where the commit-resumed
+# state of the process stratum target was not reset properly after killing an
+# inferior running in background, which would be a problem when trying to run
+# again.  The test was expanded to test various combinations of
+# run-control-related actions done with an inferior running in background.
+
+if {[use_gdb_stub]} {
+    unsupported "test requires running"
+    return
+}
+
+standard_testfile
+
+if {[build_executable "failed to prepare" $testfile $srcfile]} {
+    return
+}
+
+# Run one variation of the test:
+#
+# 1. Start an inferior in the background with "run &"
+# 2. Do action 1
+# 3. Do action 2
+#
+# Action 1 indicates what to do with the inferior running in background:
+#
+#  - kill: kill it
+#  - detach: detach it
+#  - add: add a new inferior and switch to it, leave the inferior running in
+#    background alone
+#  - none: do nothing, leave the inferior running in background alone
+#
+# Action 2 indicates what to do after that:
+#
+#  - start: use the start command
+#  - run: use the run command
+#  - attach: start a process outside of GDB and attach it
+proc do_test { action1 action2 } {
+    save_vars { ::GDBFLAGS } {
+       append ::GDBFLAGS " -ex \"maintenance set target-non-stop on\""
+       clean_restart $::binfile
+    }
+
+    # Ensure we are at least after the getpid call, should we need it.
+    if { ![runto "after_getpid"] } {
+       return
+    }
+
+    # Some commands below ask for confirmation.  Turn that off for simplicity.
+    gdb_test "set confirm off"
+    gdb_test_multiple "continue &" "" {
+       -re ".*\r\n$::gdb_prompt " {
+           pass $gdb_test_name
+       }
+    }
+
+    if { $action1 == "kill" } {
+       gdb_test "kill" "Inferior 1 .* killed.*"
+    } elseif { $action1 == "detach" } {
+       set child_pid [get_integer_valueof "mypid" -1]
+       if { $child_pid == -1 } {
+           fail "failed to extract child pid"
+           return
+       }
+
+       gdb_test "detach" "Inferior 1 .* detached.*" "detach from first 
instance"
+
+       # Kill the detached process, to avoid hanging when exiting GDBserver,
+       # when testing with the native-extended-gdbserver board.
+       remote_exec target "kill $child_pid"
+    } elseif { $action1 == "add" } {
+       gdb_test "add-inferior -exec $::binfile" \
+           "Added inferior 2 on connection 1.*" "add-inferior"
+       gdb_test "inferior 2" "Switching to inferior 2 .*"
+    } elseif { $action1 == "none" } {
+
+    } else {
+       error "invalid action 1"
+    }
+
+    if { $action2 == "start" } {
+       gdb_test "start" "Temporary breakpoint $::decimal\(?:\.$::decimal\)?, 
main .*"
+    } elseif { $action2 == "run" } {
+       gdb_test "break main" "Breakpoint $::decimal at $::hex.*"
+       gdb_test "run" "Breakpoint $::decimal\(?:\.$::decimal\)?, main .*"
+    } elseif { $action2 == "attach" } {
+       set test_spawn_id [spawn_wait_for_attach $::binfile]
+       set test_pid [spawn_id_get_pid $test_spawn_id]
+
+       if { [gdb_attach $test_pid] } {
+           gdb_test "detach" "Inferior $::decimal .* detached.*" \
+               "detach from second instance"
+       }
+
+       # Detach and kill this inferior so we don't leave it around.
+       kill_wait_spawned_process $test_spawn_id
+    } else {
+       error "invalid action 2"
+    }
+}
+
+foreach_with_prefix action1 { kill detach add none } {
+    foreach_with_prefix action2 { start run attach } {
+       do_test $action1 $action2
+    }
+}

++++++ gdb-fix-assert-when-quitting-gdb-while-a-thread-is-stepping.patch ++++++
gdb: fix assert when quitting GDB while a thread is stepping

This commit addresses one of the issues identified in PR gdb/28275.

Bug gdb/28275 identifies a number of situations in which this assert:

  Assertion `!proc_target->commit_resumed_state' failed.

could be triggered.  There's actually a number of similar places where
this assert is found in GDB, the two of interest in gdb/28275 are in
target_wait and target_stop.

In one of the comments:

  https://sourceware.org/bugzilla/show_bug.cgi?id=28275#c1

steps to trigger the assertion within target_stop were identified when
using a modified version of the gdb.threads/detach-step-over.exp test
script.

In the gdb.threads/detach-step-over.exp test, we attach to a
multi-threaded inferior, and continue the inferior in asynchronous
(background) mode.  Each thread is continuously hitting a conditional
breakpoint where the condition is always false.  While the inferior is
running we detach.  The goal is that we detach while GDB is performing a
step-over for the conditional breakpoint in at least one thread.

While detaching, if a step-over is in progress, then GDB has to
complete the step over before we can detach.  This involves calling
target_stop and target_wait (see prepare_for_detach).

As far as gdb/28275 is concerned, the interesting part here, is the
the process_stratum_target::commit_resumed_state variable must be
false when target_stop and target_wait are called.

This is currently ensured because, in detach_command (infrun.c), we
create an instance of scoped_disable_commit_resumed, this ensures that
when target_detach is called, ::commit_resumed_state will be false.

The modification to the test that I propose here, and which exposed
the bug, is that, instead of using "detach" to detach from the
inferior, we instead use "quit".  Quitting GDB after attaching to an
inferior will cause GDB to first detach, and then exit.

When we quit GDB we end up calling target_detach via a different code
path, the stack looks like:

  #0 target_detach
  #1 kill_or_detach
  #2 quit_force
  #3 quit_command

Along this path there is no scoped_disable_commit_resumed created.
::commit_resumed_state can be true when we reach prepare_for_detach,
which calls target_wait and target_stop, so the assertion will trigger.

In this commit, I propose fixing this by adding the creation of a
scoped_disable_commit_resumed into target_detach.  This will ensure
that ::commit_resumed_state is false when calling prepare_for_detach
from within target_detach.

I did consider placing the scoped_disable_commit_resumed in
prepare_for_detach, however, placing it in target_detach ensures that
the target's commit_resumed_state flag is left to false if the detached
inferior was the last one for that target.  It's the same rationale as
for patch "gdb: disable commit resumed in target_kill" that comes later
in this series, but for detach instead of kill.

detach_command still includes a scoped_disable_commit_resumed too, but I
think it is still relevant to cover the resumption at the end of the
function.

Co-Authored-By: Simon Marchi <simon.mar...@efficios.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28275
Change-Id: Ie128f7aba6ef0e018859275eca372e6ea738e96f

---
 gdb/target.c                                   |  5 +++
 gdb/testsuite/gdb.threads/detach-step-over.exp | 52 ++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)

diff --git a/gdb/target.c b/gdb/target.c
index 1ee051b520a..0c86b571e1c 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -2558,6 +2558,9 @@ target_preopen (int from_tty)
 void
 target_detach (inferior *inf, int from_tty)
 {
+  /* Thread's don't need to be resumed until the end of this function.  */
+  scoped_disable_commit_resumed disable_commit_resumed ("detaching");
+
   /* After we have detached, we will clear the register cache for this inferior
      by calling registers_changed_ptid.  We must save the pid_ptid before
      detaching, as the target detach method will clear inf->pid.  */
@@ -2588,6 +2591,8 @@ target_detach (inferior *inf, int from_tty)
      inferior_ptid matches save_pid_ptid, but in our case, it does not
      call it, as inferior_ptid has been reset.  */
   reinit_frame_cache ();
+
+  disable_commit_resumed.reset_and_commit ();
 }
 
 void
diff --git a/gdb/testsuite/gdb.threads/detach-step-over.exp 
b/gdb/testsuite/gdb.threads/detach-step-over.exp
index ad9b08f549e..d2cb52423d9 100644
--- a/gdb/testsuite/gdb.threads/detach-step-over.exp
+++ b/gdb/testsuite/gdb.threads/detach-step-over.exp
@@ -284,6 +284,56 @@ proc_with_prefix test_detach_command {condition_eval 
target_non_stop non_stop di
     kill_wait_spawned_process $test_spawn_id
 }
 
+# Similar to the proc above, but this time, instead of detaching using
+# the 'detach' command, we quit GDB, this will also trigger a detach, but
+# through a slightly different path, which can expose different bugs.
+proc_with_prefix test_detach_quit {condition_eval target_non_stop \
+       non_stop displaced} {
+    # If debugging with target remote, check whether the all-stop variant
+    # of the RSP is being used.  If so, we can't run the background tests.
+    if {!$non_stop
+       && [target_info exists gdb_protocol]
+       && ([target_info gdb_protocol] == "remote"
+           || [target_info gdb_protocol] == "extended-remote")} {
+       start_gdb_for_test $condition_eval $target_non_stop \
+           $non_stop $displaced
+
+       gdb_test_multiple "maint show target-non-stop" "" {
+           -wrap -re "(is|currently) on.*" {
+           }
+           -wrap -re "(is|currently) off.*" {
+               return
+           }
+       }
+    }
+
+    set test_spawn_id [spawn_wait_for_attach $::binfile]
+    set testpid [spawn_id_get_pid $test_spawn_id]
+
+    set attempts 3
+    for {set attempt 1} { $attempt <= $attempts } { incr attempt } {
+       with_test_prefix "iter $attempt" {
+
+           start_gdb_for_test $condition_eval $target_non_stop \
+               $non_stop $displaced
+
+           if {![prepare_test_iter $testpid $non_stop \
+                     $attempt $attempts "$::decimal"]} {
+               kill_wait_spawned_process $test_spawn_id
+               return
+           }
+
+           gdb_test_multiple "with confirm off -- quit" "" {
+               eof {
+                   pass $gdb_test_name
+               }
+           }
+       }
+    }
+
+    kill_wait_spawned_process $test_spawn_id
+}
+
 # The test program exits after a while, in case GDB crashes.  Make it
 # wait at least as long as we may wait before declaring a time out
 # failure.
@@ -331,6 +381,8 @@ foreach_with_prefix breakpoint-condition-evaluation {"host" 
"target"} {
            foreach_with_prefix displaced {"off" "auto"} {
                test_detach_command ${breakpoint-condition-evaluation} \
                    ${target-non-stop} ${non-stop} ${displaced}
+               test_detach_quit ${breakpoint-condition-evaluation} \
+                   ${target-non-stop} ${non-stop} ${displaced}
            }
        }
     }

++++++ gdb-testsuite-add-gdb.suse-debranding.exp.patch ++++++
>From b08bf94f170dd39db21cf8f62941f1866b6978c0 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevr...@suse.de>
Date: Thu, 16 Feb 2023 11:36:47 +0100
Subject: [PATCH 080/155] Add gdb.suse/debranding.exp

---
 gdb/testsuite/gdb.suse/debranding.exp | 49 +++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 gdb/testsuite/gdb.suse/debranding.exp

diff --git a/gdb/testsuite/gdb.suse/debranding.exp 
b/gdb/testsuite/gdb.suse/debranding.exp
new file mode 100644
index 00000000000..cdee10b75a7
--- /dev/null
+++ b/gdb/testsuite/gdb.suse/debranding.exp
@@ -0,0 +1,49 @@
+# 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/>.
+
+# There's a problem with dumping the entire output into gdb.log
+# on SLE-11, so redirect to file instead.  Also means the gdb.log
+# is smaller.
+set f [standard_output_file "gdb-strings.txt"]
+
+# Not using remote_exec due to using file redirection.
+set cmd "exec strings $GDB > $f"
+set status [catch $cmd msg]
+verbose -log "status: $status"
+verbose -log "msg: $msg"
+gdb_assert { $status == 0 }
+
+set fp [open $f r]
+set output [read $fp]
+close $fp
+
+set re {^.*(?:fedora|red[^a-z]?hat).*$}
+set matches [regexp -line -nocase -all -inline $re $output]
+
+set disallowed_matches 0
+set allowed_re "warning: deprecated Red Hat reloc"
+foreach match $matches {
+    if { [regexp -nocase $allowed_re $match] } {
+       verbose -log "allowed_match: '$match'"
+       continue
+    }
+
+    verbose -log "disallowed_match: '$match'"
+    incr disallowed_matches
+}
+
+gdb_assert { $disallowed_matches == 0 }
+
+remote_file build delete $f
-- 
2.35.3


++++++ gdb-testsuite-add-new-gdb_attach-to-check-attach-command.patch ++++++
gdb: testsuite: add new gdb_attach to check "attach" command

This commit adds new gdb_attach to centralize the failure checking of
"attach" command. Return 0 if attach failed, otherwise return 1.

Signed-off-by: Tiezhu Yang <yangtie...@loongson.cn>
Change-Id: I553cf386cef60c67d38e331904b4aa01e132104a

---
 gdb/testsuite/lib/gdb.exp | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 25c1572a53a..5104835a2a9 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -5146,6 +5146,32 @@ proc can_spawn_for_attach { } {
     return 1
 }
 
+# Centralize the failure checking of "attach" command.
+# Return 0 if attach failed, otherwise return 1.
+
+proc gdb_attach { testpid args } {
+    parse_args {
+       {pattern ""}
+    }
+
+    if { [llength $args] != 0 } {
+       error "Unexpected arguments: $args"
+    }
+
+    gdb_test_multiple "attach $testpid" "attach" {
+       -re -wrap "Attaching to.*ptrace: Operation not permitted\\." {
+           unsupported "$gdb_test_name (Operation not permitted)"
+           return 0
+       }
+       -re -wrap "$pattern" {
+           pass $gdb_test_name
+           return 1
+       }
+    }
+
+    return 0
+}
+
 # Kill a progress previously started with spawn_wait_for_attach, and
 # reap its wait status.  PROC_SPAWN_ID is the spawn id associated with
 # the process.

++++++ gdb-testsuite-add-xfail-case-in-gdb.python-py-record.patch ++++++
>From 835a10f8541c7c4150098c82e097c4f606475cfa Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevr...@suse.de>
Date: Mon, 20 Feb 2023 11:16:02 +0100
Subject: [PATCH] [gdb/testsuite] Add xfail case in
 gdb.python/py-record-btrace.exp

I came across:
...
gdb) PASS: gdb.python/py-record-btrace.exp: prepare record: stepi 100
python insn = r.instruction_history^M
warning: Non-contiguous trace at instruction 1 (offset = 0x3e10).^M
(gdb) FAIL: gdb.python/py-record-btrace.exp: prepare record: python insn = r.i\
nstruction_history
...

I'm assuming it's the same root cause as for the already present XFAIL.

Fix this by recognizing above warning in the xfail regexp.

Tested on x86_64-linux, although sofar I was not able to trigger the warning
again.

Approved-By: Markus T. Metzger <markus.t.metz...@intel.com>
---
 gdb/testsuite/gdb.python/py-record-btrace.exp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.python/py-record-btrace.exp 
b/gdb/testsuite/gdb.python/py-record-btrace.exp
index ca8740bc967..a930d17264d 100644
--- a/gdb/testsuite/gdb.python/py-record-btrace.exp
+++ b/gdb/testsuite/gdb.python/py-record-btrace.exp
@@ -86,6 +86,11 @@ with_test_prefix "prepare record" {
                  "warning: Decode error \\($nonl_re*\\) at instruction 
$decimal" \
                  "\\(offset = $hex, pc = $hex\\):" \
                  "$nonl_re*\\."]]
+    set xfail_re_2 \
+       [join \
+            [list \
+                 "warning: Non-contiguous trace at instruction $decimal" \
+                 "\\(offset = $hex\\)\\."]]
 
     set got_xfail 0
     set cmd "python insn = r.instruction_history"
@@ -93,7 +98,7 @@ with_test_prefix "prepare record" {
        -re "^[string_to_regexp $cmd]\r\n$::gdb_prompt $" {
            pass $gdb_test_name
        }
-       -re -wrap "$xfail_re" {
+       -re -wrap "($xfail_re|$xfail_re_2)" {
            if { $have_xfail } {
                xfail $gdb_test_name
                set got_xfail 1

base-commit: f168a48adf97a36c88c65a075b42e6b7083063df
-- 
2.35.3


++++++ gdb-testsuite-add-xfail-in-gdb.arch-i386-pkru.exp.patch ++++++
>From 1b89c346a99d89a06d9694ca4d47d040d4eebd5a Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevr...@suse.de>
Date: Tue, 3 Jan 2023 16:41:05 +0100
Subject: [PATCH 02/11] [gdb/testsuite] Add xfail in gdb.arch/i386-pkru.exp

On a x86_64-linux machine with pkru register, I run into:
...
(gdb) PASS: gdb.arch/i386-pkru.exp: set pkru value
info register pkru^M
pkru           0x12345678          305419896^M
(gdb) FAIL: gdb.arch/i386-pkru.exp: read value after setting value
...

This is a regression due to kernel commit e84ba47e313d ("x86/fpu: Hook up PKRU
onto ptrace()").  This is fixed by recent kernel commit 4a804c4f8356
("x86/fpu: Allow PKRU to be (once again) written by ptrace.").

The regression occurs for kernel versions v5.14-rc1 (the first tag containing
the regression) up to but excluding v6.2-rc1 (the first tag containing the fix).

Fix this by adding an xfail for the appropriate kernel versions.

Tested on x86_64-linux.

PR testsuite/29790
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29790
---
 gdb/testsuite/gdb.arch/i386-pkru.exp | 45 +++++++++++++++++++++++---
 gdb/testsuite/lib/gdb-utils.exp      | 48 ++++++++++++++++++++++++++++
 2 files changed, 89 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/gdb.arch/i386-pkru.exp 
b/gdb/testsuite/gdb.arch/i386-pkru.exp
index 7724a579631..5fe93db9b4b 100644
--- a/gdb/testsuite/gdb.arch/i386-pkru.exp
+++ b/gdb/testsuite/gdb.arch/i386-pkru.exp
@@ -58,6 +58,26 @@ if { !$supports_pkru } {
     return
 }
 
+# Linux kernel versions 5.14.0 to 6.1.x contain a regression related to writing
+# the PKRU using ptrace, see commit 4a804c4f8356 ("x86/fpu: Allow PKRU to be
+# (once again) written by ptrace.").
+set have_xfail 0
+if { [istarget *-*-linux*] } {
+    set res [remote_exec target "uname -r"]
+    set status [lindex $res 0]
+    set output [lindex $res 1]
+
+    set re ^($decimal)\\.($decimal)\\.($decimal)
+    if { $status == 0
+        && [regexp $re $output dummy v1 v2 v3] == 1 } {
+       set v [list $v1 $v2 $v3]
+       set have_xfail \
+           [expr \
+                [version_compare [list 5 14 0] <= $v] \
+                && [version_compare $v < [list 6 2 0]]]
+    }
+}
+
 # Test pkru register at startup
 gdb_test "print /x \$pkru" "= $default_pkru_re" "pkru register"
 
@@ -65,11 +85,28 @@ gdb_test "print /x \$pkru" "= $default_pkru_re" "pkru 
register"
 gdb_breakpoint [ gdb_get_line_number "break here 1" ]
 gdb_continue_to_breakpoint "break here 1" ".*break here 1.*"
 
-gdb_test "info register pkru" ".*pkru.*0x12345678.*" "read pkru register"
-gdb_test "print /x \$pkru = 0x44444444" "= 0x44444444" "set pkru value"
-gdb_test "info register pkru" ".*pkru.*0x44444444.*" "read value after setting 
value"
+set val1 0x12345678
+gdb_test "info register pkru" ".*pkru.*$val1.*" "read pkru register"
+
+set val2 0x44444444
+gdb_test "print /x \$pkru = $val2" "= $val2" "set pkru value"
+
+set xval $val2
+gdb_test_multiple "info register pkru" "read value after setting value" {
+    -re -wrap ".*pkru.*$val2.*" {
+       pass $gdb_test_name
+    }
+    -re -wrap ".*pkru.*$val1.*" {
+       if { $have_xfail } {
+           xfail $gdb_test_name
+       } else {
+           fail $gdb_test_name
+       }
+       set xval $val1
+    }
+}
 
 gdb_breakpoint [ gdb_get_line_number "break here 2" ]
 gdb_continue_to_breakpoint "break here 2" ".*break here 2.*"
 
-gdb_test "print /x rd_value" "= 0x44444444" "variable after reading pkru"
+gdb_test "print /x rd_value" "= $xval" "variable after reading pkru"
diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp
index ffdfb75557c..294d0998632 100644
--- a/gdb/testsuite/lib/gdb-utils.exp
+++ b/gdb/testsuite/lib/gdb-utils.exp
@@ -72,3 +72,51 @@ proc style {str style} {
     }
     return "\033\\\[${style}m${str}\033\\\[m"
 }
+
+# Compare the version numbers in L1 to those in L2 using OP, and return
+# 1 if the comparison is true.
+
+proc version_compare { l1 op l2 } {
+    set len [llength $l1]
+    if { $len != [llength $l2] } {
+       error "l2 not the same length as l1"
+    }
+
+    switch -exact $op {
+       "=="    -
+       "<"     {}
+       "<="    { return [expr [version_compare $l1 < $l2] \
+                             || [version_compare $l1 == $l2]]}
+       default { error "unsupported op: $op" }
+    }
+
+    # Handle ops < and ==.
+    set idx 0
+    foreach v1 $l1 {
+       set v2 [lindex $l2 $idx]
+       incr idx
+       set last [expr $len == $idx]
+
+       set cmp [expr $v1 $op $v2]
+       if { $op == "==" } {
+           if { $cmp } {
+               continue
+           } else {
+               return 0
+           }
+       } else {
+           # $op == "<".
+           if { $cmp } {
+               return 1
+           } else {
+               if { !$last && $v1 == $v2 } {
+                   continue
+               }
+               return 0
+           }
+       }
+    }
+
+    return 1
+}
+
-- 
2.35.3


++++++ gdb-testsuite-add-xfail-in-gdb.python-py-record-btra.patch ++++++
>From 221ecdef7cc008b01832840d1fbd25d94f8abdd1 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevr...@suse.de>
Date: Tue, 14 Feb 2023 13:15:49 +0100
Subject: [PATCH 04/11] [gdb/testsuite] Add xfail in
 gdb.python/py-record-btrace.exp

There's a HW bug affecting Processor Trace on some Intel processors
(Ice Lake to Raptor Lake microarchitectures).

The bug was exposed by linux kernel commit 670638477aed
("perf/x86/intel/pt: Opportunistically use single range output mode"),
added in version v5.5.0, and was worked around by commit ce0d998be927
("perf/x86/intel/pt: Fix sampling using single range output") in version
6.1.0.

The bug manifests (on a Performance-core of an i7-1250U, an Alder Lake cpu) in
a single test-case:
...
(gdb) python insn = r.instruction_history^M
warning: Decode error (-20) at instruction 33 (offset = 0x3d6a, \
  pc = 0x400501): compressed return without call.^M
(gdb) FAIL: gdb.python/py-record-btrace.exp: prepare record: \
  python insn = r.instruction_history
...

Add a corresponding XFAIL.

Note that the i7-1250U has both Performance-cores and Efficient-cores, and on
an Efficient-Core the test-case runs without any problems, so if the testsuite
run is not pinned to a specific cpu, the test may either PASS or XFAIL.

Tested on x86_64-linux:
- openSUSE Leap 15.4 with linux kernel version 5.14.21
- openSUSE Tumbleweed with linux kernel version 6.1.8

PR testsuite/30075
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30075
---
 gdb/testsuite/gdb.python/py-record-btrace.exp | 43 ++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.python/py-record-btrace.exp 
b/gdb/testsuite/gdb.python/py-record-btrace.exp
index 8204577b866..ca8740bc967 100644
--- a/gdb/testsuite/gdb.python/py-record-btrace.exp
+++ b/gdb/testsuite/gdb.python/py-record-btrace.exp
@@ -64,7 +64,48 @@ with_test_prefix "prepare record" {
     gdb_test "python print(r.method)" "btrace"
     gdb_test "python print(r.format)" "pt|bts"
     gdb_test "stepi 100" ".*"
-    gdb_test_no_output "python insn = r.instruction_history"
+
+    # There's a HW bug affecting Processor Trace on some Intel processors.
+    # The bug was exposed by linux kernel commit 670638477aed
+    # ("perf/x86/intel/pt: Opportunistically use single range output mode"),
+    # added in version v5.5.0, and was worked around by commit ce0d998be927
+    # ("perf/x86/intel/pt: Fix sampling using single range output") in version
+    # 6.1.0.  Detect the kernel version range for which the problem may
+    # manifest.
+    set have_xfail 0
+    set v [linux_kernel_version]
+    if { $v != {} } {
+       set have_xfail \
+           [expr [version_compare [list 5 5 0] <= $v] \
+                && [version_compare $v < [list 6 1 0]]]
+    }
+    set nonl_re \[^\r\n\]
+    set xfail_re \
+       [join \
+            [list \
+                 "warning: Decode error \\($nonl_re*\\) at instruction 
$decimal" \
+                 "\\(offset = $hex, pc = $hex\\):" \
+                 "$nonl_re*\\."]]
+
+    set got_xfail 0
+    set cmd "python insn = r.instruction_history"
+    gdb_test_multiple $cmd "" {
+       -re "^[string_to_regexp $cmd]\r\n$::gdb_prompt $" {
+           pass $gdb_test_name
+       }
+       -re -wrap "$xfail_re" {
+           if { $have_xfail } {
+               xfail $gdb_test_name
+               set got_xfail 1
+           } else {
+               fail $gdb_test_name
+           }
+       }
+    }
+    if { $got_xfail } {
+       return
+    }
+
     gdb_test_no_output "python call = r.function_call_history"
     gdb_test_no_output "python i = insn\[0\]"
     gdb_test_no_output "python c = call\[0\]"
-- 
2.35.3


++++++ gdb-testsuite-factor-out-proc-linux_kernel_version.patch ++++++
>From bbf4e4ba2a9bd73384268b0160d54e36edc92a12 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevr...@suse.de>
Date: Tue, 14 Feb 2023 11:53:54 +0100
Subject: [PATCH 03/11] [gdb/testsuite] Factor out proc linux_kernel_version

Factor out new proc linux_kernel_version from test-case
gdb.arch/i386-pkru.exp.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.arch/i386-pkru.exp | 20 ++++++--------------
 gdb/testsuite/lib/gdb.exp            | 23 +++++++++++++++++++++++
 2 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/gdb/testsuite/gdb.arch/i386-pkru.exp 
b/gdb/testsuite/gdb.arch/i386-pkru.exp
index 5fe93db9b4b..9bc9f9735e5 100644
--- a/gdb/testsuite/gdb.arch/i386-pkru.exp
+++ b/gdb/testsuite/gdb.arch/i386-pkru.exp
@@ -62,20 +62,12 @@ if { !$supports_pkru } {
 # the PKRU using ptrace, see commit 4a804c4f8356 ("x86/fpu: Allow PKRU to be
 # (once again) written by ptrace.").
 set have_xfail 0
-if { [istarget *-*-linux*] } {
-    set res [remote_exec target "uname -r"]
-    set status [lindex $res 0]
-    set output [lindex $res 1]
-
-    set re ^($decimal)\\.($decimal)\\.($decimal)
-    if { $status == 0
-        && [regexp $re $output dummy v1 v2 v3] == 1 } {
-       set v [list $v1 $v2 $v3]
-       set have_xfail \
-           [expr \
-                [version_compare [list 5 14 0] <= $v] \
-                && [version_compare $v < [list 6 2 0]]]
-    }
+set v [linux_kernel_version]
+if { $v != {} } {
+    set have_xfail \
+       [expr \
+            [version_compare [list 5 14 0] <= $v] \
+            && [version_compare $v < [list 6 2 0]]]
 }
 
 # Test pkru register at startup
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 5104835a2a9..069a61038e6 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -8551,5 +8551,28 @@ gdb_caching_proc has_hw_wp_support {
     return $has_hw_wp_support
 }
 
+# Detect linux kernel version and return as list of 3 numbers: major, minor,
+# and patchlevel.  On failure, return an empty list.
+
+gdb_caching_proc linux_kernel_version {
+    if { ![istarget *-*-linux*] } {
+       return {}
+    }
+
+    set res [remote_exec target "uname -r"]
+    set status [lindex $res 0]
+    set output [lindex $res 1]
+    if { $status != 0 } {
+       return {}
+    }
+
+    set re ^($::decimal)\\.($::decimal)\\.($::decimal)
+    if { [regexp $re $output dummy v1 v2 v3] != 1 } {
+       return {}
+    }
+
+    return [list $v1 $v2 $v3]
+}
+
 # Always load compatibility stuff.
 load_lib future.exp
-- 
2.35.3


++++++ gdb-testsuite-fix-gdb.base-break-idempotent.exp-on-ppc.patch ++++++
gdb/testsuite: fix gdb.base/break-idempotent.exp on ppc

When running the gdb.base/break-idempotent.exp test on ppc, I was
seeing some test failures (or rather errors), that looked like this:

  (gdb) watch local
  Hardware watchpoint 2: local

  has_hw_wp_support: Hardware watchpoint detected
  ERROR: no fileid for gcc2-power8
  ERROR: Couldn't send delete breakpoints to GDB.
  ERROR OCCURED: can't read "gdb_spawn_id": no such variable
      while executing
  "expect {
  -i 1000 -timeout 100
          -re ".*A problem internal to GDB has been detected" {
              fail "$message (GDB internal error)"
              gdb_internal_erro..."
      ("uplevel" body line 1)
      invoked from within

What happens is that in break-idempotent.exp we basically do this:

    if {[prepare_for_testing "failed to prepare" $binfile $srcfile $opts]} {
        continue
    }

    # ....

    if {![skip_hw_watchpoint_tests]} {
        test_break $always_inserted "watch"
    }

The problem with this is that skip_hw_watchpoint_tests, includes this:

    if { [istarget "i?86-*-*"]
         || [istarget "x86_64-*-*"]
         || [istarget "ia64-*-*"]
         || [istarget "arm*-*-*"]
         || [istarget "aarch64*-*-*"]
         || ([istarget "powerpc*-*-linux*"] && [has_hw_wp_support])
         || [istarget "s390*-*-*"] } {
        return 0
    }

For powerpc only we call has_hw_wp_support.  This is a caching proc
that runs a test within GDB to detect if we have hardware watchpoint
support or not.

Unfortunately, to run this test we restart GDB, and when the test has
completed, we exit GDB.  This means that in break-idempotent.exp, when
we call skip_hw_watchpoint_tests for the first time on powerpc, GDB
will unexpectedly be exited.  When we later call delete_breakpoints we
see the errors I reported above.

The fix is to call skip_hw_watchpoint_tests early, before we start GDB
as part of the break-idempotent.exp script, and store the result in a
variable, we can then check this variable in the script as needed.

After this change break-idempotent.exp runs fine on powerpc.

Co-authored-by: Andrew Burgess <aburg...@redhat.com>

---
 gdb/testsuite/gdb.base/break-idempotent.exp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/break-idempotent.exp 
b/gdb/testsuite/gdb.base/break-idempotent.exp
index 29002f103a8..837ac000b57 100644
--- a/gdb/testsuite/gdb.base/break-idempotent.exp
+++ b/gdb/testsuite/gdb.base/break-idempotent.exp
@@ -36,6 +36,12 @@
 
 standard_testfile
 
+# The skip_hw_watchpoint_tests starts GDB on a small test program to
+# check if HW watchpoints are supported.  We do not want to restart
+# GDB after this test script has itself started GDB, so call
+# skip_hw_watchpoint_tests first and cache the result.
+set skip_hw_watchpoint_tests_p [skip_hw_watchpoint_tests]
+
 # Force a breakpoint re-set in GDB.  Currently this is done by
 # reloading symbols with the "file" command.
 
@@ -174,7 +180,7 @@ foreach_with_prefix pie { "nopie" "pie" } {
            test_break $always_inserted "hbreak"
        }
 
-       if {![skip_hw_watchpoint_tests]} {
+       if {!$skip_hw_watchpoint_tests_p} {
            test_break $always_inserted "watch"
        }
 

++++++ gdb-testsuite-fix-gdb.base-infoline-reloc-main-from-.patch ++++++
>From 52ce02f7e38ed00f9e42fe4f272787652540c863 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevr...@suse.de>
Date: Wed, 12 Oct 2022 16:50:16 +0200
Subject: [PATCH 08/11] [gdb/testsuite] Fix
 gdb.base/infoline-reloc-main-from-zero.exp with recent ld

On openSUSE Tumbleweed (with ld 2.39) and test-case
gdb.base/infoline-reloc-main-from-zero.exp, I get:
...
gdb compile failed, ld: warning: infoline-reloc-main-from-zero has a LOAD \
  segment with RWX permissions
UNTESTED: gdb.base/infoline-reloc-main-from-zero.exp: \
  infoline-reloc-main-from-zero.exp
...

Fix this by compiling with -Wl,--no-warn-rwx-segments.

Tested on x86_64-linux.
---
 .../gdb.base/infoline-reloc-main-from-zero.exp         | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/infoline-reloc-main-from-zero.exp 
b/gdb/testsuite/gdb.base/infoline-reloc-main-from-zero.exp
index ef5fe8c24bc..a29668c9712 100644
--- a/gdb/testsuite/gdb.base/infoline-reloc-main-from-zero.exp
+++ b/gdb/testsuite/gdb.base/infoline-reloc-main-from-zero.exp
@@ -29,7 +29,15 @@ if [get_compiler_info] {
 
 # Build executable with stripped startup code and text section starting at zero
 
-set opts {debug "additional_flags=-nostdlib -emain -Wl,-Ttext=0x00 -Wl,-N"}
+set opts {}
+lappend opts debug
+lappend opts "additional_flags=-nostdlib -emain -Wl,-Ttext=0x00 -Wl,-N"
+
+set ld_flags additional_flags=-Wl,--no-warn-rwx-segments
+if { [gdb_can_simple_compile ld-flags {int main () { return 0; }} executable \
+         $ld_flags] } {
+    lappend opts $ld_flags
+}
 
 if {[build_executable $testfile.exp $testfile $srcfile $opts] == -1} {
     untested "failed to compile"
-- 
2.35.3


++++++ gdb-testsuite-fix-gdb.base-nested-subp-2-3-.exp-with.patch ++++++
>From a95556346e4336d2d6eeba74430212e833c065fb Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevr...@suse.de>
Date: Wed, 12 Oct 2022 16:50:16 +0200
Subject: [PATCH 10/11] [gdb/testsuite] Fix gdb.base/nested-subp{2,3}.exp with
 recent ld

On openSUSE Tumbleweed (with ld 2.39) I get for test-case
gdb.base/nested-subp2.exp:
...
gdb compile failed, ld: warning: tmp.o: requires executable stack \
  (because the .note.GNU-stack section is executable)
...

Fix this by compiling with -Wl,--no-warn-execstack.

Likewise in gdb.base/nested-subp3.exp

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.base/nested-subp2.exp | 15 ++++++++++++---
 gdb/testsuite/gdb.base/nested-subp3.exp | 15 ++++++++++++---
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/gdb/testsuite/gdb.base/nested-subp2.exp 
b/gdb/testsuite/gdb.base/nested-subp2.exp
index 876b797e49d..8cb57bd1ee7 100644
--- a/gdb/testsuite/gdb.base/nested-subp2.exp
+++ b/gdb/testsuite/gdb.base/nested-subp2.exp
@@ -29,10 +29,19 @@ if ![support_nested_function_tests] {
     return -1
 }
 
+set flags {}
+lappend flags debug
+lappend flags additional_flags=-std=gnu99
+
+set ld_flags additional_flags=-Wl,--no-warn-execstack
+if { [gdb_can_simple_compile ld-flags {int main () { return 0; }} executable \
+         $ld_flags] } {
+    lappend flags $ld_flags
+}
+
 if { [gdb_compile "${srcdir}/${subdir}/${testcase}.c" \
-                  [standard_output_file "${testcase}"] \
-                  executable \
-                  [list debug "additional_flags=-std=gnu99"]] != "" } {
+         [standard_output_file "${testcase}"] \
+         executable $flags] != "" } {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/nested-subp3.exp 
b/gdb/testsuite/gdb.base/nested-subp3.exp
index dd236f07c8f..31da8d47f84 100644
--- a/gdb/testsuite/gdb.base/nested-subp3.exp
+++ b/gdb/testsuite/gdb.base/nested-subp3.exp
@@ -29,10 +29,19 @@ if ![support_nested_function_tests] {
     return -1
 }
 
+set flags {}
+lappend flags debug
+lappend flags additional_flags=-std=gnu99
+
+set ld_flags additional_flags=-Wl,--no-warn-execstack
+if { [gdb_can_simple_compile ld-flags {int main () { return 0; }} executable \
+         $ld_flags] } {
+    lappend flags $ld_flags
+}
+
 if { [gdb_compile "${srcdir}/${subdir}/${testcase}.c" \
-                  [standard_output_file "${testcase}"] \
-                  executable \
-                  [list debug "additional_flags=-std=gnu99"]] != "" } {
+         [standard_output_file "${testcase}"] \
+         executable $flags] != "" } {
     return -1
 }
 
-- 
2.35.3


++++++ gdb-testsuite-fix-gdb.dwarf2-dw2-dir-file-name.exp-w.patch ++++++
>From 7ba9d8dda33a985a97c9ab922b84b894ffb2e288 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevr...@suse.de>
Date: Thu, 16 Feb 2023 13:56:07 +0100
Subject: [PATCH 11/11] [gdb/testsuite] Fix gdb.dwarf2/dw2-dir-file-name.exp
 with recent ld

---
 gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp 
b/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp
index 4d3f767f597..1fc34ef387b 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-dir-file-name.exp
@@ -317,6 +317,8 @@ puts -nonewline $f "\
        .byte           0x0                     /* Terminator */
 "
 
+puts -nonewline $f "\t.section\t.note.GNU-stack,\"\",@progbits"
+
 close $f
 
 set opts {}
-- 
2.35.3


++++++ gdb-testsuite-fix-gdb.threads-schedlock.exp-for-gcc-.patch ++++++
>From f168a48adf97a36c88c65a075b42e6b7083063df Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevr...@suse.de>
Date: Mon, 20 Feb 2023 11:16:02 +0100
Subject: [PATCH] [gdb/testsuite] Fix gdb.threads/schedlock.exp for gcc 4.8.5

Since commit 9af467b8240 ("[gdb/testsuite] Fix gdb.threads/schedlock.exp on
fast cpu"), the test-case fails for gcc 4.8.5.

The problem is that for gcc 4.8.5, the commit turned a two-line loop:
...
(gdb) next
78          while (*myp > 0)
(gdb) next
81              MAYBE_CALL_SOME_FUNCTION(); (*myp) ++;
(gdb) next
78          while (*myp > 0)
...
into a three-line loop:
...
(gdb) next
83              MAYBE_CALL_SOME_FUNCTION(); (*myp) ++;
(gdb) next
84              cnt++;
(gdb) next
85            }
(gdb) next
83              MAYBE_CALL_SOME_FUNCTION(); (*myp) ++;
(gdb)
...
and the test-case doesn't expect this.

Fix this by reverting back to the original loop shape as much as possible by:
- removing the cnt++ line
- replacing "while (1)" with "while (one)", where one is a volatile variable
  set to 1.

Tested on x86_64-linux, using compilers:
- gcc 4.8.5, 7.5.0, 12.2.1
- clang 4.0.1, 13.0.1
---
 gdb/testsuite/gdb.threads/schedlock.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/gdb/testsuite/gdb.threads/schedlock.c 
b/gdb/testsuite/gdb.threads/schedlock.c
index 9859885b1a3..af3ca3e4c87 100644
--- a/gdb/testsuite/gdb.threads/schedlock.c
+++ b/gdb/testsuite/gdb.threads/schedlock.c
@@ -75,13 +75,12 @@ volatile int call_function = 0;
 void *thread_function(void *arg) {
     int my_number =  (long) arg;
     unsigned long long int *myp = (unsigned long long int *) &args[my_number];
-    volatile unsigned int cnt = 0;
+    volatile unsigned int one = 1;
 
-    while (1)
+    while (one)
       {
        /* schedlock.exp: main loop.  */
        MAYBE_CALL_SOME_FUNCTION(); (*myp) ++;
-       cnt++;
       }
 
     pthread_exit(NULL);

base-commit: 4d69e6ec1a8ddd008f34af363dab73c014823074
-- 
2.35.3


++++++ gdb-testsuite-fix-gdb.threads-schedlock.exp-on-fast-.patch ++++++
>From c25a24cc237721c51034f4425183f73e97cdccc1 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevr...@suse.de>
Date: Mon, 6 Feb 2023 12:52:50 +0100
Subject: [PATCH 06/11] [gdb/testsuite] Fix gdb.threads/schedlock.exp on fast
 cpu

Occasionally, I run into:
...
(gdb) PASS: gdb.threads/schedlock.exp: schedlock=on: cmd=continue: \
  set scheduler-locking on
continue^M
Continuing.^M
PASS: gdb.threads/schedlock.exp: schedlock=on: cmd=continue: \
  continue (with lock)
[Thread 0x7ffff746e700 (LWP 1339) exited]^M
No unwaited-for children left.^M
(gdb) Quit^M
(gdb) FAIL: gdb.threads/schedlock.exp: schedlock=on: cmd=continue: \
  stop all threads (with lock) (timeout)
...

What happens is that this loop which is supposed to run "just short of forever":
...
    /* Don't run forever.  Run just short of it :)  */
    while (*myp > 0)
      {
        /* schedlock.exp: main loop.  */
        MAYBE_CALL_SOME_FUNCTION(); (*myp) ++;
      }
...
finishes after 0x7fffffff iterations (when a signed wrap occurs), which on my
system takes only about 1.5 seconds.

Fix this by:
- changing the pointed-at type of myp from signed to unsigned, which makes the
  wrap defined behaviour (and which also make the loop run twice as long,
  which is already enough to make it impossible for me to reproduce the FAIL.
  But let's try to solve this more structurally).
- changing the pointed-at type of myp from int to long long, making the wrap
  unlikely.
- making sure the loop runs forever, by setting the loop condition to 1.
- making sure the loop still contains different lines (as far as debug info is
  concerned) by incrementing a volatile counter in the loop.
- making sure the program doesn't run forever in case of trouble, by adding an
  "alarm (30)".

Tested on x86_64-linux.

PR testsuite/30074
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30074
---
 gdb/testsuite/gdb.threads/schedlock.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/gdb.threads/schedlock.c 
b/gdb/testsuite/gdb.threads/schedlock.c
index 7672140fdc8..9859885b1a3 100644
--- a/gdb/testsuite/gdb.threads/schedlock.c
+++ b/gdb/testsuite/gdb.threads/schedlock.c
@@ -24,7 +24,7 @@ void *thread_function(void *arg); /* Pointer to function 
executed by each thread
 
 #define NUM 1
 
-unsigned int args[NUM+1];
+unsigned long long int args[NUM+1];
 
 int main() {
     int res;
@@ -32,6 +32,8 @@ int main() {
     void *thread_result;
     long i;
 
+    alarm (30);
+
     for (i = 1; i <= NUM; i++)
       {
        args[i] = 1;
@@ -72,13 +74,14 @@ volatile int call_function = 0;
 
 void *thread_function(void *arg) {
     int my_number =  (long) arg;
-    int *myp = (int *) &args[my_number];
+    unsigned long long int *myp = (unsigned long long int *) &args[my_number];
+    volatile unsigned int cnt = 0;
 
-    /* Don't run forever.  Run just short of it :)  */
-    while (*myp > 0)
+    while (1)
       {
        /* schedlock.exp: main loop.  */
        MAYBE_CALL_SOME_FUNCTION(); (*myp) ++;
+       cnt++;
       }
 
     pthread_exit(NULL);
-- 
2.35.3


++++++ gdb-testsuite-handle-missing-.note.gnu-stack.patch ++++++
++++ 1405 lines (skipped)

++++++ gdb-testsuite-refactor-gdb.threads-detach-step-over.exp.patch ++++++
gdb/testsuite: refactor gdb.threads/detach-step-over.exp

Factor out some bits of gdb.threads/detach-step-over.exp to procs in
preparation to adding some new variations of the test.  Rename the
existing "test" proc and make it use proc_with_prefix.

Co-Authored-By: Simon Marchi <simon.mar...@efficios.com>
Change-Id: Ib4412545c81c8556029e0f7bfa9dd48d7a9f3189

---
 gdb/testsuite/gdb.threads/detach-step-over.exp | 238 ++++++++++++++-----------
 1 file changed, 138 insertions(+), 100 deletions(-)

diff --git a/gdb/testsuite/gdb.threads/detach-step-over.exp 
b/gdb/testsuite/gdb.threads/detach-step-over.exp
index 917be2ef378..ad9b08f549e 100644
--- a/gdb/testsuite/gdb.threads/detach-step-over.exp
+++ b/gdb/testsuite/gdb.threads/detach-step-over.exp
@@ -56,11 +56,11 @@ standard_testfile
 
 set bp_lineno [gdb_get_line_number "Set breakpoint here"]
 
-# The test proper.  See description above.
-proc test {condition_eval target_non_stop non_stop displaced} {
-    # Number of threads started by the program.
-    set n_threads 10
+# Number of threads started by the program.
+set n_threads 10
 
+# Start GDB, configuring various settings according to the arguments.
+proc start_gdb_for_test {condition_eval target_non_stop non_stop displaced} {
     save_vars { ::GDBFLAGS } {
        append ::GDBFLAGS " -ex \"maint set target-non-stop $target_non_stop\""
        append ::GDBFLAGS " -ex \"set non-stop $non_stop\""
@@ -69,10 +69,137 @@ proc test {condition_eval target_non_stop non_stop 
displaced} {
        clean_restart $::binfile
     }
 
+    gdb_test_no_output "set breakpoint condition-evaluation $condition_eval"
+}
+
+# Use the 'attach' command to attach to process with pid TESTPID.  Return true
+# if we believe GDB has attached and we are back at the GDB prompt, otherwise,
+# return false.
+proc attach_to {testpid} {
+    with_timeout_factor 2 {
+       set attached 0
+       set saw_attaching 0
+       gdb_test_multiple "attach $testpid" "attach" {
+           -re "Attaching to program.*process $testpid\r\n" {
+               set saw_attaching 1
+               exp_continue
+           }
+           -re "new threads in iteration" {
+               # Seen when "set debug libthread_db" is on.
+               exp_continue
+           }
+           -re "Reading symbols from|Expanding full symbols from" {
+               # Prevent -readnow timeout.
+               exp_continue
+           }
+           -re "is a zombie - the process has already 
terminated.*$::gdb_prompt " {
+               fail $gdb_test_name
+           }
+           -re "Unable to attach: .*$::gdb_prompt " {
+               fail $gdb_test_name
+           }
+           -re "\r\n$::gdb_prompt " {
+               if { $saw_attaching } {
+                   set attached 1
+                   pass $gdb_test_name
+               } else {
+                   fail $gdb_test_name
+               }
+           }
+       }
+    }
+
+    return $attached
+}
+
+# After attaching to a multi-threaded inferior in non-stop mode, we expect to
+# see a stop message from each thread.  This proc waits for all of these stop
+# messages.  TID_RE is a regexp used to match the thread-id of the stopped
+# thread.
+#
+# Return true if we saw a stop from each of the expected threads (based on the
+# global N_THREADS value), otherwise, return false.
+proc check_stops_after_non_stop_attach {tid_re} {
+    set any "\[^\r\n\]*"
+
+    # In non-stop, we will see one stop per thread after the prompt.
+    set stops 0
+    set test "seen all stops"
+    for {set thread 1} { $thread <= $::n_threads } { incr thread } {
+       if {[gdb_test_multiple "" $test {
+           -re "Thread ${tid_re} ${any} stopped" {
+               incr stops
+           }
+       }] != 0} {
+           break
+       }
+    }
+
+    # If we haven't seen all stops, then the
+    # gdb_test_multiple in the loop above will have
+    # already issued a FAIL.
+    if {$stops != $::n_threads} {
+       return false
+    }
+    pass $test
+    return true
+}
+
+# Prepare for a single test iteration.  TESTPID is the pid of the process GDB
+# will be attached too.  NON_STOP indicates if GDB is configured in non-stop
+# mode or not.  ATTEMPT is the current attempt number, and ATTEMPTS is the
+# maximum number of attempts we plan to run.  TID_RE is a string used to match
+# against a thread-id in GDB's stop messages.
+#
+# Return true if everything is prepared correctly, otherwise return false.
+proc prepare_test_iter {testpid non_stop attempt attempts tid_re} {
+    if {![attach_to $testpid]} {
+       return false
+    }
+
+    if {$non_stop} {
+       if {![check_stops_after_non_stop_attach $tid_re]} {
+           return false
+       }
+    }
+
+    gdb_test "break ${::srcfile}:${::bp_lineno} if 0" "Breakpoint.*" \
+       "break LOC if 0"
+
+    if {$attempt < $attempts} {
+       # Kick the time out timer for another round.
+       gdb_test "print again = 1" " = 1" "reset timer in the inferior"
+       # Show the time we had left in the logs, in case
+       # something goes wrong.
+       gdb_test "print seconds_left" " = .*"
+    }
+
+    if {$non_stop} {
+       set cont_cmd "continue -a &"
+    } else {
+       set cont_cmd "continue &"
+    }
+
+    set cont_cmd_re [string_to_regexp $cont_cmd]
+    gdb_test_multiple $cont_cmd "" {
+       -re "^$cont_cmd_re\r\nContinuing\.\r\n$::gdb_prompt " {
+           pass $gdb_test_name
+       }
+    }
+
+    # Wait a bit, to give time for the threads to hit the
+    # breakpoint.
+    sleep 1
+
+    return true
+}
+
+# The test proper.  See the description at the top of the file.
+proc_with_prefix test_detach_command {condition_eval target_non_stop non_stop 
displaced} {
     set test_spawn_id [spawn_wait_for_attach $::binfile]
     set testpid [spawn_id_get_pid $test_spawn_id]
 
-    set any "\[^\r\n\]*"
+    start_gdb_for_test $condition_eval $target_non_stop $non_stop $displaced
 
     gdb_test "add-inferior" "Added inferior 2.*"
     gdb_test "inferior 2" "Switching to .*"
@@ -84,8 +211,6 @@ proc test {condition_eval target_non_stop non_stop 
displaced} {
        return
     }
 
-    gdb_test_no_output "set breakpoint condition-evaluation $condition_eval"
-
     # Get the PID of the test process.
     set pid_inf2 ""
     gdb_test_multiple "p mypid" "get pid of inferior 2" {
@@ -100,101 +225,12 @@ proc test {condition_eval target_non_stop non_stop 
displaced} {
        with_test_prefix "iter $attempt" {
            gdb_test "inferior 1" "Switching to .*"
 
-           with_timeout_factor 2 {
-               set attached 0
-               set saw_attaching 0
-               set eperm 0
-               set test "attach"
-               gdb_test_multiple "attach $testpid" $test {
-                   -re "Attaching to program.*process $testpid\r\n" {
-                       set saw_attaching 1
-                       exp_continue
-                   }
-                   -re "new threads in iteration" {
-                       # Seen when "set debug libthread_db" is on.
-                       exp_continue
-                   }
-                   -re "Reading symbols from|Expanding full symbols from" {
-                       # Prevent -readnow timeout.
-                       exp_continue
-                   }
-                   -re "is a zombie - the process has already 
terminated.*$::gdb_prompt " {
-                       fail $gdb_test_name
-                   }
-                   -re "Unable to attach: .*$::gdb_prompt " {
-                       fail $gdb_test_name
-                   }
-                   -re "\r\n$::gdb_prompt " {
-                       if { $saw_attaching } {
-                           set attached 1
-                           pass $test
-                       } else {
-                           fail $test
-                       }
-                   }
-               }
-           }
-
-           if {!$attached} {
+           if {![prepare_test_iter $testpid $non_stop \
+                     $attempt $attempts "$::decimal\.$::decimal"]} {
                kill_wait_spawned_process $test_spawn_id
                return
            }
 
-           if {$non_stop} {
-               # In non-stop, we will see one stop per thread after
-               # the prompt.
-               set stops 0
-               set tid_re "$::decimal\.$::decimal"
-               set test "seen all stops"
-               for {set thread 1} { $thread <= $n_threads } { incr thread } {
-                   if {[gdb_test_multiple "" $test {
-                       -re "Thread ${tid_re} ${any} stopped" {
-                           incr stops
-                       }
-                   }] != 0} {
-                       break
-                   }
-               }
-
-               # If we haven't seen all stops, then the
-               # gdb_test_multiple in the loop above will have
-               # already issued a FAIL.
-               if {$stops != $n_threads} {
-                   kill_wait_spawned_process $test_spawn_id
-                   return
-               }
-               pass $test
-           }
-
-           # Set threads stepping over a breakpoint continuously.
-           gdb_test "break $::srcfile:$::bp_lineno if 0" "Breakpoint.*" \
-               "break LOC if 0"
-
-           if {$attempt < $attempts} {
-               # Kick the time out timer for another round.
-               gdb_test "print again = 1" " = 1" "reset timer in the inferior"
-               # Show the time we had left in the logs, in case
-               # something goes wrong.
-               gdb_test "print seconds_left" " = .*"
-           }
-
-           if {$non_stop} {
-               set cont_cmd "continue -a &"
-           } else {
-               set cont_cmd "continue &"
-           }
-
-           set cont_cmd_re [string_to_regexp $cont_cmd]
-           gdb_test_multiple $cont_cmd "" {
-               -re "^$cont_cmd_re\r\nContinuing\.\r\n$::gdb_prompt " {
-                   pass $gdb_test_name
-               }
-           }
-
-           # Wait a bit, to give time for the threads to hit the
-           # breakpoint.
-           sleep 1
-
            set running_count 0
            set interrupted 0
            gdb_test_multiple "info threads" "all threads running" {
@@ -219,7 +255,8 @@ proc test {condition_eval target_non_stop non_stop 
displaced} {
                    }
                }
                -re "$::gdb_prompt $" {
-                   gdb_assert {$running_count == ($n_threads + 1) * 2} 
$gdb_test_name
+                   gdb_assert {$running_count == ($::n_threads + 1) * 2} \
+                       $gdb_test_name
                }
            }
 
@@ -292,7 +329,8 @@ foreach_with_prefix breakpoint-condition-evaluation {"host" 
"target"} {
            }
 
            foreach_with_prefix displaced {"off" "auto"} {
-               test ${breakpoint-condition-evaluation} ${target-non-stop} 
${non-stop} ${displaced}
+               test_detach_command ${breakpoint-condition-evaluation} \
+                   ${target-non-stop} ${non-stop} ${displaced}
            }
        }
     }

++++++ 
gdb-testsuite-remove-global-declarations-in-gdb.threads-detach-step-over.exp.patch
 ++++++
gdb/testsuite: remove global declarations in gdb.threads/detach-step-over.exp

Before doing further changes to this file, change to use the :: notation
instead of declaring global variables with the `global` keyword.

Change-Id: I72301fd8f4693fea61aac054ba17245a1f4442fb
Approved-By: Andrew Burgess <aburg...@redhat.com>

---
 gdb/testsuite/gdb.threads/detach-step-over.exp | 40 +++++++++++---------------
 1 file changed, 17 insertions(+), 23 deletions(-)

diff --git a/gdb/testsuite/gdb.threads/detach-step-over.exp 
b/gdb/testsuite/gdb.threads/detach-step-over.exp
index 15af7e0e723..917be2ef378 100644
--- a/gdb/testsuite/gdb.threads/detach-step-over.exp
+++ b/gdb/testsuite/gdb.threads/detach-step-over.exp
@@ -58,24 +58,18 @@ set bp_lineno [gdb_get_line_number "Set breakpoint here"]
 
 # The test proper.  See description above.
 proc test {condition_eval target_non_stop non_stop displaced} {
-    global binfile srcfile
-    global gdb_prompt
-    global decimal
-    global bp_lineno
-    global GDBFLAGS
-
     # Number of threads started by the program.
     set n_threads 10
 
-    save_vars { GDBFLAGS } {
-       append GDBFLAGS " -ex \"maint set target-non-stop $target_non_stop\""
-       append GDBFLAGS " -ex \"set non-stop $non_stop\""
-       append GDBFLAGS " -ex \"set displaced $displaced\""
-       append GDBFLAGS " -ex \"set schedule-multiple on\""
-       clean_restart $binfile
+    save_vars { ::GDBFLAGS } {
+       append ::GDBFLAGS " -ex \"maint set target-non-stop $target_non_stop\""
+       append ::GDBFLAGS " -ex \"set non-stop $non_stop\""
+       append ::GDBFLAGS " -ex \"set displaced $displaced\""
+       append ::GDBFLAGS " -ex \"set schedule-multiple on\""
+       clean_restart $::binfile
     }
 
-    set test_spawn_id [spawn_wait_for_attach $binfile]
+    set test_spawn_id [spawn_wait_for_attach $::binfile]
     set testpid [spawn_id_get_pid $test_spawn_id]
 
     set any "\[^\r\n\]*"
@@ -83,7 +77,7 @@ proc test {condition_eval target_non_stop non_stop displaced} 
{
     gdb_test "add-inferior" "Added inferior 2.*"
     gdb_test "inferior 2" "Switching to .*"
 
-    gdb_load $binfile
+    gdb_load $::binfile
     if ![runto setup_done] then {
        fail "can't run to setup_done"
        kill_wait_spawned_process $test_spawn_id
@@ -95,7 +89,7 @@ proc test {condition_eval target_non_stop non_stop displaced} 
{
     # Get the PID of the test process.
     set pid_inf2 ""
     gdb_test_multiple "p mypid" "get pid of inferior 2" {
-       -re " = ($decimal)\r\n$gdb_prompt $" {
+       -re " = ($::decimal)\r\n$::gdb_prompt $" {
            set pid_inf2 $expect_out(1,string)
            pass $gdb_test_name
        }
@@ -124,13 +118,13 @@ proc test {condition_eval target_non_stop non_stop 
displaced} {
                        # Prevent -readnow timeout.
                        exp_continue
                    }
-                   -re "is a zombie - the process has already 
terminated.*$gdb_prompt " {
+                   -re "is a zombie - the process has already 
terminated.*$::gdb_prompt " {
                        fail $gdb_test_name
                    }
-                   -re "Unable to attach: .*$gdb_prompt " {
+                   -re "Unable to attach: .*$::gdb_prompt " {
                        fail $gdb_test_name
                    }
-                   -re "\r\n$gdb_prompt " {
+                   -re "\r\n$::gdb_prompt " {
                        if { $saw_attaching } {
                            set attached 1
                            pass $test
@@ -173,7 +167,7 @@ proc test {condition_eval target_non_stop non_stop 
displaced} {
            }
 
            # Set threads stepping over a breakpoint continuously.
-           gdb_test "break $srcfile:$bp_lineno if 0" "Breakpoint.*" \
+           gdb_test "break $::srcfile:$::bp_lineno if 0" "Breakpoint.*" \
                "break LOC if 0"
 
            if {$attempt < $attempts} {
@@ -192,7 +186,7 @@ proc test {condition_eval target_non_stop non_stop 
displaced} {
 
            set cont_cmd_re [string_to_regexp $cont_cmd]
            gdb_test_multiple $cont_cmd "" {
-               -re "^$cont_cmd_re\r\nContinuing\.\r\n$gdb_prompt " {
+               -re "^$cont_cmd_re\r\nContinuing\.\r\n$::gdb_prompt " {
                    pass $gdb_test_name
                }
            }
@@ -208,14 +202,14 @@ proc test {condition_eval target_non_stop non_stop 
displaced} {
                    incr running_count
                    exp_continue
                }
-               -re "Cannot execute this command while the target is 
running.*$gdb_prompt $" {
+               -re "Cannot execute this command while the target is 
running.*$::gdb_prompt $" {
                    # Testing against a remote server that doesn't do
                    # non-stop mode.  Explicitly interrupt.  This
                    # doesn't test the same code paths in GDB, but
                    # it's still something.
                    set interrupted 1
                    gdb_test_multiple "interrupt" "" {
-                       -re "$gdb_prompt " {
+                       -re "$::gdb_prompt " {
                            gdb_test_multiple "" $gdb_test_name {
                                -re "received signal SIGINT, Interrupt" {
                                    pass $gdb_test_name
@@ -224,7 +218,7 @@ proc test {condition_eval target_non_stop non_stop 
displaced} {
                        }
                    }
                }
-               -re "$gdb_prompt $" {
+               -re "$::gdb_prompt $" {
                    gdb_assert {$running_count == ($n_threads + 1) * 2} 
$gdb_test_name
                }
            }

++++++ gdb-testsuite-simplify-gdb.arch-amd64-disp-step-avx..patch ++++++
>From b40f43e9fd3e523c0c4b50b0dcd8ca743cb6b9a7 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevr...@suse.de>
Date: Fri, 17 Feb 2023 15:33:18 +0100
Subject: [PATCH] [gdb/testsuite] Simplify gdb.arch/amd64-disp-step-avx.exp

On SLE-11, with glibc 2.11.3, I run into:
...
(gdb) PASS: gdb.arch/amd64-disp-step-avx.exp: vex3: \
  var128 has expected value after
continue^M
Continuing.^M
^M
Program received signal SIGSEGV, Segmentation fault.^M
0x0000000000400283 in _exit (status=0) at \
  ../sysdeps/unix/sysv/linux/_exit.c:33^M
33      ../sysdeps/unix/sysv/linux/_exit.c: No such file or directory.^M
(gdb) FAIL: gdb.arch/amd64-disp-step-avx.exp: \
  continue until exit at amd64-disp-step-avx
...

This is not related to gdb, we get the same result by just running the exec.

The problem is that the test-case:
- calls glibc's _exit, and
- uses -nostartfiles -static, putting the burden for any necessary
  initialization for calling glibc's _exit on the test-case itself.

So, when we get to the second insn in _exit:
...
000000000040acb0 <_exit>:
  40acb0:       48 63 d7                movslq %edi,%rdx
  40acb3:       64 4c 8b 14 25 00 00    mov    %fs:0x0,%r10
...
no glibc-related initialization is done, and we run into the segfault.

Adding this (borrowed from __libc_start_main) in _start in the .S file is
sufficient to fix it:
...
         .rept 200
         nop
+        call __pthread_initialize_minimal
         .endr
...
But that already doesn't compile with say glibc 2.31, and regardless I think
this sort of fix is too fragile.

We could of course fix this by simply not running to exit.  But ideally we'd
have an exec that doesn't segfault when you just run it.

Alternatively, we could hand-code an _exit syscall and bypass glibc
all together.  But I'd rather fix this in a way that simplifies the test-case.

Taking a step back, the -nostartfiles -static was added to address that the
xmm registers were not zero at main (which AFAICT is a valid thing to happen).

[ The change itself silently broke the test-case, needing further fixing by
commit 40310f30a51 ("gdb: make gdb.arch/amd64-disp-step-avx.exp actually test
displaced stepping"). ]

Instead, simplify things by reverting to the original situation:
- no -nostartfiles -static compilation flags,
- no _start in the .S file,
- use exit instead of _exit in the .S file,
and fix the original problem by setting the xmm registers to zero rather than
checking that they're zero.

Now that we're no longer forcing -static, add nopie to the flags to prevent
compilation failure with target board unix/-fPIE/-pie.

Tested on x86_64-linux.

PR testsuite/30132
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30132
---
 gdb/testsuite/gdb.arch/amd64-disp-step-avx.S   | 12 ++----------
 gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp | 14 ++++----------
 2 files changed, 6 insertions(+), 20 deletions(-)

diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step-avx.S 
b/gdb/testsuite/gdb.arch/amd64-disp-step-avx.S
index 924deef224f..b39ee9f6567 100644
--- a/gdb/testsuite/gdb.arch/amd64-disp-step-avx.S
+++ b/gdb/testsuite/gdb.arch/amd64-disp-step-avx.S
@@ -19,15 +19,7 @@
    instructions.  */
 
        .text
-
-       .global _start,main
-_start:
-       # The area at _start is used as the displaced stepping buffer.  Put
-       # more than enough nop instructions so that the instructions under test
-       # below don't conflict with it.
-       .rept 200
-       nop
-       .endr
+       .global main
 main:
         nop
 
@@ -66,7 +58,7 @@ ro_var:
 
 done:
        mov $0,%rdi
-       call _exit
+       call exit
        hlt
 
 /* RIP-relative data for VEX3 test above.  */
diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp 
b/gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp
index a64c85bc0e9..e6bdc3c242f 100644
--- a/gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp
+++ b/gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp
@@ -30,9 +30,7 @@ if { ![have_avx] } {
 
 standard_testfile .S
 
-set options [list debug \
-                additional_flags=-static \
-                additional_flags=-nostartfiles]
+set options [list debug nopie]
 if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $options] 
} {
     return -1
 }
@@ -111,14 +109,10 @@ proc disp_step_func { func } {
 
 # Test a VEX2-encoded RIP-relative instruction.
 with_test_prefix "vex2" {
-    # This test writes to the 'xmm0' register.  As the test is
-    # statically linked, we know that the XMM registers should all
-    # have the default value of 0 at this point in time.  We're about
-    # to run an AVX instruction that will modify $xmm0, but lets first
-    # confirm that all XMM registers are 0.
+    # Initialize all XMM registers to 0.
     for {set i 0 } { $i < 16 } { incr i } {
-       gdb_test "p /x \$xmm${i}.uint128" " = 0x0" \
-           "xmm${i} has expected value before"
+       gdb_test_no_output "set \$xmm${i}.uint128 = 0" \
+           "xmm${i} set to zero"
     }
 
     disp_step_func "test_rip_vex2"

base-commit: 8f25c476588b41f18ef7b026c81a6b415a809930
-- 
2.35.3


++++++ gdbserver-switch-to-right-process-in-find_one_thread.patch ++++++
gdbserver: switch to right process in find_one_thread

New in this version: add a dedicated test.

When I do this:

    $ ./gdb -nx --data-directory=data-directory -q \
        /bin/sleep \
        -ex "maint set target-non-stop on" \
        -ex "tar ext :1234" \
        -ex "set remote exec-file /bin/sleep" \
        -ex "run 1231 &" \
        -ex add-inferior \
        -ex "inferior 2"
    Reading symbols from /bin/sleep...
    (No debugging symbols found in /bin/sleep)
    Remote debugging using :1234
    Starting program: /bin/sleep 1231
    Reading /lib64/ld-linux-x86-64.so.2 from remote target...
    warning: File transfers from remote targets can be slow. Use "set sysroot" 
to access files locally instead.
    Reading /lib64/ld-linux-x86-64.so.2 from remote target...
    Reading 
/usr/lib/debug/.build-id/a6/7a1408f18db3576757eea210d07ba3fc560dff.debug from 
remote target...
    [New inferior 2]
    Added inferior 2 on connection 1 (extended-remote :1234)
    [Switching to inferior 2 [<null>] (<noexec>)]
    (gdb) Reading /lib/x86_64-linux-gnu/libc.so.6 from remote target...
    attach 3659848
    Attaching to process 3659848
    /home/smarchi/src/binutils-gdb/gdb/thread.c:85: internal-error: 
inferior_thread: Assertion `current_thread_ != nullptr' failed.

Note the "attach" command just above.  When doing it on the command-line
with a -ex switch, the bug doesn't trigger.

The internal error of GDB is actually caused by GDBserver crashing, and
the error recovery of GDB is not on point.  This patch aims to fix just
the GDBserver crash, not the GDB problem.

GDBserver crashes with a segfault here:

    (gdb) bt
    #0  0x00005555557fb3f4 in find_one_thread (ptid=...) at 
/home/smarchi/src/binutils-gdb/gdbserver/thread-db.cc:177
    #1  0x00005555557fd5cf in thread_db_thread_handle (ptid=<error reading 
variable: Cannot access memory at address 0xffffffffffffffa0>, 
handle=0x7fffffffc400, handle_len=0x7fffffffc3f0)
        at /home/smarchi/src/binutils-gdb/gdbserver/thread-db.cc:461
    #2  0x000055555578a0b6 in linux_process_target::thread_handle 
(this=0x5555558a64c0 <the_x86_target>, ptid=<error reading variable: Cannot 
access memory at address 0xffffffffffffffa0>, handle=0x7fffffffc400,
        handle_len=0x7fffffffc3f0) at 
/home/smarchi/src/binutils-gdb/gdbserver/linux-low.cc:6905
    #3  0x00005555556dfcc6 in handle_qxfer_threads_worker 
(thread=0x60b000000510, buffer=0x7fffffffc8a0) at 
/home/smarchi/src/binutils-gdb/gdbserver/server.cc:1645
    #4  0x00005555556e00e6 in operator() (__closure=0x7fffffffc5e0, 
thread=0x60b000000510) at 
/home/smarchi/src/binutils-gdb/gdbserver/server.cc:1696
    #5  0x00005555556f54be in 
for_each_thread<handle_qxfer_threads_proper(buffer*)::<lambda(thread_info*)> 
>(struct {...}) (func=...) at 
/home/smarchi/src/binutils-gdb/gdbserver/gdbthread.h:159
    #6  0x00005555556e0242 in handle_qxfer_threads_proper 
(buffer=0x7fffffffc8a0) at 
/home/smarchi/src/binutils-gdb/gdbserver/server.cc:1694
    #7  0x00005555556e04ba in handle_qxfer_threads (annex=0x629000000213 "", 
readbuf=0x621000019100 '\276' <repeats 200 times>..., writebuf=0x0, offset=0, 
len=4097)
        at /home/smarchi/src/binutils-gdb/gdbserver/server.cc:1732
    #8  0x00005555556e1989 in handle_qxfer (own_buf=0x629000000200 
"qXfer:threads", packet_len=26, new_packet_len_p=0x7fffffffd630) at 
/home/smarchi/src/binutils-gdb/gdbserver/server.cc:2045
    #9  0x00005555556e720a in handle_query (own_buf=0x629000000200 
"qXfer:threads", packet_len=26, new_packet_len_p=0x7fffffffd630) at 
/home/smarchi/src/binutils-gdb/gdbserver/server.cc:2685
    #10 0x00005555556f1a01 in process_serial_event () at 
/home/smarchi/src/binutils-gdb/gdbserver/server.cc:4176
    #11 0x00005555556f4457 in handle_serial_event (err=0, client_data=0x0) at 
/home/smarchi/src/binutils-gdb/gdbserver/server.cc:4514
    #12 0x0000555555820f56 in handle_file_event (file_ptr=0x607000000250, 
ready_mask=1) at /home/smarchi/src/binutils-gdb/gdbsupport/event-loop.cc:573
    #13 0x0000555555821895 in gdb_wait_for_event (block=1) at 
/home/smarchi/src/binutils-gdb/gdbsupport/event-loop.cc:694
    #14 0x000055555581f533 in gdb_do_one_event (mstimeout=-1) at 
/home/smarchi/src/binutils-gdb/gdbsupport/event-loop.cc:264
    #15 0x00005555556ec9fb in start_event_loop () at 
/home/smarchi/src/binutils-gdb/gdbserver/server.cc:3512
    #16 0x00005555556f0769 in captured_main (argc=4, argv=0x7fffffffe0d8) at 
/home/smarchi/src/binutils-gdb/gdbserver/server.cc:3992
    #17 0x00005555556f0e3f in main (argc=4, argv=0x7fffffffe0d8) at 
/home/smarchi/src/binutils-gdb/gdbserver/server.cc:4078

The reason is a wrong current process when find_one_thread is called.
The current process is the 2nd one, which was just attached.  It does
not yet have thread_db data (proc->priv->thread_db is nullptr).  As we
iterate on all threads of all process to fulfull the qxfer:threads:read
request, we get to a thread of process 1 for which we haven't read
thread_db information yet (lwp_info::thread_known is false), so we get
into find_one_thread.  find_one_thread uses
`current_process ()->priv->thread_db`, assuming the current process
matches the ptid passed as a parameter, which is wrong.  A segfault
happens when trying to dereference that thread_db pointer.

Fix this by making find_one_thread not assume what the current process /
current thread is.  If it needs to call into libthread_db, which we know
will try to read memory from the current process, then temporarily set
the current process.

In the case where the thread is already know and we return early, we
don't need to switch process.

Add a test to reproduce this specific situation.

Change-Id: I09b00883e8b73b7e5f89d0f47cb4e9c0f3d6caaa
Approved-By: Andrew Burgess <aburg...@redhat.com>

---
 gdb/testsuite/gdb.multi/attach-while-running.c   | 26 +++++++++
 gdb/testsuite/gdb.multi/attach-while-running.exp | 73 ++++++++++++++++++++++++
 gdbserver/thread-db.cc                           | 29 ++++++----
 3 files changed, 116 insertions(+), 12 deletions(-)

diff --git a/gdb/testsuite/gdb.multi/attach-while-running.c 
b/gdb/testsuite/gdb.multi/attach-while-running.c
new file mode 100644
index 00000000000..dd321dfe007
--- /dev/null
+++ b/gdb/testsuite/gdb.multi/attach-while-running.c
@@ -0,0 +1,26 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright 2022 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/>.  */
+
+#include <unistd.h>
+
+int global_var = 123;
+
+int
+main (void)
+{
+  sleep (30);
+}
diff --git a/gdb/testsuite/gdb.multi/attach-while-running.exp 
b/gdb/testsuite/gdb.multi/attach-while-running.exp
new file mode 100644
index 00000000000..125273d0524
--- /dev/null
+++ b/gdb/testsuite/gdb.multi/attach-while-running.exp
@@ -0,0 +1,73 @@
+# Copyright 2022 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 test was introduced to reproduce a specific bug in GDBserver, where
+# attaching an inferior while another one was running would trigger a segfault
+# in GDBserver.  Reproducing the bug required specific circumstances:
+#
+#  - The first process must be far enough to have loaded its libc or
+#    libpthread (whatever triggers the loading of libthread_db), such that
+#    its proc->priv->thread_db is not nullptr
+#
+#  - However, its lwp must still be in the `!lwp->thread_known` state,
+#    meaning GDBserver hasn't asked libthread_db to compute the thread
+#    handle yet.  That means, GDB must not have refreshed the thread list
+#    yet, since that would cause the thread handles to be computed.  That
+#    means, no stopping on a breakpoint, since that causes a thread list
+#    update.  That's why the first inferior needs to be started with "run
+#    &".
+#
+#  - Attaching the second process would segfault GDBserver.
+#
+# All of this to say, if modifying this test, please keep in mind the original
+# intent.
+
+standard_testfile
+
+if [use_gdb_stub] {
+    unsupported "test requires running"
+    return
+}
+
+if { [build_executable "failed to prepare" ${testfile} ${srcfile}] } {
+    return
+}
+
+proc do_test {} {
+    save_vars { $::GDBFLAGS } {
+       append ::GDBFLAGS " -ex \"maint set target-non-stop on\""
+       clean_restart $::binfile
+    }
+
+    gdb_test_multiple "run &" "" {
+       -re ".*$::gdb_prompt " {
+           pass $gdb_test_name
+       }
+    }
+    gdb_test "add-inferior" "Added inferior 2 on connection 1 .*"
+    gdb_test "inferior 2" "Switching to inferior 2 .*"
+
+    set spawn_id [spawn_wait_for_attach $::binfile]
+    set pid [spawn_id_get_pid $spawn_id]
+
+    # This call would crash GDBserver.
+    gdb_attach $pid
+
+    # Read a variable from the inferior, just to make sure the attach worked
+    # fine.
+    gdb_test "print global_var" " = 123"
+}
+
+do_test
diff --git a/gdbserver/thread-db.cc b/gdbserver/thread-db.cc
index 6e0e2228a5f..bf98ca9557a 100644
--- a/gdbserver/thread-db.cc
+++ b/gdbserver/thread-db.cc
@@ -155,30 +155,35 @@ thread_db_state_str (td_thr_state_e state)
 }
 #endif
 
-/* Get thread info about PTID, accessing memory via the current
-   thread.  */
+/* Get thread info about PTID.  */
 
 static int
 find_one_thread (ptid_t ptid)
 {
-  td_thrhandle_t th;
-  td_thrinfo_t ti;
-  td_err_e err;
-  struct lwp_info *lwp;
-  struct thread_db *thread_db = current_process ()->priv->thread_db;
-  int lwpid = ptid.lwp ();
-
   thread_info *thread = find_thread_ptid (ptid);
-  lwp = get_thread_lwp (thread);
+  lwp_info *lwp = get_thread_lwp (thread);
   if (lwp->thread_known)
     return 1;
 
-  /* Get information about this thread.  */
-  err = thread_db->td_ta_map_lwp2thr_p (thread_db->thread_agent, lwpid, &th);
+  /* Get information about this thread.  libthread_db will need to read some
+     memory, which will be done on the current process, so make PTID's process
+     the current one.  */
+  process_info *proc = find_process_pid (ptid.pid ());
+  gdb_assert (proc != nullptr);
+
+  scoped_restore_current_thread restore_thread;
+  switch_to_process (proc);
+
+  thread_db *thread_db = proc->priv->thread_db;
+  td_thrhandle_t th;
+  int lwpid = ptid.lwp ();
+  td_err_e err = thread_db->td_ta_map_lwp2thr_p (thread_db->thread_agent, 
lwpid,
+                                                &th);
   if (err != TD_OK)
     error ("Cannot get thread handle for LWP %d: %s",
           lwpid, thread_db_err_str (err));
 
+  td_thrinfo_t ti;
   err = thread_db->td_thr_get_info_p (&th, &ti);
   if (err != TD_OK)
     error ("Cannot get thread info for LWP %d: %s",

++++++ powerpc-fix-gdb.base-watchpoint.exp-on-power-9.patch ++++++
PowerPC, fix gdb.base/watchpoint.exp on Power 9

Test gdb.base/watchpoint.exp generates 4 test errors on Power 9.  The
test uses the test [target_info exists gdb,no_hardware_watchpoints] to
determine if the processor supports hardware watchpoints.  The check
only examines the processor type to determine if it supports hardware
watchpoints.

The PowerPC processors support hardware watchpoints with the
exception of Power 9. The hardware watchpoint support is disabled on
Power 9.  The test skip_hw_watchpoint_tests must be used to correctly
determine if the PowerPC processor supports hardware watchpoints.

This patch replaces the [target_info exists gdb,no_hardware_watchpoints]
with the skip_hw_watchpoint_tests_p check.  With the patch, the test runs
on Power 9 with hardware watchpoint force-disabled.  The test runs on
all other PowerPC processors with and without hardware watchpoints
enabled.

The patch has been tested on Power 9 to verify the test only runs with
hardware breakpoints disabled.  The patch has been tested on X86-64 with
no regression failures.  The test fails on Power 10 due to an internal GDB
error due to resource management.  The resource management issue will be
addressed in another patch.

---
 gdb/testsuite/gdb.base/watchpoint.exp | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/gdb.base/watchpoint.exp 
b/gdb/testsuite/gdb.base/watchpoint.exp
index 377d3f9ff43..1916cd37cf5 100644
--- a/gdb/testsuite/gdb.base/watchpoint.exp
+++ b/gdb/testsuite/gdb.base/watchpoint.exp
@@ -15,6 +15,13 @@
 
 # This file was written by Fred Fish. (f...@cygnus.com)
 
+# The skip_hw_watchpoint_tests checks if watchpoints are supported by the
+# processor.  On PowerPC, the check runs a small test program under gdb
+# to determine if the Power processor supports HW watchpoints.  The check
+# must be done before starting the test so as to not disrupt the execution
+# of the actual test.
+
+set skip_hw_watchpoint_tests_p [skip_hw_watchpoint_tests]
 
 standard_testfile
 
@@ -628,13 +635,14 @@ proc test_watch_location {} {
 proc test_wide_location_1 {} {
     global no_hw
     global gdb_prompt
+    global skip_hw_watchpoint_tests_p
 
     # This test watches two words on most 32-bit ABIs, and one word on
     # most 64-bit ABIs.
 
     # Platforms where the target can't watch such a large region
     # should clear hw_expected below.
-    if { $no_hw || [target_info exists gdb,no_hardware_watchpoints]
+    if { $no_hw || $skip_hw_watchpoint_tests_p
          || [istarget arm*-*-*]
          || ([istarget powerpc*-*-*] && ![is_lp64_target])} {
        set hw_expected 0
@@ -675,13 +683,14 @@ proc test_wide_location_1 {} {
 proc test_wide_location_2 {} {
     global no_hw
     global gdb_prompt
+    global skip_hw_watchpoint_tests_p
 
     # This test watches four words on most 32-bit ABIs, and two words
     # on 64-bit ABIs.
 
     # Platforms where the target can't watch such a large region
     # should clear hw_expected below.
-    if { $no_hw || [target_info exists gdb,no_hardware_watchpoints]
+    if { $no_hw || $skip_hw_watchpoint_tests_p
          || [istarget arm*-*-*]
          || [istarget powerpc*-*-*]} {
        set hw_expected 0
@@ -798,6 +807,7 @@ proc test_inaccessible_watchpoint {} {
 
 proc test_no_hw_watchpoints {} {
     global testfile
+    global skip_hw_watchpoint_tests_p
 
     clean_restart $testfile
 
@@ -843,7 +853,7 @@ proc test_no_hw_watchpoints {} {
 
 
     # Re-enable hardware watchpoints if necessary.
-    if ![target_info exists gdb,no_hardware_watchpoints] {
+    if {!$skip_hw_watchpoint_tests_p} {
         gdb_test_no_output "set can-use-hw-watchpoints 1" ""
     }
 }
@@ -895,8 +905,9 @@ proc test_watchpoint_in_big_blob {} {
 
 proc test_watch_register_location {} {
     global no_hw
+    global skip_hw_watchpoint_tests_p
 
-    if {!$no_hw && ![target_info exists gdb,no_hardware_watchpoints]} {
+    if {!$no_hw && !$skip_hw_watchpoint_tests_p} {
        # Non-memory read/access watchpoints are not supported, they would
        # require software read/access watchpoint support (which is not
        # currently available).
@@ -920,10 +931,11 @@ test_no_hw_watchpoints
 proc do_tests {} {
     global testfile
     global no_hw
+    global skip_hw_watchpoint_tests_p
 
     clean_restart $testfile
 
-    if {$no_hw || [target_info exists gdb,no_hardware_watchpoints]} {
+    if {$no_hw || $skip_hw_watchpoint_tests_p} {
        gdb_test_no_output "set can-use-hw-watchpoints 0" ""
     }
 
@@ -942,7 +954,7 @@ proc do_tests {} {
     # `initialize' anymore.
     clean_restart $testfile
 
-    if {$no_hw || [target_info exists gdb,no_hardware_watchpoints]} {
+    if {$no_hw || $skip_hw_watchpoint_tests_p} {
        gdb_test_no_output "set can-use-hw-watchpoints 0" ""
     }
 
@@ -979,7 +991,7 @@ proc do_tests {} {
 # watchpoints force-disabled.
 
 do_tests
-if ![target_info exists gdb,no_hardware_watchpoints] {
+if {!$skip_hw_watchpoint_tests_p} {
     with_test_prefix "no-hw" {
        set no_hw 1
        do_tests

++++++ qa-local.sh ++++++
--- /var/tmp/diff_new_pack.Q5281J/_old  2023-03-04 22:42:35.623572716 +0100
+++ /var/tmp/diff_new_pack.Q5281J/_new  2023-03-04 22:42:35.627572735 +0100
@@ -12,6 +12,7 @@
 openSUSE_Factory
 SLE-15
 SLE-12
+SLE-11
 "
 
 usage ()
@@ -75,9 +76,9 @@
 
     if [ "$arch" = "i586" ]; then
        case $c in
-           SLE-*)
+            SLE-12|SLE-15)
                return 1
-           ;;
+               ;;
        esac
     fi
     return 0
@@ -101,6 +102,7 @@
                fi
                osc build \
                    --clean \
+                   --no-verify \
                    --trust-all-projects \
                    --no-service \
                    $c $arch \
@@ -132,6 +134,7 @@
                mkdir -p $pkgs/$c.$arch
                osc build \
                    --clean \
+                   --no-verify \
                    --trust-all-projects \
                    --no-service \
                    -k $pkgs/$c.$arch \
@@ -184,6 +187,9 @@
                    SLE-12)
                        bash qa.sh -local -sle12 $pkgs/gdb-testresults.$c.$arch
                        ;;
+                   SLE-11)
+                       bash qa.sh -local -sle11 $pkgs/gdb-testresults.$c.$arch
+                       ;;
                    *)
                        bash qa.sh -local $pkgs/gdb-testresults.$c.$arch
                        ;;

++++++ qa-remote.sh ++++++
--- /var/tmp/diff_new_pack.Q5281J/_old  2023-03-04 22:42:35.643572812 +0100
+++ /var/tmp/diff_new_pack.Q5281J/_new  2023-03-04 22:42:35.643572812 +0100
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+scriptdir=$(cd $(dirname $0); pwd -P)
+
 pwd=$(pwd -P)
 
 root=$pwd/tmp-qa-remote
@@ -39,6 +41,7 @@
     arch="$2"
 
     if [ -d $root/binaries-testsuite.$c.$arch/gdb-testresults ]; then
+       echo "Already have $c $arch, skipping"
        return
     fi
 
@@ -46,6 +49,8 @@
        # Stale config, skip.
        return
     fi
+
+    echo "Trying $c $arch"
     
     local dir
     dir=$pkgs/$c.$arch
@@ -54,20 +59,32 @@
        mkdir -p $dir
     fi
 
-    rpm=$(echo $dir/gdb-testresults-12.1-*.*.rpm)
+    rpm=$(echo $dir/gdb-testresults-*.*.rpm)
     rpm=$(for f in $rpm; do echo $f; done | grep -v nosrc)
-    if [ ! -f $rpm ]; then
+    rpm=$(basename $rpm)
+    if [ "$rpm" = "" ] || [ ! -f "$rpm" ]; then
+       echo "Getting rpms"
        osc getbinaries -q -M testsuite -d $dir $c $arch
+       rpm=$(echo $dir/gdb-testresults-*.rpm)
+       rpm=$(for f in $rpm; do echo $f; done | grep -v nosrc)
+       rpm=$(basename $rpm)
+       echo "Got rpm: $rpm"
+    else
+       echo "Already have rpm: $rpm"   
     fi
 
     if [ ! -d $pkgs/gdb-testresults.$c.$arch ]; then
        (
+           echo "Extracting rpm: $rpm"
            cd $dir
            extract $rpm
        )
+    else
+       echo "Already extracted rpm: $rpm"
     fi
 
     if [ -d $dir/usr/share/doc/packages/gdb-testresults ]; then
+       echo "Renaming"
        mkdir $root/binaries-testsuite.$c.$arch
        mv \
            $dir/usr/share/doc/packages/gdb-testresults \
@@ -75,6 +92,7 @@
     fi
 
     if [ -d $root/binaries-testsuite.$c.$arch/gdb-testresults ]; then
+       echo "Cleaning up"
        rm -Rf $dir
     fi
 }
@@ -90,6 +108,25 @@
     mkdir -p $root
 }
 
+report_todo ()
+{
+    c="$1"
+    arch="$2"
+    status="$3"
+
+    if [ "$c" = "SLE-10_SDK" ]; then
+       # Stale config.
+       return
+    fi
+    
+    if [ "$c" = "SLE-11" ] && [ "$arch" = "x86_64" ] && [ "$status" = 
"unresolvable" ]; then
+       # This needs fixing, but is a known problem.
+       return
+    fi
+
+    echo -e "Todo: $c\t$arch\t$status"
+}
+
 case "$n" in
     1)
        cleanup
@@ -102,6 +139,12 @@
            | while read line; do
            get_item $line
        done
+       osc results -M testsuite \
+           | grep -v succeeded \
+           | awk '{print $1, $2, $4}' \
+           | while read line; do
+           report_todo $line
+       done
        ;;
 
     3)
@@ -109,7 +152,7 @@
        shift
        (
            cd $root
-           bash $pwd/qa.sh $m
+           bash $scriptdir/qa.sh $m
        )
        ;;
 

++++++ qa.sh ++++++
--- /var/tmp/diff_new_pack.Q5281J/_old  2023-03-04 22:42:35.659572889 +0100
+++ /var/tmp/diff_new_pack.Q5281J/_new  2023-03-04 22:42:35.663572908 +0100
@@ -23,7 +23,7 @@
 usage ()
 {
     echo "usage: $0 <1-5>"
-    echo "       $0 -local [ -sle12 | -factory ] <dir>"
+    echo "       $0 -local [ -sle11 | -sle12 | -factory | -aarch64 | 
-powerpc64le | -s390 | -s390x ] <dir>"
     echo
     echo "Verify remote results at:"
     echo "  ./binaries-testsuite.distro.arch/gdb-testresults"
@@ -46,12 +46,19 @@
 n="$1"
 shift
 
+have_sle11=false
 have_sle12=false
 have_factory=false
 have_aarch64=false
+have_powerpc64le=false
+have_s390=false
+have_s390x=false
 if [ "$n" = "-local" ]; then
     while [ $# -gt 1 ]; do
        case $1 in
+           -sle11)
+               have_sle11=true
+               ;;
            -sle12)
                have_sle12=true
                ;;
@@ -61,6 +68,15 @@
            -aarch64)
                have_aarch64=true
                ;;
+           -powerpc64le|-ppc64le)
+               have_powerpc64le=true
+               ;;
+           -s390)
+               have_s390=true
+               ;;
+           -s390x)
+               have_s390x=true
+               ;;
            *)
                echo "Don't know how to handle arg: $1"
                usage
@@ -142,7 +158,10 @@
     "FAIL: gdb.threads/signal-while-stepping-over-bp-other-thread.exp: step 
\(pattern 3\)"
     # https://sourceware.org/bugzilla/show_bug.cgi?id=26915
     "FAIL: gdb.threads/schedlock.exp: schedlock=off: .*: other threads ran - 
unlocked"
-    "FAIL: gdb.threads/watchthreads-threaded.exp: watchpoint on args\[3\] hit 
in thread"
+    "FAIL: gdb.threads/watchthreads-threaded.exp: watchpoint on args\[[1-3]\] 
hit in thread"
+    "FAIL: gdb.threads/watchthreads-threaded.exp: watch args\[[1-3]\]"
+    "FAIL: gdb.threads/watchthreads-threaded.exp: threaded watch loop"
+    "FAIL: gdb.threads/watchthreads-threaded.exp: combination of threaded 
watchpoints = 30 \+ initial values"
     # https://sourceware.org/bugzilla/show_bug.cgi?id=28479
     "FAIL: gdb.mi/mi-nonstop.exp: wait for thread exit \(timeout\)"
     # https://sourceware.org/bugzilla/show_bug.cgi?id=26273
@@ -163,9 +182,9 @@
     "FAIL: gdb.base/info-os.exp: continue \(timeout\)"
 
     # https://sourceware.org/bugzilla/show_bug.cgi?id=26284
-    # https://sourceware.org/bugzilla/show_bug.cgi?id=28275
     # https://sourceware.org/bugzilla/show_bug.cgi?id=28343
     "FAIL: gdb.threads/detach-step-over.exp: .*internal error"
+
     # https://sourceware.org/bugzilla/show_bug.cgi?id=26363
     "FAIL: gdb.xml/tdesc-reload.exp: .*internal error"
     # https://sourceware.org/bugzilla/show_bug.cgi?id=26761
@@ -222,9 +241,6 @@
     "FAIL: gdb.reverse/i386-sse-reverse.exp: verify xmm2 after reverse xorpd"
     "FAIL: gdb.reverse/i386-sse-reverse.exp: verify xmm2 after reverse xorps"
 
-    # Fedora test.  Fails because it doesn't handle ppc64le.
-    "FAIL: gdb.arch/powerpc-bcl-prologue.exp: powerpc arch test"
-
     # https://sourceware.org/bugzilla/show_bug.cgi?id=29419
     # https://sourceware.org/bugzilla/show_bug.cgi?id=29409
     "FAIL: gdb.opt/inline-small-func.exp: info breakpoints"
@@ -254,7 +270,32 @@
     "FAIL: gdb.base/info-os.exp: get shared-memory regions"
     "FAIL: gdb.base/info-os.exp: get threads"
 
-    
+    #https://sourceware.org/bugzilla/show_bug.cgi?id=29790
+    "FAIL: gdb.arch/i386-pkru.exp: read value after setting value"
+    "FAIL: gdb.arch/i386-pkru.exp: variable after reading pkru"
+
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=28478
+    "FAIL: gdb.gdb/selftest.exp: backtrace through signal handler"
+
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=29781
+    "FAIL: gdb.mi/mi-multi-commands.exp: args=: look for second command 
output, command length .* \(timeout\)"
+
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=27813
+    "FAIL: .*.exp: .*tab complete .* \(clearing input line\) \(timeout\)"
+    "FAIL: .*.exp: .*cmd complete .*"
+
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=27027
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=28464
+    "FAIL: gdb.ada/mi_var_access.exp: Create varobj \(unexpected output\)"
+    "FAIL: gdb.ada/mi_var_access.exp: update at stop 2 \(unexpected output\)"
+
+    # Fragile test-case, requires glibc to fail in a certain way, ignore.
+    "FAIL: gdb.base/gdb-rhbz1156192-recursive-dlopen.exp:"
+
+    # GDB fails to print "Thread $x stopped" message for all threads, but
+    # subsequent info threads shows all threads stopped, and a previous
+    # info threads show all threads running.  Not harmful.
+    "FAIL: gdb.threads/interrupt-while-step-over.exp: displaced-stepping=off: 
iter=[0-9]*: wait for stops \(timeout\)"
 ) # kfail
 
 kfail_sle12=(
@@ -306,13 +347,85 @@
     # https://sourceware.org/bugzilla/show_bug.cgi?id=29245
     # Python-2 related.
     "FAIL: gdb.python/py-mi-cmd.exp: -pycmd bk3 \(unexpected output\)"
+
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=26967
+    "FAIL: gdb.base/longjmp.exp: next over call_longjmp \(2\)"
+    "FAIL: gdb.base/longjmp.exp: next over longjmp\(1\)"
+    "FAIL: gdb.base/longjmp.exp: next over patt3"
+    "FAIL: gdb.base/premature-dummy-frame-removal.exp: p some_func \(\)"
+    "FAIL: gdb.base/premature-dummy-frame-removal.exp: set debug frame on"
+
+    # Commit 2d77a94ff17 ("[gdb/testsuite] Require debug info for
+    # gdb.tui/tui-layout-asm-short-prog.exp")
+    "FAIL: gdb.tui/tui-layout-asm-short-prog.exp: check asm box contents"
+    "FAIL: gdb.tui/tui-layout-asm-short-prog.exp: check asm box contents again"
+
+    # Test-cases that use -static but may turn out to be PIE when using
+    # unix/-fPIE/-fpie.
+    "FAIL: gdb.base/break-entry.exp: running to .* in runto"
+    "FAIL: gdb.base/catch-fork-static.exp: run to fork"
+    "FAIL: gdb.threads/staticthreads.exp: continue to main's call of sem_post"
+    "FAIL: gdb.threads/staticthreads.exp: handle SIG32 helps"
+    "FAIL: gdb.threads/staticthreads.exp: running to main in runto"
+    "FAIL: gdb.threads/staticthreads.exp: running to main in runto"
+    "FAIL: gdb.dwarf2/frame-inlined-in-outer-frame.exp: step back into _start"
+    "FAIL: gdb.dwarf2/frame-inlined-in-outer-frame.exp: step back into foo"
+    "FAIL: gdb.dwarf2/frame-inlined-in-outer-frame.exp: step into bar"
+    "FAIL: gdb.dwarf2/frame-inlined-in-outer-frame.exp: step into foo"
+
+    # Fails on both i586 and s390x/-m31 for SLE-12-SP3, but does not reproduce
+    # on s390x/-m31 for SLE-12-SP5 with trunk.
+    "FAIL: gdb.guile/scm-disasm.exp: disassemble via memory port"
+    "FAIL: gdb.guile/scm-disasm.exp: memory-port: disassemble"
 ) # kfail_sle12
 
+kfail_sle11=(
+    "${kfail_sle12[@]}"
+
+    # For SLE-11, libipt is not enabled, so on intel we can run into
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=30073 affecting
+    # many test-cases.
+    "FAIL: gdb.btrace/"
+    "FAIL: gdb.python/py-record-btrace"
+
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=26956
+    "FAIL: gdb.base/command-line-input.exp: print 1"
+
+    # Due to using old python, 2.6.
+    # For instance, "ValueError: zero length field name in format".
+    "FAIL: gdb.python/py-autoloaded-pretty-printers-in-newobjfile-event.exp: 
print test"
+    "FAIL: gdb.python/py-breakpoint.exp: test_bkpt_address: python 
gdb.Breakpoint\("  *{}".format\(str\(main_addr\)\)\)"
+    "FAIL: gdb.python/py-framefilter.exp: info frame filter after disable 
frame filter"
+    "FAIL: gdb.python/py-framefilter.exp: info frame filter after reenabling 
frame filter"
+    "FAIL: gdb.python/py-framefilter.exp: info frame filter after setting 
priority"
+    "FAIL: gdb.python/py-framefilter.exp: info frame filter before disable 
frame filter"
+    "FAIL: gdb.python/py-framefilter.exp: info frame filter before setting 
priority"
+    "FAIL: gdb.python/py-mi.exp: check tsrvw expression value \(unexpected 
output\)"
+    "FAIL: gdb.python/py-mi.exp: check tsrvw varobj value \(unexpected 
output\)"
+    "FAIL: gdb.python/py-mi.exp: create tsrvw varobj \(unexpected output\)"
+    "FAIL: gdb.python/py-prettyprint.exp: c\+\+: print tsrvw"
+    "FAIL: gdb.python/py-prettyprint.exp: c: print tsrvw"
+    "FAIL: gdb.python/py-value.exp: attempt to construct large value with 
small buffer"
+    "FAIL: gdb.python/py-value.exp: construct array value from buffer"
+    "FAIL: gdb.python/py-value.exp: construct value from buffer"
+    "FAIL: gdb.python/py-value.exp: print array value"
+    "FAIL: gdb.python/py-value.exp: print first array element"
+    "FAIL: gdb.python/py-value.exp: print out of bounds array element"
+    "FAIL: gdb.python/py-value.exp: print second array element"
+    "FAIL: gdb.python/py-value.exp: print third array element"
+
+    # To be investigated.
+    "FAIL: gdb.base/compare-sections.exp: after run to main: compare-sections 
-r"
+    "FAIL: gdb.python/py-framefilter-thread.exp: bt no-filters"
+
+    # Gdb runs out of virtual memory, we can expect an internal error.
+    "FAIL: gdb.base/gcore-excessive-memory.exp: attach \(GDB internal error\)"
+
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=30154
+    "FAIL: gdb.multi/multi-target-no-resumed.exp: inf_A=.: inf_B=.: send_gdb 
control C \(timeout\)"
+)
+
 kfail_factory=(
-    # https://sourceware.org/bugzilla/show_bug.cgi?id=27027
-    # https://sourceware.org/bugzilla/show_bug.cgi?id=28464
-    "FAIL: gdb.ada/mi_var_access.exp: Create varobj \(unexpected output\)"
-    "FAIL: gdb.ada/mi_var_access.exp: update at stop 2 \(unexpected output\)"
     # https://sourceware.org/bugzilla/show_bug.cgi?id=28463
     "FAIL: gdb.ada/set_pckd_arr_elt.exp: scenario=minimal: print va.t\(1\) := 
15"
     "FAIL: gdb.ada/set_pckd_arr_elt.exp: scenario=minimal: continue to 
update_small for va.t"
@@ -333,8 +446,6 @@
     "FAIL: gdb.threads/signal-command-handle-nopass.exp: step-over (yes|no): 
signal SIGUSR1"
     # https://sourceware.org/bugzilla/show_bug.cgi?id=28477
     "FAIL: gdb.base/step-over-syscall.exp: clone: displaced=off: continue to 
marker \(clone\)"
-    # https://sourceware.org/bugzilla/show_bug.cgi?id=28478
-    "FAIL: gdb.gdb/selftest.exp: backtrace through signal handler"
     # https://sourceware.org/bugzilla/show_bug.cgi?id=26867
     "FAIL: gdb.threads/signal-sigtrap.exp: sigtrap thread 1: signal SIGTRAP 
reaches handler"
     # https://sourceware.org/bugzilla/show_bug.cgi?id=28510
@@ -366,6 +477,8 @@
     # https://sourceware.org/bugzilla/show_bug.cgi?id=29706
     "FAIL: gdb.base/eof-exit.exp: with non-dump terminal: with 
bracketed-paste-mode on: close GDB with eof \(missed the prompt\)"
 
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=29965
+    "FAIL: gdb.threads/process-exit-status-is-leader-exit-status.exp: 
iteration=.*: continue \(the program exited\)"
 ) # kfail_factory
 
 kfail_aarch64=(
@@ -390,6 +503,140 @@
     "FAIL: gdb.base/watchpoint-unaligned.exp: size8twice write"
 ) # kfail_aarch64
 
+kfail_powerpc64le=(
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=29420
+    "FAIL: gdb.ada/convvar_comp.exp: print \\\$item.started"
+
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=29814
+    "FAIL: gdb.base/msym-bp-shl.exp: debug=0: before run: info breakpoint"
+    "FAIL: gdb.base/msym-bp-shl.exp: debug=1: before run: info breakpoint"
+
+    # Commit a0eda3df5b7 ("PowerPC, fix support for printing the function
+    # return value for non-trivial values").
+    "FAIL: gdb.cp/non-trivial-retval.exp: finish from"
+    "FAIL: gdb.ada/array_return.exp: value printed by finish of 
Create_Small_Float_Vector"
+    "FAIL: gdb.base/gnu_vector.exp: call add_structvecs"
+
+    # Commit f68eca29d3b ("PowerPC, fix gdb.base/retval-large-struct.exp").
+    "FAIL: gdb.base/retval-large-struct.exp: finish from return_large_struct"
+
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=29793
+    "FAIL: gdb.cp/gdb2495.exp: call a function that raises an exception 
without a handler."
+    "FAIL: gdb.cp/gdb2495.exp: bt after returning from a popped frame"
+
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=29792
+    "FAIL: gdb.opt/solib-intra-step.exp: second-hit"
+    
+    # Carl Love mentioned he's working on these.
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=29793#c2
+    "FAIL: gdb.reverse/finish-precsave.exp"
+    "FAIL: gdb.reverse/finish-reverse.exp"
+    
+    # Commit 29004660c94 ("PowerPC fix for gdb.server/sysroot.exp").
+    "FAIL: gdb.server/sysroot.exp: sysroot=local: continue to printf"
+    "FAIL: gdb.server/sysroot.exp: sysroot=remote: continue to printf"    
+
+    # Known to run into timeouts.
+    "FAIL: gdb.gdb/python-helper.exp"
+
+    # Fedora test.  Fails because it doesn't handle ppc64le.
+    "FAIL: gdb.arch/powerpc-bcl-prologue.exp: powerpc arch test"
+
+    # Commit 301fe55e9c4 ("PowerPC: bp-permanent.exp, kill-after-signal fix").
+    "FAIL: gdb.base/kill-after-signal.exp: stepi"
+    "FAIL: gdb.base/bp-permanent.exp: always_inserted=off, sw_watchpoint=0: 
stepi signal with handler: mainline pc points at permanent breakpoint"
+    "FAIL: gdb.base/bp-permanent.exp: always_inserted=off, sw_watchpoint=1: 
stepi signal with handler: mainline pc points at permanent breakpoint"
+    "FAIL: gdb.base/bp-permanent.exp: always_inserted=on, sw_watchpoint=0: 
stepi signal with handler: mainline pc points at permanent breakpoint"
+    "FAIL: gdb.base/bp-permanent.exp: always_inserted=on, sw_watchpoint=1: 
stepi signal with handler: mainline pc points at permanent breakpoint"
+
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=29813
+    "FAIL: gdb.base/vla-optimized-out.exp: o1: printed size of optimized out 
vla"
+
+    # Commit 4d88ae0c7b5 ("[gdb/testsuite] Fix gdb.base/maint.exp on 
powerpc64le").
+    "FAIL: gdb.base/maint.exp: maint print objfiles: symtabs"
+
+    # Commit e7d69e72bfd ("gdb: always add the default register groups").
+    "FAIL: gdb.xml/tdesc-regs.exp: maintenance print reggroups"
+
+    # Commit 91836f41e20 ("Powerpc fix for gdb.base/unwind-on-each-insn.exp").
+    "FAIL: gdb.base/inline-frame-cycle-unwind.exp: cycle at level [0-9]*: 
backtrace when the unwind is broken at frame [0-9]*"
+
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=29815
+    "FAIL: gdb.reverse/finish-reverse-bkpt.exp: reverse-finish from void_func 
trips breakpoint at entry"
+    "FAIL: gdb.reverse/finish-reverse-bkpt.exp: no spurious proceed after 
breakpoint stop"
+    "FAIL: gdb.reverse/next-reverse-bkpt-over-sr.exp: reverse-next over call 
trips user breakpoint at function entry"
+    "FAIL: gdb.reverse/next-reverse-bkpt-over-sr.exp: stopped at the right 
callee call"
+
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=29816
+    "FAIL: gdb.ada/float-bits.exp: print 
16llf#4000921fb54442d18469898cc51701b8#"
+    "FAIL: gdb.ada/float-bits.exp: print 
\\\$foo:=16llf#4000921fb54442d18469898cc51701b8#"
+    "FAIL: gdb.ada/float-bits.exp: print internal long double variable after 
assignment"
+
+    # Commit 8b272d7671f ("[gdb/testsuite] Fix gdb.guile/scm-symtab.exp for
+    # ppc64le").
+    "FAIL: gdb.guile/scm-symtab.exp: test find-pc-line with resume address"
+
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=29897
+    "FAIL: gdb.base/run-control-while-bg-execution.exp: action1=.*: 
action2=start: start \(GDB internal error\)"
+    "FAIL: gdb.base/run-control-while-bg-execution.exp: action1=.*: 
action2=run: run \(GDB internal error\)"
+)
+
+kfail_powerpc64le_sle12=(
+    # Commit 85819864f7c ("[gdb/testsuite] Fix gdb.arch/altivec-regs.exp with
+    # gcc 4.8.5").
+    "FAIL: gdb.arch/altivec-regs.exp: down to vector_fun"
+    "FAIL: gdb.arch/altivec-regs.exp: finish returned correct value"
+    "FAIL: gdb.arch/altivec-regs.exp: print vector parameter a"
+    "FAIL: gdb.arch/altivec-regs.exp: print vector parameter b"
+)
+
+kfail_s390x_s390=(
+    # Commit 167f3beb655 ("[gdb/testsuite] Fix gdb.base/write_mem.exp for big
+    # endian")
+    "FAIL: gdb.base/write_mem.exp: x /xh main"
+)
+
+# Plain s390 or s390x/-m31.
+kfail_s390=(
+    "${kfail_s390x_s390[@]}"
+    
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=29841
+    "FAIL: gdb.reverse/.*.exp:"
+
+    # Doesn't reproduce with trunk on SLE-12SP5.
+    "FAIL: gdb.guile/scm-ports.exp: buffered: test byte at sp, before flush"
+    
+    # https://sourceware.org/bugzilla/show_bug.cgi?id=29867
+    "FAIL: gdb.guile/scm-lazy-string.exp: ptr: lazy string length 2 value"
+    "FAIL: gdb.guile/scm-lazy-string.exp: ptr: lazy string value"
+    "FAIL: gdb.guile/scm-lazy-string.exp: ptr: print ptr"
+    "FAIL: gdb.base/sym-file.exp: add-symbol-file sym-file-lib.so addr"
+    "FAIL: gdb.base/sym-file.exp: continue to breakpoint: gdb_add_symbol_file"
+    "FAIL: gdb.python/py-lazy-string.exp: ptr: lazy string length 2 value"
+    "FAIL: gdb.python/py-lazy-string.exp: ptr: lazy string value"
+    "FAIL: gdb.python/py-lazy-string.exp: ptr: print ptr"
+    "FAIL: gdb.python/py-nested-maps.exp: headers=on: pretty=off: exp='\*mm': 
depth=1: p \*mm"
+    "FAIL: gdb.python/py-nested-maps.exp: headers=on: pretty=off: exp='\*mm': 
depth=2: p \*mm"
+    "FAIL: gdb.python/py-nested-maps.exp: headers=on: pretty=off: exp='\*mm': 
depth=3: p \*mm"
+    "FAIL: gdb.python/py-nested-maps.exp: headers=on: pretty=off: exp='\*mm': 
depth=unlimited: p \*mm"
+    "FAIL: gdb.python/py-nested-maps.exp: pretty=off: exp='\*mm': depth=1: p 
\*mm"
+    "FAIL: gdb.python/py-nested-maps.exp: pretty=off: exp='\*mm': depth=2: p 
\*mm"
+    "FAIL: gdb.python/py-nested-maps.exp: pretty=off: exp='\*mm': depth=3: p 
\*mm"
+    "FAIL: gdb.python/py-nested-maps.exp: pretty=off: exp='\*mm': 
depth=unlimited: p \*mm"
+    "FAIL: gdb.python/py-nested-maps.exp: pretty=on: exp='\*mm': depth=1: p 
\*mm"
+    "FAIL: gdb.python/py-nested-maps.exp: pretty=on: exp='\*mm': depth=2: p 
\*mm"
+    "FAIL: gdb.python/py-nested-maps.exp: pretty=on: exp='\*mm': depth=3: p 
\*mm"
+    "FAIL: gdb.python/py-nested-maps.exp: pretty=on: exp='\*mm': 
depth=unlimited: p \*mm"
+    "FAIL: gdb.base/info-shared.exp:"
+    "FAIL: gdb.python/py-strfns.exp: p /d {char\[4\]} arg"
+    "FAIL: gdb.python/py-strfns.exp: p arg"
+)
+
+# s390x/-m64.
+kfail_s390x=(
+    "${kfail_s390x_s390[@]}"
+)
+
 case $n in
     1)
        # 'FAIL: .* internal error' in gdb.sum.
@@ -398,6 +645,8 @@
        # Todo: apply kfail_factory/kfail_sle12 only when appropriate.
        kfail+=("${kfail_factory[@]}")
        kfail+=("${kfail_sle12[@]}")
+       kfail+=("${kfail_s390[@]}")
+       kfail+=("${kfail_powerpc64le[@]}")
        kfail_re=$(join "|" "${kfail[@]}")
        grep "^FAIL:.*internal error" binaries-testsuite*/gdb-testresults/*.sum 
\
             | grep -E -v "$kfail_re"
@@ -425,7 +674,7 @@
            # https://sourceware.org/bugzilla/show_bug.cgi?id=26284
            "infrun.c:[0-9]*: internal-error: finish_step_over: Assertion 
\`ecs->event_thread->control.trap_expected' failed."
            # https://sourceware.org/bugzilla/show_bug.cgi?id=26363
-           ".i586.*i386-linux-nat.c:[0-9]*: internal-error: Got request for 
bad register number 41."
+           ".i586.*i386-linux-nat.c:[0-9]*: internal-error: Got request for 
bad register number [0-9]*."
            # https://sourceware.org/bugzilla/show_bug.cgi?id=26761
            "thread.c:[0-9]*: internal-error: inferior_thread: Assertion 
\`current_thread_ \!= nullptr' failed."
            # https://sourceware.org/bugzilla/show_bug.cgi?id=19675
@@ -441,6 +690,15 @@
            "record-full.c:[0-9]*: internal-error: ptid_t 
record_full_wait_1\(target_ops\*, ptid_t, target_waitstatus\*, 
target_wait_flags\): Assertion \`\(options & TARGET_WNOHANG\) != 0' failed."
            # https://sourceware.org/bugzilla/show_bug.cgi?id=26873
            "infrun.c:[0-9]*: internal-error: resume_1: Assertion 
\`!\(thread_has_single_step_breakpoints_set \(tp\) && step\)' failed."
+
+           # https://sourceware.org/bugzilla/show_bug.cgi?id=29783
+           "frame.c:[0-9]*: internal-error: get_selected_frame: Assertion 
\`selected_frame != NULL' failed."
+
+           # https://sourceware.org/bugzilla/show_bug.cgi?id=29841
+           "regcache.c:[0-9]*: internal-error: raw_read: Assertion \`buf != 
NULL' failed."
+
+           # https://sourceware.org/bugzilla/show_bug.cgi?id=29897
+           "displaced-stepping.c:[0-9]*: internal-error: prepare: Assertion 
\`buf.current_thread != thread' failed."
        )
 
        kfail_re=$(join "|" "${kfail[@]}")
@@ -539,6 +797,21 @@
            done
        )
 
+       (
+           kfail+=("${kfail_powerpc64le[@]}")
+
+           # Known clean config: SLE 15 / openSUSE 15.4 powerpc64le.
+           for config in SLE-15.ppc64le/gdb-testresults 
openSUSE_Leap_15.4.ppc64le/gdb-testresults; do
+               sums=("$config/gdb-ppc64le-suse-linux-m64.-fno-PIE.-no-pie.sum"
+                     "$config/gdb-ppc64le-suse-linux-m64.sum")
+           done
+           
+           for sum in "${sums[@]}"; do
+               sum=binaries-testsuite.$sum
+               report_sum "$sum"
+           done
+       )
+
        ;;
 
     5)
@@ -546,12 +819,16 @@
                     | grep -v SLE-11)
        nolibrpm=$(ls -1 binaries-testsuite*/gdb-testresults/*.sum \
                     | grep SLE-11)
-       grep -c "PASS: gdb.suse/zypper-hint.exp: zypper hint printed (librpm)" \
-            $librpm \
-           | grep -E -v ":1"
-       grep -c "PASS: gdb.suse/zypper-hint.exp: zypper hint printed (no 
librpm)" \
-            $nolibrpm \
-           | grep -E -v ":1"
+       if [ "$librpm" != "" ]; then
+           grep -c "PASS: gdb.suse/zypper-hint.exp: zypper hint printed 
(librpm)" \
+                $librpm \
+               | grep -E -v ":1"
+       fi
+       if [ "$nolibrpm" != "" ]; then
+           grep -c "PASS: gdb.suse/zypper-hint.exp: zypper hint printed (no 
librpm)" \
+                $nolibrpm \
+               | grep -E -v ":1"
+       fi
        ;;
 
     -local)
@@ -570,12 +847,28 @@
        if $have_factory; then
            kfail+=("${kfail_factory[@]}")
        fi
+       if $have_sle11; then
+           kfail+=("${kfail_sle11[@]}")
+       fi
        if $have_sle12; then
            kfail+=("${kfail_sle12[@]}")
        fi
        if $have_aarch64; then
            kfail+=("${kfail_aarch64[@]}")
        fi
+       if $have_powerpc64le; then
+           kfail+=("${kfail_powerpc64le[@]}")
+       fi
+       if $have_powerpc64le && $have_sl12; then
+           kfail+=("${kfail_powerpc64le_sle12[@]}")
+       fi
+       if $have_s390; then
+           kfail+=("${kfail_s390[@]}")
+       fi
+
+       if $have_s390x; then
+           kfail+=("${kfail_s390x[@]}")
+       fi
 
        for sum in "${sums[@]}"; do
            report_sum "$sum"

Reply via email to