Accepting request 1069165 from devel:gcc

- Maintenance script qa.sh:
  * Expand kfail pattern for PR29897.
  * Add PR29965 kfail.
- Re-enable testing all test-cases, undoing accidental change in
  previous commit.
- Add --with=for_chroot.
- 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.
- Maintenance script qa.sh:
  * Re-enable PR26284 kfails.
  * Remove mention of PR28275.
  * Add PR29897 kfail.
- Mention CVE-2018-7208 and CVE-2017-16829.
- Mention SLE-21561, bnc#1081527, and bnc#1068950.
- 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.
- Maintenance script qa.sh:
  - Add openSUSE Leap 15.4 ppc64le to known clean configs.
- 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.
- 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
- 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
- Maintenance script qa-remote.sh:
  * Make "Get remote testsuite results" more verbose.

OBS-URL: https://build.opensuse.org/request/show/1069165
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/gdb?expand=0&rev=168
factory
Dominique Leuenberger 3 months ago committed by Git OBS Bridge
commit 38bc9c3dd8

@ -0,0 +1,29 @@
From f41928feb3e44fb27776afa062a1cd06263b7d1d Mon Sep 17 00:00:00 2001
From: Cary Coutant <ccoutant@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

File diff suppressed because it is too large Load Diff

@ -0,0 +1,101 @@
From 1907d04cb6cb94052369995cf8373f2670908e2a Mon Sep 17 00:00:00 2001
From: Pedro Alves <pedro@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

@ -0,0 +1,21 @@
From 81a7585502092b3c133534ac6ecb34fd56d05337 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@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

@ -1,30 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-container-rh-pkg.patch
;; Add messages suggesting more recent RHEL gdbserver (RH BZ 1321114).
;;=fedora
diff --git a/gdb/remote.c b/gdb/remote.c
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -14343,7 +14343,17 @@ remote_target::pid_to_exec_file (int pid)
char *annex = NULL;
if (packet_support (PACKET_qXfer_exec_file) != PACKET_ENABLE)
- return NULL;
+ {
+ warning (_("Remote gdbserver does not support determining executable "
+ "automatically.\n"
+"RHEL <=6.8 and <=7.2 versions of gdbserver do not support such automatic executable detection.\n"
+"The following versions of gdbserver support it:\n"
+"- Upstream version of gdbserver (unsupported) 7.10 or later\n"
+"- Red Hat Developer Toolset (DTS) version of gdbserver from DTS 4.0 or later (only on x86_64)\n"
+"- RHEL-7.3 versions of gdbserver (on any architecture)"
+));
+ return NULL;
+ }
inferior *inf = find_inferior_pid (this, pid);
if (inf == NULL)

@ -0,0 +1,272 @@
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 <aburgess@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
+ }
+}

@ -0,0 +1,174 @@
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.marchi@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}
}
}
}

@ -1,47 +0,0 @@
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 1e524b5942f..459bc13f398 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -4916,6 +4916,7 @@ watchpoints_triggered (const target_waitstatus &ws)
affected by this data address as triggered, and all others as not
triggered. */
+ size_t triggered_cnt = 0;
for (breakpoint *b : all_breakpoints ())
if (is_hardware_watchpoint (b))
{
@@ -4932,6 +4933,7 @@ watchpoints_triggered (const target_waitstatus &ws)
if (newaddr == start)
{
w->watchpoint_triggered = watch_triggered_yes;
+ triggered_cnt++;
break;
}
}
@@ -4941,11 +4943,26 @@ watchpoints_triggered (const target_waitstatus &ws)
loc->length))
{
w->watchpoint_triggered = watch_triggered_yes;
+ triggered_cnt++;
break;
}
}
}
+ if (triggered_cnt == 0)
+ {
+ /* The target could report the data address. But none of the
+ watchpoints was affected by this data address, so mark all
+ watchpoints as unknown. */
+ for (breakpoint *b : all_breakpoints ())
+ if (is_hardware_watchpoint (b))
+ {
+ struct watchpoint *w = (struct watchpoint *) b;
+
+ w->watchpoint_triggered = watch_triggered_unknown;
+ }
+ }
+
return 1;
}

@ -1,468 +0,0 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Fedora GDB patches <invalid@email.com>
Date: Fri, 27 Oct 2017 21:07:50 +0200
Subject: gdb-test-ivy-bridge.patch
;; Test GDB opcodes/ disassembly of Intel Ivy Bridge instructions (BZ 696890).
;;=fedoratest
diff --git a/gdb/testsuite/gdb.arch/amd64-ivy-bridge.S b/gdb/testsuite/gdb.arch/amd64-ivy-bridge.S
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-ivy-bridge.S
@@ -0,0 +1,98 @@
+/* Copyright 2011 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ This file is part of the gdb testsuite. */
+
+ .globl _start
+_start: .text
+
+/* gas/i386/x86-64-rdrnd.s */
+ .att_syntax prefix
+ rdrand %bx
+ rdrand %ebx
+ rdrand %rbx
+ rdrand %r8w
+ rdrand %r8d
+ rdrand %r8
+
+ .intel_syntax noprefix
+ rdrand bx
+ rdrand ebx
+ rdrand rbx
+ rdrand r8w
+ rdrand r8d
+ rdrand r8
+
+/* gas/i386/x86-64-f16c.s */
+ .att_syntax prefix
+ vcvtph2ps %xmm4,%ymm4
+ vcvtph2ps (%r8),%ymm8
+ vcvtph2ps %xmm4,%xmm6
+ vcvtph2ps (%rcx),%xmm4
+ vcvtps2ph $0x2,%ymm4,%xmm4
+ vcvtps2ph $0x2,%ymm8,(%r8)
+ vcvtps2ph $0x2,%xmm4,%xmm4
+ vcvtps2ph $0x2,%xmm4,(%rcx)
+
+ .intel_syntax noprefix
+ vcvtph2ps ymm4,xmm4
+ vcvtph2ps ymm8,XMMWORD PTR [r8]
+ vcvtph2ps ymm4,[rcx]
+ vcvtph2ps xmm6,xmm4
+ vcvtph2ps xmm4,QWORD PTR [rcx]
+ vcvtph2ps xmm4,[rcx]
+ vcvtps2ph xmm4,ymm4,0x2
+ vcvtps2ph XMMWORD PTR [rcx],ymm4,0x2
+ vcvtps2ph [rcx],ymm4,0x2
+ vcvtps2ph xmm4,xmm4,0x2
+ vcvtps2ph QWORD PTR [r8],xmm8,0x2
+ vcvtps2ph [rcx],xmm4,0x2
+
+/* gas/i386/x86-64-fsgs.s */
+ .att_syntax prefix
+ rdfsbase %ebx
+ rdfsbase %rbx
+ rdfsbase %r8d
+ rdfsbase %r8
+ rdgsbase %ebx
+ rdgsbase %rbx
+ rdgsbase %r8d
+ rdgsbase %r8
+ wrfsbase %ebx
+ wrfsbase %rbx
+ wrfsbase %r8d
+ wrfsbase %r8
+ wrgsbase %ebx
+ wrgsbase %rbx
+ wrgsbase %r8d
+ wrgsbase %r8
+
+ .intel_syntax noprefix
+ rdfsbase ebx
+ rdfsbase rbx
+ rdfsbase r8d
+ rdfsbase r8
+ rdgsbase ebx
+ rdgsbase rbx
+ rdgsbase r8d
+ rdgsbase r8
+ wrfsbase ebx
+ wrfsbase rbx
+ wrfsbase r8d
+ wrfsbase r8
+ wrgsbase ebx
+ wrgsbase rbx
+ wrgsbase r8d
+ wrgsbase r8
diff --git a/gdb/testsuite/gdb.arch/amd64-ivy-bridge.exp b/gdb/testsuite/gdb.arch/amd64-ivy-bridge.exp
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-ivy-bridge.exp
@@ -0,0 +1,170 @@
+# Copyright 2011 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/>.
+
+if {![istarget "x86_64-*-*"]} then {
+ return
+}
+
+set testfile amd64-ivy-bridge
+set test compilation
+if [prepare_for_testing ${testfile}.exp ${testfile}.x ${testfile}.S [list debug "additional_flags=-m64 -nostdlib"]] {
+ unsupported $test
+ return -1
+}
+pass $test
+
+gdb_test_no_output "set disassembly-flavor att"
+# gas/i386/x86-64-rdrnd.d
+# gas/i386/x86-64-f16c.d
+# gas/i386/x86-64-fsgs.d
+gdb_test "disassemble/r _start" "\r
+Dump of assembler code for function _start:\r
+\[^\r\n\]+:\t66 0f c7 f3\t\( \)?rdrand %bx\r
+\[^\r\n\]+:\t0f c7 f3\t\( \)?rdrand %ebx\r
+\[^\r\n\]+:\t48 0f c7 f3\t\( \)?rdrand %rbx\r
+\[^\r\n\]+:\t66 41 0f c7 f0\t\( \)?rdrand %r8w\r
+\[^\r\n\]+:\t41 0f c7 f0\t\( \)?rdrand %r8d\r
+\[^\r\n\]+:\t49 0f c7 f0\t\( \)?rdrand %r8\r
+\[^\r\n\]+:\t66 0f c7 f3\t\( \)?rdrand %bx\r
+\[^\r\n\]+:\t0f c7 f3\t\( \)?rdrand %ebx\r
+\[^\r\n\]+:\t48 0f c7 f3\t\( \)?rdrand %rbx\r
+\[^\r\n\]+:\t66 41 0f c7 f0\t\( \)?rdrand %r8w\r
+\[^\r\n\]+:\t41 0f c7 f0\t\( \)?rdrand %r8d\r
+\[^\r\n\]+:\t49 0f c7 f0\t\( \)?rdrand %r8\r
+\[^\r\n\]+:\tc4 e2 7d 13 e4\t\( \)?vcvtph2ps %xmm4,%ymm4\r
+\[^\r\n\]+:\tc4 42 7d 13 00\t\( \)?vcvtph2ps \\(%r8\\),%ymm8\r
+\[^\r\n\]+:\tc4 e2 79 13 f4\t\( \)?vcvtph2ps %xmm4,%xmm6\r
+\[^\r\n\]+:\tc4 e2 79 13 21\t\( \)?vcvtph2ps \\(%rcx\\),%xmm4\r
+\[^\r\n\]+:\tc4 e3 7d 1d e4 02\t\( \)?vcvtps2ph \\\$0x2,%ymm4,%xmm4\r
+\[^\r\n\]+:\tc4 43 7d 1d 00 02\t\( \)?vcvtps2ph \\\$0x2,%ymm8,\\(%r8\\)\r
+\[^\r\n\]+:\tc4 e3 79 1d e4 02\t\( \)?vcvtps2ph \\\$0x2,%xmm4,%xmm4\r
+\[^\r\n\]+:\tc4 e3 79 1d 21 02\t\( \)?vcvtps2ph \\\$0x2,%xmm4,\\(%rcx\\)\r
+\[^\r\n\]+:\tc4 e2 7d 13 e4\t\( \)?vcvtph2ps %xmm4,%ymm4\r
+\[^\r\n\]+:\tc4 42 7d 13 00\t\( \)?vcvtph2ps \\(%r8\\),%ymm8\r
+\[^\r\n\]+:\tc4 e2 7d 13 21\t\( \)?vcvtph2ps \\(%rcx\\),%ymm4\r
+\[^\r\n\]+:\tc4 e2 79 13 f4\t\( \)?vcvtph2ps %xmm4,%xmm6\r
+\[^\r\n\]+:\tc4 e2 79 13 21\t\( \)?vcvtph2ps \\(%rcx\\),%xmm4\r
+\[^\r\n\]+:\tc4 e2 79 13 21\t\( \)?vcvtph2ps \\(%rcx\\),%xmm4\r
+\[^\r\n\]+:\tc4 e3 7d 1d e4 02\t\( \)?vcvtps2ph \\\$0x2,%ymm4,%xmm4\r
+\[^\r\n\]+:\tc4 e3 7d 1d 21 02\t\( \)?vcvtps2ph \\\$0x2,%ymm4,\\(%rcx\\)\r
+\[^\r\n\]+:\tc4 e3 7d 1d 21 02\t\( \)?vcvtps2ph \\\$0x2,%ymm4,\\(%rcx\\)\r
+\[^\r\n\]+:\tc4 e3 79 1d e4 02\t\( \)?vcvtps2ph \\\$0x2,%xmm4,%xmm4\r
+\[^\r\n\]+:\tc4 43 79 1d 00 02\t\( \)?vcvtps2ph \\\$0x2,%xmm8,\\(%r8\\)\r
+\[^\r\n\]+:\tc4 e3 79 1d 21 02\t\( \)?vcvtps2ph \\\$0x2,%xmm4,\\(%rcx\\)\r
+\[^\r\n\]+:\tf3 0f ae c3\t\( \)?rdfsbase %ebx\r
+\[^\r\n\]+:\tf3 48 0f ae c3\t\( \)?rdfsbase %rbx\r
+\[^\r\n\]+:\tf3 41 0f ae c0\t\( \)?rdfsbase %r8d\r
+\[^\r\n\]+:\tf3 49 0f ae c0\t\( \)?rdfsbase %r8\r
+\[^\r\n\]+:\tf3 0f ae cb\t\( \)?rdgsbase %ebx\r
+\[^\r\n\]+:\tf3 48 0f ae cb\t\( \)?rdgsbase %rbx\r
+\[^\r\n\]+:\tf3 41 0f ae c8\t\( \)?rdgsbase %r8d\r
+\[^\r\n\]+:\tf3 49 0f ae c8\t\( \)?rdgsbase %r8\r
+\[^\r\n\]+:\tf3 0f ae d3\t\( \)?wrfsbase %ebx\r
+\[^\r\n\]+:\tf3 48 0f ae d3\t\( \)?wrfsbase %rbx\r
+\[^\r\n\]+:\tf3 41 0f ae d0\t\( \)?wrfsbase %r8d\r
+\[^\r\n\]+:\tf3 49 0f ae d0\t\( \)?wrfsbase %r8\r
+\[^\r\n\]+:\tf3 0f ae db\t\( \)?wrgsbase %ebx\r
+\[^\r\n\]+:\tf3 48 0f ae db\t\( \)?wrgsbase %rbx\r
+\[^\r\n\]+:\tf3 41 0f ae d8\t\( \)?wrgsbase %r8d\r
+\[^\r\n\]+:\tf3 49 0f ae d8\t\( \)?wrgsbase %r8\r
+\[^\r\n\]+:\tf3 0f ae c3\t\( \)?rdfsbase %ebx\r
+\[^\r\n\]+:\tf3 48 0f ae c3\t\( \)?rdfsbase %rbx\r
+\[^\r\n\]+:\tf3 41 0f ae c0\t\( \)?rdfsbase %r8d\r
+\[^\r\n\]+:\tf3 49 0f ae c0\t\( \)?rdfsbase %r8\r
+\[^\r\n\]+:\tf3 0f ae cb\t\( \)?rdgsbase %ebx\r
+\[^\r\n\]+:\tf3 48 0f ae cb\t\( \)?rdgsbase %rbx\r
+\[^\r\n\]+:\tf3 41 0f ae c8\t\( \)?rdgsbase %r8d\r
+\[^\r\n\]+:\tf3 49 0f ae c8\t\( \)?rdgsbase %r8\r
+\[^\r\n\]+:\tf3 0f ae d3\t\( \)?wrfsbase %ebx\r
+\[^\r\n\]+:\tf3 48 0f ae d3\t\( \)?wrfsbase %rbx\r
+\[^\r\n\]+:\tf3 41 0f ae d0\t\( \)?wrfsbase %r8d\r
+\[^\r\n\]+:\tf3 49 0f ae d0\t\( \)?wrfsbase %r8\r
+\[^\r\n\]+:\tf3 0f ae db\t\( \)?wrgsbase %ebx\r
+\[^\r\n\]+:\tf3 48 0f ae db\t\( \)?wrgsbase %rbx\r
+\[^\r\n\]+:\tf3 41 0f ae d8\t\( \)?wrgsbase %r8d\r
+\[^\r\n\]+:\tf3 49 0f ae d8\t\( \)?wrgsbase %r8\r
+End of assembler dump\\." "att"
+
+gdb_test_no_output "set disassembly-flavor intel"
+# gas/i386/x86-64-rdrnd-intel.d
+# gas/i386/x86-64-f16c-intel.d
+# gas/i386/x86-64-fsgs-intel.d
+gdb_test "disassemble/r _start" "\r
+Dump of assembler code for function _start:\r
+\[^\r\n\]+:\t66 0f c7 f3\t\( \)?rdrand bx\r
+\[^\r\n\]+:\t0f c7 f3\t\( \)?rdrand ebx\r
+\[^\r\n\]+:\t48 0f c7 f3\t\( \)?rdrand rbx\r
+\[^\r\n\]+:\t66 41 0f c7 f0\t\( \)?rdrand r8w\r
+\[^\r\n\]+:\t41 0f c7 f0\t\( \)?rdrand r8d\r
+\[^\r\n\]+:\t49 0f c7 f0\t\( \)?rdrand r8\r
+\[^\r\n\]+:\t66 0f c7 f3\t\( \)?rdrand bx\r
+\[^\r\n\]+:\t0f c7 f3\t\( \)?rdrand ebx\r
+\[^\r\n\]+:\t48 0f c7 f3\t\( \)?rdrand rbx\r
+\[^\r\n\]+:\t66 41 0f c7 f0\t\( \)?rdrand r8w\r
+\[^\r\n\]+:\t41 0f c7 f0\t\( \)?rdrand r8d\r
+\[^\r\n\]+:\t49 0f c7 f0\t\( \)?rdrand r8\r
+\[^\r\n\]+:\tc4 e2 7d 13 e4\t\( \)?vcvtph2ps ymm4,xmm4\r
+\[^\r\n\]+:\tc4 42 7d 13 00\t\( \)?vcvtph2ps ymm8,XMMWORD PTR \\\[r8\\\]\r
+\[^\r\n\]+:\tc4 e2 79 13 f4\t\( \)?vcvtph2ps xmm6,xmm4\r
+\[^\r\n\]+:\tc4 e2 79 13 21\t\( \)?vcvtph2ps xmm4,QWORD PTR \\\[rcx\\\]\r
+\[^\r\n\]+:\tc4 e3 7d 1d e4 02\t\( \)?vcvtps2ph xmm4,ymm4,0x2\r
+\[^\r\n\]+:\tc4 43 7d 1d 00 02\t\( \)?vcvtps2ph XMMWORD PTR \\\[r8\\\],ymm8,0x2\r
+\[^\r\n\]+:\tc4 e3 79 1d e4 02\t\( \)?vcvtps2ph xmm4,xmm4,0x2\r
+\[^\r\n\]+:\tc4 e3 79 1d 21 02\t\( \)?vcvtps2ph QWORD PTR \\\[rcx\\\],xmm4,0x2\r
+\[^\r\n\]+:\tc4 e2 7d 13 e4\t\( \)?vcvtph2ps ymm4,xmm4\r
+\[^\r\n\]+:\tc4 42 7d 13 00\t\( \)?vcvtph2ps ymm8,XMMWORD PTR \\\[r8\\\]\r
+\[^\r\n\]+:\tc4 e2 7d 13 21\t\( \)?vcvtph2ps ymm4,XMMWORD PTR \\\[rcx\\\]\r
+\[^\r\n\]+:\tc4 e2 79 13 f4\t\( \)?vcvtph2ps xmm6,xmm4\r
+\[^\r\n\]+:\tc4 e2 79 13 21\t\( \)?vcvtph2ps xmm4,QWORD PTR \\\[rcx\\\]\r
+\[^\r\n\]+:\tc4 e2 79 13 21\t\( \)?vcvtph2ps xmm4,QWORD PTR \\\[rcx\\\]\r
+\[^\r\n\]+:\tc4 e3 7d 1d e4 02\t\( \)?vcvtps2ph xmm4,ymm4,0x2\r
+\[^\r\n\]+:\tc4 e3 7d 1d 21 02\t\( \)?vcvtps2ph XMMWORD PTR \\\[rcx\\\],ymm4,0x2\r
+\[^\r\n\]+:\tc4 e3 7d 1d 21 02\t\( \)?vcvtps2ph XMMWORD PTR \\\[rcx\\\],ymm4,0x2\r
+\[^\r\n\]+:\tc4 e3 79 1d e4 02\t\( \)?vcvtps2ph xmm4,xmm4,0x2\r
+\[^\r\n\]+:\tc4 43 79 1d 00 02\t\( \)?vcvtps2ph QWORD PTR \\\[r8\\\],xmm8,0x2\r
+\[^\r\n\]+:\tc4 e3 79 1d 21 02\t\( \)?vcvtps2ph QWORD PTR \\\[rcx\\\],xmm4,0x2\r
+\[^\r\n\]+:\tf3 0f ae c3\t\( \)?rdfsbase ebx\r
+\[^\r\n\]+:\tf3 48 0f ae c3\t\( \)?rdfsbase rbx\r
+\[^\r\n\]+:\tf3 41 0f ae c0\t\( \)?rdfsbase r8d\r
+\[^\r\n\]+:\tf3 49 0f ae c0\t\( \)?rdfsbase r8\r
+\[^\r\n\]+:\tf3 0f ae cb\t\( \)?rdgsbase ebx\r
+\[^\r\n\]+:\tf3 48 0f ae cb\t\( \)?rdgsbase rbx\r
+\[^\r\n\]+:\tf3 41 0f ae c8\t\( \)?rdgsbase r8d\r
+\[^\r\n\]+:\tf3 49 0f ae c8\t\( \)?rdgsbase r8\r
+\[^\r\n\]+:\tf3 0f ae d3\t\( \)?wrfsbase ebx\r
+\[^\r\n\]+:\tf3 48 0f ae d3\t\( \)?wrfsbase rbx\r
+\[^\r\n\]+:\tf3 41 0f ae d0\t\( \)?wrfsbase r8d\r
+\[^\r\n\]+:\tf3 49 0f ae d0\t\( \)?wrfsbase r8\r
+\[^\r\n\]+:\tf3 0f ae db\t\( \)?wrgsbase ebx\r
+\[^\r\n\]+:\tf3 48 0f ae db\t\( \)?wrgsbase rbx\r
+\[^\r\n\]+:\tf3 41 0f ae d8\t\( \)?wrgsbase r8d\r
+\[^\r\n\]+:\tf3 49 0f ae d8\t\( \)?wrgsbase r8\r
+\[^\r\n\]+:\tf3 0f ae c3\t\( \)?rdfsbase ebx\r
+\[^\r\n\]+:\tf3 48 0f ae c3\t\( \)?rdfsbase rbx\r
+\[^\r\n\]+:\tf3 41 0f ae c0\t\( \)?rdfsbase r8d\r
+\[^\r\n\]+:\tf3 49 0f ae c0\t\( \)?rdfsbase r8\r
+\[^\r\n\]+:\tf3 0f ae cb\t\( \)?rdgsbase ebx\r
+\[^\r\n\]+:\tf3 48 0f ae cb\t\( \)?rdgsbase rbx\r
+\[^\r\n\]+:\tf3 41 0f ae c8\t\( \)?rdgsbase r8d\r
+\[^\r\n\]+:\tf3 49 0f ae c8\t\( \)?rdgsbase r8\r
+\[^\r\n\]+:\tf3 0f ae d3\t\( \)?wrfsbase ebx\r
+\[^\r\n\]+:\tf3 48 0f ae d3\t\( \)?wrfsbase rbx\r
+\[^\r\n\]+:\tf3 41 0f ae d0\t\( \)?wrfsbase r8d\r
+\[^\r\n\]+:\tf3 49 0f ae d0\t\( \)?wrfsbase r8\r
+\[^\r\n\]+:\tf3 0f ae db\t\( \)?wrgsbase ebx\r
+\[^\r\n\]+:\tf3 48 0f ae db\t\( \)?wrgsbase rbx\r
+\[^\r\n\]+:\tf3 41 0f ae d8\t\( \)?wrgsbase r8d\r
+\[^\r\n\]+:\tf3 49 0f ae d8\t\( \)?wrgsbase r8\r
+End of assembler dump\\." "intel"
diff --git a/gdb/testsuite/gdb.arch/i386-ivy-bridge.S b/gdb/testsuite/gdb.arch/i386-ivy-bridge.S
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/i386-ivy-bridge.S
@@ -0,0 +1,66 @@
+/* Copyright 2011 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ This file is part of the gdb testsuite. */
+
+ .globl _start
+_start: .text
+
+/* gas/i386/rdrnd.s */
+ .att_syntax prefix
+ rdrand %bx
+ rdrand %ebx
+
+ .intel_syntax noprefix
+ rdrand bx
+ rdrand ebx
+
+/* gas/i386/f16c.s */
+ .att_syntax prefix
+ vcvtph2ps %xmm4,%ymm4
+ vcvtph2ps (%ecx),%ymm4
+ vcvtph2ps %xmm4,%xmm6
+ vcvtph2ps (%ecx),%xmm4
+ vcvtps2ph $0x2,%ymm4,%xmm4
+ vcvtps2ph $0x2,%ymm4,(%ecx)
+ vcvtps2ph $0x2,%xmm4,%xmm4
+ vcvtps2ph $0x2,%xmm4,(%ecx)
+
+ .intel_syntax noprefix
+ vcvtph2ps ymm4,xmm4
+ vcvtph2ps ymm4,XMMWORD PTR [ecx]
+ vcvtph2ps ymm4,[ecx]
+ vcvtph2ps xmm6,xmm4
+ vcvtph2ps xmm4,QWORD PTR [ecx]
+ vcvtph2ps xmm4,[ecx]
+ vcvtps2ph xmm4,ymm4,0x2
+ vcvtps2ph XMMWORD PTR [ecx],ymm4,0x2
+ vcvtps2ph [ecx],ymm4,0x2
+ vcvtps2ph xmm4,xmm4,0x2
+ vcvtps2ph QWORD PTR [ecx],xmm4,0x2
+ vcvtps2ph [ecx],xmm4,0x2
+
+/* gas/i386/fsgs.s */
+ .att_syntax prefix
+ rdfsbase %ebx
+ rdgsbase %ebx
+ wrfsbase %ebx
+ wrgsbase %ebx
+
+ .intel_syntax noprefix
+ rdfsbase ebx
+ rdgsbase ebx
+ wrfsbase ebx
+ wrgsbase ebx
diff --git a/gdb/testsuite/gdb.arch/i386-ivy-bridge.exp b/gdb/testsuite/gdb.arch/i386-ivy-bridge.exp
new file mode 100644
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/i386-ivy-bridge.exp
@@ -0,0 +1,106 @@
+# Copyright 2011 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/>.
+
+if {![istarget "x86_64-*-*"] && ![istarget "i?86-*-*"]} then {
+ return
+}
+
+set testfile i386-ivy-bridge
+set test compilation
+if [prepare_for_testing ${testfile}.exp ${testfile}.x ${testfile}.S [list debug "additional_flags=-m32 -nostdlib"]] {
+ fail $test
+ return -1
+}
+pass $test
+
+gdb_test_no_output "set disassembly-flavor att"
+# gas/i386/rdrnd.d
+# gas/i386/f16c.d
+# gas/i386/fsgs.d
+gdb_test "disassemble/r _start" "\r
+Dump of assembler code for function _start:\r
+\[^\r\n\]+:\t66 0f c7 f3\t\( \)?rdrand %bx\r
+\[^\r\n\]+:\t0f c7 f3\t\( \)?rdrand %ebx\r
+\[^\r\n\]+:\t66 0f c7 f3\t\( \)?rdrand %bx\r
+\[^\r\n\]+:\t0f c7 f3\t\( \)?rdrand %ebx\r
+\[^\r\n\]+:\tc4 e2 7d 13 e4\t\( \)?vcvtph2ps %xmm4,%ymm4\r
+\[^\r\n\]+:\tc4 e2 7d 13 21\t\( \)?vcvtph2ps \\(%ecx\\),%ymm4\r
+\[^\r\n\]+:\tc4 e2 79 13 f4\t\( \)?vcvtph2ps %xmm4,%xmm6\r
+\[^\r\n\]+:\tc4 e2 79 13 21\t\( \)?vcvtph2ps \\(%ecx\\),%xmm4\r
+\[^\r\n\]+:\tc4 e3 7d 1d e4 02\t\( \)?vcvtps2ph \\\$0x2,%ymm4,%xmm4\r
+\[^\r\n\]+:\tc4 e3 7d 1d 21 02\t\( \)?vcvtps2ph \\\$0x2,%ymm4,\\(%ecx\\)\r
+\[^\r\n\]+:\tc4 e3 79 1d e4 02\t\( \)?vcvtps2ph \\\$0x2,%xmm4,%xmm4\r
+\[^\r\n\]+:\tc4 e3 79 1d 21 02\t\( \)?vcvtps2ph \\\$0x2,%xmm4,\\(%ecx\\)\r
+\[^\r\n\]+:\tc4 e2 7d 13 e4\t\( \)?vcvtph2ps %xmm4,%ymm4\r
+\[^\r\n\]+:\tc4 e2 7d 13 21\t\( \)?vcvtph2ps \\(%ecx\\),%ymm4\r
+\[^\r\n\]+:\tc4 e2 7d 13 21\t\( \)?vcvtph2ps \\(%ecx\\),%ymm4\r
+\[^\r\n\]+:\tc4 e2 79 13 f4\t\( \)?vcvtph2ps %xmm4,%xmm6\r
+\[^\r\n\]+:\tc4 e2 79 13 21\t\( \)?vcvtph2ps \\(%ecx\\),%xmm4\r
+\[^\r\n\]+:\tc4 e2 79 13 21\t\( \)?vcvtph2ps \\(%ecx\\),%xmm4\r
+\[^\r\n\]+:\tc4 e3 7d 1d e4 02\t\( \)?vcvtps2ph \\\$0x2,%ymm4,%xmm4\r
+\[^\r\n\]+:\tc4 e3 7d 1d 21 02\t\( \)?vcvtps2ph \\\$0x2,%ymm4,\\(%ecx\\)\r
+\[^\r\n\]+:\tc4 e3 7d 1d 21 02\t\( \)?vcvtps2ph \\\$0x2,%ymm4,\\(%ecx\\)\r
+\[^\r\n\]+:\tc4 e3 79 1d e4 02\t\( \)?vcvtps2ph \\\$0x2,%xmm4,%xmm4\r
+\[^\r\n\]+:\tc4 e3 79 1d 21 02\t\( \)?vcvtps2ph \\\$0x2,%xmm4,\\(%ecx\\)\r
+\[^\r\n\]+:\tc4 e3 79 1d 21 02\t\( \)?vcvtps2ph \\\$0x2,%xmm4,\\(%ecx\\)\r
+\[^\r\n\]+:\tf3 0f ae c3\t\( \)?rdfsbase %ebx\r
+\[^\r\n\]+:\tf3 0f ae cb\t\( \)?rdgsbase %ebx\r
+\[^\r\n\]+:\tf3 0f ae d3\t\( \)?wrfsbase %ebx\r
+\[^\r\n\]+:\tf3 0f ae db\t\( \)?wrgsbase %ebx\r
+\[^\r\n\]+:\tf3 0f ae c3\t\( \)?rdfsbase %ebx\r
+\[^\r\n\]+:\tf3 0f ae cb\t\( \)?rdgsbase %ebx\r
+\[^\r\n\]+:\tf3 0f ae d3\t\( \)?wrfsbase %ebx\r
+\[^\r\n\]+:\tf3 0f ae db\t\( \)?wrgsbase %ebx\r
+End of assembler dump\\." "att"
+
+gdb_test_no_output "set disassembly-flavor intel"
+# gas/i386/rdrnd-intel.d
+# gas/i386/f16c-intel.d
+# gas/i386/fsgs-intel.d
+gdb_test "disassemble/r _start" "\r
+Dump of assembler code for function _start:\r
+\[^\r\n\]+:\t66 0f c7 f3\t\( \)?rdrand bx\r
+\[^\r\n\]+:\t0f c7 f3\t\( \)?rdrand ebx\r
+\[^\r\n\]+:\t66 0f c7 f3\t\( \)?rdrand bx\r
+\[^\r\n\]+:\t0f c7 f3\t\( \)?rdrand ebx\r
+\[^\r\n\]+:\tc4 e2 7d 13 e4\t\( \)?vcvtph2ps ymm4,xmm4\r
+\[^\r\n\]+:\tc4 e2 7d 13 21\t\( \)?vcvtph2ps ymm4,XMMWORD PTR \\\[ecx\\\]\r
+\[^\r\n\]+:\tc4 e2 79 13 f4\t\( \)?vcvtph2ps xmm6,xmm4\r
+\[^\r\n\]+:\tc4 e2 79 13 21\t\( \)?vcvtph2ps xmm4,QWORD PTR \\\[ecx\\\]\r
+\[^\r\n\]+:\tc4 e3 7d 1d e4 02\t\( \)?vcvtps2ph xmm4,ymm4,0x2\r
+\[^\r\n\]+:\tc4 e3 7d 1d 21 02\t\( \)?vcvtps2ph XMMWORD PTR \\\[ecx\\\],ymm4,0x2\r
+\[^\r\n\]+:\tc4 e3 79 1d e4 02\t\( \)?vcvtps2ph xmm4,xmm4,0x2\r
+\[^\r\n\]+:\tc4 e3 79 1d 21 02\t\( \)?vcvtps2ph QWORD PTR \\\[ecx\\\],xmm4,0x2\r
+\[^\r\n\]+:\tc4 e2 7d 13 e4\t\( \)?vcvtph2ps ymm4,xmm4\r
+\[^\r\n\]+:\tc4 e2 7d 13 21\t\( \)?vcvtph2ps ymm4,XMMWORD PTR \\\[ecx\\\]\r
+\[^\r\n\]+:\tc4 e2 7d 13 21\t\( \)?vcvtph2ps ymm4,XMMWORD PTR \\\[ecx\\\]\r
+\[^\r\n\]+:\tc4 e2 79 13 f4\t\( \)?vcvtph2ps xmm6,xmm4\r
+\[^\r\n\]+:\tc4 e2 79 13 21\t\( \)?vcvtph2ps xmm4,QWORD PTR \\\[ecx\\\]\r
+\[^\r\n\]+:\tc4 e2 79 13 21\t\( \)?vcvtph2ps xmm4,QWORD PTR \\\[ecx\\\]\r
+\[^\r\n\]+:\tc4 e3 7d 1d e4 02\t\( \)?vcvtps2ph xmm4,ymm4,0x2\r
+\[^\r\n\]+:\tc4 e3 7d 1d 21 02\t\( \)?vcvtps2ph XMMWORD PTR \\\[ecx\\\],ymm4,0x2\r
+\[^\r\n\]+:\tc4 e3 7d 1d 21 02\t\( \)?vcvtps2ph XMMWORD PTR \\\[ecx\\\],ymm4,0x2\r
+\[^\r\n\]+:\tc4 e3 79 1d e4 02\t\( \)?vcvtps2ph xmm4,xmm4,0x2\r
+\[^\r\n\]+:\tc4 e3 79 1d 21 02\t\( \)?vcvtps2ph QWORD PTR \\\[ecx\\\],xmm4,0x2\r
+\[^\r\n\]+:\tc4 e3 79 1d 21 02\t\( \)?vcvtps2ph QWORD PTR \\\[ecx\\\],xmm4,0x2\r
+\[^\r\n\]+:\tf3 0f ae c3\t\( \)?rdfsbase ebx\r
+\[^\r\n\]+:\tf3 0f ae cb\t\( \)?rdgsbase ebx\r
+\[^\r\n\]+:\tf3 0f ae d3\t\( \)?wrfsbase ebx\r
+\[^\r\n\]+:\tf3 0f ae db\t\( \)?wrgsbase ebx\r
+\[^\r\n\]+:\tf3 0f ae c3\t\( \)?rdfsbase ebx\r
+\[^\r\n\]+:\tf3 0f ae cb\t\( \)?rdgsbase ebx\r
+\[^\r\n\]+:\tf3 0f ae d3\t\( \)?wrfsbase ebx\r
+\[^\r\n\]+:\tf3 0f ae db\t\( \)?wrgsbase ebx\r
+End of assembler dump\\." "intel"

@ -0,0 +1,68 @@
From b08bf94f170dd39db21cf8f62941f1866b6978c0 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@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

@ -0,0 +1,49 @@
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 <yangtiezhu@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.

@ -0,0 +1,57 @@
From 835a10f8541c7c4150098c82e097c4f606475cfa Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@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.metzger@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

@ -0,0 +1,154 @@
From 1b89c346a99d89a06d9694ca4d47d040d4eebd5a Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@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

@ -0,0 +1,98 @@
From 221ecdef7cc008b01832840d1fbd25d94f8abdd1 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@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

@ -0,0 +1,81 @@
From bbf4e4ba2a9bd73384268b0160d54e36edc92a12 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@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

@ -0,0 +1,93 @@
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 <aburgess@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