From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MbDsGR0k32p6xxsAWB0awg (envelope-from ) for ; Mon, 26 Oct 2026 05:57:49 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=IQFk6KZr; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 5DF7A378002; Mon, 26 Oct 2026 05:57:49 -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.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 90DB1378003 for ; Mon, 26 Oct 2026 05:57:43 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3C58E4BA2E25 for ; Mon, 26 Oct 2026 09:57:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C58E4BA2E25 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=IQFk6KZr Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id D3EBB4BA23D8 for ; Mon, 26 Oct 2026 09:57:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D3EBB4BA23D8 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D3EBB4BA23D8 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::435 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793008630; cv=none; b=vj+prGAVnOgt7x6ZvlreTAzAlrBGJvPJYwo+Mxk9sRUglpn6I8cX9PeAF/TAdQY/cxv96KKc+28GJCwAl6/tybKVKaTXUQIywkvDygqJWuMHPf/EG3M3opchfgyE3HxXDI9hNg/8uEGxoIM/A9tO3+uRrP0SrfXr5mta5zfk6ro= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793008630; c=relaxed/simple; bh=nef4aRRMWzhoCFysBls/BKIsehcB5T+xSTBv0vKQ/Ys=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jHZjYcuOiTzn3HD98OHem4RJhAdXc6F6o4sz1Vs9UBoMYlwVq0wKBkDkXmJlcblp2kJ42FGgZ8XPylWh0aE++f6oKATSzG+b8UqYyeNbfbXY0NTX0uoNBeDaHzVOJsI8EmuWZZu4w6aarkroamJF5FNrCPDvDdC4uHbMYub2tu8= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=IQFk6KZr DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3EBB4BA23D8 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-48e1d0e5dafso2586206f8f.1 for ; Mon, 26 Oct 2026 02:57:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1793008629; x=1793613429; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Yg+VuAIlisqkdHBYLoFrbsWtP/aUJRlittpRR3Diczc=; b=IQFk6KZrNB8afEg4vOyj+zFpU+eM1sQkhefDfC3UqlIqUeLBNNlMnDuOpxkyKb6JoY yjPtfSSvi/4gmlJhMlD9SP5W766O1aOmS6LlhHWM7BpcZrANutvmPVWOwe5p9Y046bYG 79GMq9Cmkk5Sc3QAkRXFL1fSaJ3CyD39mgxGviopknBtHGOdIZYTKBJpb8uKtBPHWYbO syCc/xJslI8HXpIa2qNpTWrCamu30rNTODlEi5GS91OxMdQiXcqc2TSSxtF+bgmqQ+A8 lGviC90kowDCyf2Sm3wPoP1/um9EWtnNVUMOLAUV9O3aiB833RJKS1dSWRw0bw3X+zOL oGTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793008629; x=1793613429; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Yg+VuAIlisqkdHBYLoFrbsWtP/aUJRlittpRR3Diczc=; b=NbbSMOYMp8tPKPFpfcvIjCcaSoORsAJItk6CH4K2vNSCotbgrYiY4BkiVs6T8dLV6l /dqGEkaDfYwELUmenit1Jmw1WFFh+iSkyg4jmHuMK76Kp0TcF44wjC++PbVvwJUztkbL pum89rdmtGZTGQaWNuwcuyz66WwwIdzaVdUPIjFcAXcMpmG/OHCHq4SKENWwL+Be4TNI MBqNL/9UM9mWsGWy1EI/SdEsRqwqZsP9rTtGnF/oG4mWk5dSwc78xdXEltku5P5vaqbd 7AYBCrFhTeAl4om060j2yGBm7WwX0XGFREKogU2wYYBVcakh97J9G1SXKPT/TI9RHkKT 9t+w== X-Gm-Message-State: AFq9FYIUUP1os58ugq3fEWzL2ZtaL4QUULoPJLKblCsT9fwiduI5SfO9 XZDRyHjT7HJ+ckNzWbVqKWTk78sPeWSNmHJ9AT9ZaaDSE48nmSmF55XM5dAsRG/ufhW64x3c2o8 = X-Gm-Gg: AYBFou1AwmtQzmUk0DmVBEelL/cm+JoxiO56Xf3hBHVTz4kCGeRqXcssShqjqgG8A+4 ErehlsDynSsfXrAbLOgtB57GZCcVH2ausGmpEOi7YG92qv77ZtplUrhtQijdHL+6umCKnLsZl2C ODt4gxJGq69+MyndxpXW7kqm3vFnHUKkSOlqB2xtiHdPD9K8pAIINDAfoWuZ1YS84rXclJIg2h7 pURYsav6ZrviC0CGSyX8YmmJBjzvlE2LPFzvKmo8WJJwa3w5TkCkN9VFFTF5xqyYPh2G9VGw3dq EYmzDtf3jjVZp46vw9Y0Ief3VK5kbZyWl3jxoaJ5dGnP2+HdeqNxB0ZP53H3wV+1QJA90APB+zb sfNpXc+XYSuCBdjQXCfpuP2OfGbQGcGRtvab73YeGoJyt+ju/qvs0Aeh8f9doKzFUquLJPJAsDu d5ZfGt8za3Ozv39NhupWWvjoAqcyGSoFxTsRzWT69moMNYyxV9BSoagWt95m4RNSjdYiy0d+1dI tqc738gTiqirpoEomFbuphD0Nrll4i1kOEbPySevVL2FqmEJnEYmv6/61Tt/91lraPli3/SpJh6 cdrmteJeNStfyQj/QJaLvcsOqUbiwyshssGcemmxAFwzN7DxYB9VfAiq9CwK91Zk7QcXsg1U X-Received: by 2002:a05:6000:240e:b0:48d:f4ef:62e7 with SMTP id ffacd0b85a97d-48e3eab73b1mr13856372f8f.0.1793008628641; Mon, 26 Oct 2026 02:57:08 -0700 (PDT) Received: from localhost.localdomain ([178.64.143.40]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48e3eb8f387sm15080682f8f.4.2026.10.26.02.57.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2026 02:57:08 -0700 (PDT) From: Farid Khaidari To: gdb-patches@sourceware.org Cc: Andrew Burgess , Palmer Dabbelt , Timur Golubovich , Kevin Buettner Subject: [PATCH v2 3/4] gdb/riscv: test the "arch=" disassembler option Date: Mon, 26 Oct 2026 12:56:45 +0300 Message-ID: <20261026095647.3035166-4-khaidari.fg@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261026095647.3035166-1-khaidari.fg@gmail.com> References: <20261022154417.235510-1-khaidari.fg@gmail.com> <20261026095647.3035166-1-khaidari.fg@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org The test puts vector instructions into an executable built for rv64gc. They disassemble as raw .insn words until "arch=" names an ISA with V. The check is repeated on a copy with the architecture attribute stripped. One "disassemble" command uses a single disassembler for the whole function, so the expected output covers more than the first instruction: an option lost after it would show there. Mapping symbols are left to objdump tests, since GDB cannot exercise them. Signed-off-by: Farid Khaidari --- .../gdb.arch/riscv-disasm-arch-option.c | 40 ++++++++++ .../gdb.arch/riscv-disasm-arch-option.exp | 80 +++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 gdb/testsuite/gdb.arch/riscv-disasm-arch-option.c create mode 100644 gdb/testsuite/gdb.arch/riscv-disasm-arch-option.exp diff --git a/gdb/testsuite/gdb.arch/riscv-disasm-arch-option.c b/gdb/testsuite/gdb.arch/riscv-disasm-arch-option.c new file mode 100644 index 00000000000..75857442b7e --- /dev/null +++ b/gdb/testsuite/gdb.arch/riscv-disasm-arch-option.c @@ -0,0 +1,40 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 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 . */ + +/* Plant the encodings of two vector instructions in an ordinary + function. The file is compiled without the vector extension, so the + ELF carries an rv64gc architecture attribute and the instructions + only decode once the disassembler is told about the vector extension + through the "arch=" option. ".insn" is used rather than the + mnemonics because assembling those would require the vector + extension, which would then appear in the architecture attribute of + the ELF and leave the option with nothing to prove. */ + +void +vector_insns (void) +{ + /* vsetvli t0,a0,e8,m1,ta,ma */ + asm volatile (".insn 4, 0x0c0572d7"); + /* vxor.vv v1,v2,v3 */ + asm volatile (".insn 4, 0x2e2180d7"); +} + +int +main (void) +{ + return 0; +} diff --git a/gdb/testsuite/gdb.arch/riscv-disasm-arch-option.exp b/gdb/testsuite/gdb.arch/riscv-disasm-arch-option.exp new file mode 100644 index 00000000000..2dd7a998eeb --- /dev/null +++ b/gdb/testsuite/gdb.arch/riscv-disasm-arch-option.exp @@ -0,0 +1,80 @@ +# Copyright 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 . + +# Check the "arch=" disassembler option against an executable. The +# option names the ISA to disassemble for, in place of the one the +# object records, so the test needs an object both with and without an +# architecture attribute. +# +# A single "disassemble" prints the whole function through one +# disassembler, so an ISA that survived only the first instruction would +# show up from the second on: the expected output names both. + +require {istarget "riscv64-*-*"} + +standard_testfile + +# Compile without the vector extension: the executable carries an rv64gc +# architecture attribute, and the vector instructions planted in it only +# decode once the disassembler is told about the vector extension. +set compile_flags {debug} +lappend compile_flags "additional_flags=-march=rv64gc" + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile \ + $compile_flags]} { + return -1 +} + +# The planted words decoded as vector instructions, and left raw. +set vector_re "vsetvli\[ \t\]+t0,a0,e8,m1,ta,ma.*vxor\\.vv\[ \t\]+v1,v2,v3.*" +set raw_re "\\.insn\[ \t\]+4, 0x0c0572d7.*" + +gdb_test "disassemble vector_insns" $raw_re \ + "vector instructions not decoded with the ISA of the object" + +gdb_test_no_output "set disassembler-options arch=rv64gcv" \ + "set the arch to one with vector" + +gdb_test "disassemble vector_insns" $vector_re \ + "arch= overrides the ISA of the object" + +# Clearing the option returns to the ISA of the object. +gdb_test_no_output "set disassembler-options" "clear disassembler options" + +gdb_test "disassemble vector_insns" $raw_re \ + "vector instructions not decoded after clearing the option" + +# An object that records no ISA is the case GDB supplies the option for +# on its own. Strip the attribute to get one that still has a symbol +# table, which a core file cannot stand in for. +set stripped ${testfile}-no-attributes +set objcopy [gdb_find_objcopy] + +if {[run_on_host "strip the architecture attribute" $objcopy \ + "--remove-section=.riscv.attributes $binfile \ + [standard_output_file $stripped]"]} { + return -1 +} + +clean_restart $stripped + +gdb_test "info symbol vector_insns" "vector_insns in section .*" \ + "the stripped binary still carries a symbol table" + +gdb_test_no_output "set disassembler-options arch=rv64gcv" \ + "set the arch on an object without an attribute" + +gdb_test "disassemble vector_insns" $vector_re \ + "vector instructions decoded with arch=rv64gcv" -- 2.43.0