[v1,2/3] gas: add new command line options to control diagnostic information messages

Message ID 20240702174003.1424939-3-matthieu.longo@arm.com
State New
Headers
Series gas: add command line option to inhibit info messages |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Matthieu Longo July 2, 2024, 5:40 p.m. UTC
  gas currently emits information 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
    information messages (default behavior).
  * --no-info, similar to the existing --no-warn flag to disable diagnostic
    information messages.

It also adds the flags to the existing documentation, and command manual.
---
 gas/as.c                | 18 +++++++++++++++++-
 gas/as.h                |  3 +++
 gas/config/tc-aarch64.c |  3 +++
 gas/doc/as.texi         | 34 ++++++++++++++++++++++++++++++++++
 gas/messages.c          |  3 +++
 5 files changed, 60 insertions(+), 1 deletion(-)
  

Comments

Jan Beulich July 3, 2024, 7:55 a.m. UTC | #1
On 02.07.2024 19:40, Matthieu Longo wrote:
> 
> gas currently emits information 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
>     information messages (default behavior).
>   * --no-info, similar to the existing --no-warn flag to disable diagnostic
>     information messages.

Nick, Alan, what is your take on these option names? Having dropped the 's'
from the original form is an improvement imo, but I'm a little afraid "info"
(unlike "warn") may become ambiguous with something else down the road.

> It also adds the flags to the existing documentation, and command manual.

In all of the doc changes you appear to be entirely ignoring the present
alphabetical sorting in the blocks you insert into. The info additions
want to all move further up; the sorting there isn't on a "related to one
another" basis afaics.

> ---
>  gas/as.c                | 18 +++++++++++++++++-
>  gas/as.h                |  3 +++
>  gas/config/tc-aarch64.c |  3 +++

This change will need explicit buy-off by Arm64 folks. Mind me asking why
you Cc-ed only Richard, but not Marcus?

Jan

>  gas/doc/as.texi         | 34 ++++++++++++++++++++++++++++++++++
>  gas/messages.c          |  3 +++
>  5 files changed, 60 insertions(+), 1 deletion(-)
>
  
Matthieu Longo July 3, 2024, 4:52 p.m. UTC | #2
On 2024-07-03 08:55, Jan Beulich wrote:
> On 02.07.2024 19:40, Matthieu Longo wrote:
>>
>> gas currently emits information 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
>>      information messages (default behavior).
>>    * --no-info, similar to the existing --no-warn flag to disable diagnostic
>>      information messages.
> 
> Nick, Alan, what is your take on these option names? Having dropped the 's'
> from the original form is an improvement imo, but I'm a little afraid "info"
> (unlike "warn") may become ambiguous with something else down the road.
> 
>> It also adds the flags to the existing documentation, and command manual.
> 
> In all of the doc changes you appear to be entirely ignoring the present
> alphabetical sorting in the blocks you insert into. The info additions
> want to all move further up; the sorting there isn't on a "related to one
> another" basis afaics.
> 
>> ---
>>   gas/as.c                | 18 +++++++++++++++++-
>>   gas/as.h                |  3 +++
>>   gas/config/tc-aarch64.c |  3 +++
> 
> This change will need explicit buy-off by Arm64 folks. Mind me asking why
> you Cc-ed only Richard, but not Marcus?

Although Marcus Shawcroft is listed in the maintainers file, he works on 
others things these days (but still at Arm).

> Jan
> 
>>   gas/doc/as.texi         | 34 ++++++++++++++++++++++++++++++++++
>>   gas/messages.c          |  3 +++
>>   5 files changed, 60 insertions(+), 1 deletion(-)
>>
  

Patch

diff --git a/gas/as.c b/gas/as.c
index 259dc0ee580..93792e5d4d1 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -393,6 +393,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\
@@ -519,7 +523,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.  */
     };
@@ -595,6 +601,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}
@@ -603,6 +610,7 @@  parse_args (int * pargc, char *** pargv)
     ,{"verbose", no_argument, NULL, OPTION_VERBOSE}
     ,{"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}
   };
@@ -982,6 +990,14 @@  This program has absolutely no warranty.\n"));
 	  flag_fatal_warnings = 1;
 	  break;
 
+	case OPTION_NOINFO:
+	  flag_no_information = 1;
+	  break;
+
+	case OPTION_INFO:
+	  flag_no_information = 0;
+	  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 24bf66eb8a7..5adcc679a8b 100644
--- a/gas/as.h
+++ b/gas/as.h
@@ -320,6 +320,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 int 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 42c03bd199e..34ed802a2bc 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -5662,6 +5662,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 352f2a328c3..6cdf93b66ca 100644
--- a/gas/doc/as.texi
+++ b/gas/doc/as.texi
@@ -261,6 +261,7 @@  gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}.
  [@b{--statistics}]
  [@b{-v}] [@b{-version}] [@b{--version}]
  [@b{-W}] [@b{--no-warn}] [@b{--warn}] [@b{--fatal-warnings}]
+ [@b{--no-info}] [@b{--info}]
  [@b{-w}] [@b{-x}]
  [@b{-Z}] [@b{@@@var{FILE}}]
  [@var{target-options}]
@@ -990,6 +991,12 @@  Don't suppress warning messages or treat them as errors.
 @item --fatal-warnings
 Treat warnings as errors.
 
+@item --no-info
+Suppress information messages.
+
+@item --info
+Don't suppress information messages.
+
 @item -w
 Ignored.
 
@@ -2465,6 +2472,7 @@  assembler.)
 * traditional-format:: --traditional-format for compatible output
 * v::             -v to announce version
 * W::             -W, --no-warn, --warn, --fatal-warnings to control warnings
+* info::          --no-info, --info to control information messages
 * Z::             -Z to make object file even after errors
 @end menu
 
@@ -2893,6 +2901,32 @@  will switch on warnings again, and cause them to be output as usual.
 If you use the @option{--fatal-warnings} option, @command{@value{AS}} considers
 files that generate warnings to be in error.
 
+@node info
+@section Control Information Messages: @option{--info}, @option{--no-info}
+
+In some cases, @command{@value{AS}} might give an additional information message
+associated to a context that generated a warning or error message when assembling.
+The information 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 informations are directed to the standard error file.
+This flag only affects the information messages, it does not change any particular
+of how @command{@value{AS}} assembles your file.
+
+@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.
+
+@kindex --info
+@cindex diagnostic informations, switching on (default behavior)
+The option @option{--info} is enabled by default, and enables printing of additional
+diagnostic informations.
+
+Specifying @option{--info} after @option{--no-info} will turn on again printing
+of additional diagnostic informations.
+
 @node Z
 @section Generate Object File in Spite of Errors: @option{-Z}
 @cindex object file, after errors
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];