This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] Output "warning:" or "error:" in plugin messages
- From: H.J.Lu <hjl at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 11 Feb 2015 22:01:56 -0000
- Subject: [binutils-gdb] Output "warning:" or "error:" in plugin messages
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=45e813544eb076dd52fefe7b36e28b088963207d
commit 45e813544eb076dd52fefe7b36e28b088963207d
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed Feb 11 12:16:07 2015 -0800
Output "warning:" or "error:" in plugin messages
When plugin generates LDPL_WARNING, LDPL_FATAL and LDPL_ERROR messages,
linker should display "warning:" or "error:" in plugin messages like
regular linker messages.
ld/
* plugin.c (message): Output "warning:" for LDPL_WARNING. Output
"error:" for LDPL_FATAL and LDPL_ERROR.
* testplug2.c (parse_option): Handle fatal, error and warning.
ld/testsuite/
* ld-plugin/plugin-27.d: New.
* ld-plugin/plugin-28.d: Likewise.
* ld-plugin/plugin-29.d: Likewise.
* plugin.exp (plugin_tests): Add tests for LDPL_FATAL, LDPL_ERROR
and LDPL_WARNING.
Diff:
---
ld/ChangeLog | 6 ++++++
ld/plugin.c | 12 ++++++++----
ld/testplug2.c | 17 ++++++++++++++++-
ld/testsuite/ChangeLog | 8 ++++++++
ld/testsuite/ld-plugin/plugin-27.d | 1 +
ld/testsuite/ld-plugin/plugin-28.d | 1 +
ld/testsuite/ld-plugin/plugin-29.d | 1 +
ld/testsuite/ld-plugin/plugin.exp | 6 ++++++
8 files changed, 47 insertions(+), 5 deletions(-)
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 7bd1c01..f46bd9b 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,11 @@
2015-02-11 H.J. Lu <hongjiu.lu@intel.com>
+ * plugin.c (message): Output "warning:" for LDPL_WARNING. Output
+ "error:" for LDPL_FATAL and LDPL_ERROR.
+ * testplug2.c (parse_option): Handle fatal, error and warning.
+
+2015-02-11 H.J. Lu <hongjiu.lu@intel.com>
+
* testplug2.c (dump_tv_tag): Removed.
(onall_symbols_read): Return LDPS_ERR if the file descriptor isn't
closed.
diff --git a/ld/plugin.c b/ld/plugin.c
index b48ce86..4fee305 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -814,15 +814,19 @@ message (int level, const char *format, ...)
putchar ('\n');
break;
case LDPL_WARNING:
- vfinfo (stdout, format, args, TRUE);
- putchar ('\n');
+ {
+ char *newfmt = ACONCAT (("%P: warning: ", format, "\n",
+ (const char *) NULL));
+ vfinfo (stdout, newfmt, args, TRUE);
+ }
break;
case LDPL_FATAL:
case LDPL_ERROR:
default:
{
- char *newfmt = ACONCAT ((level == LDPL_FATAL ? "%P%F: " : "%P%X: ",
- format, "\n", (const char *) NULL));
+ char *newfmt = ACONCAT ((level == LDPL_FATAL ? "%P%F" : "%P%X",
+ ": error: ", format, "\n",
+ (const char *) NULL));
fflush (stdout);
vfinfo (stderr, newfmt, args, TRUE);
fflush (stderr);
diff --git a/ld/testplug2.c b/ld/testplug2.c
index 8cafc51..10f0efb 100644
--- a/ld/testplug2.c
+++ b/ld/testplug2.c
@@ -318,7 +318,22 @@ set_register_hook (const char *whichhook, bfd_boolean yesno)
static enum ld_plugin_status
parse_option (const char *opt)
{
- if (!strncmp ("fail", opt, 4))
+ if (!strncmp ("fatal", opt, 5))
+ {
+ TV_MESSAGE (LDPL_FATAL, "Fatal error");
+ fflush (NULL);
+ }
+ else if (!strncmp ("error", opt, 5))
+ {
+ TV_MESSAGE (LDPL_ERROR, "Error");
+ fflush (NULL);
+ }
+ else if (!strncmp ("warning", opt, 7))
+ {
+ TV_MESSAGE (LDPL_WARNING, "Warning");
+ fflush (NULL);
+ }
+ else if (!strncmp ("fail", opt, 4))
return set_ret_val (opt + 4, LDPS_ERR);
else if (!strncmp ("pass", opt, 4))
return set_ret_val (opt + 4, LDPS_OK);
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index ea1d533..2b963fa 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,5 +1,13 @@
2015-02-11 H.J. Lu <hongjiu.lu@intel.com>
+ * ld-plugin/plugin-27.d: New.
+ * ld-plugin/plugin-28.d: Likewise.
+ * ld-plugin/plugin-29.d: Likewise.
+ * plugin.exp (plugin_tests): Add tests for LDPL_FATAL, LDPL_ERROR
+ and LDPL_WARNING.
+
+2015-02-11 H.J. Lu <hongjiu.lu@intel.com>
+
PR ld/17878
* ld-plugin/func.c: Add some comments.
* ld-plugin/plugin-13.d: New file.
diff --git a/ld/testsuite/ld-plugin/plugin-27.d b/ld/testsuite/ld-plugin/plugin-27.d
new file mode 100644
index 0000000..bae8c2c
--- /dev/null
+++ b/ld/testsuite/ld-plugin/plugin-27.d
@@ -0,0 +1 @@
+.*: error: Fatal error
diff --git a/ld/testsuite/ld-plugin/plugin-28.d b/ld/testsuite/ld-plugin/plugin-28.d
new file mode 100644
index 0000000..9052b76
--- /dev/null
+++ b/ld/testsuite/ld-plugin/plugin-28.d
@@ -0,0 +1 @@
+.*: error: Error
diff --git a/ld/testsuite/ld-plugin/plugin-29.d b/ld/testsuite/ld-plugin/plugin-29.d
new file mode 100644
index 0000000..c42bdf2
--- /dev/null
+++ b/ld/testsuite/ld-plugin/plugin-29.d
@@ -0,0 +1 @@
+.*: warning: Warning
diff --git a/ld/testsuite/ld-plugin/plugin.exp b/ld/testsuite/ld-plugin/plugin.exp
index b832534..35b7bbe 100644
--- a/ld/testsuite/ld-plugin/plugin.exp
+++ b/ld/testsuite/ld-plugin/plugin.exp
@@ -168,6 +168,12 @@ set plugin_tests [list \
$testsrcfiles $libs" "" "" "" {{ld plugin-17.d}} "main.x" ] \
[list "load plugin with source not claimed" "-plugin $plugin_path $regclm \
$testsrcfiles $libs" "" "" "" {{ld plugin-26.d}} "main.x" ] \
+ [list "plugin fatal error" "-plugin $plugin2_path -plugin-opt fatal \
+ $testobjfiles $libs" "" "" "" {{ld plugin-27.d}} "main.x" ] \
+ [list "plugin error" "-plugin $plugin2_path -plugin-opt error \
+ $testobjfiles $libs" "" "" "" {{ld plugin-28.d}} "main.x" ] \
+ [list "plugin warning" "-plugin $plugin2_path -plugin-opt warning \
+ $testobjfiles $libs" "" "" "" {{ld plugin-29.d}} "main.x" ] \
]
set plugin_lib_tests [list \