public inbox for
help / color / mirror / Atom feed
* [binutils-gdb] Fix gdb.base/call-ar-st to work with Clang
@ 2022-09-12 12:18 Bruno Larsen
  0 siblings, 0 replies; only message in thread
From: Bruno Larsen @ 2022-09-12 12:18 UTC (permalink / raw)
  To: gdb-cvs;h=39801ed9697c027ae40bc65237d5212980fa48ae

commit 39801ed9697c027ae40bc65237d5212980fa48ae
Author: Bruno Larsen <>
Date:   Wed Jul 20 16:44:33 2022 -0300

    Fix gdb.base/call-ar-st to work with Clang
    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 <>
    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 7c80ec7c0b8..2da438ccd96 100644
--- a/gdb/testsuite/gdb.base/call-ar-st.exp
+++ b/gdb/testsuite/gdb.base/call-ar-st.exp
@@ -147,10 +147,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}"
 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-12 12:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-12 12:18 [binutils-gdb] Fix gdb.base/call-ar-st to work with Clang 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).