From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7850) id AC91C3858401; Tue, 27 Jun 2023 19:42:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC91C3858401 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_ra_offset X-Act-Checkin: binutils-gdb X-Git-Author: Indu Bhagat X-Git-Refname: refs/heads/master X-Git-Oldrev: 99fde044fc332b97616b395393b2590c510b0e6f X-Git-Newrev: 36aecb4197c035ac5f6a83e1f396290cbe1236a4 Message-Id: <20230627194221.AC91C3858401@sourceware.org> Date: Tue, 27 Jun 2023 19:42:21 +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:21 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D36aecb4197c0= 35ac5f6a83e1f396290cbe1236a4 commit 36aecb4197c035ac5f6a83e1f396290cbe1236a4 Author: Indu Bhagat Date: Tue Jun 27 11:54:49 2023 -0700 libsframe: update the semantics of sframe_fre_get_ra_offset =20 Until now, sframe_fre_get_ra_offset () would return SFRAME_ERR_FREOFFSET_NOPRESENT if the ABI uses fixed RA offset (e.g., AMD64). A stack tracer, then, will call an explicit sframe_decoder_get_fixed_ra_offset () to get the RA offset. =20 On second look, it appears to make sense to hide these details of whether the RA offset is fixed or not from the consumer. Now, with the changed semantics, the call to sframe_fre_get_ra_offset () will fetch the fixed RA offset if applicable, or get the RA offset from FRE when there is no fixed RA offset. =20 Adjustments need to be made to ensure the textual dump remains the same as preivous. Currently, e.g., if RA is not being tracked per FRE, following is seen with objdump --sframe: =20 STARTPC CFA FP RA 000000000000NNNN sp+X u u =20 This patch changes the behavior of sframe_fre_get_ra_offset: it turns an error into non-error. This change will be included with the next release of libsframe, where all exposed symbols will be versioned for the first time. =20 libsframe/ * sframe.c (sframe_fre_get_ra_offset): Return the fixed offset, if applicable. Else return the RA offset from the FRE. * sframe-dump.c (dump_sframe_func_with_fres): Make adjustments to keep the textual dump same as previous. Diff: --- libsframe/sframe-dump.c | 12 ++++++++---- libsframe/sframe.c | 14 +++++++++----- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/libsframe/sframe-dump.c b/libsframe/sframe-dump.c index 6d266392cd7..2491b4391f3 100644 --- a/libsframe/sframe-dump.c +++ b/libsframe/sframe-dump.c @@ -164,11 +164,15 @@ dump_sframe_func_with_fres (sframe_decoder_ctx *sfd_c= tx, strcpy (temp, "u"); printf ("%-10s", temp); =20 - /* Dump RA info. */ - if (err[2] =3D=3D 0) - sprintf (temp, "c%+d", ra_offset); - else + /* Dump RA info. + If an ABI does not track RA offset, e.g., AMD64, display a 'u', + else display the offset d as 'c+-d'. */ + if (sframe_decoder_get_fixed_ra_offset(sfd_ctx) + !=3D SFRAME_CFA_FIXED_RA_INVALID) strcpy (temp, "u"); + else if (err[2] =3D=3D 0) + sprintf (temp, "c%+d", ra_offset); + /* Mark SFrame FRE's RA information with "[s]" if the RA is mangled with signature bits. */ const char *ra_mangled_p_str diff --git a/libsframe/sframe.c b/libsframe/sframe.c index 8837f878fb0..3d1b5575f0b 100644 --- a/libsframe/sframe.c +++ b/libsframe/sframe.c @@ -665,11 +665,15 @@ int32_t sframe_fre_get_ra_offset (sframe_decoder_ctx *dctx, sframe_frame_row_entry *fre, int *errp) { - sframe_header *dhp =3D sframe_decoder_get_header (dctx); - /* If the RA offset was not being tracked, return an error code so the c= aller - can gather the fixed RA offset from the SFrame header. */ - if (dhp->sfh_cfa_fixed_ra_offset !=3D SFRAME_CFA_FIXED_RA_INVALID) - return sframe_set_errno (errp, SFRAME_ERR_FREOFFSET_NOPRESENT); + int8_t ra_offset =3D sframe_decoder_get_fixed_ra_offset (dctx); + /* If the RA offset was not being tracked, return the fixed RA offset + from the SFrame header. */ + if (ra_offset !=3D SFRAME_CFA_FIXED_RA_INVALID) + { + if (errp) + *errp =3D 0; + return ra_offset; + } =20 /* Otherwise, get the RA offset from the FRE. */ return sframe_get_fre_offset (fre, SFRAME_FRE_RA_OFFSET_IDX, errp);