From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id qXdVDT4/82o8vD4AWB0awg (envelope-from ) for ; Tue, 10 Nov 2026 10:58:54 -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=V4mUOMxO; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 317FD378002; Tue, 10 Nov 2026 10:58:54 -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_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 2664B1E04F for ; Tue, 10 Nov 2026 10:58:53 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3B22C4BA23C7 for ; Tue, 10 Nov 2026 15:58:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3B22C4BA23C7 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=V4mUOMxO Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by sourceware.org (Postfix) with ESMTPS id B952F4BA23E4 for ; Tue, 10 Nov 2026 15:58:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B952F4BA23E4 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 B952F4BA23E4 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=192.198.163.9 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794326282; cv=none; b=ZWfpLk2144d6yDHlQPWSuJg51hYjpCIsHNlKQ819y3nP+Halg37OKvuD+lyP4KCyRA9oNEIMk6pjTvTyeka3UwOu2rlegF1z5TJclXyIYcc7hiZeVMR2ZiPunrqoGRdNj7tQkJ+LMdZlDgfA29reHsxZCj0fu5eMaUP9LnDPpxs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1794326282; c=relaxed/simple; bh=Ivg0jwg7hYgwCYK+w4ADa/9+I07ZH8MiqWAto3HKEhc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=V+b1x2kCdk3VhexrPwnCab23G9+MogJf6z9zHrDeU5YlLDtBeKX9yH3UKI4MJTw5CjpxnOS+FvKVeVRvVLIoosRDZADWvqZB54u2ycNV/d53Y7uzajG+RSPv/qdhMH5teCMX9yi8MBsD15FSjK/o0MjvNCL6b07lX+EjyvSAS0k= 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=V4mUOMxO DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B952F4BA23E4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1794326282; x=1825862282; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ivg0jwg7hYgwCYK+w4ADa/9+I07ZH8MiqWAto3HKEhc=; b=V4mUOMxO6bRn2gOwlmLKxuKDXQPLupvKS2m9IqFmx0CTRVf0UN54GQIv QqrG6pCfn0QYLoZ79AK0qvtfCvso0NHWaiwLIYA4yMrQvGt6cIxCzOqTl OcmCsemBGMZNDB7km08IQ75/4dmZYIN6pScodR+o5g/5/n8IuOT1Qwvpy LYRwk8dROs6aqvtPqmk4ROuO97e29HTLsuyho7rp0ggEGyvIrzCNV2wG1 S1Qoa85qqQqFdv6o31mpnjkOvy/k0mYFmYGWiTyJHd0bgggGoUtViB4/l RK5NV6yOJ6+iXW0HhzL1WPmTMQDzxRNPLSqhwDfJ7WOLQClHo5wZlW+/y g==; X-CSE-ConnectionGUID: NUnpeP2nSDeeQ/nw0I8Wdg== X-CSE-MsgGUID: +1kRsmWJT7iU4+xvqXSXvQ== X-IronPort-AV: E=McAfee;i="6800,10657,11962"; a="2958075" X-IronPort-AV: E=Sophos;i="6.27,206,1787036400"; d="scan'208";a="2958075" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2026 07:58:01 -0800 X-CSE-ConnectionGUID: xu/23baoRPWNjVQ+FIl2vw== X-CSE-MsgGUID: IOQNvXQQQO2hfTgEOuBVlA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,206,1787036400"; d="scan'208";a="8013813" Received: from dut1048pvc.igk.intel.com (HELO localhost) ([10.211.177.228]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Nov 2026 07:57:59 -0800 From: Stephan Rohr To: gdb-patches@sourceware.org Cc: pedro@palves.net, jhb@FreeBSD.org, luis.machado@arm.com, christina.joos@intel.com Subject: [PATCH v4 3/5] gdb: support register groups for user registers Date: Tue, 10 Nov 2026 15:57:27 +0000 Message-ID: <20261110155729.436474-4-stephan.rohr@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261110155729.436474-1-stephan.rohr@intel.com> References: <20261110155729.436474-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. Reviewed-By: Eli Zaretskii --- 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 97ec5ab25ff..5b11c7b30ac 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}. @@ -42833,7 +42834,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 a9bceba1087..301f9a162af 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.