From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7850) id BF1E63858D28; Tue, 27 Jun 2023 19:42:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BF1E63858D28 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Indu Bhagat To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org Subject: [binutils-gdb] libsframe: update the semantics of sframe_fre_get_fp_offset X-Act-Checkin: binutils-gdb X-Git-Author: Indu Bhagat X-Git-Refname: refs/heads/master X-Git-Oldrev: 36aecb4197c035ac5f6a83e1f396290cbe1236a4 X-Git-Newrev: 526960c9121d58a532a8c32752f134bb1e0f76b4 Message-Id: <20230627194226.BF1E63858D28@sourceware.org> Date: Tue, 27 Jun 2023 19:42:26 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jun 2023 19:42:26 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D526960c9121d= 58a532a8c32752f134bb1e0f76b4 commit 526960c9121d58a532a8c32752f134bb1e0f76b4 Author: Indu Bhagat Date: Tue Jun 27 11:55:00 2023 -0700 libsframe: update the semantics of sframe_fre_get_fp_offset =20 Until now, sframe_fre_get_fp_offset () would return SFRAME_ERR_FREOFFSET_NOPRESENT if the ABI uses fixed FP offset. A stack tracer, then, would call an explicit sframe_decoder_get_fixed_fp_offset= () to get the FP offset. =20 On second look, it appears to make sense to hide these details of whether the FP offset is fixed or not in an ABI from the consumer. Now, with the changed semantics, the call to sframe_fre_get_fp_offset () will fetch the fixed FP offset if applicable, or get the FP offset from FRE when there is no fixed FP offset. =20 This patch changes the behavior of sframe_fre_get_fp_offset (): it turns an error into non-error. This change will be included with the next release of libsframe, where all the exposed symbols will be versioned with version node LIBSFRAME_1.0 for the first time. =20 libsframe/ * sframe.c (sframe_fre_get_fp_offset): Return the fixed offset,= if applicable. Else return the FP offset from the FRE. Diff: --- libsframe/sframe.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libsframe/sframe.c b/libsframe/sframe.c index 3d1b5575f0b..912d34352a1 100644 --- a/libsframe/sframe.c +++ b/libsframe/sframe.c @@ -644,16 +644,21 @@ sframe_fre_get_fp_offset (sframe_decoder_ctx *dctx, sframe_frame_row_entry *fre, int *errp) { uint32_t fp_offset_idx =3D 0; - sframe_header *dhp =3D sframe_decoder_get_header (dctx); - /* If the FP offset is not being tracked, return an error code so the ca= ller - can gather the fixed FP offset from the SFrame header. */ - if (dhp->sfh_cfa_fixed_fp_offset !=3D SFRAME_CFA_FIXED_FP_INVALID) - return sframe_set_errno (errp, SFRAME_ERR_FREOFFSET_NOPRESENT); + int8_t fp_offset =3D sframe_decoder_get_fixed_fp_offset (dctx); + /* If the FP offset is not being tracked, return the fixed FP offset + from the SFrame header. */ + if (fp_offset !=3D SFRAME_CFA_FIXED_FP_INVALID) + { + if (errp) + *errp =3D 0; + return fp_offset; + } =20 /* In some ABIs, the stack offset to recover RA (using the CFA) from is fixed (like AMD64). In such cases, the stack offset to recover FP wi= ll appear at the second index. */ - fp_offset_idx =3D ((dhp->sfh_cfa_fixed_ra_offset !=3D SFRAME_CFA_FIXED_R= A_INVALID) + fp_offset_idx =3D ((sframe_decoder_get_fixed_ra_offset (dctx) + !=3D SFRAME_CFA_FIXED_RA_INVALID) ? SFRAME_FRE_RA_OFFSET_IDX : SFRAME_FRE_FP_OFFSET_IDX); return sframe_get_fre_offset (fre, fp_offset_idx, errp);