From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689933525; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uiU5pIzJGUBOIlK/RTqpW/e6PWYCxk8lPo9pMUme9C8=; b=ESRDA4feFAqqm6Geop7RIcuEyWU4hMHrWBR4NmShu9nCsOAaWhj7DORe/XxG4ldV3d8mzp guj+XteriCIYpVOhKuRPEcukaI7KdVu+EB+dDWxOrm33O0gTsMH52P/5cp1m9u8f4PjqJP 7PZPtlTg9yHUt1B2V8gfcvmcvxCBNBc= 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) From: Bruno Larsen 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 List-Id: 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 +} -- 2.41.0