From patchwork Thu May 18 06:20:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Indu Bhagat X-Patchwork-Id: 95668 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp274399vqo; Wed, 17 May 2023 23:20:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5TUvVyo6jKueM+bQPqjrYAZlJNJVa7jkycgjqDLcOsGY4LM7jIgpJZAA7nLlHWFA+V7rAI X-Received: by 2002:a17:906:730b:b0:96f:1f69:3d8f with SMTP id di11-20020a170906730b00b0096f1f693d8fmr1960506ejc.35.1684390854943; Wed, 17 May 2023 23:20:54 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id k12-20020a1709065fcc00b0096b5c43d44csi770241ejv.833.2023.05.17.23.20.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 May 2023 23:20:54 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="PvnClW/r"; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 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 B6FE43853570 for ; Thu, 18 May 2023 06:20:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B6FE43853570 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684390852; bh=Qwd9GDbg5OFcD37yGZUX8LlhWxI/wglT15iRiFagdQU=; 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=PvnClW/rph68h4+iczgZPBCHrvZWtePGCxSbFpa6iSa9ANhb+2A5uOvrnEqQVNBx+ G8q1K7sZ0iq0PoevZFxHRSHaEsHuj3aTETwTC3r7tPsql937VMwbRIIOB0DuwNUl92 Zm6fRQU6uiBygkxpKPn8Mm1CnbTzQYoYbBaK6BHI= 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 A8DAD3858434 for ; Thu, 18 May 2023 06:20:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A8DAD3858434 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34I6Iv4V012574 for ; Thu, 18 May 2023 06:20:42 GMT Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3qj2kdqkv7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 18 May 2023 06:20:42 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 34I5DMwe033915 for ; Thu, 18 May 2023 06:20:41 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3qj106v0tg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 18 May 2023 06:20:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B3AI1Tp4Ru0FFStLmdX7gk8wwX0BniUMQf6VDvMq1dHogmAMkMbFO9psjzukO+v8Bcs6liO2v+ww97ges4KDTGEtAMzfQewwoyit33S5gi2wp4o37jAhYnZJf3VIWppgxywgf5NxcyqHTZoWCqO+qbvtzN9Axn3oJiKoW6Q1BmaGp65hkhZaESbk1Zwpy50/Wbykz+/OTHGnDALSu95gVVKidhSEUXIF3DiWJLBvijxiIVJZfii5YGjUhS5zrzRLu0+uqihxQ6ahydf+et++AeizV/tpHOi59njAkE6/BsTdd1XLIUKwJOHlh40r9UtcbkOsWm6BJnc7U4pRZut6gQ== 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=Qwd9GDbg5OFcD37yGZUX8LlhWxI/wglT15iRiFagdQU=; b=SVJqMdtzd3XKnutvWm/FJf3IiCy9phTNMR8RfI0sHuXYjKF3KUgXslR83iMMzgdyqYdvnK/I5MZKIynnumhJWSjd5HUm8cbFWb0zzNDC4NLzZ3uncvTmxCYCQL+Grbphg95fcdxSf+0+WawChC7qWNT3mLFAdLsyOgfUsqfNgXcynNxwKKWfDlfPME9tAPe3goYh5pSO1jUM4HZB+AmStF+29mJ5jdfSjyJmry4V7sQfQIMq9ni7wXbWzMOu12uid3LNObHFzjU9ltV7wsPQYouGOuRTzBXWD+5U+Fapvrmkkkhb/LdczXdPK7DNV6rtsz5B4V26lo/ccLdoA2WBdA== 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 DS7PR10MB4877.namprd10.prod.outlook.com (2603:10b6:5:3a3::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6411.19; Thu, 18 May 2023 06:20:38 +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.6387.019; Thu, 18 May 2023 06:20:38 +0000 To: binutils@sourceware.org Cc: Indu Bhagat Subject: [COMMITTED] libsframe: testsuite: add tests for sframe_get_funcdesc_with_addr API Date: Wed, 17 May 2023 23:20:25 -0700 Message-Id: <20230518062025.1535847-2-indu.bhagat@oracle.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230518062025.1535847-1-indu.bhagat@oracle.com> References: <20230518062025.1535847-1-indu.bhagat@oracle.com> X-ClientProxiedBy: MW4PR03CA0311.namprd03.prod.outlook.com (2603:10b6:303:dd::16) To MWHPR1001MB2158.namprd10.prod.outlook.com (2603:10b6:301:2d::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWHPR1001MB2158:EE_|DS7PR10MB4877:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b887a94-22c2-4215-8972-08db5767ff7e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W2P5nk9CNYgnPUXahWuRQcE8a8PLFySBSo2zc2KhBXJct5ptdjie1+MROuhh48AGeETZptfi+lsaT1EQeOsq9P1J6cyY6cngp8ZPnpnQj2Y0bKg2FtPoqymJaPk+a/LKFfEKpaB2kAlnBLONdqpTsyZ4z74Wxp+c6/07GOcfDQo3TGzkAzCfNlDd8qw0kVEB9cHD7/QmOqwUGG66qEbRYcoSBOl9heRTKbCSElFotSWWfGqDNKkgxnWYyvts3Q6YffPcoTVv0YzHIGQ58O1Q5P4itvHD2+5VH3EvE4Yz/DTFOqf7w2F/T+Mfm8d+T2CY2XTLx5uXwDUgqNpldHv3B8allnIfwnHKSUr4X8cPjDr6BbDnFZxI6pLGAuG5zc7OKqr9WoFw624EgH+Qyv7YUA+oKYQVtcEkLqeB6EoXjw4MUpqsgy3LCEN3C2TlTScY46y1PrdyTEsKwjSOpJKIU8lxq76ypCuKZd+TVe5BB3WHWayPjiwB5U+zyLnXRkyZ+BIfrW55HqZ6vSZ2Ro9KoegTqcctUFNjrdlIpmrXvgWD/AL3xMkTD/a+jv48Qx94U/Oq1k+oYrUTssf6kq6dHiZSV17WZ73qNXnWvFfpU6s= 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)(376002)(346002)(39860400002)(136003)(366004)(451199021)(107886003)(6486002)(2616005)(36756003)(83380400001)(6512007)(6506007)(1076003)(38100700002)(186003)(316002)(478600001)(2906002)(30864003)(66556008)(66476007)(5660300002)(66946007)(6916009)(4326008)(8676002)(8936002)(86362001)(44832011)(41300700001)(6666004)(2004002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bWbDsaV4Gh1eFBnQoTq32Shb77MnsFpHwSwgLA148JeVVBxJ63EXepWqxlwS4y2Dwr9/3uKgAdKTDAyZQPPv3PI9nVvHq1+2u814kVYV7T0ffAGoDAxwqd97UNTdVm+HK72nkp5xIodKHPBSSOzu0YP6goL8nnVNV+ImOOu/EzlTrFbCut1ONwSDtAZw1JQ1v9+/8M9OgAbTY00Rud284IovVeDzElmb6DwIlhDAyaI9YwfBGy1vktcMOg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WzSfuMeJ6CvZ1wVP8HFgOrEVqbhyuOQwCHkMmYZrQISbLI0Eo9f8icbzT4unsQCSYv X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b887a94-22c2-4215-8972-08db5767ff7e X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2158.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2023 06:20:38.4717 (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: J2HrnbDzZLU6Dl8fp3FwOcGL67KqOn6UplWYALb8N2Fke6n44Dgmbku0Z8pzuRMe55u7y4cB5zZsc2pLygMwBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR10MB4877 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-18_04,2023-05-17_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 phishscore=0 spamscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305180047 X-Proofpoint-GUID: 4pKEJwiLiklBzwrWSPZx6dOVk-KI4aJm X-Proofpoint-ORIG-GUID: 4pKEJwiLiklBzwrWSPZx6dOVk-KI4aJm 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, KAM_SHORT, RCVD_IN_DNSWL_LOW, 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?1766211825256225626?= X-GMAIL-MSGID: =?utf-8?q?1766211825256225626?= sframe_get_funcdesc_with_addr API is currently used internally by the sframe_find_fre (). In this test, we create three dummy SFrame FDEs with 4 FREs each. Then, we use few negative tests to lookup FREs with PCs not in the range of PCs covered by the FDEs, ensuring graceful return from sframe_get_funcdesc_with_addr in all cases. Some positive tests are also added that exercise further scenarios as well. libsframe/ * Makefile.in: Regenerated. * testsuite/libsframe.find/find.exp: Include new test. * testsuite/libsframe.find/findfunc-1.c: New Test. * testsuite/libsframe.find/local.mk: Include new test. --- libsframe/Makefile.in | 42 +++- libsframe/testsuite/libsframe.find/find.exp | 5 + .../testsuite/libsframe.find/findfunc-1.c | 204 ++++++++++++++++++ libsframe/testsuite/libsframe.find/local.mk | 6 +- 4 files changed, 252 insertions(+), 5 deletions(-) create mode 100644 libsframe/testsuite/libsframe.find/findfunc-1.c diff --git a/libsframe/Makefile.in b/libsframe/Makefile.in index 2ef60de3f90..405bc04263d 100644 --- a/libsframe/Makefile.in +++ b/libsframe/Makefile.in @@ -115,7 +115,8 @@ check_PROGRAMS = $(am__EXEEXT_1) @HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.decode/frecnt-1 \ @HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.decode/frecnt-2 \ @HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.encode/encode-1 \ -@HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.find/findfre-1 +@HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.find/findfre-1 \ +@HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.find/findfunc-1 subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \ @@ -184,7 +185,8 @@ am__v_lt_1 = @HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.decode/frecnt-1$(EXEEXT) \ @HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.decode/frecnt-2$(EXEEXT) \ @HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.encode/encode-1$(EXEEXT) \ -@HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.find/findfre-1$(EXEEXT) +@HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.find/findfre-1$(EXEEXT) \ +@HAVE_COMPAT_DEJAGNU_TRUE@ testsuite/libsframe.find/findfunc-1$(EXEEXT) am__dirstamp = $(am__leading_dot)dirstamp am_testsuite_libsframe_decode_be_flipping_OBJECTS = testsuite/libsframe.decode/testsuite_libsframe_decode_be_flipping-be-flipping.$(OBJEXT) testsuite_libsframe_decode_be_flipping_OBJECTS = \ @@ -211,6 +213,11 @@ testsuite_libsframe_find_findfre_1_OBJECTS = \ $(am_testsuite_libsframe_find_findfre_1_OBJECTS) testsuite_libsframe_find_findfre_1_DEPENDENCIES = \ ${top_builddir}/libsframe.la +am_testsuite_libsframe_find_findfunc_1_OBJECTS = testsuite/libsframe.find/testsuite_libsframe_find_findfunc_1-findfunc-1.$(OBJEXT) +testsuite_libsframe_find_findfunc_1_OBJECTS = \ + $(am_testsuite_libsframe_find_findfunc_1_OBJECTS) +testsuite_libsframe_find_findfunc_1_DEPENDENCIES = \ + ${top_builddir}/libsframe.la AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -250,13 +257,15 @@ SOURCES = $(libsframe_la_SOURCES) \ $(testsuite_libsframe_decode_frecnt_1_SOURCES) \ $(testsuite_libsframe_decode_frecnt_2_SOURCES) \ $(testsuite_libsframe_encode_encode_1_SOURCES) \ - $(testsuite_libsframe_find_findfre_1_SOURCES) + $(testsuite_libsframe_find_findfre_1_SOURCES) \ + $(testsuite_libsframe_find_findfunc_1_SOURCES) DIST_SOURCES = $(libsframe_la_SOURCES) \ $(testsuite_libsframe_decode_be_flipping_SOURCES) \ $(testsuite_libsframe_decode_frecnt_1_SOURCES) \ $(testsuite_libsframe_decode_frecnt_2_SOURCES) \ $(testsuite_libsframe_encode_encode_1_SOURCES) \ - $(testsuite_libsframe_find_findfre_1_SOURCES) + $(testsuite_libsframe_find_findfre_1_SOURCES) \ + $(testsuite_libsframe_find_findfunc_1_SOURCES) AM_V_DVIPS = $(am__v_DVIPS_@AM_V@) am__v_DVIPS_ = $(am__v_DVIPS_@AM_DEFAULT_V@) am__v_DVIPS_0 = @echo " DVIPS " $@; @@ -528,6 +537,9 @@ testsuite_libsframe_encode_encode_1_CPPFLAGS = -I${top_srcdir}/../include -Wall testsuite_libsframe_find_findfre_1_SOURCES = testsuite/libsframe.find/findfre-1.c testsuite_libsframe_find_findfre_1_LDADD = ${top_builddir}/libsframe.la testsuite_libsframe_find_findfre_1_CPPFLAGS = -I${top_srcdir}/../include -Wall +testsuite_libsframe_find_findfunc_1_SOURCES = testsuite/libsframe.find/findfunc-1.c +testsuite_libsframe_find_findfunc_1_LDADD = ${top_builddir}/libsframe.la +testsuite_libsframe_find_findfunc_1_CPPFLAGS = -I${top_srcdir}/../include -Wall all: config.h $(MAKE) $(AM_MAKEFLAGS) all-am @@ -693,6 +705,13 @@ testsuite/libsframe.find/testsuite_libsframe_find_findfre_1-findfre-1.$(OBJEXT): testsuite/libsframe.find/findfre-1$(EXEEXT): $(testsuite_libsframe_find_findfre_1_OBJECTS) $(testsuite_libsframe_find_findfre_1_DEPENDENCIES) $(EXTRA_testsuite_libsframe_find_findfre_1_DEPENDENCIES) testsuite/libsframe.find/$(am__dirstamp) @rm -f testsuite/libsframe.find/findfre-1$(EXEEXT) $(AM_V_CCLD)$(LINK) $(testsuite_libsframe_find_findfre_1_OBJECTS) $(testsuite_libsframe_find_findfre_1_LDADD) $(LIBS) +testsuite/libsframe.find/testsuite_libsframe_find_findfunc_1-findfunc-1.$(OBJEXT): \ + testsuite/libsframe.find/$(am__dirstamp) \ + testsuite/libsframe.find/$(DEPDIR)/$(am__dirstamp) + +testsuite/libsframe.find/findfunc-1$(EXEEXT): $(testsuite_libsframe_find_findfunc_1_OBJECTS) $(testsuite_libsframe_find_findfunc_1_DEPENDENCIES) $(EXTRA_testsuite_libsframe_find_findfunc_1_DEPENDENCIES) testsuite/libsframe.find/$(am__dirstamp) + @rm -f testsuite/libsframe.find/findfunc-1$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(testsuite_libsframe_find_findfunc_1_OBJECTS) $(testsuite_libsframe_find_findfunc_1_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -711,6 +730,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@testsuite/libsframe.decode/$(DEPDIR)/testsuite_libsframe_decode_frecnt_2-frecnt-2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@testsuite/libsframe.encode/$(DEPDIR)/testsuite_libsframe_encode_encode_1-encode-1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@testsuite/libsframe.find/$(DEPDIR)/testsuite_libsframe_find_findfre_1-findfre-1.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@testsuite/libsframe.find/$(DEPDIR)/testsuite_libsframe_find_findfunc_1-findfunc-1.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @@ -827,6 +847,20 @@ testsuite/libsframe.find/testsuite_libsframe_find_findfre_1-findfre-1.obj: tests @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testsuite_libsframe_find_findfre_1_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o testsuite/libsframe.find/testsuite_libsframe_find_findfre_1-findfre-1.obj `if test -f 'testsuite/libsframe.find/findfre-1.c'; then $(CYGPATH_W) 'testsuite/libsframe.find/findfre-1.c'; else $(CYGPATH_W) '$(srcdir)/testsuite/libsframe.find/findfre-1.c'; fi` +testsuite/libsframe.find/testsuite_libsframe_find_findfunc_1-findfunc-1.o: testsuite/libsframe.find/findfunc-1.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testsuite_libsframe_find_findfunc_1_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT testsuite/libsframe.find/testsuite_libsframe_find_findfunc_1-findfunc-1.o -MD -MP -MF testsuite/libsframe.find/$(DEPDIR)/testsuite_libsframe_find_findfunc_1-findfunc-1.Tpo -c -o testsuite/libsframe.find/testsuite_libsframe_find_findfunc_1-findfunc-1.o `test -f 'testsuite/libsframe.find/findfunc-1.c' || echo '$(srcdir)/'`testsuite/libsframe.find/findfunc-1.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) testsuite/libsframe.find/$(DEPDIR)/testsuite_libsframe_find_findfunc_1-findfunc-1.Tpo testsuite/libsframe.find/$(DEPDIR)/testsuite_libsframe_find_findfunc_1-findfunc-1.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='testsuite/libsframe.find/findfunc-1.c' object='testsuite/libsframe.find/testsuite_libsframe_find_findfunc_1-findfunc-1.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testsuite_libsframe_find_findfunc_1_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o testsuite/libsframe.find/testsuite_libsframe_find_findfunc_1-findfunc-1.o `test -f 'testsuite/libsframe.find/findfunc-1.c' || echo '$(srcdir)/'`testsuite/libsframe.find/findfunc-1.c + +testsuite/libsframe.find/testsuite_libsframe_find_findfunc_1-findfunc-1.obj: testsuite/libsframe.find/findfunc-1.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testsuite_libsframe_find_findfunc_1_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT testsuite/libsframe.find/testsuite_libsframe_find_findfunc_1-findfunc-1.obj -MD -MP -MF testsuite/libsframe.find/$(DEPDIR)/testsuite_libsframe_find_findfunc_1-findfunc-1.Tpo -c -o testsuite/libsframe.find/testsuite_libsframe_find_findfunc_1-findfunc-1.obj `if test -f 'testsuite/libsframe.find/findfunc-1.c'; then $(CYGPATH_W) 'testsuite/libsframe.find/findfunc-1.c'; else $(CYGPATH_W) '$(srcdir)/testsuite/libsframe.find/findfunc-1.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) testsuite/libsframe.find/$(DEPDIR)/testsuite_libsframe_find_findfunc_1-findfunc-1.Tpo testsuite/libsframe.find/$(DEPDIR)/testsuite_libsframe_find_findfunc_1-findfunc-1.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='testsuite/libsframe.find/findfunc-1.c' object='testsuite/libsframe.find/testsuite_libsframe_find_findfunc_1-findfunc-1.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(testsuite_libsframe_find_findfunc_1_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o testsuite/libsframe.find/testsuite_libsframe_find_findfunc_1-findfunc-1.obj `if test -f 'testsuite/libsframe.find/findfunc-1.c'; then $(CYGPATH_W) 'testsuite/libsframe.find/findfunc-1.c'; else $(CYGPATH_W) '$(srcdir)/testsuite/libsframe.find/findfunc-1.c'; fi` + mostlyclean-libtool: -rm -f *.lo diff --git a/libsframe/testsuite/libsframe.find/find.exp b/libsframe/testsuite/libsframe.find/find.exp index 463d94ab6c9..05ac02ba60b 100644 --- a/libsframe/testsuite/libsframe.find/find.exp +++ b/libsframe/testsuite/libsframe.find/find.exp @@ -24,9 +24,14 @@ load_lib dejagnu.exp if [string equal $COMPAT_DEJAGNU "no"] { verbose -log "SFrame testsuite needs perhaps a more recent DejaGnu" unsupported findfre-1 + unsupported findfunc-1 return; } if { [host_execute "testsuite/libsframe.find/findfre-1"] ne "" } { fail "findfre-1" } + +if { [host_execute "testsuite/libsframe.find/findfunc-1"] ne "" } { + fail "findfunc-1" +} diff --git a/libsframe/testsuite/libsframe.find/findfunc-1.c b/libsframe/testsuite/libsframe.find/findfunc-1.c new file mode 100644 index 00000000000..292e8185600 --- /dev/null +++ b/libsframe/testsuite/libsframe.find/findfunc-1.c @@ -0,0 +1,204 @@ +/* findfunc-1.c -- Test for sframe_get_funcdesc_with_addr in libsframe. + + Copyright (C) 2023 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* sframe_get_funcdesc_with_addr is a core API in the libsframe library, which + is used to find an FDE given a PC. It is used by sframe_find_fre (). The + latter is the mainstay for an SFrame based stack tracer. + + The tests in here stress the sframe_get_funcdesc_with_addr API via calls to + the sframe_find_fre (). */ + +#include "config.h" + +#include +#include +#include + +#include "sframe-api.h" + +/* DejaGnu should not use gnulib's vsnprintf replacement here. */ +#undef vsnprintf +#include + +static int +add_fde1 (sframe_encoder_ctx *encode, int idx) +{ + int i, err; + /* A contiguous block containing 4 FREs. */ + sframe_frame_row_entry fres[] + = { {0x0, {0x1, 0, 0}, 0x3}, + {0x1, {0x2, 0xf0, 0}, 0x5}, + {0x10, {0x3, 0xf0, 0}, 0x4}, + {0x38, {0x8, 0xf0, 0}, 0x5} + }; + + unsigned char finfo = sframe_fde_create_func_info (SFRAME_FRE_TYPE_ADDR1, + SFRAME_FDE_TYPE_PCINC); + err = sframe_encoder_add_funcdesc (encode, 0xfffff03e, 0x40, finfo, 4); + if (err == -1) + return err; + + for (i = 0; i < 4; i++) + if (sframe_encoder_add_fre (encode, idx,fres+i) == SFRAME_ERR) + return -1; + + return 0; +} + +static int +add_fde2 (sframe_encoder_ctx *encode, int idx) +{ + int i, err; + /* A contiguous block containing 4 FREs. */ + sframe_frame_row_entry fres[] + = { {0x0, {0x10, 0, 0}, 0x3}, + {0x10, {0x12, 0xf0, 0}, 0x5}, + {0x14, {0x14, 0xf0, 0}, 0x4}, + {0x20, {0x15, 0xf0, 0}, 0x5} + }; + + unsigned char finfo = sframe_fde_create_func_info (SFRAME_FRE_TYPE_ADDR1, + SFRAME_FDE_TYPE_PCINC); + err = sframe_encoder_add_funcdesc (encode, 0xfffff08e, 0x60, finfo, 4); + if (err == -1) + return err; + + for (i = 0; i < 4; i++) + if (sframe_encoder_add_fre (encode, idx, fres+i) == SFRAME_ERR) + return -1; + + return 0; +} + +static int +add_fde3 (sframe_encoder_ctx *encode, int idx) +{ + int i, err; + /* A contiguous block containing 4 FREs. */ + sframe_frame_row_entry fres[] + = { {0x0, {0x16, 0, 0}, 0x3}, + {0x1, {0x17, 0xf0, 0}, 0x5}, + {0x10, {0x18, 0xf0, 0}, 0x4}, + {0x38, {0x19, 0xf0, 0}, 0x5} + }; + + unsigned char finfo = sframe_fde_create_func_info (SFRAME_FRE_TYPE_ADDR1, + SFRAME_FDE_TYPE_PCINC); + err = sframe_encoder_add_funcdesc (encode, 0xfffff10e, 0x40, finfo, 4); + if (err == -1) + return err; + + for (i = 0; i < 4; i++) + if (sframe_encoder_add_fre (encode, idx,fres+i) == SFRAME_ERR) + return -1; + + return 0; +} + +int main (void) +{ + sframe_encoder_ctx *encode; + sframe_decoder_ctx *dctx; + sframe_frame_row_entry frep; + char *sframe_buf; + size_t sf_size; + int err = 0; + unsigned int fde_cnt = 0; + +#define TEST(name, cond) \ + do \ + { \ + if (cond) \ + pass (name); \ + else \ + fail (name); \ + } \ + while (0) + + encode = sframe_encode (SFRAME_VERSION, 0, + SFRAME_ABI_AMD64_ENDIAN_LITTLE, + SFRAME_CFA_FIXED_FP_INVALID, + -8, /* Fixed RA offset for AMD64. */ + &err); + + /* Add FDE at index 0. */ + err = add_fde1 (encode, 0); + TEST ("findfunc-1: Adding FDE1", err == 0); + + /* Add FDE at index 1. */ + err = add_fde2 (encode, 1); + TEST ("findfunc-1: Adding FDE2", err == 0); + + /* Add FDE at index 2. */ + err = add_fde3 (encode, 2); + TEST ("findfunc-1: Adding FDE3", err == 0); + + fde_cnt = sframe_encoder_get_num_fidx (encode); + TEST ("findfunc-1: Test FDE count", fde_cnt == 3); + + sframe_buf = sframe_encoder_write (encode, &sf_size, &err); + TEST ("findfunc-1: Encoder write", err == 0); + + dctx = sframe_decode (sframe_buf, sf_size, &err); + TEST("findfunc-1: Decoder setup", dctx != NULL); + + /* Following negative tests check that libsframe APIs + (sframe_get_funcdesc_with_addr, sframe_find_fre) work + well for PCs not covered by the FDEs. */ + + /* Search with PC less than the first FDE's start addr. */ + err = sframe_find_fre (dctx, (0xfffff03e - 0x15), &frep); + TEST("findfunc-1: test-1: Find FRE for PC not in range", + (err == SFRAME_ERR)); + + /* Search with a PC between func1's last PC and func2's first PC. */ + err = sframe_find_fre (dctx, (0xfffff03e + 0x40 + 0x1), &frep); + TEST("findfunc-1: test-2: Find FRE for PC not in range", + (err == SFRAME_ERR)); + + /* Search for a PC between func2's last PC and func3's first PC. */ + err = sframe_find_fre (dctx, (0xfffff08e + 0x60 + 0x3), &frep); + TEST("findfunc-1: test-3: Find FRE for PC not in range", + (err == SFRAME_ERR)); + + /* Search for a PC beyond the last func, i.e., > func3's last PC. */ + err = sframe_find_fre (dctx, (0xfffff10e + 0x40 + 0x10), &frep); + TEST("findfunc-1: test-4: Find FRE for PC not in range", + (err == SFRAME_ERR)); + + /* And some positive tests... */ + + /* Find an FRE for PC in FDE1. */ + err = sframe_find_fre (dctx, (0xfffff03e + 0x9), &frep); + TEST("findfunc-1: Find FRE in FDE1", + ((err == 0) && (sframe_fre_get_cfa_offset(dctx, &frep, &err) == 0x2))); + + /* Find an FRE for PC in FDE2. */ + err = sframe_find_fre (dctx, (0xfffff08e + 0x11), &frep); + TEST("findfunc-1: Find FRE in FDE2", + ((err == 0) && (sframe_fre_get_cfa_offset(dctx, &frep, &err) == 0x12))); + + /* Find an FRE for PC in FDE3. */ + err = sframe_find_fre (dctx, (0xfffff10e + 0x10), &frep); + TEST("findfunc-1: Find FRE in FDE3", + ((err == 0) && (sframe_fre_get_cfa_offset(dctx, &frep, &err) == 0x18))); + + sframe_encoder_free (&encode); + sframe_decoder_free (&dctx); + + return 0; +} diff --git a/libsframe/testsuite/libsframe.find/local.mk b/libsframe/testsuite/libsframe.find/local.mk index 9943520446d..e8e4fa8091e 100644 --- a/libsframe/testsuite/libsframe.find/local.mk +++ b/libsframe/testsuite/libsframe.find/local.mk @@ -1,7 +1,11 @@ if HAVE_COMPAT_DEJAGNU - check_PROGRAMS += %D%/findfre-1 + check_PROGRAMS += %D%/findfre-1 %D%/findfunc-1 endif %C%_findfre_1_SOURCES = %D%/findfre-1.c %C%_findfre_1_LDADD = ${top_builddir}/libsframe.la %C%_findfre_1_CPPFLAGS = -I${top_srcdir}/../include -Wall + +%C%_findfunc_1_SOURCES = %D%/findfunc-1.c +%C%_findfunc_1_LDADD = ${top_builddir}/libsframe.la +%C%_findfunc_1_CPPFLAGS = -I${top_srcdir}/../include -Wall