aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.arch
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite/gdb.arch')
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-atomic-inst.exp2
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-fp.exp2
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-frameptr-vecreg-unwind.c62
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-frameptr-vecreg-unwind.exp33
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs-core.c123
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs-core.exp116
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs-disp-step.c140
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs-disp-step.exp86
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs-return.c105
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs-return.exp132
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs-tdesc-without-linux.xml65
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs-wrong-tdesc.c26
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs-wrong-tdesc.exp48
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs.c180
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-gcs.exp99
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-mops-single-step.exp2
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.exp2
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-mte-core.exp12
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-mte.exp30
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-non-address-bits.exp2
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-pauth.exp2
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-prologue.exp2
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-pseudo-unwind.exp2
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-sighandler-regs.exp4
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl20
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl34
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl16
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl30
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-sme-sanity.exp4
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-sve-sigunwind.exp14
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-sve.exp4
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-tagged-pointer.exp2
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-unwind-pc.exp2
-rw-r--r--gdb/testsuite/gdb.arch/aarch64-w-registers.exp2
-rw-r--r--gdb/testsuite/gdb.arch/alpha-step.exp31
-rw-r--r--gdb/testsuite/gdb.arch/altivec-abi.exp9
-rw-r--r--gdb/testsuite/gdb.arch/altivec-regs.exp10
-rw-r--r--gdb/testsuite/gdb.arch/amd64-break-on-asm-line.exp2
-rw-r--r--gdb/testsuite/gdb.arch/amd64-byte.exp8
-rw-r--r--gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp1
-rw-r--r--gdb/testsuite/gdb.arch/amd64-disp-step-self-call-alarm.c18
-rw-r--r--gdb/testsuite/gdb.arch/amd64-disp-step-self-call.S23
-rw-r--r--gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp4
-rw-r--r--gdb/testsuite/gdb.arch/amd64-disp-step.exp4
-rw-r--r--gdb/testsuite/gdb.arch/amd64-dword.exp2
-rw-r--r--gdb/testsuite/gdb.arch/amd64-entry-value-inline.exp6
-rw-r--r--gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.exp6
-rw-r--r--gdb/testsuite/gdb.arch/amd64-entry-value-param.exp6
-rw-r--r--gdb/testsuite/gdb.arch/amd64-entry-value-paramref.exp4
-rw-r--r--gdb/testsuite/gdb.arch/amd64-entry-value.exp4
-rw-r--r--gdb/testsuite/gdb.arch/amd64-eval.exp2
-rw-r--r--gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis-no-cfi.S117
-rw-r--r--gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis-offset.S112
-rw-r--r--gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.S143
-rw-r--r--gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.c56
-rw-r--r--gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.exp208
-rw-r--r--gdb/testsuite/gdb.arch/amd64-frameptr-vecreg-unwind.c63
-rw-r--r--gdb/testsuite/gdb.arch/amd64-frameptr-vecreg-unwind.exp40
-rw-r--r--gdb/testsuite/gdb.arch/amd64-gs_base.exp2
-rw-r--r--gdb/testsuite/gdb.arch/amd64-i386-address.exp2
-rw-r--r--gdb/testsuite/gdb.arch/amd64-init-x87-values.exp8
-rw-r--r--gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp10
-rw-r--r--gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp10
-rw-r--r--gdb/testsuite/gdb.arch/amd64-optimout-repeat.exp4
-rw-r--r--gdb/testsuite/gdb.arch/amd64-prologue-skip.exp5
-rw-r--r--gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp6
-rw-r--r--gdb/testsuite/gdb.arch/amd64-pseudo-unwind.exp2
-rw-r--r--gdb/testsuite/gdb.arch/amd64-shadow-stack-cmds.exp143
-rw-r--r--gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.c46
-rw-r--r--gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.exp119
-rw-r--r--gdb/testsuite/gdb.arch/amd64-shadow-stack-disp-step.exp84
-rw-r--r--gdb/testsuite/gdb.arch/amd64-shadow-stack.c40
-rw-r--r--gdb/testsuite/gdb.arch/amd64-shadow-stack.exp71
-rw-r--r--gdb/testsuite/gdb.arch/amd64-tailcall-cxx.exp4
-rw-r--r--gdb/testsuite/gdb.arch/amd64-tailcall-noret.exp4
-rw-r--r--gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp6
-rw-r--r--gdb/testsuite/gdb.arch/amd64-tailcall-self.exp2
-rw-r--r--gdb/testsuite/gdb.arch/amd64-watchpoint-downgrade.exp2
-rw-r--r--gdb/testsuite/gdb.arch/amd64-word.exp2
-rw-r--r--gdb/testsuite/gdb.arch/arc-analyze-prologue.exp4
-rw-r--r--gdb/testsuite/gdb.arch/arc-dbnz.exp2
-rw-r--r--gdb/testsuite/gdb.arch/arc-decode-insn.exp4
-rw-r--r--gdb/testsuite/gdb.arch/arm-cmse-sgstubs.exp2
-rw-r--r--gdb/testsuite/gdb.arch/arm-neon.exp2
-rw-r--r--gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy.exp2
-rw-r--r--gdb/testsuite/gdb.arch/arm-pseudo-unwind.exp2
-rw-r--r--gdb/testsuite/gdb.arch/arm-pthread_cond_timedwait-bt.exp2
-rw-r--r--gdb/testsuite/gdb.arch/avr-flash-qualifier.exp2
-rw-r--r--gdb/testsuite/gdb.arch/disp-step-insn-reloc.exp6
-rw-r--r--gdb/testsuite/gdb.arch/e500-prologue.exp5
-rw-r--r--gdb/testsuite/gdb.arch/e500-regs.exp9
-rw-r--r--gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp10
-rw-r--r--gdb/testsuite/gdb.arch/gdb1291.exp3
-rw-r--r--gdb/testsuite/gdb.arch/gdb1431.exp3
-rw-r--r--gdb/testsuite/gdb.arch/gdb1558.exp3
-rw-r--r--gdb/testsuite/gdb.arch/i386-avx.exp8
-rw-r--r--gdb/testsuite/gdb.arch/i386-avx512.exp12
-rw-r--r--gdb/testsuite/gdb.arch/i386-biarch-core.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-bp_permanent.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-byte.exp8
-rw-r--r--gdb/testsuite/gdb.arch/i386-cfi-notcurrent.exp4
-rw-r--r--gdb/testsuite/gdb.arch/i386-disp-step-self-call-alarm.c18
-rw-r--r--gdb/testsuite/gdb.arch/i386-disp-step-self-call.S23
-rw-r--r--gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp4
-rw-r--r--gdb/testsuite/gdb.arch/i386-dr3-watch.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-gnu-cfi.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-permbkpt.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-pkru.exp6
-rw-r--r--gdb/testsuite/gdb.arch/i386-prologue-skip-cf-protection-stackalign.c27
-rw-r--r--gdb/testsuite/gdb.arch/i386-prologue-skip-cf-protection.exp70
-rw-r--r--gdb/testsuite/gdb.arch/i386-prologue.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-signal.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-size-overlap.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-size.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-sse-stack-align.exp4
-rw-r--r--gdb/testsuite/gdb.arch/i386-sse.exp6
-rw-r--r--gdb/testsuite/gdb.arch/i386-unwind.exp2
-rw-r--r--gdb/testsuite/gdb.arch/i386-word.exp2
-rw-r--r--gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.exp9
-rw-r--r--gdb/testsuite/gdb.arch/mips-fcr.exp2
-rw-r--r--gdb/testsuite/gdb.arch/mips-fpregset-core.exp6
-rw-r--r--gdb/testsuite/gdb.arch/mips-octeon-bbit.exp13
-rw-r--r--gdb/testsuite/gdb.arch/pa-nullify.exp13
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-addpcis.exp14
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp5
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-altivec.exp5
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-altivec2.exp5
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-altivec3.exp5
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-d128-regs.exp12
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-fpscr-gcore.exp2
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-htm-regs.exp13
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-lnia.exp12
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-plxv-nonrel.exp8
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-power10.exp5
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-power7.exp5
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-power8.exp5
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-power9.exp5
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp8
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-prologue-frame.exp4
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-prologue.exp2
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-tar.exp8
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-vector-regs.exp4
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-vsx-gcore.exp2
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-vsx.exp5
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-vsx2.exp5
-rw-r--r--gdb/testsuite/gdb.arch/powerpc-vsx3.exp5
-rw-r--r--gdb/testsuite/gdb.arch/ppc-dfp.exp4
-rw-r--r--gdb/testsuite/gdb.arch/ppc-fp.exp4
-rw-r--r--gdb/testsuite/gdb.arch/ppc-longdouble.exp2
-rw-r--r--gdb/testsuite/gdb.arch/ppc64-break-on-_exit.exp2
-rw-r--r--gdb/testsuite/gdb.arch/pr25124.exp2
-rw-r--r--gdb/testsuite/gdb.arch/riscv-bp-infcall.exp2
-rw-r--r--gdb/testsuite/gdb.arch/riscv-info-fcsr.exp12
-rw-r--r--gdb/testsuite/gdb.arch/s390-vregs.exp28
-rw-r--r--gdb/testsuite/gdb.arch/skip-prologue.exp2
-rw-r--r--gdb/testsuite/gdb.arch/sparc-sysstep.exp4
-rw-r--r--gdb/testsuite/gdb.arch/sparc64-adi.exp2
-rw-r--r--gdb/testsuite/gdb.arch/thumb-bx-pc.exp2
-rw-r--r--gdb/testsuite/gdb.arch/thumb-prologue.exp2
-rw-r--r--gdb/testsuite/gdb.arch/thumb-singlestep.exp2
-rw-r--r--gdb/testsuite/gdb.arch/thumb2-it.exp2
-rw-r--r--gdb/testsuite/gdb.arch/vsx-regs.exp7
-rw-r--r--gdb/testsuite/gdb.arch/vsx-vsr-float28.exp4
163 files changed, 2966 insertions, 433 deletions
diff --git a/gdb/testsuite/gdb.arch/aarch64-atomic-inst.exp b/gdb/testsuite/gdb.arch/aarch64-atomic-inst.exp
index 091d1f8..fa80a9c 100644
--- a/gdb/testsuite/gdb.arch/aarch64-atomic-inst.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-atomic-inst.exp
@@ -25,7 +25,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/aarch64-fp.exp b/gdb/testsuite/gdb.arch/aarch64-fp.exp
index 0c24939..ab4988c 100644
--- a/gdb/testsuite/gdb.arch/aarch64-fp.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-fp.exp
@@ -25,7 +25,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/aarch64-frameptr-vecreg-unwind.c b/gdb/testsuite/gdb.arch/aarch64-frameptr-vecreg-unwind.c
new file mode 100644
index 0000000..44ed3e8
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-frameptr-vecreg-unwind.c
@@ -0,0 +1,62 @@
+/* Copyright 2025 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ 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/>. */
+
+volatile void dummy () {}
+
+long test_function(void)
+{
+ __asm__ volatile (
+ /* Zero d0 (64-bit vector register part of v0). */
+ "movi d0, #0\n\t"
+
+ /* Move the frame pointer (x29) to d0 using fmov. */
+ "fmov d0, x29\n\t"
+
+ /* Describe CFI: Frame pointer is now in d0. */
+ ".cfi_register x29, d0\n\t"
+
+ /* Clobber list: Specify all modified registers. */
+ : /* No output operands. */
+ : /* No input operands. */
+ : "d0"
+ );
+
+ dummy (); /* break-here */
+
+ __asm__ volatile (
+ /* Restore the frame pointer (x29) from d0 using fmov. */
+ "fmov x29, d0\n\t"
+
+ /* Describe CFI: Frame pointer is restored. */
+ ".cfi_restore x29\n\t"
+
+ /* Clobber list: Specify all modified registers. */
+ : /* No output operands. */
+ : /* No input operands. */
+ : "x29", "d0"
+ );
+
+ return 0;
+}
+
+int
+main ()
+{
+ long result = test_function ();
+ dummy ();
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-frameptr-vecreg-unwind.exp b/gdb/testsuite/gdb.arch/aarch64-frameptr-vecreg-unwind.exp
new file mode 100644
index 0000000..2d710bc
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-frameptr-vecreg-unwind.exp
@@ -0,0 +1,33 @@
+# Copyright 2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+require is_aarch64_target
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" ${testfile} \
+ "${srcfile}" {debug}] } {
+ return -1
+}
+
+if {![runto_main]} {
+ return
+}
+
+gdb_breakpoint [gdb_get_line_number "break-here"]
+gdb_continue_to_breakpoint "break-here"
+gdb_test "with confirm off --return -1" "result = test_function \\(\\);"
+gdb_test "step" "dummy \\(\\);"
+gdb_test "print result" "= -1"
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs-core.c b/gdb/testsuite/gdb.arch/aarch64-gcs-core.c
new file mode 100644
index 0000000..f3362cb
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs-core.c
@@ -0,0 +1,123 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2025 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/auxv.h>
+#include <linux/prctl.h>
+#include <sys/syscall.h>
+
+/* Feature check for Guarded Control Stack. */
+#ifndef HWCAP_GCS
+#define HWCAP_GCS (1ULL << 32)
+#endif
+
+#ifndef PR_GET_SHADOW_STACK_STATUS
+#define PR_GET_SHADOW_STACK_STATUS 74
+#define PR_SET_SHADOW_STACK_STATUS 75
+#define PR_SHADOW_STACK_ENABLE (1UL << 0)
+#endif
+
+/* We need to use a macro to call prctl because after GCS is enabled, it's not
+ possible to return from the function which enabled it. This is because the
+ return address of the calling function isn't on the GCS. */
+#define my_syscall2(num, arg1, arg2) \
+ ({ \
+ register long _num __asm__("x8") = (num); \
+ register long _arg1 __asm__("x0") = (long)(arg1); \
+ register long _arg2 __asm__("x1") = (long)(arg2); \
+ register long _arg3 __asm__("x2") = 0; \
+ register long _arg4 __asm__("x3") = 0; \
+ register long _arg5 __asm__("x4") = 0; \
+ \
+ __asm__ volatile ("svc #0\n" \
+ : "=r"(_arg1) \
+ : "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4), \
+ "r"(_arg5), "r"(_num) \
+ : "memory", "cc"); \
+ _arg1; \
+ })
+
+#define get_gcspr(void) \
+ ({ \
+ unsigned long *gcspr; \
+ \
+ /* Get GCSPR_EL0. */ \
+ asm volatile ("mrs %0, S3_3_C2_C5_1" : "=r"(gcspr) : : "cc"); \
+ \
+ gcspr; \
+ })
+
+/* Corrupt the return address to see if GDB will report a SIGSEGV with the
+ expected $_siginfo.si_code. */
+static void __attribute__ ((noinline))
+function (unsigned long *gcspr)
+{
+ /* x30 holds the return address. */
+ register long x30 __asm__("x30") __attribute__ ((unused));
+
+ /* Print GCSPR to stdout so that the testcase can capture it. */
+ printf ("%p\n", get_gcspr ());
+ fflush (stdout);
+
+ /* Cause a GCS exception. */
+ x30 = 0xbadc0ffee;
+ __asm__ volatile ("ret\n");
+}
+
+int
+main (void)
+{
+ if (!(getauxval (AT_HWCAP) & HWCAP_GCS))
+ {
+ fprintf (stderr, "GCS support not found in AT_HWCAP\n");
+ return EXIT_FAILURE;
+ }
+
+ /* Force shadow stacks on, our tests *should* be fine with or
+ without libc support and with or without this having ended
+ up tagged for GCS and enabled by the dynamic linker. We
+ can't use the libc prctl() function since we can't return
+ from enabling the stack. Also lock GCS if not already
+ locked so we can test behaviour when it's locked. */
+ unsigned long gcs_mode;
+ int ret = my_syscall2 (__NR_prctl, PR_GET_SHADOW_STACK_STATUS, &gcs_mode);
+ if (ret)
+ {
+ fprintf (stderr, "Failed to read GCS state: %d\n", ret);
+ return EXIT_FAILURE;
+ }
+
+ if (!(gcs_mode & PR_SHADOW_STACK_ENABLE))
+ {
+ gcs_mode = PR_SHADOW_STACK_ENABLE;
+ ret = my_syscall2 (__NR_prctl, PR_SET_SHADOW_STACK_STATUS, gcs_mode);
+ if (ret)
+ {
+ fprintf (stderr, "Failed to configure GCS: %d\n", ret);
+ return EXIT_FAILURE;
+ }
+ }
+
+ unsigned long *gcspr = get_gcspr ();
+
+ /* Pass gscpr to function just so it's used for something. */
+ function (gcspr); /* Break here. */
+
+ /* Avoid returning, in case libc doesn't understand GCS. */
+ exit (EXIT_SUCCESS);
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs-core.exp b/gdb/testsuite/gdb.arch/aarch64-gcs-core.exp
new file mode 100644
index 0000000..66990eb
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs-core.exp
@@ -0,0 +1,116 @@
+# Copyright 2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test reading and writing the core dump of a binary that uses a Guarded
+# Control Stack.
+
+require allow_aarch64_gcs_tests
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
+ return
+}
+
+set linespec ${srcfile}:[gdb_get_line_number "Break here"]
+
+if {![runto $linespec]} {
+ return
+}
+
+# Obtain an OS-generated core file. Save test program output to
+# ${binfile}.out.
+set core_filename [core_find $binfile {} {} "${binfile}.out"]
+set core_generated [expr {$core_filename != ""}]
+
+# Make sure GDB can read the given core file correctly.
+proc check_core_file {core_filename saved_gcspr} {
+ global decimal hex
+
+ # Load the core file.
+ if {[gdb_test "core $core_filename" \
+ [multi_line \
+ "Core was generated by .*\\." \
+ "Program terminated with signal SIGSEGV, Segmentation fault" \
+ "Guarded Control Stack error\\." \
+ "#0 function \\(gcspr=$hex\\) at .*aarch64-gcs-core.c:$decimal" \
+ "$decimal.*__asm__ volatile \\(\"ret\\\\n\"\\);"] \
+ "load core file"]} {
+ return -1
+ }
+
+ # Check the value of GCSPR in the core file.
+ gdb_test "print/x \$gcspr" "\\$\[0-9\]+ = $saved_gcspr" \
+ "gcspr contents from core file"
+}
+
+if {!$core_generated} {
+ untested "unable to create or find corefile"
+}
+
+if {$core_generated} {
+ clean_restart
+ gdb_load $binfile
+
+ with_test_prefix "OS corefile" {
+ # Read GCSPR value from saved output of the test program.
+ set out_id [open ${binfile}.out "r"]
+ set gcspr_in_core [gets $out_id]
+ close $out_id
+
+ check_core_file $core_filename $gcspr_in_core
+ }
+}
+
+if {![gcore_cmd_available]} {
+ unsupported "target does not support gcore command."
+ return
+}
+
+clean_restart
+gdb_load $binfile
+
+if {![runto $linespec]} {
+ return
+}
+
+# Continue until a crash. The line with the hex number is optional because
+# it's printed by the test program, and doesn't appear in the Expect buffer
+# when testing a remote target.
+gdb_test "continue" \
+ [multi_line \
+ "Continuing\\." \
+ "($hex\r\n)?" \
+ "Program received signal SIGSEGV, Segmentation fault" \
+ "Guarded Control Stack error\\." \
+ "function \\(gcspr=$hex\\) at .*aarch64-gcs-core.c:$decimal" \
+ {.*__asm__ volatile \("ret\\n"\);}] \
+ "continue to SIGSEGV"
+
+set gcspr_in_gcore [get_valueof "/x" "\$gcspr" "*unknown*"]
+
+# Generate the gcore core file.
+set gcore_filename [standard_output_file "${testfile}.gcore"]
+set gcore_generated [gdb_gcore_cmd "$gcore_filename" "generate gcore file"]
+
+gdb_assert { $gcore_generated } "gcore corefile created"
+if {$gcore_generated} {
+ clean_restart
+ gdb_load $binfile
+
+ with_test_prefix "gcore corefile" {
+ check_core_file $gcore_filename $gcspr_in_gcore
+ }
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs-disp-step.c b/gdb/testsuite/gdb.arch/aarch64-gcs-disp-step.c
new file mode 100644
index 0000000..754fda1
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs-disp-step.c
@@ -0,0 +1,140 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2025 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/auxv.h>
+#include <sys/syscall.h>
+#include <linux/prctl.h>
+
+/* Feature check for Guarded Control Stack. */
+#ifndef HWCAP_GCS
+#define HWCAP_GCS (1ULL << 32)
+#endif
+
+#ifndef PR_GET_SHADOW_STACK_STATUS
+#define PR_GET_SHADOW_STACK_STATUS 74
+#define PR_SET_SHADOW_STACK_STATUS 75
+#define PR_SHADOW_STACK_ENABLE (1UL << 0)
+#endif
+
+/* We need to use a macro to call prctl because after GCS is enabled, it's not
+ possible to return from the function which enabled it. This is because the
+ return address of the calling function isn't on the GCS. */
+#define my_syscall2(num, arg1, arg2) \
+ ({ \
+ register long _num __asm__("x8") = (num); \
+ register long _arg1 __asm__("x0") = (long)(arg1); \
+ register long _arg2 __asm__("x1") = (long)(arg2); \
+ register long _arg3 __asm__("x2") = 0; \
+ register long _arg4 __asm__("x3") = 0; \
+ register long _arg5 __asm__("x4") = 0; \
+ \
+ __asm__ volatile("svc #0\n" \
+ : "=r"(_arg1) \
+ : "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4), \
+ "r"(_arg5), "r"(_num) \
+ : "memory", "cc"); \
+ _arg1; \
+ })
+
+#define get_gcspr(void) \
+ ({ \
+ unsigned long *gcspr; \
+ \
+ /* Get GCSPR_EL0. */ \
+ asm volatile("mrs %0, S3_3_C2_C5_1" : "=r"(gcspr) : : "cc"); \
+ \
+ gcspr; \
+ })
+
+static int __attribute__ ((noinline))
+function2 (void)
+{
+ return EXIT_SUCCESS;
+}
+
+/* Put branch and link instructions being tested into their own functions so
+ that the program returns one level up in the stack after the displaced
+ stepped instruction. This tests that GDB doesn't leave the GCS out of sync
+ with the regular stack. */
+
+static int __attribute__ ((noinline))
+function_bl (void)
+{
+ register int x0 __asm__("x0");
+
+ __asm__ ("bl function2\n"
+ : "=r"(x0)
+ :
+ : "x30");
+
+ return x0;
+}
+
+static int __attribute__ ((noinline))
+function_blr (void)
+{
+ register int x0 __asm__("x0");
+
+ __asm__ ("blr %1\n"
+ : "=r"(x0)
+ : "r"(&function2)
+ : "x30");
+
+ return x0;
+}
+
+int
+main (void)
+{
+ if (!(getauxval (AT_HWCAP) & HWCAP_GCS))
+ {
+ fprintf (stderr, "GCS support not found in AT_HWCAP\n");
+ return EXIT_FAILURE;
+ }
+
+ /* Force shadow stacks on, our tests *should* be fine with or
+ without libc support and with or without this having ended
+ up tagged for GCS and enabled by the dynamic linker. We
+ can't use the libc prctl() function since we can't return
+ from enabling the stack. */
+ unsigned long gcs_mode;
+ int ret = my_syscall2 (__NR_prctl, PR_GET_SHADOW_STACK_STATUS, &gcs_mode);
+ if (ret)
+ {
+ fprintf (stderr, "Failed to read GCS state: %d\n", ret);
+ return EXIT_FAILURE;
+ }
+
+ if (!(gcs_mode & PR_SHADOW_STACK_ENABLE))
+ {
+ gcs_mode = PR_SHADOW_STACK_ENABLE;
+ ret = my_syscall2 (__NR_prctl, PR_SET_SHADOW_STACK_STATUS, gcs_mode);
+ if (ret)
+ {
+ fprintf (stderr, "Failed to configure GCS: %d\n", ret);
+ return EXIT_FAILURE;
+ }
+ }
+
+ int ret1 = function_bl ();
+ int ret2 = function_blr ();
+
+ /* Avoid returning, in case libc doesn't understand GCS. */
+ exit (ret1 + ret2);
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs-disp-step.exp b/gdb/testsuite/gdb.arch/aarch64-gcs-disp-step.exp
new file mode 100644
index 0000000..e625251
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs-disp-step.exp
@@ -0,0 +1,86 @@
+# Copyright 2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test displaced stepping in a program that uses a Guarded Control Stack.
+
+require allow_aarch64_gcs_tests
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
+ return
+}
+
+if {![runto_main]} {
+ return
+}
+
+gdb_test_no_output "set breakpoint auto-hw off"
+gdb_test_no_output "set displaced-stepping on"
+
+# Get address of the branch and link instructions of interest.
+set addr_bl 0
+set test "get address of bl instruction"
+gdb_test_multiple "disassemble function_bl" $test -lbl {
+ -re "\r\n\\s+($hex) <\\+${decimal}>:\\s+bl\\s+${hex} <function2>(?=\r\n)" {
+ set addr_bl $expect_out(1,string)
+ exp_continue
+ }
+ -re -wrap "" {
+ gdb_assert { $addr_bl != 0 } $test
+ }
+}
+
+set addr_blr 0
+set test "get address of blr instruction"
+gdb_test_multiple "disassemble function_blr" $test -lbl {
+ -re "\r\n\\s+($hex) <\\+${decimal}>:\\s+blr\\s+x${decimal}(?=\r\n)" {
+ set addr_blr $expect_out(1,string)
+ exp_continue
+ }
+ -re -wrap "" {
+ gdb_assert { $addr_blr != 0 } $test
+ }
+}
+
+if { $addr_bl == 0 || $addr_blr == 0 } {
+ return
+}
+
+gdb_test "break *$addr_bl" \
+ "Breakpoint $decimal at $hex: file .*aarch64-gcs-disp-step.c, line ${decimal}." \
+ "set breakpoint at bl instruction"
+
+gdb_test "break *$addr_blr" \
+ "Breakpoint $decimal at $hex: file .*aarch64-gcs-disp-step.c, line ${decimal}." \
+ "set breakpoint at blr instruction"
+
+gdb_test "continue" \
+ [multi_line \
+ {Continuing\.} \
+ "" \
+ "Breakpoint $decimal, function_bl \\(\\) at .*aarch64-gcs-disp-step.c:${decimal}(?: \\\[GCS error\\\])?" \
+ {[^\r\n]+"bl function2\\n"}] \
+ "continue to breakpoint at bl"
+
+gdb_test "continue" \
+ [multi_line \
+ {Continuing\.} \
+ "" \
+ "Breakpoint $decimal, $hex in function_blr \\(\\) at .*aarch64-gcs-disp-step.c:${decimal}(?: \\\[GCS error\\\])?" \
+ {[^\r\n]+"blr %1\\n"}] \
+ "continue to breakpoint at blr"
+
+gdb_continue_to_end
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs-return.c b/gdb/testsuite/gdb.arch/aarch64-gcs-return.c
new file mode 100644
index 0000000..c062fea
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs-return.c
@@ -0,0 +1,105 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2025 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/auxv.h>
+#include <sys/syscall.h>
+#include <linux/prctl.h>
+
+/* Feature check for Guarded Control Stack. */
+#ifndef HWCAP_GCS
+#define HWCAP_GCS (1ULL << 32)
+#endif
+
+#ifndef PR_GET_SHADOW_STACK_STATUS
+#define PR_GET_SHADOW_STACK_STATUS 74
+#define PR_SET_SHADOW_STACK_STATUS 75
+#define PR_SHADOW_STACK_ENABLE (1UL << 0)
+#endif
+
+/* We need to use a macro to call prctl because after GCS is enabled, it's not
+ possible to return from the function which enabled it. This is because the
+ return address of the calling function isn't on the GCS. */
+#define my_syscall2(num, arg1, arg2) \
+ ({ \
+ register long _num __asm__("x8") = (num); \
+ register long _arg1 __asm__("x0") = (long)(arg1); \
+ register long _arg2 __asm__("x1") = (long)(arg2); \
+ register long _arg3 __asm__("x2") = 0; \
+ register long _arg4 __asm__("x3") = 0; \
+ register long _arg5 __asm__("x4") = 0; \
+ \
+ __asm__ volatile("svc #0\n" \
+ : "=r"(_arg1) \
+ : "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4), \
+ "r"(_arg5), "r"(_num) \
+ : "memory", "cc"); \
+ _arg1; \
+ })
+
+static int __attribute__ ((noinline))
+call2 ()
+{
+ return 42; /* Break call2. */
+}
+
+static int __attribute__ ((noinline))
+call1 ()
+{
+ return call2 (); /* Break call1. */
+}
+
+int
+main ()
+{
+ if (!(getauxval (AT_HWCAP) & HWCAP_GCS))
+ {
+ fprintf (stderr, "GCS support not found in AT_HWCAP\n");
+ return EXIT_FAILURE;
+ }
+
+ /* Force shadow stacks on, our tests *should* be fine with or
+ without libc support and with or without this having ended
+ up tagged for GCS and enabled by the dynamic linker. We
+ can't use the libc prctl() function since we can't return
+ from enabling the stack. Also lock GCS if not already
+ locked so we can test behaviour when it's locked. */
+ unsigned long gcs_mode;
+ int ret = my_syscall2 (__NR_prctl, PR_GET_SHADOW_STACK_STATUS, &gcs_mode);
+ if (ret)
+ {
+ fprintf (stderr, "Failed to read GCS state: %d\n", ret);
+ return EXIT_FAILURE;
+ }
+
+ if (!(gcs_mode & PR_SHADOW_STACK_ENABLE))
+ {
+ gcs_mode = PR_SHADOW_STACK_ENABLE;
+ ret = my_syscall2 (__NR_prctl, PR_SET_SHADOW_STACK_STATUS, gcs_mode);
+ if (ret)
+ {
+ fprintf (stderr, "Failed to configure GCS: %d\n", ret);
+ return EXIT_FAILURE;
+ }
+ }
+
+ call1 (); /* Break begin. */
+
+ /* Avoid returning, in case libc doesn't understand GCS. */
+ exit (EXIT_SUCCESS);
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs-return.exp b/gdb/testsuite/gdb.arch/aarch64-gcs-return.exp
new file mode 100644
index 0000000..7e531e8
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs-return.exp
@@ -0,0 +1,132 @@
+# Copyright 2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test the GDB return command in a program that uses a Guarded Control Stack.
+# Based on the return tests in gdb.arch/amd64-shadow-stack-cmds.exp.
+# Note that potential GCS violations often only occur after resuming normal
+# execution. Therefore, it is important to test normal program
+# completion after testing the return command.
+
+require allow_aarch64_gcs_tests
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
+ return
+}
+
+set begin_line [gdb_get_line_number "Break begin"]
+set call1_line [gdb_get_line_number "Break call1"]
+set call2_line [gdb_get_line_number "Break call2"]
+
+if {![runto ${begin_line}]} {
+ return
+}
+
+proc restart_and_run_infcall_call2 {} {
+ global binfile call2_line
+ clean_restart
+ gdb_load $binfile
+ if {![runto_main]} {
+ return
+ }
+ set inside_infcall_str "The program being debugged stopped while in a function called from GDB"
+ gdb_breakpoint ${call2_line}
+ gdb_continue_to_breakpoint "Break call2" ".*Break call2.*"
+ gdb_test "call (int) call2()" \
+ "Breakpoint \[0-9\]*, call2.*$inside_infcall_str.*"
+}
+
+with_test_prefix "test inferior call and continue" {
+ gdb_breakpoint ${call1_line}
+ gdb_continue_to_breakpoint "Break call1" ".*Break call1.*"
+
+ gdb_test "call (int) call2()" "= 42"
+
+ gdb_continue_to_end
+}
+
+with_test_prefix "test return inside an inferior call" {
+ restart_and_run_infcall_call2
+
+ gdb_test "return" "\#0.*call2.*" \
+ "Test GCS return inside an inferior call" \
+ "Make.*return now\\? \\(y or n\\) " "y"
+
+ gdb_continue_to_end
+}
+
+with_test_prefix "test return 'above' an inferior call" {
+ restart_and_run_infcall_call2
+
+ gdb_test "frame 2" "call2 ().*" "move to frame 'above' inferior call"
+
+ gdb_test "return" "\#0.*call1.*" \
+ "Test GCS return 'above' an inferior call" \
+ "Make.*return now\\? \\(y or n\\) " "y"
+
+ gdb_continue_to_end
+}
+
+clean_restart
+gdb_load $binfile
+if {![runto ${begin_line}]} {
+ return
+}
+
+# Extract GCS pointer inside main, call1 and call2 function.
+gdb_breakpoint ${call1_line}
+gdb_breakpoint ${call2_line}
+set gcspr_main [get_valueof /x "\$gcspr" 0 "get value of gcspr in main"]
+gdb_continue_to_breakpoint "Break call1" ".*Break call1.*"
+set gcspr_call1 [get_valueof /x "\$gcspr" 0 "get value of gcspr in call1"]
+gdb_continue_to_breakpoint "Break call2" ".*Break call2.*"
+set gcspr_call2 [get_valueof /x "\$gcspr" 0 "get value of gcspr in call2"]
+
+with_test_prefix "test frame level update" {
+ gdb_test "up" "call1.*" "move to frame 1"
+ gdb_test "print /x \$gcspr" "= $gcspr_call1" "check gcspr of frame 1"
+ gdb_test "up" "main.*" "move to frame 2"
+ gdb_test "print /x \$gcspr" "= $gcspr_main" "check gcspr of frame 2"
+ gdb_test "frame 0" "call2.*" "move to frame 0"
+ gdb_test "print /x \$gcspr" "= $gcspr_call2" "check gcspr of frame 0"
+}
+
+with_test_prefix "test return from current frame" {
+ gdb_test "return (int) 1" "#0.*call1.*" \
+ "Test GCS return from current frame" \
+ "Make.*return now\\? \\(y or n\\) " "y"
+
+ gdb_continue_to_end
+}
+
+clean_restart
+gdb_load $binfile
+if {![runto_main]} {
+ return
+}
+
+with_test_prefix "test return from past frame" {
+ gdb_breakpoint ${call2_line}
+ gdb_continue_to_breakpoint "Break call2" ".*Break call2.*"
+
+ gdb_test "frame 1" ".*in call1.*"
+
+ gdb_test "return (int) 1" "#0.*main.*" \
+ "Test GCS return from past frame" \
+ "Make.*return now\\? \\(y or n\\) " "y"
+
+ gdb_continue_to_end
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs-tdesc-without-linux.xml b/gdb/testsuite/gdb.arch/aarch64-gcs-tdesc-without-linux.xml
new file mode 100644
index 0000000..056ab58
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs-tdesc-without-linux.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+<!DOCTYPE target SYSTEM "gdb-target.dtd">
+<target>
+ <architecture>aarch64</architecture>
+ <feature name="org.gnu.gdb.aarch64.core">
+ <flags id="cpsr_flags" size="4">
+ <field name="SP" start="0" end="0" type="bool"/>
+ <field name="EL" start="2" end="3" type="uint32"/>
+ <field name="nRW" start="4" end="4" type="bool"/>
+ <field name="F" start="6" end="6" type="bool"/>
+ <field name="I" start="7" end="7" type="bool"/>
+ <field name="A" start="8" end="8" type="bool"/>
+ <field name="D" start="9" end="9" type="bool"/>
+ <field name="BTYPE" start="10" end="11" type="uint32"/>
+ <field name="SSBS" start="12" end="12" type="bool"/>
+ <field name="IL" start="20" end="20" type="bool"/>
+ <field name="SS" start="21" end="21" type="bool"/>
+ <field name="PAN" start="22" end="22" type="bool"/>
+ <field name="UAO" start="23" end="23" type="bool"/>
+ <field name="DIT" start="24" end="24" type="bool"/>
+ <field name="TCO" start="25" end="25" type="bool"/>
+ <field name="V" start="28" end="28" type="bool"/>
+ <field name="C" start="29" end="29" type="bool"/>
+ <field name="Z" start="30" end="30" type="bool"/>
+ <field name="N" start="31" end="31" type="bool"/>
+ </flags>
+ <reg name="x0" bitsize="64" type="int" regnum="0"/>
+ <reg name="x1" bitsize="64" type="int" regnum="1"/>
+ <reg name="x2" bitsize="64" type="int" regnum="2"/>
+ <reg name="x3" bitsize="64" type="int" regnum="3"/>
+ <reg name="x4" bitsize="64" type="int" regnum="4"/>
+ <reg name="x5" bitsize="64" type="int" regnum="5"/>
+ <reg name="x6" bitsize="64" type="int" regnum="6"/>
+ <reg name="x7" bitsize="64" type="int" regnum="7"/>
+ <reg name="x8" bitsize="64" type="int" regnum="8"/>
+ <reg name="x9" bitsize="64" type="int" regnum="9"/>
+ <reg name="x10" bitsize="64" type="int" regnum="10"/>
+ <reg name="x11" bitsize="64" type="int" regnum="11"/>
+ <reg name="x12" bitsize="64" type="int" regnum="12"/>
+ <reg name="x13" bitsize="64" type="int" regnum="13"/>
+ <reg name="x14" bitsize="64" type="int" regnum="14"/>
+ <reg name="x15" bitsize="64" type="int" regnum="15"/>
+ <reg name="x16" bitsize="64" type="int" regnum="16"/>
+ <reg name="x17" bitsize="64" type="int" regnum="17"/>
+ <reg name="x18" bitsize="64" type="int" regnum="18"/>
+ <reg name="x19" bitsize="64" type="int" regnum="19"/>
+ <reg name="x20" bitsize="64" type="int" regnum="20"/>
+ <reg name="x21" bitsize="64" type="int" regnum="21"/>
+ <reg name="x22" bitsize="64" type="int" regnum="22"/>
+ <reg name="x23" bitsize="64" type="int" regnum="23"/>
+ <reg name="x24" bitsize="64" type="int" regnum="24"/>
+ <reg name="x25" bitsize="64" type="int" regnum="25"/>
+ <reg name="x26" bitsize="64" type="int" regnum="26"/>
+ <reg name="x27" bitsize="64" type="int" regnum="27"/>
+ <reg name="x28" bitsize="64" type="int" regnum="28"/>
+ <reg name="x29" bitsize="64" type="int" regnum="29"/>
+ <reg name="x30" bitsize="64" type="int" regnum="30"/>
+ <reg name="sp" bitsize="64" type="data_ptr" regnum="31"/>
+ <reg name="pc" bitsize="64" type="code_ptr" regnum="32"/>
+ <reg name="cpsr" bitsize="32" type="cpsr_flags" regnum="33"/>
+ </feature>
+ <feature name="org.gnu.gdb.aarch64.gcs">
+ <reg name="gcspr" bitsize="64" type="data_ptr" regnum="90" group="system"/>
+ </feature>
+</target>
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs-wrong-tdesc.c b/gdb/testsuite/gdb.arch/aarch64-gcs-wrong-tdesc.c
new file mode 100644
index 0000000..10cf749
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs-wrong-tdesc.c
@@ -0,0 +1,26 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2025 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+
+int
+main (void)
+{
+ printf ("Hello, world!\n");
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs-wrong-tdesc.exp b/gdb/testsuite/gdb.arch/aarch64-gcs-wrong-tdesc.exp
new file mode 100644
index 0000000..ba7741f
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs-wrong-tdesc.exp
@@ -0,0 +1,48 @@
+# Copyright 2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test that GDB complains when given a target description with the GCS feature
+# but not the GCS Linux feature.
+
+require allow_aarch64_gcs_tests
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
+ return
+}
+
+set xml_path "${srcdir}/${subdir}/aarch64-gcs-tdesc-without-linux.xml"
+
+gdb_test "set tdesc filename ${xml_path}" \
+ "warning: Incomplete GCS support in the target: missing Linux part. GCS feature disabled." \
+ "warn about incomplete GCS support"
+
+# We can't test a debugging session on a remote target because with the
+# wrong tdesc, GDB expects a g packet reply with the wrong size.
+if {[gdb_protocol_is_remote]} {
+ return
+}
+
+if {![runto_main]} {
+ return
+}
+
+gdb_test "print \$gcspr" " = <unavailable>" "GCSPR is unavailable"
+
+# Now check that we can continue the debugging session normally.
+gdb_test "next"
+
+gdb_continue_to_end
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs.c b/gdb/testsuite/gdb.arch/aarch64-gcs.c
new file mode 100644
index 0000000..9eb2e9e
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs.c
@@ -0,0 +1,180 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2025 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <sys/auxv.h>
+#include <sys/syscall.h>
+#include <linux/prctl.h>
+
+/* Feature check for Guarded Control Stack. */
+#ifndef HWCAP_GCS
+#define HWCAP_GCS (1ULL << 32)
+#endif
+
+#ifndef PR_GET_SHADOW_STACK_STATUS
+#define PR_GET_SHADOW_STACK_STATUS 74
+#define PR_SET_SHADOW_STACK_STATUS 75
+#define PR_SHADOW_STACK_ENABLE (1UL << 0)
+#endif
+
+/* We need to use a macro to call prctl because after GCS is enabled, it's not
+ possible to return from the function which enabled it. This is because the
+ return address of the calling function isn't on the GCS. */
+#define my_syscall2(num, arg1, arg2) \
+ ({ \
+ register long _num __asm__("x8") = (num); \
+ register long _arg1 __asm__("x0") = (long)(arg1); \
+ register long _arg2 __asm__("x1") = (long)(arg2); \
+ register long _arg3 __asm__("x2") = 0; \
+ register long _arg4 __asm__("x3") = 0; \
+ register long _arg5 __asm__("x4") = 0; \
+ \
+ __asm__ volatile ("svc #0\n" \
+ : "=r"(_arg1) \
+ : "r"(_arg1), "r"(_arg2), "r"(_arg3), "r"(_arg4), \
+ "r"(_arg5), "r"(_num) \
+ : "memory", "cc"); \
+ _arg1; \
+ })
+
+#define get_gcspr(void) \
+ ({ \
+ unsigned long *gcspr; \
+ \
+ /* Get GCSPR_EL0. */ \
+ asm volatile ("mrs %0, S3_3_C2_C5_1" : "=r"(gcspr) : : "cc"); \
+ \
+ gcspr; \
+ })
+
+static unsigned long *handler_gcspr = 0;
+
+static void
+handler (int sig)
+{
+ handler_gcspr = get_gcspr ();
+}
+
+static int __attribute__ ((unused))
+called_from_gdb (int val)
+{
+ return val + 1;
+}
+
+/* Corrupt the return address to see if GDB will report a SIGSEGV with the
+ expected $_siginfo.si_code. */
+static void __attribute__ ((noinline))
+normal_function2 (void)
+{
+ /* x30 holds the return address. */
+ register unsigned long x30 __asm__("x30") __attribute__ ((unused));
+
+ /* Cause a GCS exception. */
+ x30 = 0xbadc0ffee;
+ /* Use explicit ret so that we can verify that a SIGSEGV was generated
+ exactly on the return instruction. */
+ __asm__ volatile ("ret\n");
+}
+
+static inline void __attribute__ ((__always_inline__))
+inline_function2 (void)
+{
+ normal_function2 ();
+}
+
+static void __attribute__ ((noinline))
+normal_function1 (void)
+{
+ inline_function2 ();
+}
+
+/* First in a sequence of inline and normal functions, to test GDB
+ backtrace. */
+static inline void __attribute__ ((__always_inline__))
+inline_function1 (void)
+{
+ normal_function1 ();
+}
+
+/* Trivial function, just so that GDB can test return with wrong GCSPR. */
+static void __attribute__ ((noinline))
+normal_function0 (void)
+{
+ /* Use explicit ret so that we can verify that a SIGSEGV was generated
+ exactly on the return instruction. */
+ __asm__ volatile ("ret\n");
+}
+
+int
+main (void)
+{
+ if (!(getauxval (AT_HWCAP) & HWCAP_GCS))
+ {
+ fprintf (stderr, "GCS support not found in AT_HWCAP\n");
+ return EXIT_FAILURE;
+ }
+
+ /* Force shadow stacks on, our tests *should* be fine with or
+ without libc support and with or without this having ended
+ up tagged for GCS and enabled by the dynamic linker. We
+ can't use the libc prctl() function since we can't return
+ from enabling the stack. Also lock GCS if not already
+ locked so we can test behaviour when it's locked. */
+ unsigned long gcs_mode;
+ int ret = my_syscall2 (__NR_prctl, PR_GET_SHADOW_STACK_STATUS, &gcs_mode);
+ if (ret)
+ {
+ fprintf (stderr, "Failed to read GCS state: %d\n", ret);
+ return EXIT_FAILURE;
+ }
+
+ if (!(gcs_mode & PR_SHADOW_STACK_ENABLE))
+ {
+ gcs_mode = PR_SHADOW_STACK_ENABLE;
+ ret = my_syscall2 (__NR_prctl, PR_SET_SHADOW_STACK_STATUS, gcs_mode);
+ if (ret)
+ {
+ fprintf (stderr, "Failed to configure GCS: %d\n", ret);
+ return EXIT_FAILURE;
+ }
+ }
+
+ /* Regular function call. */
+ normal_function0 ();
+
+ /* This is used by GDB. */
+ __attribute__((unused)) unsigned long *gcspr = get_gcspr ();
+
+ struct sigaction act = { 0 };
+
+ act.sa_handler = &handler; /* Break here. */
+ if (sigaction (SIGUSR1, &act, NULL) == -1)
+ {
+ perror ("sigaction");
+ exit (EXIT_FAILURE);
+ }
+
+ raise (SIGUSR1);
+
+/* Call sequence of inline and normal functions, to test GDB backtrace. */
+ inline_function1 ();
+
+ /* Avoid returning, in case libc doesn't understand GCS. */
+ exit (EXIT_SUCCESS);
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-gcs.exp b/gdb/testsuite/gdb.arch/aarch64-gcs.exp
new file mode 100644
index 0000000..63c18a1
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-gcs.exp
@@ -0,0 +1,99 @@
+# Copyright 2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test a binary that uses a Guarded Control Stack.
+
+require allow_aarch64_gcs_tests
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
+ return
+}
+
+set linespec ${srcfile}:[gdb_get_line_number "Break here"]
+
+if {![runto ${linespec}]} {
+ return
+}
+
+gdb_test "print \$gcs_features_enabled" \
+ [string_to_regexp { = [ PR_SHADOW_STACK_ENABLE ]}] \
+ "GCS is enabled"
+
+gdb_test "print \$gcspr" ". = \\(void \\*\\) $hex" "GDB knows about gcspr"
+gdb_test "print \$gcspr == gcspr" ". = 1" "GDB has the correct gcspr value"
+gdb_test_no_output "set \$gcspr_in_main = \$gcspr" \
+ "save gcspr value in main for later"
+
+# If the inferior function call fails, we don't want the tests following it
+# to be affected.
+gdb_test_no_output "set unwindonsignal on"
+gdb_test "print called_from_gdb (41)" ". = 42" "call inferior function"
+
+gdb_test "break handler" "Breakpoint \[0-9\]+ .*aarch64-gcs.c, line \[0-9\]+\\."
+gdb_test "handle SIGUSR1 nostop" \
+ ".*\r\nSIGUSR1\\s+No\\s+Yes\\s+Yes\\s+User defined signal 1" \
+ "let the inferior receive SIGUSR1 uninterrupted"
+gdb_test "continue" \
+ ".*\r\nBreakpoint \[0-9\]+, handler \\(sig=10\\) at .*aarch64-gcs.c.*handler_gcspr = get_gcspr \\(\\);" \
+ "continue to signal handler"
+
+gdb_test_no_output "set \$gcspr_in_handler = \$gcspr" \
+ "save gcspr value in handler for later"
+# Select the frame above the <signal handler called> frame, which makes GDB
+# unwind the gcspr from the signal frame GCS context.
+gdb_test "frame 2" "#2 ($hex in )?\\S+ \\(.*\\) (at|from) \\S+.*" \
+ "reached frame 2"
+gdb_test "print \$gcspr" ". = \\(void \\*\\) $hex" "gcspr in frame level 2"
+gdb_test "print \$gcspr == \$gcspr_in_handler + 8" ". = 1" \
+ "gcspr unwound from signal context is correct"
+
+gdb_test "continue" \
+ [multi_line \
+ "Continuing\\." \
+ "" \
+ "Program received signal SIGSEGV, Segmentation fault" \
+ "Guarded Control Stack error\\." \
+ "normal_function2 \\(\\) at .*aarch64-gcs.c:$decimal" \
+ "${decimal}\\s+__asm__ volatile \\(\"ret\\\\n\"\\);"] \
+ "continue to SIGSEGV"
+
+gdb_test "print \$_siginfo.si_code" ". = 10" \
+ "test value of si_code when GCS SIGSEGV happens"
+# The GCS grows down, and there are two real frames until main.
+gdb_test "print \$gcspr == \$gcspr_in_main - 16" ". = 1" \
+ "test value of gcspr when GCS SIGSEGV happens"
+
+# Test writing to GCSPR.
+clean_restart
+gdb_load $binfile
+if {![runto normal_function0]} {
+ return
+}
+
+gdb_test_no_output "set \$gcspr = 0xbadc0ffee" "set bogus gcspr value"
+# Continue to make sure that the value was actually written to the register.
+# The SIGSEGV isn't a GCS error because the problem isn't that the GCS entry
+# doesn't match the return address, but rather that that GCSPR is pointing
+# to an invalid address.
+gdb_test "continue" \
+ [multi_line \
+ "Continuing\\." \
+ "" \
+ "Program received signal SIGSEGV, Segmentation fault\\." \
+ "normal_function0 \\(\\) at .*aarch64-gcs.c:$decimal" \
+ "${decimal}\\s+__asm__ volatile \\(\"ret\\\\n\"\\);"] \
+ "continue after bad gcspr"
diff --git a/gdb/testsuite/gdb.arch/aarch64-mops-single-step.exp b/gdb/testsuite/gdb.arch/aarch64-mops-single-step.exp
index 4cdd985..3891fcc 100644
--- a/gdb/testsuite/gdb.arch/aarch64-mops-single-step.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-mops-single-step.exp
@@ -71,7 +71,7 @@ proc step_through_sequence { prefix } {
return 0
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.exp b/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.exp
index 70a49b5..20d2513 100644
--- a/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-mops-watchpoint.exp
@@ -28,7 +28,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
}
set linespec ${srcfile}:[gdb_get_line_number "Break here"]
-if ![runto ${linespec}] {
+if {![runto ${linespec}]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/aarch64-mte-core.exp b/gdb/testsuite/gdb.arch/aarch64-mte-core.exp
index fdaa061..849780a 100644
--- a/gdb/testsuite/gdb.arch/aarch64-mte-core.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-mte-core.exp
@@ -67,14 +67,14 @@ proc test_mte_core_file { core_filename mode } {
# has the expected value, that means the core file was generated correctly
# and that GDB read the contents correctly.
for {set i 0} {$i < $nmaps} {incr i} {
- for {set offset 0} {$offset < $page_size} {set offset [expr $offset + 16]} {
+ for {set offset 0} {$offset < $page_size} {set offset [expr {$offset + 16}]} {
set hex_tag [format "%x" $tag]
gdb_test "memory-tag print-allocation-tag mmap_pointers\[$i\] + $offset" \
"= 0x$hex_tag" \
"mmap_ponters\[$i\] + $offset contains expected tag"
# Update the expected tag. The test writes tags in sequential
# order.
- set tag [expr ($tag + 1) % 16]
+ set tag [expr {($tag + 1) % 16}]
}
}
}
@@ -98,7 +98,7 @@ proc test_mode { mode } {
}
set binfile [standard_output_file ${executable}]
- if ![runto_main] {
+ if {![runto_main]} {
untested "could not run to main"
return -1
}
@@ -145,7 +145,8 @@ proc test_mode { mode } {
# both correctly.
if {$gcore_generated} {
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
with_test_prefix "gcore corefile" {
test_mte_core_file $gcore_filename $mode
}
@@ -154,7 +155,8 @@ proc test_mode { mode } {
}
if {$core_generated} {
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
with_test_prefix "native corefile" {
test_mte_core_file $core_filename $mode
}
diff --git a/gdb/testsuite/gdb.arch/aarch64-mte.exp b/gdb/testsuite/gdb.arch/aarch64-mte.exp
index 8bb5814..a228755 100644
--- a/gdb/testsuite/gdb.arch/aarch64-mte.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-mte.exp
@@ -50,7 +50,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
@@ -63,7 +63,7 @@ if {![supports_memtag]} {
gdb_breakpoint "access_memory"
-if [gdb_continue "access_memory"] {
+if {[gdb_continue "access_memory"]} {
return -1
}
@@ -104,7 +104,7 @@ with_test_prefix "literals" {
set addr_tagged [get_tagged_ptr $i ${tagged_ptr_addr}]
}
- set tag_hexnz [get_hex_tag [expr $i % 16]]
+ set tag_hexnz [get_hex_tag [expr {$i % 16}]]
gdb_test "memory-tag print-logical-tag ${addr_tagged}" \
" = 0x${tag_hexnz}" \
"print-logical-tag with tag ${i}"
@@ -124,7 +124,7 @@ with_test_prefix "literals" {
$atag_msg \
"set-allocation-tag with tag ${i}"
- set tag_hexnz [get_hex_tag [expr $i % 16]]
+ set tag_hexnz [get_hex_tag [expr {$i % 16}]]
gdb_test "memory-tag print-allocation-tag ${tagged_ptr_addr}" " = 0x${tag_hexnz}" \
"print-allocation-tag with tag ${i}"
}
@@ -139,7 +139,7 @@ with_test_prefix "literals" {
$atag_msg \
"set-allocation-tag with tag ${i}"
- set atag_hexnz [get_hex_tag [expr $i % 16]]
+ set atag_hexnz [get_hex_tag [expr {$i % 16}]]
# Validate that the logical tag matches the allocation tag.
with_test_prefix "tag ${i}" {
@@ -152,14 +152,14 @@ with_test_prefix "literals" {
# Get a pointer with the logical tag that does not match the
# allocation tag.
- set ltag [expr $i + 1]
+ set ltag [expr {$i + 1}]
with_test_prefix "fetch mismatch tag ${i}" {
set addr_tagged [get_tagged_ptr $ltag ${tagged_ptr_addr}]
}
# Validate that the logical tag does not match the allocation
# tag.
- set ltag_hexnz [get_hex_tag [expr [expr $i + 1]% 16]]
+ set ltag_hexnz [get_hex_tag [expr {($i + 1) % 16}]]
gdb_test "memory-tag check ${addr_tagged}" \
"Logical tag \\(0x${ltag_hexnz}\\) does not match the allocation tag \\(0x${atag_hexnz}\\) for address $hex\." \
"check mismatch with tag ${i}"
@@ -187,7 +187,7 @@ with_test_prefix "symbolic" {
"update value of symbol ${tagged_ptr_symbol}"
}
- set tag_hexnz [get_hex_tag [expr $i % 16]]
+ set tag_hexnz [get_hex_tag [expr {$i % 16}]]
gdb_test "memory-tag print-logical-tag ${tagged_ptr_symbol}" \
" = 0x${tag_hexnz}" \
"print-logical-tag with tag ${i}"
@@ -211,7 +211,7 @@ with_test_prefix "symbolic" {
$atag_msg \
"set-allocation-tag with tag ${i}"
- set tag_hexnz [get_hex_tag [expr $i % 16]]
+ set tag_hexnz [get_hex_tag [expr {$i % 16}]]
gdb_test "memory-tag print-allocation-tag ${tagged_ptr_symbol}" \
" = 0x${tag_hexnz}" \
"print-allocation-tag with tag ${i}"
@@ -227,7 +227,7 @@ with_test_prefix "symbolic" {
$atag_msg \
"set-allocation-tag with tag ${i}"
- set atag_hexnz [get_hex_tag [expr $i % 16]]
+ set atag_hexnz [get_hex_tag [expr {$i % 16}]]
# Validate that the logical tag matches the allocation tag.
with_test_prefix "tag ${i}" {
@@ -245,7 +245,7 @@ with_test_prefix "symbolic" {
# Get a pointer with the logical tag that does not match the
# allocation tag.
- set ltag [expr $i + 1]
+ set ltag [expr {$i + 1}]
with_test_prefix "fetch mismatch tag ${i}" {
set addr_tagged [get_tagged_ptr $ltag ${tagged_ptr_addr}]
}
@@ -257,7 +257,7 @@ with_test_prefix "symbolic" {
# Validate that the logical tag does not match the allocation
# tag.
- set ltag_hexnz [get_hex_tag [expr [expr $i + 1]% 16]]
+ set ltag_hexnz [get_hex_tag [expr {($i + 1) % 16}]]
gdb_test "memory-tag check ${tagged_ptr_symbol}" \
"Logical tag \\(0x${ltag_hexnz}\\) does not match the allocation tag \\(0x${atag_hexnz}\\) for address $hex\." \
"check mismatch with tag ${i}"
@@ -281,7 +281,7 @@ with_test_prefix "print command" {
return -1
}
- set atag [expr [expr $ltag + 1] % 16]
+ set atag [expr {($ltag + 1) % 16}]
set atag_hexnn [get_tag_nn $atag]
gdb_test "memory-tag set-allocation-tag ${tagged_ptr_symbol} 1 ${atag_hexnn}" \
@@ -334,13 +334,13 @@ gdb_test "continue" \
# Restart to execute the async tag fault test.
with_test_prefix "async" {
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
gdb_breakpoint "access_memory"
- if [gdb_continue "access_memory"] {
+ if {[gdb_continue "access_memory"]} {
fail "could not run to tagged memory test function"
return -1
}
diff --git a/gdb/testsuite/gdb.arch/aarch64-non-address-bits.exp b/gdb/testsuite/gdb.arch/aarch64-non-address-bits.exp
index 0f90da8..e3023d1 100644
--- a/gdb/testsuite/gdb.arch/aarch64-non-address-bits.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-non-address-bits.exp
@@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/aarch64-pauth.exp b/gdb/testsuite/gdb.arch/aarch64-pauth.exp
index 72cefa1..89193ce 100644
--- a/gdb/testsuite/gdb.arch/aarch64-pauth.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-pauth.exp
@@ -45,7 +45,7 @@ if {!$compilation_ok} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/aarch64-prologue.exp b/gdb/testsuite/gdb.arch/aarch64-prologue.exp
index f782daa..2e0d05d 100644
--- a/gdb/testsuite/gdb.arch/aarch64-prologue.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-prologue.exp
@@ -22,7 +22,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {nodebug}]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/aarch64-pseudo-unwind.exp b/gdb/testsuite/gdb.arch/aarch64-pseudo-unwind.exp
index 7ce1fdf..e835ddf 100644
--- a/gdb/testsuite/gdb.arch/aarch64-pseudo-unwind.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-pseudo-unwind.exp
@@ -29,7 +29,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
return -1
}
-clean_restart ${binfile}
+clean_restart $testfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.arch/aarch64-sighandler-regs.exp b/gdb/testsuite/gdb.arch/aarch64-sighandler-regs.exp
index f8039d4..cce7376 100644
--- a/gdb/testsuite/gdb.arch/aarch64-sighandler-regs.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-sighandler-regs.exp
@@ -32,7 +32,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} ${compile_f
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
@@ -91,7 +91,7 @@ gdb_breakpoint [gdb_get_line_number "exit(0)"]
gdb_continue_to_breakpoint "exit" ".*exit.*"
set handlerframe [get_current_frame_number]
-set mainframe [expr $handlerframe + 2]
+set mainframe [expr {$handlerframe + 2}]
# Check register values
diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl
index 44d0808..b57ff73 100644
--- a/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl
+++ b/gdb/testsuite/gdb.arch/aarch64-sme-core.exp.tcl
@@ -25,13 +25,13 @@ load_lib aarch64-scalable.exp
#
proc check_sme_core_file { core_filename state vl svl } {
# Load the core file.
- if [gdb_test "core $core_filename" \
- [multi_line \
- "Core was generated by.*\." \
- "Program terminated with signal SIGSEGV, Segmentation fault\." \
- "#0 ${::hex} in main \\(.*\\) at .*" \
+ if {[gdb_test "core $core_filename" \
+ [multi_line \
+ "Core was generated by.*\." \
+ "Program terminated with signal SIGSEGV, Segmentation fault\." \
+ "#0 ${::hex} in main \\(.*\\) at .*" \
".*p = 0xff;.* crash point .*"] \
- "load core file"] {
+ "load core file"]} {
untested "failed to generate core file"
return -1
}
@@ -91,7 +91,8 @@ proc generate_sme_core_files { executable binfile id state vl svl} {
# and the native one generated by the Linux Kernel. Make sure GDB can read
# both correctly.
if {$gcore_generated} {
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
gdb_test_no_output "set print repeats 1" \
"adjust repeat count post-crash gcore"
@@ -103,7 +104,8 @@ proc generate_sme_core_files { executable binfile id state vl svl} {
}
if {$core_generated} {
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
gdb_test_no_output "set print repeats 1" \
"adjust repeat count post-crash native core"
@@ -167,7 +169,7 @@ proc test_sme_core_file { id_start id_end } {
return -1
}
- if ![runto_main] {
+ if {![runto_main]} {
untested "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl
index 4dc106e..de17e4e 100644
--- a/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl
+++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-available.exp.tcl
@@ -34,11 +34,11 @@ require !gdb_protocol_is_remote
#
proc check_regs { mode vl svl } {
# Check VG to make sure it is correct
- set expected_vg [expr $vl / 8]
+ set expected_vg [expr {$vl / 8}]
gdb_test "print \$vg" "= ${expected_vg}"
# Check SVG to make sure it is correct
- set expected_svg [expr $svl / 8]
+ set expected_svg [expr {$svl / 8}]
gdb_test "print \$svg" "= ${expected_svg}"
# If svl is adjusted by prctl, we will have ZA enabled. If gdb is
@@ -50,13 +50,13 @@ proc check_regs { mode vl svl } {
}
# Check SVCR.
- if [gdb_test "print \$svcr" $za_state "svcr before assignments" ] {
+ if {[gdb_test "print \$svcr" $za_state "svcr before assignments" ]} {
fail "incorrect za state"
return -1
}
# Check the size of ZA.
- set expected_za_size [expr $svl * $svl]
+ set expected_za_size [expr {$svl * $svl}]
gdb_test "print sizeof \$za" " = $expected_za_size"
# Check the size of Z0.
@@ -69,7 +69,7 @@ proc check_regs { mode vl svl } {
# Exercise reading/writing from/to the tile pseudo-registers.
set last_tile 1
- set expected_size [expr $svl * $svl]
+ set expected_size [expr {$svl * $svl}]
set tile_svl $svl
set za_state "= \\\[ ZA \\\]"
foreach_with_prefix granularity {"b" "h" "s" "d" "q"} {
@@ -83,7 +83,7 @@ proc check_regs { mode vl svl } {
initialize_2d_array $register_name 255 $tile_svl $tile_svl
# Make sure we have ZA state.
- if [gdb_test "print \$svcr" $za_state "svcr after assignment to ${register_name}" ] {
+ if {[gdb_test "print \$svcr" $za_state "svcr after assignment to ${register_name}" ]} {
fail "incorrect za state"
return -1
}
@@ -91,9 +91,9 @@ proc check_regs { mode vl svl } {
set pattern [string_to_regexp [2d_array_value_pattern 255 $tile_svl $tile_svl]]
gdb_test "print $register_name" " = $pattern" "read back from $register_name"
}
- set last_tile [expr $last_tile * 2]
- set expected_size [expr $expected_size / 2]
- set tile_svl [expr $tile_svl / 2]
+ set last_tile [expr {$last_tile * 2}]
+ set expected_size [expr {$expected_size / 2}]
+ set tile_svl [expr {$tile_svl / 2}]
}
# Exercise reading/writing from/to the tile slice pseudo-registers.
@@ -114,7 +114,7 @@ proc check_regs { mode vl svl } {
initialize_1d_array $register_name 255 $num_elements
# Make sure we have ZA state.
- if [gdb_test "print \$svcr" $za_state "svcr after assignment of ${register_name}" ] {
+ if {[gdb_test "print \$svcr" $za_state "svcr after assignment of ${register_name}" ]} {
fail "incorrect za state"
return -1
}
@@ -124,13 +124,13 @@ proc check_regs { mode vl svl } {
}
}
}
- set last_tile [expr $last_tile * 2]
- set last_slice [expr ($last_slice / 2)]
- set num_elements [expr $num_elements / 2]
+ set last_tile [expr {$last_tile * 2}]
+ set last_slice [expr {($last_slice / 2)}]
+ set num_elements [expr {$num_elements / 2}]
}
# Exercise reading/writing from/to SME2 registers.
- if [is_sme2_available] {
+ if {[is_sme2_available]} {
# The target supports SME2.
set zt_size 64
gdb_test "print sizeof \$zt0" " = $zt_size"
@@ -163,7 +163,7 @@ proc test_sme_registers_available { id_start id_end } {
}
set binfile [standard_output_file ${executable}]
- if ![runto_main] {
+ if {![runto_main]} {
untested "could not run to main"
return -1
}
@@ -245,8 +245,8 @@ proc test_sme_registers_available { id_start id_end } {
gdb_continue_to_breakpoint $non_prctl_breakpoint
# Adjust svl via gdb.
- set vg_value [expr $vl / 8]
- set svg_value [expr $svl / 8]
+ set vg_value [expr {$vl / 8}]
+ set svg_value [expr {$svl / 8}]
gdb_test_no_output "set \$vg = ${vg_value}"
gdb_test_no_output "set \$svg = ${svg_value}"
diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl
index 403da75..4f37019 100644
--- a/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl
+++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-sigframe.exp.tcl
@@ -42,7 +42,7 @@ proc test_sme_registers_sigframe { id_start id_end } {
}
set binfile [standard_output_file ${executable}]
- if ![runto_main] {
+ if {![runto_main]} {
untested "could not run to main"
return -1
}
@@ -83,16 +83,16 @@ proc test_sme_registers_sigframe { id_start id_end } {
}
# Run the program until it has adjusted the svl.
- if [gdb_continue_to_breakpoint $sigill_breakpoint] {
+ if {[gdb_continue_to_breakpoint $sigill_breakpoint]} {
return -1
}
# Check SVG to make sure it is correct
- set expected_svg [expr $svl / 8]
+ set expected_svg [expr {$svl / 8}]
gdb_test "print \$svg" "= ${expected_svg}"
# Check the size of ZA.
- set expected_za_size [expr $svl * $svl]
+ set expected_za_size [expr {$svl * $svl}]
gdb_test "print sizeof \$za" " = $expected_za_size"
# Check the value of SVCR.
@@ -134,14 +134,14 @@ proc test_sme_registers_sigframe { id_start id_end } {
gdb_test_no_output "set \$tpidr2=0x0102030405060708"
# Run to the illegal instruction.
- if [gdb_test "continue" "Continuing\.\r\n\r\nProgram received signal SIGILL, Illegal instruction\..*in main.*"] {
+ if {[gdb_test "continue" "Continuing\.\r\n\r\nProgram received signal SIGILL, Illegal instruction\..*in main.*"]} {
return
}
# Skip the illegal instruction. The signal handler will be called after we continue.
gdb_test_no_output "set \$pc=\$pc+4"
# Continue to the signal handler.
- if [gdb_continue_to_breakpoint $handler_breakpoint] {
+ if {[gdb_continue_to_breakpoint $handler_breakpoint]} {
return -1
}
@@ -159,7 +159,7 @@ proc test_sme_registers_sigframe { id_start id_end } {
}
# Check the size of ZA in the signal frame.
- set expected_za_size [expr $svl * $svl]
+ set expected_za_size [expr {$svl * $svl}]
gdb_test "print sizeof \$za" " = $expected_za_size" "size of za in signal frame"
# Check the value of SVCR in the signal frame.
@@ -172,7 +172,7 @@ proc test_sme_registers_sigframe { id_start id_end } {
gdb_test "print/x \$tpidr2" " = 0x102030405060708" "tpidr2 contents from signal frame"
# Check the value of SME2 ZT0 in the signal frame.
- if [is_sme2_available] {
+ if {[is_sme2_available]} {
# The target supports SME2.
set zt_size 64
gdb_test "print sizeof \$zt0" " = $zt_size"
diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl
index ba69b76..04e8b88 100644
--- a/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl
+++ b/gdb/testsuite/gdb.arch/aarch64-sme-regs-unavailable.exp.tcl
@@ -26,21 +26,21 @@ load_lib aarch64-scalable.exp
#
proc_with_prefix check_regs { vl svl } {
# Check VG to make sure it is correct
- set expected_vg [expr $vl / 8]
+ set expected_vg [expr {$vl / 8}]
gdb_test "print \$vg" "= ${expected_vg}"
# Check SVG to make sure it is correct
- set expected_svg [expr $svl / 8]
+ set expected_svg [expr {$svl / 8}]
gdb_test "print \$svg" "= ${expected_svg}"
# Make sure there is no SM or ZA state.
- if [gdb_test "print \$svcr" "= \\\[ \\\]"] {
+ if {[gdb_test "print \$svcr" "= \\\[ \\\]"]} {
fail "incorrect ZA state"
return -1
}
# Check the size of ZA.
- set expected_za_size [expr $svl * $svl]
+ set expected_za_size [expr {$svl * $svl}]
gdb_test "print sizeof \$za" " = $expected_za_size"
# Check the size of Z0.
@@ -69,15 +69,15 @@ proc_with_prefix check_regs { vl svl } {
}
}
}
- set last_tile [expr $last_tile * 2]
- set last_slice [expr ($last_slice / 2)]
- set elements [expr ($elements / 2)]
+ set last_tile [expr {$last_tile * 2}]
+ set last_slice [expr {($last_slice / 2)}]
+ set elements [expr {($elements / 2)}]
}
# Exercise reading/writing the tile pseudo-registers.
set last_tile 1
set elements $svl
- set expected_size [expr $svl * $svl]
+ set expected_size [expr {$svl * $svl}]
foreach_with_prefix granularity {"b" "h" "s" "d" "q"} {
set pattern [string_to_regexp [2d_array_value_pattern 0 $elements $elements]]
for {set tile 0} {$tile < $last_tile} {incr tile} {
@@ -86,13 +86,13 @@ proc_with_prefix check_regs { vl svl } {
gdb_test "print sizeof ${register_name}" " = ${expected_size}"
gdb_test "print ${register_name}" $pattern
}
- set last_tile [expr $last_tile * 2]
- set expected_size [expr $expected_size / 2]
- set elements [expr ($elements / 2)]
+ set last_tile [expr {$last_tile * 2}]
+ set expected_size [expr {$expected_size / 2}]
+ set elements [expr {($elements / 2)}]
}
# Exercise reading from SME2 registers.
- if [is_sme2_available] {
+ if {[is_sme2_available]} {
# The target supports SME2.
set zt_size 64
gdb_test "print sizeof \$zt0" " = $zt_size"
@@ -128,7 +128,7 @@ proc test_sme_registers_unavailable { id_start id_end } {
return -1
}
- if ![runto_main] {
+ if {![runto_main]} {
untested "could not run to main"
return -1
}
@@ -207,8 +207,8 @@ proc test_sme_registers_unavailable { id_start id_end } {
}
# Adjust vg and svg.
- set vg_value [expr $vl / 8]
- set svg_value [expr $svl / 8]
+ set vg_value [expr {$vl / 8}]
+ set svg_value [expr {$svl / 8}]
gdb_test_no_output "set \$vg = ${vg_value}"
gdb_test_no_output "set \$svg = ${svg_value}"
diff --git a/gdb/testsuite/gdb.arch/aarch64-sme-sanity.exp b/gdb/testsuite/gdb.arch/aarch64-sme-sanity.exp
index c72e578..9664069 100644
--- a/gdb/testsuite/gdb.arch/aarch64-sme-sanity.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-sme-sanity.exp
@@ -60,8 +60,8 @@ gdb_test_no_output "set print repeats 1" "adjust repeat count"
# Fetch both the vector length and the streaming vector length the target
# system is using. We do not force any vector lengths and do not change
# it mid-execution.
-set vl [expr [get_valueof "" "\$vg" "0" "fetch value of vl"] * 8]
-set svl [expr [get_valueof "" "\$svg" "0" "fetch value of svl"] * 8]
+set vl [expr {[get_valueof "" "\$vg" "0" "fetch value of vl"] * 8}]
+set svl [expr {[get_valueof "" "\$svg" "0" "fetch value of svl"] * 8}]
# Now we are at the point where we can start checking state and moving the
# testcase forward.
diff --git a/gdb/testsuite/gdb.arch/aarch64-sve-sigunwind.exp b/gdb/testsuite/gdb.arch/aarch64-sve-sigunwind.exp
index 32340bb..7a47fc7 100644
--- a/gdb/testsuite/gdb.arch/aarch64-sve-sigunwind.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-sve-sigunwind.exp
@@ -58,12 +58,12 @@ gdb_test "handle SIGUSR1 nostop" \
set linespec ${srcfile}:[gdb_get_line_number "Break here."]
gdb_test_no_output "set args $first_vl $second_vl"
-if ![runto ${linespec}] {
+if {![runto ${linespec}]} {
return
}
-set first_vg [expr $first_vl/8]
-set second_vg [expr $second_vl/8]
+set first_vg [expr {$first_vl/8}]
+set second_vg [expr {$second_vl/8}]
gdb_test "print \$vg" ". = $second_vg" "vg was changed"
@@ -77,10 +77,10 @@ for {set row 0} {$row < 32} {incr row} {
for {set row 0} {$row < 16} {incr row} {
set register_name "\$p${row}"
- gdb_test "print $register_name" ". = \\{(0, ){[expr $second_vl/8 - 1]}0\\}" \
+ gdb_test "print $register_name" ". = \\{(0, ){[expr {$second_vl/8 - 1}]}0\\}" \
"$register_name contents in signal handler"
}
-gdb_test "print \$ffr" ". = \\{(255, ){[expr $second_vl/8 - 1]}255\\}" \
+gdb_test "print \$ffr" ". = \\{(255, ){[expr {$second_vl/8 - 1}]}255\\}" \
"ffr contents in signal handler"
gdb_test "frame function main" \
@@ -99,8 +99,8 @@ for {set row 0} {$row < 32} {incr row} {
for {set row 0} {$row < 16} {incr row} {
set register_name "\$p${row}"
- gdb_test "print $register_name" ". = \\{(1, ){[expr $first_vl/8 - 1]}1\\}" \
+ gdb_test "print $register_name" ". = \\{(1, ){[expr {$first_vl/8 - 1}]}1\\}" \
"$register_name contents were correctly unwound"
}
-gdb_test "print \$ffr" ". = \\{(255, ){[expr $first_vl/8 - 1]}255\\}" \
+gdb_test "print \$ffr" ". = \\{(255, ){[expr {$first_vl/8 - 1}]}255\\}" \
"ffr contents were correctly unwound"
diff --git a/gdb/testsuite/gdb.arch/aarch64-sve.exp b/gdb/testsuite/gdb.arch/aarch64-sve.exp
index 34bcff2..6cdc30d 100644
--- a/gdb/testsuite/gdb.arch/aarch64-sve.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-sve.exp
@@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
set linespec ${srcfile}:[gdb_get_line_number "break here"]
-if ![runto ${linespec}] {
+if {![runto ${linespec}]} {
return
}
@@ -59,7 +59,7 @@ proc get_register_value {register} {
# The test executable halves the vector length in a loop, so loop along
# to check it.
-for {set i [get_register_value "vg"]} {$i > 1} {set i [expr $i / 2]} {
+for {set i [get_register_value "vg"]} {$i > 1} {set i [expr {$i / 2}]} {
set lines_before [count_info_registers]
gdb_test "next" ".*if .res < 0." "step over prctl vg = ${i}"
diff --git a/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.exp b/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.exp
index 904f92f..eb2bc92 100644
--- a/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-tagged-pointer.exp
@@ -22,7 +22,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/aarch64-unwind-pc.exp b/gdb/testsuite/gdb.arch/aarch64-unwind-pc.exp
index 1bcd1b2..bc6d242 100644
--- a/gdb/testsuite/gdb.arch/aarch64-unwind-pc.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-unwind-pc.exp
@@ -25,7 +25,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/aarch64-w-registers.exp b/gdb/testsuite/gdb.arch/aarch64-w-registers.exp
index 409beec..06c6626 100644
--- a/gdb/testsuite/gdb.arch/aarch64-w-registers.exp
+++ b/gdb/testsuite/gdb.arch/aarch64-w-registers.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile {nodebug}]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
untested "could not run to main"
return -1
}
diff --git a/gdb/testsuite/gdb.arch/alpha-step.exp b/gdb/testsuite/gdb.arch/alpha-step.exp
index e41bd97..aea492e 100644
--- a/gdb/testsuite/gdb.arch/alpha-step.exp
+++ b/gdb/testsuite/gdb.arch/alpha-step.exp
@@ -25,7 +25,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] !
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
proc test_stepi {function } {
# Restart the program from scratch. If GDB got confused during one
@@ -41,50 +42,50 @@ proc test_stepi {function } {
gdb_test "break *$function+4" \
"Breakpoint .* at .*" \
"breakpoint on fb$function instruction"
-
+
gdb_test "continue" \
"Breakpoint .*, 0x\[0-9a-fA-F\]+ in $function\(\).*" \
"continue to fb$function instruction (first call)"
-
+
# Extra check to make sure we stopped on the FP branch instruction.
-
+
gdb_test "x /i \$pc" \
"0x\[0-9a-fA-F\]+ <.*>:\[ \t\]+fb$function.*" \
"Check breakpoint on fb$function instruction (first call)"
-
+
# Step test, followed by the check that we landed on the expected
# instruction (the testcase should be written in such a way that
# the branch is taken on the first call to this function.
-
+
gdb_test "stepi" \
"0x\[0-9a-fA-F\]+.*" \
"stepi on fb$function (first call)"
-
+
gdb_test "x /i \$pc" \
"0x\[0-9a-fA-F\]+ <.*>:\[ \t\]+ret.*" \
"Check stepi over fb$function stopped on ret"
-
+
# Continue again. FUNCTION should be called a second time, this time
# with an argument such that the FP branch will not be taken.
-
+
gdb_test "continue" \
"Breakpoint .*, 0x\[0-9a-fA-F\]+ in $function\(\).*" \
"continue to fb$function instruction (second call)"
-
+
# Extra check to make sure we stopped on the FP branch instruction.
-
+
gdb_test "x /i \$pc" \
"0x\[0-9a-fA-F\]+ <.*>:\[ \t\]+fb$function.*" \
"Check breakpoint on fb$function instruction (second call)"
-
+
# Step test, branch should not be taken.
-
+
gdb_test "stepi" \
"0x\[0-9a-fA-F\]+.*" \
"stepi on fb$function (branch not taken)"
-
+
# Extra check to verify that we landed on the instruction we expected.
-
+
gdb_test "x /i \$pc" \
"0x\[0-9a-fA-F\]+ <.*>:\[ \t\]+fneg.*" \
"check stepi over fb$function stopped on fneg instruction"
diff --git a/gdb/testsuite/gdb.arch/altivec-abi.exp b/gdb/testsuite/gdb.arch/altivec-abi.exp
index 12f523b..c41e82d 100644
--- a/gdb/testsuite/gdb.arch/altivec-abi.exp
+++ b/gdb/testsuite/gdb.arch/altivec-abi.exp
@@ -39,7 +39,7 @@ proc altivec_abi_tests { extra_flags force_abi } {
if { "$force_abi" == "auto" } {
# If the toolchain does not record attributes, skip auto-ABI tests.
set readelf_program [gdb_find_readelf]
- set result [catch "exec $readelf_program -A $binfile" output]
+ set result [catch {exec $readelf_program -A $binfile} output]
if {$result == 0 && ![regexp Tag_GNU_Power_ABI_Vector $output]} {
untested "ABI not marked"
@@ -47,7 +47,8 @@ proc altivec_abi_tests { extra_flags force_abi } {
}
}
- clean_restart $binfile
+ clean_restart
+ gdb_load $::binfile
# Run to `main' where we begin our tests.
if {![runto_main]} {
@@ -131,7 +132,7 @@ proc altivec_abi_tests { extra_flags force_abi } {
gdb_test "p matrix\[3\]" ".*= .31, 32, 33, 34, 35, 36, 37, 38." "print fourth vector"
}
-if [test_compiler_info gcc*] {
+if {[test_compiler_info gcc*]} {
set binprefix ${binfile}
with_test_prefix "default ABI, auto" {
@@ -165,7 +166,7 @@ if [test_compiler_info gcc*] {
altivec_abi_tests "additional_flags=-maltivec additional_flags=-mabi=altivec" "auto"
}
}
-} elseif [test_compiler_info xlc*] {
+} elseif {[test_compiler_info xlc*]} {
altivec_abi_tests "additional_flags=-qaltivec" "auto"
} else {
warning "unknown compiler"
diff --git a/gdb/testsuite/gdb.arch/altivec-regs.exp b/gdb/testsuite/gdb.arch/altivec-regs.exp
index d297f4b..dfe7e24 100644
--- a/gdb/testsuite/gdb.arch/altivec-regs.exp
+++ b/gdb/testsuite/gdb.arch/altivec-regs.exp
@@ -1,5 +1,5 @@
# Copyright (C) 2002-2025 Free Software Foundation, Inc.
-#
+#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
@@ -26,9 +26,9 @@ require allow_altivec_tests
standard_testfile
set compile_flags {debug nowarnings}
-if [test_compiler_info gcc*] {
+if {[test_compiler_info gcc*]} {
set compile_flags "$compile_flags additional_flags=-maltivec additional_flags=-mabi=altivec"
-} elseif [test_compiler_info xlc*] {
+} elseif {[test_compiler_info xlc*]} {
set compile_flags "$compile_flags additional_flags=-qaltivec"
} else {
warning "unknown compiler"
@@ -134,11 +134,11 @@ gdb_test "continue" \
"Breakpoint $decimal, vector_fun .a=.0xfefefefe, 0xfefefefe, 0xfefefefe, 0xfefefefe., b=.0x1010101, 0x1010101, 0x1010101, 0x1010101.*altivec-regs.c.*vec_splat_u8.2..;" \
"continue to vector_fun"
-# Do a next over the assignment to vector 'a'.
+# Do a next over the assignment to vector 'a'.
gdb_test "next" ".*b = \\(\\(vector unsigned int\\) vec_splat_u8\\(3\\)\\);" \
"next (1)"
-# Do a next over the assignment to vector 'b'.
+# Do a next over the assignment to vector 'b'.
gdb_test "next" "c = vec_add \\(a, b\\);" \
"next (2)"
diff --git a/gdb/testsuite/gdb.arch/amd64-break-on-asm-line.exp b/gdb/testsuite/gdb.arch/amd64-break-on-asm-line.exp
index 7f0a8b8..a2caf46 100644
--- a/gdb/testsuite/gdb.arch/amd64-break-on-asm-line.exp
+++ b/gdb/testsuite/gdb.arch/amd64-break-on-asm-line.exp
@@ -23,7 +23,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/amd64-byte.exp b/gdb/testsuite/gdb.arch/amd64-byte.exp
index ac70672..d67361d 100644
--- a/gdb/testsuite/gdb.arch/amd64-byte.exp
+++ b/gdb/testsuite/gdb.arch/amd64-byte.exp
@@ -27,7 +27,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list
return
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
@@ -63,7 +63,7 @@ with_test_prefix "at first bp" {
}
for { set r 1 } { $r <= 4 } { incr r } {
- set h [expr $r + 14]
+ set h [expr {$r + 14}]
gdb_test "print/x \$$byte_regs($h)" \
".. = 0x[format %x $r]2" \
"check contents of %$byte_regs($h)"
@@ -85,7 +85,7 @@ with_test_prefix "at second bp" {
}
for { set r 1 } { $r <= 4 } { incr r } {
- set h [expr $r + 14]
+ set h [expr {$r + 14}]
gdb_test "set var \$$byte_regs($h) = $h" "" "set %$byte_regs($h)"
}
}
@@ -101,7 +101,7 @@ with_test_prefix "at third bp" {
}
for { set r 1 } { $r <= 4 } { incr r } {
- set h [expr $r + 14]
+ set h [expr {$r + 14}]
gdb_test "print \$$byte_regs($h)" \
".. = $h" \
"check contents of %$byte_regs($h)"
diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp b/gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp
index 08d73d8..b11efa7 100644
--- a/gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp
+++ b/gdb/testsuite/gdb.arch/amd64-disp-step-avx.exp
@@ -19,6 +19,7 @@
# instructions.
require is_x86_64_m64_target have_avx
+require support_displaced_stepping
standard_testfile .S
diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call-alarm.c b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call-alarm.c
index 03b868c..0fb2904 100644
--- a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call-alarm.c
+++ b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call-alarm.c
@@ -16,9 +16,27 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <unistd.h>
+#include <stdlib.h>
+
+extern void test_call (void);
+
+void
+unreachable (void)
+{
+ abort ();
+}
void
setup_alarm (void)
{
alarm (300);
}
+
+int
+main ()
+{
+ setup_alarm ();
+ test_call ();
+ unreachable ();
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.S b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.S
index 78a6859..20a8eb7 100644
--- a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.S
+++ b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.S
@@ -18,33 +18,12 @@
handling. */
.text
-
- .global main
-main:
- nop
-
- callq setup_alarm
-
- nop
-
-/***********************************************/
-
-/* test call/ret */
-
.global test_call
test_call:
call test_call
- nop
+ call unreachable
.global test_ret_end
test_ret_end:
nop
-/***********************************************/
-
-/* all done */
-
-done:
- mov $0,%rdi
- call exit
- hlt
.section .note.GNU-stack,"",@progbits
diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp
index 61ce4be..cd982a0 100644
--- a/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp
+++ b/gdb/testsuite/gdb.arch/amd64-disp-step-self-call.exp
@@ -59,7 +59,7 @@ gdb_test_multiple "x/2i \$pc" "get address of next insn" {
}
# Clear the slot on the stack and confirm it was set to zero.
-set sp [expr $sp - 0x8]
+set sp [expr {$sp - 0x8}]
gdb_test_no_output "set {unsigned long long} $sp = 0" \
"clear stack slot"
set zero_val 0x[format %016x 0]
@@ -73,7 +73,7 @@ gdb_test "stepi" \
# Check stack pointer was updated to the expected value.
set new_sp [get_hexadecimal_valueof "\$sp" "*UNKNOWN*" \
"get stack pointer after step"]
-gdb_assert {[expr $sp == $new_sp]} \
+gdb_assert {[expr {$sp == $new_sp}]} \
"check stack pointer was updated as expected"
# Check the contents of the stack were updated to the expected value.
diff --git a/gdb/testsuite/gdb.arch/amd64-disp-step.exp b/gdb/testsuite/gdb.arch/amd64-disp-step.exp
index aee1d7a..3b0d828 100644
--- a/gdb/testsuite/gdb.arch/amd64-disp-step.exp
+++ b/gdb/testsuite/gdb.arch/amd64-disp-step.exp
@@ -143,7 +143,7 @@ proc set_regs { regs val } {
# Use send_gdb/gdb_expect so that these aren't logged as pass/fail.
send_gdb "set \$${reg} = ${val}\n"
gdb_expect 10 {
- -re "$gdb_prompt $" {
+ -re "$gdb_prompt $" {
verbose "Setting ${reg} to ${val}." 2
}
timeout {
@@ -223,7 +223,7 @@ proc rip_test { reg test_start_label test_end_label signal_modes } {
# the displaced step, but instead just delivers the signal.
set inferior_pid [get_inferior_pid]
# Ensure that $inferior_pid refers to a single process.
- gdb_assert {[expr $inferior_pid > 0]} \
+ gdb_assert {[expr {$inferior_pid > 0}]} \
"check for a sane inferior pid"
if {$inferior_pid > 0} {
remote_exec target "kill -ALRM $inferior_pid"
diff --git a/gdb/testsuite/gdb.arch/amd64-dword.exp b/gdb/testsuite/gdb.arch/amd64-dword.exp
index e8a527d..cd3d76b 100644
--- a/gdb/testsuite/gdb.arch/amd64-dword.exp
+++ b/gdb/testsuite/gdb.arch/amd64-dword.exp
@@ -27,7 +27,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list
return
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value-inline.exp b/gdb/testsuite/gdb.arch/amd64-entry-value-inline.exp
index 14946d7..ec6ebc4 100644
--- a/gdb/testsuite/gdb.arch/amd64-entry-value-inline.exp
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value-inline.exp
@@ -16,7 +16,7 @@
set opts {}
standard_testfile .S .c
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
# make check RUNTESTFLAGS="gdb.arch/amd64-entry-value-inline.exp COMPILE=1"
standard_testfile .c .c
lappend opts debug optimize=-O2
@@ -25,7 +25,7 @@ if [info exists COMPILE] {
}
# Make .c available on the host.
-if [is_remote host] {
+if {[is_remote host]} {
gdb_remote_download host $srcdir/$subdir/$srcfile2
}
@@ -33,7 +33,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.exp b/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.exp
index d31c057..2207ecf 100644
--- a/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.exp
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value-param-dwarf5.exp
@@ -16,7 +16,7 @@
standard_testfile .S .c
set opts {}
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
# make check RUNTESTFLAGS="gdb.arch/amd64-entry-value-param-dwarf5.exp COMPILE=1"
standard_testfile .c .c
lappend opts optimize=-O2 dwarf5
@@ -25,7 +25,7 @@ if [info exists COMPILE] {
}
# Make .c available on the host.
-if [is_remote host] {
+if {[is_remote host]} {
gdb_remote_download host $srcdir/$subdir/$srcfile2
}
@@ -33,7 +33,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp b/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp
index 0c7cd21..57b3ca4 100644
--- a/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value-param.exp
@@ -16,7 +16,7 @@
standard_testfile .S .c
set opts {}
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
# make check RUNTESTFLAGS="gdb.arch/amd64-entry-value-param.exp COMPILE=1"
standard_testfile .c .c
lappend opts debug optimize=-O2
@@ -25,7 +25,7 @@ if [info exists COMPILE] {
}
# Make .c available on the host.
-if [is_remote host] {
+if {[is_remote host]} {
remote_download host $srcdir/$subdir/$srcfile2
}
@@ -33,7 +33,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.exp b/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.exp
index e508a04..94737f3 100644
--- a/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.exp
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value-paramref.exp
@@ -18,7 +18,7 @@ standard_testfile .S .cc
require is_x86_64_m64_target
# Make .cc available on the host.
-if [is_remote host] {
+if {[is_remote host]} {
gdb_remote_download host $srcdir/$subdir/$srcfile2
}
@@ -27,7 +27,7 @@ if { [prepare_for_testing_full "failed to prepare" \
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/amd64-entry-value.exp b/gdb/testsuite/gdb.arch/amd64-entry-value.exp
index 2bc676c..59f0975 100644
--- a/gdb/testsuite/gdb.arch/amd64-entry-value.exp
+++ b/gdb/testsuite/gdb.arch/amd64-entry-value.exp
@@ -16,7 +16,7 @@
standard_testfile .s
set opts {nopie}
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
# make check RUNTESTFLAGS="gdb.arch/amd64-entry-value.exp COMPILE=1"
set srcfile ${testfile}.cc
lappend opts debug
@@ -30,7 +30,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/amd64-eval.exp b/gdb/testsuite/gdb.arch/amd64-eval.exp
index 3d798ee..79ff8aa 100644
--- a/gdb/testsuite/gdb.arch/amd64-eval.exp
+++ b/gdb/testsuite/gdb.arch/amd64-eval.exp
@@ -26,7 +26,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis-no-cfi.S b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis-no-cfi.S
new file mode 100644
index 0000000..39cf3e6
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis-no-cfi.S
@@ -0,0 +1,117 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* This file is compiled from gdb.arch/amd64-extended-prologue-analysis.c
+ using gcc 11.4.0 with flags: -g0 -O1 -S -fno-omit-frame-pointer
+ -fno-asynchronous-unwind-tables. */
+
+ .file "amd64-extended-prologue-analysis.c"
+ .text
+ .globl bar
+ .type bar, @function
+bar:
+ endbr64
+ leal (%rdi,%rdi), %eax
+ ret
+ .size bar, .-bar
+ .globl foo
+ .type foo, @function
+foo:
+ endbr64
+ pushq %rbp
+ movq %rsp, %rbp
+ pushq %r15
+ pushq %r14
+ pushq %r13
+ pushq %r12
+ pushq %rbx
+ subq $280, %rsp
+ movl %edi, %ebx
+ movl %esi, %r14d
+ movl %edx, %r13d
+ movl %ecx, %r12d
+ movq %fs:40, %rax
+ movq %rax, -56(%rbp)
+ xorl %eax, %eax
+.L3:
+ leal (%rbx,%rax), %ecx
+ movslq %eax, %rdx
+ movb %cl, -320(%rbp,%rdx)
+ addl $1, %eax
+ cmpl $256, %eax
+ jne .L3
+ movl %ebx, %edi
+ call bar
+ movl %eax, %r15d
+ movl %r14d, %edi
+ call bar
+ leal (%r15,%rax), %r14d
+ movl %r13d, %edi
+ call bar
+ addl %eax, %r14d
+ movl %r12d, %edi
+ call bar
+ addl %r14d, %eax
+ addl %ebx, %eax
+ movq -56(%rbp), %rdx
+ subq %fs:40, %rdx
+ jne .L7
+ addq $280, %rsp
+ popq %rbx
+ popq %r12
+ popq %r13
+ popq %r14
+ popq %r15
+ popq %rbp
+ ret
+.L7:
+ call __stack_chk_fail@PLT
+ .size foo, .-foo
+ .globl main
+ .type main, @function
+main:
+ endbr64
+ pushq %rbp
+ movq %rsp, %rbp
+ subq $16, %rsp
+ leal (%rdi,%rdi), %ecx
+ leal 2(%rdi), %edx
+ leal 1(%rdi), %esi
+ call foo
+ movl %eax, -4(%rbp)
+ movl -4(%rbp), %eax
+ leave
+ ret
+ .size main, .-main
+ .ident "GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
+ .section .note.GNU-stack,"",@progbits
+ .section .note.gnu.property,"a"
+ .align 8
+ .long 1f - 0f
+ .long 4f - 1f
+ .long 5
+0:
+ .string "GNU"
+1:
+ .align 8
+ .long 0xc0000002
+ .long 3f - 2f
+2:
+ .long 0x3
+3:
+ .align 8
+4:
diff --git a/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis-offset.S b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis-offset.S
new file mode 100644
index 0000000..ea001b3
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis-offset.S
@@ -0,0 +1,112 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* This file is compiled from gdb.arch/amd64-extended-prologue-analysis.c
+ using gcc 11.4.0 with flags: -g0 -O1 -S -fomit-frame-pointer
+ -fno-asynchronous-unwind-tables. */
+
+ .file "amd64-extended-prologue-analysis.c"
+ .text
+ .globl bar
+ .type bar, @function
+bar:
+ endbr64
+ leal (%rdi,%rdi), %eax
+ ret
+ .size bar, .-bar
+ .globl foo
+ .type foo, @function
+foo:
+ endbr64
+ pushq %r14
+ pushq %r13
+ pushq %r12
+ pushq %rbp
+ pushq %rbx
+ subq $272, %rsp
+ movl %edi, %ebx
+ movl %esi, %r13d
+ movl %edx, %r12d
+ movl %ecx, %ebp
+ movq %fs:40, %rax
+ movq %rax, 264(%rsp)
+ xorl %eax, %eax
+.L3:
+ leal (%rbx,%rax), %ecx
+ movslq %eax, %rdx
+ movb %cl, (%rsp,%rdx)
+ addl $1, %eax
+ cmpl $256, %eax
+ jne .L3
+ movl %ebx, %edi
+ call bar
+ movl %eax, %r14d
+ movl %r13d, %edi
+ call bar
+ leal (%r14,%rax), %r13d
+ movl %r12d, %edi
+ call bar
+ addl %eax, %r13d
+ movl %ebp, %edi
+ call bar
+ addl %r13d, %eax
+ addl %ebx, %eax
+ movq 264(%rsp), %rdx
+ subq %fs:40, %rdx
+ jne .L7
+ addq $272, %rsp
+ popq %rbx
+ popq %rbp
+ popq %r12
+ popq %r13
+ popq %r14
+ ret
+.L7:
+ call __stack_chk_fail@PLT
+ .size foo, .-foo
+ .globl main
+ .type main, @function
+main:
+ endbr64
+ subq $24, %rsp
+ leal (%rdi,%rdi), %ecx
+ leal 2(%rdi), %edx
+ leal 1(%rdi), %esi
+ call foo
+ movl %eax, 12(%rsp)
+ movl 12(%rsp), %eax
+ addq $24, %rsp
+ ret
+ .size main, .-main
+ .ident "GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
+ .section .note.GNU-stack,"",@progbits
+ .section .note.gnu.property,"a"
+ .align 8
+ .long 1f - 0f
+ .long 4f - 1f
+ .long 5
+0:
+ .string "GNU"
+1:
+ .align 8
+ .long 0xc0000002
+ .long 3f - 2f
+2:
+ .long 0x3
+3:
+ .align 8
+4:
diff --git a/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.S b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.S
new file mode 100644
index 0000000..691eee0
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.S
@@ -0,0 +1,143 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* This file is compiled from gdb.arch/amd64-extended-prologue-analysis.c
+ using gcc 11.4.0 with flags: -g0 -O1 -S -fno-omit-frame-pointer. */
+
+ .file "amd64-extended-prologue-analysis.c"
+ .text
+ .globl bar
+ .type bar, @function
+bar:
+.LFB0:
+ .cfi_startproc
+ endbr64
+ leal (%rdi,%rdi), %eax
+ ret
+ .cfi_endproc
+.LFE0:
+ .size bar, .-bar
+ .globl foo
+ .type foo, @function
+foo:
+.LFB1:
+ .cfi_startproc
+ endbr64
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register 6
+ pushq %r15
+ pushq %r14
+ pushq %r13
+ pushq %r12
+ pushq %rbx
+ subq $280, %rsp
+ .cfi_offset 15, -24
+ .cfi_offset 14, -32
+ .cfi_offset 13, -40
+ .cfi_offset 12, -48
+ .cfi_offset 3, -56
+ movl %edi, %ebx
+ movl %esi, %r14d
+ movl %edx, %r13d
+ movl %ecx, %r12d
+ movq %fs:40, %rax
+ movq %rax, -56(%rbp)
+ xorl %eax, %eax
+.L3:
+ leal (%rbx,%rax), %ecx
+ movslq %eax, %rdx
+ movb %cl, -320(%rbp,%rdx)
+ addl $1, %eax
+ cmpl $256, %eax
+ jne .L3
+ movl %ebx, %edi
+ call bar
+ movl %eax, %r15d
+ movl %r14d, %edi
+ call bar
+ leal (%r15,%rax), %r14d
+ movl %r13d, %edi
+ call bar
+ addl %eax, %r14d
+ movl %r12d, %edi
+ call bar
+ addl %r14d, %eax
+ addl %ebx, %eax
+ movq -56(%rbp), %rdx
+ subq %fs:40, %rdx
+ jne .L7
+ addq $280, %rsp
+ popq %rbx
+ popq %r12
+ popq %r13
+ popq %r14
+ popq %r15
+ popq %rbp
+ .cfi_remember_state
+ .cfi_def_cfa 7, 8
+ ret
+.L7:
+ .cfi_restore_state
+ call __stack_chk_fail@PLT
+ .cfi_endproc
+.LFE1:
+ .size foo, .-foo
+ .globl main
+ .type main, @function
+main:
+.LFB2:
+ .cfi_startproc
+ endbr64
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset 6, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register 6
+ subq $16, %rsp
+ leal (%rdi,%rdi), %ecx
+ leal 2(%rdi), %edx
+ leal 1(%rdi), %esi
+ call foo
+ movl %eax, -4(%rbp)
+ movl -4(%rbp), %eax
+ leave
+ .cfi_def_cfa 7, 8
+ ret
+ .cfi_endproc
+.LFE2:
+ .size main, .-main
+ .ident "GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
+ .section .note.GNU-stack,"",@progbits
+ .section .note.gnu.property,"a"
+ .align 8
+ .long 1f - 0f
+ .long 4f - 1f
+ .long 5
+0:
+ .string "GNU"
+1:
+ .align 8
+ .long 0xc0000002
+ .long 3f - 2f
+2:
+ .long 0x3
+3:
+ .align 8
+4:
diff --git a/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.c b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.c
new file mode 100644
index 0000000..707b4fb
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.c
@@ -0,0 +1,56 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int __attribute__ ((noinline))
+bar (int x)
+{
+ return x + x;
+}
+
+/* This function should generate a prologue in shape of:
+ push %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset %rbp, -16
+ mov %rsp, %rbp
+ .cfi_def_cfa_register %rbp
+ push %reg1
+ push %reg2
+ sub $XXX, %rsp
+ .cfi_offset %reg2, 32
+ .cfi_offset %reg1, 24
+
+ So to be able to unwind a register, GDB needs to skip prologue past
+ register pushes and stack allocation (to access .cfi directives). */
+int __attribute__ ((noinline))
+foo (int a, int b, int c, int d)
+{
+ /* "volatile" alone isn't enough for clang to not optimize it out and
+ allocate space on the stack. */
+ volatile char s[256];
+ for (int i = 0; i < 256; i++)
+ s[i] = (char) (a + i);
+
+ a += bar (a) + bar (b) + bar (c) + bar (d);
+ return a;
+}
+
+int
+main (int argc, char **argv)
+{
+ volatile int a = foo (argc, argc + 1, argc + 2, argc * 2);
+ return a;
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.exp b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.exp
new file mode 100644
index 0000000..dcdb850
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-extended-prologue-analysis.exp
@@ -0,0 +1,208 @@
+# Copyright 2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# This test verifies that when placing a breakpoint on a function with a frame
+# pointer, instructions that push callee-saved registers and stack allocation
+# in the prologue are skipped, without debug info. When stopped on such
+# breakpoint, the pushed registers should be able to be immediately unwound.
+# With debug info present, GDB would try to use prologue-end markers found in
+# the line table to determine where the prologue ends.
+#
+# It is also tested both with and without .eh_frame's .cfi directives - with
+# them, GDB can only unwind a register once stopped after .cfi directive for
+# that register's push.
+
+require is_x86_64_m64_target
+standard_testfile .c -no-cfi.S .S -offset.S
+
+proc test_run {} {
+ gdb_breakpoint "foo"
+ gdb_continue_to_breakpoint "Continue to foo"
+
+ gdb_test "backtrace" "#0\[^\r\n\]+in foo\[^s\]+#1\[^\r\n\]+in main\[^s\]+" \
+ "Verify backtrace output in foo"
+
+ set main_r12 [get_integer_valueof "\$r12" "null"]
+ gdb_assert { $main_r12 ne "null" }
+
+ set foo_r12 [expr {$main_r12 + 2}]
+ gdb_test "print \$r12=$foo_r12" "$foo_r12" "Set foo's %r12=$foo_r12"
+ gdb_test "up" ".*main.*" "Go up a frame from foo"
+ gdb_test "print \$r12" "$main_r12" "foo's %r12 unwound"
+ gdb_test "down" ".*foo.*" "Go back down a frame to foo"
+ gdb_test "print \$r12" "$foo_r12" "foo's %r12 unwound back"
+}
+
+proc offset_test_run {} {
+ gdb_breakpoint "*foo"
+ gdb_continue_to_breakpoint "Continue to entry of foo"
+
+ set old_reg_val [get_integer_valueof "\$r12" "null"]
+ gdb_assert { $old_reg_val ne "null" }
+
+ set new_reg_val [expr {$old_reg_val + 3}]
+ gdb_test "print \$r14=$new_reg_val" "$new_reg_val" "Set %r14=$new_reg_val"
+ gdb_test "print \$r13=$new_reg_val" "$new_reg_val" "Set %r13=$new_reg_val"
+ gdb_test "print \$r12=$new_reg_val" "$new_reg_val" "Set %r12=$new_reg_val"
+
+ set addr_past_prologue "null"
+ gdb_test_multiple "disassemble" "Disassemble foo" -lbl {
+ -re "\r\n\\s*($::hex) <\\+($::decimal)>:\\s*mov.*(?=\r\n)" {
+ set addr_past_prologue $expect_out(1,string)
+ exp_continue
+ }
+
+ -re -wrap "" {
+ gdb_assert { $addr_past_prologue ne "null" } $gdb_test_name
+ }
+ }
+
+ gdb_assert { $addr_past_prologue ne "null" }
+
+ gdb_breakpoint "*$addr_past_prologue"
+ gdb_continue_to_breakpoint "Continue past foo's prologue"
+
+ gdb_test "up" ".*main.*" "Go up a frame from foo"
+ gdb_test "print \$r14" "$new_reg_val" "Verify %r14 value"
+ gdb_test "print \$r13" "$new_reg_val" "Verify %r13 value"
+ gdb_test "print \$r12" "$new_reg_val" "Verify %r12 value"
+}
+
+# Tests are done for two versions (not counting with and w/o .cfi):
+# - binary compiled from C source, which verifies we actually test against
+# the code that compilers produce and we expect
+# - binary compiled from ASM source, which verifies that we properly analyze
+# prologue sequences even when compiler introduces a sudden change in how
+# it generates assembly
+#
+# With those 2 versions, we can easily distinguish GDB breaking analyzer and
+# compilers behaving differently, if there ever is an impactful change in how
+# they generate prologues.
+with_test_prefix "w/o .cfi directives" {
+ with_test_prefix "compiler gen" {
+ # -fno-asynchronous-unwind-tables is needed to get rid of .cfi
+ # directives in .eh_frame section.
+ if { [gdb_can_simple_compile fno-asynchronous-unwind-tables \
+ { void foo () { } } object -fno-asynchronous-unwind-tables] == 0 } {
+ unsupported \
+ "compiler doesn't support -fno-asynchronous-unwind-tables flag"
+ } else {
+ # For at least gcc 11.4/clang 14.0.0 and later, -O1 makes them more
+ # eager to use registers in the prologue.
+ #
+ # At least gcc 11.4 and later by default does not generate full
+ # debug info, "nodebug" is there for other compilers.
+ if { [prepare_for_testing "failed to prepare" "$testfile-no-cfi-C" \
+ $srcfile { optimize=-O1 nodebug
+ additional_flags=-fno-asynchronous-unwind-tables
+ additional_flags=-fno-omit-frame-pointer}] } {
+ return
+ }
+
+ if { ![runto_main] } {
+ untested "unable to run to main"
+ return
+ }
+
+ test_run
+ }
+ }
+
+ with_test_prefix "ASM source" {
+ if { [prepare_for_testing "failed to prepare" "$testfile-no-cfi-S" \
+ $srcfile2 nodebug ] } {
+ return
+ }
+
+ if { ![runto_main] } {
+ untested "unable to run to main"
+ return
+ }
+
+ test_run
+ }
+}
+
+with_test_prefix "with .cfi directives" {
+ with_test_prefix "compiler gen" {
+ if { [prepare_for_testing "failed to prepare" "$testfile-cfi-C" \
+ $srcfile { optimize=-O1
+ nodebug additional_flags=-fno-omit-frame-pointer}] } {
+ return
+ }
+
+ if { ![runto_main] } {
+ untested "unable to run to main"
+ return
+ }
+
+ test_run
+ }
+
+ with_test_prefix "ASM source" {
+ if { [prepare_for_testing "failed to prepare" "$testfile-cfi-S" \
+ $srcfile3 nodebug ] } {
+ return
+ }
+
+ if { ![runto_main] } {
+ untested "unable to run to main"
+ return
+ }
+
+ test_run
+ }
+}
+
+# This section exists to verify that we properly assign offsets for functions
+# w/o a frame pointer, for registers when they're pushed. If they were assigned
+# in a wrong way, we might end up unwinding improper register values.
+with_test_prefix "offset initialization" {
+ with_test_prefix "compiler gen" {
+ if { [gdb_can_simple_compile fno-asynchronous-unwind-tables \
+ { void foo () { } } object -fno-asynchronous-unwind-tables] == 0 } {
+ unsupported \
+ "compiler doesn't support -fno-asynchronous-unwind-tables flag"
+ } else {
+ if { [prepare_for_testing "failed to prepare" "$testfile-offset-C" \
+ $srcfile { optimize=-O1 nodebug
+ additional_flags=-fno-asynchronous-unwind-tables
+ additional_flags=-fomit-frame-pointer}] } {
+ return
+ }
+
+ if { ![runto_main] } {
+ untested "unable to run to main"
+ return
+ }
+
+ offset_test_run
+ }
+ }
+
+ with_test_prefix "ASM source" {
+ if { [prepare_for_testing "failed to prepare" "$testfile-offset-S" \
+ $srcfile4 nodebug ] } {
+ return
+ }
+
+ if { ![runto_main] } {
+ untested "unable to run to main"
+ return
+ }
+
+ offset_test_run
+ }
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-frameptr-vecreg-unwind.c b/gdb/testsuite/gdb.arch/amd64-frameptr-vecreg-unwind.c
new file mode 100644
index 0000000..1b79a65
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-frameptr-vecreg-unwind.c
@@ -0,0 +1,63 @@
+/* Copyright 2025 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ 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/>. */
+
+volatile void dummy () {}
+
+long test_function(void)
+{
+ __asm__ volatile (
+ /* Clear xmm0. */
+ "vxorps %%xmm0, %%xmm0, %%xmm0\n\t"
+
+ /* Move the frame pointer (rbp) to xmm0. */
+ "movq %%rbp, %%xmm0\n\t"
+
+ /* CFI: Frame pointer is in xmm0. */
+ ".cfi_register %%rbp, %%xmm0\n\t"
+
+ /* Clobber list: Specify all modified registers */
+ : // No output operands
+ : // No input operands
+ : "xmm0"
+ );
+
+ dummy (); /* break-here */
+
+ /* Pseudo-epilogue: Restore rbp from xmm0. */
+ __asm__ volatile (
+ /* Restore rbp. */
+ "movq %%xmm0, %%rbp\n\t"
+
+ /* Describe CFI: Frame pointer is restored. */
+ ".cfi_restore %%rbp\n\t"
+
+ /* Clobber list: Specify all modified registers */
+ : /* No output operands. */
+ : /* No input operands. */
+ : /* Despite clobbering rbp, gcc doesn't let us list it here. */
+ );
+
+ return 0;
+}
+
+int
+main ()
+{
+ long result = test_function ();
+ dummy ();
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-frameptr-vecreg-unwind.exp b/gdb/testsuite/gdb.arch/amd64-frameptr-vecreg-unwind.exp
new file mode 100644
index 0000000..3c0b319
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-frameptr-vecreg-unwind.exp
@@ -0,0 +1,40 @@
+# Copyright 2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This test verifies that we can read and write the value of a pseudo register
+# in unwound frames. For the test, we choose one raw register, rbx, and one
+# pseudo register that is backed by rbx, ebx. We have two frames (the inner one,
+# #0 and the outer one, #1) that each set a value for rbx. We verify that we
+# can read both rbx and ebx correctly for each frame, and that when we write to
+# ebx, rbx for that frame is correctly updated.
+
+require is_x86_64_m64_target
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" ${testfile} \
+ "${srcfile}" {debug}] } {
+ return -1
+}
+
+if {![runto_main]} {
+ return
+}
+
+gdb_breakpoint [gdb_get_line_number "break-here"]
+gdb_continue_to_breakpoint "break-here"
+gdb_test "with confirm off --return -1" "result = test_function \\(\\);"
+gdb_test "step" "dummy \\(\\);"
+gdb_test "print result" "= -1"
diff --git a/gdb/testsuite/gdb.arch/amd64-gs_base.exp b/gdb/testsuite/gdb.arch/amd64-gs_base.exp
index 90cbe02..a48cbec 100644
--- a/gdb/testsuite/gdb.arch/amd64-gs_base.exp
+++ b/gdb/testsuite/gdb.arch/amd64-gs_base.exp
@@ -22,7 +22,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/amd64-i386-address.exp b/gdb/testsuite/gdb.arch/amd64-i386-address.exp
index 55a25db..31ce704 100644
--- a/gdb/testsuite/gdb.arch/amd64-i386-address.exp
+++ b/gdb/testsuite/gdb.arch/amd64-i386-address.exp
@@ -21,7 +21,7 @@
require {is_any_target "x86_64-*-*" "i?86-*-*"} is_lp64_target
require {!istarget "*-*-openbsd*"}
-if [prepare_for_testing "failed to prepare" amd64-i386-address amd64-i386-address.S [list debug "additional_flags=-m32 -nostdlib"]] {
+if {[prepare_for_testing "failed to prepare" amd64-i386-address amd64-i386-address.S [list debug "additional_flags=-m32 -nostdlib"]]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/amd64-init-x87-values.exp b/gdb/testsuite/gdb.arch/amd64-init-x87-values.exp
index 11004fa..5bbadaf 100644
--- a/gdb/testsuite/gdb.arch/amd64-init-x87-values.exp
+++ b/gdb/testsuite/gdb.arch/amd64-init-x87-values.exp
@@ -24,7 +24,7 @@ standard_testfile .S
set options [list debug \
additional_flags=-static \
- additional_flags=-nostartfiles]
+ ldflags=-nostartfiles]
if { [build_executable "failed to prepare" ${testfile} ${srcfile} $options] } {
return -1
}
@@ -40,7 +40,7 @@ if { [build_executable "failed to prepare" ${testfile} ${srcfile} $options] } {
proc_with_prefix check_x87_regs_around_init {} {
global binfile
- clean_restart ${binfile}
+ clean_restart ${::testfile}
# Get things started.
if {![runto_main]} {
@@ -115,7 +115,7 @@ proc_with_prefix check_x87_regs_around_init {} {
proc_with_prefix check_setting_mxcsr_before_enable {} {
global binfile gdb_prompt
- clean_restart ${binfile}
+ clean_restart ${::testfile}
if {![runto_main]} {
return 0
@@ -149,7 +149,7 @@ proc_with_prefix check_setting_mxcsr_before_enable {} {
proc_with_prefix check_setting_x87_regs_before_enable {} {
global binfile
- clean_restart ${binfile}
+ clean_restart ${::testfile}
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp b/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp
index 03ecba6..a499eae 100644
--- a/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp
+++ b/gdb/testsuite/gdb.arch/amd64-invalid-stack-middle.exp
@@ -35,7 +35,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {nopie}] }
return -1
}
-if ![runto breakpt] {
+if {![runto breakpt]} {
return -1
}
@@ -45,9 +45,9 @@ gdb_test "bt" "^#0 +breakpt *\\(\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in func5\[^\
gdb_test "bt" "^#0 +breakpt *\\(\\) \[^\r\n\]*\r\n#1 +0x\[0-9a-f\]+ in func5\[^\r\n\]*\r\n#2 +0x\[0-9a-f\]+ in func4\[^\r\n\]*\r\n#3 +0x\[0-9a-f\]+ in func3\[^\r\n\]*\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \
"second backtrace, with error message"
-clean_restart ${binfile}
+clean_restart ${::testfile}
-if ![runto breakpt] {
+if {![runto breakpt]} {
return -1
}
@@ -59,9 +59,9 @@ gdb_test "interpreter-exec mi \"-stack-info-depth\"" \
"\\^done,depth=\"4\"" \
"check mi -stack-info-depth command, second time"
-clean_restart ${binfile}
+clean_restart ${::testfile}
-if ![runto breakpt] {
+if {![runto breakpt]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp b/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp
index 134dfda..7f1b806 100644
--- a/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp
+++ b/gdb/testsuite/gdb.arch/amd64-invalid-stack-top.exp
@@ -36,7 +36,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
return -1
}
-if ![runto breakpt] {
+if {![runto breakpt]} {
return -1
}
@@ -49,9 +49,9 @@ gdb_test "bt no-filters" "^#0 +$hex in func2 \\(\\)\r\nBacktrace stopped: Cannot
gdb_test "bt no-filters" "^#0 +$hex in func2 \\(\\)\r\nBacktrace stopped: Cannot access memory at address 0x\[0-9a-f\]+" \
"second backtrace, with error message"
-clean_restart ${binfile}
+clean_restart ${::testfile}
-if ![runto breakpt] {
+if {![runto breakpt]} {
return -1
}
@@ -63,9 +63,9 @@ gdb_test "interpreter-exec mi \"-stack-info-depth\"" \
"\\^done,depth=\"1\"" \
"check mi -stack-info-depth command, second time"
-clean_restart ${binfile}
+clean_restart ${::testfile}
-if ![runto breakpt] {
+if {![runto breakpt]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/amd64-optimout-repeat.exp b/gdb/testsuite/gdb.arch/amd64-optimout-repeat.exp
index 1b85e4e..38ce3ac 100644
--- a/gdb/testsuite/gdb.arch/amd64-optimout-repeat.exp
+++ b/gdb/testsuite/gdb.arch/amd64-optimout-repeat.exp
@@ -16,7 +16,7 @@
standard_testfile .S .c
set opts {}
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
# make check RUNTESTFLAGS="gdb.arch/amd64-optimout-repeat.exp COMPILE=1"
set srcfile ${srcfile2}
lappend opts debug optimize=-O2
@@ -28,7 +28,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/amd64-prologue-skip.exp b/gdb/testsuite/gdb.arch/amd64-prologue-skip.exp
index 04f3266..c96c0c7 100644
--- a/gdb/testsuite/gdb.arch/amd64-prologue-skip.exp
+++ b/gdb/testsuite/gdb.arch/amd64-prologue-skip.exp
@@ -14,7 +14,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
standard_testfile .S
-set binfile ${binfile}.o
+set testfile $testfile.o
+set binfile [standard_output_file $testfile]
require is_x86_64_m64_target
@@ -23,7 +24,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {debug}]
return
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_test "break *pushrbp" " at 0x1: file .*"
gdb_test "break pushrbp" " at 0x1: file .*"
diff --git a/gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp b/gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp
index 7c16238..3a688ab 100644
--- a/gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp
+++ b/gdb/testsuite/gdb.arch/amd64-prologue-xmm.exp
@@ -20,7 +20,7 @@ set csrcfile [file rootname $srcfile].c
set csrcfile ${testfile}.c
set opts {}
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
# make check RUNTESTFLAGS='gdb.arch/amd64-prologue-xmm.exp COMPILE=1'
set srcfile ${csrcfile}
lappend opts debug optimize=-O0
@@ -28,11 +28,11 @@ if [info exists COMPILE] {
require is_x86_64_m64_target
}
-if {[prepare_for_testing "failed to prepare" ${binfile} $srcfile $opts]} {
+if {[prepare_for_testing "failed to prepare" ${testfile} $srcfile $opts]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/amd64-pseudo-unwind.exp b/gdb/testsuite/gdb.arch/amd64-pseudo-unwind.exp
index 6333311..49721dd 100644
--- a/gdb/testsuite/gdb.arch/amd64-pseudo-unwind.exp
+++ b/gdb/testsuite/gdb.arch/amd64-pseudo-unwind.exp
@@ -32,7 +32,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.arch/amd64-shadow-stack-cmds.exp b/gdb/testsuite/gdb.arch/amd64-shadow-stack-cmds.exp
new file mode 100644
index 0000000..0ae172d
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-shadow-stack-cmds.exp
@@ -0,0 +1,143 @@
+# Copyright 2024-2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test shadow stack enabling for frame level update, the return and the
+# call commands.
+# As potential CET violations often only occur after resuming normal
+# execution, test normal program continuation after each return or call
+# commands.
+
+require allow_ssp_tests
+
+standard_testfile amd64-shadow-stack.c
+
+# Restart GDB an run until breakpoint in call2.
+
+proc restart_and_run_infcall_call2 {} {
+ global binfile
+ clean_restart ${::testfile}
+ if { ![runto_main] } {
+ return -1
+ }
+ set inside_infcall_str "The program being debugged stopped while in a function called from GDB"
+ gdb_breakpoint [ gdb_get_line_number "break call2" ]
+ gdb_continue_to_breakpoint "break call2" ".*break call2.*"
+ gdb_test "call (int) call2()" \
+ "Breakpoint \[0-9\]*, call2.*$inside_infcall_str.*"
+}
+
+save_vars { ::env(GLIBC_TUNABLES) } {
+
+ append_environment GLIBC_TUNABLES "glibc.cpu.hwcaps" "SHSTK"
+
+ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
+ {debug additional_flags="-fcf-protection=return"}] } {
+ return -1
+ }
+
+ clean_restart ${::testfile}
+ if { ![runto_main] } {
+ return -1
+ }
+
+ with_test_prefix "test inferior call and continue" {
+ gdb_breakpoint [ gdb_get_line_number "break call1" ]
+ gdb_continue_to_breakpoint "break call1" ".*break call1.*"
+
+ gdb_test "call (int) call2()" "= 42"
+
+ gdb_continue_to_end
+ }
+
+ with_test_prefix "test return inside an inferior call" {
+ restart_and_run_infcall_call2
+
+ gdb_test "return" "\#0.*call2.*" \
+ "Test shadow stack return inside an inferior call" \
+ "Make.*return now\\? \\(y or n\\) " "y"
+
+ gdb_continue_to_end
+ }
+
+ with_test_prefix "test return 'above' an inferior call" {
+ restart_and_run_infcall_call2
+
+ gdb_test "frame 2" "call2 ().*" "move to frame 'above' inferior call"
+
+ gdb_test "return" "\#0.*call1.*" \
+ "Test shadow stack return 'above' an inferior call" \
+ "Make.*return now\\? \\(y or n\\) " "y"
+
+ gdb_continue_to_end
+ }
+
+ clean_restart ${::testfile}
+ if { ![runto_main] } {
+ return -1
+ }
+
+ set call1_line [ gdb_get_line_number "break call1" ]
+ set call2_line [ gdb_get_line_number "break call2" ]
+
+ # Extract shadow stack pointer inside main, call1 and call2 function.
+ gdb_breakpoint $call1_line
+ gdb_breakpoint $call2_line
+ set ssp_main [get_valueof /x "\$pl3_ssp" 0 "get value of ssp in main"]
+ gdb_continue_to_breakpoint "break call1" ".*break call1.*"
+ set ssp_call1 [get_valueof /x "\$pl3_ssp" 0 "get value of ssp in call1"]
+ gdb_continue_to_breakpoint "break call2" ".*break call2.*"
+ set ssp_call2 [get_valueof /x "\$pl3_ssp" 0 "get value of ssp in call2"]
+
+ with_test_prefix "test frame level update" {
+ gdb_test "up" "call1.*" "move to frame 1"
+ gdb_test "print /x \$pl3_ssp" "= $ssp_call1" "check pl3_ssp of frame 1"
+ gdb_test "up" "main.*" "move to frame 2"
+ gdb_test "print /x \$pl3_ssp" "= $ssp_main" "check pl3_ssp of frame 2"
+ gdb_test "frame 0" "call2.*" "move to frame 0"
+ gdb_test "print /x \$pl3_ssp" "= $ssp_call2" "check pl3_ssp of frame 0"
+ }
+
+ with_test_prefix "test return from current frame" {
+ gdb_test "return (int) 1" "#0.*call1.*" \
+ "Test shadow stack return from current frame" \
+ "Make.*return now\\? \\(y or n\\) " "y"
+
+ # Potential CET violations often only occur after resuming normal execution.
+ # Therefore, it is important to test normal program continuation after
+ # testing the return command.
+ gdb_continue_to_end
+ }
+
+ clean_restart ${::testfile}
+ if { ![runto_main] } {
+ return -1
+ }
+
+ with_test_prefix "test return from past frame" {
+ gdb_breakpoint $call2_line
+ gdb_continue_to_breakpoint "break call2" ".*break call2.*"
+
+ gdb_test "frame 1" ".*in call1.*"
+
+ gdb_test "return (int) 1" "#0.*main.*" \
+ "Test shadow stack return from past frame" \
+ "Make.*return now\\? \\(y or n\\) " "y"
+
+ # Potential CET violations often only occur after resuming normal execution.
+ # Therefore, it is important to test normal program continuation after
+ # testing the return command.
+ gdb_continue_to_end
+ }
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.c b/gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.c
new file mode 100644
index 0000000..5e84793
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.c
@@ -0,0 +1,46 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2025 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+
+/* Call the return instruction before function epilogue to trigger a
+ control-flow exception. */
+void
+function ()
+{
+ unsigned long ssp;
+ #ifndef __ILP32__
+ asm volatile ("xor %0, %0; rdsspq %0" : "=r" (ssp));
+ #else
+ asm volatile ("xor %0, %0; rdsspd %0" : "=r" (ssp));
+ #endif
+
+ /* Print ssp to stdout so that the testcase can capture it. */
+ printf ("%p\n", (void *) ssp);
+ fflush (stdout);
+
+ /* Manually cause a control-flow exception by executing a return
+ instruction before function epilogue, so the address atop the stack
+ is not the return instruction. */
+ __asm__ volatile ("ret\n");
+}
+
+int
+main (void)
+{
+ function (); /* Break here. */
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.exp b/gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.exp
new file mode 100644
index 0000000..82d68da
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-shadow-stack-corefile.exp
@@ -0,0 +1,119 @@
+# Copyright 2024-2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test the shadow stack pointer note in core dumps.
+# Based on the corefile tests in gdb.arch/aarch64-gcs-core.exp.
+
+require allow_ssp_tests
+
+standard_testfile
+
+# Make sure GDB can read the given core file correctly.
+
+proc check_core_file {core_filename saved_pl3_ssp} {
+ global decimal
+
+ # Load the core file.
+ if {[gdb_test "core $core_filename" \
+ [multi_line \
+ "Core was generated by .*\\." \
+ "Program terminated with signal SIGSEGV, Segmentation fault.*" \
+ "#0 function \\(\\) at .*amd64-shadow-stack-corefile.c:$decimal" \
+ "$decimal.*__asm__ volatile \\(\"ret\\\\n\"\\);"] \
+ "load core file"]} {
+ return
+ }
+
+ # Check the value of ssp in the core file.
+ gdb_test "print/x \$pl3_ssp" "\\$\[0-9\]+ = $saved_pl3_ssp" \
+ "pl3_ssp contents from core file $saved_pl3_ssp"
+}
+
+save_vars { ::env(GLIBC_TUNABLES) } {
+
+ append_environment GLIBC_TUNABLES "glibc.cpu.hwcaps" "SHSTK"
+
+ if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
+ {debug additional_flags="-fcf-protection=return"}] } {
+ return
+ }
+
+ set linespec ${srcfile}:[gdb_get_line_number "Break here"]
+
+ if {![runto $linespec]} {
+ return
+ }
+
+ # Obtain an OS-generated core file. Save test program output to
+ # ${binfile}.out.
+ set core_filename [core_find $binfile {} {} "${binfile}.out"]
+ set core_generated [expr {$core_filename != ""}]
+
+ if {!$core_generated} {
+ untested "unable to create or find corefile"
+ }
+
+ # Load the core file and check the value of the shadow stack pointer.
+ if {$core_generated} {
+ clean_restart $::testfile
+
+ with_test_prefix "OS corefile" {
+ # Read ssp value from saved output of the test program.
+ set out_id [open ${binfile}.out "r"]
+ set ssp_in_gcore [gets $out_id]
+ close $out_id
+ check_core_file $core_filename $ssp_in_gcore
+ }
+ }
+
+ if {![gcore_cmd_available]} {
+ unsupported "target does not support gcore command."
+ return
+ }
+
+ clean_restart $::testfile
+
+ if {![runto $linespec]} {
+ return
+ }
+
+ # Continue until a crash. The line with the hex number is optional because
+ # it's printed by the test program, and doesn't appear in the Expect buffer
+ # when testing a remote target.
+
+ gdb_test "continue" \
+ [multi_line \
+ "Continuing\\." \
+ "($hex\r\n)?" \
+ "Program received signal SIGSEGV, Segmentation fault.*" \
+ "function \\(\\) at .*amd64-shadow-stack-corefile.c:$decimal" \
+ {.*__asm__ volatile \("ret\\n"\);}] \
+ "continue to SIGSEGV"
+
+ set ssp_in_gcore [get_valueof "/x" "\$pl3_ssp" "*unknown*"]
+
+ # Generate the gcore core file.
+ set gcore_filename [standard_output_file "${testfile}.gcore"]
+ set gcore_generated [gdb_gcore_cmd "$gcore_filename" "generate gcore file"]
+
+ gdb_assert { $gcore_generated } "gcore corefile created"
+ if { $gcore_generated } {
+ clean_restart $::testfile
+
+ with_test_prefix "gcore corefile" {
+ check_core_file $gcore_filename $ssp_in_gcore
+ }
+ }
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-shadow-stack-disp-step.exp b/gdb/testsuite/gdb.arch/amd64-shadow-stack-disp-step.exp
new file mode 100644
index 0000000..e4efa00
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-shadow-stack-disp-step.exp
@@ -0,0 +1,84 @@
+# Copyright 2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test continue from call instructions with shadow stack and displaced
+# stepping being enabled.
+
+require allow_ssp_tests support_displaced_stepping
+
+standard_testfile amd64-shadow-stack.c
+
+save_vars { ::env(GLIBC_TUNABLES) } {
+
+ append_environment GLIBC_TUNABLES "glibc.cpu.hwcaps" "SHSTK"
+
+ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
+ additional_flags="-fcf-protection=return"] } {
+ return
+ }
+
+ # Enable displaced stepping.
+ gdb_test_no_output "set displaced-stepping on"
+ gdb_test "show displaced-stepping" ".* displaced stepping .* is on.*"
+
+ if { ![runto_main] } {
+ return
+ }
+
+ # Get the address of the call to the call1 function.
+ set call1_addr -1
+ gdb_test_multiple "disassemble main" "" {
+ -re -wrap "($hex) <\\+($decimal)>:\\s*call\\s*0x.*<call1>.*" {
+ set call1_addr $expect_out(1,string)
+ pass $gdb_test_name
+ }
+ }
+
+ if { $call1_addr == -1 } {
+ return
+ }
+
+ # Get the address of the call to the call2 function.
+ set call2_addr -1
+ gdb_test_multiple "disassemble call1" "" {
+ -re -wrap "($hex) <\\+($decimal)>:\\s*call\\s*0x.*<call2>.*" {
+ set call2_addr $expect_out(1,string)
+ pass $gdb_test_name
+ }
+ }
+
+ if { $call2_addr == -1 } {
+ return
+ }
+
+ gdb_test "break *$call1_addr" \
+ "Breakpoint $decimal at $hex.*" \
+ "break at the address of the call1 instruction"
+
+ gdb_test "break *$call2_addr" \
+ "Breakpoint $decimal at $hex.*" \
+ "break at the address of the call2 instruction"
+
+ gdb_test "continue" \
+ "Breakpoint $decimal, $call1_addr in main ().*" \
+ "continue until call1 instruction"
+
+ # Test continue from breakpoint at call1 and call2 instructions.
+ gdb_test "continue" \
+ "Breakpoint $decimal, $call2_addr in call1 ().*" \
+ "continue from call1 instruction"
+
+ gdb_continue_to_end "continue from call2 instruction"
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-shadow-stack.c b/gdb/testsuite/gdb.arch/amd64-shadow-stack.c
new file mode 100644
index 0000000..4a1ca1e
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-shadow-stack.c
@@ -0,0 +1,40 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2024-2025 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+static int
+call2 ()
+{
+ return 42; /* break call2. */
+}
+
+static int
+call1 ()
+{
+ return call2 (); /* break call1. */
+}
+
+int
+main ()
+{
+ /* Depending on instruction generation we might end up in the call
+ instruction of call1 function after "runto_main". Avoid this by
+ adding a nop instruction, to simplify the testing in
+ amd64-shadow-stack-disp-step.exp. */
+ asm ("nop");
+ call1 (); /* break main. */
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-shadow-stack.exp b/gdb/testsuite/gdb.arch/amd64-shadow-stack.exp
new file mode 100644
index 0000000..e9f6fa6
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-shadow-stack.exp
@@ -0,0 +1,71 @@
+# Copyright 2024-2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test accessing the shadow stack pointer register.
+
+require allow_ssp_tests
+
+standard_testfile
+
+# Write PL3_SSP register with invalid shadow stack pointer value.
+proc write_invalid_ssp {} {
+ gdb_test "print /x \$pl3_ssp = 0x12345678" "= 0x12345678" "set pl3_ssp value"
+ gdb_test "print /x \$pl3_ssp" "= 0x12345678" "read pl3_ssp value after setting"
+}
+
+save_vars { ::env(GLIBC_TUNABLES) } {
+
+ append_environment GLIBC_TUNABLES "glibc.cpu.hwcaps" "SHSTK"
+
+ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
+ additional_flags="-fcf-protection=return"] } {
+ return
+ }
+
+ if {![runto_main]} {
+ return
+ }
+
+ with_test_prefix "invalid ssp" {
+ write_invalid_ssp
+
+ # Continue until SIGSEV to test that the value is written back to HW.
+ gdb_test "continue" \
+ [multi_line \
+ "Continuing\\." \
+ "" \
+ "Program received signal SIGSEGV, Segmentation fault\\." \
+ "$hex in main \\(\\)"] \
+ "continue to SIGSEGV"
+ }
+
+ clean_restart ${::testfile}
+ if { ![runto_main] } {
+ return
+ }
+
+ with_test_prefix "restore original ssp" {
+ # Read PL3_SSP register.
+ set ssp_main [get_hexadecimal_valueof "\$pl3_ssp" "read pl3_ssp value"]
+
+ write_invalid_ssp
+
+ # Restore original value.
+ gdb_test "print /x \$pl3_ssp = $ssp_main" "= $ssp_main" "restore original value"
+
+ # Now we should not see a SIGSEV, since the original value is restored.
+ gdb_continue_to_end
+ }
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-tailcall-cxx.exp b/gdb/testsuite/gdb.arch/amd64-tailcall-cxx.exp
index 7e1df43..5fbdf8b 100644
--- a/gdb/testsuite/gdb.arch/amd64-tailcall-cxx.exp
+++ b/gdb/testsuite/gdb.arch/amd64-tailcall-cxx.exp
@@ -16,7 +16,7 @@
set opts {}
standard_testfile amd64-tailcall-cxx1.S amd64-tailcall-cxx2.S
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
# make check RUNTESTFLAGS="gdb.arch/amd64-tailcall-cxx.exp COMPILE=1"
standard_testfile amd64-tailcall-cxx1.cc amd64-tailcall-cxx2.cc
lappend opts debug
@@ -30,7 +30,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} "${srcfile} ${srcfile2
return -1
}
-if ![runto g] {
+if {![runto g]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/amd64-tailcall-noret.exp b/gdb/testsuite/gdb.arch/amd64-tailcall-noret.exp
index fe65c4d..12abf58 100644
--- a/gdb/testsuite/gdb.arch/amd64-tailcall-noret.exp
+++ b/gdb/testsuite/gdb.arch/amd64-tailcall-noret.exp
@@ -16,7 +16,7 @@
set opts {}
standard_testfile .S
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
# make check RUNTESTFLAGS="gdb.arch/amd64-tailcall-noret.exp COMPILE=1"
standard_testfile
lappend opts debug optimize=-O2
@@ -30,7 +30,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
return -1
}
-if ![runto noret] {
+if {![runto noret]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp b/gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp
index 51baf7b..e96b85b 100644
--- a/gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp
+++ b/gdb/testsuite/gdb.arch/amd64-tailcall-ret.exp
@@ -16,7 +16,7 @@
set opts {}
standard_testfile .S .c
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
# make check RUNTESTFLAGS="gdb.arch/amd64-tailcall-ret.exp COMPILE=1"
standard_testfile .c .c
lappend opts debug optimize=-O2
@@ -25,7 +25,7 @@ if [info exists COMPILE] {
}
# Make .c available on the host.
-if [is_remote host] {
+if {[is_remote host]} {
gdb_remote_download host $srcdir/$subdir/$srcfile2
}
@@ -33,7 +33,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/amd64-tailcall-self.exp b/gdb/testsuite/gdb.arch/amd64-tailcall-self.exp
index de3c606..e5f47eb 100644
--- a/gdb/testsuite/gdb.arch/amd64-tailcall-self.exp
+++ b/gdb/testsuite/gdb.arch/amd64-tailcall-self.exp
@@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {}] } {
return -1
}
-if ![runto b] {
+if {![runto b]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/amd64-watchpoint-downgrade.exp b/gdb/testsuite/gdb.arch/amd64-watchpoint-downgrade.exp
index dcee040..5663b0d 100644
--- a/gdb/testsuite/gdb.arch/amd64-watchpoint-downgrade.exp
+++ b/gdb/testsuite/gdb.arch/amd64-watchpoint-downgrade.exp
@@ -58,7 +58,7 @@ gdb_test "starti" \
[multi_line \
"warning: watchpoint $num downgraded to software watchpoint" \
"" \
- "Program stopped\\." \
+ "(Program|Thread \[^\r\n\]) stopped\\." \
".*"]
# Watchpoint should now have downgraded to a s/w watchpoint.
diff --git a/gdb/testsuite/gdb.arch/amd64-word.exp b/gdb/testsuite/gdb.arch/amd64-word.exp
index d5dfb02..8a6b28d 100644
--- a/gdb/testsuite/gdb.arch/amd64-word.exp
+++ b/gdb/testsuite/gdb.arch/amd64-word.exp
@@ -27,7 +27,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list
return
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.arch/arc-analyze-prologue.exp b/gdb/testsuite/gdb.arch/arc-analyze-prologue.exp
index 1b084f9..dc1149c 100644
--- a/gdb/testsuite/gdb.arch/arc-analyze-prologue.exp
+++ b/gdb/testsuite/gdb.arch/arc-analyze-prologue.exp
@@ -29,7 +29,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile $options] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
@@ -85,7 +85,7 @@ proc prologue_test {funcname {savedregs ""} {fp_offset ""} } {
}
if { $fp_offset != "" } {
set sp [get_integer_valueof \$sp -1 "get value of sp in $funcname"]
- set fp_val [expr $sp + $fp_offset]
+ set fp_val [expr {$sp + $fp_offset}]
set fp_real_val \
[get_integer_valueof \$fp 0 "get value of fp in $funcname"]
if { $fp_real_val != $fp_val } {
diff --git a/gdb/testsuite/gdb.arch/arc-dbnz.exp b/gdb/testsuite/gdb.arch/arc-dbnz.exp
index 0563210..7f76aa2 100644
--- a/gdb/testsuite/gdb.arch/arc-dbnz.exp
+++ b/gdb/testsuite/gdb.arch/arc-dbnz.exp
@@ -37,7 +37,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
diff --git a/gdb/testsuite/gdb.arch/arc-decode-insn.exp b/gdb/testsuite/gdb.arch/arc-decode-insn.exp
index 5e7f3c2..01b23eb 100644
--- a/gdb/testsuite/gdb.arch/arc-decode-insn.exp
+++ b/gdb/testsuite/gdb.arch/arc-decode-insn.exp
@@ -39,7 +39,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
@@ -53,7 +53,7 @@ proc test_branch_insn { test_name } {
# Calculate instruction length, based on ${test_name}_end symbol.
set end_pc [get_hexadecimal_valueof &${test_name}_end -1]
- set length [expr $end_pc - $pc]
+ set length [expr {$end_pc - $pc}]
set target_address [get_hexadecimal_valueof &${test_name}_target -1]
diff --git a/gdb/testsuite/gdb.arch/arm-cmse-sgstubs.exp b/gdb/testsuite/gdb.arch/arm-cmse-sgstubs.exp
index f3aca94..d01f817 100644
--- a/gdb/testsuite/gdb.arch/arm-cmse-sgstubs.exp
+++ b/gdb/testsuite/gdb.arch/arm-cmse-sgstubs.exp
@@ -22,7 +22,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile ]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/arm-neon.exp b/gdb/testsuite/gdb.arch/arm-neon.exp
index b38a685..b29b9ca 100644
--- a/gdb/testsuite/gdb.arch/arm-neon.exp
+++ b/gdb/testsuite/gdb.arch/arm-neon.exp
@@ -25,7 +25,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug quie
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy.exp b/gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy.exp
index 892cfba..9cbf71d 100644
--- a/gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy.exp
+++ b/gdb/testsuite/gdb.arch/arm-pseudo-unwind-legacy.exp
@@ -34,7 +34,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
return -1
}
-clean_restart ${binfile}
+clean_restart $testfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.arch/arm-pseudo-unwind.exp b/gdb/testsuite/gdb.arch/arm-pseudo-unwind.exp
index c474a99..4cbb12e 100644
--- a/gdb/testsuite/gdb.arch/arm-pseudo-unwind.exp
+++ b/gdb/testsuite/gdb.arch/arm-pseudo-unwind.exp
@@ -29,7 +29,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \
return -1
}
-clean_restart ${binfile}
+clean_restart $testfile
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.arch/arm-pthread_cond_timedwait-bt.exp b/gdb/testsuite/gdb.arch/arm-pthread_cond_timedwait-bt.exp
index 15c4050..32f085a 100644
--- a/gdb/testsuite/gdb.arch/arm-pthread_cond_timedwait-bt.exp
+++ b/gdb/testsuite/gdb.arch/arm-pthread_cond_timedwait-bt.exp
@@ -33,7 +33,7 @@ if { [build_executable "failed to prepare" ${testfile} ${srcfile} \
save_vars { GDBFLAGS } {
append GDBFLAGS " --readnever"
- if { [clean_restart ${binfile}] == -1 } {
+ if { [clean_restart $testfile] == -1 } {
return -1
}
}
diff --git a/gdb/testsuite/gdb.arch/avr-flash-qualifier.exp b/gdb/testsuite/gdb.arch/avr-flash-qualifier.exp
index cafae60..ea58543 100644
--- a/gdb/testsuite/gdb.arch/avr-flash-qualifier.exp
+++ b/gdb/testsuite/gdb.arch/avr-flash-qualifier.exp
@@ -31,7 +31,7 @@ if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} {
return -1
}
-if ![runto [gdb_get_line_number "break here."]] {
+if {![runto [gdb_get_line_number "break here."]]} {
untested "could not run to \"break here.\""
return -1
}
diff --git a/gdb/testsuite/gdb.arch/disp-step-insn-reloc.exp b/gdb/testsuite/gdb.arch/disp-step-insn-reloc.exp
index a7cd5f3..6a08f70 100644
--- a/gdb/testsuite/gdb.arch/disp-step-insn-reloc.exp
+++ b/gdb/testsuite/gdb.arch/disp-step-insn-reloc.exp
@@ -21,12 +21,12 @@ require support_displaced_stepping
# Some targets have leading underscores on assembly symbols.
set additional_flags [gdb_target_symbol_prefix_flags]
-if [prepare_for_testing "failed to prepare" $executable $srcfile \
- [list debug $additional_flags]] {
+if {[prepare_for_testing "failed to prepare" $executable $srcfile \
+ [list debug $additional_flags]]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/e500-prologue.exp b/gdb/testsuite/gdb.arch/e500-prologue.exp
index e8f3ebd..b468e71 100644
--- a/gdb/testsuite/gdb.arch/e500-prologue.exp
+++ b/gdb/testsuite/gdb.arch/e500-prologue.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] !
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# Insert a breakpoint in FUNCTION and verifies that the breakpoint was
# inserted at the expected location. EXPECTED_LOCATION should be an
@@ -36,7 +37,7 @@ proc insert_breakpoint {function expected_location} {
global gdb_prompt
global expect_out
global hex
-
+
set address ""
# Insert a breakpoint using the given function name, and extract
diff --git a/gdb/testsuite/gdb.arch/e500-regs.exp b/gdb/testsuite/gdb.arch/e500-regs.exp
index 543ce63..fa10b4f 100644
--- a/gdb/testsuite/gdb.arch/e500-regs.exp
+++ b/gdb/testsuite/gdb.arch/e500-regs.exp
@@ -1,5 +1,5 @@
# Copyright 2003-2025 Free Software Foundation, Inc.
-#
+#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
@@ -136,7 +136,8 @@ gdb_expect_list "info vector" ".*$gdb_prompt $" {
# We must restart everything, because we have set important registers to
# some unusual values.
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
if {![runto_main]} {
return 0
}
@@ -154,11 +155,11 @@ gdb_test "continue" \
"Breakpoint 2, vector_fun .a=.-2, -2., b=.1, 1.*e500-regs.c.*ev_create_s32 .2, 2.;" \
"continue to vector_fun"
-# Do a next over the assignment to vector 'a'.
+# Do a next over the assignment to vector 'a'.
gdb_test "next" ".*b = \\(vector int\\) __ev_create_s32 \\(3, 3\\);" \
"next (1)"
-# Do a next over the assignment to vector 'b'.
+# Do a next over the assignment to vector 'b'.
gdb_test "next" "c = __ev_and \\(a, b\\);" \
"next (2)"
diff --git a/gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp b/gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp
index 80df6b9..d8b94f2 100644
--- a/gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp
+++ b/gdb/testsuite/gdb.arch/ftrace-insn-reloc.exp
@@ -19,16 +19,16 @@ standard_testfile insn-reloc.c
# Some targets have leading underscores on assembly symbols.
set additional_flags [gdb_target_symbol_prefix_flags]
-if [prepare_for_testing "failed to prepare" $testfile-no-ipa $srcfile \
- [list debug $additional_flags]] {
+if {[prepare_for_testing "failed to prepare" $testfile-no-ipa $srcfile \
+ [list debug $additional_flags]]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
-if ![gdb_target_supports_trace] {
+if {![gdb_target_supports_trace]} {
unsupported "target does not support trace"
return -1
}
@@ -48,7 +48,7 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \
clean_restart $testfile
set remote_libipa [gdb_load_shlib $libipa]
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
diff --git a/gdb/testsuite/gdb.arch/gdb1291.exp b/gdb/testsuite/gdb.arch/gdb1291.exp
index ad3b8f9..9f460c8 100644
--- a/gdb/testsuite/gdb.arch/gdb1291.exp
+++ b/gdb/testsuite/gdb.arch/gdb1291.exp
@@ -33,7 +33,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ""] !
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
#
# Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.arch/gdb1431.exp b/gdb/testsuite/gdb.arch/gdb1431.exp
index 34bc8d6..bc65d26 100644
--- a/gdb/testsuite/gdb.arch/gdb1431.exp
+++ b/gdb/testsuite/gdb.arch/gdb1431.exp
@@ -35,7 +35,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ""] !
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
#
# Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.arch/gdb1558.exp b/gdb/testsuite/gdb.arch/gdb1558.exp
index f690468..3de5723 100644
--- a/gdb/testsuite/gdb.arch/gdb1558.exp
+++ b/gdb/testsuite/gdb.arch/gdb1558.exp
@@ -32,7 +32,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {"add
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
gdb_test "b -q main" "Breakpoint 1.*" "set breakpoint at main"
gdb_test "b -q sub1" "Breakpoint 2.*" "set breakpoint at sub1"
diff --git a/gdb/testsuite/gdb.arch/i386-avx.exp b/gdb/testsuite/gdb.arch/i386-avx.exp
index 8f07a3d..3a1d8e8 100644
--- a/gdb/testsuite/gdb.arch/i386-avx.exp
+++ b/gdb/testsuite/gdb.arch/i386-avx.exp
@@ -42,7 +42,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
return
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
@@ -53,7 +53,7 @@ gdb_test "break [gdb_get_line_number "first breakpoint here"]" \
"set first breakpoint in main"
gdb_continue_to_breakpoint "continue to first breakpoint in main"
-if [is_amd64_regs_target] {
+if {[is_amd64_regs_target]} {
set nr_regs 16
} else {
set nr_regs 8
@@ -79,7 +79,7 @@ gdb_continue_to_breakpoint "continue to second breakpoint in main"
for { set r 0 } { $r < $nr_regs } { incr r } {
gdb_test "print data\[$r\]" \
- ".. = \\{f = \\{[expr $r + 10], $r.125, $r.25, $r.375, $r.5, $r.625, $r.75, $r.875\\}\\}.*" \
+ ".. = \\{f = \\{[expr {$r + 10}], $r.125, $r.25, $r.375, $r.5, $r.625, $r.75, $r.875\\}\\}.*" \
"check contents of data\[$r\]"
}
@@ -93,7 +93,7 @@ with_test_prefix "force-disable xml descriptions" {
save_vars { GDBFLAGS } {
append GDBFLAGS " -ex \"set remote target-features-packet off\""
- clean_restart ${binfile}
+ clean_restart ${::testfile}
}
if {![runto_main]} {
diff --git a/gdb/testsuite/gdb.arch/i386-avx512.exp b/gdb/testsuite/gdb.arch/i386-avx512.exp
index dcd6cc9..675a3c7 100644
--- a/gdb/testsuite/gdb.arch/i386-avx512.exp
+++ b/gdb/testsuite/gdb.arch/i386-avx512.exp
@@ -31,7 +31,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
@@ -78,7 +78,7 @@ gdb_continue_to_breakpoint "continue to second breakpoint in main"
set nr_regs 7
for { set r 0 } { $r < $nr_regs } { incr r } {
- set val [expr $r + 1]
+ set val [expr {$r + 1}]
gdb_test "print/x k_data\[$r\]" \
".. = 0x$val$val$val$val" \
"check contents of k_data\[$r\]"
@@ -89,7 +89,7 @@ gdb_test "break [gdb_get_line_number "third breakpoint here"]" \
"set third breakpoint in main"
gdb_continue_to_breakpoint "continue to third breakpoint in main"
-if [is_amd64_regs_target] {
+if {[is_amd64_regs_target]} {
set nr_regs 32
} else {
set nr_regs 8
@@ -134,7 +134,7 @@ gdb_continue_to_breakpoint "continue to fourth breakpoint in main"
for { set r 0 } { $r < $nr_regs } { incr r } {
gdb_test "print zmm_data\[$r\]" \
- ".. = \\{f = \\{[expr $r + 10], [expr $r.125 + 10], [expr $r.25 + 10], [expr $r.375 + 10], [expr $r.5 + 10], [expr $r.625 + 10], [expr $r.75 + 10], [expr $r.875 + 10]\\}\\}.*" \
+ ".. = \\{f = \\{[expr {$r + 10}], [expr {$r + 10.125}], [expr {$r + 10.25}], [expr {$r + 10.375}], [expr {$r + 10.5}], [expr {$r + 10.625}], [expr {$r +10.75}], [expr {$r + 10.875}]\\}\\}.*" \
"check contents of zmm_data\[$r\] after writing ZMM regs"
}
@@ -152,7 +152,7 @@ gdb_continue_to_breakpoint "continue to fifth breakpoint in main"
for { set r 0 } { $r < $nr_regs } { incr r } {
gdb_test "print zmm_data\[$r\]" \
- ".. = \\{f = \\{[expr $r + 20], [expr $r.125 + 20], [expr $r.25 + 20], [expr $r.375 + 20], [expr $r.5 + 10], [expr $r.625 + 10], [expr $r.75 + 10], [expr $r.875 + 10]\\}\\}.*" \
+ ".. = \\{f = \\{[expr {$r + 20}], [expr {$r + 20.125}], [expr {$r + 20.25}], [expr {$r + 20.375}], [expr {$r + 10.5}], [expr {$r + 10.625}], [expr {$r + 10.75}], [expr {$r + 10.875}]\\}\\}.*" \
"check contents of zmm_data\[$r\] after writing YMM regs"
}
@@ -168,7 +168,7 @@ gdb_continue_to_breakpoint "continue to sixth breakpoint in main"
for { set r 0 } { $r < $nr_regs } { incr r } {
gdb_test "print zmm_data\[$r\]" \
- ".. = \\{f = \\{[expr $r + 30], [expr $r.125 + 30], [expr $r.25 + 20], [expr $r.375 + 20], [expr $r.5 + 10], [expr $r.625 + 10], [expr $r.75 + 10], [expr $r.875 + 10]\\}\\}.*" \
+ ".. = \\{f = \\{[expr {$r + 30}], [expr {$r + 30.125}], [expr {$r + 20.25}], [expr {$r + 20.375}], [expr {$r + 10.5}], [expr {$r + 10.625}], [expr {$r + 10.75}], [expr {$r + 10.875}]\\}\\}.*" \
"check contents of zmm_data\[$r\] after writing XMM regs"
}
diff --git a/gdb/testsuite/gdb.arch/i386-biarch-core.exp b/gdb/testsuite/gdb.arch/i386-biarch-core.exp
index 6e83939..c04b87d 100644
--- a/gdb/testsuite/gdb.arch/i386-biarch-core.exp
+++ b/gdb/testsuite/gdb.arch/i386-biarch-core.exp
@@ -54,7 +54,7 @@ set corefile [gdb_remote_download host $corefile]
# First check if this particular GDB supports i386, otherwise we should not
# expect the i386 core file to be loaded successfully.
set archs [get_set_option_choices "set architecture" "i386"]
-set supports_arch_i386 [expr [lsearch -exact $archs i386] != -1]
+set supports_arch_i386 [expr {[lsearch -exact $archs i386] != -1}]
# Wrongly built GDB complains by:
# "..." is not a core dump: File format not recognized
diff --git a/gdb/testsuite/gdb.arch/i386-bp_permanent.exp b/gdb/testsuite/gdb.arch/i386-bp_permanent.exp
index 1d3713f..6eb9ee6 100644
--- a/gdb/testsuite/gdb.arch/i386-bp_permanent.exp
+++ b/gdb/testsuite/gdb.arch/i386-bp_permanent.exp
@@ -33,7 +33,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list
}
-clean_restart $binfile
+clean_restart $::testfile
#
# Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.arch/i386-byte.exp b/gdb/testsuite/gdb.arch/i386-byte.exp
index dcbcb40..12b57f3 100644
--- a/gdb/testsuite/gdb.arch/i386-byte.exp
+++ b/gdb/testsuite/gdb.arch/i386-byte.exp
@@ -28,7 +28,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list
return
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
@@ -51,7 +51,7 @@ with_test_prefix "at first bp" {
gdb_test "print/x \$$byte_regs($r)" \
".. = 0x[format %x $r]1" \
"check contents of %$byte_regs($r)"
- set h [expr $r + 4]
+ set h [expr {$r + 4}]
gdb_test "print/x \$$byte_regs($h)" \
".. = 0x[format %x $r]2" \
"check contents of %$byte_regs($h)"
@@ -59,7 +59,7 @@ with_test_prefix "at first bp" {
for { set r 1 } { $r <= 4 } { incr r } {
gdb_test "set var \$$byte_regs($r) = $r" "" "set %$byte_regs($r)"
- set h [expr $r + 4]
+ set h [expr {$r + 4}]
gdb_test "set var \$$byte_regs($h) = $h" "" "set %$byte_regs($h)"
}
}
@@ -72,7 +72,7 @@ with_test_prefix "at second bp" {
gdb_test "print \$$byte_regs($r)" \
".. = $r" \
"check contents of %$byte_regs($r)"
- set h [expr $r + 4]
+ set h [expr {$r + 4}]
gdb_test "print \$$byte_regs($h)" \
".. = $h" \
"check contents of %$byte_regs($h)"
diff --git a/gdb/testsuite/gdb.arch/i386-cfi-notcurrent.exp b/gdb/testsuite/gdb.arch/i386-cfi-notcurrent.exp
index 7291f02..661265b 100644
--- a/gdb/testsuite/gdb.arch/i386-cfi-notcurrent.exp
+++ b/gdb/testsuite/gdb.arch/i386-cfi-notcurrent.exp
@@ -21,11 +21,11 @@ require is_x86_like_target
set testfile "i386-cfi-notcurrent"
set srcfile ${testfile}.S
-if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {nodebug}] {
+if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {nodebug}]} {
return -1
}
-if ![runto f] {
+if {![runto f]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/i386-disp-step-self-call-alarm.c b/gdb/testsuite/gdb.arch/i386-disp-step-self-call-alarm.c
index 03b868c..0fb2904 100644
--- a/gdb/testsuite/gdb.arch/i386-disp-step-self-call-alarm.c
+++ b/gdb/testsuite/gdb.arch/i386-disp-step-self-call-alarm.c
@@ -16,9 +16,27 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <unistd.h>
+#include <stdlib.h>
+
+extern void test_call (void);
+
+void
+unreachable (void)
+{
+ abort ();
+}
void
setup_alarm (void)
{
alarm (300);
}
+
+int
+main ()
+{
+ setup_alarm ();
+ test_call ();
+ unreachable ();
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/i386-disp-step-self-call.S b/gdb/testsuite/gdb.arch/i386-disp-step-self-call.S
index 466e50c..20a8eb7 100644
--- a/gdb/testsuite/gdb.arch/i386-disp-step-self-call.S
+++ b/gdb/testsuite/gdb.arch/i386-disp-step-self-call.S
@@ -18,33 +18,12 @@
handling. */
.text
-
- .global main
-main:
- nop
-
- call setup_alarm
-
- nop
-
-/***********************************************/
-
-/* test call/ret */
-
.global test_call
test_call:
call test_call
- nop
+ call unreachable
.global test_ret_end
test_ret_end:
nop
-/***********************************************/
-
-/* all done */
-
-done:
- pushl $0
- call exit
- hlt
.section .note.GNU-stack,"",@progbits
diff --git a/gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp b/gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp
index 3e8ae1c..1d4c87e 100644
--- a/gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp
+++ b/gdb/testsuite/gdb.arch/i386-disp-step-self-call.exp
@@ -59,7 +59,7 @@ gdb_test_multiple "x/2i \$pc" "get address of next insn" {
}
# Clear the slot on the stack and confirm it was set to zero.
-set sp [expr $sp - 0x4]
+set sp [expr {$sp - 0x4}]
gdb_test_no_output "set {unsigned int} $sp = 0" \
"clear stack slot"
set zero_val 0x[format %08x 0]
@@ -73,7 +73,7 @@ gdb_test "stepi" \
# Check stack pointer was updated to the expected value.
set new_sp [get_hexadecimal_valueof "\$sp" "*UNKNOWN*" \
"get stack pointer after step"]
-gdb_assert {[expr $sp == $new_sp]} \
+gdb_assert {[expr {$sp == $new_sp}]} \
"check stack pointer was updated as expected"
# Check the contents of the stack were updated to the expected value.
diff --git a/gdb/testsuite/gdb.arch/i386-dr3-watch.exp b/gdb/testsuite/gdb.arch/i386-dr3-watch.exp
index 4fe2608..16d2872 100644
--- a/gdb/testsuite/gdb.arch/i386-dr3-watch.exp
+++ b/gdb/testsuite/gdb.arch/i386-dr3-watch.exp
@@ -23,7 +23,7 @@ require {is_any_target "i?86-*-*" "x86_64-*-*"}
standard_testfile
-if [prepare_for_testing "failed to prepare" ${binfile} ${srcfile} {debug $additional_flags}] {
+if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug $additional_flags}]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/i386-gnu-cfi.exp b/gdb/testsuite/gdb.arch/i386-gnu-cfi.exp
index b51f034..c446fae 100644
--- a/gdb/testsuite/gdb.arch/i386-gnu-cfi.exp
+++ b/gdb/testsuite/gdb.arch/i386-gnu-cfi.exp
@@ -40,7 +40,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfilec} ${srcdir}/${subdir}/${srcfile
# Get things started.
-clean_restart $binfile
+clean_restart $::testfile
# We should stop in abort(3).
diff --git a/gdb/testsuite/gdb.arch/i386-permbkpt.exp b/gdb/testsuite/gdb.arch/i386-permbkpt.exp
index b979d6e..1118cb4 100644
--- a/gdb/testsuite/gdb.arch/i386-permbkpt.exp
+++ b/gdb/testsuite/gdb.arch/i386-permbkpt.exp
@@ -30,7 +30,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list
return -1
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_test "break -q main" "" "first permanent break"
gdb_test "break -q main" "" "second permanent break"
diff --git a/gdb/testsuite/gdb.arch/i386-pkru.exp b/gdb/testsuite/gdb.arch/i386-pkru.exp
index 7262b8b..6355c43 100644
--- a/gdb/testsuite/gdb.arch/i386-pkru.exp
+++ b/gdb/testsuite/gdb.arch/i386-pkru.exp
@@ -34,7 +34,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
@@ -63,8 +63,8 @@ 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]]]
+ {[version_compare [list 5 14 0] <= $v] \
+ && [version_compare $v < [list 6 2 0]]}]
}
# Test pkru register at startup
diff --git a/gdb/testsuite/gdb.arch/i386-prologue-skip-cf-protection-stackalign.c b/gdb/testsuite/gdb.arch/i386-prologue-skip-cf-protection-stackalign.c
new file mode 100644
index 0000000..f55cee5
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/i386-prologue-skip-cf-protection-stackalign.c
@@ -0,0 +1,27 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2025 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <alloca.h>
+
+int
+main (int argc, char **argv)
+{
+ volatile __attribute__ ((__aligned__ (64))) int a;
+ volatile char *p = (char *) alloca (argc * 12);
+ p[2] = 'b';
+ return 1;
+}
diff --git a/gdb/testsuite/gdb.arch/i386-prologue-skip-cf-protection.exp b/gdb/testsuite/gdb.arch/i386-prologue-skip-cf-protection.exp
index eb93127..ac2be79 100644
--- a/gdb/testsuite/gdb.arch/i386-prologue-skip-cf-protection.exp
+++ b/gdb/testsuite/gdb.arch/i386-prologue-skip-cf-protection.exp
@@ -19,41 +19,65 @@
# This option places an `endbr32`/`endbr64` instruction at the start of
# all functions, which can interfere with prologue analysis.
-standard_testfile .c
-set binfile ${binfile}
+standard_testfile .c -stackalign.c
require {is_any_target x86_64-*-* i?86-*-*}
-
require supports_fcf_protection
-set opts {debug additional_flags=-fcf-protection=full}
+# Tests if breakpoint set on main is placed past main's entry.
+proc test_run {} {
+ # Get start address of function main.
+ set main_addr [get_integer_valueof &main -1]
+ gdb_assert {$main_addr != -1}
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $opts] != "" } {
- untested "failed to compile"
- return
-}
+ set bp_addr -1
-clean_restart ${binfile}
+ # Put breakpoint on main, get the address where the breakpoint was installed.
+ gdb_test_multiple "break -q main" "break on main, get address" {
+ -re -wrap "Breakpoint $::decimal at ($::hex).*" {
+ set bp_addr $expect_out(1,string)
-# Get start address of function main.
-set main_addr [get_integer_valueof &main -1]
-gdb_assert {$main_addr != -1}
+ # Convert to decimal.
+ set bp_addr [expr {$bp_addr}]
-set bp_addr -1
+ pass $gdb_test_name
+ }
+ }
-# Put breakpoint on main, get the address where the breakpoint was installed.
-gdb_test_multiple "break -q main" "break on main, get address" {
- -re -wrap "Breakpoint $decimal at ($hex).*" {
- set bp_addr $expect_out(1,string)
+ # Make sure some prologue was skipped.
+ gdb_assert {$bp_addr != -1 && $bp_addr > $main_addr} \
+ "breakpoint placed past main's entry"
+}
- # Convert to decimal.
- set bp_addr [expr $bp_addr]
+with_test_prefix "skip-cf-protection" {
+ set opts {debug additional_flags=-fcf-protection=full}
- pass $gdb_test_name
+ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
+ $opts] != "" } {
+ untested "failed to compile"
+ return
}
+
+ clean_restart ${::testfile}
+
+ test_run
}
-if { $bp_addr != -1 } {
- # Make sure some prologue was skipped.
- gdb_assert {$bp_addr > $main_addr}
+# Now, make sure that the prologue analysis does not end up at function's entry
+# when stack alignment sequence is generated right after 'endbr64'/'endbr32'.
+# That could happen if GDB handled those incorrectly - there was a bug that
+# checked for those two in incorrect order, which caused such issue.
+with_test_prefix "skip-cf-protection-stackalign" {
+ # gcc is easier to make it produce the sequence of interest.
+ if { ![is_c_compiler_gcc] } {
+ unsupported "stackalign test part requires gcc compiler"
+ return
+ }
+
+ if { [prepare_for_testing "failed to prepare" "${testfile}-stackalign" \
+ $srcfile2 [list optimize=-O0 additional_flags=-fcf-protection=full]] } {
+ return
+ }
+
+ test_run
}
diff --git a/gdb/testsuite/gdb.arch/i386-prologue.exp b/gdb/testsuite/gdb.arch/i386-prologue.exp
index 72246f4..bfab6d1 100644
--- a/gdb/testsuite/gdb.arch/i386-prologue.exp
+++ b/gdb/testsuite/gdb.arch/i386-prologue.exp
@@ -53,7 +53,7 @@ proc skip_breakpoint { msg } {
}
-clean_restart $binfile
+clean_restart $::testfile
#
# Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.arch/i386-signal.exp b/gdb/testsuite/gdb.arch/i386-signal.exp
index 30f212b..80d1827 100644
--- a/gdb/testsuite/gdb.arch/i386-signal.exp
+++ b/gdb/testsuite/gdb.arch/i386-signal.exp
@@ -30,7 +30,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
runto func
gdb_test "backtrace 10" \
diff --git a/gdb/testsuite/gdb.arch/i386-size-overlap.exp b/gdb/testsuite/gdb.arch/i386-size-overlap.exp
index ca8383d..db88673 100644
--- a/gdb/testsuite/gdb.arch/i386-size-overlap.exp
+++ b/gdb/testsuite/gdb.arch/i386-size-overlap.exp
@@ -30,7 +30,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
# We use gdb_run_cmd so this stands a chance to work for remote
# targets too.
diff --git a/gdb/testsuite/gdb.arch/i386-size.exp b/gdb/testsuite/gdb.arch/i386-size.exp
index b08182f..997e629 100644
--- a/gdb/testsuite/gdb.arch/i386-size.exp
+++ b/gdb/testsuite/gdb.arch/i386-size.exp
@@ -35,7 +35,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
# We use gdb_run_cmd so this stands a chance to work for remote
# targets too.
diff --git a/gdb/testsuite/gdb.arch/i386-sse-stack-align.exp b/gdb/testsuite/gdb.arch/i386-sse-stack-align.exp
index af0b56d..6b9260b 100644
--- a/gdb/testsuite/gdb.arch/i386-sse-stack-align.exp
+++ b/gdb/testsuite/gdb.arch/i386-sse-stack-align.exp
@@ -22,7 +22,7 @@ set executable ${testfile}
set binfile [standard_output_file ${executable}]
set opts {}
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
set srcfile ${csrcfile}
lappend opts debug optimize=-O2 additional_flags=-msse
}
@@ -53,5 +53,5 @@ foreach i {0 1 2 3 4} {
if {$args != ""} {
set args "$args, "
}
- set args "$args[expr $i + 1]"
+ set args "$args[expr {$i + 1}]"
}
diff --git a/gdb/testsuite/gdb.arch/i386-sse.exp b/gdb/testsuite/gdb.arch/i386-sse.exp
index f0aa5ec..ee22b62 100644
--- a/gdb/testsuite/gdb.arch/i386-sse.exp
+++ b/gdb/testsuite/gdb.arch/i386-sse.exp
@@ -40,7 +40,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
return
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
@@ -68,7 +68,7 @@ gdb_test "break [gdb_get_line_number "first breakpoint here"]" \
"set first breakpoint in main"
gdb_continue_to_breakpoint "continue to first breakpoint in main"
-if [is_amd64_regs_target] {
+if {[is_amd64_regs_target]} {
set nr_regs 16
} else {
set nr_regs 8
@@ -94,6 +94,6 @@ gdb_continue_to_breakpoint "continue to second breakpoint in main"
for { set r 0 } { $r < $nr_regs } { incr r } {
gdb_test "print data\[$r\]" \
- ".. = \\{f = \\{[expr $r + 10], $r.25, $r.5, $r.75\\}\\}.*" \
+ ".. = \\{f = \\{[expr {$r + 10}], $r.25, $r.5, $r.75\\}\\}.*" \
"check contents of data\[$r\]"
}
diff --git a/gdb/testsuite/gdb.arch/i386-unwind.exp b/gdb/testsuite/gdb.arch/i386-unwind.exp
index 99acfe9..76f0a78 100644
--- a/gdb/testsuite/gdb.arch/i386-unwind.exp
+++ b/gdb/testsuite/gdb.arch/i386-unwind.exp
@@ -33,7 +33,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
# Testcase for backtrace/1435.
diff --git a/gdb/testsuite/gdb.arch/i386-word.exp b/gdb/testsuite/gdb.arch/i386-word.exp
index 0da49c0..ed02d27 100644
--- a/gdb/testsuite/gdb.arch/i386-word.exp
+++ b/gdb/testsuite/gdb.arch/i386-word.exp
@@ -28,7 +28,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list
return
}
-clean_restart ${binfile}
+clean_restart ${::testfile}
if {![runto_main]} {
return 0
diff --git a/gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.exp b/gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.exp
index 8e8ed9b..ed617fc 100644
--- a/gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.exp
+++ b/gdb/testsuite/gdb.arch/ia64-breakpoint-shadow.exp
@@ -23,10 +23,11 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# We need to start the inferior to place the breakpoints in the memory at all.
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
@@ -53,7 +54,7 @@ gdb_test_multiple "b bundle" $test {
}
}
-if ![info exists bpt2address] {
+if {![info exists bpt2address]} {
return -1
}
@@ -64,7 +65,7 @@ set test "disassembly with breakpoints"
gdb_test_multiple "disass main" $test {
-re $match {
set got $expect_out(1,string)
- if [string equal -nocase $orig $got] {
+ if {[string equal -nocase $orig $got]} {
pass $test
} else {
fail $test
diff --git a/gdb/testsuite/gdb.arch/mips-fcr.exp b/gdb/testsuite/gdb.arch/mips-fcr.exp
index b47c371..6fe332a 100644
--- a/gdb/testsuite/gdb.arch/mips-fcr.exp
+++ b/gdb/testsuite/gdb.arch/mips-fcr.exp
@@ -25,7 +25,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile}] } {
return
}
-if ![runto_main] {
+if {![runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.arch/mips-fpregset-core.exp b/gdb/testsuite/gdb.arch/mips-fpregset-core.exp
index aa55ede..d67cef2 100644
--- a/gdb/testsuite/gdb.arch/mips-fpregset-core.exp
+++ b/gdb/testsuite/gdb.arch/mips-fpregset-core.exp
@@ -79,7 +79,8 @@ set core_supported [expr {$corefile != ""}]
# Generate a core file with "gcore".
-clean_restart ${binfile}
+clean_restart
+gdb_load $binfile
runto break_here
@@ -116,7 +117,8 @@ proc mips_fpregset_core_test { supported corefile } {
upvar host_triplet host_triplet
upvar binfile binfile
- clean_restart ${binfile}
+ clean_restart
+ gdb_load $binfile
set test "load core file"
if { $supported } {
diff --git a/gdb/testsuite/gdb.arch/mips-octeon-bbit.exp b/gdb/testsuite/gdb.arch/mips-octeon-bbit.exp
index 3fb6f9c..1921578 100644
--- a/gdb/testsuite/gdb.arch/mips-octeon-bbit.exp
+++ b/gdb/testsuite/gdb.arch/mips-octeon-bbit.exp
@@ -4,16 +4,16 @@
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
-# Test single-step on bbit.
+# Test single-step on bbit.
require {istarget "*octeon*"}
@@ -48,7 +48,7 @@ proc single_step_until { match } {
set insn [current_insn]
set start [timestamp]
while { $insn != "" && [timestamp] - $start < 3*$timeout } {
- if [regexp $match $insn] {
+ if {[regexp $match $insn]} {
return 1
}
if {![single_step]} {
@@ -66,7 +66,7 @@ proc test_bbit { name taken } {
}
pass "$name single-step until bbit"
gdb_test "si" "" "$name single-step on bbit"
- if [regexp "li\\s+\[sv\]0,$taken" [current_insn]] {
+ if {[regexp "li\\s+\[sv\]0,$taken" [current_insn]]} {
pass "$name check insn after bbit"
} else {
send_log "expected: li\\s+\[sv\]0,$taken found [current_insn]\n"
@@ -86,7 +86,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
pass "compilation"
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# Native needs run.
runto_main
diff --git a/gdb/testsuite/gdb.arch/pa-nullify.exp b/gdb/testsuite/gdb.arch/pa-nullify.exp
index 87afe7a..cb8eeeb 100644
--- a/gdb/testsuite/gdb.arch/pa-nullify.exp
+++ b/gdb/testsuite/gdb.arch/pa-nullify.exp
@@ -40,9 +40,10 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] !
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
-# In the first test, we do a "step" on a function whose last instruction
+# In the first test, we do a "step" on a function whose last instruction
# contains a branch-with-nullify. The instruction in the delay slot belongs
# to the next function. We verify that when we step off the first function
# that we end up back at the caller and not at the second instruction.
@@ -64,9 +65,9 @@ gdb_test_multiple "stepi" "${test}" {
}
}
-# In the second test, we verify that we can get a proper backtrace
+# In the second test, we verify that we can get a proper backtrace
# even when we are in a nullified instruction that belongs to the next function.
-# We also verify that when stepping over a branch-with-nullify insn that we
+# We also verify that when stepping over a branch-with-nullify insn that we
# stay on the same insn for two steps.
proc get_addr_of_sym { sym } {
@@ -126,7 +127,7 @@ if {![runto_main]} {
}
gdb_breakpoint "*$foo_last"
gdb_test "continue" "Breakpoint \[0-9\]*,.* in foo.*" "$test: continue to breakpoint"
-if [gen_core $test] {
+if {[gen_core $test]} {
test_core_bt $test
}
@@ -137,6 +138,6 @@ if {![runto_main]} {
gdb_breakpoint "*$foo_last"
gdb_test "continue" "Breakpoint \[0-9\]*,.* in foo.*" "$test: continue to breakpoint"
gdb_test "stepi" ".*in foo.*" "$test: step to nullified instruction"
-if [gen_core $test] {
+if {[gen_core $test]} {
test_core_bt $test
}
diff --git a/gdb/testsuite/gdb.arch/powerpc-addpcis.exp b/gdb/testsuite/gdb.arch/powerpc-addpcis.exp
index 5a6d38e..9d88c78 100644
--- a/gdb/testsuite/gdb.arch/powerpc-addpcis.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-addpcis.exp
@@ -86,25 +86,25 @@ set check_r9 [get_hexadecimal_valueof "\$r9" "default0"]
# addpcis 8,+0x10 # /* set r8 */
# addpcis 9,+0x100 # /* set r9 */
-if [expr $check_r3 + 0x1000000 != $check_r6 - 0xc ] {
+if {$check_r3 + 0x1000000 != $check_r6 - 0xc} {
fail "unexpected value r3 + 0x1,000,000 != r6 + 0xc ; r3: $check_r3 r6: $check_r6 "
}
-if [expr $check_r4 + 0x100000 != $check_r6 - 0x8 ] {
+if {$check_r4 + 0x100000 != $check_r6 - 0x8} {
fail "unexpected value r4 + 0x100,000 != r6 - 0x8 ; r4: $check_r4 r6: $check_r6 "
}
-if [expr $check_r5 + 0x10000 != $check_r6 - 0x4 ] {
+if {$check_r5 + 0x10000 != $check_r6 - 0x4} {
fail "unexpected value r5 + 0x10,000 != r6 , r5: $check_r5 r6: $check_r6 "
}
-if [expr $check_r6 != $check_r6] {
+if {$check_r6 != $check_r6} {
fail "unexpected value r6 != r6 , r6: $check_r6 r6: $check_r6 "
}
-if [expr $check_r7 - 0x10000 != $check_r6 + 0x4] {
+if {$check_r7 - 0x10000 != $check_r6 + 0x4} {
fail "unexpected value r7 - 0x10,000 != r6 + 0x4 , r7: $check_r7 r7: $check_r6 "
}
-if [expr $check_r8 - 0x100000 != $check_r6 + 0x8 ] {
+if {$check_r8 - 0x100000 != $check_r6 + 0x8} {
fail "unexpected value r8 - 0x100,000 != r6 , r8: $check_r8 r8: $check_r6 "
}
-if [expr $check_r9 - 0x1000000 != $check_r6 + 0xc ] {
+if {$check_r9 - 0x1000000 != $check_r6 + 0xc} {
fail "unexpected value r9 - 0x1,000,000 != r6 + 0xc , r9: $check_r9 r6: $check_r6 "
}
diff --git a/gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp b/gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp
index 13e3fd3..4e6ee78 100644
--- a/gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-aix-prologue.exp
@@ -28,7 +28,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] !
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
# Insert a breakpoint in FUNCTION and verifies that the breakpoint was
# inserted at the expected location. EXPECTED_LOCATION should be an
@@ -37,7 +38,7 @@ proc insert_breakpoint {function expected_location} {
global gdb_prompt
global expect_out
global hex
-
+
set address ""
# Insert a breakpoint using the given function name, and extract
diff --git a/gdb/testsuite/gdb.arch/powerpc-altivec.exp b/gdb/testsuite/gdb.arch/powerpc-altivec.exp
index 987da07..0084ffe 100644
--- a/gdb/testsuite/gdb.arch/powerpc-altivec.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-altivec.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
@@ -52,7 +53,7 @@ proc func_check {instr} {
set test "found: '$instr'"
set peb [instr_to_patt $instr]
- if [regexp -nocase -line [instr_to_patt $instr] $func] {
+ if {[regexp -nocase -line [instr_to_patt $instr] $func]} {
pass $test
} else {
fail $peb
diff --git a/gdb/testsuite/gdb.arch/powerpc-altivec2.exp b/gdb/testsuite/gdb.arch/powerpc-altivec2.exp
index 3bf7c57..cd2240a 100644
--- a/gdb/testsuite/gdb.arch/powerpc-altivec2.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-altivec2.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
@@ -51,7 +52,7 @@ proc func_check {instr} {
global func
set test "found: $instr"
- if [regexp -nocase -line [instr_to_patt $instr] $func] {
+ if {[regexp -nocase -line [instr_to_patt $instr] $func]} {
pass $test
} else {
fail $test
diff --git a/gdb/testsuite/gdb.arch/powerpc-altivec3.exp b/gdb/testsuite/gdb.arch/powerpc-altivec3.exp
index ff1d79a..c7d1a2b 100644
--- a/gdb/testsuite/gdb.arch/powerpc-altivec3.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-altivec3.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
@@ -51,7 +52,7 @@ proc func_check {instr} {
global func
set test "found: $instr"
- if [regexp -nocase -line [instr_to_patt $instr] $func] {
+ if {[regexp -nocase -line [instr_to_patt $instr] $func]} {
pass $test
} else {
fail $test
diff --git a/gdb/testsuite/gdb.arch/powerpc-d128-regs.exp b/gdb/testsuite/gdb.arch/powerpc-d128-regs.exp
index 42fc51e..904c758 100644
--- a/gdb/testsuite/gdb.arch/powerpc-d128-regs.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-d128-regs.exp
@@ -29,13 +29,13 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {qui
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
if {![runto_main]} {
return
}
-if [gdb_test "show arch" ".*powerpc:common.*" "checking for PPC arch"] {
+if {[gdb_test "show arch" ".*powerpc:common.*" "checking for PPC arch"]} {
return -1
}
@@ -50,12 +50,12 @@ gdb_test "info reg dl$i" \
"dl$i\[ \]*1\.2345678910\[ \t\]*\\(raw 0x2205800000000000000000049c5de09c\\)" \
"print dl$i register with the info reg command"
-gdb_test "info reg f[expr 2*$i]" \
- "f[expr 2*$i]\[ \]*8\.608957309287334e\-145\[ \t\]*\\(raw 0x2205800000000000\\)" \
+gdb_test "info reg f[expr {2*$i}]" \
+ "f[expr {2*$i}]\[ \]*8\.608957309287334e\-145\[ \t\]*\\(raw 0x2205800000000000\\)" \
"testing lower half of dl$i register"
-gdb_test "info reg f[expr 2*$i+1]" \
- "f[expr 2*$i+1]\[ \]*9\.7841140127686122e\-314\[ \t\]*\\(raw 0x000000049c5de09c\\)" \
+gdb_test "info reg f[expr {2*$i+1}]" \
+ "f[expr {2*$i+1}]\[ \]*9\.7841140127686122e\-314\[ \t\]*\\(raw 0x000000049c5de09c\\)" \
"testing upper half of dl$i register"
}
diff --git a/gdb/testsuite/gdb.arch/powerpc-fpscr-gcore.exp b/gdb/testsuite/gdb.arch/powerpc-fpscr-gcore.exp
index a7614fa..13163d2 100644
--- a/gdb/testsuite/gdb.arch/powerpc-fpscr-gcore.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-fpscr-gcore.exp
@@ -34,7 +34,7 @@ if {[build_executable "compile" $binfile $gen_src] == -1} {
return -1
}
-clean_restart $binfile
+clean_restart $testfile
if {![runto_main]} {
return -1
diff --git a/gdb/testsuite/gdb.arch/powerpc-htm-regs.exp b/gdb/testsuite/gdb.arch/powerpc-htm-regs.exp
index 6fcb69f..456833e 100644
--- a/gdb/testsuite/gdb.arch/powerpc-htm-regs.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-htm-regs.exp
@@ -82,7 +82,8 @@ with_test_prefix "check htm support" {
return
}
- clean_restart $binfile
+ clean_restart
+ gdb_load $binfile
# Displaced-stepping a tbegin. causes problems,
# so we make the breakpoint temporary.
@@ -131,7 +132,7 @@ if {[build_executable "compile" $binfile $srcfile {debug}] == -1} {
return
}
-clean_restart $binfile
+clean_restart $testfile
gdb_breakpoint [gdb_get_line_number "first marker"] temporary
@@ -158,7 +159,7 @@ gdb_test_no_output "set \$xer = 0xc0000000"
# FPRs
gdb_test_no_output "set \$f0 = 0.5"
for {set i 1} {$i < 32} {incr i 1} {
- gdb_test_no_output "set \$f$i = \$f[expr $i - 1] + 1.0"
+ gdb_test_no_output "set \$f$i = \$f[expr {$i - 1}] + 1.0"
}
gdb_test_no_output "set \$fpscr = 0x84005000"
@@ -212,7 +213,7 @@ proc test_register_match {reg_name reg_var_name hex} {
# In some infrequent cases CXER doesn't match the
# pre-transactional XER, possibly due to a linux kernel bug.
set should_xfail 0
- if [istarget "powerpc*-*-linux*" && reg_name == "cxer"] {
+ if {[istarget "powerpc*-*-linux*" && reg_name == "cxer"]} {
set should_xfail 1
}
@@ -267,7 +268,7 @@ test_register_match "ctar" "tar" 1
# Support for writing to the checkpointed registers is not
# currently available in the gdbserver stub.
-if [target_is_gdbserver] {
+if {[target_is_gdbserver]} {
unsupported "write to checkpointed registers"
return
}
@@ -281,7 +282,7 @@ for {set i 0} {$i < 32} {incr i 1} {
gdb_test_no_output "set \$cf0 = 0.25"
for {set i 1} {$i < 32} {incr i 1} {
- gdb_test_no_output "set \$cf$i = \$cf[expr $i - 1] + 1.0"
+ gdb_test_no_output "set \$cf$i = \$cf[expr {$i - 1}] + 1.0"
}
for {set i 0} {$i < 32} {incr i 1} {
diff --git a/gdb/testsuite/gdb.arch/powerpc-lnia.exp b/gdb/testsuite/gdb.arch/powerpc-lnia.exp
index 357ec7a..c317465 100644
--- a/gdb/testsuite/gdb.arch/powerpc-lnia.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-lnia.exp
@@ -82,22 +82,22 @@ set check_r9 [get_hexadecimal_valueof "\$r9" "default0"]
# Specifically that the values loaded by the lnia instruction
# reflect the value of the PC as if the instruction was
# not displaced.
-if [expr $check_r3 + 4 != $check_r4] {
+if {$check_r3 + 4 != $check_r4} {
fail "unexpected value r3+4 != r4 , r3: $check_r3 r4: $check_r4 "
}
-if [expr $check_r4 + 4 != $check_r5] {
+if {$check_r4 + 4 != $check_r5} {
fail "unexpected value r4+4 != r5 , r4: $check_r4 r5: $check_r5 "
}
-if [expr $check_r5 + 4 != $check_r6] {
+if {$check_r5 + 4 != $check_r6} {
fail "unexpected value r5+4 != r6 , r5: $check_r5 r6: $check_r6 "
}
-if [expr $check_r6 + 4 != $check_r7] {
+if {$check_r6 + 4 != $check_r7} {
fail "unexpected value r6+4 != r7 , r6: $check_r6 r7: $check_r7 "
}
-if [expr $check_r7 + 4 != $check_r8] {
+if {$check_r7 + 4 != $check_r8} {
fail "unexpected value r7+4 != r8 , r7: $check_r7 r8: $check_r8 "
}
-if [expr $check_r8 + 4 != $check_r9] {
+if {$check_r8 + 4 != $check_r9} {
fail "unexpected value r8+4 != r9 , r8: $check_r8 r9: $check_r9 "
}
diff --git a/gdb/testsuite/gdb.arch/powerpc-plxv-nonrel.exp b/gdb/testsuite/gdb.arch/powerpc-plxv-nonrel.exp
index f4a3fdb..ef6e1ff 100644
--- a/gdb/testsuite/gdb.arch/powerpc-plxv-nonrel.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-plxv-nonrel.exp
@@ -109,16 +109,16 @@ set vs5_expected 0xa7b7c7d7a6b6c6d6a5b5c5d5a4b4c4d4
set vs6_expected 0xa9b9c9d9a8b8c8d8a7b7c7d7a6b6c6d6
set vs7_expected 0xabbbcbdbaabacadaa9b9c9d9a8b8c8d8
-if [expr $check_vs4 != $vs4_expected] {
+if {$check_vs4 != $vs4_expected} {
fail "unexpected value vs4; actual:$check_vs4 expected:$vs4_expected"
}
-if [expr $check_vs5 != $vs5_expected ] {
+if {$check_vs5 != $vs5_expected} {
fail "unexpected value vs5; actual:$check_vs5 expected:$vs5_expected"
}
-if [expr $check_vs6 != $vs6_expected ] {
+if {$check_vs6 != $vs6_expected} {
fail "unexpected value vs6; actual:$check_vs6 expected:$vs6_expected"
}
-if [expr $check_vs7 != $vs7_expected ] {
+if {$check_vs7 != $vs7_expected} {
fail "unexpected value vs7; actual:$check_vs7 expected:$vs7_expected"
}
diff --git a/gdb/testsuite/gdb.arch/powerpc-power10.exp b/gdb/testsuite/gdb.arch/powerpc-power10.exp
index 1bb7174..089ca73 100644
--- a/gdb/testsuite/gdb.arch/powerpc-power10.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-power10.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
@@ -51,7 +52,7 @@ proc func_check {instr} {
global func
set test "found: $instr"
- if [regexp -nocase -line [instr_to_patt $instr] $func] {
+ if {[regexp -nocase -line [instr_to_patt $instr] $func]} {
pass $test
} else {
fail $test
diff --git a/gdb/testsuite/gdb.arch/powerpc-power7.exp b/gdb/testsuite/gdb.arch/powerpc-power7.exp
index f33405d..4d85fd9 100644
--- a/gdb/testsuite/gdb.arch/powerpc-power7.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-power7.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
@@ -51,7 +52,7 @@ proc func_check {instr} {
global func
set test "found: $instr"
- if [regexp -nocase -line [instr_to_patt $instr] $func] {
+ if {[regexp -nocase -line [instr_to_patt $instr] $func]} {
pass $test
} else {
fail $test
diff --git a/gdb/testsuite/gdb.arch/powerpc-power8.exp b/gdb/testsuite/gdb.arch/powerpc-power8.exp
index ab69b0f..f679253 100644
--- a/gdb/testsuite/gdb.arch/powerpc-power8.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-power8.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
@@ -51,7 +52,7 @@ proc func_check {instr} {
global func
set test "found: $instr"
- if [regexp -nocase -line [instr_to_patt $instr] $func] {
+ if {[regexp -nocase -line [instr_to_patt $instr] $func]} {
pass $test
} else {
fail $test
diff --git a/gdb/testsuite/gdb.arch/powerpc-power9.exp b/gdb/testsuite/gdb.arch/powerpc-power9.exp
index b1bfa9d..784ba9b 100644
--- a/gdb/testsuite/gdb.arch/powerpc-power9.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-power9.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
@@ -51,7 +52,7 @@ proc func_check {instr} {
global func
set test "found: $instr"
- if [regexp -nocase -line [instr_to_patt $instr] $func] {
+ if {[regexp -nocase -line [instr_to_patt $instr] $func]} {
pass $test
} else {
fail $test
diff --git a/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp b/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp
index ef6bb9d..1b70535 100644
--- a/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-ppr-dscr.exp
@@ -66,9 +66,9 @@ proc ppr_dscr_available {} {
}
with_test_prefix "check PPR/DSCR access" {
- clean_restart $binfile
+ clean_restart $::testfile
- if ![runto_main] {
+ if {![runto_main]} {
return
}
@@ -86,9 +86,9 @@ with_test_prefix "check PPR/DSCR access" {
}
# Now do the actual test
-clean_restart $binfile
+clean_restart $::testfile
-if ![runto_main] {
+if {![runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.arch/powerpc-prologue-frame.exp b/gdb/testsuite/gdb.arch/powerpc-prologue-frame.exp
index 3c79039..4682cb9 100644
--- a/gdb/testsuite/gdb.arch/powerpc-prologue-frame.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-prologue-frame.exp
@@ -26,9 +26,9 @@ if {[gdb_compile \
}
-clean_restart ${binfile}
+clean_restart $testfile
-if ![runto bar] {
+if {![runto bar]} {
untested "could not run to bar"
return -1
}
diff --git a/gdb/testsuite/gdb.arch/powerpc-prologue.exp b/gdb/testsuite/gdb.arch/powerpc-prologue.exp
index 4e697c1..44877a1 100644
--- a/gdb/testsuite/gdb.arch/powerpc-prologue.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-prologue.exp
@@ -31,7 +31,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {}] !
}
-clean_restart $binfile
+clean_restart $testfile
#
# Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.arch/powerpc-tar.exp b/gdb/testsuite/gdb.arch/powerpc-tar.exp
index b44d554..917d759 100644
--- a/gdb/testsuite/gdb.arch/powerpc-tar.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-tar.exp
@@ -68,9 +68,9 @@ proc tar_available {} {
# Do one pass to check if TAR is usable, system
# software can prevent it from being used.
with_test_prefix "check TAR access" {
- clean_restart $binfile
+ clean_restart $::testfile
- if ![runto_main] {
+ if {![runto_main]} {
return
}
@@ -84,9 +84,9 @@ with_test_prefix "check TAR access" {
}
# Now do the actual test
-clean_restart $binfile
+clean_restart $::testfile
-if ![runto_main] {
+if {![runto_main]} {
return
}
diff --git a/gdb/testsuite/gdb.arch/powerpc-vector-regs.exp b/gdb/testsuite/gdb.arch/powerpc-vector-regs.exp
index 9e9162e..4537646 100644
--- a/gdb/testsuite/gdb.arch/powerpc-vector-regs.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-vector-regs.exp
@@ -30,7 +30,7 @@ if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile} executable {debug}]
}
# Check if our test binary can actually run on this processor.
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_run_cmd
@@ -44,7 +44,7 @@ gdb_test_multiple "" "wait for exit" {
}
# Run the actual test.
-clean_restart ${binfile}
+clean_restart ${::testfile}
gdb_breakpoint [gdb_get_line_number "marker"]
diff --git a/gdb/testsuite/gdb.arch/powerpc-vsx-gcore.exp b/gdb/testsuite/gdb.arch/powerpc-vsx-gcore.exp
index be1f93a..db568c6 100644
--- a/gdb/testsuite/gdb.arch/powerpc-vsx-gcore.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-vsx-gcore.exp
@@ -34,7 +34,7 @@ if {[build_executable "compile" $binfile $gen_src] == -1} {
return -1
}
-clean_restart $binfile
+clean_restart $testfile
if {![runto_main]} {
return -1
diff --git a/gdb/testsuite/gdb.arch/powerpc-vsx.exp b/gdb/testsuite/gdb.arch/powerpc-vsx.exp
index a6832e6..27f2bd0 100644
--- a/gdb/testsuite/gdb.arch/powerpc-vsx.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-vsx.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
@@ -51,7 +52,7 @@ proc func_check {instr} {
global func
set test "found: $instr"
- if [regexp -nocase -line [instr_to_patt $instr] $func] {
+ if {[regexp -nocase -line [instr_to_patt $instr] $func]} {
pass $test
} else {
fail $test
diff --git a/gdb/testsuite/gdb.arch/powerpc-vsx2.exp b/gdb/testsuite/gdb.arch/powerpc-vsx2.exp
index d5cb18e..ec09815 100644
--- a/gdb/testsuite/gdb.arch/powerpc-vsx2.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-vsx2.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
@@ -51,7 +52,7 @@ proc func_check {instr} {
global func
set test "found: $instr"
- if [regexp -nocase -line [instr_to_patt $instr] $func] {
+ if {[regexp -nocase -line [instr_to_patt $instr] $func]} {
pass $test
} else {
fail $test
diff --git a/gdb/testsuite/gdb.arch/powerpc-vsx3.exp b/gdb/testsuite/gdb.arch/powerpc-vsx3.exp
index bd54eaf..5aeed8e 100644
--- a/gdb/testsuite/gdb.arch/powerpc-vsx3.exp
+++ b/gdb/testsuite/gdb.arch/powerpc-vsx3.exp
@@ -27,7 +27,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${objfile}" object {debug}]
return -1
}
-clean_restart ${objfile}
+clean_restart
+gdb_load $objfile
# Disassemble the function.
set func ""
@@ -51,7 +52,7 @@ proc func_check {instr} {
global func
set test "found: $instr"
- if [regexp -nocase -line [instr_to_patt $instr] $func] {
+ if {[regexp -nocase -line [instr_to_patt $instr] $func]} {
pass $test
} else {
fail $test
diff --git a/gdb/testsuite/gdb.arch/ppc-dfp.exp b/gdb/testsuite/gdb.arch/ppc-dfp.exp
index d7a8312..3c3b030 100644
--- a/gdb/testsuite/gdb.arch/ppc-dfp.exp
+++ b/gdb/testsuite/gdb.arch/ppc-dfp.exp
@@ -20,7 +20,7 @@ require {istarget "powerpc*"}
standard_testfile
-if ![test_compiler_info gcc*] {
+if {![test_compiler_info gcc*]} {
# We use GCC's extended asm syntax
warning "unknown compiler"
return -1
@@ -31,7 +31,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {quie
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
gdb_breakpoint [gdb_get_line_number "Set DFP rounding mode."]
diff --git a/gdb/testsuite/gdb.arch/ppc-fp.exp b/gdb/testsuite/gdb.arch/ppc-fp.exp
index 4733296..b8b3f00 100644
--- a/gdb/testsuite/gdb.arch/ppc-fp.exp
+++ b/gdb/testsuite/gdb.arch/ppc-fp.exp
@@ -20,7 +20,7 @@ require {istarget "powerpc*"}
standard_testfile
-if ![test_compiler_info gcc*] {
+if {![test_compiler_info gcc*]} {
# We use GCC's extended asm syntax
warning "unknown compiler"
return -1
@@ -31,7 +31,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {quie
return -1
}
-clean_restart $binfile
+clean_restart $::testfile
gdb_breakpoint [gdb_get_line_number "Invalid operation."]
gdb_breakpoint [gdb_get_line_number "Division by zero."]
diff --git a/gdb/testsuite/gdb.arch/ppc-longdouble.exp b/gdb/testsuite/gdb.arch/ppc-longdouble.exp
index f3603f1..739e36f 100644
--- a/gdb/testsuite/gdb.arch/ppc-longdouble.exp
+++ b/gdb/testsuite/gdb.arch/ppc-longdouble.exp
@@ -28,7 +28,7 @@ proc do_test { name {opts {}} } {
return
}
- clean_restart ${binfile}.${name}
+ clean_restart ${::testfile}.${name}
if {![runto_main]} {
return
diff --git a/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.exp b/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.exp
index 17bbdb4..35b442f 100644
--- a/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.exp
+++ b/gdb/testsuite/gdb.arch/ppc64-break-on-_exit.exp
@@ -26,7 +26,7 @@
require {istarget "powerpc*"} is_lp64_target
set flags { nodebug }
-if [info exists COMPILE] {
+if {[info exists COMPILE]} {
standard_testfile .c -main.c
lappend flags optimize=-O2
lappend flags additional_flags=-fno-stack-protector
diff --git a/gdb/testsuite/gdb.arch/pr25124.exp b/gdb/testsuite/gdb.arch/pr25124.exp
index 4c43716..4e7c114 100644
--- a/gdb/testsuite/gdb.arch/pr25124.exp
+++ b/gdb/testsuite/gdb.arch/pr25124.exp
@@ -25,7 +25,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug
return -1
}
-clean_restart $binfile
+clean_restart $testfile
# Check if the disassemble ouput is correct.
gdb_test "x /i main+8" \
diff --git a/gdb/testsuite/gdb.arch/riscv-bp-infcall.exp b/gdb/testsuite/gdb.arch/riscv-bp-infcall.exp
index 62d4c44..39aa793 100644
--- a/gdb/testsuite/gdb.arch/riscv-bp-infcall.exp
+++ b/gdb/testsuite/gdb.arch/riscv-bp-infcall.exp
@@ -31,7 +31,7 @@ if {![runto_main]} {
# Figure out where the breakpoint will be placed taking account for
# stack alignment, and allocation of the dummy code area.
set bp_addr [get_valueof "/x" "\$sp" 0]
-set bp_addr [format 0x%x [expr ($bp_addr & ~0xf) - 0x20]]
+set bp_addr [format 0x%x [expr {($bp_addr & ~0xf) - 0x20}]]
# Fill the region we know will be used as the scratch area with the
# compressed nop instruction. If GDB fails to overwrite this with an
diff --git a/gdb/testsuite/gdb.arch/riscv-info-fcsr.exp b/gdb/testsuite/gdb.arch/riscv-info-fcsr.exp
index 4b3baae..358544f 100644
--- a/gdb/testsuite/gdb.arch/riscv-info-fcsr.exp
+++ b/gdb/testsuite/gdb.arch/riscv-info-fcsr.exp
@@ -32,7 +32,7 @@ if {![runto_main]} {
# that can be written to the fcsr register. The two arguments should
# be the value of each of the two fields within the fcsr register.
proc merge_fflags_and_frm { fflags_value frm_value } {
- set fcsr_value 0x[format %x [expr $fflags_value | ($frm_value << 5)]]
+ set fcsr_value 0x[format %x [expr {$fflags_value | ($frm_value << 5)}]]
return $fcsr_value
}
@@ -48,11 +48,11 @@ proc check_fcsr { fflags_value frm_value frm_string } {
set frm_str_re [string_to_regexp "$frm_string"]
set frm_val_re [format %d ${frm_value}]
- set nv [format %d [expr ($fflags_value >> 4) & 0x1]]
- set dz [format %d [expr ($fflags_value >> 3) & 0x1]]
- set of [format %d [expr ($fflags_value >> 2) & 0x1]]
- set uf [format %d [expr ($fflags_value >> 1) & 0x1]]
- set nx [format %d [expr ($fflags_value >> 0) & 0x1]]
+ set nv [format %d [expr {($fflags_value >> 4) & 0x1}]]
+ set dz [format %d [expr {($fflags_value >> 3) & 0x1}]]
+ set of [format %d [expr {($fflags_value >> 2) & 0x1}]]
+ set uf [format %d [expr {($fflags_value >> 1) & 0x1}]]
+ set nx [format %d [expr {($fflags_value >> 0) & 0x1}]]
set fflags_pattern "NV:${nv} DZ:${dz} OF:${of} UF:${uf} NX:${nx}"
set frm_pattern "FRM:${frm_val_re} \\\[${frm_str_re}\\\]"
diff --git a/gdb/testsuite/gdb.arch/s390-vregs.exp b/gdb/testsuite/gdb.arch/s390-vregs.exp
index 3e47cac..9ee959b 100644
--- a/gdb/testsuite/gdb.arch/s390-vregs.exp
+++ b/gdb/testsuite/gdb.arch/s390-vregs.exp
@@ -19,7 +19,7 @@ require {is_any_target s390-*-* s390x-*-*}
standard_testfile .S
-if [isnative] {
+if {[isnative]} {
# Create a temporary directory, to take a core dump there later.
set coredir [standard_output_file ${testfile}.d]
remote_exec build "rm -rf $coredir"
@@ -31,7 +31,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
@@ -71,7 +71,7 @@ gdb_test_multiple "x/i \$pc" "get PC after vector insn" {
}
}
-if [expr $before_pc + 6 != $after_pc] {
+if {$before_pc + 6 != $after_pc} {
fail "stepping first vector insn"
}
@@ -93,17 +93,17 @@ set a_low 2
set b_high 3
set b_low 5
-set a [expr ($a_high << 32) | $a_low]
-set b [expr ($b_high << 32) | $b_low]
+set a [expr {($a_high << 32) | $a_low}]
+set b [expr {($b_high << 32) | $b_low}]
for {set j 0} {$j < 32} {incr j 1} {
- set i [expr 17 * $j % 32]
+ set i [expr {17 * $j % 32}]
gdb_test_no_output \
- "set \$v$i.v2_int64\[0\] = [expr $a * ($i + 1)]" \
+ "set \$v$i.v2_int64\[0\] = [expr {$a * ($i + 1)}]" \
"set v$i left"
- set i [expr 19 * (31 - $j) % 32]
+ set i [expr {19 * (31 - $j) % 32}]
gdb_test_no_output \
- "set \$v$i.v2_int64\[1\] = [expr $b * (32 - $i)]" \
+ "set \$v$i.v2_int64\[1\] = [expr {$b * (32 - $i)}]" \
"set v$i right"
}
@@ -121,7 +121,7 @@ set vregs [capture_command_output "x/64xg &save_area" ""]
set i 0
foreach {- left right} [regexp -all -inline -line {^.*:\s+(\w+)\s+(\w+)} $vregs] {
- if [expr $left != $a * ($i + 1) || $right != $b * (32 - $i)] {
+ if {$left != $a * ($i + 1) || $right != $b * (32 - $i)} {
fail "verify \$v$i after set"
}
if { $i < 16 } {
@@ -157,10 +157,10 @@ foreach {- r i val} [regexp -all -inline -line \
if { $r ne "v" } {
fail "info registers vector: bad line $j"
} elseif { $val ne [hex128 \
- [expr $a_high * ($i + 1) * $a_high ] \
- [expr $a_low * ($i + 1) * $a_low ] \
- [expr $b_high * (32 - $i) * $b_high * 32] \
- [expr $b_low * (32 - $i) * $b_low * 32] ] } {
+ [expr {$a_high * ($i + 1) * $a_high }] \
+ [expr {$a_low * ($i + 1) * $a_low }] \
+ [expr {$b_high * (32 - $i) * $b_high * 32}] \
+ [expr {$b_low * (32 - $i) * $b_low * 32}] ] } {
fail "compare \$v$i"
}
incr j 1
diff --git a/gdb/testsuite/gdb.arch/skip-prologue.exp b/gdb/testsuite/gdb.arch/skip-prologue.exp
index ec04dad..26fd022 100644
--- a/gdb/testsuite/gdb.arch/skip-prologue.exp
+++ b/gdb/testsuite/gdb.arch/skip-prologue.exp
@@ -48,7 +48,7 @@ proc do_test { f } {
}
set test {$bp_addr == $prologue_end_addr}
- if { [expr $test] } {
+ if {$bp_addr == $prologue_end_addr} {
pass $test
} elseif { $bp_addr < $prologue_end_addr } {
# We'll allow this. For instance, amd64 has a prologue
diff --git a/gdb/testsuite/gdb.arch/sparc-sysstep.exp b/gdb/testsuite/gdb.arch/sparc-sysstep.exp
index 40de862..2a5c194 100644
--- a/gdb/testsuite/gdb.arch/sparc-sysstep.exp
+++ b/gdb/testsuite/gdb.arch/sparc-sysstep.exp
@@ -28,11 +28,11 @@ set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}
set opts {}
-if {[prepare_for_testing "failed to prepare" ${binfile} $srcfile {additional_flags=-g}]} {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {additional_flags=-g}]} {
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/sparc64-adi.exp b/gdb/testsuite/gdb.arch/sparc64-adi.exp
index 25c3ce6..40a8eab 100644
--- a/gdb/testsuite/gdb.arch/sparc64-adi.exp
+++ b/gdb/testsuite/gdb.arch/sparc64-adi.exp
@@ -15,7 +15,7 @@
# This file is part of the gdb testsuite.
-# Basic tests of examining/assigning ADI version tags, and reporting
+# Basic tests of examining/assigning ADI version tags, and reporting
# precise mismatch.
require {istarget "sparc64*-*-linux*"}
diff --git a/gdb/testsuite/gdb.arch/thumb-bx-pc.exp b/gdb/testsuite/gdb.arch/thumb-bx-pc.exp
index 13622eb..e5699d7 100644
--- a/gdb/testsuite/gdb.arch/thumb-bx-pc.exp
+++ b/gdb/testsuite/gdb.arch/thumb-bx-pc.exp
@@ -21,7 +21,7 @@ set testfile "thumb-bx-pc"
set srcfile ${testfile}.S
set opts {}
-if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts] {
+if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} $opts]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/thumb-prologue.exp b/gdb/testsuite/gdb.arch/thumb-prologue.exp
index 112c111..2ee82fb 100644
--- a/gdb/testsuite/gdb.arch/thumb-prologue.exp
+++ b/gdb/testsuite/gdb.arch/thumb-prologue.exp
@@ -27,7 +27,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {"add
}
-clean_restart $binfile
+clean_restart $testfile
#
# Run to `main' where we begin our tests.
diff --git a/gdb/testsuite/gdb.arch/thumb-singlestep.exp b/gdb/testsuite/gdb.arch/thumb-singlestep.exp
index f4f695a..88fe49b 100644
--- a/gdb/testsuite/gdb.arch/thumb-singlestep.exp
+++ b/gdb/testsuite/gdb.arch/thumb-singlestep.exp
@@ -21,7 +21,7 @@ set testfile "thumb-singlestep"
set srcfile ${testfile}.S
set additional_flags "additional_flags=-mthumb"
-if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} [list debug $additional_flags]] {
+if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} [list debug $additional_flags]]} {
return -1
}
diff --git a/gdb/testsuite/gdb.arch/thumb2-it.exp b/gdb/testsuite/gdb.arch/thumb2-it.exp
index 49031e1..e6ef06d 100644
--- a/gdb/testsuite/gdb.arch/thumb2-it.exp
+++ b/gdb/testsuite/gdb.arch/thumb2-it.exp
@@ -24,7 +24,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug
return -1
}
-clean_restart $binfile
+clean_restart $testfile
if {![runto_main]} {
return -1
diff --git a/gdb/testsuite/gdb.arch/vsx-regs.exp b/gdb/testsuite/gdb.arch/vsx-regs.exp
index 645207f..a6ecbfd 100644
--- a/gdb/testsuite/gdb.arch/vsx-regs.exp
+++ b/gdb/testsuite/gdb.arch/vsx-regs.exp
@@ -24,9 +24,9 @@ require {istarget "powerpc*"} allow_vsx_tests
standard_testfile
set compile_flags {debug nowarnings quiet}
-if [test_compiler_info gcc*] {
+if {[test_compiler_info gcc*]} {
set compile_flags "$compile_flags additional_flags=-maltivec additional_flags=-mabi=altivec"
-} elseif [test_compiler_info xlc*] {
+} elseif {[test_compiler_info xlc*]} {
set compile_flags "$compile_flags additional_flags=-qaltivec"
} else {
warning "unknown compiler"
@@ -184,7 +184,8 @@ if {!$core_supported} {
return -1
}
-clean_restart $binfile
+clean_restart
+gdb_load $binfile
set core_loaded [gdb_core_cmd "$corefile" "re-load generated corefile"]
if { $core_loaded == -1 } {
diff --git a/gdb/testsuite/gdb.arch/vsx-vsr-float28.exp b/gdb/testsuite/gdb.arch/vsx-vsr-float28.exp
index e40d52c..76c38ff 100644
--- a/gdb/testsuite/gdb.arch/vsx-vsr-float28.exp
+++ b/gdb/testsuite/gdb.arch/vsx-vsr-float28.exp
@@ -23,9 +23,9 @@ require {istarget "powerpc*"} allow_vsx_tests
standard_testfile
set compile_flags {debug nowarnings quiet}
-if [test_compiler_info gcc*] {
+if {[test_compiler_info gcc*]} {
set compile_flags "$compile_flags additional_flags=-maltivec additional_flags=-mabi=altivec"
-} elseif [test_compiler_info xlc*] {
+} elseif {[test_compiler_info xlc*]} {
set compile_flags "$compile_flags additional_flags=-qaltivec"
} else {
warning "unknown compiler"