diff mbox

patch PLUGIN_HEADER_FILE event for tracing of header inclusions.

Message ID 20131119094811.GA13278@ours.starynkevitch.net
State New
Headers show

Commit Message

Basile Starynkevitch Nov. 19, 2013, 9:48 a.m. UTC
On Mon, Nov 18, 2013 at 10:50:10PM +0000, Joseph S. Myers wrote:
> On Mon, 18 Nov 2013, Basile Starynkevitch wrote:
> 
> > @@ -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
> 
> This is a spurious diff hunk that should not be in this patch.
> 
> OK minus the spurious change in the absence of objections from the plugin 
> maintainers within 48 hours (or in the presence of approval from either of 
> them).

Thanks for your attention. I am attaching a slightly improved patch 
against trunk svn rev. 305009 (the improvements are removing the spurious 
diff hunk, and better comments.)

##### gcc/c-family/ChangeLog entry :
2013-11-19  Basile Starynkevitch  <basile@starynkevitch.net>

	* c-opts.c: Include plugin.h.
	(cb_file_change): Invoke plugin event PLUGIN_INCLUDE_FILE.


##### gcc/ChangeLog entry :
2013-11-19  Basile Starynkevitch  <basile@starynkevitch.net>

	* plugin.def (PLUGIN_INCLUDE_FILE): New event, invoked in 
	cb_file_change.

### 

Ok for trunk?

Regards.

Comments

Joseph Myers Nov. 19, 2013, 4:16 p.m. UTC | #1
On Tue, 19 Nov 2013, Basile Starynkevitch wrote:

> Thanks for your attention. I am attaching a slightly improved patch 
> against trunk svn rev. 305009 (the improvements are removing the spurious 
> diff hunk, and better comments.)

Still OK in the absence of plugin maintainer objections.
Diego Novillo Nov. 19, 2013, 4:17 p.m. UTC | #2
On Tue, Nov 19, 2013 at 11:16 AM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> On Tue, 19 Nov 2013, Basile Starynkevitch wrote:
>
>> Thanks for your attention. I am attaching a slightly improved patch
>> against trunk svn rev. 305009 (the improvements are removing the spurious
>> diff hunk, and better comments.)
>
> Still OK in the absence of plugin maintainer objections.

I'm OK with this patch.  Thanks, Basile.


Diego.
Basile Starynkevitch Nov. 19, 2013, 4:27 p.m. UTC | #3
On Tue, 2013-11-19 at 16:16 +0000, Joseph S. Myers wrote:
> On Tue, 19 Nov 2013, Basile Starynkevitch wrote:
> 
> > Thanks for your attention. I am attaching a slightly improved patch 
> > against trunk svn rev. 305009 (the improvements are removing the spurious 
> > diff hunk, and better comments.)
> 
> Still OK in the absence of plugin maintainer objections.

Thanks: Committed revision 205038.
diff mbox

Patch

Index: gcc/c-family/c-opts.c
===================================================================
--- gcc/c-family/c-opts.c	(revision 205009)
+++ gcc/c-family/c-opts.c	(working copy)
@@ -34,6 +34,7 @@  along with GCC; see the file COPYING3.  If not see
 #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,
@@ -1397,6 +1398,17 @@  cb_file_change (cpp_reader * ARG_UNUSED (pfile),
   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 with the same file path, e.g. because of
+	 several '#include' or '#line' directives...  */
+      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 ();
Index: gcc/plugin.def
===================================================================
--- gcc/plugin.def	(revision 205009)
+++ gcc/plugin.def	(working copy)
@@ -92,6 +92,12 @@  DEFEVENT (PLUGIN_EARLY_GIMPLE_PASSES_END)
 /* Called when a pass is first instantiated.  */
 DEFEVENT (PLUGIN_NEW_PASS)
 
+/* Called when a file is #include-d or given thru #line directive.
+   Could happen many times.  The event data is the included file path,
+   as a const char* pointer.  */
+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.  */