From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id LKsoGNZ1P2r6MhoAWB0awg (envelope-from ) for ; Sat, 27 Jun 2026 03:03:50 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=VIxFg2V5; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4D4C71E098; Sat, 27 Jun 2026 03:03:50 -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,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 7168E1E070 for ; Sat, 27 Jun 2026 03:03:49 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DDE654BA2E3B for ; Sat, 27 Jun 2026 07:03:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DDE654BA2E3B Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=VIxFg2V5 Received: from mail-dl1-x122c.google.com (mail-dl1-x122c.google.com [IPv6:2607:f8b0:4864:20::122c]) by sourceware.org (Postfix) with ESMTPS id EE3424BA2E22 for ; Sat, 27 Jun 2026 07:03:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EE3424BA2E22 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EE3424BA2E22 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::122c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782543802; cv=none; b=k5c3F0X9mh6PqJ55/zJuUS6yRsQHRWOSsFTWSbR3y2wmBLnfFJELjMbGnkHHOvxy8su7WBvi5po3dbcXuacH1PdKM30HAwMjVCF/YoyDIKCznPW71JE90lHw13Ir+WpBJod2RQd9HxJcUtXxXgHyJCoJ3yK0ueHYENC4pU6iN7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782543802; c=relaxed/simple; bh=NMcBnovZm1BEmHfY3RD4/OGDq8/SXT8Eox4YGQJMByA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rihGx39ENxyFWwaPBuxM8X+QRlUvtWFwfgp+lrIccaJ2LAz2AWHQacoeFWFLiuq0MOVCztW2XfIBY+ayyQlaIPX3k69Hu97EmKym48YihLm+ugcsu92iYF2cjzvktc9ifYDpKPKHjB1M8f3TKzqYw+KmhgfjzBqwADtVhPVGMQ8= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=VIxFg2V5 DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EE3424BA2E22 Received: by mail-dl1-x122c.google.com with SMTP id a92af1059eb24-139f3eaaa49so1655c88.0 for ; Sat, 27 Jun 2026 00:03:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1782543801; x=1783148601; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/YKM9SrNZmCdas7MON3fMt/zK+fTAjTRrGJJ4wf4Z9M=; b=VIxFg2V5jVcZCqeRZ+ovHABspnCVjyHGwVngPW6Cf4FPQqCHt8j/SQEdigu/N9Ymle HR3ipcM8b2nWM4ZTJxXBsdY+LmR/dZ5rmwPy/o9FkDQ9mPKRNSLHU3EnICGuFXmtPzli 96dlYm0W7qohJmLCty82J4OV5H7b46phEaE/Np2bARyWaounJApez0CGg9eteOy72l8F My9XkycBbwkyTPMcPE80nzm9SjqcmdXrkmOPKLUxAG1Rclvz1zJhw1C+CoL8TafU+y5k ZoMApuNcoCccJV0yRFZDhPvOKwHH3RvCr1Mt5k6Xez7SfJnNxKCbjUbMCp7FX1514nXU zO+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782543801; x=1783148601; h=content-transfer-encoding:mime-version:message-id:date:user-agent :references:in-reply-to:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/YKM9SrNZmCdas7MON3fMt/zK+fTAjTRrGJJ4wf4Z9M=; b=FHuint7qkcPsuVRVqAr5+eDWk558azjEDFRsHJcZFeF2/tAFVfgN6dP8CnkzyFBgly BiHLTsX/Ag4lOALfBzUOoe0PltYHf4fPpc0V50mghCAOndl49uYcsSa8TsG291yeoGy1 FqICD+1dGNgDSVCEFO9DEnyTTAicHutmSL68X3pSakgX3SgE5sLy/LyUvhZRh56tasT/ 4HVJ5bTlEJ459Z0cc/PMi36Ue/GVrJhD1s1rfv5Boe0AUPm7sR/SbH//1qNynw/t4vuG F1pmDhiax75QzTyQfh74mDffsuKKMaMLkQI5InqRVd53g3Ix08qDcYp92DA4rNf2FPE9 sOxw== X-Gm-Message-State: AOJu0Yz4g+65riF1DarPMrP9nsP7kiwsASkyowjw37mqWxQaA2yrMs/y 1YNc0B26PTlrrdaInUumCNzXG6aHlVXgIBIko8+w2TXuEHdFJsp4QASgoNtsFvaQJng= X-Gm-Gg: AfdE7cmEhnxupY3nGcztnf/sogcodjxA1qwKgCsKyBfHcm110Q+dzyjoA/P6NxToHk8 BsZgbpIuJ7LrssNItFH1p1NBUAfL++YtTX5Q9XgB6NTNDMULta2fedhYOqLGuSNoNLatnHXjUID n7fJRnNo85sXArwThwl7eGMwArwaq9EEo4/HFC5Ygd+b2Ki/rNOX8ZfYOi7VNWY7svcuYDV0HDd W7jk5CJy6mvtYwGSXNZ8iCZBrmXS2avp5bLps25tZVAVoB+As10cUjeElzzEYTxwhV3O4NVtPXy 5ya2Jr9YC1iFsa5Dt03nJ16rgUtkj4f4jfzod0AAXTFIOWALDUmqVpKOZYIqk/IxHLjrToX5s9o Xo+kYG3puxof5+MepSGD36HAc7Z0rOpLLLBf6ZGHdO5UKCp/Wo+qjMWsIDQmnlNfagoWMIqK49+ vAGY2Sy0qB4bgqeoTeYmkk+klJTI6Y7fA4Zw== X-Received: by 2002:a05:7022:62a7:b0:128:cf80:deea with SMTP id a92af1059eb24-139dbb1847amr7544602c88.1.1782543800641; Sat, 27 Jun 2026 00:03:20 -0700 (PDT) Received: from localhost ([2804:14d:7e39:8083:f04c:42e3:5943:38f6]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-139d8f6d2e4sm25071822c88.7.2026.06.27.00.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jun 2026 00:03:20 -0700 (PDT) From: Thiago Jung Bauermann To: Cc: , , , , Subject: Re: [PATCH v2 2/7] gdb/aarch64: Add custom printing for POR_EL0 In-Reply-To: <20260626180821.376406-3-srinath.parvathaneni@arm.com> (srinath parvathaneni's message of "Fri, 26 Jun 2026 18:08:16 +0000") References: <20260626180821.376406-1-srinath.parvathaneni@arm.com> <20260626180821.376406-3-srinath.parvathaneni@arm.com> User-Agent: mu4e 1.14.2; emacs 30.2 Date: Sat, 27 Jun 2026 07:03:17 +0000 Message-ID: <87y0g0h3d6.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 writes: > From: Srinath Parvathaneni > > Add custom printing support for the POR_EL0 register when displayed > using `info registers` or `info all-registers`. > > The register value is decoded into a human-readable "rwx" > representation for each nibble in the POR_EL0 register, making the > POE permissions easier to interpret. > > Example: > (gdb) set $por_el0=3D0xffffffff77777777 > (gdb) info register por_el0 > por_el0 0xffffffff77777777 [P15=3D??? P14=3D??? P13=3D??? P12=3D?= ?? P11=3D??? P10=3D??? P9=3D??? P8=3D??? P7=3Drwx P6=3Drwx P5=3Drwx P4=3Drw= x P3=3Drwx P2=3Drwx P1=3Drwx P0=3Drwx ] Nice. > --- > gdb/aarch64-tdep.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 86 insertions(+) > > diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c > index f1e1a9c7a19..3ef4e696c7c 100644 > --- a/gdb/aarch64-tdep.c > +++ b/gdb/aarch64-tdep.c > @@ -3135,6 +3135,86 @@ aarch64_pseudo_register_type (struct gdbarch *gdba= rch, int regnum) > p_regnum); > } >=20=20 > +/* Convert a POR_EL0 Perm overlay permission encoding into rwx-style = string. > + For example: > + 0b0011 -> "r-x" (3) > + 0b0101 -> "rw-" (5) > + 0b0111 -> "rwx" (7) > + 0b0000 -> "---" (0) > + Reserved encodings (0b1xxx) are returned as "???". */ > + > +static const char* > +aarch64_perm_overlay_decode (unsigned int perm) > +{ > + switch (perm) > + { > + case 0: return "---"; > + case 1: return "r--"; > + case 2: return "--x"; > + case 3: return "r-x"; > + case 4: return "-w-"; > + case 5: return "rw-"; > + case 6: return "-wx"; > + case 7: return "rwx"; > + default: return "???"; > + } > +} > + > +/* Display POE reigster POR_EL0 in the following format for the 'info re= gisters' Typo: reigster > + and 'info all-registers' commands: > + [= ] */ > + > +static void > +aarch64_print_poe_register_info (struct ui_file *file, > + int regnum, > + const char *name, > + const frame_info_ptr &frame) > +{ > + value *val =3D value_of_register (regnum, get_next_frame_sentinel_okay= (frame)); > + ULONGEST por_el0 =3D (ULONGEST) value_as_long (val); > + gdb_printf (file, "%-14s 0x%s [", name, phex_nz (por_el0, 8)); > + > + for (int i =3D 15; i >=3D 0; --i) > + { > + unsigned int perm =3D (por_el0 >> (i * 4)) & 0xf; > + gdb_printf (file, "P%d=3D%s ", i, aarch64_perm_overlay_decode (per= m)); > + } > + > + gdb_puts ("]\n", file); > +} > + > +/* For 'info registers' and 'info all-registers', print POR_EL0 using the > + custom POE register printer and all other registers using the default > + register printer. */ > + > +static void > +aarch64_print_registers_info (struct gdbarch *gdbarch, > + struct ui_file *file, > + const frame_info_ptr &frame, > + int regnum, > + bool print_all) > +{ > + const int numregs =3D gdbarch_num_cooked_regs (gdbarch); > + aarch64_gdbarch_tdep *tdep =3D gdbarch_tdep (gdb= arch); > + > + if (regnum =3D=3D -1) > + { > + for (int i =3D 0; i < numregs; i++) > + { > + if (i =3D=3D tdep->poe_regnum) > + { > + aarch64_print_poe_register_info (file, i, "por_el0", frame); > + continue; > + } > + default_print_registers_info (gdbarch, file, frame, i, print_all); > + } > + } > + else if (regnum =3D=3D tdep->poe_regnum) > + aarch64_print_poe_register_info (file, regnum, "por_el0", frame); > + else > + default_print_registers_info (gdbarch, file, frame, regnum, print_al= l); > +} > + > /* Implement the "pseudo_register_reggroup_p" tdesc_arch_data method. */ >=20=20 > static bool Instead of adding this gdbarch hook, have you considered using enum target types=C2=B9 in the feature XML instead? E.g: Note that I haven't tested the above and I'm not sure it would actually work (or work well). I see two advantages: - It works in the "print $por_el0" case too, not only "info register $por_el0". Or does this patch also work with "print $por_el0" as well? - It's less code. > @@ -4141,6 +4221,10 @@ aarch64_features_from_target_desc (const struct ta= rget_desc *tdesc) > features.fpmr =3D (tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.fpm= r") > !=3D nullptr); >=20=20 > + /* Check for POE feature. */ > + features.poe =3D (tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.poe") > + !=3D nullptr); > + > return features; > } >=20=20 > @@ -4774,6 +4858,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, str= uct gdbarch_list *arches) > tdep->gcs_reg_base =3D first_gcs_regnum; > tdep->gcs_linux_reg_base =3D first_gcs_linux_regnum; > tdep->fpmr_regnum =3D fpmr_regnum; > + tdep->poe_regnum =3D poe_regnum; >=20=20 > /* Set the SME register set details. The pseudo-registers will be adj= usted > later. */ This change and the one above it in aarch64_features_from_target_desc should be in the previous patch instead. --=20 Thiago (he/him) =C2=B9 https://sourceware.org/gdb/current/onlinedocs/gdb.html/Enum-Target-T= ypes.html#Enum-Target-Types