From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MeaWEZxr7GqGjh8AWB0awg (envelope-from ) for ; Thu, 05 Nov 2026 06:42:20 -0500 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=lbjYz9ou; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 3891C378002; Thu, 05 Nov 2026 06:42:20 -0500 (EST) 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_MSPIKE_H2,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 5E74E378002 for ; Thu, 05 Nov 2026 06:42:16 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C26E64BA2E3C for ; Thu, 5 Nov 2026 11:42:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C26E64BA2E3C 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=lbjYz9ou Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by sourceware.org (Postfix) with ESMTPS id 18A024BA23CE for ; Thu, 5 Nov 2026 11:41:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 18A024BA23CE 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 18A024BA23CE Authentication-Results: sourceware.org; arc=none smtp.remote-ip=198.175.65.14 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793878905; cv=none; b=NnpKI660ZBDj5OdFUyWkXKYUE7uE6AVpXmNvCf3U2LPqV9Qo0B1+21ztjRyA+0GhGNzW2BvNQ5orFE92MmDg26Cuyd4Klw1zt2wLy3sBcCFm/m7OOnUMPlECM/tzbV6E6v3k+GcjF6s/ZDBJytt3YIIV1JO+2BSYPOHHwQ9AdMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793878905; c=relaxed/simple; bh=0/lCFlnvgY8Wo83E1GDNjHba/8JS6bewLZjSBTl3i28=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rCR+u5aBufrKkOYBUJz7NxRRloNAl4G5Pw39GEhb2uWRjNBJpDV05w/eqec1PuCly3IUedFUoZAq71YrYuCYEic0/tbga8Zzw3gjZkNqpzcP+Bkkjfx4uq/FwYINJK36sok9WUwH4byu5mYLNAyU1vsBFHHwAsjNrihJMg6yNyc= 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=lbjYz9ou DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 18A024BA23CE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1793878905; x=1825414905; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0/lCFlnvgY8Wo83E1GDNjHba/8JS6bewLZjSBTl3i28=; b=lbjYz9ouxjTzGWXQY22ebm2eAO6i8dcwrfc+nb4EfGGqVei0vMZHuIPy DXUEDNoZp4OaXd1dRBoZec9eP5ANpESbU190BL6yH9ZS0bSd4hXUIlQxz TYujoZNPi4pYDI8GycYBW6sXcDTpplcMu8T/kkh0hTwNYUvx3TWjdqZ6J mx5ued4PqwCezrgMnZtu+HLeFtByITv80p9f594ezAQ9kGPhhMYPSGjNY EAP9UqrD04kgCNcqhhueVdF1uszMkVpau4qtXHzTzdSED3MuJaD++bHfV w3bHf1Z/wfTMIVxV+9uI+kPyWR2dMN5GJMQU9HW6gRd0Rh8haqlXEiFVe Q==; X-CSE-ConnectionGUID: q7usBBqvR5uOKhtwhoRMmg== X-CSE-MsgGUID: nTdGDSTdSIe8Y3WbQW1eDQ== X-IronPort-AV: E=McAfee;i="6800,10657,11956"; a="2551107" X-IronPort-AV: E=Sophos;i="6.27,197,1787036400"; d="scan'208";a="2551107" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2026 03:41:44 -0800 X-CSE-ConnectionGUID: y21zyC5mTmaI8xwSX0JnFA== X-CSE-MsgGUID: eekqGZBWRxqC3frB7EyYHw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,197,1787036400"; d="scan'208";a="7313667" Received: from dut1048pvc.igk.intel.com (HELO localhost) ([10.211.177.228]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2026 03:41:43 -0800 From: Stephan Rohr To: gdb-patches@sourceware.org Cc: pedro@palves.net, eliz@gnu.org, jhb@FreeBSD.org, luis.machado@arm.com, christina.joos@intel.com Subject: [PATCH v3 3/5] gdb: support register groups for user registers Date: Thu, 5 Nov 2026 11:41:07 +0000 Message-ID: <20261105114109.153949-4-stephan.rohr@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261105114109.153949-1-stephan.rohr@intel.com> References: <20261105114109.153949-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 1d635d743a0..86446c36722 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -84,6 +84,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. + * Python API ** The gdb.Breakpoint constructor now takes an optional diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index b38d455ab18..b45fc1ac521 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}. @@ -42831,7 +42832,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.