From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SQ84KmdjYmqMVioAWB0awg (envelope-from ) for ; Thu, 23 Jul 2026 14:54:31 -0400 Received: by simark.ca (Postfix, from userid 112) id AAA2E1E09E; Thu, 23 Jul 2026 14:54:31 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 1BC341E033 for ; Thu, 23 Jul 2026 14:54:31 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DE43F4BA23D9 for ; Thu, 23 Jul 2026 18:54:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DE43F4BA23D9 Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by sourceware.org (Postfix) with ESMTP id 2D6794BA7999 for ; Thu, 23 Jul 2026 18:53:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2D6794BA7999 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=orcam.me.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=orcam.me.uk ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2D6794BA7999 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2001:4190:8020::34 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784832792; cv=none; b=td/djcaqbJ2cP5C2ir4CbGHRc5ggy2M6rc0/60oKvndP6efeY/pvrCG+5E3KpuwgT76gojswDHiwDddy1iYPXLP/EtRorOMx1Q7ardkrznBgPdl/QR/ErNnS0calPXKUyReiHnhrLZ53/lH9QIWRPfdTtLOQQ6+ZfwlmZvsZcOc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1784832792; c=relaxed/simple; bh=/VV1Mac/hokOKHiRUB7ZKV03mx8+sjayKiba8niGqog=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=PWo31WxlliOttnHz+zcJcmWqNC2G0Y94U084I/DYCfe6p0aj1FLoku6evmCobWqKezukrTTHR/eHRCHugyykk0RlMEHeCi40sPFvRWqNGe0ScjdZC4WUeHgR2Ay7xH/Oj3fwnAuo+yjUnmHWq0oTNGpI9Iy5Hhipp7fdpJHv8oY= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D6794BA7999 Received: by angie.orcam.me.uk (Postfix, from userid 500) id A102C9200BC; Thu, 23 Jul 2026 20:53:11 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 9A0A092009E; Thu, 23 Jul 2026 19:53:11 +0100 (BST) Date: Thu, 23 Jul 2026 19:53:11 +0100 (BST) From: "Maciej W. Rozycki" To: gdb-patches@sourceware.org cc: Jovan Dmitrovic , Djordje Todorovic , Milica Matic , "Maciej W. Rozycki" Subject: [PATCH 6/7] MIPS/testsuite: Verify MIPS16 branch stepping In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: "Maciej W. Rozycki" Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org From: Maciej W. Rozycki 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 --- 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 . */ + +/* 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 . + +# 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