diff options
author | Bruno Larsen <blarsen@redhat.com> | 2022-07-20 16:44:33 -0300 |
---|---|---|
committer | Bruno Larsen <blarsen@redhat.com> | 2022-09-12 14:09:07 +0200 |
commit | 39801ed9697c027ae40bc65237d5212980fa48ae (patch) | |
tree | 12fe81c4e779285bfe782d7ea32f1f5f0b467aa8 /gdb/testsuite | |
parent | 96ca89d245e262578ef565247c1d68dff493d8a3 (diff) | |
download | gdb-39801ed9697c027ae40bc65237d5212980fa48ae.zip gdb-39801ed9697c027ae40bc65237d5212980fa48ae.tar.gz gdb-39801ed9697c027ae40bc65237d5212980fa48ae.tar.bz2 |
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 <pedro@palves.net>
Change-Id: Iaf2ccdb9d5996e0268ed12f595a6e04b368bfcb4
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/gdb.base/call-ar-st.exp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.base/call-ar-st.exp b/gdb/testsuite/gdb.base/call-ar-st.exp index 7c80ec7..2da438c 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}" +} + #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 |