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 5DEC038518A1 for ; Mon, 21 Nov 2022 16:37:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5DEC038518A1 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 (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ALGRkbl009115 for ; Mon, 21 Nov 2022 16:37:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : to : cc : date : in-reply-to : references : content-type : mime-version : content-transfer-encoding; s=pp1; bh=pwNF8m1MYnOc2VTYJ/mkpKumz19CN42j++OU4DC4N5U=; b=eGJsOYS+aX/zz5TF/g1j1c9lbNmAIsxSczC6at4r1IgawaaOm31lkT810M6akzUVo1b1 QYXVXC7JJ2ByQ6l0j1ae3mHXU9nx4HcKxcCNRzWReLeC7Im/7+Ey5A9l8XvXDWCfLCTo DzgH1S2/oPRrNTsN2KDC/oUEdBkCYjZ5rxQlRtOEHif8XThQBwmK/u6E5hjigEO53Ji4 mWfTfpta2SLTqllpgiIkZVznwnb1HC+AbYsQ8pQTPU52MpkpiX+5g3UfPHjgqja/5KuJ KNHa+HhjLwuIUOW+0psGrsDJZmZejNbk5aFcvequwq6SYwFszaHaAaeU5w4pDzXq19UI 8Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3m0cvg0796-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 21 Nov 2022 16:36:59 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2ALGRna8009236 for ; Mon, 21 Nov 2022 16:36:59 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3m0cvg078y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Nov 2022 16:36:59 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2ALGZUYf027383; Mon, 21 Nov 2022 16:36:58 GMT Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by ppma03dal.us.ibm.com with ESMTP id 3kxpsa238y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 21 Nov 2022 16:36:58 +0000 Received: from smtpav06.wdc07v.mail.ibm.com ([9.208.128.115]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2ALGavBO4457160 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 21 Nov 2022 16:36:57 GMT Received: from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1714258066; Mon, 21 Nov 2022 16:36:57 +0000 (GMT) Received: from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 83A6858060; Mon, 21 Nov 2022 16:36:56 +0000 (GMT) Received: from li-e362e14c-2378-11b2-a85c-87d605f3c641.ibm.com (unknown [9.163.52.7]) by smtpav06.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 21 Nov 2022 16:36:56 +0000 (GMT) Message-ID: <977af6a5c429256411322ea4fb418a86407b3114.camel@us.ibm.com> Subject: [PING] Re: [PATCH] PowerPC, fix gdb.reverse/finish-reverse-bkpt.exp and gdb.reverse/next-reverse-bkpt-over-sr.exp From: Carl Love To: Bruno Larsen , "gdb-patches@sourceware.org" Cc: Ulrich Weigand , Will Schmidt Date: Mon, 21 Nov 2022 08:36:55 -0800 In-Reply-To: References: <69b2451b-1baf-8bd4-25dd-a1b46963981f@redhat.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-18.el8) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: jb5OcqEzFYK_PR1F3MDW-NwoB8o38Yvn X-Proofpoint-ORIG-GUID: 9GD0fhPZeiDoPMcp5kuTzwRgHREorsrz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-21_14,2022-11-18_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 phishscore=0 malwarescore=0 impostorscore=0 mlxscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 spamscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211210128 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,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: When you have a chance, could you take a look at the new version of the test and see if you agree this does not break the test like my initial fix did. Thanks. Carl Love On Mon, 2022-11-14 at 13:05 -0800, Carl Love wrote: > Bruno, GDB maintainers: > > 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. > > The tests were modified to call the function with a function pointer > so > the test 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. > > 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. > --- > .../gdb.reverse/finish-reverse-bkpt.exp | 30 > +++++++++++++++++++ > gdb/testsuite/gdb.reverse/finish-reverse.c | 4 +++ > .../gdb.reverse/next-reverse-bkpt-over-sr.exp | 29 ++++++++++++++++- > - > gdb/testsuite/gdb.reverse/step-precsave.exp | 1 + > gdb/testsuite/gdb.reverse/step-reverse.c | 9 ++++++ > gdb/testsuite/gdb.reverse/step-reverse.exp | 1 + > 6 files changed, 71 insertions(+), 3 deletions(-) > > diff --git a/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp > b/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp > index 2a204748d98..94bcf41dc67 100644 > --- a/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp > +++ b/gdb/testsuite/gdb.reverse/finish-reverse-bkpt.exp > @@ -19,6 +19,27 @@ > # 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 > } > @@ -38,6 +59,15 @@ if [supports_process_record] { > gdb_test_no_output "record" "turn on process record" > } > > +# Move to the function pointer call to void_func so we will use the > GEP > +# to enter void_func and break. > +set breakloc [gdb_get_line_number "FUNCTION PTR" "$srcfile"] > +gdb_test "break $breakloc" \ > + "Breakpoint $decimal at .*$srcfile, line $breakloc\." \ > + "set breakpoint on funp" > +gdb_continue_to_breakpoint "funp call" ".*$srcfile:$breakloc.*" > + > +# 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/finish-reverse.c > b/gdb/testsuite/gdb.reverse/finish-reverse.c > index 316d6f6aa7e..676d960ca9c 100644 > --- a/gdb/testsuite/gdb.reverse/finish-reverse.c > +++ b/gdb/testsuite/gdb.reverse/finish-reverse.c > @@ -89,6 +89,7 @@ int main (int argc, char **argv) > float float_resultval; > double double_resultval; > int i; > + void (*funp) (void) = void_func; > > /* A "test load" that will insure that the function really > returns > a ${type} (as opposed to just a truncated or part of a > ${type}). */ > @@ -123,6 +124,9 @@ int main (int argc, char **argv) > testval.double_testval = 3.14159265358979323846; /* > float_checkpoint */ > double_resultval = double_func (); > main_test = 1; /* double_checkpoint */ > + > + /* This call is used with finish-reverse-bkpt.exp. */ > + funp(); /* FUNCTION PTR call to > void_func */ > return 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..d78c6ac490e 100644 > --- a/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.exp > +++ b/gdb/testsuite/gdb.reverse/next-reverse-bkpt-over-sr.exp > @@ -22,6 +22,25 @@ > # 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 > @@ -42,8 +61,12 @@ 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" > +# Move to the function pointer call to the callee call after the > function > +# pointer call to callee to begin the test. The function pointer > call to > +# callee will use the Global Entry Point on Power. > +set lineno [gdb_get_line_number "STEP INTO CALL AFTER FUNP CALL"] > +gdb_test "advance $lineno" ".*STEP INTO CALL AFTER FUNP CALL.*" \ > + "get past callee call" > > gdb_test "b \*callee" "" "set breakpoint at callee's entry" > > @@ -53,5 +76,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" > diff --git a/gdb/testsuite/gdb.reverse/step-precsave.exp > b/gdb/testsuite/gdb.reverse/step-precsave.exp > index 3279b6ce879..602dd7e6976 100644 > --- a/gdb/testsuite/gdb.reverse/step-precsave.exp > +++ b/gdb/testsuite/gdb.reverse/step-precsave.exp > @@ -76,6 +76,7 @@ gdb_test "record restore $precsave" \ > > # plain vanilla step/next (no count) > > +gdb_test "next" ".*BREAK AT MAIN.*" "next past funp declaration" > gdb_test "next" ".*NEXT TEST 1.*" "next test 1" > gdb_test "step" ".*STEP TEST 1.*" "step test 1" > > diff --git a/gdb/testsuite/gdb.reverse/step-reverse.c > b/gdb/testsuite/gdb.reverse/step-reverse.c > index 809c7d16dc9..984fd336510 100644 > --- a/gdb/testsuite/gdb.reverse/step-reverse.c > +++ b/gdb/testsuite/gdb.reverse/step-reverse.c > @@ -54,6 +54,7 @@ large_struct_by_value (struct rhomboidal r) > int main () { > int w,x,y,z; > int a[10], b[10]; > + int (*funp) (void) = callee; > > /* Test "next" and "step" */ > w = 0; /* BREAK AT MAIN */ > @@ -90,6 +91,14 @@ int main () { > large_struct_by_value (r); /* step-test.exp: large struct by > value */ > } > > + /* 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 */ > + > + /* Test that "step" doesn't */ > + callee(); /* STEP INTO CALL AFTER FUNP CALL */ > + > exit (0); /* end of main */ > } > > diff --git a/gdb/testsuite/gdb.reverse/step-reverse.exp > b/gdb/testsuite/gdb.reverse/step-reverse.exp > index d2975cffb5c..bce137a97ad 100644 > --- a/gdb/testsuite/gdb.reverse/step-reverse.exp > +++ b/gdb/testsuite/gdb.reverse/step-reverse.exp > @@ -40,6 +40,7 @@ if [supports_process_record] { > > # plain vanilla step/next (no count) > > +gdb_test "next" ".*BREAK AT MAIN.*" "next past funp declaration" > gdb_test "next" ".*NEXT TEST 1.*" "next test 1" > gdb_test "step" ".*STEP TEST 1.*" "step test 1" >