From patchwork Fri Nov 11 16:36:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 60432 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8C1D13858025 for ; Fri, 11 Nov 2022 16:37:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C1D13858025 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668184627; bh=FbksmJy+fSYgwuqW+YXlZJe2jh7/laEr96nx+j3lUJc=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=slZ5xphdYzZkBI/ZtJ/uNtwIHXdZCKg1szmi3iFosHLt2UazcNTu4odqZcIMVm2y2 K11ueq0R4KAN98+i339ns/WlT8nR9IcJR5NvDoLusJxmfET1Wq+d70tRtgDc5jWVWN 4KmQXyZrHsqi6LGgWv4JkQ5tToaA9n5eFAYgDV0M= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org 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 23E243858D35 for ; Fri, 11 Nov 2022 16:36:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 23E243858D35 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-453-o8ZMKgH7NzeSAlnH0pDbbg-1; Fri, 11 Nov 2022 11:36:33 -0500 X-MC-Unique: o8ZMKgH7NzeSAlnH0pDbbg-1 Received: by mail-qt1-f198.google.com with SMTP id i13-20020ac8764d000000b003a4ec8693dcso3954569qtr.14 for ; Fri, 11 Nov 2022 08:36:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FbksmJy+fSYgwuqW+YXlZJe2jh7/laEr96nx+j3lUJc=; b=ubTEWKw5KXln4xAvI9vYRWb6zUPfDeziAWXDO4fSigL5lcbjSK51rO6HazTI5abhs9 Yl0MexTuygfQ76q8ab2Q+1OwGnh2sSIts2mjmSvTvBknBfvjNI804euqFSKMKNmKQh8t TGNceSnWtsH7y7JUXHmiF2mpQZy/FjmRLlVqwGthCF7TNzU7Ozt46NQovptaiOifqXZ7 JI4rI0vj8pxIwYewi1MwUuRTwVEDr0zk8fp71xZz4HudYyKibrL26EpLYhLm9IeBfJRe ueHK+e6opOuoiEoNBdwuel6G0xB+mYHDNJ4M0ToW5TSPBeYzUwd+wK1wVPGLreSLMiEg v+EA== X-Gm-Message-State: ANoB5pnhYCj/XkIt7Yy//mLN9v1F5KFGvPR0R/N4gsfC1iUeePiPiNi6 NSijW0mEqB25CtYhtQUI8fT5oaHJw23xf9rH4/w7554Ids/weWjUuNbr77MhAg/BzyAc8yH0s7e Q08Q+5o3NGJS3ZurJvk7iyh2StK7lyGaq1/2fzCnX3lG+vnI7JMEJXXJV7M6sm2NPFBJBPwBf7g == X-Received: by 2002:a05:6214:887:b0:4c6:141f:819d with SMTP id cz7-20020a056214088700b004c6141f819dmr2635236qvb.34.1668184592993; Fri, 11 Nov 2022 08:36:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf65rC8NmhBFSqb+JbYjGW0Hh4qgeFVU/TECwtgcIocLEgVMV7rqQXmAEPsM3LowffDOyXRYRg== X-Received: by 2002:a05:6214:887:b0:4c6:141f:819d with SMTP id cz7-20020a056214088700b004c6141f819dmr2635225qvb.34.1668184592745; Fri, 11 Nov 2022 08:36:32 -0800 (PST) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id n16-20020a05620a295000b006b640efe6dasm1635072qkp.132.2022.11.11.08.36.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 08:36:32 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 1/6] gdb/testsuite: don't avoid DWARF assembler tests with Clang Date: Fri, 11 Nov 2022 16:36:20 +0000 Message-Id: <91331c625a5a332ca1d3286ccc3a9ef21b6d1218.1668184173.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Two tests make the claim that the DWARF assembler requires gcc, however, this isn't true. I think at one point, when the DWARF assembler was first added, we did use some techniques that were not portable (see the comments in lib/dwarf.exp on function_range for details), however, I think most DWARF assembler tests will now work fine with Clang. The two tests that I modify in this commit both work fine with Clang, at least, I've tested with Clang 9.0.1 and 15.0.2, and don't see any problems, so I'm removing the early return logic that stops these tests from running with Clang. --- gdb/testsuite/gdb.base/until-trailing-insns.exp | 6 ------ gdb/testsuite/gdb.cp/incomplete-type-overload.exp | 5 ----- 2 files changed, 11 deletions(-) diff --git a/gdb/testsuite/gdb.base/until-trailing-insns.exp b/gdb/testsuite/gdb.base/until-trailing-insns.exp index 6396b6650c1..56f6cf038e2 100644 --- a/gdb/testsuite/gdb.base/until-trailing-insns.exp +++ b/gdb/testsuite/gdb.base/until-trailing-insns.exp @@ -84,12 +84,6 @@ if {![dwarf2_support]} { return 0 } -# The DWARF assembler requires the gcc compiler. -if {![is_c_compiler_gcc]} { - unsupported "gcc is required for this test" - return 0 -} - standard_testfile .c .S if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { diff --git a/gdb/testsuite/gdb.cp/incomplete-type-overload.exp b/gdb/testsuite/gdb.cp/incomplete-type-overload.exp index 96ed25dd5d1..024014d68ba 100644 --- a/gdb/testsuite/gdb.cp/incomplete-type-overload.exp +++ b/gdb/testsuite/gdb.cp/incomplete-type-overload.exp @@ -31,11 +31,6 @@ if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}] { return } -if {[test_compiler_info clang-*-*]} { - untested "gcc is required for dwarf assembler tests" - return -} - if ![runto_main] { return } From patchwork Fri Nov 11 16:36:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 60433 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E38763842AC0 for ; Fri, 11 Nov 2022 16:37:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E38763842AC0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668184629; bh=fZaYQI8YTBuJNIr8AogTwAfwQHiZIndCbIF7X3n/OZo=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=EeTJ8X2T1a6Scar4gJQ2LPg3uuvenV/zuQUBugr5MfTvPCd8NNXwG9NxosNlWCocs kryaSc82R//6T2ne02foPivyQ457dWQNOlRU7EMLpN8809QmGtC8O4LDKElduz31jf FNgZ+dufw8CwaqyT+kScp8msQuBw3a0CZJkugwvY= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 4DFE83858C27 for ; Fri, 11 Nov 2022 16:36:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4DFE83858C27 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-246-wdcURWxnOuioeqKoAdz6Xg-1; Fri, 11 Nov 2022 11:36:36 -0500 X-MC-Unique: wdcURWxnOuioeqKoAdz6Xg-1 Received: by mail-qk1-f197.google.com with SMTP id o13-20020a05620a2a0d00b006cf9085682dso5101282qkp.7 for ; Fri, 11 Nov 2022 08:36:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fZaYQI8YTBuJNIr8AogTwAfwQHiZIndCbIF7X3n/OZo=; b=Hn3J8Kfvqh7WHM7k4tIjfVKO3bCfzbJXnQHnrzUMGgPAD1TP1JiPkQh7LBo9+JNuYG vHtiRG0UJqtw9sARxgwiARTuXKkm9dPYXpLLpf4oyJOSf1foZ3FmHFNxC8VRpPSnefYl 5x2VGWv+c2/kisXyA4cDbig+onRUymsReZXS1CSNKCKQ5H5pVNXklfeUFMqc1dDTpRvf WivHNiEI+Q9JHxyUqhBZaSq4B2sL1Uw3vRGBWNAqtFfqpY/hXWNtts/W81i4bctB5qzY 30bloaBhd5K64JC50kOMTdFggdcu7icUQ/DyjKo2CIJWMYvGj3iXojBz4IRxlxD9Hf1Y eLig== X-Gm-Message-State: ANoB5plB1cOGkxPuwXG+sSHMJTcNNI93SywQJSOPR8yKGHAIQICHD+Bb mrQv2QZoYf++VTK4UuxinrLsbbEwrrCEPZ91xuV/o2xzZ2j2TuRvHDdPL0YP9VtgUqf7Nc+jeyB TQAV7EZeXOs9ciKuijidCYC+0kr0f8uLymFygJeYtXnijM9v19PC6LExWG7TyliJ9YM1aSgPmuw == X-Received: by 2002:a05:620a:c09:b0:6ce:3f1c:a4ef with SMTP id l9-20020a05620a0c0900b006ce3f1ca4efmr1768366qki.507.1668184595361; Fri, 11 Nov 2022 08:36:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf5glZgb0YwcYXPlErnimQ/mFcJUgIqaVT+LfKTFRtLklNMJYfH62t7/Z/sPZNpvwxqhnYrmoA== X-Received: by 2002:a05:620a:c09:b0:6ce:3f1c:a4ef with SMTP id l9-20020a05620a0c0900b006ce3f1ca4efmr1768342qki.507.1668184595018; Fri, 11 Nov 2022 08:36:35 -0800 (PST) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id f17-20020ac859d1000000b0039467aadeb8sm1515841qtf.13.2022.11.11.08.36.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 08:36:34 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 2/6] gdb/testsuite: fix gdb.trace/unavailable-dwarf-piece.exp with Clang Date: Fri, 11 Nov 2022 16:36:21 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I noticed that the test gdb.trace/unavailable-dwarf-piece.exp was failing when run with Clang. Or rather, the test was not running as the test executable failed to compile. The problem is that Clang was emitting this warning: warning: argument unused during compilation: '-fdiagnostics-color=never' [-Wunused-command-line-argument] This warning is emitted when compiling the assembler file generated by the DWARF assembler. Most DWARF assembler tests generate the assembler file into a file with the '.S' extension. However, this particular test uses a '.s' extension. Now a .S file will be passed through the preprocessor, while a .s will be sent straight to the assembler. My guess is that Clang doesn't support the -fdiagnostics-color=never option for the assembler, but does for the preprocessor. That's a little annoying, but easily worked around. We don't care if our assembler file is passed through the preprocessor, so, in this commit, I just change the file extension from .s to .S, and the problem is fixed. Currently, the unavailable-dwarf-piece.exp script names the assembler file using standard_output_file, in this commit I've switched to make use of standard_testfile, as that seems to be the more common way of doing this sort of thing. With these changes the test now passes with Clang 9.0.1 and 15.0.2, and also still passes with gcc. --- gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp b/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp index f80f8005fcf..13c6f38737c 100644 --- a/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp +++ b/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp @@ -20,9 +20,9 @@ if {![dwarf2_support]} { return 0 } -standard_testfile .c +standard_testfile .c -dbg.S -set asm_file [standard_output_file "${testfile}-dbg.s"] +set asm_file $srcfile2 set opts {} if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile}1.o \ From patchwork Fri Nov 11 16:36:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 60434 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B338C383EC43 for ; Fri, 11 Nov 2022 16:37:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B338C383EC43 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668184633; bh=SBS2MvXVLo2wTLHjP+nXT8Bw62ZGXxrOkCDE+4JWgSM=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=QHAu0JZeP8fP0S8x9RvZI6oEdkS6xOF6/N3mQBqB8IS7sOkZZ3WFaMDfg86StuBiM eumCXbxQHTtLUEkVi1neKipDU2l4EhGpjzv/APyh+I1J2gwdMuFNAP0sdF/7OVywuP PDgUc3O1EjR/xtcQEHe0rkd1ABAifQsC2vNYZZ5Q= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org 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 EF94538582AC for ; Fri, 11 Nov 2022 16:36:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EF94538582AC Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-407-AiaffWBtNBm3QLR7I8ABFw-1; Fri, 11 Nov 2022 11:36:38 -0500 X-MC-Unique: AiaffWBtNBm3QLR7I8ABFw-1 Received: by mail-qk1-f198.google.com with SMTP id v7-20020a05620a0f0700b006faffce43b2so5086037qkl.9 for ; Fri, 11 Nov 2022 08:36:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SBS2MvXVLo2wTLHjP+nXT8Bw62ZGXxrOkCDE+4JWgSM=; b=wV7wDCv1JBAof6aerD+8lnbtR05OuSFpHXMEYJ1IoM7DV9hmV0ipGHH1a+zdwsj/T3 ikxcNCSNWnOQWhKKcehIe+AIsNJ0sl0KBYsVec+JAn2sqPaXatzCVInxAGIMrWwaFR/V 2P1Mdgxojb+qhw+lt3ZfEw5LyX8M+5ZfhYNJbDyqKtuGAAcAG/R5WgWqElG12FYBQ2b2 0WPb+ffbrXME+cEWCiAQALDvkW8k7Qtr3VahdVREQQp81uSLTFdhcfckLiZBves+CxUw SFL1T96dj7h/6YaeB4CVrrVrP1s02BO7523PphfGJ0642UKUKYxRxI1iDSzfPHpZGxVa Oy+Q== X-Gm-Message-State: ANoB5pmkRfI5rNdbJehyfV+OMsmxUKJ8Niy9+tyTUoHTJFiqZobSIk59 Alp/wpqX1G7PnLjz0hiElApkF7XQn8rNZAJO0ABk0jXG3v+RhIzr4qPSvTYpAHLun62rYwryk49 MJ+V3hWfUnCOPsl/l88wBrBoI7AOp9Bqp66z/iCL09/lTg54h+MhcljYrK7Q++RyGvFr6G2mDWA == X-Received: by 2002:a05:622a:5816:b0:3a5:1a23:ca39 with SMTP id fg22-20020a05622a581600b003a51a23ca39mr2037780qtb.109.1668184597786; Fri, 11 Nov 2022 08:36:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf5NmVTvZuz64VgydvFFcwihQ7VeHSYZt0STLuoatBWdOo81NN7N0h23VRCHPmqsMcNTuD+gZw== X-Received: by 2002:a05:622a:5816:b0:3a5:1a23:ca39 with SMTP id fg22-20020a05622a581600b003a51a23ca39mr2037748qtb.109.1668184597474; Fri, 11 Nov 2022 08:36:37 -0800 (PST) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id v22-20020a05620a441600b006faac3c33b8sm1738723qkp.27.2022.11.11.08.36.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 08:36:37 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 3/6] gdb/testsuite: fix gdb.compile/compile-ops.exp with clang Date: Fri, 11 Nov 2022 16:36:22 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I noticed that the gdb.compile/compile-ops.exp test was failing when run with Clang as the compiler. This test makes use of the DWARF assembler, and, it turns out, uses a technique which is not portable to Clang. This problem is described in the comment on the function_range proc in lib/dwarf.exp, the explanation is: # If the compiler is gcc, we can do the following to get function start # and end address too: # # asm ("func_start: .globl func_start"); # static void func (void) {} # asm ("func_end: .globl func_end"); # # however, this isn't portable, because other compilers, such as clang, # may not guarantee the order of global asms and function. The code # becomes: # # asm ("func_start: .globl func_start"); # asm ("func_end: .globl func_end"); # static void func (void) {} These start/end labels are used for computing the function start, end, and length. The portable solution is to place a label within the function, like this: # int main (void) # { # asm ("main_label: .globl main_label"); # return 0; # } And make use of 'proc function_range' (from lib/dwarf.exp). So, that's what I do in this commit. One consequence of this change is that we need to compile the source file, and have it loaded into a GDB session, before calling function_range, so I've added an early call to prepare_for_testing. Additionally, this test script was generating the DWARF assembler into a file called gdbjit-ops.S, I suspect a copy and paste issue there, so I've switched this to use compile-ops-dbg.S instead, which is more inline with what other DWARF assembler tests do. The only other change, which might be a problem, is that I also deleted these two lines from the source file: asm (".section \".text\""); asm (".balign 8"); These lines were setting the alignment of the .text section. What I don't know is whether this was significant or not. If it is significant, then I can't see why. On x86-64, the test still passes fine without these lines, but that doesn't mean the test wont start failing on some other architecture. Still, I figure, lets remove them, then, if/when we find a test that starts failing, we can add the lines back, along with an explanation for why the extra alignment is required. But, if people would prefer to be more conservative, then I'm happy to just add the lines back. --- gdb/testsuite/gdb.compile/compile-ops.c | 8 ++------ gdb/testsuite/gdb.compile/compile-ops.exp | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/gdb/testsuite/gdb.compile/compile-ops.c b/gdb/testsuite/gdb.compile/compile-ops.c index 28afe628e35..7a35909e21e 100644 --- a/gdb/testsuite/gdb.compile/compile-ops.c +++ b/gdb/testsuite/gdb.compile/compile-ops.c @@ -18,20 +18,16 @@ int value = 0xdeadf00d; int *ptr = &value; -asm (".section \".text\""); -asm (".balign 8"); -asm ("func_start: .globl func_start"); - static void func (void) { + asm ("func_label: .globl func_label"); } -asm ("func_end: .globl func_end"); - int main (void) { + asm ("main_label: .globl main_label"); func (); return 0; } diff --git a/gdb/testsuite/gdb.compile/compile-ops.exp b/gdb/testsuite/gdb.compile/compile-ops.exp index b3b14d949d8..76f284f52f3 100644 --- a/gdb/testsuite/gdb.compile/compile-ops.exp +++ b/gdb/testsuite/gdb.compile/compile-ops.exp @@ -23,7 +23,7 @@ if {![dwarf2_support]} { return 0 } -standard_testfile .c gdbjit-ops.S +standard_testfile .c -dbg.S # # A port of the pr10770.c test code to the DWARF assembler format. @@ -354,9 +354,17 @@ set program [subst { addr ptr }] +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { + return -1 +} + # Make some DWARF for the test. set asm_file [standard_output_file $srcfile2] Dwarf::assemble $asm_file { + + # Find start, end, and length of "func". + get_func_info func + # Creating a CU with 4-byte addresses lets this test link on both # 32- and 64-bit machines. cu { addr_size 4 } { @@ -366,8 +374,8 @@ Dwarf::assemble $asm_file { compile_unit { {name file1.txt} {language @DW_LANG_C} - {low_pc func_start addr} - {high_pc func_end addr} + {low_pc $func_start addr} + {high_pc $func_end addr} } { global program @@ -380,8 +388,8 @@ Dwarf::assemble $asm_file { subprogram { {external 1 flag} {name func} - {low_pc func_start addr} - {high_pc func_end addr} + {low_pc $func_start addr} + {high_pc $func_end addr} } { formal_parameter { {name param} From patchwork Fri Nov 11 16:36:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 60435 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8358D3886C49 for ; Fri, 11 Nov 2022 16:37:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8358D3886C49 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668184657; bh=6W6G1pIwD1ptpJXrB+TrrHJRsVrqT67twZuRevrbTBk=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=yEK13RVIZMsihkhCTT/NOsRC2iJrHzPCaRxXSkYBdddVj/cDx2A2dRwhVuLEf4ENR 1RWgtD4ifrGRj5ThOjbXAmdVgZ6iuurU05nri695D8+NCj2B4xGXAU+dk24+ZX1HFL fJMWCPcXnldhlRL8R3nMGtnTj8+9uIOHex8yfuvs= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 8CD063858C00 for ; Fri, 11 Nov 2022 16:36:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8CD063858C00 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-338-erEphBI9PQOz2cta4XrUHw-1; Fri, 11 Nov 2022 11:36:40 -0500 X-MC-Unique: erEphBI9PQOz2cta4XrUHw-1 Received: by mail-qt1-f199.google.com with SMTP id s14-20020a05622a1a8e00b00397eacd9c1aso3966949qtc.21 for ; Fri, 11 Nov 2022 08:36:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6W6G1pIwD1ptpJXrB+TrrHJRsVrqT67twZuRevrbTBk=; b=WVfMm0pkClrdtSW94AoFepXCHem1qBYuqCchSSVmo+cpAoUEnb0LPIDcWYdz7GGfA3 sZDnqqaWZ/4GPXLusmWu1yGN6tEa7TXf+Z5NSnHvl4TQwiYHAEpgFYy874zEL4UyD8wF Annwf6bFK949+/yWDqL0/gzB/6Q1zBODfDge+hVfod+p4kRV/C2ZYR4zGzukzK1hiobO atZardeT6Q4IUJMuvdifbkvJkpj21K3OakQQV9qGU7+XKP3KAjF7sbfD0/HOs4ayQlPh LrmNfMGJTuV4+4BAQbhIaEqx7+V5pLPAHFEdl+cVpahrCzCvOT5hATHlruVX3O15qsmm M9Cg== X-Gm-Message-State: ANoB5plqdpwgVkf5gVYkEIu219FJ0QZsgEWJslSulC5Pz569So1OLYGV /Rfk7sivW2XVvURsvpyONloaANVEA26a8GTuwhvr/q+2tKhKycswoUzKrWB/++YTAcjEL7Opuha d9vDd1Uz7kkZXvXfCuuwwMgwGQD145xERQCzsNFDfCK7mpCM9XzKt/aoZ6MlR7I+4zY8L3TpLXw == X-Received: by 2002:a05:622a:2595:b0:3a5:62e4:b972 with SMTP id cj21-20020a05622a259500b003a562e4b972mr2002948qtb.198.1668184600249; Fri, 11 Nov 2022 08:36:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf5bDHSsfdGEyjRN3ewumxOsRtCUDouXOjUevq0Q69+p3YQpb0uLZ8mMf07HR0fsW/91HOr+gg== X-Received: by 2002:a05:622a:2595:b0:3a5:62e4:b972 with SMTP id cj21-20020a05622a259500b003a562e4b972mr2002918qtb.198.1668184599915; Fri, 11 Nov 2022 08:36:39 -0800 (PST) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id r17-20020ae9d611000000b006ee7e223bb8sm1687975qkk.39.2022.11.11.08.36.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 08:36:39 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 4/6] gdb/testsuite: add (and use) a new build-id compile option Date: Fri, 11 Nov 2022 16:36:23 +0000 Message-Id: <1d74d73394e4c2b97ea6a0009ace830ac7399db7.1668184173.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I noticed that the gdb.debuginfod/fetch_src_and_symbols.exp test was failing when run with Clang as the compiler. This test relies on the compiled binaries having a build-id within them. For GCC, really GNU ld, the default is to always include a build-id. When compiling with Clang though, the default is for no build-id. I did consider *always* turning on the build-id feature when the compiler is Clang, but that felt a little weird. Instead, I propose that we add a new 'build-id' compiler option to gdb_compile, this flag indicates that the test _requires_ a build-id. In gcc_compile we can then add the required flags if the compiler is Clang so that we do get a build-id. With this change the gdb.debuginfod/fetch_src_and_symbols.exp test now (mostly) passes with Clang 9.0.1 and 15.0.2, and still passes with gcc. The 'mostly' part is an unrelated issue, and will be addressed in a later commit in this series. --- gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp | 4 ++-- gdb/testsuite/lib/gdb.exp | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp index 9bffb3397ec..b57b3201cf7 100644 --- a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp +++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp @@ -32,12 +32,12 @@ if { [catch {file copy -force ${srcdir}/${subdir}/${srcfile} \ return -1 } -if { [gdb_compile "$sourcetmp" "$binfile" executable {debug}] != "" } { +if { [gdb_compile "$sourcetmp" "$binfile" executable {debug build-id}] != "" } { untested "failed to compile" return -1 } -if { [gdb_compile "$sourcetmp" "${binfile}2" executable {debug}] != "" } { +if { [gdb_compile "$sourcetmp" "${binfile}2" executable {debug build-id}] != "" } { fail "compile" return -1 } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 3e0a46445ca..b006d0fe855 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -4684,6 +4684,7 @@ set gdb_saved_set_unbuffered_mode_obj "" # - macros: Add the required compiler flag to include macro information in # debug information # - text_segment=addr: Tell the linker to place the text segment at ADDR. +# - build-id: Ensure the final binary includes a build-id. # # And here are some of the not too obscure options understood by DejaGnu that # influence the compilation: @@ -4746,6 +4747,14 @@ proc gdb_compile {source dest type options} { } } + # If the 'build-id' option is used, then ensure that we generate a + # build-id. GCC does this by default, but Clang does not, so + # enable it now. + if {[lsearch -exact $options build-id] > 0 + && [test_compiler_info "clang-*"]} { + lappend new_options "additional_flags=-Wl,--build-id" + } + # Treating .c input files as C++ is deprecated in Clang, so # explicitly force C++ language. if { !$getting_compiler_info From patchwork Fri Nov 11 16:36:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 60437 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 28CB43885503 for ; Fri, 11 Nov 2022 16:38:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 28CB43885503 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668184686; bh=AJiBi3KVh4t5LkwYToZWuJjU26pF8WCSmWElXgF1rQw=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=sVe9dec7fjDO4V+mTm8jCLQRb1elANapKyBJKVwNYdOh55PX5cYvGG43QXVoWfp3A hNRrsY3fPN3hglFLFKbAnBnHZIINIK4CKUizUzs2w1mgdcrpmvz2bpr64LQRsyyUt6 I7zfK9HB77gg0d3goceYOGPegNeP+f6n0AbFXJbs= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 68F1A3858017 for ; Fri, 11 Nov 2022 16:36:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 68F1A3858017 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-148-QmkitUJ8PaW-9GFUGgQycQ-1; Fri, 11 Nov 2022 11:36:43 -0500 X-MC-Unique: QmkitUJ8PaW-9GFUGgQycQ-1 Received: by mail-qt1-f198.google.com with SMTP id cm12-20020a05622a250c00b003a521f66e8eso3942758qtb.17 for ; Fri, 11 Nov 2022 08:36:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AJiBi3KVh4t5LkwYToZWuJjU26pF8WCSmWElXgF1rQw=; b=MHmngdEg9Xyym7DMLuix4U3bP6mPCX1um0Kdgaqrh8j09rrJmIGPZAA8OaiHLNZUog PJXbQ+iMyLW/271U3EZmyyrYpM51J7/hi/GvtcjhMxQOYdyepFJonCLLRSf7DHZwXrvY fQYPXEU22YhjxrAEeuG0FBYzetfbyZK9cn7wGfarKzeeY+XxJeHJuzSBlLN3/EIaHJ/C p4gMOo8B1/TPsMzf5ECVG4FqrbG4JqGY4A+Ny8189O+RnBw79v1AtLw0nE81BbpOsmzp ubeGG7Jy/JglHdAeXmvNIFsDHyoTS/LzvwAsBI7d9ZOtM4kcLtdPMKCq+w+cfC7KBoCf g5MA== X-Gm-Message-State: ANoB5pl1BRPtPL50xoRVGWDCA55vlrLVhZhkbKUw7Ov5ScLN/UV2586C dba5oto5LujshtSAgZBVI+AMxRbv2yUBu75PnNc+12k+ptvKm2Jn+i/4eMHRQEE+kZLPzuR4lAi Io+5TE+Zh5mOtpkbI3xcBq2gCDMuHRHsPB2keFEVl5q3BtcN84FoCH3O2ofDwnmHpDgUYP1sI8g == X-Received: by 2002:a05:622a:1a86:b0:3a5:8a24:e6bf with SMTP id s6-20020a05622a1a8600b003a58a24e6bfmr2018333qtc.529.1668184602469; Fri, 11 Nov 2022 08:36:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf7YneHyDBE2vDvznSXNiFPCvwcurdhq1LQ9u98v7Xyn1wsWHYpcWXCnqgl3RBy7be+1YhW9Dg== X-Received: by 2002:a05:622a:1a86:b0:3a5:8a24:e6bf with SMTP id s6-20020a05622a1a8600b003a58a24e6bfmr2018305qtc.529.1668184602145; Fri, 11 Nov 2022 08:36:42 -0800 (PST) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id u12-20020a05620a084c00b006bc192d277csm1642138qku.10.2022.11.11.08.36.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 08:36:41 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 5/6] gdb/testsuite: fix gdb.debuginfod/fetch_src_and_symbols.exp with Clang Date: Fri, 11 Nov 2022 16:36:24 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" The gdb.debuginfod/fetch_src_and_symbols.exp test is showing a single failure when run with some older versions of Clang, e.g. 9.0.1. The problem appears to be with Clang's generated line table. The test source looks like this: int main() { asm ("main_label: .globl main_label"); return 0; } In GDB, when we 'start', we expect to stop at the 'return 0;' line. This is the behaviour when the compiler is gcc, or later versions of Clang. However, with Clang 9.0.2, I see GDB stop on the 'asm' line. I propose adding some code to the test script to step GDB onto the next line if we stop on the 'asm' line. With this change in place, I now see the test fully passing with Clang 9.0.1 and 15.0.2, as well as with gcc. --- .../gdb.debuginfod/fetch_src_and_symbols.exp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp index b57b3201cf7..cebaa435102 100644 --- a/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp +++ b/gdb/testsuite/gdb.debuginfod/fetch_src_and_symbols.exp @@ -161,6 +161,27 @@ proc_with_prefix no_url { } { if ![runto_main] { return -1 } + + # Some older versions of Clang (e.g. 9.0.1) were observed stopped + # at the 'asm' line rather than the 'return' line in main.c. This + # messes up some of the expected patterns later in the test. + set rtn_lineno [gdb_get_line_number "return 0;"] + set prev_lineno [expr $rtn_lineno - 1] + gdb_test_multiple "info line" "" { + -wrap -re "\r\nLine ${prev_lineno} of .*" { + gdb_test "step" + pass $gdb_test_name + } + -wrap -re "\r\nLine ${rtn_lineno} of .*" { + pass $gdb_test_name + } + -wrap -re "\r\nLine ${::decimal} of .*" { + # Not sure what line this stopped on, but later tests are + # probably going to fail. + fail $gdb_test_name + } + } + gdb_test "generate-core-file $::corefile" "Saved corefile $::corefile" \ "file [file tail $::corefile] gen" file rename -force ${binfile}2 $debugdir From patchwork Fri Nov 11 16:36:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 60436 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8E6FF3858C36 for ; Fri, 11 Nov 2022 16:38:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8E6FF3858C36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668184681; bh=Ls8USQt4xqhErKZEDHGKC4+jBFkpTTUScDeKtZgnRMM=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=y0qS4fbTGlab0sNyuL6HFO/Br2qLBpTJ+nl9TDJKl283lGOEXcAaSb67o9ITXQVZL YT8PvVNhnMsw3o732q8EDcdec22RUfxLyyFLW3XFbq7Kv+nVXaOc2BK7pTmgHsI607 B4gJ3ugfrt+eBm9H/NQIxoBhk5/DLJm620vBIx2Y= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 944603858408 for ; Fri, 11 Nov 2022 16:36:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 944603858408 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-558-O5qUWFYTPHi3posqw0XPrw-1; Fri, 11 Nov 2022 11:36:45 -0500 X-MC-Unique: O5qUWFYTPHi3posqw0XPrw-1 Received: by mail-qv1-f72.google.com with SMTP id on28-20020a056214449c00b004bbf12d7976so3960997qvb.18 for ; Fri, 11 Nov 2022 08:36:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ls8USQt4xqhErKZEDHGKC4+jBFkpTTUScDeKtZgnRMM=; b=58xdGLKUl/832fMisb8gdCPZ73tQ3ysII5Q1hLyHsrE37c3QmpgcXN8eiYfnIfPa5H KJerlkcTT0y/6+qnIotghK3NHrJ33lCCKmY8e/9vIjTA3Y/K+OcEgjMuEZkTgVrBUTM7 jnpSQe1gJmo50SbEPc+vRKHEbOlIn9SsjlYyA6bh1WRGprdohcDdJwfUJzjk55u3FC0o eQ+YeX7fzftnh9znsgyubHRsql7zrmA9MI9T/Xk8ejX3f3cGF+OLgQGxMb0mgUl1RLkb KP7j3J6wSp57szB/ZAbzKAPIbiLiOGsiSVhFH4LHOSxwTI8EPM0Gm6BFqgeSR+yL0VoV VKlQ== X-Gm-Message-State: ANoB5pkjxYEEDTRSBEhbjOAYZXKLhNeEREomWuzKEuLWKwTY1fc8rJEu m/sP1I/KjCwgLxPFrgjD8/HUYNOkaFHyINrOLelbSksrrUX/8l2+Rk5eX0i1eBa9f8PCeecnUpU w6Uj2rWjos8Hykn7M48mt1HuS/X8O6+/S/lCg00RpWS3ZMAKFX0bsB3NN1PKCra++azFlVtawEQ == X-Received: by 2002:ac8:148e:0:b0:397:c806:2162 with SMTP id l14-20020ac8148e000000b00397c8062162mr2104756qtj.171.1668184604622; Fri, 11 Nov 2022 08:36:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf6gaPxGi24UJQKWGyHOporYJSsyjJ3UfPRFEZt9siGAIJZlfdi2i6mi+S2d3etAXQPpJ77qog== X-Received: by 2002:ac8:148e:0:b0:397:c806:2162 with SMTP id l14-20020ac8148e000000b00397c8062162mr2104716qtj.171.1668184604204; Fri, 11 Nov 2022 08:36:44 -0800 (PST) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id bn4-20020a05620a2ac400b006f1187ca494sm1655621qkb.28.2022.11.11.08.36.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Nov 2022 08:36:44 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 6/6] gdb/testsuite: rewrite gdb.cp/call-method-register.exp with dwarf assembler Date: Fri, 11 Nov 2022 16:36:25 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" Convert the gdb.cp/call-method-register.exp test to make use of the DWARF assembler. The existing gdb.cp/call-method-register.exp test relies on a GCC extension - forcing a local variable into a particular named register. This means that the test will only work with Clang, and, as we have to name the register into which the variable will be placed, will only work for those targets where we've selected a suitable register, currently this is x86-64, i386, and ppc64. By switching to the DWARF assembler, the test will work with gcc and clang, and should work on most, if not all, architectures. The test creates a small structure, something that can fit within a register, and then tries to call a method on the structure from within GDB. This should fail because GDB can't take the address of the in register structure (for the `this` pointer). As the test is for a failure case, then we don't really care _which_ register the structure is in, and I take advantage of this for the DWARF assembler test, I just declare that the variable is in DW_OP_reg0, whatever that might be. I've tested the new test on x86-64, ppc, aarch64, and risc-v, and the test runs, and passes on all these architectures, which is already more than we used to cover. Additionally, on x86-64, I've tested with Clang and gcc, and the test runs and passed with both compilers. Reviewed-By: Lancelot SIX --- gdb/testsuite/gdb.cp/call-method-register.cc | 49 +------- gdb/testsuite/gdb.cp/call-method-register.exp | 108 +++++++++++++----- 2 files changed, 81 insertions(+), 76 deletions(-) diff --git a/gdb/testsuite/gdb.cp/call-method-register.cc b/gdb/testsuite/gdb.cp/call-method-register.cc index d60fee03701..91cbf13ebca 100644 --- a/gdb/testsuite/gdb.cp/call-method-register.cc +++ b/gdb/testsuite/gdb.cp/call-method-register.cc @@ -1,6 +1,6 @@ /* This testcase is part of GDB, the GNU debugger. - Copyright 1993-2022 Free Software Foundation, Inc. + Copyright 2022 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,54 +15,9 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#if defined __x86_64__ -# define ASM_REG "rax" -#elif defined __i386__ -# define ASM_REG "eax" -#elif defined __powerpc64__ -# define ASM_REG "r9" -#else -# error "port me" -#endif - -/* A class small enough that it fits in a register. */ -struct small -{ - int x; - int method (); -}; - -int -small::method () -{ - return x + 5; -} - -int -register_class () -{ - /* Given the use of the GNU register-asm local variables extension, - the compiler puts this variable in a register. This means that - GDB can't call any methods for this variable, which is what we - want to test. */ - register small v asm (ASM_REG); - - int i; - - /* Perform a computation sufficiently complicated that optimizing - compilers won't optimize out the variable. If some compiler - constant-folds this whole loop, maybe using a parameter to this - function here would help. */ - v.x = 0; - for (i = 0; i < 13; ++i) - v.x += i; - --v.x; /* v.x is now 77 */ - return v.x + 5; /* set breakpoint here */ -} - int main () { - register_class (); + asm ("main_label: .globl main_label"); return 0; } diff --git a/gdb/testsuite/gdb.cp/call-method-register.exp b/gdb/testsuite/gdb.cp/call-method-register.exp index a98b11e4c11..a86ea1e44f9 100644 --- a/gdb/testsuite/gdb.cp/call-method-register.exp +++ b/gdb/testsuite/gdb.cp/call-method-register.exp @@ -19,43 +19,93 @@ if { [skip_cplus_tests] } { continue } load_lib "cp-support.exp" +load_lib dwarf.exp -standard_testfile .cc +standard_testfile .cc -dw.S -if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} { +if {[prepare_for_testing "failed to prepare" $testfile $srcfile \ + {debug c++}]} { return -1 } -if {![test_compiler_info gcc-*-* c++]} { - untested "test relies on a gcc extension" - return -} +set asm_file [standard_output_file $srcfile2] +Dwarf::assemble $asm_file { + + set main_result \ + [function_range main ${::srcdir}/${::subdir}/${::srcfile}] + set main_start [lindex $main_result 0] + set main_length [lindex $main_result 1] + + cu {} { + compile_unit { + {DW_AT_language @DW_LANG_C_plus_plus} + {DW_AT_name $::srcfile} + {DW_AT_comp_dir /tmp} + } { + declare_labels int_type_label struct_type_label \ + struct_ptr_type_label + set ptr_size [get_sizeof "void *" 96] + + DW_TAG_subprogram { + {name main} + {low_pc $main_start addr} + {high_pc $main_length data8} + {DW_AT_type :$int_type_label} + } + + int_type_label: DW_TAG_base_type { + {DW_AT_byte_size 4 DW_FORM_sdata} + {DW_AT_encoding @DW_ATE_signed} + {DW_AT_name int} + } + + struct_type_label: DW_TAG_structure_type { + {DW_AT_byte_size 4 DW_FORM_sdata} + {DW_AT_name small} + } { + member { + {name xxx} + {type :$int_type_label} + {data_member_location 0 data1} + } + subprogram { + {name yyy} + {type :$int_type_label} + {data_member_location 0 data1} + } { + formal_parameter { + {type :$struct_ptr_type_label} + {artificial 1 flag_present} + } + } + } -proc test_call_register_class {} { - global gdb_prompt + struct_ptr_type_label: DW_TAG_pointer_type { + {DW_AT_byte_size $ptr_size DW_FORM_data1} + {type :$struct_type_label} + } - if ![runto_main] { - return + DW_TAG_variable { + {DW_AT_name global_var} + {DW_AT_type :$struct_type_label} + {DW_AT_location { + DW_OP_reg0 + } SPECIAL_expr} + {external 1 flag} + } + } } +} - set bp_location [gdb_get_line_number "set breakpoint here"] - gdb_breakpoint $bp_location - gdb_continue_to_breakpoint "break here" - - # This class is so small that an instance of it can fit in a register. - # When gdb tries to call a method, it gets embarrassed about taking - # the address of a register. - # - # That message is a PASS, not an XFAIL, because gdb prints an - # informative message and declines to do something impossible. - # - # The method call actually succeeds if the compiler allocates very - # small classes in memory instead of registers. If that happens, - # it's a FAIL, because the testcase is written in a form such that - # it should not happen. - gdb_test "print v.method ()" \ - "Address requested for identifier \"v\" which is in register .*" \ - "call method on register local" +if { [prepare_for_testing "failed to prepare" ${testfile} \ + [list $srcfile $asm_file] {nodebug}] } { + return -1 +} + +if ![runto_main] { + return -1 } -test_call_register_class +gdb_test "print global_var.yyy ()" \ + "Address requested for identifier \"global_var\" which is in register .*" \ + "call method on register local"