This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
patch PLUGIN_HEADER_FILE event for tracing of header inclusions.
- From: Basile Starynkevitch <basile at starynkevitch dot net>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 18 Nov 2013 20:06:03 +0100
- Subject: patch PLUGIN_HEADER_FILE event for tracing of header inclusions.
- Authentication-results: sourceware.org; auth=none
Hello All
After http://gcc.gnu.org/ml/gcc/2013-11/msg00360.html &
http://gcc.gnu.org/ml/gcc/2013-11/msg00361.html &
http://gcc.gnu.org/ml/gcc/2013-11/msg00347.html I am proposing the
following patch
############## patch
Index: gcc/plugin.def
===================================================================
--- gcc/plugin.def (revision 204976)
+++ gcc/plugin.def (working copy)
@@ -92,6 +92,10 @@
/* Called when a pass is first instantiated. */
DEFEVENT (PLUGIN_NEW_PASS)
+/* Called when a file is #include-d or given thru #line directive. */
+DEFEVENT (PLUGIN_INCLUDE_FILE)
+
+
/* After the hard-coded events above, plugins can dynamically allocate
events
at run time.
PLUGIN_EVENT_FIRST_DYNAMIC only appears as last enum element. */
Index: gcc/c-family/c-opts.c
===================================================================
--- gcc/c-family/c-opts.c (revision 204976)
+++ gcc/c-family/c-opts.c (working copy)
@@ -34,6 +34,7 @@
#include "debug.h" /* For debug_hooks. */
#include "opts.h"
#include "options.h"
+#include "plugin.h" /* For PLUGIN_INCLUDE_FILE event. */
#include "mkdeps.h"
#include "c-target.h"
#include "tm.h" /* For BYTES_BIG_ENDIAN,
@@ -43,6 +44,7 @@
TARGET_OPTF. */
#include "tm_p.h" /* For C_COMMON_OVERRIDE_OPTIONS. */
+
#ifndef DOLLARS_IN_IDENTIFIERS
# define DOLLARS_IN_IDENTIFIERS true
#endif
@@ -1397,6 +1399,16 @@
else
fe_file_change (new_map);
+ if (new_map
+ && (new_map->reason == LC_ENTER || new_map->reason == LC_RENAME))
+ {
+ /* Signal to plugins that a file is included. This could happen
+ several times. */
+ invoke_plugin_callbacks
+ (PLUGIN_INCLUDE_FILE,
+ const_cast<char*> (ORDINARY_MAP_FILE_NAME (new_map)));
+ }
+
if (new_map == 0 || (new_map->reason == LC_LEAVE && MAIN_FILE_P
(new_map)))
{
pch_cpp_save_state ();
########################################### gcc/ChangeLog entry
2013-11-18 Basile Starynkevitch <basile@starynkevitch.net>
* plugins.def (PLUGIN_INCLUDE_FILE): New event.
########################################### gcc/c-family/ChangeLog entry
2013-11-18 Basile Starynkevitch <basile@starynkevitch.net>
* c-opts.c: Include plugin.h header.
(cb_file_change): Sent plugin event PLUGIN_INCLUDE_FILE.
###########################################
Ok for 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 mine, sont seulement les miennes} ***