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 CBC6B38375A7 for ; Wed, 14 Dec 2022 03:36:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CBC6B38375A7 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=polymtl.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=polymtl.ca 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 2BE3ajKW029860 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Dec 2022 22:36:49 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 2BE3ajKW029860 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=polymtl.ca; s=default; t=1670989010; bh=SpX9zZ+77mX9YkDF8hcawZdyHfol2WXHNVssGdWdV2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dd/CDAPxza/qfgXoLOFR9IQ3TRMWvlLZhWV372SB/MFdt4STRwS7oNeAaypZoIy1u gxIynlRUlRJdQzBx2VfKUSvsTW0ln/fLP8YWEDB46ewtfgwUuYvqgtNGkudcKkQvZG GvD+QXF/clOSRDhABwn1bucLv3qJvWl4h72t5pHk= Received: from simark.localdomain (unknown [217.28.27.60]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 13DB11E124; Tue, 13 Dec 2022 22:36:45 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v2 09/13] gdb: add create_new_frame(frame_id) overload Date: Tue, 13 Dec 2022 22:34:37 -0500 Message-Id: <20221214033441.499512-10-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221214033441.499512-1-simon.marchi@polymtl.ca> References: <20221214033441.499512-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Wed, 14 Dec 2022 03:36:45 +0000 X-Spam-Status: No, score=-3189.5 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 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: The subsequent patches will need to call create_new_frame with an existing frame_id representing a user created frame. They could call the existing create_new_frame, passing both addresses, but it seems nicer to have a version of the function that takes a frame_id directly. Change-Id: If31025314fec0c3e644703e4391a5ef8079e1a32 --- gdb/frame.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/gdb/frame.c b/gdb/frame.c index 528ad76b58de..b9132d0f35a7 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -1929,22 +1929,23 @@ select_frame (frame_info_ptr fi) /* Create an arbitrary (i.e. address specified by user) or innermost frame. Always returns a non-NULL value. */ -frame_info_ptr -create_new_frame (CORE_ADDR addr, CORE_ADDR pc) +static frame_info_ptr +create_new_frame (frame_id id) { - frame_info *fi; + gdb_assert (id.user_created_p); + gdb_assert (id.stack_status == frame_id_stack_status::FID_STACK_VALID); + gdb_assert (id.code_addr_p); - frame_debug_printf ("addr=%s, pc=%s", hex_string (addr), hex_string (pc)); + frame_debug_printf ("stack_addr=%s, core_addr=%s", + hex_string (id.stack_addr), hex_string (id.code_addr)); /* Avoid creating duplicate frames, search for an existing frame with that id in the stash. */ - frame_id id = frame_id_build (addr, pc); - id.user_created_p = 1; frame_info_ptr frame = frame_stash_find (id); if (frame != nullptr) return frame; - fi = FRAME_OBSTACK_ZALLOC (struct frame_info); + frame_info *fi = FRAME_OBSTACK_ZALLOC (struct frame_info); fi->next = create_sentinel_frame (current_program_space, get_current_regcache ()); @@ -1953,7 +1954,7 @@ create_new_frame (CORE_ADDR addr, CORE_ADDR pc) Do this before looking for this frame's unwinder. A sniffer is very likely to read this, and the corresponding unwinder is entitled to rely that the PC doesn't magically change. */ - fi->next->prev_pc.value = pc; + fi->next->prev_pc.value = id.code_addr; fi->next->prev_pc.status = CC_VALUE; /* We currently assume that frame chain's can't cross spaces. */ @@ -1975,6 +1976,15 @@ create_new_frame (CORE_ADDR addr, CORE_ADDR pc) return frame_info_ptr (fi); } +frame_info_ptr +create_new_frame (CORE_ADDR stack, CORE_ADDR pc) +{ + frame_id id = frame_id_build (stack, pc); + id.user_created_p = 1; + + return create_new_frame (id); +} + /* Return the frame that THIS_FRAME calls (NULL if THIS_FRAME is the innermost frame). Be careful to not fall off the bottom of the frame chain and onto the sentinel frame. */ -- 2.38.1