Output "warning:" or "error:" in plugin messages
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 11 Feb 2015 20:16:07 +0000 (12:16 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 11 Feb 2015 22:00:51 +0000 (14:00 -0800)
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.

ld/ChangeLog
ld/plugin.c
ld/testplug2.c
ld/testsuite/ChangeLog
ld/testsuite/ld-plugin/plugin-27.d [new file with mode: 0644]
ld/testsuite/ld-plugin/plugin-28.d [new file with mode: 0644]
ld/testsuite/ld-plugin/plugin-29.d [new file with mode: 0644]
ld/testsuite/ld-plugin/plugin.exp

index 7bd1c01ce8387fd54ffa1acb0d5c091fe6236d6e..f46bd9b0175d8ce66ace64d330f26c01303865a6 100644 (file)
@@ -1,3 +1,9 @@
+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.
index b48ce86a6f1ecc4d1561171d212a8526d91270c2..4fee305b698c844f9e717a843dd17dcb89c383f7 100644 (file)
@@ -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);
index 8cafc5160623f45a4bfc465751e8a09b4d60cbfa..10f0efba6ccca3c91fe47bed1118ccde81626e6d 100644 (file)
@@ -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);
index ea1d5336724e6e15629402be0a34e23c60a91775..2b963fa391deceb1867d55d52b89b06018dcf519 100644 (file)
@@ -1,3 +1,11 @@
+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
diff --git a/ld/testsuite/ld-plugin/plugin-27.d b/ld/testsuite/ld-plugin/plugin-27.d
new file mode 100644 (file)
index 0000000..bae8c2c
--- /dev/null
@@ -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 (file)
index 0000000..9052b76
--- /dev/null
@@ -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 (file)
index 0000000..c42bdf2
--- /dev/null
@@ -0,0 +1 @@
+.*: warning: Warning
index b83253440d21cd9ba3737efabecf18ea941f0a36..35b7bbe5298c8a48e0280ed488d8fc11781b4b03 100644 (file)
@@ -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 \
This page took 0.027897 seconds and 4 git commands to generate.