]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: add new command line options to control diagnostic informational messages
authorMatthieu Longo <matthieu.longo@arm.com>
Thu, 27 Jun 2024 10:02:18 +0000 (11:02 +0100)
committerMatthieu Longo <matthieu.longo@arm.com>
Tue, 17 Dec 2024 11:01:24 +0000 (11:01 +0000)
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.

gas/as.c
gas/as.h
gas/config/tc-aarch64.c
gas/doc/as.texi
gas/messages.c

index e629f30bf7b400f05545ef825d919eac33ab94b8..5a0cb6019cc316ca0db275d4a328defb93634afa 100644 (file)
--- 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;
index 3d5f710c5c5e9d71c440356430b1f51ed2f6f464..a57935de1492bb61bc02d0d3c547cd4e7e8c4c8d 100644 (file)
--- 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 */
index c706f920f15a0ab988ded294ee8da74973fa5f1a..464a727be00fcb1ce199ca620de6b000efea9fdc 100644 (file)
@@ -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;
index 725029c867ddd4e19dec4e7f17b0cb687bbd002a..6be54b575992af607f2846480b661d7e4a537b10 100644 (file)
@@ -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}
 
index bbe2596f27b50ddc1e224e65ef36507ee82e0f3d..17835d1c251a094ce8b99c1e6f1b9cc426752cd5 100644 (file)
@@ -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];