From patchwork Thu Dec 21 19:16:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 82692 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 014B0384CB94 for ; Thu, 21 Dec 2023 19:17:37 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id B26D63857B99 for ; Thu, 21 Dec 2023 19:17:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B26D63857B99 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B26D63857B99 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703186241; cv=none; b=SGlLJXizR6vZz3x18rOIhtA2gY7Ng48YcsqR1CIAW4rerKYwwFwflBujv6VG2v/zK5bHJKZdS+0AM/Fee7ApwB8rgrvAD2rwUKbTAi/zPWLZ1UGKS+4qiRQF3oZqCVuamQq7r6y1j3oWXHTuS8rHRrBJwfSEy9itCJrGevSHecc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703186241; c=relaxed/simple; bh=ET5QXZd5PS74Md1gMcSwPwNMuL1wGuVJSjBHjKk6YHE=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=B+o1jgjv59ak1ROBghas6ZcZSwEUlm9xIqUsdAZngzdrviLiyOUh1F3uKHDVcGNVRv2soPQr4Ws11ZGe8Xjfvz8/9e+rt7pNDbdGmI23zouCrO7vDQBsfdKY1cAMoWZUn2Br0rRhFMXTdb3gTKff3irpdT8H2tSedtTXNdRD9gA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from smarchi-efficios.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) (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 ESMTPSA id 3D29C1E0D0; Thu, 21 Dec 2023 14:17:19 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 3/9] gdb: pass non-nullptr frame to gdbarch_value_from_register in address_from_register Date: Thu, 21 Dec 2023 14:16:24 -0500 Message-ID: <20231221191716.257256-4-simon.marchi@efficios.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231221191716.257256-1-simon.marchi@efficios.com> References: <20231221191716.257256-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3496.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_SOFTFAIL, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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+patchwork=sourceware.org@sourceware.org address_from_register used to pass null_frame_id to gdbarch_value_from_register as "this frame"'s id, because it's possible for it to be called during unwind, when "this frame"'s id is not yet known. This create an oddity where those register struct values are created without a valid next frame id. I would much prefer for things to be consistent and have all register struct values to have a valid next frame id. Since gdbarch_value_from_register takes a frame_info_ptr now, rather than a frame_id, we can pass down "this frame", even if it doesn't have a valid id. gdbarch_value_from_register implementations can obtain the next frame from it. However, it's possible for the "this frame"'s next frame to be an inline frame, inlined in "this frame", in which case that next frame's id is also not known. So, loop until we get to the next non-inline frame (which is actually the frame where registers for "this frame" are unwound from). This is the same thing that we do in value_of_register_lazy, for the same reason. A later patch will factor out this "while next frame is inline" loop to apply it to all register struct values, so this is somewhat temporary. Change-Id: If487c82620cc5a4a4ea5807f0a0bad80ab984078 --- gdb/findvar.c | 19 +++++-------------- gdb/rs6000-tdep.c | 10 ++++------ 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/gdb/findvar.c b/gdb/findvar.c index 25737c4e3159..852f42dc176d 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -755,13 +755,11 @@ default_value_from_register (gdbarch *gdbarch, type *type, int regnum, struct value *value = value::allocate (type); value->set_lval (lval_register); - frame_id next_frame_id; - if (this_frame == nullptr) - next_frame_id = null_frame_id; - else - next_frame_id = get_frame_id (get_next_frame_sentinel_okay (this_frame)); + frame_info_ptr next_frame = get_next_frame_sentinel_okay (this_frame); + while (get_frame_type (next_frame) == INLINE_FRAME) + next_frame = get_next_frame_sentinel_okay (next_frame); - VALUE_NEXT_FRAME_ID (value) = next_frame_id; + VALUE_NEXT_FRAME_ID (value) = get_frame_id (next_frame); VALUE_REGNUM (value) = regnum; /* Any structure stored in more than one register will always be @@ -887,13 +885,6 @@ address_from_register (int regnum, frame_info_ptr frame) error (_("Invalid register #%d, expecting 0 <= # < %d"), regnum, regnum_max_excl); - /* This routine may be called during early unwinding, at a time - where the ID of FRAME is not yet known. Calling value_from_register - would therefore abort in get_frame_id. However, since we only need - a temporary value that is never used as lvalue, we actually do not - really need to set its VALUE_NEXT_FRAME_ID. Therefore, we re-implement - the core of value_from_register, but use the null_frame_id. */ - /* Some targets require a special conversion routine even for plain pointer types. Avoid constructing a value object in those cases. */ if (gdbarch_convert_register_p (gdbarch, regnum, type)) @@ -915,7 +906,7 @@ address_from_register (int regnum, frame_info_ptr frame) return unpack_long (type, buf); } - value *value = gdbarch_value_from_register (gdbarch, type, regnum, nullptr); + value *value = gdbarch_value_from_register (gdbarch, type, regnum, frame); read_frame_register_value (value, frame); if (value->optimized_out ()) diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index a0f3d94f3a11..478e9078de6f 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -2760,13 +2760,11 @@ rs6000_value_from_register (gdbarch *gdbarch, type *type, int regnum, value->set_lval (lval_register); - frame_id next_frame_id; - if (this_frame == nullptr) - next_frame_id = null_frame_id; - else - next_frame_id = get_frame_id (get_next_frame_sentinel_okay (this_frame)); + frame_info_ptr next_frame = get_next_frame_sentinel_okay (this_frame); + while (get_frame_type (next_frame) == INLINE_FRAME) + next_frame = get_next_frame_sentinel_okay (next_frame); - VALUE_NEXT_FRAME_ID (value) = next_frame_id; + VALUE_NEXT_FRAME_ID (value) = get_frame_id (next_frame); VALUE_REGNUM (value) = regnum; /* Any structure stored in more than one register will always be