From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id E04E23858039 for ; Wed, 8 Nov 2023 05:51:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E04E23858039 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E04E23858039 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=132.207.4.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699422706; cv=none; b=YdvFdAA2JSHLBYrVZ0ZDrYJSkzNarQ1AG3djaG+wT5XMqgxIbjBLAQtskboXoSazdJ6/Uxv2R4TD7j34thRWCPhTKvq4/sk5ZniLLzJJH879cMYld71MCpC8TAjGbz1SiO6H/1QElb9UecHqKgURlensb1vQ3X6D6Jkte89aY4Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699422706; c=relaxed/simple; bh=klY8ROuh0omHi3MYYlsV9jiKfb0kjToKEDIUnnaKjvU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=FaOG+IdgxiXVbaFfZh9JClSwctgXLTJQltknhKn/yUGoewcbGWSTXdXsuIgg7nRkSSKC+fA29M5X2Y5QcfosUHRuKIOhSCWiBz956nZfHfQ6kJHgyOf9A729I4SYaMZovMkZPU8Y74qyTXQ9eO/xE+O5aXqIJrARj1VAyOdgnWE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 3A85pcew022283 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 8 Nov 2023 00:51:43 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 3A85pcew022283 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1699422703; bh=VFXA9q0eDnRudiMx2f7/Z6PT2RL7tu5F20ojZDnfyPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N+aGtdzkiARG2Ararhb6eTvwKoha1o3LyEVHpAeht83zf9LUpbID20kqs6oHZ/FRg jRLc2KncdQoW0vj1wS0+7R+Y4ml1cFGPtOMmeTqHrtFzpujlWsQ0AzEI+JZfHFNhKg zBiXKPAaZj7xrIyoVA5XGYnEWXyFovyHCHwoWAEg= Received: from simark.localdomain (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (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 5EE861E1AB; Wed, 8 Nov 2023 00:14:32 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 13/24] gdb: add value::allocate_register Date: Wed, 8 Nov 2023 00:00:57 -0500 Message-ID: <20231108051222.1275306-14-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231108051222.1275306-1-simon.marchi@polymtl.ca> References: <20231108051222.1275306-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 8 Nov 2023 05:51:38 +0000 X-Spam-Status: No, score=-3188.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,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: From: Simon Marchi 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 --- 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 4f3881386f34..4256b82da19a 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -792,11 +792,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 17b7c53d0522..a1b18087416f 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 37017c9dd9f7..511bde8bbd46 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.42.1