Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 0/7] MIPS+testsuite: BLEZL stepping fix and associated test infrastructure
@ 2026-07-23 18:52 Maciej W. Rozycki
  2026-07-23 18:52 ` [PATCH 1/7] testsuite: Factor out target feature test template Maciej W. Rozycki
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Maciej W. Rozycki @ 2026-07-23 18:52 UTC (permalink / raw)
  To: gdb-patches
  Cc: Jovan Dmitrovic, Djordje Todorovic, Milica Matic, Maciej W. Rozycki

Hi,

 This patch series is based on a buried bug fix extracted from a change 
submitted to add MIPSr6 support, most recently posted at 
<https://inbox.sourceware.org/gdb-patches/20250604123838.501596-3-jovan.dmitrovic@htecgroup.com/>, 
that corrects the handling of single-stepping through the BLEZL MIPS II 
instruction.

 This fix begged for test coverage, as indeed does all the MIPS software 
single-stepping infrastructure, so I have created a bunch of test cases 
roughly based on the skeleton already provided with said MIPSr6 change, 
however with extra feature checks to correctly enable individual tests 
based on the target configuration chosen for the testsuite invocation and 
target board's compatibility with the ISA required for test execution.

 This in turn revealed a repeated pattern of feature check code across 
numerous procedures in testsuite/lib/gdb.exp.  Rather than adding a bunch 
more, I chose to factor out the repeated pattern and build the new feature 
checks around it.  For illustration purposes I have converted the existing 
`powerpc*-*-*' target feature checks I could verify with my POWER9 test 
system.

 Consequently this set of 7 changes has resulted, comprised of the new 
generic procedure in 1/7, followed by the `powerpc*-*-*' updates in 2/7, 
and then the MIPS changes in 3/7 through 7/7.  Only MIPS I, MIPS II and 
MIPS16 CPU branches are covered at this point.  See individual change 
descriptions for details.  Authorship attributions are on the best 
knowledge basis.

 This patch set has been regression-tested with a `powerpc64le-linux-gnu' 
native configuration using POWER9 hardware and with the `mips-linux-gnu' 
and `mipsel-linux-gnu' targets, using real MIPS I, MIPS III and MIPS32r2 
hardware, the latter with regular MIPS and MIPS16 test configurations.  
Detailed logs were examined for correctness with respect to the tests 
affected as well.

 I request approval for the non-MIPS parts of the patch series; I can 
self-approve the MIPS bits, though obviously I'm happy to address any 
feedback.

 Company copyright assignment with FSF is currently being sorted.

  Maciej

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/7] testsuite: Factor out target feature test template
  2026-07-23 18:52 [PATCH 0/7] MIPS+testsuite: BLEZL stepping fix and associated test infrastructure Maciej W. Rozycki
@ 2026-07-23 18:52 ` Maciej W. Rozycki
  2026-07-23 18:52 ` [PATCH 2/7] PowerPC/testsuite: Reduce feature tests in terms of `allow_target_tests' Maciej W. Rozycki
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Maciej W. Rozycki @ 2026-07-23 18:52 UTC (permalink / raw)
  To: gdb-patches
  Cc: Jovan Dmitrovic, Djordje Todorovic, Milica Matic, Maciej W. Rozycki

From: Maciej W. Rozycki <macro@globalfoundries.com>

Implement `allow_target_tests' generic target feature test procedure, 
factoring out duplicate code from tests such as `allow_altivec_tests', 
`allow_power_isa_3_1_tests', `allow_vsx_tests', etc.
---
 gdb/testsuite/lib/gdb.exp |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

gdb-test-target-allow.diff
Index: binutils-gdb/gdb/testsuite/lib/gdb.exp
===================================================================
--- binutils-gdb.orig/gdb/testsuite/lib/gdb.exp
+++ binutils-gdb/gdb/testsuite/lib/gdb.exp
@@ -4285,6 +4285,50 @@ gdb_caching_proc libc_has_debug_info {}
     }
 }
 
+# Using name ME for reporting, check for target feature FEATURE, the
+# absence of which is supposed to get message MESSAGE produced by GDB.
+# Use source SRC and optional list of additional compiler flags FLAGS
+# for the check.  Make sure the source provided builds and then that
+# target hardware runs it.
+proc allow_target_tests { me feature message src { flags {} } } {
+    global srcdir subdir gdb_prompt inferior_exited_re
+
+    set compile_flags {}
+    foreach flag $flags {
+	require {have_compile_flag $flag}
+	lappend compile_flags "additional_flags=$flag"
+    }
+
+    if {![gdb_simple_compile $me $src executable $compile_flags]} {
+	return 0
+    }
+
+    gdb_exit
+    gdb_start
+    gdb_reinitialize_dir $srcdir/$subdir
+    gdb_load "$obj"
+    gdb_run_cmd
+    gdb_expect {
+	-re ".*${message}.*${gdb_prompt} $" {
+	    verbose -log "\n$me $feature not detected"
+	    set allow_target_tests 0
+	}
+	-re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
+	    verbose -log "\n$me: $feature detected"
+	    set allow_target_tests 1
+	}
+	default {
+	    warning "\n$me: default case taken"
+	    set allow_target_tests 0
+	}
+    }
+    gdb_exit
+    remote_file build delete $obj
+
+    verbose "$me: returning $allow_target_tests" 2
+    return $allow_target_tests
+}
+
 # Run a test on the target to see if it supports vmx hardware.  Return 1 if so,
 # 0 if it does not.  Based on 'check_vmx_hw_available' from the GCC testsuite.
 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/7] PowerPC/testsuite: Reduce feature tests in terms of `allow_target_tests'
  2026-07-23 18:52 [PATCH 0/7] MIPS+testsuite: BLEZL stepping fix and associated test infrastructure Maciej W. Rozycki
  2026-07-23 18:52 ` [PATCH 1/7] testsuite: Factor out target feature test template Maciej W. Rozycki
@ 2026-07-23 18:52 ` Maciej W. Rozycki
  2026-07-23 18:52 ` [PATCH 3/7] MIPS/testsuite: Verify MIPS I CPU branch stepping Maciej W. Rozycki
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Maciej W. Rozycki @ 2026-07-23 18:52 UTC (permalink / raw)
  To: gdb-patches
  Cc: Jovan Dmitrovic, Djordje Todorovic, Milica Matic, Maciej W. Rozycki

From: Maciej W. Rozycki <macro@globalfoundries.com>

Reimplement `allow_altivec_tests', `allow_power_isa_3_1_tests', and 
`allow_vsx_tests' in terms of `allow_target_tests', removing duplicate 
code.  No functional change.

Eventually it may make sense to migrate the resulting wrappers to 
testsuite/gdb.arch/ so as to declutter generic test framework from 
target-specific stuff.
---
 gdb/testsuite/lib/gdb.exp |  163 +++++++++-------------------------------------
 1 file changed, 35 insertions(+), 128 deletions(-)

gdb-powerpc-test-target-allow.diff
Index: binutils-gdb/gdb/testsuite/lib/gdb.exp
===================================================================
--- binutils-gdb.orig/gdb/testsuite/lib/gdb.exp
+++ binutils-gdb/gdb/testsuite/lib/gdb.exp
@@ -4333,8 +4333,6 @@ proc allow_target_tests { me feature mes
 # 0 if it does not.  Based on 'check_vmx_hw_available' from the GCC testsuite.
 
 gdb_caching_proc allow_altivec_tests {} {
-    global srcdir subdir gdb_prompt inferior_exited_re
-
     set me "allow_altivec_tests"
 
     # Some simulators are known to not support VMX instructions.
@@ -4350,110 +4348,47 @@ gdb_caching_proc allow_altivec_tests {}
 
     # Make sure we have a compiler that understands altivec.
     if {[test_compiler_info gcc*]} {
-	set compile_flags "additional_flags=-maltivec"
+	set flags "-maltivec"
     } elseif {[test_compiler_info xlc*]} {
-	set compile_flags "additional_flags=-qaltivec"
+	set flags "-qaltivec"
     } else {
 	verbose "Could not compile with altivec support, returning 0" 2
 	return 0
     }
 
     # Compile a test program containing VMX instructions.
-    set src {
-	int main() {
-	    #ifdef __MACH__
-	    asm volatile ("vor v0,v0,v0");
-	    #else
-	    asm volatile ("vor 0,0,0");
-	    #endif
-	    return 0;
-	}
-    }
-    if {![gdb_simple_compile $me $src executable $compile_flags]} {
-	return 0
-    }
-
-    # Compilation succeeded so now run it via gdb.
-
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load "$obj"
-    gdb_run_cmd
-    gdb_expect {
-	-re ".*Illegal instruction.*${gdb_prompt} $" {
-	    verbose -log "\n$me altivec hardware not detected"
-	    set allow_vmx_tests 0
-	}
-	-re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
-	    verbose -log "\n$me: altivec hardware detected"
-	    set allow_vmx_tests 1
-	}
-	default {
-	  warning "\n$me: default case taken"
-	    set allow_vmx_tests 0
-	}
-    }
-    gdb_exit
-    remote_file build delete $obj
-
-    verbose "$me:  returning $allow_vmx_tests" 2
-    return $allow_vmx_tests
+    return [allow_target_tests $me "altivec hardware" "Illegal instruction" \
+	{
+	    int main() {
+		#ifdef __MACH__
+		asm volatile ("vor v0,v0,v0");
+		#else
+		asm volatile ("vor 0,0,0");
+		#endif
+		return 0;
+	    }
+	} \
+	$flags]
 }
 
 # Run a test on the power target to see if it supports ISA 3.1 instructions
 gdb_caching_proc allow_power_isa_3_1_tests {} {
-    global srcdir subdir gdb_prompt inferior_exited_re
-
-    set me "allow_power_isa_3_1_tests"
-
     # Compile a test program containing ISA 3.1 instructions.
-    set src {
-	int main() {
-	asm volatile ("pnop"); // marker
+    return [allow_target_tests "allow_power_isa_3_1_tests" \
+	"Power ISA 3.1 hardware" "Illegal instruction" \
+	{
+	    int main() {
+		asm volatile ("pnop"); // marker
 		asm volatile ("nop");
 		return 0;
 	    }
-	}
-
-    if {![gdb_simple_compile $me $src executable ]} {
-	return 0
-    }
-
-    # No error message, compilation succeeded so now run it via gdb.
-
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load "$obj"
-    gdb_run_cmd
-    gdb_expect {
-	-re ".*Illegal instruction.*${gdb_prompt} $" {
-	    verbose -log "\n$me Power ISA 3.1 hardware not detected"
-	    set allow_power_isa_3_1_tests 0
-	}
-	-re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
-	    verbose -log "\n$me: Power ISA 3.1 hardware detected"
-	    set allow_power_isa_3_1_tests 1
-	}
-	default {
-	    warning "\n$me: default case taken"
-	    set allow_power_isa_3_1_tests 0
-	}
-    }
-    gdb_exit
-    remote_file build delete $obj
-
-    verbose "$me:  returning $allow_power_isa_3_1_tests" 2
-    return $allow_power_isa_3_1_tests
+	}]
 }
 
 # Run a test on the target to see if it supports vmx hardware.  Return 1 if so,
 # 0 if it does not.  Based on 'check_vmx_hw_available' from the GCC testsuite.
 
 gdb_caching_proc allow_vsx_tests {} {
-    global srcdir subdir gdb_prompt inferior_exited_re
-
     set me "allow_vsx_tests"
 
     # Some simulators are known to not support Altivec instructions, so
@@ -4465,56 +4400,28 @@ gdb_caching_proc allow_vsx_tests {} {
 
     # Make sure we have a compiler that understands altivec.
     if {[test_compiler_info gcc*]} {
-	set compile_flags "additional_flags=-mvsx"
+	set flags "-mvsx"
     } elseif {[test_compiler_info xlc*]} {
-	set compile_flags "additional_flags=-qasm=gcc"
+	set flags "-qasm=gcc"
     } else {
 	verbose "Could not compile with vsx support, returning 0" 2
 	return 0
     }
 
     # Compile a test program containing VSX instructions.
-    set src {
-	int main() {
-	    double a[2] = { 1.0, 2.0 };
-	    #ifdef __MACH__
-	    asm volatile ("lxvd2x v0,v0,%[addr]" : : [addr] "r" (a));
-	    #else
-	    asm volatile ("lxvd2x 0,0,%[addr]" : : [addr] "r" (a));
-	    #endif
-	    return 0;
-	}
-    }
-    if {![gdb_simple_compile $me $src executable $compile_flags]} {
-	return 0
-    }
-
-    # No error message, compilation succeeded so now run it via gdb.
-
-    gdb_exit
-    gdb_start
-    gdb_reinitialize_dir $srcdir/$subdir
-    gdb_load "$obj"
-    gdb_run_cmd
-    gdb_expect {
-	-re ".*Illegal instruction.*${gdb_prompt} $" {
-	    verbose -log "\n$me VSX hardware not detected"
-	    set allow_vsx_tests 0
-	}
-	-re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
-	    verbose -log "\n$me: VSX hardware detected"
-	    set allow_vsx_tests 1
-	}
-	default {
-	  warning "\n$me: default case taken"
-	    set allow_vsx_tests 0
-	}
-    }
-    gdb_exit
-    remote_file build delete $obj
-
-    verbose "$me:  returning $allow_vsx_tests" 2
-    return $allow_vsx_tests
+    return [allow_target_tests $me "VSX hardware" "Illegal instruction" \
+	{
+	    int main() {
+		double a[2] = { 1.0, 2.0 };
+		#ifdef __MACH__
+		asm volatile ("lxvd2x v0,v0,%[addr]" : : [addr] "r" (a));
+		#else
+		asm volatile ("lxvd2x 0,0,%[addr]" : : [addr] "r" (a));
+		#endif
+		return 0;
+	    }
+	} \
+	$flags]
 }
 
 # Run a test on the target to see if it supports TSX hardware.  Return 1 if so,

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/7] MIPS/testsuite: Verify MIPS I CPU branch stepping
  2026-07-23 18:52 [PATCH 0/7] MIPS+testsuite: BLEZL stepping fix and associated test infrastructure Maciej W. Rozycki
  2026-07-23 18:52 ` [PATCH 1/7] testsuite: Factor out target feature test template Maciej W. Rozycki
  2026-07-23 18:52 ` [PATCH 2/7] PowerPC/testsuite: Reduce feature tests in terms of `allow_target_tests' Maciej W. Rozycki
@ 2026-07-23 18:52 ` Maciej W. Rozycki
  2026-07-23 18:53 ` [PATCH 4/7] MIPS: Correct BLEZL single-stepping Maciej W. Rozycki
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Maciej W. Rozycki @ 2026-07-23 18:52 UTC (permalink / raw)
  To: gdb-patches
  Cc: Jovan Dmitrovic, Djordje Todorovic, Milica Matic, Maciej W. Rozycki

From: Maciej W. Rozycki <macro@globalfoundries.com>

Verify that breakpoints are correctly placed via `mips32_next_pc' while 
single-stepping through MIPS I CPU branches.

The idea behind these test cases is that if a branch is misinterpreted 
by the stepping code, then the breakpoint will be placed at the wrong 
place, usually at the branch destination rather than immediately beyond 
the delay slot or vice versa.  In the former case a step will be missed 
over the extra NOP placed beyond the delay slot and therefore from the 
count and in the latter case the single-stepping breakpoint will be 
missed altogether, letting code run through to the end of the intended 
stepping range.  In either case the stepping counter will not reach 0 at 
conclusion, causing the test case to fail.

The target feature tests for these test cases have been written somewhat 
overly cautiously, for example BLTZL is never a macro, so `.set nomacro' 
doesn't really guard against anything.  This is however harmless while 
making the feature tests more uniform.

Co-Authored-By: Andrew Bennett <andrew.bennett@imgtec.com>
Co-Authored-By: Matthew Fortune <matthew.fortune@mips.com>
Co-Authored-By: Faraz Shahbazker <fshahbazker@wavecomp.com>
Co-Authored-By: Milica Matic <milica.matic@htecgroup.com>
Co-Authored-By: Jovan Dmitrović <jovan.dmitrovic@htecgroup.com>
Approved-by: Maciej W. Rozycki <macro@orcam.me.uk>
---
 gdb/testsuite/gdb.arch/mips-allow.exp.tcl |   61 ++++++++++++++++++++++
 gdb/testsuite/gdb.arch/mips-stepi.exp.tcl |   78 +++++++++++++++++++++++++++++
 gdb/testsuite/gdb.arch/mips1-bal.c        |   70 ++++++++++++++++++++++++++
 gdb/testsuite/gdb.arch/mips1-bal.exp      |   30 +++++++++++
 gdb/testsuite/gdb.arch/mips1-branch.c     |   80 ++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.arch/mips1-branch.exp   |   30 +++++++++++
 6 files changed, 349 insertions(+)

gdb-mips1-next-pc-test.diff
Index: binutils-gdb/gdb/testsuite/gdb.arch/mips-allow.exp.tcl
===================================================================
--- /dev/null
+++ binutils-gdb/gdb/testsuite/gdb.arch/mips-allow.exp.tcl
@@ -0,0 +1,61 @@
+# Copyright (C) 2026 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/>.
+
+# Feature availability check helpers for MIPS tests.
+
+# Check for MIPS I branch support.  These instructions may be absent,
+# such as with MIPS16 compilations.  Make sure an actual BLTZ machine
+# instruction is produced and no macro expanded.
+proc allow_mips1_branch_tests {} {
+    return [allow_target_tests "allow_mips1_branch_tests" \
+	"MIPS I branch support" "Illegal instruction" \
+	    {
+		int main() {
+		    asm volatile (
+			".set	push\n\t"
+			".set	noreorder\n\t"
+			".set	nomacro\n\t"
+			"bltz	$0, 0f\n\t"
+			" nop\n"
+			"0:\n\t"
+			".set	pop\n");
+		    return 0;
+		}
+	    } \
+	{-Wa,-fatal-warnings -mno-mips16 -minterlink-compressed}]
+}
+
+# Check for MIPS I branch-and-link support.  These instructions may be
+# absent, such as with MIPSr6, or MIPS16 compilations.  Make sure an
+# actual BLTZAL machine instruction is produced and no macro expanded.
+proc allow_mips1_bal_tests {} {
+    return [allow_target_tests "allow_mips1_bal_tests" \
+	"MIPS I branch-and-link support" "Illegal instruction" \
+	    {
+		int main() {
+		    asm volatile (
+			".set	push\n\t"
+			".set	noreorder\n\t"
+			".set	nomacro\n\t"
+			"bltzal	$4, 0f\n\t"
+			" nop\n"
+			"0:\n\t"
+			".set	pop\n"
+			: : : "$31");
+		    return 0;
+		}
+	    } \
+	{-Wa,-fatal-warnings -mno-mips16 -minterlink-compressed}]
+}
Index: binutils-gdb/gdb/testsuite/gdb.arch/mips-stepi.exp.tcl
===================================================================
--- /dev/null
+++ binutils-gdb/gdb/testsuite/gdb.arch/mips-stepi.exp.tcl
@@ -0,0 +1,78 @@
+# Copyright (C) 2026 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/>.
+
+# Template for MIPS single-stepping tests.
+
+# Send `stepi' to gdb until inferior hits a breakpoint, starting with
+# ERR (which is a program variable) set to STEPS and decrementing it
+# with each step.  Use MESSAGE for the test result.
+proc stepi { steps message } {
+    global gdb_prompt
+
+    set timeout [get_largest_timeout]
+    set start [timestamp]
+
+    gdb_test_no_output -nopass "set err = $steps"
+    while { [timestamp] - $start < $steps * $timeout } {
+	gdb_test_multiple "stepi" "" {
+	    -re ".*Breakpoint.*$gdb_prompt" {
+		send_gdb "set err -= 1\n"
+		gdb_expect {
+		    -re "$gdb_prompt" { }
+		}
+		pass $message
+		return 1
+	    }
+	    -re ".*$gdb_prompt" {
+		send_gdb "set err -= 1\n"
+		gdb_expect {
+		    -re "$gdb_prompt" { }
+		}
+	    }
+	}
+    }
+    fail $message
+    return 0
+}
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
+	[lappend compile_flags debug]] } {
+    return
+}
+
+if { ![runto_main] } {
+    return
+}
+
+# Put breakpoints at the boundaries of the stepping range.
+foreach place [list step_start step_stop] {
+    if {![gdb_breakpoint "$place"]} {
+	unresolved "couldn't put breakpoint at $place"
+	return
+    }
+}
+
+# Advance to the beginning of the range.
+gdb_test "continue" ".*Breakpoint.*" "continue to step_start"
+
+# Make it easier to match results against expectations in the case of failures.
+gdb_test "info registers" ".*"
+gdb_test "display /i \$pc" ".*"
+
+# Step through to the end of the range.
+stepi $steps "step through to step_stop"
+
+# And run to completion to retrieve the result.
+gdb_test "continue" ".*exited normally.*" "continue to completion"
Index: binutils-gdb/gdb/testsuite/gdb.arch/mips1-bal.c
===================================================================
--- /dev/null
+++ binutils-gdb/gdb/testsuite/gdb.arch/mips1-bal.c
@@ -0,0 +1,70 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright (C) 2026 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 usefu,
+   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-stepping through MIPS I branch-and-link instructions.  */
+
+int
+test_mips1_bal (void)
+{
+  /* Make 'err' available to the debugger to track the number of single
+     steps executed.  Use `volatile' to prevent the variable from being
+     optimized away.  */
+  volatile int err = -1;
+
+  int any = 0x55aa;
+  int mone = -1;
+  int zero = 0;
+  int one = 1;
+
+  asm volatile (
+	".macro	b_test op, args:vararg\n\t"
+	"\\op	\\args, 0f\n\t"
+	" nop\n\t"
+	"nop\n"
+	"0:\n\t"
+	".endm\n\t"
+
+	".set	push\n\t"
+	".set	noreorder\n\t"
+	".globl	step_start\n\t"
+	".type	step_start, @function\n"
+	"step_start:\n\t"			/* Units: steps.  */
+	"nop\n\t"				/* NOP:       1s  */
+	"b_test	bltzal, %[mone]\n\t"		/* Taken:     1s  */
+	"b_test	bltzal, %[zero]\n\t"		/* Not taken: 2s  */
+	"b_test	bltzal, %[one]\n\t"		/* Not taken: 2s  */
+	"b_test	bgezal, %[mone]\n\t"		/* Not taken: 2s  */
+	"b_test	bgezal, %[zero]\n\t"		/* Taken:     1s  */
+	"b_test	bgezal, %[one]\n\t"		/* Taken:     1s  */
+	"nop\n\t"				/* NOP:       1s  */
+	".globl	step_stop\n\t"			/* Total:    11s  */
+	".type	step_stop, @function\n"
+	"step_stop:\n\t"
+	".set pop\n"
+	:
+	: [mone] "r" (mone), [zero] "r" (zero), [one] "r" (one),
+	  [any] "r" (any)
+	: "$31");
+
+  return err;
+}
+
+int
+main (void)
+{
+  return test_mips1_bal ();
+}
Index: binutils-gdb/gdb/testsuite/gdb.arch/mips1-bal.exp
===================================================================
--- /dev/null
+++ binutils-gdb/gdb/testsuite/gdb.arch/mips1-bal.exp
@@ -0,0 +1,30 @@
+# Copyright (C) 2026 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 single-stepping through MIPS I branch-and-link instructions.
+
+require {istarget "mips*-*-*"}
+
+source $srcdir/$subdir/mips-allow.exp.tcl
+
+require allow_mips1_bal_tests
+
+standard_testfile
+
+set steps 11
+foreach flag {-mno-mips16 -minterlink-compressed} {
+    lappend compile_flags "additional_flags=$flag"
+}
+source $srcdir/$subdir/mips-stepi.exp.tcl
Index: binutils-gdb/gdb/testsuite/gdb.arch/mips1-branch.c
===================================================================
--- /dev/null
+++ binutils-gdb/gdb/testsuite/gdb.arch/mips1-branch.c
@@ -0,0 +1,80 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright (C) 2026 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 usefu,
+   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-stepping through MIPS I branch instructions.  */
+
+int
+test_mips1_branch (void)
+{
+  /* Make 'err' available to the debugger to track the number of single
+     steps executed.  Use `volatile' to prevent the variable from being
+     optimized away.  */
+  volatile int err = -1;
+
+  int any = 0x55aa;
+  int mone = -1;
+  int zero = 0;
+  int one = 1;
+
+  asm volatile (
+	".macro	b_test op, args:vararg\n\t"
+	"\\op	\\args, 0f\n\t"
+	" nop\n\t"
+	"nop\n"
+	"0:\n\t"
+	".endm\n\t"
+
+	".set	push\n\t"
+	".set	noreorder\n\t"
+	".globl	step_start\n\t"
+	".type	step_start, @function\n"
+	"step_start:\n\t"			/* Units: steps.  */
+	"nop\n\t"				/* NOP:       1s  */
+	"b_test	beq, %[any], %[any]\n\t"	/* Taken:     1s  */
+	"b_test	beq, %[any], %[one]\n\t"	/* Not taken: 2s  */
+	"b_test	bne, %[any], %[any]\n\t"	/* Not taken: 2s  */
+	"b_test	bne, %[any], %[one]\n\t"	/* Taken:     1s  */
+	"b_test	bltz, %[mone]\n\t"		/* Taken:     1s  */
+	"b_test	bltz, %[zero]\n\t"		/* Not taken: 2s  */
+	"b_test	bltz, %[one]\n\t"		/* Not taken: 2s  */
+	"b_test	blez, %[mone]\n\t"		/* Taken:     1s  */
+	"b_test	blez, %[zero]\n\t"		/* Taken:     1s  */
+	"b_test	blez, %[one]\n\t"		/* Not taken: 2s  */
+	"b_test	bgez, %[mone]\n\t"		/* Not taken: 2s  */
+	"b_test	bgez, %[zero]\n\t"		/* Taken:     1s  */
+	"b_test	bgez, %[one]\n\t"		/* Taken:     1s  */
+	"b_test	bgtz, %[mone]\n\t"		/* Not taken: 2s  */
+	"b_test	bgtz, %[zero]\n\t"		/* Not taken: 2s  */
+	"b_test	bgtz, %[one]\n\t"		/* Taken:     1s  */
+	"nop\n\t"				/* NOP:       1s  */
+	".globl	step_stop\n\t"			/* Total:    26s  */
+	".type	step_stop, @function\n"
+	"step_stop:\n\t"
+	".set pop\n"
+	:
+	: [mone] "r" (mone), [zero] "r" (zero), [one] "r" (one),
+	  [any] "r" (any)
+	: "$31");
+
+  return err;
+}
+
+int
+main (void)
+{
+  return test_mips1_branch ();
+}
Index: binutils-gdb/gdb/testsuite/gdb.arch/mips1-branch.exp
===================================================================
--- /dev/null
+++ binutils-gdb/gdb/testsuite/gdb.arch/mips1-branch.exp
@@ -0,0 +1,30 @@
+# Copyright (C) 2026 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 single-stepping through MIPS I branch instructions.
+
+require {istarget "mips*-*-*"}
+
+source $srcdir/$subdir/mips-allow.exp.tcl
+
+require allow_mips1_branch_tests
+
+standard_testfile
+
+set steps 26
+foreach flag {-mno-mips16 -minterlink-compressed} {
+    lappend compile_flags "additional_flags=$flag"
+}
+source $srcdir/$subdir/mips-stepi.exp.tcl

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 4/7] MIPS: Correct BLEZL single-stepping
  2026-07-23 18:52 [PATCH 0/7] MIPS+testsuite: BLEZL stepping fix and associated test infrastructure Maciej W. Rozycki
                   ` (2 preceding siblings ...)
  2026-07-23 18:52 ` [PATCH 3/7] MIPS/testsuite: Verify MIPS I CPU branch stepping Maciej W. Rozycki
@ 2026-07-23 18:53 ` Maciej W. Rozycki
  2026-07-23 18:53 ` [PATCH 5/7] MIPS/testsuite: Verify MIPS II CPU branch stepping Maciej W. Rozycki
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Maciej W. Rozycki @ 2026-07-23 18:53 UTC (permalink / raw)
  To: gdb-patches
  Cc: Jovan Dmitrovic, Djordje Todorovic, Milica Matic, Maciej W. Rozycki

From: Maciej W. Rozycki <macro@globalfoundries.com>

Correct `mips32_next_pc' and also consider BLEZL taken for the value of 
zero held in the source register as per the instruction's semantics, 
restoring `less_zero_branch' label discarded with commit 54f1137d66be 
and actually matching the comment present in the source.

Verification will be provided with the test cases in the next change.

Co-Authored-By: Andrew Bennett <andrew.bennett@imgtec.com>
Co-Authored-By: Matthew Fortune <matthew.fortune@mips.com>
Co-Authored-By: Faraz Shahbazker <fshahbazker@wavecomp.com>
Co-Authored-By: Milica Matic <milica.matic@htecgroup.com>
Co-Authored-By: Jovan Dmitrović <jovan.dmitrovic@htecgroup.com>
Approved-by: Maciej W. Rozycki <macro@orcam.me.uk>
---
 gdb/mips-tdep.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

gdb-mips-next-pc-blezl.diff
Index: binutils-gdb/gdb/mips-tdep.c
===================================================================
--- binutils-gdb.orig/gdb/mips-tdep.c
+++ binutils-gdb/gdb/mips-tdep.c
@@ -1662,7 +1662,7 @@ mips32_next_pc (struct regcache *regcach
 	    case 1:		/* BNEL */
 	      goto neq_branch;
 	    case 2:		/* BLEZL */
-	      goto less_branch;
+	      goto less_equal_branch;
 	    case 3:		/* BGTZL */
 	      goto greater_branch;
 	    default:
@@ -1751,7 +1751,6 @@ mips32_next_pc (struct regcache *regcach
 	      case 2:		/* BLTZL */
 	      case 16:		/* BLTZAL */
 	      case 18:		/* BLTZALL */
-	      less_branch:
 		if (regcache_raw_get_signed (regcache, itype_rs (inst)) < 0)
 		  pc += mips32_relative_offset (inst) + 4;
 		else
@@ -1817,6 +1816,7 @@ mips32_next_pc (struct regcache *regcach
 	    pc += 8;
 	  break;
 	case 6:		/* BLEZ, BLEZL */
+	less_equal_branch:
 	  if (regcache_raw_get_signed (regcache, itype_rs (inst)) <= 0)
 	    pc += mips32_relative_offset (inst) + 4;
 	  else

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 5/7] MIPS/testsuite: Verify MIPS II CPU branch stepping
  2026-07-23 18:52 [PATCH 0/7] MIPS+testsuite: BLEZL stepping fix and associated test infrastructure Maciej W. Rozycki
                   ` (3 preceding siblings ...)
  2026-07-23 18:53 ` [PATCH 4/7] MIPS: Correct BLEZL single-stepping Maciej W. Rozycki
@ 2026-07-23 18:53 ` Maciej W. Rozycki
  2026-07-23 18:53 ` [PATCH 6/7] MIPS/testsuite: Verify MIPS16 " Maciej W. Rozycki
  2026-07-23 18:53 ` [PATCH 7/7] MIPS: Reorder a reference to "BGTZ, BGTZL" in `mips32_next_pc' Maciej W. Rozycki
  6 siblings, 0 replies; 8+ messages in thread
From: Maciej W. Rozycki @ 2026-07-23 18:53 UTC (permalink / raw)
  To: gdb-patches
  Cc: Jovan Dmitrovic, Djordje Todorovic, Milica Matic, Maciej W. Rozycki

From: Maciej W. Rozycki <macro@globalfoundries.com>

Verify that breakpoints are correctly placed via `mips32_next_pc' while
single-stepping through MIPS II CPU branches.

Approved-by: Maciej W. Rozycki <macro@orcam.me.uk>
---
 gdb/testsuite/gdb.arch/mips-allow.exp.tcl |   25 ++++++++
 gdb/testsuite/gdb.arch/mips2-branch.c     |   86 ++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.arch/mips2-branch.exp   |   30 ++++++++++
 3 files changed, 141 insertions(+)

gdb-mips2-next-pc-test.diff
Index: binutils-gdb/gdb/testsuite/gdb.arch/mips-allow.exp.tcl
===================================================================
--- binutils-gdb.orig/gdb/testsuite/gdb.arch/mips-allow.exp.tcl
+++ binutils-gdb/gdb/testsuite/gdb.arch/mips-allow.exp.tcl
@@ -59,3 +59,28 @@ proc allow_mips1_bal_tests {} {
 	    } \
 	{-Wa,-fatal-warnings -mno-mips16 -minterlink-compressed}]
 }
+
+# Check for MIPS II branch-likely support.  These instructions may be
+# absent, such as with MIPS I, MIPSr6, or MIPS16 compilations, or only
+# supported as assembler macros, such as with microMIPS compilations.
+# Make sure an actual BEQL machine instruction is produced and no macro
+# expanded.
+proc allow_mips2_branch_tests {} {
+    return [allow_target_tests "allow_mips2_branch_tests" \
+	"MIPS II branch support" "Illegal instruction" \
+	    {
+		int main() {
+		    asm volatile (
+			".set	push\n\t"
+			".set	noreorder\n\t"
+			".set	nomacro\n\t"
+			"beql	$0, $0, 0f\n\t"
+			" nop\n"
+			"0:\n\t"
+			".set	pop\n");
+		    return 0;
+		}
+	    } \
+	{-Wa,-fatal-warnings -mno-mips16 -mno-micromips
+	    -minterlink-compressed}]
+}
Index: binutils-gdb/gdb/testsuite/gdb.arch/mips2-branch.c
===================================================================
--- /dev/null
+++ binutils-gdb/gdb/testsuite/gdb.arch/mips2-branch.c
@@ -0,0 +1,86 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright (C) 2026 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 single-stepping through MIPS II branch instructions.  */
+
+int
+test_mips2_branch (void)
+{
+  /* Make 'err' available to the debugger to track the number of single
+     steps executed.  Use `volatile' to prevent the variable from being
+     optimized away.  */
+  volatile int err = -1;
+
+  int any = 0x55aa;
+  int mone = -1;
+  int zero = 0;
+  int one = 1;
+
+  asm volatile (
+	".macro	b_test op, args:vararg\n\t"
+	"\\op	\\args, 0f\n\t"
+	" nop\n\t"
+	"nop\n"
+	"0:\n\t"
+	".endm\n\t"
+
+	".set	push\n\t"
+	".set	noreorder\n\t"
+	".globl	step_start\n\t"
+	".type	step_start, @function\n"
+	"step_start:\n\t"			/* Units: steps.  */
+	"nop\n\t"				/* NOP:       1s  */
+	"b_test	beql, %[any], %[any]\n\t"	/* Taken:     1s  */
+	"b_test	beql, %[any], %[one]\n\t"	/* Not taken: 2s  */
+	"b_test	bnel, %[any], %[any]\n\t"	/* Not taken: 2s  */
+	"b_test	bnel, %[any], %[one]\n\t"	/* Taken:     1s  */
+	"b_test	bltzl, %[mone]\n\t"		/* Taken:     1s  */
+	"b_test	bltzl, %[zero]\n\t"		/* Not taken: 2s  */
+	"b_test	bltzl, %[one]\n\t"		/* Not taken: 2s  */
+	"b_test	blezl, %[mone]\n\t"		/* Taken:     1s  */
+	"b_test	blezl, %[zero]\n\t"		/* Taken:     1s  */
+	"b_test	blezl, %[one]\n\t"		/* Not taken: 2s  */
+	"b_test	bgezl, %[mone]\n\t"		/* Not taken: 2s  */
+	"b_test	bgezl, %[zero]\n\t"		/* Taken:     1s  */
+	"b_test	bgezl, %[one]\n\t"		/* Taken:     1s  */
+	"b_test	bgtzl, %[mone]\n\t"		/* Not taken: 2s  */
+	"b_test	bgtzl, %[zero]\n\t"		/* Not taken: 2s  */
+	"b_test	bgtzl, %[one]\n\t"		/* Taken:     1s  */
+	"b_test	bltzall, %[mone]\n\t"		/* Taken:     1s  */
+	"b_test	bltzall, %[zero]\n\t"		/* Not taken: 2s  */
+	"b_test	bltzall, %[one]\n\t"		/* Not taken: 2s  */
+	"b_test	bgezall, %[mone]\n\t"		/* Not taken: 2s  */
+	"b_test	bgezall, %[zero]\n\t"		/* Taken:     1s  */
+	"b_test	bgezall, %[one]\n\t"		/* Taken:     1s  */
+	"nop\n\t"				/* NOP:       1s  */
+	".globl	step_stop\n\t"			/* Total:    35s  */
+	".type	step_stop, @function\n"
+	"step_stop:\n\t"
+	".set pop\n"
+	:
+	: [mone] "r" (mone), [zero] "r" (zero), [one] "r" (one),
+	  [any] "r" (any)
+	: "$31");
+
+  return err;
+}
+
+int
+main (void)
+{
+  return test_mips2_branch ();
+}
Index: binutils-gdb/gdb/testsuite/gdb.arch/mips2-branch.exp
===================================================================
--- /dev/null
+++ binutils-gdb/gdb/testsuite/gdb.arch/mips2-branch.exp
@@ -0,0 +1,30 @@
+# Copyright (C) 2026 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 single-stepping through MIPS II branch instructions.
+
+require {istarget "mips*-*-*"}
+
+source $srcdir/$subdir/mips-allow.exp.tcl
+
+require allow_mips2_branch_tests
+
+standard_testfile
+
+set steps 35
+foreach flag {-mno-mips16 -mno-micromips -minterlink-compressed} {
+    lappend compile_flags "additional_flags=$flag"
+}
+source $srcdir/$subdir/mips-stepi.exp.tcl

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 6/7] MIPS/testsuite: Verify MIPS16 branch stepping
  2026-07-23 18:52 [PATCH 0/7] MIPS+testsuite: BLEZL stepping fix and associated test infrastructure Maciej W. Rozycki
                   ` (4 preceding siblings ...)
  2026-07-23 18:53 ` [PATCH 5/7] MIPS/testsuite: Verify MIPS II CPU branch stepping Maciej W. Rozycki
@ 2026-07-23 18:53 ` Maciej W. Rozycki
  2026-07-23 18:53 ` [PATCH 7/7] MIPS: Reorder a reference to "BGTZ, BGTZL" in `mips32_next_pc' Maciej W. Rozycki
  6 siblings, 0 replies; 8+ messages in thread
From: Maciej W. Rozycki @ 2026-07-23 18:53 UTC (permalink / raw)
  To: gdb-patches
  Cc: Jovan Dmitrovic, Djordje Todorovic, Milica Matic, Maciej W. Rozycki

From: Maciej W. Rozycki <macro@globalfoundries.com>

Verify that breakpoints are correctly placed via `mips16_next_pc' while 
single-stepping through MIPS16 branches.  Explicit instruction suffixes 
are used to get both regular and extended instruction forms covered, and 
`-Wa,-W' GAS option is used to quiesce warnings as the tool is keen to 
complain about the extended form where requested unnecessarily.

Approved-by: Maciej W. Rozycki <macro@orcam.me.uk>
---
 gdb/testsuite/gdb.arch/mips-allow.exp.tcl |   21 +++++++
 gdb/testsuite/gdb.arch/mips16-branch.c    |   82 ++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.arch/mips16-branch.exp  |   30 ++++++++++
 3 files changed, 133 insertions(+)

gdb-mips16-next-pc-test.diff
Index: binutils-gdb/gdb/testsuite/gdb.arch/mips-allow.exp.tcl
===================================================================
--- binutils-gdb.orig/gdb/testsuite/gdb.arch/mips-allow.exp.tcl
+++ binutils-gdb/gdb/testsuite/gdb.arch/mips-allow.exp.tcl
@@ -84,3 +84,24 @@ proc allow_mips2_branch_tests {} {
 	{-Wa,-fatal-warnings -mno-mips16 -mno-micromips
 	    -minterlink-compressed}]
 }
+
+# Check for MIPS16 branch support.  These instructions may be absent,
+# such as with microMIPS compilations.  Make sure an actual BTEQZ
+# machine instruction is produced and no macro expanded.
+proc allow_mips16_branch_tests {} {
+    return [allow_target_tests "allow_mips16_branch_tests" \
+	"MIPS16 branch support" "(:?Bus error|Illegal instruction)" \
+	    {
+		int main() {
+		    asm volatile (
+			".set	push\n\t"
+			".set	noreorder\n\t"
+			".set	nomacro\n\t"
+			"bteqz	0f\n\t"
+			"0:\n\t"
+			".set	pop\n");
+		    return 0;
+		}
+	    } \
+	{-Wa,-fatal-warnings -mno-micromips -mips16 -minterlink-compressed}]
+}
Index: binutils-gdb/gdb/testsuite/gdb.arch/mips16-branch.c
===================================================================
--- /dev/null
+++ binutils-gdb/gdb/testsuite/gdb.arch/mips16-branch.c
@@ -0,0 +1,82 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+   Copyright (C) 2026 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 usefu,
+   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-stepping through MIPS I branch instructions.  */
+
+int
+test_mips16_branch (void)
+{
+  /* Make 'err' available to the debugger to track the number of single
+     steps executed.  Use `volatile' to prevent the variable from being
+     optimized away.  */
+  volatile int err = -1;
+
+  int any = 0x55aa;
+  int mone = -1;
+  int zero = 0;
+  int one = 1;
+
+  asm volatile (
+	".macro	b_test op, args:vararg\n\t"
+	".ifb	\\args\n\t"
+	"\\op	0f\n\t"
+	".else\n\t"
+	"\\op	\\args, 0f\n\t"
+	".endif\n\t"
+	"nop\n"
+	"0:\n\t"
+	".endm\n\t"
+
+	".set	push\n\t"
+	".set	noreorder\n\t"
+	".globl	step_start\n\t"
+	".type	step_start, @function\n"
+	"step_start:\n\t"			/* Units: steps.  */
+	"nop\n\t"				/* NOP:       1s  */
+	"b_test	beqz.t %[zero]\n\t"		/* Taken:     1s  */
+	"b_test	beqz.e %[zero]\n\t"		/* Taken:     1s  */
+	"b_test	beqz.t %[any]\n\t"		/* Not taken: 2s  */
+	"b_test	beqz.e %[any]\n\t"		/* Not taken: 2s  */
+	"b_test	bnez.t %[zero]\n\t"		/* Not taken: 2s  */
+	"b_test	bnez.e %[zero]\n\t"		/* Not taken: 2s  */
+	"b_test	bnez.t %[any]\n\t"		/* Taken:     1s  */
+	"b_test	bnez.e %[any]\n\t"		/* Taken:     1s  */
+	"b_test	bteqz.t\n\t"			/* Taken:     1s  */
+	"b_test	bteqz.e\n\t"			/* Taken:     1s  */
+	"b_test	btnez.t\n\t"			/* Not taken: 2s  */
+	"b_test	btnez.e\n\t"			/* Not taken: 2s  */
+	"move	%[t], %[any]\n\t"		/* MOVE:      1s  */
+	"b_test	bteqz.t\n\t"			/* Not taken: 2s  */
+	"b_test	bteqz.e\n\t"			/* Not taken: 2s  */
+	"b_test	btnez.t\n\t"			/* Taken:     1s  */
+	"b_test	btnez.e\n\t"			/* Taken:     1s  */
+	"nop\n\t"				/* NOP:       1s  */
+	".globl	step_stop\n\t"			/* Total:    27s  */
+	".type	step_stop, @function\n"
+	"step_stop:\n\t"
+	".set pop\n"
+	: [t] "+t" (zero)
+	: [zero] "u" (zero), [any] "u" (any));
+
+  return err;
+}
+
+int
+main (void)
+{
+  return test_mips16_branch ();
+}
Index: binutils-gdb/gdb/testsuite/gdb.arch/mips16-branch.exp
===================================================================
--- /dev/null
+++ binutils-gdb/gdb/testsuite/gdb.arch/mips16-branch.exp
@@ -0,0 +1,30 @@
+# Copyright (C) 2026 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 single-stepping through MIPS16 branch instructions.
+
+require {istarget "mips*-*-*"}
+
+source $srcdir/$subdir/mips-allow.exp.tcl
+
+require allow_mips16_branch_tests
+
+standard_testfile
+
+set steps 27
+foreach flag {-Wa,-W -mno-micromips -mips16 -minterlink-compressed} {
+    lappend compile_flags "additional_flags=$flag"
+}
+source $srcdir/$subdir/mips-stepi.exp.tcl

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 7/7] MIPS: Reorder a reference to "BGTZ, BGTZL" in `mips32_next_pc'
  2026-07-23 18:52 [PATCH 0/7] MIPS+testsuite: BLEZL stepping fix and associated test infrastructure Maciej W. Rozycki
                   ` (5 preceding siblings ...)
  2026-07-23 18:53 ` [PATCH 6/7] MIPS/testsuite: Verify MIPS16 " Maciej W. Rozycki
@ 2026-07-23 18:53 ` Maciej W. Rozycki
  6 siblings, 0 replies; 8+ messages in thread
From: Maciej W. Rozycki @ 2026-07-23 18:53 UTC (permalink / raw)
  To: gdb-patches
  Cc: Jovan Dmitrovic, Djordje Todorovic, Milica Matic, Maciej W. Rozycki

From: Maciej W. Rozycki <macro@globalfoundries.com>

Move a reference to "BGTZ, BGTZL" in `mips32_next_pc' to the leading 
case label as with the other instructions called out in the function.

Approved-by: Maciej W. Rozycki <macro@orcam.me.uk>
---
 gdb/mips-tdep.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

gdb-mips-next-pc-bgtz-comment.diff
Index: binutils-gdb/gdb/mips-tdep.c
===================================================================
--- binutils-gdb.orig/gdb/mips-tdep.c
+++ binutils-gdb/gdb/mips-tdep.c
@@ -1822,9 +1822,9 @@ mips32_next_pc (struct regcache *regcach
 	  else
 	    pc += 8;
 	  break;
-	case 7:
+	case 7:		/* BGTZ, BGTZL */
 	default:
-	greater_branch:	/* BGTZ, BGTZL */
+	greater_branch:
 	  if (regcache_raw_get_signed (regcache, itype_rs (inst)) > 0)
 	    pc += mips32_relative_offset (inst) + 4;
 	  else

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-07-23 18:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-23 18:52 [PATCH 0/7] MIPS+testsuite: BLEZL stepping fix and associated test infrastructure Maciej W. Rozycki
2026-07-23 18:52 ` [PATCH 1/7] testsuite: Factor out target feature test template Maciej W. Rozycki
2026-07-23 18:52 ` [PATCH 2/7] PowerPC/testsuite: Reduce feature tests in terms of `allow_target_tests' Maciej W. Rozycki
2026-07-23 18:52 ` [PATCH 3/7] MIPS/testsuite: Verify MIPS I CPU branch stepping Maciej W. Rozycki
2026-07-23 18:53 ` [PATCH 4/7] MIPS: Correct BLEZL single-stepping Maciej W. Rozycki
2026-07-23 18:53 ` [PATCH 5/7] MIPS/testsuite: Verify MIPS II CPU branch stepping Maciej W. Rozycki
2026-07-23 18:53 ` [PATCH 6/7] MIPS/testsuite: Verify MIPS16 " Maciej W. Rozycki
2026-07-23 18:53 ` [PATCH 7/7] MIPS: Reorder a reference to "BGTZ, BGTZL" in `mips32_next_pc' Maciej W. Rozycki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox