From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id bwB5D92F5GoUnBMAWB0awg (envelope-from ) for ; Fri, 30 Oct 2026 07:56:13 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=lT05UDKo; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 2DC521E023; Fri, 30 Oct 2026 07:56:13 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.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 3BA7E1E023 for ; Fri, 30 Oct 2026 07:56:12 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6CE3F4BAE7C1 for ; Fri, 30 Oct 2026 11:56:11 +0000 (GMT) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) by sourceware.org (Postfix) with ESMTPS id 6B34D4BA903A for ; Fri, 30 Oct 2026 11:50:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B34D4BA903A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6B34D4BA903A Authentication-Results: sourceware.org; arc=none smtp.remote-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793361048; cv=none; b=We+fymOCfzEiKev52wGa2z+7DwQeUxTmigDSypWHq2ouh+8R3VukATVIHpyqWfdkRAdl8FA/aqVsD0QaiJlyirL4a9UpnF4F0zWB9GHiLLuoEZMX2IGH+TpFBuHFrwSXjBr0Td5nQDmfYxX2w4Ri3JVTIoizkPyysb07RllGLRg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793361048; c=relaxed/simple; bh=4sPoKoHEIzLz08E5jBkHmyESoHDVK7/hp+y9qR9Xkwo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=pqgiLW1z7ira3rRfVNE4RQaqaMUEUe8IcxTfGqMrQ4FHfjDB0sEsuyvDGhjSmxwxonrQSi/VkgVQMQ17sTANFVK5LanM/hLcfBcTRUEWagu+hR9i2pXmBWwP2udT/81jI0IMyRdOFs+RcY/+L2izIpdxBavZPXAg/bx5vI/1k9Q= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=lT05UDKo DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B34D4BA903A Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=lT05UDKo DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1793361048; x=1824897048; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4sPoKoHEIzLz08E5jBkHmyESoHDVK7/hp+y9qR9Xkwo=; b=lT05UDKoT9Ezn48htcBBsV+IeplkrFHWyYCvu5W2YraxkRjq0Gw882nH PkJsOJldEhi6aVkxyGyjMXjkNhGcXHNZ9TcKLcv74I9aCGRnXAXi6Ypsu XR7Lce9ug5Hi30DfHHCdKm4Ju0xUcXwEEwoKXsX0Cgn84h3O2hTol2SUu Tl5g5CfylSQcu03lQqTlvAkoZZO+19745ygcKa3x5oCLN4JiErmHDeyB/ 87sjmehrWJHadxLXdL0jmik22EbB4cCcxSXn37F1gT7A05YU4bmuz+AK/ i/mj/V1tffeLtlzss7Owvroo+309ZCxPKIsByOtz9a5UoSWsSxn725EY6 w==; X-CSE-ConnectionGUID: MWb71JZ7TyupHCf66y5V5Q== X-CSE-MsgGUID: IAHmQNRBRk+k2XaaIO6luQ== X-IronPort-AV: E=McAfee;i="6800,10657,11950"; a="1998852" X-IronPort-AV: E=Sophos;i="6.27,186,1787036400"; d="scan'208";a="1998852" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2026 04:50:47 -0700 X-CSE-ConnectionGUID: iVloZGdZSKqlpcSNBX7Ryg== X-CSE-MsgGUID: +jr1l4YiQDOZK8h2WRJEmg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,186,1787036400"; d="scan'208";a="5379281" Received: from dut1048pvc.igk.intel.com (HELO localhost) ([10.211.177.228]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2026 04:50:46 -0700 From: Stephan Rohr To: gdb-patches@sourceware.org Cc: pedro@palves.net, eliz@gnu.org, jhb@FreeBSD.org, luis.machado@arm.com Subject: [PATCH v2 3/5] gdb: support register groups for user registers Date: Fri, 30 Oct 2026 11:50:14 +0000 Message-ID: <20261030115016.45786-4-stephan.rohr@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261030115016.45786-1-stephan.rohr@intel.com> References: <20261030115016.45786-1-stephan.rohr@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 From: "Rohr, Stephan" User registers are not part of any register group and user registers are not listed with the "info registers " command. Neither do "info registers" and "info all-registers". Allow an optional set of register groups when adding a user register. Update the "info registers" commands to print user registers, too. This is in preparation for adding the Intel AMX tile registers as user registers. --- gdb/NEWS | 7 +++++++ gdb/doc/gdb.texinfo | 7 +++++-- gdb/infcmd.c | 28 +++++++++++++++++++++++++++ gdb/user-regs.c | 46 +++++++++++++++++++++++++++++++++++++++------ gdb/user-regs.h | 17 +++++++++++++---- 5 files changed, 93 insertions(+), 12 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index 2047e7376fb..4869f3595be 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -88,6 +88,13 @@ info locals The new "-shadowed on|off" option overrides the "set print shadowed" setting for a single invocation of the command. +info registers +info all-registers +info registers REGGROUP + These commands now also print the user registers that are part of the + "general" register group, the "all" register group, or of REGGROUP, + respectively. + *** Changes in GDB 18 * Support for the Common Trace Format (CTF) has been removed. GDB now diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 9e3b6fca669..72b87401c5c 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -13772,7 +13772,8 @@ and vector registers (in the selected stack frame). @item info registers @var{reggroup} @dots{} Print the name and value of the registers in each of the specified @var{reggroup}s. The @var{reggroup} can be any of those returned by -@code{maint print reggroups} (@pxref{Maintenance Commands}). +@code{maint print reggroups} (@pxref{Maintenance Commands}). This +includes the user registers that are part of a @var{reggroup}. @item info registers @var{regname} @dots{} Print the @dfn{relativized} value of each specified register @var{regname}. @@ -42832,7 +42833,9 @@ include the four ``standard'' registers @code{$fp}, @code{$pc}, @code{$sp}, and @code{$ps}. @xref{standard registers}. User registers can be used in expressions in the same way as the canonical register names, but only the latter are listed by the @code{info -registers} and @code{maint print registers} commands. +registers} and @code{maint print registers} commands. The exceptions are +user registers that are part of a register group, which @code{info registers +@var{reggroup}} lists (@pxref{info_registers_reggroup}). @kindex maint print section-scripts @cindex info for known .debug_gdb_scripts-loaded scripts diff --git a/gdb/infcmd.c b/gdb/infcmd.c index d7544168362..a1a31b65a07 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -2533,6 +2533,27 @@ default_print_registers_info (struct gdbarch *gdbarch, } } +/* Print the user registers of GDBARCH in FRAME that are part of GROUP + to FILE. */ + +static void +print_user_registers_in_group (gdbarch *gdbarch, ui_file *file, + const frame_info_ptr &frame, + const reggroup *group) +{ + /* User registers lie above the range of normal registers. */ + for (int regnum = gdbarch_num_cooked_regs (gdbarch);; regnum++) + { + const char *regname = user_reg_map_regnum_to_name (gdbarch, regnum); + if (regname == nullptr) + break; + + if (user_reg_reggroup_p (gdbarch, regnum, group)) + default_print_one_register_info (file, regname, + value_of_user_reg (regnum, frame)); + } +} + void registers_info (const char *addr_exp, bool fpregs) { @@ -2548,6 +2569,11 @@ registers_info (const char *addr_exp, bool fpregs) { gdbarch_print_registers_info (gdbarch, gdb_stdout, frame, -1, fpregs); + + /* Print all user registers that are in the all register group or the + general register group, respectively. */ + print_user_registers_in_group (gdbarch, gdb_stdout, frame, + fpregs ? all_reggroup : general_reggroup); return; } @@ -2632,6 +2658,8 @@ registers_info (const char *addr_exp, bool fpregs) gdb_stdout, frame, regnum, fpregs); } + + print_user_registers_in_group (gdbarch, gdb_stdout, frame, group); continue; } } diff --git a/gdb/user-regs.c b/gdb/user-regs.c index f1c6c9a1b24..1e6280ef593 100644 --- a/gdb/user-regs.c +++ b/gdb/user-regs.c @@ -25,6 +25,8 @@ #include "arch-utils.h" #include "command.h" #include "cli/cli-cmds.h" +#include "reggroups.h" +#include /* A table of user registers. @@ -45,6 +47,10 @@ struct user_reg syscall. */ struct value *(*xread) (const frame_info_ptr &frame, const void *baton); const void *baton; + /* The register groups the register is part of. The array is owned by + the caller of user_reg_add or user_reg_add_builtin. */ + const reggroup *const *groups; + size_t num_groups; struct user_reg *next; }; @@ -63,15 +69,26 @@ struct gdb_user_regs static void append_user_reg (struct gdb_user_regs *regs, const char *name, user_reg_read_ftype *xread, const void *baton, + gdb::array_view groups, struct user_reg *reg) { /* The caller is responsible for allocating memory needed to store - the register. By doing this, the function can operate on a - register list stored in the common heap or a specific obstack. */ + the register and its GROUPS. By doing this, the function can operate + on a register list stored in the common heap or a specific obstack. */ gdb_assert (reg != NULL); + + /* User registers provide a different view of hardware registers. They + shall not be added to the "save" or "restore" register groups. */ + for (const reggroup *group : groups) + gdb_assert (group != nullptr + && group != save_reggroup + && group != restore_reggroup); + reg->name = name; reg->xread = xread; reg->baton = baton; + reg->groups = groups.data (); + reg->num_groups = groups.size (); reg->next = NULL; if (regs->last == nullptr) regs->last = ®s->first; @@ -85,9 +102,10 @@ static struct gdb_user_regs builtin_user_regs; void user_reg_add_builtin (const char *name, user_reg_read_ftype *xread, - const void *baton) + const void *baton, + gdb::array_view groups) { - append_user_reg (&builtin_user_regs, name, xread, baton, + append_user_reg (&builtin_user_regs, name, xread, baton, groups, XNEW (struct user_reg)); } @@ -110,6 +128,7 @@ get_user_regs (struct gdbarch *gdbarch) reg != NULL; reg = reg->next) append_user_reg (regs, reg->name, reg->xread, reg->baton, + gdb::make_array_view (reg->groups, reg->num_groups), OBSTACK_ZALLOC (obstack, struct user_reg)); user_regs_data.set (gdbarch, regs); } @@ -119,11 +138,12 @@ get_user_regs (struct gdbarch *gdbarch) void user_reg_add (struct gdbarch *gdbarch, const char *name, - user_reg_read_ftype *xread, const void *baton) + user_reg_read_ftype *xread, const void *baton, + gdb::array_view groups) { struct gdb_user_regs *regs = get_user_regs (gdbarch); gdb_assert (regs != NULL); - append_user_reg (regs, name, xread, baton, + append_user_reg (regs, name, xread, baton, groups, GDBARCH_OBSTACK_ZALLOC (gdbarch, struct user_reg)); } @@ -194,6 +214,20 @@ user_reg_map_regnum_to_name (struct gdbarch *gdbarch, int regnum) } } +/* See user-regs.h. */ + +bool +user_reg_reggroup_p (struct gdbarch *gdbarch, int regnum, + const reggroup *group) +{ + int maxregs = gdbarch_num_cooked_regs (gdbarch); + struct user_reg *reg = usernum_to_user_reg (gdbarch, regnum - maxregs); + + gdb_assert (reg != nullptr); + return (std::find (reg->groups, reg->groups + reg->num_groups, group) + != reg->groups + reg->num_groups); +} + struct value * value_of_user_reg (int regnum, const frame_info_ptr &frame) { diff --git a/gdb/user-regs.h b/gdb/user-regs.h index 7fdb05db4b1..8e08e677950 100644 --- a/gdb/user-regs.h +++ b/gdb/user-regs.h @@ -38,8 +38,11 @@ of assumed to be read-only. Should it, for instance, return a register descriptor that contains all the relevant access methods. */ +#include "gdbsupport/array-view.h" + class frame_info_ptr; struct gdbarch; +struct reggroup; /* Given an architecture, map a user visible register name onto its index. */ @@ -61,12 +64,18 @@ typedef struct value *(user_reg_read_ftype) (const frame_info_ptr &frame, extern struct value *value_of_user_reg (int regnum, const frame_info_ptr &frame); /* Add a builtin register (present in all architectures). */ -extern void user_reg_add_builtin (const char *name, - user_reg_read_ftype *read, - const void *baton); +extern void user_reg_add_builtin + (const char *name, user_reg_read_ftype *read, const void *baton, + gdb::array_view groups = {}); /* Add a per-architecture frame register. */ extern void user_reg_add (struct gdbarch *gdbarch, const char *name, - user_reg_read_ftype *read, const void *baton); + user_reg_read_ftype *read, const void *baton, + gdb::array_view groups = {}); + +/* Return true if the user register REGNUM is a member of GROUP. */ + +extern bool user_reg_reggroup_p (struct gdbarch *gdbarch, int regnum, + const reggroup *group); #endif /* GDB_USER_REGS_H */ -- 2.43.0 ________________________________________ Intel Deutschland GmbH Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany Tel: +49 (89) 99143-0 www.intel.de Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman Chairperson of the Supervisory Board: Sonja Pierer Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928 This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.