From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id v9p1BFtUEmmPvzMAWB0awg (envelope-from ) for ; Mon, 10 Nov 2025 16:08:43 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=stackframe.org header.i=@stackframe.org header.a=rsa-sha256 header.s=duo-1634547266507-560c42ae header.b=AHNP89Xb; dkim=pass (2048-bit key; unprotected) header.d=outbound.mailhop.org header.i=@outbound.mailhop.org header.a=rsa-sha256 header.s=dkim-high header.b=w4zhqJFq; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=stackframe.org header.i=@stackframe.org header.a=rsa-sha256 header.s=dkim1 header.b=Lm+bR4oC; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id F0CA81E0B8; Mon, 10 Nov 2025 16:08:42 -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_MED,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 server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 308711E04C for ; Mon, 10 Nov 2025 16:08:42 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B14ED3858C42 for ; Mon, 10 Nov 2025 21:08:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B14ED3858C42 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, secure) header.d=stackframe.org header.i=@stackframe.org header.a=rsa-sha256 header.s=duo-1634547266507-560c42ae header.b=AHNP89Xb; dkim=pass (2048-bit key, unprotected) header.d=outbound.mailhop.org header.i=@outbound.mailhop.org header.a=rsa-sha256 header.s=dkim-high header.b=w4zhqJFq; dkim=fail reason="signature verification failed" (2048-bit key, secure) header.d=stackframe.org header.i=@stackframe.org header.a=rsa-sha256 header.s=dkim1 header.b=Lm+bR4oC Received: from outbound1g.eu.mailhop.org (outbound1g.eu.mailhop.org [52.28.6.212]) by sourceware.org (Postfix) with ESMTPS id D7FCE3858D1E for ; Mon, 10 Nov 2025 21:07:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D7FCE3858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=stackframe.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=stackframe.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D7FCE3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=52.28.6.212 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762808862; cv=none; b=dHyBODlV7oI4BerrH9wEDc7iZl2zEFTuuWPkmyleR7ERkidS95tDy1GFK+9FDK3XgmgZAmgc3k7UcafiTAFx12nYeLp8AjJt7tIJhcgPFxYAHGRxM7rVwhjWxPuiXQMLuuLZd8LcouFU0ktavv1GaDV1FxksYnp6w0O+SLDeNqs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1762808862; c=relaxed/simple; bh=RN8zXgOeCjDgrgREYS6mzWbcpXEAE7z3Cvrp26NUmPU=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:From:To:Subject:Date: Message-ID:MIME-Version; b=QyTQh4xL2iGplcDCgffVwDr4GxkuFpqTRMiXwW6rRvCYf7ix15TVYSkSjEZ8nES60P0oOOpHES3zlEtu3cU2aSDHSfdBOgvWVK1LTjRDmFKfoHMh8AIi2t0KHsVmOqT4EphH5VOQBOtVFik2q6E8QuWbe58uYIDQ/3vkU4Zg+3E= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7FCE3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=stackframe.org; s=duo-1634547266507-560c42ae; h=content-transfer-encoding:mime-version:message-id:date:subject:cc:to:from: cfbl-address:cfbl-feedback-id:from; bh=sSfLh8yvf1Hs7UjsH5jmFcTFKIe1x6NdAKS93+boOuk=; b=AHNP89XbFsr3DFoBA9YDEeOObQ3POuCrkZc30DIB7KiG7PAXVR+aj3J7FExd2AAp1qL8EYMT9aX+Z LmnIQ50jwr3IgkNsttMoHr/Se3YRiyadkxGFWHf9z+rlA2PnaI3Zck0TvTaokCjgWhfxlFH87gswJ7 +d1OrIgWcD8I3ZV4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:message-id:date:subject:cc:to:from: cfbl-address:cfbl-feedback-id:from; bh=sSfLh8yvf1Hs7UjsH5jmFcTFKIe1x6NdAKS93+boOuk=; b=w4zhqJFqWhwwPq5HmUU9D4qLnTqjZsCPnBC+Gcu5rR0U2KfNhTyJVisR6yYJKW65YkpjYlWIQRQsv 2UIraVGbmrLgQdeXwqxyxcYFTCuwwn7lrfBxXasNzCQR5gm+g3nPHt+stHJPJgQHBZGC9xrS6Avm1h hqiFUn3i+PUF1DZMMMluR+gSRXwPbagv5gGJv525UAK58FrjCU/JqLnFJbM4eMbhC6ZZOqmjc0Pbji IRteik0sH+5qKTj0S1UIb0u5BrdzTKpWri7towsw46B5EikA4/ye37PC9UQRoSmBihaj8hGiDi44ju 6mIlpJIGdQ4KTnMw7f+QlDLWgs+zlYQ== X-Originating-IP: 130.180.31.158 X-MHO-RoutePath: dG9ta2lzdG5lcm51 X-MHO-User: 49169773-be79-11f0-b95c-5f56af36decb X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Mail-Handler: DuoCircle Outbound SMTP CFBL-Feedback-ID: 49169773-be79-11f0-b95c-5f56af36decb:5 CFBL-Address: prvs=040923d279=abuse@outbound.mailhop.org; report=arf Received: from mail.duncanthrax.net (mail.duncanthrax.net [130.180.31.158]) by outbound3.eu.mailhop.org (Halon) with ESMTPSA id 49169773-be79-11f0-b95c-5f56af36decb; Mon, 10 Nov 2025 21:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=stackframe.org; s=dkim1; h=Content-Transfer-Encoding:MIME-Version: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=sSfLh8yvf1Hs7UjsH5jmFcTFKIe1x6NdAKS93+boOuk=; b=Lm+bR4oCWNIam73AJBDOvz636t GfycbLFX+DUqPw9e8JR4LtsnWJv4BbbR1G6z1H2MVyWxf20pXqENJoV1z9IAOB4dtDpYvdT8/6BfM +4w148jqqj+ha++ze++vzKUqZ5jLv7A8jVkFndv9yPAy3mQVfjR/4ZTRZNHNNfvT4JWlg8LYThuCe DjFtyz/0cnvQ1Cy5zDWh9bipRmztvw2AK3ncX6j3go/LB6kRPUVBBwiPrrxr2Gr8QDF5p9wNWoulQ XeOuRJsw15pp+NjFDJRxrgaUNEYe1F04fiVxcy3E23KD9cpyrBTzFdg1krYL1QQdqoieEXyN9x8k5 f8WVx+jQ==; Received: from [134.3.93.166] (helo=debian.stackframe.org) by mail.duncanthrax.net with esmtpa (Exim 4.97) (envelope-from ) id 1vIZ6v-00000005pFs-16xC; Mon, 10 Nov 2025 22:07:37 +0100 From: Sven Schnelle To: gdb-patches@sourceware.org Cc: Helge Deller , John David Anglin , binutils@sourceware.org, Sven Schnelle Subject: [PATCH v3] gdb/hppa: guess g packet size Date: Mon, 10 Nov 2025 22:07:17 +0100 Message-ID: <20251110210717.152087-1-svens@stackframe.org> X-Mailer: git-send-email 2.51.0 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 With qemu supporting 64 bit now, add some code to determine the register size of a hppa remote target. Signed-off-by: Sven Schnelle --- Changes in v3: - adjust coding style - default to 4 bytes and print a warning when target description misses size attribute (or uses an unknown size) Changes in v2: - adjust coding style - use target_desc_up, make it static - use nullptr instead of NULL gdb/hppa-tdep.c | 57 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index 96cb797c023..929d0758991 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -33,6 +33,8 @@ #include "trad-frame.h" #include "frame-unwind.h" #include "frame-base.h" +#include "remote.h" +#include "target-descriptions.h" #include "gdbcore.h" #include "cli/cli-cmds.h" @@ -43,6 +45,14 @@ static bool hppa_debug = false; +/* Properties (for struct target_desc) describing the g/G packet + layout. */ +#define PROPERTY_GP32 "internal: transfers-32bit-registers" +#define PROPERTY_GP64 "internal: transfers-64bit-registers" + +static target_desc_up hppa_tdesc32; +static target_desc_up hppa_tdesc64; + /* Some local constants. */ static const int hppa32_num_regs = 128; static const int hppa64_num_regs = 96; @@ -2978,6 +2988,19 @@ hppa_skip_trampoline_code (const frame_info_ptr &frame, CORE_ADDR pc) -- chastain 2003-12-18 */ +static void +hppa_register_g_packet_guesses (struct gdbarch *gdbarch) +{ + /* If the size matches the set of 32-bit or 64-bit integer registers, + assume that's what we've got. */ + register_remote_g_packet_guess (gdbarch, hppa32_num_regs * 4, + hppa_tdesc32.get ()); + register_remote_g_packet_guess (gdbarch, hppa64_num_regs * 8, + hppa_tdesc64.get ()); + + /* Otherwise we don't have a useful guess. */ +} + static struct gdbarch * hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { @@ -2991,15 +3014,32 @@ hppa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) = gdbarch_alloc (&info, gdbarch_tdep_up (new hppa_gdbarch_tdep)); hppa_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - /* Determine from the bfd_arch_info structure if we are dealing with - a 32 or 64 bits architecture. If the bfd_arch_info is not available, - then default to a 32bit machine. */ - if (info.bfd_arch_info != NULL) - tdep->bytes_per_address = - info.bfd_arch_info->bits_per_address / info.bfd_arch_info->bits_per_byte; + /* Determine from the target description if we are dealing with + a 32 or 64 bits architecture. If the target description is not + available, then check whether bfd_arch_info could be used. + Otherwise default to a 32bit machine. + */ + if (info.target_desc != nullptr) + { + if (tdesc_property (info.target_desc, PROPERTY_GP64) != nullptr) + tdep->bytes_per_address = 8; + else if (tdesc_property (info.target_desc, PROPERTY_GP32) != nullptr) + tdep->bytes_per_address = 4; + else + { + warning (_("target returned a target description this gdb doesn't " + "support for the HP/PA architecture")); + tdep->bytes_per_address = 4; + } + } + else if (info.bfd_arch_info != nullptr) + tdep->bytes_per_address = + info.bfd_arch_info->bits_per_address / info.bfd_arch_info->bits_per_byte; else tdep->bytes_per_address = 4; + hppa_register_g_packet_guesses (gdbarch); + tdep->find_global_pointer = hppa_find_global_pointer; /* Some parts of the gdbarch vector depend on whether we are running @@ -3122,6 +3162,11 @@ hppa_dump_tdep (struct gdbarch *gdbarch, struct ui_file *file) INIT_GDB_FILE (hppa_tdep) { gdbarch_register (bfd_arch_hppa, hppa_gdbarch_init, hppa_dump_tdep); + hppa_tdesc32 = allocate_target_description (); + set_tdesc_property (hppa_tdesc32.get(), PROPERTY_GP32, ""); + + hppa_tdesc64 = allocate_target_description (); + set_tdesc_property (hppa_tdesc64.get(), PROPERTY_GP64, ""); add_cmd ("unwind", class_maintenance, unwind_command, _("Print unwind table entry at given address."), -- 2.51.0