From patchwork Tue Aug 8 18:28:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 21997 Received: (qmail 127420 invoked by alias); 8 Aug 2017 18:29:05 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 120308 invoked by uid 89); 8 Aug 2017 18:29:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=enrich, colored, mentions, arnez X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 08 Aug 2017 18:29:01 +0000 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v78ISuhT058903 for ; Tue, 8 Aug 2017 14:28:59 -0400 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0b-001b2d01.pphosted.com with ESMTP id 2c7hqyty5j-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 08 Aug 2017 14:28:58 -0400 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 8 Aug 2017 19:28:37 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 8 Aug 2017 19:28:35 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v78ISZq920381844; Tue, 8 Aug 2017 18:28:35 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4320F52041; Tue, 8 Aug 2017 18:24:29 +0100 (BST) Received: from oc1027705133.ibm.com (unknown [9.152.212.154]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 1F0845203F; Tue, 8 Aug 2017 18:24:29 +0100 (BST) From: Andreas Arnez To: Yao Qi Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] GDB testsuite: Suppress GCC's colored output References: <86h8xn3833.fsf@gmail.com> Date: Tue, 08 Aug 2017 20:28:31 +0200 In-Reply-To: <86h8xn3833.fsf@gmail.com> (Yao Qi's message of "Fri, 04 Aug 2017 12:06:56 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17080818-0016-0000-0000-000004E16569 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17080818-0017-0000-0000-00002819A8EA Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-08_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1708080302 X-IsSubscribed: yes On Fri, Aug 04 2017, Yao Qi wrote: > Andreas Arnez writes: > > Hi Andreas, > >> + # Stop the compiler from producing colored output. >> + setenv GCC_COLORS "" >> + > > This doesn't work for remote host. Hm, what scenario are you referring to? It *does* work with "--target_board=native-gdbserver", at least on the system I've tested it on. And a cross-target config should work as well, right? > How about passing option -fno-color-diagnostics to compiler which > supports that option? Both gcc (4.9 and later) and clang has this > option. Actually, clang only, AFAIK. And I don't know that there is a compatible option between GCC and clang for disabling colored diagnostics. Clang's manual page (1) mentions -f[no-]color-diagnostics whereas GCC has -fdiagnostics-color[=WHEN] -fno-diagnostics-color So unless I missed something, we have to handle clang and GCC separately. See below for an alternative patch that tries the GCC option "-fdiagnostics-color=never". We could possibly enrich this and try clang's "-fno-color-diagnostics" if that fails. * (1) https://clang.llvm.org/docs/UsersManual.html --- Andreas Subject: [PATCH v2] GDB testsuite: Suppress GCC's colored output Newer GCC versions yield colored diagnostic messages by default, which may be useful when executing GDB interactively from a terminal. But when run from a GDB test case, the compiler output is written into gdb.log, where such escape sequences are usually more inhibiting than helpful to the evaluation of test results. So this patch suppresses that. gdb/testsuite/ChangeLog: * lib/gdb.exp (universal_compile_options): New caching proc. (gdb_compile): Suppress GCC's coloring of messages. --- gdb/testsuite/lib/gdb.exp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 3d3eaab..51bf848 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -3368,6 +3368,34 @@ proc gdb_wrapper_init { args } { set gdb_wrapper_target [current_target_name] } +# Determine options that we always want to pass to the compiler. +gdb_caching_proc universal_compile_options { + set me "universal_compile_options" + set options {} + + set src [standard_temp_file ccopts[pid].c] + set obj [standard_temp_file ccopts[pid].o] + + gdb_produce_source $src { + int foo(void) { return 0; } + } + + # Try an option for disabling colored diagnostics. Some compilers + # yield colored diagnostics by default (when run from a tty) unless + # such an option is specified. + set opt "additional_flags=-fdiagnostics-color=never" + set lines [target_compile $src $obj object [list "quiet" $opt]] + if [string match "" $lines] then { + # Seems to have worked; use the option. + lappend options $opt + } + file delete $src + file delete $obj + + verbose "$me: returning $options" 2 + return $options +} + # Some targets need to always link a special object in. Save its path here. global gdb_saved_set_unbuffered_mode_obj set gdb_saved_set_unbuffered_mode_obj "" @@ -3419,7 +3447,7 @@ proc gdb_compile {source dest type options} { # Add platform-specific options if a shared library was specified using # "shlib=librarypath" in OPTIONS. - set new_options "" + set new_options [universal_compile_options] set shlib_found 0 set shlib_load 0 foreach opt $options {