From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by sourceware.org (Postfix) with ESMTPS id F2FCF3858424 for ; Wed, 2 Mar 2022 19:00:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F2FCF3858424 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f45.google.com with SMTP id t11so4299856wrm.5 for ; Wed, 02 Mar 2022 11:00:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=jOz6PI1zRFkKTTCRdSZbg6BZLwQXv7l+sYAt5sle1DQ=; b=MqRBepXIs9OyI8BCEJQlfUQQC+SlpJX5hhGTMk9JYPANdO3qZOJ8hxsvMMxRhyqft3 +1rNA87bIl1bR2zw+cvsKYkUBidu0sVDiYRWG19HpYZDCmUG0v0bvDWWTD3eBeIkk6Si LWgw1R7wit53QnJyBQHovdXenkzW7homjWOXerTIeCWzgO7ojaAcR4ElTw07lvMvC+Qk t9XtyxtMDl6VEqaf7yuzABOOFOLJ8LHdK8pz03c36n7IDD/VVjpVnzjzWasGzRx8ulD4 ejXcPo7u1Jk7pfwn0V10GjUy+qn81qpNlsyrLi6Jb1yIAPJ5PjYZPx2yi/d/ksy1AHgm hodA== X-Gm-Message-State: AOAM532CxzbQGq9Atw8AJBGh39sFjanIk4YI1sVtlSN+EEi5hhgyPyHp Vz2NL/AQVIPdwp4uCb4+xb3pLZJtMCw= X-Google-Smtp-Source: ABdhPJwt6a7mTB0voh4OnHaP/2kIvP0r0+VSCIgoiII0CL/e2kwrzFlthE0WR3C7R9FQh/wNVwiiFw== X-Received: by 2002:adf:e7d2:0:b0:1ef:89ec:d84c with SMTP id e18-20020adfe7d2000000b001ef89ecd84cmr15758401wrn.718.1646247601755; Wed, 02 Mar 2022 11:00:01 -0800 (PST) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id a17-20020a5d5091000000b001edb61b2687sm24524094wrt.63.2022.03.02.11.00.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Mar 2022 11:00:00 -0800 (PST) Message-ID: Date: Wed, 2 Mar 2022 18:59:59 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH 07/11] fix gdb.base/call-ar-st to work with clang Content-Language: en-US To: Bruno Larsen , gdb-patches@sourceware.org References: <20220126195053.69559-1-blarsen@redhat.com> <20220126195053.69559-8-blarsen@redhat.com> From: Pedro Alves In-Reply-To: <20220126195053.69559-8-blarsen@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Mar 2022 19:00:04 -0000 On 2022-01-26 19:50, Bruno Larsen via Gdb-patches wrote: > When running this test with clang-compiled code, this test was failing > by producing an output like > array_i=, ... > > instead of > > array_i = , ... > > This commit changes the testcase to accept both outputs, as they are > functionally identical. It would be useful to explain that the symbols in question are local static variables. "main" is the name of the function they are defined in, and Clang puts that in the elf/linkage name. 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 Note that for GCC, even though the ELF symbol is called "integer_array.3968", GDB still prints "integer_array", without the suffix. I wonder how that happens? Anyone knows offhand? It kind of looks like the testcase was expecting that the ".3968" suffix could appear in the output, given that it expects "array_i=" instead of "array_i=" ? > --- > gdb/testsuite/gdb.base/call-ar-st.exp | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > > diff --git a/gdb/testsuite/gdb.base/call-ar-st.exp b/gdb/testsuite/gdb.base/call-ar-st.exp > index d1fb3ac9ec1..e447d3e231d 100644 > --- a/gdb/testsuite/gdb.base/call-ar-st.exp > +++ b/gdb/testsuite/gdb.base/call-ar-st.exp > @@ -153,9 +153,16 @@ if {!$skip_float_test && \ > > #step > set stop_line [gdb_get_line_number "-step1-"] > -gdb_test "step" \ > - "print_all_arrays \\(array_i=, array_c= .ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa., array_f=, array_d=\\) at .*$srcfile:$stop_line\[ \t\r\n\]+$stop_line.*print_int_array\\(array_i\\);.*" \ > - "step inside print_all_arrays" > + > +gdb_test_multiple "step" "" { > + > + -re "print_all_arrays \\(array_i=, array_c= .ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa., array_f=, array_d=\\) at .*$srcfile:$stop_line\[ \t\r\n\]+$stop_line.*print_int_array\\(array_i\\);.*" { > + pass "step inside print_all_arrays" > + } > + -re "print_all_arrays \\(array_i=, array_c= .ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa., array_f=, array_d=\\) at .*$srcfile:$stop_line\[ \t\r\n\]+$stop_line.*print_int_array\\(array_i\\);.*" { > + pass "step inside print_all_arrays (clang)" > + } > +} > If we end up taking the approach of accepting the current GDB output, then it would seem better to me to continue having a single expression. Something like this: >From d024950e743df1712f9adda759023e5ba07ee6e1 Mon Sep 17 00:00:00 2001 From: Bruno Larsen Date: Wed, 2 Mar 2022 18:09:31 +0000 Subject: [PATCH] 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=, array_c= "ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa ZaZaZaZaZaZaZaZaZaZaZaZa", array_f=, array_d=) 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=, array_c= "ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa", array_f=, array_d=) 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=, ... instead of array_i = , ... 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 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=, array_c= .ZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZaZa., array_f=, array_d=\\) 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.26.2