From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id E52D93858C50 for ; Thu, 1 Dec 2022 15:51:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E52D93858C50 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=us.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=us.ibm.com Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B1Eiacg019598 for ; Thu, 1 Dec 2022 15:51:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : from : to : cc : date : in-reply-to : references : content-type : content-transfer-encoding : mime-version : subject; s=pp1; bh=7NjFnpzOUZkRpiHfdnG5ovcVb4DL7gixTn0zfC9YYfA=; b=toNsOow3ajLAWks4zyRRVmU0Bl3AICT2O2PnoHga6h2u6VTWUOeQqK5G5YjDYV/rOFRY UmarI795OvkuBuilvopgBFbnTXRtaqQ4hTdFElLC0kl7xOKuacr0bZnqMQgddxF9SzTS VU8GkUp1zFeojFHd1Z0MwjboXHZzTSnbLRB8SHr92csRWDEioObiHLVj6qcxQtNgR7wJ +BY1L+55L2kgLQjZ9knzJFqF/49TSQy3HzGL/uL8l6pfmL070WTOSXdUgJ9HNhaaUGir hcvq2vnCQKfr+KSp9+ous4yE/iamBKS6pEqeJ2QcpWQfsmiMqp2J/ExYa2BKaYNNIJNA kw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3m6x9v274u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 01 Dec 2022 15:51:40 +0000 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2B1FA5lv026907 for ; Thu, 1 Dec 2022 15:51:39 GMT Received: from ppma01dal.us.ibm.com (83.d6.3fa9.ip4.static.sl-reverse.com [169.63.214.131]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3m6x9v274m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Dec 2022 15:51:39 +0000 Received: from pps.filterd (ppma01dal.us.ibm.com [127.0.0.1]) by ppma01dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2B1FpagF030155; Thu, 1 Dec 2022 15:51:39 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([9.208.129.120]) by ppma01dal.us.ibm.com with ESMTP id 3m3aeap3c5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Dec 2022 15:51:39 +0000 Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2B1FoMrX54657432 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 1 Dec 2022 15:50:22 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C917458064; Thu, 1 Dec 2022 15:50:22 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 503DB5805A; Thu, 1 Dec 2022 15:50:22 +0000 (GMT) Received: from li-e362e14c-2378-11b2-a85c-87d605f3c641.ibm.com (unknown [9.163.74.58]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 1 Dec 2022 15:50:22 +0000 (GMT) Message-ID: From: Carl Love To: Ulrich Weigand , "gdb-patches@sourceware.org" , "blarsen@redhat.com" Cc: "will_schmidt@vnet.ibm.com" Date: Thu, 01 Dec 2022 07:50:21 -0800 In-Reply-To: <40ae618990682da7b6e790ac7d69d899d2da7ec8.camel@us.ibm.com> References: <69b2451b-1baf-8bd4-25dd-a1b46963981f@redhat.com> <75b124722aa20466d5044fa115b679b61ff83010.camel@de.ibm.com> <526c2ea0e35214ef46c248ae88bcd1346fa8e574.camel@us.ibm.com> <682e79ba-0e4b-3209-4fa2-e94ef8e6c978@redhat.com> <015a43bb0dfedfd85f864a2abb9ae005d95103cb.camel@us.ibm.com> <930d9b2f37859733ce04996a1e8cd699bbb59c8a.camel@de.ibm.com> <40ae618990682da7b6e790ac7d69d899d2da7ec8.camel@us.ibm.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-18.el8) X-TM-AS-GCONF: 00 X-Proofpoint-GUID: vQIYsKyvBzB6FyQTXIQo0BQv7ymBU_TI X-Proofpoint-ORIG-GUID: s8VmfdRqHSEDh2HAlP-gr2XMj4RtQScs Content-Transfer-Encoding: 7bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 Subject: RE: [PATCH V5] PowerPC, fix gdb.reverse/finish-reverse-bkpt.exp and gdb.reverse/next-reverse-bkpt-over-sr.exp X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-01_11,2022-12-01_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 mlxscore=0 phishscore=0 adultscore=0 mlxlogscore=999 suspectscore=0 spamscore=0 lowpriorityscore=0 impostorscore=0 clxscore=1015 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212010113 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Bruno, GDB maintainers: Version 5, removed unnecessary break, removed unused comment markers, make comment marker all caps and fixed comment per Ulrich's feedback. Version 4, fixed the style comments on function declarations, missing period mentioned by Bruno. Also, removed the callee () call in next- reverse-bkpt-over-sr.c since it isn't really needed and the comment is misleading since the test doesn't actually step into callee (). Retested on PowerPC to make sure there were no typos. Version 3, per the comments from Ulrich, I created new source files for the two tests based on their original source files. The expect files were then updated to use the new source files. The updated patch has been re-tested on PowerPC and x86-64 with no new regression test failures. The first attempt to fix test next-reverse-bkpt-over-sr.exp basically breaks the test per the comments from Bruno in the thread with the subject [PATCH] Fix test next-reverse-bkpt-over-sr.exp. The following is a second, new approach to fixing the issue. PowerPC uses a Global Entry Point (GEP) and a Local Entry Point (LEP). The GEP is located on the first instruction of the function. It sets up register r2 before the LEP. : lis r2,4098 <- GEP addi r2,r2,32512 mflr r0 <- LEP std r0,16(r1) ... The issue is the gdb command break *callee sets the breakpoint on the first instruction in the function. The call to function callee enters the function at the LEP. Thus gdb never "sees" the breakpoint at the GEP resulting in the test failing on PowerPC. If the function is called using a function pointer, then the linker will setup the call to use the GEP rather instead of the LEP and the test then works as expected on PowerPC. A new function pointer call to callee afollowed by a normal call to callee is added for test next-reverse-bkpt-over-sr.exp at the end of the main so as to not change the test behavior of step-reverse.exp. Note, the source file step-reverse.c is used by both test next-reverse- bkpt-over-sr.exp and test step-reverse.exp. Test next-reverse-bkpt- over-sr.exp starts at the new call to callee at the end of the main program. The rest of the test runs without changes. By entering via the GEP on PowerPC, the breakpoint is seen and the test passes as expected. Note, on non PowerPC systems the GEP and LEP are the same. Calling function callee normally or with a function pointer has the same behavior on non-PowerPC systems. This was specifically verified on Intel X86-64. Test gdb.reverse/finish-reverse-bkpt.exp also fails on PowerPC for the same reasons as discussed above. Again, this test is modified by adding a function pointer call to void_func at the end of main. The source code is used for both test finish-reverse-bkpt.exp and finish- reverse.exp so the a breakpoint is added to finish-reverse-bkpt.exp to stop before the function pointer call to void_func where the test then starts. The addition of the function pointer declarations in the two source files require an additional next statement to tests step-precsave.exp and step-reverse.exp to keep the keep things lined up. Hopefully, this approach to fixing the failing tests on PowerPC is acceptable without changing the behavior on non-PowerPC platforms. The patch has been tested on both PowerPC and X86-64 with no regressions. Please let me know if this patch is acceptable. Thanks. Carl Love ------------------------------------------------------ PowerPC, fix gdb.reverse/finish-reverse-bkpt.exp and gdb.reverse/next-reverse-bkpt-over-sr.exp The tests set a break point with the command break *func. This sets a breakpoint on the first instruction of the function. PowerPC uses Global Entry Points (GEP) and Local Entry Points (LEP). The first instruction in the function is the GEP. The GEP sets up register r2 before reaching the LEP. When the function is called with func() the function is entered via the LEP and the test fails because GDB does not see the breakpoint on the GEP. However, if the function is called via a function pointer, execution begins at the GEP as the test expects. Currently finish-reverse-bkpt.exp uses source file finish-reverse.c and next-reverse-bpkt-over-sr.exp uses source file step-reverse.c A new source file was created for tests finish-reverse-bkpt.exp and next-reverse-bkpt-over-sr.exp. The new files use the new function pointer method to call the functions so the tests will work correctly on both PowerPC with a GEP and LEP as well as on other systems. The GEP is the same as the LEP on non PowerPC systems. The expect files were changed to use the new source files and to set the initial break point for the rest of the test on the function pointer call for the function. This patch fixes two PowerPC test failures in each of the tests gdb.reverse/finish-reverse-bkpt.exp and gdb.reverse/next-reverse-bkpt-over-sr.exp. Patch tested on PowerPC and Intel X86-64 with no regressions. Reviewed-By: Bruno Larsen --- .../gdb.reverse/finish-reverse-bkpt.c | 39 +++++++++++++++++ .../gdb.reverse/finish-reverse-bkpt.exp | 24 ++++++++++- .../gdb.reverse/next-reverse-bkpt-over-sr.c | 43 +++++++++++++++++++ .../gdb.reverse/next-reverse-bkpt-over-sr.exp | 31 ++++++++++--- 4 files changed, 130 insertions(+), 7 deletions(-) create mode 100644 gdb/testsuite/gdb.reverse/finish-reverse-bkpt.c create mode 100644 gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.c diff --git a/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.c b/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.c new file mode 100644 index 00000000000..7a954179234 --- /dev/null +++ b/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.c @@ -0,0 +1,39 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2008-2022 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 . */ + +/* Test gdb's "return" command in reverse. The code for this test is based + on the code in test finish-reverse.c. The code was modified to call the + function via a function pointer so the test will behave the same on all + platforms. See comments in finish-reverse-bkpt.exp. */ + +int void_test = 0; + +void +void_func () +{ + void_test = 1; /* VOID FUNC */ +} + +int +main (int argc, char **argv) +{ + int i; + void (*funp) (void) = void_func; + + funp (); + return 0; +} diff --git a/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp b/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp index 2a204748d98..722f0206e09 100644 --- a/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp +++ b/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp @@ -19,11 +19,32 @@ # the functions entry would be ignored. Make sure the bug doesn't # reappear. +# The test sets a breakpoint with the command break *void_func to set a +# breakpoint on the first instruction of the function. The issue is on +# PowerPC it uses Global Entry Points (GEP) and Local Entry Points (LEP). +# The GEP is the first instruction in the function. It sets up register +# r2 and then reaches the LEP. +# +# : +# lis r2,4098 <- GEP +# addi r2,r2,32512 +# mflr r0 <- LEP +# std r0,16(r1) +# .... + +# +# The command break *void_func sets the breakpoint on the GEP. Calling +# the function with void_func() will enter the function via the LEP. So, +# this test needs to use a function pointer to call void_func() so the +# function will be entered via the GEP to work as designed on PowerPC in +# addition to non-PowerPC systems. On non-PowerPC systems, the GEP and LEP +# are the same. + if ![supports_reverse] { return } -standard_testfile finish-reverse.c +standard_testfile if { [prepare_for_testing "failed to prepare" "$testfile" $srcfile] } { return -1 @@ -38,6 +59,7 @@ if [supports_process_record] { gdb_test_no_output "record" "turn on process record" } +# Start the test. set breakloc [gdb_get_line_number "VOID FUNC" "$srcfile"] gdb_test "tbreak void_func" \ "Temporary breakpoint $decimal at .*$srcfile, line $breakloc\." \ diff --git a/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.c b/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.c new file mode 100644 index 00000000000..6d0ed521fc3 --- /dev/null +++ b/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.c @@ -0,0 +1,43 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2008-2022 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 . */ + +#include +#include + +/* Test reverse finish command. The code for this test is based on the code + in test step-reverse.c. The code was modified to call the function via + a function pointer so the test will behave the same on all platforms. + See comments in next-reverse-bkpt-over-sr.exp. */ + +int myglob = 0; + +int +callee() { + return myglob++; +} + +int +main () { + int (*funp) (void) = callee; + + /* Test next-reverse-bkpt-over-sr.exp needs to call function callee using + a function pointer to work correctly on PowerPC. See comments in + next-reverse-bkpt-over-sr.exp. */ + funp (); /* FUNCTION PTR CALL TO CALLEE */ + + exit (0); /* END OF MAIN */ +} diff --git a/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.exp b/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.exp index 6ef56d30e7b..f6e1d8b9b2f 100644 --- a/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.exp +++ b/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.exp @@ -14,20 +14,37 @@ # along with this program. If not, see . */ # This file is part of the GDB testsuite. It tests reverse stepping. -# Lots of code borrowed from "step-test.exp". - # # reverse-next over a function call sets a step-resume breakpoint at # callee's entry point, runs to it, and then does an extra single-step # to get at the callee's caller. Test that a user breakpoint set at # the same location as the step-resume breakpoint isn't ignored. # +# The test sets a breakpoint with the command break *callee to set a +# breakpoint on the first instruction of the function. The issue is on +# PowerPC it uses Global Entry Points (GEP) and Local Entry Points (LEP). +# The GEP is the first instruction in the function. It sets up register +# r2 and then reaches the LEP. +# +# : +# lis r2,4098 <- GEP +# addi r2,r2,32512 +# mflr r0 <- LEP +# std r0,16(r1) + +# +# The command break *callee sets the breakpoint on the GEP. Calling +# the function with callee() will enter the function via the LEP. So, +# this test needs to use a function pointer to call callee() so the +# function will be entered via the GEP to work as designed on PowerPC in +# addition to non-PowerPC systems. On non-PowerPC systems, the GEP and LEP +# are the same. if ![supports_reverse] { return } -standard_testfile step-reverse.c +standard_testfile if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { return -1 @@ -42,8 +59,10 @@ if [supports_process_record] { gdb_test_no_output "record" "turn on process record" } -set lineno [gdb_get_line_number "STEP INTO THIS CALL"] -gdb_test "advance $lineno" ".*STEP INTO THIS CALL.*" "get past callee call" +# Stop after the function pointer call to test the reverse-next command. +set lineno [gdb_get_line_number "END OF MAIN"] +gdb_test "advance $lineno" ".*END OF MAIN.*" \ + "get past callee call" gdb_test "b \*callee" "" "set breakpoint at callee's entry" @@ -53,5 +72,5 @@ gdb_test "reverse-next" \ "reverse-next over call trips user breakpoint at function entry" gdb_test "up" \ - ".*NEXT OVER THIS CALL.*" \ + ".*FUNCTION PTR CALL TO CALLEE.*" \ "stopped at the right callee call" -- 2.37.2