From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7862) id 9B6813856243; Mon, 12 Sep 2022 12:18:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9B6813856243 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1662985088; bh=a9euX7ikxEtA/HPwIF/cxh6MhxgZTttLjjPQu/eFAbU=; h=From:To:Subject:Date:From; b=xSyumVs/dKz/THpKj1iVHwNLmcMbj2wmWK3nvsRYpg+uLoPe5dmwMq+aE6lTNyIEC UdKzxaT5Tp788c0rpSPSmHFV20Hq18MJDMrjVaftpSeTylQ3i6nFI1yPx3ocsT6HVX PMMwAx+H0LIgYR1qoxx3oHh+s71sZfYoFDJrylrw= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Bruno Larsen To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Fix gdb.base/call-ar-st to work with Clang X-Act-Checkin: binutils-gdb X-Git-Author: Bruno Larsen X-Git-Refname: refs/heads/master X-Git-Oldrev: 96ca89d245e262578ef565247c1d68dff493d8a3 X-Git-Newrev: 39801ed9697c027ae40bc65237d5212980fa48ae Message-Id: <20220912121808.9B6813856243@sourceware.org> Date: Mon, 12 Sep 2022 12:18:08 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D39801ed9697c= 027ae40bc65237d5212980fa48ae commit 39801ed9697c027ae40bc65237d5212980fa48ae Author: Bruno Larsen Date: Wed Jul 20 16:44:33 2022 -0300 Fix gdb.base/call-ar-st to work with Clang =20 When running gdb.base/call-ar-st.exp against Clang, we see one FAIL, like so: =20 print_all_arrays (array_i=3D, array_c=3D "ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa= ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa ZaZaZaZaZaZaZaZaZaZaZaZa", array_f=3D, array_d=3D) 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 =20 With GCC we instead see: =20 print_all_arrays (array_i=3D, array_c=3D "Z= aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa= ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa", array_f=3D, arr= ay_d=3D) 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 =20 The difference is that with Clang we get: =20 array_i=3D, ... =20 instead of =20 array_i =3D , ... =20 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: =20 $ nm -A call-ar-st.gcc | grep integer_ call-ar-st/call-ar-st:00000000000061a0 b integer_array.3968 =20 $ nm -A call-ar-st.clang | grep integer_ call-ar-st:00000000004061a0 b main.integer_array =20 This commit changes the testcase to accept both outputs, as they are functionally identical. =20 Co-Authored-By: Pedro Alves Change-Id: Iaf2ccdb9d5996e0268ed12f595a6e04b368bfcb4 Diff: --- 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" ".*" "" } =20 +# 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=3D, array_c=3D .ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZ= aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa., array_f=3D, array_d=3D\\) at .*$srcfile:$stop_line\[ \t\r\n\]+$st= op_line.*print_int_array\\(array_i\\);.*" \ + "print_all_arrays \\(array_i=3D<[main_static_local_re integer_array]>,\ + array_c=3D<[main_static_local_re char_array]> .ZaZaZaZaZaZaZaZaZaZaZaZ= aZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa= ZaZaZaZaZaZaZaZaZaZaZa.,\ + array_f=3D<[main_static_local_re float_array]>,\ + array_d=3D<[main_static_local_re double_array]>\\)\ + at .*$srcfile:$stop_line\[ \t\r\n\]+$stop_line.*print_int_array\\(arra= y_i\\);.*" \ "step inside print_all_arrays" =20 #step -over