From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 72AB03858D20; Fri, 20 Jan 2023 19:52:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 72AB03858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674244372; bh=BGj3pxif5k3ZJGYDR4lX43gylN8GHI07a/HAxy2/qLc=; h=From:To:Subject:Date:From; b=S133p8g/voyhhtM/vEDzstVqHOJWqZGmKcCWish5EJ+8fDzioMMJRAdKlyAXEurQc fegnkd9FSUZPsuZBcwFlNJuYJeCahew33WtaDIEf7kUQ+wALZU7Wp2z9SQnS14oYff LuYj+33qeDtX0/lgERQFH6iEEE6GUFGezW5ApLag= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: add create_new_frame(frame_id) overload X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: f649a718522b018bbb09eb96beb103a4f5892a45 X-Git-Newrev: d015d3206e11c6926c4afce723d8366afc965b97 Message-Id: <20230120195252.72AB03858D20@sourceware.org> Date: Fri, 20 Jan 2023 19:52:52 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dd015d3206e11= c6926c4afce723d8366afc965b97 commit d015d3206e11c6926c4afce723d8366afc965b97 Author: Simon Marchi Date: Tue Dec 13 22:34:37 2022 -0500 gdb: add create_new_frame(frame_id) overload =20 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. =20 Change-Id: If31025314fec0c3e644703e4391a5ef8079e1a32 Reviewed-By: Bruno Larsen Diff: --- gdb/frame.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/gdb/frame.c b/gdb/frame.c index 2e6a477ef16..0909109c1f4 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. */ =20 -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 =3D=3D frame_id_stack_status::FID_STACK_VALI= D); + gdb_assert (id.code_addr_p); =20 - frame_debug_printf ("addr=3D%s, pc=3D%s", hex_string (addr), hex_string = (pc)); + frame_debug_printf ("stack_addr=3D%s, core_addr=3D%s", + hex_string (id.stack_addr), hex_string (id.code_addr)); =20 /* Avoid creating duplicate frames, search for an existing frame with th= at id in the stash. */ - frame_id id =3D frame_id_build (addr, pc); - id.user_created_p =3D 1; frame_info_ptr frame =3D frame_stash_find (id); if (frame !=3D nullptr) return frame; =20 - fi =3D FRAME_OBSTACK_ZALLOC (struct frame_info); + frame_info *fi =3D FRAME_OBSTACK_ZALLOC (struct frame_info); =20 fi->next =3D 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 =3D pc; + fi->next->prev_pc.value =3D id.code_addr; fi->next->prev_pc.status =3D CC_VALUE; =20 /* 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); } =20 +frame_info_ptr +create_new_frame (CORE_ADDR stack, CORE_ADDR pc) +{ + frame_id id =3D frame_id_build (stack, pc); + id.user_created_p =3D 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. */