From patchwork Fri Jun 23 04:44:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 111913 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5528012vqr; Thu, 22 Jun 2023 21:48:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7gU3CUYoPsslhO4KUU3L8Jm3D6TYP9VPqEGgtXxcz4sp5FCamm4tLMSrgrqluFmygYJ5sV X-Received: by 2002:a17:907:1ca8:b0:973:84b0:b077 with SMTP id nb40-20020a1709071ca800b0097384b0b077mr19662337ejc.33.1687495679780; Thu, 22 Jun 2023 21:47:59 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id j11-20020a170906474b00b00988a5cdbfa7si4397335ejs.889.2023.06.22.21.47.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 21:47:59 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=dhe5mIJf; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1333D38323FF for ; Fri, 23 Jun 2023 04:46:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1333D38323FF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687495580; bh=1Wa0C5PMcZWx0bM17a6QcGGrSwg7A2239F45hmXPOVQ=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=dhe5mIJfJjPCI3y9AXHGSkKnGV2Il+eojzzBKIzVcQAqlZbXxiSXowTjMKYZWMmqp 1rJlBchBRPiV1AxE6TeY5bfAxQI8SJKPAR91KaDiVHsX2+lMvlZBIlcc0M3g5+pfEd TZWDs3Qe22nKQtGl1UomSVwgPLzD37y5VzKjq1do= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by sourceware.org (Postfix) with ESMTPS id D28623858017 for ; Fri, 23 Jun 2023 04:45:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D28623858017 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35N4KsKi019475 for ; Fri, 23 Jun 2023 04:45:10 GMT Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3r938du514-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 23 Jun 2023 04:45:10 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35N22jfH005923 for ; Fri, 23 Jun 2023 04:45:09 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2046.outbound.protection.outlook.com [104.47.66.46]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3r93989cmm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 23 Jun 2023 04:45:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XL92CTFpL9eyXdfgYSwLftjDDWR9/xytJmnaZAD0goEkOdRXzuzL7yr+pabG5fWSQeaioI338hy0pI3Ub1S/WfJWBRnW5f04FbqZcD0+THybwXcZSIuHYLF6HvHZynnetaqnb4iilcCpx5BYamCIDAa2wD95S5ksyKJ+mQ1uH26NZhLgraMzdhqK7FnEsS3m2kf5icEf8npBd07fJBLeysCoI9L0nyTOi0tQqX3B7dK0X5v05YYRegBAp7UvlglvlDE0/rwwoH8wnspg8XhDkXbWnu2iqTfG4nHPJ9ZSaH7fZJF31CKRVHS8NpoFyYCTodykxw3aDj96c4+TsA9Yzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1Wa0C5PMcZWx0bM17a6QcGGrSwg7A2239F45hmXPOVQ=; b=DyY++dDswRZSBiwvWIM0c05iEC+ImnoiRaYZ7pxD3o41GTJlD0SdS2lhp/P+aZcDx/fhgBMRZqsLSn2iyH+Za356f/Y+QtuA6h8kwK3zxWls27nmAbgfVLwvgpVWHIw+2uzAJEfRHEmJlAJuMbcJiXL2diDEH9pI1L7CMDpfvn+RGRWsVBBGoxRUv+cbqCIJA1Tc5HPf573Zgk6dz1A0x25UDdA7Km7RtND69hE1N03fLvY3227IV3mbgu1o7ZWqitQXNOj4oPvLPNTTu2dYATYIesm5uk3BDbP+xH+tSaHUKSQtPKztCk7ow5CLbYXNMnjMoCb3YsGOcd2vsMiJPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none Received: from MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) by DM4PR10MB5966.namprd10.prod.outlook.com (2603:10b6:8:b2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.24; Fri, 23 Jun 2023 04:45:07 +0000 Received: from MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::fdbb:b921:1ef:2d44]) by MWHPR1001MB2158.namprd10.prod.outlook.com ([fe80::fdbb:b921:1ef:2d44%4]) with mapi id 15.20.6521.026; Fri, 23 Jun 2023 04:45:07 +0000 To: binutils@sourceware.org Cc: Indu Bhagat Subject: [PATCH 04/10] libsframe: update the semantics of sframe_fre_get_ra_offset Date: Thu, 22 Jun 2023 21:44:42 -0700 Message-Id: <20230623044448.2617101-5-indu.bhagat@oracle.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230623044448.2617101-1-indu.bhagat@oracle.com> References: <20230623044448.2617101-1-indu.bhagat@oracle.com> X-ClientProxiedBy: MW4PR04CA0090.namprd04.prod.outlook.com (2603:10b6:303:6b::35) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR1001MB2158:EE_|DM4PR10MB5966:EE_ X-MS-Office365-Filtering-Correlation-Id: 908d3ecd-1acc-4bb0-6636-08db73a49e42 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r5SILXHZhpLRbM4qZy8jxWR1eMcjYb2JUSH/UVTvwXVbgES4Iq+Jp+Zzhng8kZOJVxwmtwQB7Q87xiRZmQiXfy/mg4W5q30tRHryj5X+BWrliktSZLyhwQJ8O6/g4++GesSiiddaGclHsCePCJxdA1R1tlOlDBnVWTR1s2r7bwedQvET5OWvAfXoD55rsh+06IbZyrsb0ugiAj7XPYeB1/65izL8xbyWPlieJXwRmV8613zsxoy5Rer8jsi0g9DT4aUVeQ6LC/JEwo+9CNOi9YwRSTh8naYUQzOXfJwl2Mhgpau5uWpFaJI0NYIBNtKQRAX372zaeaTAWQ8FI6OGA3boI6d6gkhZYRbHzpiJsgsbR/NIxajDCQ6v8jNbuaUuTpKRvtBD1uibKYFKM5zArkvuVUzWJSOIF4vqcE2AT5rHxoX3aljgJv2qYRzXSoIpQOJ+40EHuUSFdAOoSG5E7szWrdp0+1gKrbG0lwZUueimzRqIvyw+ZFfsKO69b+BEL4iKMbBe1mWTiuVEyK3HBtD2XgvFUny1d4VVvLcOkXR5WLsCkW5XhduNaCHRRLKg X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2158.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(396003)(136003)(346002)(366004)(39860400002)(376002)(451199021)(2906002)(478600001)(38100700002)(2616005)(36756003)(6666004)(5660300002)(6486002)(66946007)(66556008)(66476007)(83380400001)(316002)(6916009)(86362001)(41300700001)(44832011)(8936002)(8676002)(4326008)(6506007)(6512007)(1076003)(107886003)(186003)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5vGN43g8CzDWcmbhBwQrMkIFbtPUs7NS7qRAEoT8VXkFWyNvNVbkerrpVUJvlP0/HwVQtKbsNwi2Ed32028IiKN6yRqnOU0fa98DskcdiPYQUTteFfr2n6ubyfRIlOjy9vldv0g1HiOARf7haSsq3N/ZvC2jdTRxTWCd6xmgPuz6jt+rFfELNl2p9I3zDWZcf4YH2Li0vIGfBE7twyc+7h89Bhkv7R7PvQu6U+yt1oW065Q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7Z1tsD2Xh/nKBLzWxftrq6f1ZnWqLF1tRP78NkBRo4rNFsNd6wt7 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 908d3ecd-1acc-4bb0-6636-08db73a49e42 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jun 2023 04:45:07.1153 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Dy7lXEk4oZouQ/njgRzKk3moY6BDkYM52S4PmWyzmaDFbO41+LKOKycw9TTxn0glRfC5ukuNlQkjQ48kPAsgxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB5966 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-23_02,2023-06-22_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=853 adultscore=0 spamscore=0 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306230041 X-Proofpoint-GUID: doq-_xw8mrhW_VKLdVOABJhFMZF7QCxu X-Proofpoint-ORIG-GUID: doq-_xw8mrhW_VKLdVOABJhFMZF7QCxu X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Indu Bhagat via Binutils From: Indu Bhagat Reply-To: Indu Bhagat Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769467470057909452?= X-GMAIL-MSGID: =?utf-8?q?1769467470057909452?= 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. 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. 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: STARTPC CFA FP RA 000000000000NNNN sp+X u u 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. 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. --- 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_ctx, strcpy (temp, "u"); printf ("%-10s", temp); - /* Dump RA info. */ - if (err[2] == 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) + != SFRAME_CFA_FIXED_RA_INVALID) strcpy (temp, "u"); + else if (err[2] == 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 = sframe_decoder_get_header (dctx); - /* If the RA offset was not being tracked, return an error code so the caller - can gather the fixed RA offset from the SFrame header. */ - if (dhp->sfh_cfa_fixed_ra_offset != SFRAME_CFA_FIXED_RA_INVALID) - return sframe_set_errno (errp, SFRAME_ERR_FREOFFSET_NOPRESENT); + int8_t ra_offset = 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 != SFRAME_CFA_FIXED_RA_INVALID) + { + if (errp) + *errp = 0; + return ra_offset; + } /* Otherwise, get the RA offset from the FRE. */ return sframe_get_fre_offset (fre, SFRAME_FRE_RA_OFFSET_IDX, errp);