From: Andreas Arnez <arnez@linux.vnet.ibm.com>
To: Yao Qi <qiyaoltc@gmail.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] GDB testsuite: Suppress GCC's colored output
Date: Tue, 08 Aug 2017 18:29:00 -0000 [thread overview]
Message-ID: <m3mv7929tc.fsf@oc1027705133.ibm.com> (raw)
In-Reply-To: <86h8xn3833.fsf@gmail.com> (Yao Qi's message of "Fri, 04 Aug 2017 12:06:56 +0100")
On Fri, Aug 04 2017, Yao Qi wrote:
> Andreas Arnez <arnez@linux.vnet.ibm.com> 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 {
--
2.5.0
next prev parent reply other threads:[~2017-08-08 18:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-02 17:35 Andreas Arnez
2017-08-02 20:22 ` Simon Marchi
2017-08-03 11:13 ` Andreas Arnez
[not found] ` <86h8xn3833.fsf@gmail.com>
2017-08-04 12:19 ` Simon Marchi
2017-08-04 13:00 ` Yao Qi
2017-08-08 18:29 ` Andreas Arnez [this message]
2017-08-09 10:01 ` Simon Marchi
2017-08-09 10:29 ` Yao Qi
2017-08-14 18:32 ` Andreas Arnez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3mv7929tc.fsf@oc1027705133.ibm.com \
--to=arnez@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=qiyaoltc@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox