From patchwork Tue Jun 27 19:51:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 113569 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8435921vqr; Tue, 27 Jun 2023 12:54:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5i321+ndN/ylt6DNviC9OpkVYUmsEv8w5Dtqj24zyiOhgNB0IHMAaYl+UMMp+EwOVgJ7M7 X-Received: by 2002:aa7:ca55:0:b0:51d:9e0c:1396 with SMTP id j21-20020aa7ca55000000b0051d9e0c1396mr3654871edt.35.1687895651874; Tue, 27 Jun 2023 12:54:11 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ca25-20020aa7cd79000000b0051d9217d06dsi3265991edb.266.2023.06.27.12.54.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 12:54:11 -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=b4tNWqJF; 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 1D18D3856DC8 for ; Tue, 27 Jun 2023 19:53:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D18D3856DC8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687895596; 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=b4tNWqJF1AfXRRUL380o9plEeDs22FfoiAwA/y5+mwmlUF4NCxe62F9Fo5tq6cNKI p2yQ3A0VGaluUTq9gVankuFIwr0+VtKN65bU1tVTVgvw9apHhU8ewPgu00Gleway+R W412GLWyiZ7usx2DS3Wn+lRDHHSaMS0kiLHiZTpg= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id 527893858028 for ; Tue, 27 Jun 2023 19:52:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 527893858028 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35REPbGO015515 for ; Tue, 27 Jun 2023 19:52:01 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 3rds1u5sm7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 27 Jun 2023 19:51:59 +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 35RJjC6h038332 for ; Tue, 27 Jun 2023 19:51:57 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2174.outbound.protection.outlook.com [104.47.59.174]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpxbgh44-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 27 Jun 2023 19:51:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WxteiKTPnnbeMmyG/dnItcz8X1hny4Dl2KD3OA96U2JqIf5Jlu5nHMDwHVdD5Vgtpj6qNZm29m3vBWgs+Hl7/dldbNrOdmYajoneRZXakwVk3n7TbYN689bJxsLaXgUzUjNdByDBkAedkxMY20JWj1vhVU0PiTwhgS13ro3FPu2IwB4WI0Fase9mv+lMIpWxVz17DRHtXe7kSJnSUDw1B+U1Hy4MYsRr8AEtUZda0DrqNuQM1Zx2DaeV5FUciXZEM0QZl1y99rxMUW2EB5K/TRoYDaUilUcn0vntmWLg6bXtf/FRrusFOtWH3/7ZHZAPZYoDb1yA/J3z+D4Pr0nUDQ== 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=ULS5Hcq792vo1HZ4KXkJ2ELQlxdd8Du9RkntuR/h5rObaQRPK7EQz1uVfKrdGwlJ2bzPe6yXJPCABfOlFYH6fluilSPJWVXN2iqEwkl6TNGxtwjTpiqiJtk29AcMHIuhj+zwMVKx3bS6BXcVxch75ccURwtgW9p5OHSPuecLijvmWjc5KuriRLXwg/kV+KRHz5d+odPDWjwEvx8uvXho1xRFZBYyKMzfKOM7mvqx/YD9z81DvE2stQhGk4btGunDfMlLjzi2LB5JqTlskXl6fLCZqezfPqNfp4MYmW7WiOyDpA3r6O0CmGRB2wKOtXnn77emHLsi5Hq+MmDkvxfu6w== 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 BLAPR10MB5361.namprd10.prod.outlook.com (2603:10b6:208:325::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Tue, 27 Jun 2023 19:51:55 +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; Tue, 27 Jun 2023 19:51:55 +0000 To: binutils@sourceware.org Cc: Indu Bhagat Subject: [COMMITTED] libsframe: update the semantics of sframe_fre_get_ra_offset Date: Tue, 27 Jun 2023 12:51:18 -0700 Message-Id: <20230627195126.1955051-4-indu.bhagat@oracle.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230627195126.1955051-1-indu.bhagat@oracle.com> References: <20230627195126.1955051-1-indu.bhagat@oracle.com> X-ClientProxiedBy: MW4PR03CA0220.namprd03.prod.outlook.com (2603:10b6:303:b9::15) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR1001MB2158:EE_|BLAPR10MB5361:EE_ X-MS-Office365-Filtering-Correlation-Id: adcd631b-0d7b-43ff-5137-08db7747f584 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iVZbLa678ZtRqIKUQKs3ttDjjDgLcy/iHnpqvCqrd/8Rpg0teOlmKK2pHUVNS/sMNdfmWRLw/axEyexzZo+ipzUSIDq582bCunw+rb6nmSNqAC/TAWJEJYn0R7+g7bZnjLTl5fIN3WWVmTHRSHMOwygxUvHUceFvC1OqvAAk/oshLdcNMKnTrUZcLynyy0Uhd8YGu3XocBBB3aNGXgSM9SviIfqqT4k7JgR0CyK8v7UmU+Va9wLuk0cL2xpy7UyUHoPmwPoJYnUFXSq7uGBIrkmKibLaowX7yzHN6tCSAk3n9vGM+M7dNSIuei4yMla1GPMu31HXXcB1b34BriDU2NRgwK1pA2qyBA1Tl82SisLqB5ItujuWbdFPRF0RoDTGbRQiAAjuxv5eQkhdBT4Ms4lDHi+oYu3B1eKHMFWb5jmKEpAgKewkc3IbiKoghjVvlC96wz8im4Qc9oaemOE2zAtccWQLRMqoPp8ThWVyj4ZszkKy56RmTHUDICN10cBdFuSGehOyY9SkfClQZGCYpJ7VCOPGd/a0uvC0+bNHlO4Kl+T3QTOVPZo9oahT4qh4 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)(376002)(346002)(39860400002)(396003)(366004)(136003)(451199021)(1076003)(107886003)(6486002)(83380400001)(6666004)(26005)(2906002)(2616005)(6512007)(6506007)(478600001)(186003)(5660300002)(44832011)(36756003)(38100700002)(316002)(4326008)(66946007)(66476007)(41300700001)(8936002)(8676002)(66556008)(86362001)(6916009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rYdWkQt0FY3hLMgEJCmsxbr04unudbIaJVRefOP20n5xFIS8O5KdjsFJhU5doEnxe9nvy1Wwbe7Le4ZHsgVrdvrFTtAFf7+2QLEM8qamhzESI1cqhCx3klubv2GLd0m9eyG7pS3ErWWqALrKNZfe3A1yUmTSgDfqM7RpsQJ474LBEAuxiUnpUz8RlNwt+JRsk5AWVbEqoJau1dK2BiX4esJ4DOp2vCpeXG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KwbFJaThz4ydSZnXnA3Q9elhi78585ZXd1vmzJ3r85OOZumMciXPf2mivchR1mWIcK43ffkPgJQ10tR2+oet2Qnsl7XzP5a9ezSalJF5A1X+inUycrIYF8LXJO4feyrZBAlGmDZwncNcST08/dTOzJJ7WE0eSmtU0tFQDTbOPcSSKRwCa+TkykFXxpdJtqRCW6BJqDRSwCmZzPZedlXfB118itlAF7VIMns6oc6qXcLeFZPiHiaqclOAloH9jwFdyWHSGP/M3XKTQvRnVTrpid08XTN14h5j4neisDNO X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ABd2BEkwRu64lWcrgAHlEo7+a3XqOxZW1NzOYynygRjwRXm0VDQckLaNuOFDKpN4k0+Zt/LPCvJHqiub4mUuscv1Epe69Wos0eFZ4rXeblxjnTV4UdDAI2UgT4uUbrfyA/EG1GXAFv9jM8r3Hwd4GymYnuREEVVIcGzeFaI3O80gDaI5YRn/eL96GJJAnnZZfyJsXDdoejMjsIyZPJojTL7X9VtGmGJMdbPsXfUL/IebGimCaDCdbRf3t08uRZ0E6h+j9dvp4zENuOGXZ0wjk9vHB9zhLyGWP47964fqXFHK3QkjFRzgY4qm/wCax8oxiXV9kM1JFg+utr2VU8ethmW6iBLMd1nXBf4+AQuAB+dPTl1IxdjuEackZtp6xH2VvqU/9i/jH0MEgZjRhAohzZ48VMonz4wVOXQPPM+Glv/um/0DrwNijuQR/wEISt9gAKJrxq5UrZve5xqsF676xgQukADI9dY0GQDUiuL5LRFvOIGv75RBvkyguRbyRu1IOtI+xBKmpXQQ6uvEL3wFIwS8XgJHVC+QuiNXqF+LcAoqhai50qKmTd40XSYDLJSETHFC0hj2sIXJMQ/kiORn0ZhHqF0AarwFRgtPCFynBOAQee8ikrd/J5jDrcNOnnjOtjgDr7jnDQk6hGm33FsPZbdwS+SWAdAm4DdyxniYreF2XAorFRswMnlCym79H8IlGCWPR0SWKRxNCzHMj1fnza02hSLJv7l9IDvzvWdIRuRl/7WZpcGTcOqeOJzPvfew X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: adcd631b-0d7b-43ff-5137-08db7747f584 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2023 19:51:55.1218 (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: lfEpxS+N71zU891q37HI0xwQDKMT2i0eKxsQCFaTnQnFDDFIZuZiMlcfRiWMbcYdcxvQ/XskaXl1Ej51osq30g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLAPR10MB5361 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-27_14,2023-06-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 mlxlogscore=854 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306270180 X-Proofpoint-GUID: ADZSXKeGlF1dEFxOTf2g5rGOIAUYGpKH X-Proofpoint-ORIG-GUID: ADZSXKeGlF1dEFxOTf2g5rGOIAUYGpKH X-Spam-Status: No, score=-13.2 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?1769886871339609972?= X-GMAIL-MSGID: =?utf-8?q?1769886871339609972?= 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);