diff options
author | Andreas Arnez <arnez@linux.vnet.ibm.com> | 2017-08-14 20:31:09 +0200 |
---|---|---|
committer | Andreas Arnez <arnez@linux.vnet.ibm.com> | 2017-08-14 20:31:09 +0200 |
commit | bf0ec4c2769236d9c471685409605f50b01479e5 (patch) | |
tree | d8c97d035b04aeea6733b793d0b80a6bd27d4793 /gdb/testsuite | |
parent | d3abe1c8ef1ec9a90932b801138a144dcae95100 (diff) | |
download | gdb-bf0ec4c2769236d9c471685409605f50b01479e5.zip gdb-bf0ec4c2769236d9c471685409605f50b01479e5.tar.gz gdb-bf0ec4c2769236d9c471685409605f50b01479e5.tar.bz2 |
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.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/lib/gdb.exp | 30 |
2 files changed, 34 insertions, 1 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 6db249b..f9494af 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-08-14 Andreas Arnez <arnez@linux.vnet.ibm.com> + + * lib/gdb.exp (universal_compile_options): New caching proc. + (gdb_compile): Suppress GCC's coloring of messages. + 2017-08-14 Tom Tromey <tom@tromey.com> PR gdb/21675: diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index d0265fc..c0ecab3 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 { |