From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id UHKjMG5b2GJkTRcAWB0awg (envelope-from ) for ; Wed, 20 Jul 2022 15:45:50 -0400 Received: by simark.ca (Postfix, from userid 112) id C3A861E5EA; Wed, 20 Jul 2022 15:45:50 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=mUNTgqnx; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 5E1F71E21F for ; Wed, 20 Jul 2022 15:45:50 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0FE423856097 for ; Wed, 20 Jul 2022 19:45:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0FE423856097 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1658346350; bh=M5QRTj7/IpKOjlF6av/w9BjlcZMOhGcXFmtCVzO8mmc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=mUNTgqnxEAxMOepVRm691SNSVk2Iqv82A8O4Rdg1KxjJV2IbXb3L5VLLVOyvDrT2w 8ywcjSsxFJO5pq/Nf/TrkiTO6G6hUMsnWMRB2XYR/6/AN9hj7lJQ5Ilt+rgFnTRofz sOd8bzJfkTZIdD6ir5sdr2PyqguP3kGI12hl5udk= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 676813857B96 for ; Wed, 20 Jul 2022 19:45:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 676813857B96 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-209-tl7wXfP_NTK_sD80b6dLvQ-1; Wed, 20 Jul 2022 15:45:03 -0400 X-MC-Unique: tl7wXfP_NTK_sD80b6dLvQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76524852AC1; Wed, 20 Jul 2022 19:45:03 +0000 (UTC) Received: from blarsen.com (ovpn-116-8.gru2.redhat.com [10.97.116.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 67D0D403D0C1; Wed, 20 Jul 2022 19:45:02 +0000 (UTC) To: gdb-patches@sourceware.org Subject: [PATCH v4 07/15] Fix gdb.base/call-ar-st to work with Clang Date: Wed, 20 Jul 2022 16:44:33 -0300 Message-Id: <20220720194441.168906-9-blarsen@redhat.com> In-Reply-To: <20220720194441.168906-1-blarsen@redhat.com> References: <20220720194441.168906-1-blarsen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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: , From: Bruno Larsen via Gdb-patches Reply-To: Bruno Larsen Cc: Pedro Alves Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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 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}" +} + #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.31.1