From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 16CD93858C2B for ; Fri, 24 Nov 2023 21:29:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 16CD93858C2B 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 16CD93858C2B 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=1700861347; cv=none; b=pTl/1JBPAJqbgegh8REcdXwzo2EPk7ei0im6nPjv90uPf889JpfCQvat2/ZOMDkfVdHpCvDWbkWfrV8w2WLnsPpJUKTprKmmXRNPQZRK4w3WX+OclIqukGLxEYZk8VPqUfgnOcL7ht+x1aMFbnHyrkb6cKNsZGsKWIJpPhwyXRg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700861347; c=relaxed/simple; bh=dgxUWVOp2UKIAKxEmE4p2ltL+qGyc3inRvb3LM4cFhI=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=xJueJP7e/pf4dsDXrmjYDZi0+x8WtJUVLM6OBgQ6D275NkppNTTA4KoJm8NxHrXmv/8oGceLjmyAvSnVVUhXVJ+NfUWw+vRnLgUUvTIZPMZypapf6+CNuq8l5F0wHz5cP1/MrsI56V1NrFDrLCe3sL+VrH287Wc7RWd2Lt+97wY= 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 5E0591E1A7; Fri, 24 Nov 2023 16:29:04 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Luis Machado , John Baldwin , Andrew Burgess , Simon Marchi , John Baldwin Subject: [PATCH v2 13/24] gdb: add value::allocate_register Date: Fri, 24 Nov 2023 16:26:30 -0500 Message-ID: <20231124212656.96801-14-simon.marchi@efficios.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231124212656.96801-1-simon.marchi@efficios.com> References: <20231124212656.96801-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3496.8 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 List-Id: Add value::allocate_register, to facilitate allocating a value representing a register in a given frame (or rather, in the given frame's previous frame). It will be used in a subsequent patch. I changed one relatively obvious spot that could use it, to at least exercise the code path. Change-Id: Icd4960f5e471a74b657bb3596c88d89679ef3772 Reviewed-By: John Baldwin --- gdb/regcache.c | 7 ++----- gdb/value.c | 15 +++++++++++++++ gdb/value.h | 7 +++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/gdb/regcache.c b/gdb/regcache.c index c151aee5f717..218257aa085f 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -773,11 +773,8 @@ readable_regcache::cooked_read_value (int regnum) || (m_has_pseudo && m_register_status[regnum] != REG_UNKNOWN) || !gdbarch_pseudo_register_read_value_p (m_descr->gdbarch)) { - struct value *result; - - result = value::allocate (register_type (m_descr->gdbarch, regnum)); - result->set_lval (lval_register); - VALUE_REGNUM (result) = regnum; + value *result = value::allocate_register + (get_next_frame_sentinel_okay (get_current_frame ()), regnum); /* It is more efficient in general to do this delegation in this direction than in the other one, even though the value-based diff --git a/gdb/value.c b/gdb/value.c index 7067ae94df0b..a2acd1f26e03 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -959,6 +959,21 @@ value::allocate (struct type *type) return allocate (type, true); } +/* See value.h */ + +struct value * +value::allocate_register (frame_info_ptr next_frame, int regnum) +{ + value *result + = value::allocate (register_type (frame_unwind_arch (next_frame), regnum)); + + result->set_lval (lval_register); + VALUE_REGNUM (result) = regnum; + VALUE_NEXT_FRAME_ID (result) = get_frame_id (next_frame); + + return result; +} + /* Allocate a value that has the correct length for COUNT repetitions of type TYPE. */ diff --git a/gdb/value.h b/gdb/value.h index 3f9b35b589bd..2f3b41e26ea4 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -159,6 +159,13 @@ struct value /* Allocate a value and its contents for type TYPE. */ static struct value *allocate (struct type *type); + /* Allocate a non-lazy value representing register RENUM in the frame previous + to NEXT_FRAME. The type of the value is found using `register_type`. + + The caller is responsible for filling the value's contents. */ + static struct value *allocate_register (frame_info_ptr next_frame, + int regnum); + /* Create a computed lvalue, with type TYPE, function pointers FUNCS, and closure CLOSURE. */ static struct value *allocate_computed (struct type *type, -- 2.43.0