[PATCH v4 1/2] gas: add new command line options to control diagnostic information messages
Matthieu Longo
matthieu.longo@arm.com
Wed Nov 20 18:24:43 GMT 2024
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(-)
diff --git a/gas/as.c b/gas/as.c
index f20b1e0cbe5..2ef18a084ce 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 = 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 3d5f710c5c5..5b337fd494f 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 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 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 a5535845e40..d56677e60e4 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}]
@@ -873,6 +874,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 information messages.
+
+@item --no-info
+Suppress information messages.
+
@item -I @var{dir}
Add directory @var{dir} to the search list for @code{.include} directives.
@@ -2446,6 +2453,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 information messages
* I:: -I for .include search path
@ifclear DIFF-TBL-KLUGE
* K:: -K for compatibility
@@ -2558,6 +2566,32 @@ preprocessed (if they contain comments, for example), @command{@value{AS}} does
not work correctly.
@end quotation
+@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 --info
+@cindex diagnostic informations, switching on (default behavior)
+The option @option{--info} is enabled by default, and enables printing of additional
+diagnostic informations.
+
+@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 informations.
+
@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];
--
2.47.0
More information about the Binutils
mailing list