From patchwork Fri Jul 21 09:58:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guinevere Larsen X-Patchwork-Id: 73030 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 554A1385B527 for ; Fri, 21 Jul 2023 09:59:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 554A1385B527 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1689933569; bh=uiU5pIzJGUBOIlK/RTqpW/e6PWYCxk8lPo9pMUme9C8=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=iqIFNzE38KTYF8Zu41byfJIn1cayn3q9QSc2JZzvuhz83bDzHlm/ml4UUvkNqBsPV n7/L2BziK2lifrs3Tcnzu3mxCkaOJ4WpLBIALojwssLDNHZEVCR1ACGTtFbNog4UKj AoaBJptZ3fy09PdadRMecEsh5rB51+o963CAs6h8= 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 ABCB83853D0E for ; Fri, 21 Jul 2023 09:58:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ABCB83853D0E 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-588-UbKSaeF9PIqIh8Ruzw9Dxg-1; Fri, 21 Jul 2023 05:58:44 -0400 X-MC-Unique: UbKSaeF9PIqIh8Ruzw9Dxg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E51F6185A7A4 for ; Fri, 21 Jul 2023 09:58:43 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.225.51]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4E2481454142; Fri, 21 Jul 2023 09:58:43 +0000 (UTC) To: gdb-patches@sourceware.org Cc: Bruno Larsen , Andrew Burgess Subject: [PATCH v2] gdb/testsuite: explicitly test for stderr in gdb.mi/mi-dprintf.exp Date: Fri, 21 Jul 2023 11:58:10 +0200 Message-ID: <20230721095809.3479260-2-blarsen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.5 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_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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: Bruno Larsen via Gdb-patches From: Guinevere Larsen Reply-To: Bruno Larsen Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" As mentioned in commit 3f5bbc3e2075ef5061a815c73fdc277218489f22, some compilers such as clang don't add debug information about stderr by default, leaving it to external debug packages. This commit adds a way to check if GDB has access to stderr information when in MI mode, and uses this new mechanism to skip the related section of the test gdb.mi/mi-dprintf.exp. It also fixes an incorrect name for a test in that file. Co-Authored-By: Andrew Burgess --- gdb/testsuite/gdb.mi/mi-dprintf.exp | 11 ++++++++--- gdb/testsuite/lib/mi-support.exp | 14 ++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/gdb/testsuite/gdb.mi/mi-dprintf.exp b/gdb/testsuite/gdb.mi/mi-dprintf.exp index e40fa6121fa..d771993386b 100644 --- a/gdb/testsuite/gdb.mi/mi-dprintf.exp +++ b/gdb/testsuite/gdb.mi/mi-dprintf.exp @@ -127,6 +127,7 @@ proc mi_continue_dprintf {args} { mi_continue_dprintf "gdb" # The "call" style depends on having I/O functions available, so test. +set has_stderr_symbol [mi_gdb_is_stderr_available] if ![target_info exists gdb,noinferiorio] { @@ -136,9 +137,13 @@ if ![target_info exists gdb,noinferiorio] { mi_gdb_test "set dprintf-style call" ".*" "mi set dprintf style to call" mi_continue_dprintf "call" - mi_gdb_test "set dprintf-function fprintf" ".*" "mi set dprintf-channel stderr" - mi_gdb_test "set dprintf-channel stderr" ".*" "mi set dprintf channel" - mi_continue_dprintf "fprintf" + # Some compilers don't add information about stderr, + # so skip these tests if needed. + if {$::has_stderr_symbol} { + mi_gdb_test "set dprintf-function fprintf" ".*" "mi set dprintf function" + mi_gdb_test "set dprintf-channel stderr" ".*" "mi set dprintf channel" + mi_continue_dprintf "fprintf" + } } set target_can_dprintf 0 diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index 49d5e2ef272..468c481ab95 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -2883,3 +2883,17 @@ proc foreach_mi_ui_mode { var_name body } { } } } + +# Check if GDB has information about the stderr symbol. +proc mi_gdb_is_stderr_available {} { + set has_stderr_symbol false + gdb_test_multiple "-data-evaluate-expression stderr" "stderr symbol check" { + -re "\\^error,msg=\"'stderr' has unknown type; cast it to its declared type\"\r\n$::mi_gdb_prompt$" { + # Default value of false is fine. + } + -re "$::mi_gdb_prompt$" { + set has_stderr_symbol true + } + } + return $has_stderr_symbol +}