From: Matthieu Longo Date: Thu, 27 Jun 2024 10:02:18 +0000 (+0100) Subject: gas: add new command line options to control diagnostic informational messages X-Git-Tag: gdb-16-branchpoint~68 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=63e8e1a1674225214ee462e3044edf6450f41c10;p=thirdparty%2Fbinutils-gdb.git gas: add new command line options to control diagnostic informational messages gas currently emits informational messages for context information along warnings. In the context of system register tests in AArch64 backend, these messages pollute the tests when checking for error message patterns in stderr output. This patch aims at providing two new flags while preserving the existing behavior if none of the options is provided. * --info, similar to the existing --warn flag to enable diagnostic informational messages (default behavior). * --no-info, similar to the existing --no-warn flag to disable diagnostic informational messages. It also adds the flags to the existing documentation, and command manual. --- diff --git a/gas/as.c b/gas/as.c index e629f30bf7b..5a0cb6019cc 100644 --- a/gas/as.c +++ b/gas/as.c @@ -382,6 +382,10 @@ Options:\n\ --warn don't suppress warnings\n")); fprintf (stream, _("\ --fatal-warnings treat warnings as errors\n")); + fprintf (stream, _("\ + --no-info suppress information messages\n")); + fprintf (stream, _("\ + --info don't suppress information messages\n")); #ifdef HAVE_ITBL_CPU fprintf (stream, _("\ --itbl INSTTBL extend instruction set to include instructions\n\ @@ -499,7 +503,9 @@ parse_args (int * pargc, char *** pargv) OPTION_NO_PAD_SECTIONS, OPTION_MULTIBYTE_HANDLING, /* = STD_BASE + 40 */ OPTION_SFRAME, - OPTION_SCFI + OPTION_SCFI, + OPTION_INFO, + OPTION_NOINFO /* When you add options here, check that they do not collide with OPTION_MD_BASE. See as.h. */ }; @@ -575,6 +581,7 @@ parse_args (int * pargc, char *** pargv) ,{"mri", no_argument, NULL, 'M'} ,{"nocpp", no_argument, NULL, OPTION_NOCPP} ,{"no-pad-sections", no_argument, NULL, OPTION_NO_PAD_SECTIONS} + ,{"no-info", no_argument, NULL, OPTION_NOINFO} ,{"no-warn", no_argument, NULL, 'W'} ,{"reduce-memory-overheads", no_argument, NULL, OPTION_REDUCE_MEMORY_OVERHEADS} ,{"statistics", no_argument, NULL, OPTION_STATISTICS} @@ -583,6 +590,7 @@ parse_args (int * pargc, char *** pargv) ,{"verbose", no_argument, NULL, 'v'} ,{"target-help", no_argument, NULL, OPTION_TARGET_HELP} ,{"traditional-format", no_argument, NULL, OPTION_TRADITIONAL_FORMAT} + ,{"info", no_argument, NULL, OPTION_INFO} ,{"warn", no_argument, NULL, OPTION_WARN} ,{"multibyte-handling", required_argument, NULL, OPTION_MULTIBYTE_HANDLING} }; @@ -955,6 +963,14 @@ This program has absolutely no warranty.\n")); flag_fatal_warnings = 1; break; + case OPTION_NOINFO: + flag_no_information = true; + break; + + case OPTION_INFO: + flag_no_information = false; + break; + #if defined OBJ_ELF || defined OBJ_MAYBE_ELF case OPTION_EXECSTACK: flag_execstack = 1; diff --git a/gas/as.h b/gas/as.h index 3d5f710c5c5..a57935de149 100644 --- a/gas/as.h +++ b/gas/as.h @@ -323,6 +323,9 @@ COMMON int flag_no_warnings; /* -W, --no-warn */ /* True if warnings count as errors. */ COMMON int flag_fatal_warnings; /* --fatal-warnings */ +/* True if infos should be inhibited. */ +COMMON bool flag_no_information; /* --no-info */ + /* True if we should attempt to generate output even if non-fatal errors are detected. */ COMMON unsigned char flag_always_generate_output; /* -Z */ diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index c706f920f15..464a727be00 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -5667,6 +5667,9 @@ print_operands (char *buf, const aarch64_opcode *opcode, static void output_info (const char *format, ...) { + if (flag_no_information) + return; + const char *file; unsigned int line; va_list args; diff --git a/gas/doc/as.texi b/gas/doc/as.texi index 725029c867d..6be54b57599 100644 --- a/gas/doc/as.texi +++ b/gas/doc/as.texi @@ -243,6 +243,7 @@ gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}. [@b{--gsframe}] [@b{--hash-size}=@var{N}] [@b{--help}] [@b{--target-help}] + [@b{--info}] [@b{--no-info}] [@b{-I} @var{dir}] [@b{-J}] [@b{-K}] @@ -867,6 +868,12 @@ Print a summary of the command-line options and exit. @item --target-help Print a summary of all target specific options and exit. +@item --info +Don't suppress informational messages. + +@item --no-info +Suppress informational messages. + @item -I @var{dir} Add directory @var{dir} to the search list for @code{.include} directives. @@ -2422,6 +2429,7 @@ assembler.) * alternate:: --alternate enable alternate macro syntax * D:: -D for compatibility and debugging * f:: -f to work faster +* info:: --info, --no-info to control informational messages * I:: -I for .include search path @ifclear DIFF-TBL-KLUGE * K:: -K for compatibility @@ -2534,6 +2542,32 @@ preprocessed (if they contain comments, for example), @command{@value{AS}} does not work correctly. @end quotation +@node info +@section Control Informational Messages: @option{--info}, @option{--no-info} + +In some cases, @command{@value{AS}} might give additional informational messages +associated to a context that generated a warning or error message when assembling. +The informational message provides additional details about an earlier diagnostic +message, usually in the form of some context (such as when the earlier diagnostic +was within a macro). +All such information are directed to the standard error file. +This flag only affects the informational messages, it does not change any particular +of how @command{@value{AS}} assembles your file. + +@kindex --info +@cindex diagnostic information, switching on (default behavior) +The option @option{--info} is enabled by default, and enables printing of additional +diagnostic information. + +@kindex --no-info +@cindex diagnostic informations, switching off +You can switch the option @option{--info} off by specifying @option{--no-info}, +which disables printing of additional information in the context of an earlier +diagnostic. + +Specifying @option{--info} after @option{--no-info} will turn on again printing +of additional diagnostic information. + @node I @section @code{.include} Search Path: @option{-I} @var{path} diff --git a/gas/messages.c b/gas/messages.c index bbe2596f27b..17835d1c251 100644 --- a/gas/messages.c +++ b/gas/messages.c @@ -138,6 +138,9 @@ void as_info_where (const char *file, unsigned int line, unsigned int indent, const char *format, ...) { + if (flag_no_information) + return; + va_list args; char buffer[2000];