This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Plugins: unpleasant dump_active_plugins
- From: Basile STARYNKEVITCH <basile at starynkevitch dot net>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 12 Nov 2009 15:24:10 +0100
- Subject: Plugins: unpleasant dump_active_plugins
Hello All
The attached patch (to trunk rev 154119) fixes several minor issues in dump_active_plugins, which happens to be called
when a plugin misbehave (e.g. SIGSEGV or bad gcc_assert).
The issues fixed are minor
* the current dump_active_plugins mix printing to file & to stderr [this is not coherent, even if it will almost
always called with file == stderr]
* the Event & Plugins strings have been builtin and lack internationalization.
* for plugin events of very different name width (e.g. PLUGIN_CXX_CP_PRE_GENERICIZE vs PLUGIN_FINISH) the output was
unpleasant visually (misaligned columns)
* a fprintf of just "\n" was replaced by a putc
#### gcc/ChangeLog ####
2009-11-12 Basile Starynkevitch <basile@starynkevitch.net>
* plugin.c (FMT_FOR_PLUGIN_EVENT): added definition.
(dump_active_plugins): output to file everything. Use
internationalized dump & FMT_FOR_PLUGIN_EVENT.
#######################
Without this patch (from my MELT branch) when a MELT module (loaded by the melt.so plugin) crashed [*], the output was
as ugly as
Event Plugins
PLUGIN_FINISH_UNIT melt.so
PLUGIN_FINISH melt.so
PLUGIN_GGC_MARKING melt.so
PLUGIN_ATTRIBUTES melt.so
PLUGIN_START_UNIT melt.so
cc1: internal compiler error: Segmentation fault
With this patch, the output is more pleasant in my eyes
Event | Plugins
PLUGIN_FINISH_UNIT | melt.so
PLUGIN_FINISH | melt.so
PLUGIN_GGC_MARKING | melt.so
PLUGIN_ATTRIBUTES | melt.so
PLUGIN_START_UNIT | melt.so
cc1: internal compiler error: Segmentation fault
Note [*]. FYI some MELT module crashes when compiled by tinycc, but this don't happen when the MELT module is compiled
by gcc-4.2 gcc-4.3 gcc-4.4 gcc-trunk or clang, so I suspect a tinycc bug.
http://www.mail-archive.com/tinycc-devel@nongnu.org/msg02414.html
#########################
Ok to apply the patch on trunk?
Regards.
--
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***
Index: gcc/plugin.c
===================================================================
--- gcc/plugin.c (revision 154119)
+++ gcc/plugin.c (working copy)
@@ -63,6 +63,8 @@ const char *plugin_event_name[] =
"PLUGIN_PRAGMAS",
"PLUGIN_EVENT_LAST"
};
+/* a printf format large enough for the largest event above */
+#define FMT_FOR_PLUGIN_EVENT "%-26s"
/* Hash table for the plugin_name_args objects created during command-line
parsing. */
@@ -637,18 +639,18 @@ dump_active_plugins (FILE *file)
if (!plugins_active_p ())
return;
- fprintf (stderr, "Event\t\t\tPlugins\n");
+ fprintf (file, FMT_FOR_PLUGIN_EVENT " | %s\n", _("Event"), _("Plugins"));
for (event = PLUGIN_PASS_MANAGER_SETUP; event < PLUGIN_EVENT_LAST; event++)
if (plugin_callbacks[event])
{
struct callback_info *ci;
- fprintf (file, "%s\t", plugin_event_name[event]);
+ fprintf (file, FMT_FOR_PLUGIN_EVENT " |", plugin_event_name[event]);
for (ci = plugin_callbacks[event]; ci; ci = ci->next)
- fprintf (file, "%s ", ci->plugin_name);
+ fprintf (file, " %s", ci->plugin_name);
- fprintf (file, "\n");
+ putc('\n', file);
}
}