Fix test step-and-next-inline.cc

Message ID bcbd58d3b49b464aa1a9323cd9265235ac2161ba.camel@us.ibm.com
State New
Headers show
Series
  • Fix test step-and-next-inline.cc
Related show

Commit Message

Lancelot SIX via Gdb-patches Oct. 13, 2021, 11:51 p.m.
GDB maintainers:

The gdb.pc/step-and-next-inline.cc test has 10 fails on Powerpc.  The
test fails when any level of optimization us used because the initial
runto_main stops in the prolog since gdb does not do prolog skipping
for optimized code.  If no optimizations are used, then gdb properly
stops after the prolog.

The test works fine on Intel.

The following patch explicitly sets a break point on the first line of
the main program and does a run to the breakpoint.  This results in
PowerPC reliably stopping at the first line of the main program.  The
patch fixes the error for PowerPC.  The patch was also tested on Intel
to ensure the test still works correctly.

Please let me know if the patch is acceptable for mainline.  Thanks.

                 Carl Love


------------------------------------------------
[PATCH] Fix test step-and-next-inline.cc

The test expects the runto_main to stop at the first line of the function.
Depending on the optimization level, gdb may stop in the prolog or after
the prolog at the first line.  To ensure the test stops at the first line
of main, have it explicitly stop at a break point on the first line of the
function.

On PowerPC, the test passes when compiled with no optimization but fails
with all levels of optimization due to gdb stopping in the prolog.
---
 gdb/testsuite/gdb.cp/step-and-next-inline.cc  | 2 +-
 gdb/testsuite/gdb.cp/step-and-next-inline.exp | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

-- 
2.30.2

Comments

Tom Tromey Oct. 20, 2021, 9:31 p.m. | #1
>>>>> "Carl" == Carl Love via Gdb-patches <gdb-patches@sourceware.org> writes:


Carl> The following patch explicitly sets a break point on the first line of
Carl> the main program and does a run to the breakpoint.  This results in
Carl> PowerPC reliably stopping at the first line of the main program.  The
Carl> patch fixes the error for PowerPC.  The patch was also tested on Intel
Carl> to ensure the test still works correctly.

Carl> Please let me know if the patch is acceptable for mainline.  Thanks.

I think this looks ok.  Thank you.

Tom

Patch

diff --git a/gdb/testsuite/gdb.cp/step-and-next-inline.cc b/gdb/testsuite/gdb.cp/step-and-next-inline.cc
index 26b29d01777..71b93e844f4 100644
--- a/gdb/testsuite/gdb.cp/step-and-next-inline.cc
+++ b/gdb/testsuite/gdb.cp/step-and-next-inline.cc
@@ -61,6 +61,6 @@  tree xx;
 int
 main()
 {
-  get_alias_set (&xx);
+  get_alias_set (&xx);  /* Beginning of main */
   return 0;
 } // main
diff --git a/gdb/testsuite/gdb.cp/step-and-next-inline.exp b/gdb/testsuite/gdb.cp/step-and-next-inline.exp
index 4997abb9b1b..9f30f537bd3 100644
--- a/gdb/testsuite/gdb.cp/step-and-next-inline.exp
+++ b/gdb/testsuite/gdb.cp/step-and-next-inline.exp
@@ -58,7 +58,9 @@  proc do_test { use_header } {
 
     with_test_prefix $prefix {
 
-    if ![runto_main] {
+    set main_location [gdb_get_line_number "Beginning of main" $srcfile]
+
+    if ![runto $main_location qualified] {
 	return
     }