public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing
@ 2022-04-11 20:13 Bruno Larsen
  2022-04-11 20:13 ` [PATCH v2 01/11] gdb/testsuite: introduce gdb_step_until_regexp Bruno Larsen
                   ` (11 more replies)
  0 siblings, 12 replies; 17+ messages in thread
From: Bruno Larsen @ 2022-04-11 20:13 UTC (permalink / raw)
  To: gdb-patches

When testing GDB with clang, gdb.base had over 50 more failures than when
testing with gcc.  Examining the failed tests led to a few clang bugs, a
few GDB bugs, and many testsuite assumptions that could be changed.

After this patch series, nothing should be changed for testing with gcc,
and testing with clang should only show non-trivial failures for
maint.exp and macscp.exp, along with the same GCC failures.

Changes in v2:
    * Introduced gdb_step_until_regexp, based on Pedro's and Andrew's suggestions
    * reworked fixes for: skip.exp, skip-solib.exp and msym-bp-shl.exp
    * Used Pedro's suggestion for call-ar-st
    * reordered patches slightly

Bruno Larsen (11):
  gdb/testsuite: introduce gdb_step_until_regexp
  Change gdb.base/skip-solib.exp deal with lack of epilogue information
  change gdb.base/skip.exp to use finish instead of step
  change gdb.base/symbol-alias to xfail with clang
  change gdb.base/nodebug.c to not fail with clang
  update gdb.base/info-program.exp to not fail with clang
  fix gdb.base/access-mem-running.exp for clang testing
  Fix gdb.base/call-ar-st to work with Clang
  add xfails to gdb.base/complex-parts.exp when testing with clang
  gdb/testsuite: fix gdb.base/msym-bp-shl when running with Clang
  explicitly test for stderr in gdb.base/dprintf.exp

 gdb/testsuite/gdb.base/access-mem-running.c |   2 +-
 gdb/testsuite/gdb.base/call-ar-st.exp       |  13 +-
 gdb/testsuite/gdb.base/complex-parts.exp    |   5 +
 gdb/testsuite/gdb.base/dprintf.exp          |  10 ++
 gdb/testsuite/gdb.base/info-program.exp     |   2 +-
 gdb/testsuite/gdb.base/msym-bp-shl.exp      |   8 +
 gdb/testsuite/gdb.base/nodebug.c            |   2 +-
 gdb/testsuite/gdb.base/nodebug.exp          |   2 +-
 gdb/testsuite/gdb.base/skip-inline.exp      |  18 ++-
 gdb/testsuite/gdb.base/skip-solib-lib.c     |   3 +-
 gdb/testsuite/gdb.base/skip-solib-main.c    |   3 +-
 gdb/testsuite/gdb.base/skip-solib.exp       |  12 +-
 gdb/testsuite/gdb.base/skip.exp             | 164 ++++++++++++++++----
 gdb/testsuite/gdb.base/symbol-alias.exp     |   9 +-
 gdb/testsuite/lib/gdb.exp                   |  30 ++++
 15 files changed, 232 insertions(+), 51 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 01/11] gdb/testsuite: introduce gdb_step_until_regexp
  2022-04-11 20:13 [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing Bruno Larsen
@ 2022-04-11 20:13 ` Bruno Larsen
  2022-04-11 20:13 ` [PATCH v2 02/11] Change gdb.base/skip-solib.exp deal with lack of epilogue information Bruno Larsen
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Bruno Larsen @ 2022-04-11 20:13 UTC (permalink / raw)
  To: gdb-patches

Currently, GDB's testsuite uses a set amount of step commands to exit
functions. This is a problem if a compiler emits different epilogue
information from gcc, or emits no epilogue information at all. It was
most noticeable if Clang was used to test GDB.

To fix this unreliability, this commit introduces a new proc that will
single step the inferior until it is stopped at a line that matches the
given regexp, or until it steps too many times - defined as an optional
argument. If the line is found, it shows up as a single PASS in the
test, and if the line is not found, a single FAIL is emitted.

This patch only introduces this proc, but does not add it to any
existing tests, these will be introduced in the following commit.
---
 gdb/testsuite/lib/gdb.exp | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 2eb711748e7..c48c5919a61 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -8506,5 +8506,35 @@ proc get_set_option_choices {set_cmd} {
     return $values
 }
 
+# This proc is used mainly to exit function in a compiler agnostic way
+# It makes gdb single step and evaluate the output at every step, to see
+# if the regexp is present.
+#
+# The proc takes 2 optional arguments, the first being the name of the
+# test and the second the maximum amount of iterations until we expect to
+# see the function. The default is 10 steps, since this is meant as the
+# last step by default, and we don't expect any compiler generated epilogue
+# longer than 10 steps.
+
+proc gdb_step_until_regexp { regexp {test_name "single stepping until regexp"} {max_steps 10} } {
+    global gdb_prompt
+
+    set count 0
+    gdb_test_multiple "step" "$test_name" {
+	-re "$regexp\r\n$gdb_prompt $" {
+	    pass $test_name
+	}
+	-re ".*$gdb_prompt $" {
+	    if {$count < $max_steps} {
+		incr count
+		send_gdb "step\n"
+		exp_continue
+	    } else {
+		fail $test_name
+	    }
+	}
+    }
+}
+
 # Always load compatibility stuff.
 load_lib future.exp
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 02/11] Change gdb.base/skip-solib.exp deal with lack of epilogue information
  2022-04-11 20:13 [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing Bruno Larsen
  2022-04-11 20:13 ` [PATCH v2 01/11] gdb/testsuite: introduce gdb_step_until_regexp Bruno Larsen
@ 2022-04-11 20:13 ` Bruno Larsen
  2022-04-11 20:13 ` [PATCH v2 03/11] change gdb.base/skip.exp to use finish instead of step Bruno Larsen
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Bruno Larsen @ 2022-04-11 20:13 UTC (permalink / raw)
  To: gdb-patches

When running gdb.base/skip-solib.exp, the backtrace tests could fail if
the compiler did not emit epilogue information for trivial epilogues,
despite the feature being fully functional.  As an example, when testing
skipping the function square, the testsuite would show

Breakpoint 1, main () at (...)/binutils-gdb/gdb/testsuite/gdb.base/skip-solib-main.c:5
5         return square(0);
(gdb) step
0x00007ffff7cef560 in __libc_start_call_main () from /lib64/libc.so.6
(gdb) PASS: gdb.base/skip-solib.exp: ignoring solib file: step
bt
 #0  0x00007ffff7cef560 in __libc_start_call_main () from /lib64/libc.so.6
 #1  0x00007ffff7cef60c in __libc_start_main_impl () from /lib64/libc.so.6
 #2  0x0000000000401065 in _start ()
(gdb) FAIL: gdb.base/skip-solib.exp: ignoring solib file: bt

Which means that the feature is working, the testsuite is just
mis-identifying it.  To avoid this problem, the skipped function calls
have been sent to a line before `return`, so epilogues won't factor in.

This commit has also changed a few hardcoded steps to leave functions to
the newly introduced gdb_step_until_regexp to leave those functions.
---
 gdb/testsuite/gdb.base/skip-inline.exp   | 18 +++++++++++-------
 gdb/testsuite/gdb.base/skip-solib-lib.c  |  3 ++-
 gdb/testsuite/gdb.base/skip-solib-main.c |  3 ++-
 gdb/testsuite/gdb.base/skip-solib.exp    | 12 ++++++++++--
 4 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/gdb/testsuite/gdb.base/skip-inline.exp b/gdb/testsuite/gdb.base/skip-inline.exp
index f6e9926b66c..327ea676140 100644
--- a/gdb/testsuite/gdb.base/skip-inline.exp
+++ b/gdb/testsuite/gdb.base/skip-inline.exp
@@ -35,16 +35,20 @@ gdb_test "skip function foo" "Function foo will be skipped when stepping\."
 gdb_test "bt" "\\s*\\#0\\s+main.*" "in the main"
 gdb_test "step" ".*" "step into baz, since foo will be skipped"
 gdb_test "bt" "\\s*\\#0\\s+baz.*" "in the baz, since foo was skipped"
-gdb_test "step" ".*" "step in the baz"
-gdb_test "bt" "\\s*\\#0\\s+baz.*" "still in the baz"
-gdb_test "step" ".*" "step back to main"
+gdb_step_until_regexp ".*x = 0; x = baz \\(foo \\(\\)\\).*"
 gdb_test "bt" "\\s*\\#0\\s+main.*" "again in the main"
 gdb_test "step" ".*" "step again into baz, since foo will be skipped"
 gdb_test "bt" "\\s*\\#0\\s+baz.*" "again in the baz"
-gdb_test "step" ".*" "step in the baz, again"
-gdb_test "bt" "\\s*\\#0\\s+baz.*" "still in the baz, again"
-gdb_test "step" ".*" "step back to main, again"
-gdb_test "bt" "\\s*\\#0\\s+main.*" "again back to main"
+gdb_step_until_regexp "main \\(\\) at .*" "step back to main, again"
+gdb_test "bt" "\\s*\\#0.*main.*" "again back to main"
+
+# because clang doesn't add epilogue information, having a set number of
+# steps puts clang more and more out of sync with gcc.  It is unlikely that
+# the effort of keeping both outputs will be useful.
+if {[test_compiler_info "clang-*"]} {
+    untested "Multiple steps are not supported with clang"
+    return
+}
 
 if ![runto_main] {
     return
diff --git a/gdb/testsuite/gdb.base/skip-solib-lib.c b/gdb/testsuite/gdb.base/skip-solib-lib.c
index b2c4d86d703..341f1440a3b 100644
--- a/gdb/testsuite/gdb.base/skip-solib-lib.c
+++ b/gdb/testsuite/gdb.base/skip-solib-lib.c
@@ -7,5 +7,6 @@ int multiply(int a, int b)
 
 int square(int num)
 {
-  return multiply(num, num);
+  int res = multiply(num, num);
+  return res;
 }
diff --git a/gdb/testsuite/gdb.base/skip-solib-main.c b/gdb/testsuite/gdb.base/skip-solib-main.c
index 746bb5f36bb..a3b6d417935 100644
--- a/gdb/testsuite/gdb.base/skip-solib-main.c
+++ b/gdb/testsuite/gdb.base/skip-solib-main.c
@@ -2,5 +2,6 @@ int square(int num);
 
 int main()
 {
-  return square(0);
+  int s = square(0);
+  return s;
 }
diff --git a/gdb/testsuite/gdb.base/skip-solib.exp b/gdb/testsuite/gdb.base/skip-solib.exp
index ce2b080229e..f768a4bb538 100644
--- a/gdb/testsuite/gdb.base/skip-solib.exp
+++ b/gdb/testsuite/gdb.base/skip-solib.exp
@@ -82,7 +82,7 @@ with_test_prefix "ignoring solib file" {
     # We shouldn't step into square(), since we skipped skip-solib-lib.c.
     #
     gdb_test "step" ""
-    gdb_test "bt" "#0\\s+main.*"
+    gdb_test "bt 1" "#0\\s+main.*"
 }
 
 #
@@ -114,5 +114,13 @@ with_test_prefix "ignoring solib function" {
     # the last line of square.
     #
     gdb_test "step" ""
-    gdb_test "bt" "#0\\s+square.*"
+    gdb_test "bt 1" "#0\\s+square.*" "skipped multiply"
+#    gdb_test_multiple "bt 1" "skipped multiply" {
+#	-re "#0\\s+square.*" {
+#	    pass "skipped multiply"
+#	}
+#	-re "#0.*main.*" {
+#	    pass "skipped multiply"
+#	}
+#    }
 }
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 03/11] change gdb.base/skip.exp to use finish instead of step
  2022-04-11 20:13 [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing Bruno Larsen
  2022-04-11 20:13 ` [PATCH v2 01/11] gdb/testsuite: introduce gdb_step_until_regexp Bruno Larsen
  2022-04-11 20:13 ` [PATCH v2 02/11] Change gdb.base/skip-solib.exp deal with lack of epilogue information Bruno Larsen
@ 2022-04-11 20:13 ` Bruno Larsen
  2022-04-12 18:11   ` Bruno Larsen
  2022-05-17 16:38   ` Bruno Larsen
  2022-04-11 20:13 ` [PATCH v2 04/11] change gdb.base/symbol-alias to xfail with clang Bruno Larsen
                   ` (8 subsequent siblings)
  11 siblings, 2 replies; 17+ messages in thread
From: Bruno Larsen @ 2022-04-11 20:13 UTC (permalink / raw)
  To: gdb-patches

skip.exp was making use of a fixed amount of step commands to exit
some functions.  This caused some problems when testing GDB with clang,
as it doesn't add epilogue information for functions, along with some
unreliable results depending on the version of GCC, as sometimes gdb
could stop in either of the 2 lines after 2 steps:

x = bax ((bar (), foo ()))
test_skip_file_and_function ();

whereas using clang will always stop on the second line after 1 step.
To deal with GCC unreliability, this test case used to use the question
mechanism from gdb_test, but Pedro mentioned that this is a mis-use of
that feature, and it doesn't deal with the clang case.  This commit
changes it to use gdb_test_multiple and deal with all possible cases,
only considering it a pass when test_skip_file_and_function () is
reached.
---
 gdb/testsuite/gdb.base/skip.exp | 164 +++++++++++++++++++++++++-------
 1 file changed, 131 insertions(+), 33 deletions(-)

diff --git a/gdb/testsuite/gdb.base/skip.exp b/gdb/testsuite/gdb.base/skip.exp
index 7c71bb07a84..5021b696668 100644
--- a/gdb/testsuite/gdb.base/skip.exp
+++ b/gdb/testsuite/gdb.base/skip.exp
@@ -117,9 +117,23 @@ with_test_prefix "step after deleting 1" {
 	return
     }
 
-    gdb_test "step" "foo \\(\\) at.*" "step 1"
-    gdb_test "step" ".*" "step 2" ; # Return from foo()
-    gdb_test "step" "main \\(\\) at.*" "step 3"
+    gdb_test "step" "foo \\(\\) at.*" "step"
+    # step until we are after foo and bar calls, while making sure that
+    # we never step into baz.
+    gdb_test_multiple "step" "step until main" {
+	# gcc stop in this line before continuing
+	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
+	    send_gdb "step\n"
+	    exp_continue
+	}
+	-re ".*\}\r\n$gdb_prompt $" {
+	    send_gdb "step\n"
+	    exp_continue
+	}
+	-re ".*test_skip_file_and_function \\(\\).*" {
+	    pass "step until main"
+	}
+    }
 }
 
 # Now disable the skiplist entry for  skip1.c.  We should now
@@ -137,13 +151,27 @@ with_test_prefix "step after disabling 3" {
     }
 
     gdb_test "step" "bar \\(\\) at.*" "step 1"
-    gdb_test "step" ".*" "step 2"; # Return from bar()
-    # With gcc 9.2.0 we jump once back to main before entering foo here.
-    # If that happens try to step a second time.
-    gdb_test "step" "foo \\(\\) at.*" "step 3" \
-	"main \\(\\) at .*\r\n$gdb_prompt " "step"
-    gdb_test "step" ".*" "step 4"; # Return from foo()
-    gdb_test "step" "main \\(\\) at.*" "step 5"
+    # guarantee that we jump once back to main before entering foo here.
+    # This makes behavior more consistent over different compilers and
+    # different compiler versions
+    gdb_test "finish" ".*" "finish 1"; # Return to main()
+    gdb_test "step" "foo \\(\\) at.*" "step 2"
+    # step until we are after foo and bar calls, while making sure that
+    # we never step into baz.
+    gdb_test_multiple "step" "step until main" {
+	# gcc stop in this line before continuing
+	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
+	    send_gdb "step\n"
+	    exp_continue
+	}
+	-re ".*\}\r\n$gdb_prompt $" {
+	    send_gdb "step\n"
+	    exp_continue
+	}
+	-re ".*test_skip_file_and_function \\(\\).*" {
+	    pass "step until main"
+	}
+    }
 }
 
 # Enable skiplist entry 3 and make sure we step over it like before.
@@ -159,9 +187,23 @@ with_test_prefix "step after enable 3" {
 	return
     }
 
-    gdb_test "step" "foo \\(\\) at.*" "step 1"
-    gdb_test "step" ".*" "step 2"; # Return from foo()
-    gdb_test "step" "main \\(\\) at.*" "step 3"
+    gdb_test "step" "foo \\(\\) at.*" "step"
+    # step until we are after foo and bar calls, while making sure that
+    # we never step into baz.
+    gdb_test_multiple "step" "step until main" {
+	# gcc stop in this line before continuing
+	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
+	    send_gdb "step\n"
+	    exp_continue
+	}
+	-re ".*\}\r\n$gdb_prompt $" {
+	    send_gdb "step\n"
+	    exp_continue
+	}
+	-re ".*test_skip_file_and_function \\(\\).*" {
+	    pass "step until main"
+	}
+    }
 }
 
 # Admin tests (disable,enable,delete).
@@ -230,9 +272,23 @@ with_test_prefix "step using -fi" {
 
     gdb_test_no_output "skip disable"
     gdb_test_no_output "skip enable 5"
-    gdb_test "step" "foo \\(\\) at.*" "step 1"
-    gdb_test "step" ".*" "step 2"; # Return from foo()
-    gdb_test "step" "main \\(\\) at.*" "step 3"
+    gdb_test "step" "foo \\(\\) at.*" "step"
+    # step until we are after foo and bar calls, while making sure that
+    # we never step into baz.
+    gdb_test_multiple "step" "step until main" {
+	# gcc stop in this line before continuing
+	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
+	    send_gdb "step\n"
+	    exp_continue
+	}
+	-re ".*\}\r\n$gdb_prompt $" {
+	    send_gdb "step\n"
+	    exp_continue
+	}
+	-re ".*test_skip_file_and_function \\(\\).*" {
+	    pass "step until main"
+	}
+    }
 }
 
 with_test_prefix "step using -gfi" {
@@ -242,9 +298,23 @@ with_test_prefix "step using -gfi" {
 
     gdb_test_no_output "skip disable"
     gdb_test_no_output "skip enable 6"
-    gdb_test "step" "foo \\(\\) at.*" "step 1"
-    gdb_test "step" ".*" "step 2"; # Return from foo()
-    gdb_test "step" "main \\(\\) at.*" "step 3"
+    gdb_test "step" "foo \\(\\) at.*" "step"
+    # step until we are after foo and bar calls, while making sure that
+    # we never step into baz.
+    gdb_test_multiple "step" "step until main" {
+	# gcc stop in this line before continuing
+	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
+	    send_gdb "step\n"
+	    exp_continue
+	}
+	-re ".*\}\r\n$gdb_prompt $" {
+	    send_gdb "step\n"
+	    exp_continue
+	}
+	-re ".*test_skip_file_and_function \\(\\).*" {
+	    pass "step until main"
+	}
+    }
 }
 
 with_test_prefix "step using -fu for baz" {
@@ -255,13 +325,27 @@ with_test_prefix "step using -fu for baz" {
     gdb_test_no_output "skip disable"
     gdb_test_no_output "skip enable 7"
     gdb_test "step" "bar \\(\\) at.*" "step 1"
-    gdb_test "step" ".*" "step 2"; # Return from bar()
-    # With gcc 9.2.0 we jump once back to main before entering foo here.
-    # If that happens try to step a second time.
-    gdb_test "step" "foo \\(\\) at.*" "step 3" \
-	"main \\(\\) at .*\r\n$gdb_prompt " "step"
-    gdb_test "step" ".*" "step 4"; # Return from foo()
-    gdb_test "step" "main \\(\\) at.*" "step 5"
+    # guarantee that we jump once back to main before entering foo here.
+    # This makes behavior more consistent over different compilers and
+    # different compiler versions
+    gdb_test "finish" ".*" "finish 1"; # Return to main()
+    gdb_test "step" "foo \\(\\) at.*" "step 2"
+    # step until we are after foo and bar calls, while making sure that
+    # we never step into baz.
+    gdb_test_multiple "step" "step until main" {
+	# gcc stop in this line before continuing
+	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
+	    send_gdb "step\n"
+	    exp_continue
+	}
+	-re ".*\}\r\n$gdb_prompt $" {
+	    send_gdb "step\n"
+	    exp_continue
+	}
+	-re ".*test_skip_file_and_function \\(\\).*" {
+	    pass "step until main"
+	}
+    }
 }
 
 with_test_prefix "step using -rfu for baz" {
@@ -272,13 +356,27 @@ with_test_prefix "step using -rfu for baz" {
     gdb_test_no_output "skip disable"
     gdb_test_no_output "skip enable 8"
     gdb_test "step" "bar \\(\\) at.*" "step 1"
-    gdb_test "step" ".*" "step 2"; # Return from bar()
-    # With gcc 9.2.0 we jump once back to main before entering foo here.
-    # If that happens try to step a second time.
-    gdb_test "step" "foo \\(\\) at.*" "step 3" \
-	"main \\(\\) at .*\r\n$gdb_prompt " "step"
-    gdb_test "step" ".*" "step 4"; # Return from foo()
-    gdb_test "step" "main \\(\\) at.*" "step 5"
+    # guarantee that we jump once back to main before entering foo here.
+    # This makes behavior more consistent over different compilers and
+    # different compiler versions
+    gdb_test "finish" ".*" "finish 1"; # Return to main()
+    gdb_test "step" "foo \\(\\) at.*" "step 2"
+    # step until we are after foo and bar calls, while making sure that
+    # we never step into baz.
+    gdb_test_multiple "step" "step until main" {
+	# gcc stop in this line before continuing
+	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
+	    send_gdb "step\n"
+	    exp_continue
+	}
+	-re ".*\}\r\n$gdb_prompt $" {
+	    send_gdb "step\n"
+	    exp_continue
+	}
+	-re ".*test_skip_file_and_function \\(\\).*" {
+	    pass "step until main"
+	}
+    }
 }
 
 # Test -fi + -fu.
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 04/11] change gdb.base/symbol-alias to xfail with clang
  2022-04-11 20:13 [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing Bruno Larsen
                   ` (2 preceding siblings ...)
  2022-04-11 20:13 ` [PATCH v2 03/11] change gdb.base/skip.exp to use finish instead of step Bruno Larsen
@ 2022-04-11 20:13 ` Bruno Larsen
  2022-04-11 20:13 ` [PATCH v2 05/11] change gdb.base/nodebug.c to not fail " Bruno Larsen
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Bruno Larsen @ 2022-04-11 20:13 UTC (permalink / raw)
  To: gdb-patches

Clang does not issue alias information, even when using -gfull.  This
commit adds an xfail to that test in case we are using clang to reduce
noise when testing.
---
 gdb/testsuite/gdb.base/symbol-alias.exp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.base/symbol-alias.exp b/gdb/testsuite/gdb.base/symbol-alias.exp
index 2b53cc31053..38f8f354346 100644
--- a/gdb/testsuite/gdb.base/symbol-alias.exp
+++ b/gdb/testsuite/gdb.base/symbol-alias.exp
@@ -31,6 +31,11 @@ foreach f {"func" "func_alias"} {
 }
 
 # Variables.
-foreach v {"g_var_s" "g_var_s_alias"} {
-    gdb_test "p $v" "= {field1 = 1, field2 = 2}"
+gdb_test "p g_var_s" "= {field1 = 1, field2 = 2}"
+
+# clang doesn't include variable alias information in the dwarf:
+# https://github.com/llvm/llvm-project/issues/52664
+if [test_compiler_info {clang*}] {
+    setup_xfail "clang/52664" *-*-*
 }
+gdb_test "p g_var_s_alias" "= {field1 = 1, field2 = 2}"
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 05/11] change gdb.base/nodebug.c to not fail with clang
  2022-04-11 20:13 [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing Bruno Larsen
                   ` (3 preceding siblings ...)
  2022-04-11 20:13 ` [PATCH v2 04/11] change gdb.base/symbol-alias to xfail with clang Bruno Larsen
@ 2022-04-11 20:13 ` Bruno Larsen
  2022-04-11 20:13 ` [PATCH v2 06/11] update gdb.base/info-program.exp " Bruno Larsen
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Bruno Larsen @ 2022-04-11 20:13 UTC (permalink / raw)
  To: gdb-patches

Clang organizes the variables differently to gcc in the original version
of this code, leading to the following differences when testing
p (int*) &dataglobal + 1

gcc:
$16 = (int *) 0x404034 <datalocal>

clang:
$16 = (int *) 0x404034 <dataglobal8>

The code change to nodebug.c makes it so gcc and clang will place the
same variable under dataglobal8, generating the same output.
---
 gdb/testsuite/gdb.base/nodebug.c   | 2 +-
 gdb/testsuite/gdb.base/nodebug.exp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.base/nodebug.c b/gdb/testsuite/gdb.base/nodebug.c
index c7bc93991b8..572255697bb 100644
--- a/gdb/testsuite/gdb.base/nodebug.c
+++ b/gdb/testsuite/gdb.base/nodebug.c
@@ -3,8 +3,8 @@
 
 /* Test that things still (sort of) work when compiled without -g.  */
 
-int dataglobal = 3;			/* Should go in global data */
 static int datalocal = 4;		/* Should go in local data */
+int dataglobal = 3;			/* Should go in global data */
 int bssglobal;				/* Should go in global bss */
 static int bsslocal;			/* Should go in local bss */
 
diff --git a/gdb/testsuite/gdb.base/nodebug.exp b/gdb/testsuite/gdb.base/nodebug.exp
index 0dbd0ad153e..fbff6ecb395 100644
--- a/gdb/testsuite/gdb.base/nodebug.exp
+++ b/gdb/testsuite/gdb.base/nodebug.exp
@@ -187,7 +187,7 @@ if [nodebug_runto inner] then {
 	{"dataglobal + 1"		""   $dataglobal_unk_re					$dataglobal_unk_re}
 	{"&dataglobal"			""   "\\($data_var_type \\*\\) $hex <dataglobal>"	" = $data_var_type \\*"}
 	{"&dataglobal + 1"		""   $ptr_math_re					$ptr_math_re}
-	{"(int *) &dataglobal + 1"	""   " = \\(int \\*\\) $hex <datalocal>"		"int \\*"}
+	{"(int *) &dataglobal + 1"	""   " = \\(int \\*\\) $hex <dataglobal8>"		"int \\*"}
 	{"&(int) dataglobal + 1"	""   $not_mem_re					$not_mem_re}
 	{"&dataglobal, &dataglobal"	""   "\\($data_var_type \\*\\) $hex <dataglobal>"	" = $data_var_type \\*"}
 	{"*dataglobal"			""   $dataglobal_unk_re					$dataglobal_unk_re}
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 06/11] update gdb.base/info-program.exp to not fail with clang
  2022-04-11 20:13 [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing Bruno Larsen
                   ` (4 preceding siblings ...)
  2022-04-11 20:13 ` [PATCH v2 05/11] change gdb.base/nodebug.c to not fail " Bruno Larsen
@ 2022-04-11 20:13 ` Bruno Larsen
  2022-04-11 20:13 ` [PATCH v2 07/11] fix gdb.base/access-mem-running.exp for clang testing Bruno Larsen
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Bruno Larsen @ 2022-04-11 20:13 UTC (permalink / raw)
  To: gdb-patches

The updated test specifically mentions that it doesn't care where the
program stops, however it was still testing for something.  With this
correction, the test works even if the compiler doesn't add epilogue
information to functions.
---
 gdb/testsuite/gdb.base/info-program.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/info-program.exp b/gdb/testsuite/gdb.base/info-program.exp
index facc13efa2f..f652cfbf426 100644
--- a/gdb/testsuite/gdb.base/info-program.exp
+++ b/gdb/testsuite/gdb.base/info-program.exp
@@ -28,7 +28,7 @@ gdb_test "info program" "Program stopped at $hex\.\r\nIt stopped at breakpoint $
 
 # We don't really care where this step lands, so long as it gets
 # the inferior pushed off the breakpoint it's currently on...
-gdb_test "next" "$decimal\t.*" "step before info program"
+gdb_test "next" ".*" "step before info program"
 
 gdb_test "info program" "Program stopped at $hex\.\r\nIt stopped after being stepped\.\r\nType \"info stack\" or \"info registers\" for more information\." \
     "info program after next"
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 07/11] fix gdb.base/access-mem-running.exp for clang testing
  2022-04-11 20:13 [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing Bruno Larsen
                   ` (5 preceding siblings ...)
  2022-04-11 20:13 ` [PATCH v2 06/11] update gdb.base/info-program.exp " Bruno Larsen
@ 2022-04-11 20:13 ` Bruno Larsen
  2022-04-11 20:13 ` [PATCH v2 08/11] Fix gdb.base/call-ar-st to work with Clang Bruno Larsen
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Bruno Larsen @ 2022-04-11 20:13 UTC (permalink / raw)
  To: gdb-patches

Clang was optimizing global_var away because it was not being used
anywhere. this commit fixes that by adding the attribute used it.
---
 gdb/testsuite/gdb.base/access-mem-running.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/access-mem-running.c b/gdb/testsuite/gdb.base/access-mem-running.c
index 6335f1bf199..cff6f0da820 100644
--- a/gdb/testsuite/gdb.base/access-mem-running.c
+++ b/gdb/testsuite/gdb.base/access-mem-running.c
@@ -19,7 +19,7 @@
 
 static unsigned int global_counter = 1;
 
-static volatile unsigned int global_var = 123;
+static volatile unsigned int __attribute__((used)) global_var = 123;
 
 static void
 maybe_stop_here ()
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 08/11] Fix gdb.base/call-ar-st to work with Clang
  2022-04-11 20:13 [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing Bruno Larsen
                   ` (6 preceding siblings ...)
  2022-04-11 20:13 ` [PATCH v2 07/11] fix gdb.base/access-mem-running.exp for clang testing Bruno Larsen
@ 2022-04-11 20:13 ` Bruno Larsen
  2022-04-11 20:13 ` [PATCH v2 09/11] add xfails to gdb.base/complex-parts.exp when testing with clang Bruno Larsen
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Bruno Larsen @ 2022-04-11 20:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Bruno Larsen, Pedro Alves

When running gdb.base/call-ar-st.exp against Clang, we see one FAIL,
like so:

 print_all_arrays (array_i=<main.integer_array>, array_c=<main.char_array> "ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa
 ZaZaZaZaZaZaZaZaZaZaZaZa", array_f=<main.float_array>, array_d=<main.double_array>) at ../../../src/gdb/testsuite/gdb.base/call-ar-st.c:274
 274       print_int_array(array_i);     /* -step1- */
 (gdb) FAIL: gdb.base/call-ar-st.exp: step inside print_all_arrays

With GCC we instead see:

 print_all_arrays (array_i=<integer_array>, array_c=<char_array> "ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa", array_f=<float_array>, array_d=<double_array>) at /home/pedro/gdb/build/gdb/testsuite/../../../src/gdb/testsuite/gdb.base/call-ar-st.c:274
 274       print_int_array(array_i);     /* -step1- */
 (gdb) PASS: gdb.base/call-ar-st.exp: step inside print_all_arrays

The difference is that with Clang we get:

 array_i=<main.integer_array>, ...

instead of

 array_i = <integer_array>, ...

These symbols are local static variables, and "main" is the name of
the function they are defined in.  GCC instead appends a sequence
number to the linkage name:

 $ nm -A call-ar-st.gcc | grep integer_
 call-ar-st/call-ar-st:00000000000061a0 b integer_array.3968

 $ nm -A call-ar-st.clang | grep integer_
 call-ar-st:00000000004061a0 b main.integer_array

This commit changes the testcase to accept both outputs, as they are
functionally identical.

Co-Authored-By: Pedro Alves <pedro@palves.net>
Change-Id: Iaf2ccdb9d5996e0268ed12f595a6e04b368bfcb4
---
 gdb/testsuite/gdb.base/call-ar-st.exp | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/call-ar-st.exp b/gdb/testsuite/gdb.base/call-ar-st.exp
index d1fb3ac9ec1..43fd6ff9f40 100644
--- a/gdb/testsuite/gdb.base/call-ar-st.exp
+++ b/gdb/testsuite/gdb.base/call-ar-st.exp
@@ -151,10 +151,21 @@ if {!$skip_float_test && \
     gdb_test "continue" ".*" ""
 }
 
+# Return a regexp that matches the linkage name of SYM, assuming SYM
+# is a local static variable inside the main function.
+proc main_static_local_re {sym} {
+    # Clang prepends the function name + '.'.
+    return "(main\\.)?${sym}"
+}
+
 #step
 set stop_line [gdb_get_line_number "-step1-"]
 gdb_test "step" \
-    "print_all_arrays \\(array_i=<integer_array.*>, array_c=<char_array.*> .ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa., array_f=<float_array.*>, array_d=<double_array.*>\\) at .*$srcfile:$stop_line\[ \t\r\n\]+$stop_line.*print_int_array\\(array_i\\);.*" \
+    "print_all_arrays \\(array_i=<[main_static_local_re integer_array]>,\
+			 array_c=<[main_static_local_re char_array]> .ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa.,\
+			 array_f=<[main_static_local_re float_array]>,\
+			 array_d=<[main_static_local_re double_array]>\\)\
+			 at .*$srcfile:$stop_line\[ \t\r\n\]+$stop_line.*print_int_array\\(array_i\\);.*" \
     "step inside print_all_arrays"
 
 #step -over
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 09/11] add xfails to gdb.base/complex-parts.exp when testing with clang
  2022-04-11 20:13 [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing Bruno Larsen
                   ` (7 preceding siblings ...)
  2022-04-11 20:13 ` [PATCH v2 08/11] Fix gdb.base/call-ar-st to work with Clang Bruno Larsen
@ 2022-04-11 20:13 ` Bruno Larsen
  2022-04-11 20:13 ` [PATCH v2 10/11] gdb/testsuite: fix gdb.base/msym-bp-shl when running with Clang Bruno Larsen
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 17+ messages in thread
From: Bruno Larsen @ 2022-04-11 20:13 UTC (permalink / raw)
  To: gdb-patches

clang doesn't add encoding to the name of complex variables, only says
that the type name is complex, making the relevant tests fail.
This patch adds the xfails to the tests that expect the variable name to
include it.
---
 gdb/testsuite/gdb.base/complex-parts.exp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gdb/testsuite/gdb.base/complex-parts.exp b/gdb/testsuite/gdb.base/complex-parts.exp
index e67fd482268..7fa94c72cd4 100644
--- a/gdb/testsuite/gdb.base/complex-parts.exp
+++ b/gdb/testsuite/gdb.base/complex-parts.exp
@@ -30,8 +30,13 @@ gdb_test "p z1" " = 1.5 \\+ 4.5i"
 gdb_test "p z2" " = 2.5 \\+ -5.5i"
 gdb_test "p z3" " = 3.5 \\+ 6.5i"
 
+# The following 3 tests are broken for Clang.
+# More info at https://github.com/llvm/llvm-project/issues/52996.
+if {[test_compiler_info clang-*-*]} { setup_xfail *-*-* }
 gdb_test "ptype z1" " = complex double"
+if {[test_compiler_info clang-*-*]} { setup_xfail *-*-* }
 gdb_test "ptype z2" " = complex float"
+if {[test_compiler_info clang-*-*]} { setup_xfail *-*-* }
 gdb_test "ptype z3" " = complex long double"
 
 with_test_prefix "double imaginary" {
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 10/11] gdb/testsuite: fix gdb.base/msym-bp-shl when running with Clang
  2022-04-11 20:13 [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing Bruno Larsen
                   ` (8 preceding siblings ...)
  2022-04-11 20:13 ` [PATCH v2 09/11] add xfails to gdb.base/complex-parts.exp when testing with clang Bruno Larsen
@ 2022-04-11 20:13 ` Bruno Larsen
  2022-04-11 20:13 ` [PATCH v2 11/11] explicitly test for stderr in gdb.base/dprintf.exp Bruno Larsen
  2022-04-26 13:17 ` [PING] [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing Bruno Larsen
  11 siblings, 0 replies; 17+ messages in thread
From: Bruno Larsen @ 2022-04-11 20:13 UTC (permalink / raw)
  To: gdb-patches

Because Clang's -O0 is not as unoptimized as gcc's, one of the functions
of gdb.base/msym-bp-shl was being optimized away, making the entire test
fail. A lot of the test fail like so:

(gdb) break foo
Breakpoint 1 at 0x401030
(gdb) FAIL: gdb.base/msym-bp-shl.exp: debug=0: before run: break foo
info breakpoint
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x0000000000401030 <foo@plt>
(gdb) FAIL: gdb.base/msym-bp-shl.exp: debug=0: before run: info breakpoint

As the test expects 2 breakpoints to be placed. This can't be easily fixed
by adding __attribute__ ((used)) to the function, since Clang will still
optimize away the function. Because of this, the test is skipped when
the it detects that Clang is being used
---
 gdb/testsuite/gdb.base/msym-bp-shl.exp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gdb/testsuite/gdb.base/msym-bp-shl.exp b/gdb/testsuite/gdb.base/msym-bp-shl.exp
index 42adcb191dd..dd7d05bab52 100644
--- a/gdb/testsuite/gdb.base/msym-bp-shl.exp
+++ b/gdb/testsuite/gdb.base/msym-bp-shl.exp
@@ -22,6 +22,14 @@ if {[skip_shlib_tests]} {
     return 0
 }
 
+# Clang will optimize away the static foo, regardless of using
+# __attribute__((used)), so we'll always get a single breakpoint
+# making this test useless
+if {[test_compiler_info {clang-*-*}]} {
+    untested "Clang optimizes away one of the functions"
+    return
+}
+
 standard_testfile msym-bp-shl-main.c msym-bp-shl-main-2.c msym-bp-shl-lib.c
 set srcfile ${srcdir}/${subdir}/${srcfile}
 set srcfile2 ${srcdir}/${subdir}/${srcfile2}
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH v2 11/11] explicitly test for stderr in gdb.base/dprintf.exp
  2022-04-11 20:13 [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing Bruno Larsen
                   ` (9 preceding siblings ...)
  2022-04-11 20:13 ` [PATCH v2 10/11] gdb/testsuite: fix gdb.base/msym-bp-shl when running with Clang Bruno Larsen
@ 2022-04-11 20:13 ` Bruno Larsen
  2022-04-26 13:17 ` [PING] [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing Bruno Larsen
  11 siblings, 0 replies; 17+ messages in thread
From: Bruno Larsen @ 2022-04-11 20:13 UTC (permalink / raw)
  To: gdb-patches

Not all compilers add stderr debug information when compiling a
program. Clang, for instance, prefers to add nothing from standard
libraries and let an external debug package have this information.
Because of this, gdb.base/dprintf.exp was failing when GDB attempted to
use dprintf as a call to fprintf(stderrr, ...), like this:

 (gdb) PASS: gdb.base/dprintf.exp: call: fprintf: set dprintf style to call
 continue
 Continuing.
 kickoff 1234
 also to stderr 1234
 'stderr' has unknown type; cast it to its declared type
 (gdb) FAIL: gdb.base/dprintf.exp: call: fprintf: 1st dprintf (timeout)

To avoid this false positive, we explicitly test to see if
the compiler has added information about stderr at all, and abort
testing dprintf as an frpintf call if it is unavailable.
---
 gdb/testsuite/gdb.base/dprintf.exp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/gdb/testsuite/gdb.base/dprintf.exp b/gdb/testsuite/gdb.base/dprintf.exp
index 0b209c02a62..e214531f6dc 100644
--- a/gdb/testsuite/gdb.base/dprintf.exp
+++ b/gdb/testsuite/gdb.base/dprintf.exp
@@ -111,6 +111,16 @@ proc test_call {} {
 	test_dprintf "At foo entry.*arg=1235, g=2222\r\n" "2nd dprintf"
     }
 
+    gdb_test_multiple "print stderr" "stderr symbol check" {
+	-re "\\'stderr\\' has unknown type.*" {
+	    untested "No information available for stderr, exiting early"
+	    return
+	}
+	-re "\\\$1.*" {
+	    pass "stderr is available"
+	}
+    }
+
     with_test_prefix "fprintf" {
 	restart
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 03/11] change gdb.base/skip.exp to use finish instead of step
  2022-04-11 20:13 ` [PATCH v2 03/11] change gdb.base/skip.exp to use finish instead of step Bruno Larsen
@ 2022-04-12 18:11   ` Bruno Larsen
  2022-05-17 16:38   ` Bruno Larsen
  1 sibling, 0 replies; 17+ messages in thread
From: Bruno Larsen @ 2022-04-12 18:11 UTC (permalink / raw)
  To: gdb-patches

Further testing showed that this version of the patch is racy, because of when gdb_test_multiple were getting the outputs. Changing the following regexps:

".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*"
".*test_skip_file_and_function \\(\\).*"

with


".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);\r\n$gdb_prompt $"
".*test_skip_file_and_function \\(\\);\r\n$gdb_prompt $"

I've made these changes locally. Please keep this in mind when reviewing the patch.

Cheers!
Bruno Larsen

On 4/11/22 17:13, Bruno Larsen wrote:
> skip.exp was making use of a fixed amount of step commands to exit
> some functions.  This caused some problems when testing GDB with clang,
> as it doesn't add epilogue information for functions, along with some
> unreliable results depending on the version of GCC, as sometimes gdb
> could stop in either of the 2 lines after 2 steps:
> 
> x = bax ((bar (), foo ()))
> test_skip_file_and_function ();
> 
> whereas using clang will always stop on the second line after 1 step.
> To deal with GCC unreliability, this test case used to use the question
> mechanism from gdb_test, but Pedro mentioned that this is a mis-use of
> that feature, and it doesn't deal with the clang case.  This commit
> changes it to use gdb_test_multiple and deal with all possible cases,
> only considering it a pass when test_skip_file_and_function () is
> reached.
> ---
>   gdb/testsuite/gdb.base/skip.exp | 164 +++++++++++++++++++++++++-------
>   1 file changed, 131 insertions(+), 33 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.base/skip.exp b/gdb/testsuite/gdb.base/skip.exp
> index 7c71bb07a84..5021b696668 100644
> --- a/gdb/testsuite/gdb.base/skip.exp
> +++ b/gdb/testsuite/gdb.base/skip.exp
> @@ -117,9 +117,23 @@ with_test_prefix "step after deleting 1" {
>   	return
>       }
>   
> -    gdb_test "step" "foo \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2" ; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 3"
> +    gdb_test "step" "foo \\(\\) at.*" "step"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   # Now disable the skiplist entry for  skip1.c.  We should now
> @@ -137,13 +151,27 @@ with_test_prefix "step after disabling 3" {
>       }
>   
>       gdb_test "step" "bar \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2"; # Return from bar()
> -    # With gcc 9.2.0 we jump once back to main before entering foo here.
> -    # If that happens try to step a second time.
> -    gdb_test "step" "foo \\(\\) at.*" "step 3" \
> -	"main \\(\\) at .*\r\n$gdb_prompt " "step"
> -    gdb_test "step" ".*" "step 4"; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 5"
> +    # guarantee that we jump once back to main before entering foo here.
> +    # This makes behavior more consistent over different compilers and
> +    # different compiler versions
> +    gdb_test "finish" ".*" "finish 1"; # Return to main()
> +    gdb_test "step" "foo \\(\\) at.*" "step 2"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   # Enable skiplist entry 3 and make sure we step over it like before.
> @@ -159,9 +187,23 @@ with_test_prefix "step after enable 3" {
>   	return
>       }
>   
> -    gdb_test "step" "foo \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2"; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 3"
> +    gdb_test "step" "foo \\(\\) at.*" "step"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   # Admin tests (disable,enable,delete).
> @@ -230,9 +272,23 @@ with_test_prefix "step using -fi" {
>   
>       gdb_test_no_output "skip disable"
>       gdb_test_no_output "skip enable 5"
> -    gdb_test "step" "foo \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2"; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 3"
> +    gdb_test "step" "foo \\(\\) at.*" "step"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   with_test_prefix "step using -gfi" {
> @@ -242,9 +298,23 @@ with_test_prefix "step using -gfi" {
>   
>       gdb_test_no_output "skip disable"
>       gdb_test_no_output "skip enable 6"
> -    gdb_test "step" "foo \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2"; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 3"
> +    gdb_test "step" "foo \\(\\) at.*" "step"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   with_test_prefix "step using -fu for baz" {
> @@ -255,13 +325,27 @@ with_test_prefix "step using -fu for baz" {
>       gdb_test_no_output "skip disable"
>       gdb_test_no_output "skip enable 7"
>       gdb_test "step" "bar \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2"; # Return from bar()
> -    # With gcc 9.2.0 we jump once back to main before entering foo here.
> -    # If that happens try to step a second time.
> -    gdb_test "step" "foo \\(\\) at.*" "step 3" \
> -	"main \\(\\) at .*\r\n$gdb_prompt " "step"
> -    gdb_test "step" ".*" "step 4"; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 5"
> +    # guarantee that we jump once back to main before entering foo here.
> +    # This makes behavior more consistent over different compilers and
> +    # different compiler versions
> +    gdb_test "finish" ".*" "finish 1"; # Return to main()
> +    gdb_test "step" "foo \\(\\) at.*" "step 2"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   with_test_prefix "step using -rfu for baz" {
> @@ -272,13 +356,27 @@ with_test_prefix "step using -rfu for baz" {
>       gdb_test_no_output "skip disable"
>       gdb_test_no_output "skip enable 8"
>       gdb_test "step" "bar \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2"; # Return from bar()
> -    # With gcc 9.2.0 we jump once back to main before entering foo here.
> -    # If that happens try to step a second time.
> -    gdb_test "step" "foo \\(\\) at.*" "step 3" \
> -	"main \\(\\) at .*\r\n$gdb_prompt " "step"
> -    gdb_test "step" ".*" "step 4"; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 5"
> +    # guarantee that we jump once back to main before entering foo here.
> +    # This makes behavior more consistent over different compilers and
> +    # different compiler versions
> +    gdb_test "finish" ".*" "finish 1"; # Return to main()
> +    gdb_test "step" "foo \\(\\) at.*" "step 2"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   # Test -fi + -fu.


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PING] [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing
  2022-04-11 20:13 [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing Bruno Larsen
                   ` (10 preceding siblings ...)
  2022-04-11 20:13 ` [PATCH v2 11/11] explicitly test for stderr in gdb.base/dprintf.exp Bruno Larsen
@ 2022-04-26 13:17 ` Bruno Larsen
  2022-05-03 20:43   ` [PINGv2] " Bruno Larsen
  11 siblings, 1 reply; 17+ messages in thread
From: Bruno Larsen @ 2022-04-26 13:17 UTC (permalink / raw)
  To: gdb-patches

Kindly pinging

Cheers!
Bruno Larsen

On 4/11/22 17:13, Bruno Larsen wrote:
> When testing GDB with clang, gdb.base had over 50 more failures than when
> testing with gcc.  Examining the failed tests led to a few clang bugs, a
> few GDB bugs, and many testsuite assumptions that could be changed.
> 
> After this patch series, nothing should be changed for testing with gcc,
> and testing with clang should only show non-trivial failures for
> maint.exp and macscp.exp, along with the same GCC failures.
> 
> Changes in v2:
>      * Introduced gdb_step_until_regexp, based on Pedro's and Andrew's suggestions
>      * reworked fixes for: skip.exp, skip-solib.exp and msym-bp-shl.exp
>      * Used Pedro's suggestion for call-ar-st
>      * reordered patches slightly
> 
> Bruno Larsen (11):
>    gdb/testsuite: introduce gdb_step_until_regexp
>    Change gdb.base/skip-solib.exp deal with lack of epilogue information
>    change gdb.base/skip.exp to use finish instead of step
>    change gdb.base/symbol-alias to xfail with clang
>    change gdb.base/nodebug.c to not fail with clang
>    update gdb.base/info-program.exp to not fail with clang
>    fix gdb.base/access-mem-running.exp for clang testing
>    Fix gdb.base/call-ar-st to work with Clang
>    add xfails to gdb.base/complex-parts.exp when testing with clang
>    gdb/testsuite: fix gdb.base/msym-bp-shl when running with Clang
>    explicitly test for stderr in gdb.base/dprintf.exp
> 
>   gdb/testsuite/gdb.base/access-mem-running.c |   2 +-
>   gdb/testsuite/gdb.base/call-ar-st.exp       |  13 +-
>   gdb/testsuite/gdb.base/complex-parts.exp    |   5 +
>   gdb/testsuite/gdb.base/dprintf.exp          |  10 ++
>   gdb/testsuite/gdb.base/info-program.exp     |   2 +-
>   gdb/testsuite/gdb.base/msym-bp-shl.exp      |   8 +
>   gdb/testsuite/gdb.base/nodebug.c            |   2 +-
>   gdb/testsuite/gdb.base/nodebug.exp          |   2 +-
>   gdb/testsuite/gdb.base/skip-inline.exp      |  18 ++-
>   gdb/testsuite/gdb.base/skip-solib-lib.c     |   3 +-
>   gdb/testsuite/gdb.base/skip-solib-main.c    |   3 +-
>   gdb/testsuite/gdb.base/skip-solib.exp       |  12 +-
>   gdb/testsuite/gdb.base/skip.exp             | 164 ++++++++++++++++----
>   gdb/testsuite/gdb.base/symbol-alias.exp     |   9 +-
>   gdb/testsuite/lib/gdb.exp                   |  30 ++++
>   15 files changed, 232 insertions(+), 51 deletions(-)
> 


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PINGv2] [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing
  2022-04-26 13:17 ` [PING] [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing Bruno Larsen
@ 2022-05-03 20:43   ` Bruno Larsen
  2022-05-10 20:06     ` [PINGv3] " Bruno Larsen
  0 siblings, 1 reply; 17+ messages in thread
From: Bruno Larsen @ 2022-05-03 20:43 UTC (permalink / raw)
  To: gdb-patches

Kindly pinging, v2

Cheers!
Bruno Larsen

On 4/26/22 10:17, Bruno Larsen wrote:
> Kindly pinging
> 
> Cheers!
> Bruno Larsen
> 
> On 4/11/22 17:13, Bruno Larsen wrote:
>> When testing GDB with clang, gdb.base had over 50 more failures than when
>> testing with gcc.  Examining the failed tests led to a few clang bugs, a
>> few GDB bugs, and many testsuite assumptions that could be changed.
>>
>> After this patch series, nothing should be changed for testing with gcc,
>> and testing with clang should only show non-trivial failures for
>> maint.exp and macscp.exp, along with the same GCC failures.
>>
>> Changes in v2:
>>      * Introduced gdb_step_until_regexp, based on Pedro's and Andrew's suggestions
>>      * reworked fixes for: skip.exp, skip-solib.exp and msym-bp-shl.exp
>>      * Used Pedro's suggestion for call-ar-st
>>      * reordered patches slightly
>>
>> Bruno Larsen (11):
>>    gdb/testsuite: introduce gdb_step_until_regexp
>>    Change gdb.base/skip-solib.exp deal with lack of epilogue information
>>    change gdb.base/skip.exp to use finish instead of step
>>    change gdb.base/symbol-alias to xfail with clang
>>    change gdb.base/nodebug.c to not fail with clang
>>    update gdb.base/info-program.exp to not fail with clang
>>    fix gdb.base/access-mem-running.exp for clang testing
>>    Fix gdb.base/call-ar-st to work with Clang
>>    add xfails to gdb.base/complex-parts.exp when testing with clang
>>    gdb/testsuite: fix gdb.base/msym-bp-shl when running with Clang
>>    explicitly test for stderr in gdb.base/dprintf.exp
>>
>>   gdb/testsuite/gdb.base/access-mem-running.c |   2 +-
>>   gdb/testsuite/gdb.base/call-ar-st.exp       |  13 +-
>>   gdb/testsuite/gdb.base/complex-parts.exp    |   5 +
>>   gdb/testsuite/gdb.base/dprintf.exp          |  10 ++
>>   gdb/testsuite/gdb.base/info-program.exp     |   2 +-
>>   gdb/testsuite/gdb.base/msym-bp-shl.exp      |   8 +
>>   gdb/testsuite/gdb.base/nodebug.c            |   2 +-
>>   gdb/testsuite/gdb.base/nodebug.exp          |   2 +-
>>   gdb/testsuite/gdb.base/skip-inline.exp      |  18 ++-
>>   gdb/testsuite/gdb.base/skip-solib-lib.c     |   3 +-
>>   gdb/testsuite/gdb.base/skip-solib-main.c    |   3 +-
>>   gdb/testsuite/gdb.base/skip-solib.exp       |  12 +-
>>   gdb/testsuite/gdb.base/skip.exp             | 164 ++++++++++++++++----
>>   gdb/testsuite/gdb.base/symbol-alias.exp     |   9 +-
>>   gdb/testsuite/lib/gdb.exp                   |  30 ++++
>>   15 files changed, 232 insertions(+), 51 deletions(-)
>>


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PINGv3] [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing
  2022-05-03 20:43   ` [PINGv2] " Bruno Larsen
@ 2022-05-10 20:06     ` Bruno Larsen
  0 siblings, 0 replies; 17+ messages in thread
From: Bruno Larsen @ 2022-05-10 20:06 UTC (permalink / raw)
  To: gdb-patches

Kindly pinging, v3

Cheers!
Bruno Larsen

On 5/3/22 17:43, Bruno Larsen wrote:
> Kindly pinging, v2
> 
> Cheers!
> Bruno Larsen
> 
> On 4/26/22 10:17, Bruno Larsen wrote:
>> Kindly pinging
>>
>> Cheers!
>> Bruno Larsen
>>
>> On 4/11/22 17:13, Bruno Larsen wrote:
>>> When testing GDB with clang, gdb.base had over 50 more failures than when
>>> testing with gcc.  Examining the failed tests led to a few clang bugs, a
>>> few GDB bugs, and many testsuite assumptions that could be changed.
>>>
>>> After this patch series, nothing should be changed for testing with gcc,
>>> and testing with clang should only show non-trivial failures for
>>> maint.exp and macscp.exp, along with the same GCC failures.
>>>
>>> Changes in v2:
>>>      * Introduced gdb_step_until_regexp, based on Pedro's and Andrew's suggestions
>>>      * reworked fixes for: skip.exp, skip-solib.exp and msym-bp-shl.exp
>>>      * Used Pedro's suggestion for call-ar-st
>>>      * reordered patches slightly
>>>
>>> Bruno Larsen (11):
>>>    gdb/testsuite: introduce gdb_step_until_regexp
>>>    Change gdb.base/skip-solib.exp deal with lack of epilogue information
>>>    change gdb.base/skip.exp to use finish instead of step
>>>    change gdb.base/symbol-alias to xfail with clang
>>>    change gdb.base/nodebug.c to not fail with clang
>>>    update gdb.base/info-program.exp to not fail with clang
>>>    fix gdb.base/access-mem-running.exp for clang testing
>>>    Fix gdb.base/call-ar-st to work with Clang
>>>    add xfails to gdb.base/complex-parts.exp when testing with clang
>>>    gdb/testsuite: fix gdb.base/msym-bp-shl when running with Clang
>>>    explicitly test for stderr in gdb.base/dprintf.exp
>>>
>>>   gdb/testsuite/gdb.base/access-mem-running.c |   2 +-
>>>   gdb/testsuite/gdb.base/call-ar-st.exp       |  13 +-
>>>   gdb/testsuite/gdb.base/complex-parts.exp    |   5 +
>>>   gdb/testsuite/gdb.base/dprintf.exp          |  10 ++
>>>   gdb/testsuite/gdb.base/info-program.exp     |   2 +-
>>>   gdb/testsuite/gdb.base/msym-bp-shl.exp      |   8 +
>>>   gdb/testsuite/gdb.base/nodebug.c            |   2 +-
>>>   gdb/testsuite/gdb.base/nodebug.exp          |   2 +-
>>>   gdb/testsuite/gdb.base/skip-inline.exp      |  18 ++-
>>>   gdb/testsuite/gdb.base/skip-solib-lib.c     |   3 +-
>>>   gdb/testsuite/gdb.base/skip-solib-main.c    |   3 +-
>>>   gdb/testsuite/gdb.base/skip-solib.exp       |  12 +-
>>>   gdb/testsuite/gdb.base/skip.exp             | 164 ++++++++++++++++----
>>>   gdb/testsuite/gdb.base/symbol-alias.exp     |   9 +-
>>>   gdb/testsuite/lib/gdb.exp                   |  30 ++++
>>>   15 files changed, 232 insertions(+), 51 deletions(-)
>>>


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH v2 03/11] change gdb.base/skip.exp to use finish instead of step
  2022-04-11 20:13 ` [PATCH v2 03/11] change gdb.base/skip.exp to use finish instead of step Bruno Larsen
  2022-04-12 18:11   ` Bruno Larsen
@ 2022-05-17 16:38   ` Bruno Larsen
  1 sibling, 0 replies; 17+ messages in thread
From: Bruno Larsen @ 2022-05-17 16:38 UTC (permalink / raw)
  To: gdb-patches

This patch no longer applies, and has non-trivial merge conflicts. However, the rest of the series does not depend on this patch, so please continue reviewing the rest and ignore this specific patch.

Cheers!
Bruno Larsen

On 4/11/22 17:13, Bruno Larsen wrote:
> skip.exp was making use of a fixed amount of step commands to exit
> some functions.  This caused some problems when testing GDB with clang,
> as it doesn't add epilogue information for functions, along with some
> unreliable results depending on the version of GCC, as sometimes gdb
> could stop in either of the 2 lines after 2 steps:
> 
> x = bax ((bar (), foo ()))
> test_skip_file_and_function ();
> 
> whereas using clang will always stop on the second line after 1 step.
> To deal with GCC unreliability, this test case used to use the question
> mechanism from gdb_test, but Pedro mentioned that this is a mis-use of
> that feature, and it doesn't deal with the clang case.  This commit
> changes it to use gdb_test_multiple and deal with all possible cases,
> only considering it a pass when test_skip_file_and_function () is
> reached.
> ---
>   gdb/testsuite/gdb.base/skip.exp | 164 +++++++++++++++++++++++++-------
>   1 file changed, 131 insertions(+), 33 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.base/skip.exp b/gdb/testsuite/gdb.base/skip.exp
> index 7c71bb07a84..5021b696668 100644
> --- a/gdb/testsuite/gdb.base/skip.exp
> +++ b/gdb/testsuite/gdb.base/skip.exp
> @@ -117,9 +117,23 @@ with_test_prefix "step after deleting 1" {
>   	return
>       }
>   
> -    gdb_test "step" "foo \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2" ; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 3"
> +    gdb_test "step" "foo \\(\\) at.*" "step"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   # Now disable the skiplist entry for  skip1.c.  We should now
> @@ -137,13 +151,27 @@ with_test_prefix "step after disabling 3" {
>       }
>   
>       gdb_test "step" "bar \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2"; # Return from bar()
> -    # With gcc 9.2.0 we jump once back to main before entering foo here.
> -    # If that happens try to step a second time.
> -    gdb_test "step" "foo \\(\\) at.*" "step 3" \
> -	"main \\(\\) at .*\r\n$gdb_prompt " "step"
> -    gdb_test "step" ".*" "step 4"; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 5"
> +    # guarantee that we jump once back to main before entering foo here.
> +    # This makes behavior more consistent over different compilers and
> +    # different compiler versions
> +    gdb_test "finish" ".*" "finish 1"; # Return to main()
> +    gdb_test "step" "foo \\(\\) at.*" "step 2"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   # Enable skiplist entry 3 and make sure we step over it like before.
> @@ -159,9 +187,23 @@ with_test_prefix "step after enable 3" {
>   	return
>       }
>   
> -    gdb_test "step" "foo \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2"; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 3"
> +    gdb_test "step" "foo \\(\\) at.*" "step"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   # Admin tests (disable,enable,delete).
> @@ -230,9 +272,23 @@ with_test_prefix "step using -fi" {
>   
>       gdb_test_no_output "skip disable"
>       gdb_test_no_output "skip enable 5"
> -    gdb_test "step" "foo \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2"; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 3"
> +    gdb_test "step" "foo \\(\\) at.*" "step"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   with_test_prefix "step using -gfi" {
> @@ -242,9 +298,23 @@ with_test_prefix "step using -gfi" {
>   
>       gdb_test_no_output "skip disable"
>       gdb_test_no_output "skip enable 6"
> -    gdb_test "step" "foo \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2"; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 3"
> +    gdb_test "step" "foo \\(\\) at.*" "step"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   with_test_prefix "step using -fu for baz" {
> @@ -255,13 +325,27 @@ with_test_prefix "step using -fu for baz" {
>       gdb_test_no_output "skip disable"
>       gdb_test_no_output "skip enable 7"
>       gdb_test "step" "bar \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2"; # Return from bar()
> -    # With gcc 9.2.0 we jump once back to main before entering foo here.
> -    # If that happens try to step a second time.
> -    gdb_test "step" "foo \\(\\) at.*" "step 3" \
> -	"main \\(\\) at .*\r\n$gdb_prompt " "step"
> -    gdb_test "step" ".*" "step 4"; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 5"
> +    # guarantee that we jump once back to main before entering foo here.
> +    # This makes behavior more consistent over different compilers and
> +    # different compiler versions
> +    gdb_test "finish" ".*" "finish 1"; # Return to main()
> +    gdb_test "step" "foo \\(\\) at.*" "step 2"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   with_test_prefix "step using -rfu for baz" {
> @@ -272,13 +356,27 @@ with_test_prefix "step using -rfu for baz" {
>       gdb_test_no_output "skip disable"
>       gdb_test_no_output "skip enable 8"
>       gdb_test "step" "bar \\(\\) at.*" "step 1"
> -    gdb_test "step" ".*" "step 2"; # Return from bar()
> -    # With gcc 9.2.0 we jump once back to main before entering foo here.
> -    # If that happens try to step a second time.
> -    gdb_test "step" "foo \\(\\) at.*" "step 3" \
> -	"main \\(\\) at .*\r\n$gdb_prompt " "step"
> -    gdb_test "step" ".*" "step 4"; # Return from foo()
> -    gdb_test "step" "main \\(\\) at.*" "step 5"
> +    # guarantee that we jump once back to main before entering foo here.
> +    # This makes behavior more consistent over different compilers and
> +    # different compiler versions
> +    gdb_test "finish" ".*" "finish 1"; # Return to main()
> +    gdb_test "step" "foo \\(\\) at.*" "step 2"
> +    # step until we are after foo and bar calls, while making sure that
> +    # we never step into baz.
> +    gdb_test_multiple "step" "step until main" {
> +	# gcc stop in this line before continuing
> +	-re ".*x = baz \\(\\(bar \\(\\), foo \\(\\)\\)\\);.*" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*\}\r\n$gdb_prompt $" {
> +	    send_gdb "step\n"
> +	    exp_continue
> +	}
> +	-re ".*test_skip_file_and_function \\(\\).*" {
> +	    pass "step until main"
> +	}
> +    }
>   }
>   
>   # Test -fi + -fu.


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-05-17 16:38 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-11 20:13 [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 01/11] gdb/testsuite: introduce gdb_step_until_regexp Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 02/11] Change gdb.base/skip-solib.exp deal with lack of epilogue information Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 03/11] change gdb.base/skip.exp to use finish instead of step Bruno Larsen
2022-04-12 18:11   ` Bruno Larsen
2022-05-17 16:38   ` Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 04/11] change gdb.base/symbol-alias to xfail with clang Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 05/11] change gdb.base/nodebug.c to not fail " Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 06/11] update gdb.base/info-program.exp " Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 07/11] fix gdb.base/access-mem-running.exp for clang testing Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 08/11] Fix gdb.base/call-ar-st to work with Clang Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 09/11] add xfails to gdb.base/complex-parts.exp when testing with clang Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 10/11] gdb/testsuite: fix gdb.base/msym-bp-shl when running with Clang Bruno Larsen
2022-04-11 20:13 ` [PATCH v2 11/11] explicitly test for stderr in gdb.base/dprintf.exp Bruno Larsen
2022-04-26 13:17 ` [PING] [PATCH v2 00/11] gdb/testsuite: Cleanup gdb.base for clang testing Bruno Larsen
2022-05-03 20:43   ` [PINGv2] " Bruno Larsen
2022-05-10 20:06     ` [PINGv3] " Bruno Larsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).