Capturing line no and file name of a joinpoint
authorKetan Dixit <ketan.dixit@gmail.com>
Fri, 13 Aug 2010 22:30:29 +0000 (18:30 -0400)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Fri, 13 Aug 2010 22:49:24 +0000 (18:49 -0400)
src/aop-pc-assign.c
src/aop-pc-entry.c
src/aop-pc-exit.c
src/aop-pc-fun-call.c
src/aop-pointcut.c
src/aop-pointcut.h
src/aop.h

index 07b88b8b31ce4610eb087c20bfe2fef84bfb950e..03801cffe0f6cf2a9998026f83db0226997bdd74 100644 (file)
@@ -306,6 +306,7 @@ op_join_on_assign (struct aop_pointcut *pc, join_callback cb,
                   void *callback_param)
 {
   basic_block bb;
+  expanded_location xloc;
 
   aop_assert (pc->kind == ATP_ASSIGN);
 
@@ -320,7 +321,8 @@ op_join_on_assign (struct aop_pointcut *pc, join_callback cb,
          if (stmt_matches_pointcut (pc, stmt))
            {
              struct aop_joinpoint jp;
-             init_joinpoint (&jp, &gsi, pc, stmt);
+             xloc = expand_location (gimple_location (stmt));
+             init_joinpoint (&jp, &gsi, pc, stmt, xloc.line, xloc.file);
              cb (&jp, callback_param);
            }
        }
index 33c985be5f6d979647a1f7b971b0421b15e01ce8..faf7ee8f562db75e372a9c58ffe7dd3836dfa00f 100644 (file)
@@ -32,6 +32,7 @@
 #include <basic-block.h>
 #include <gimple.h>
 #include <string.h>
+#include <tree-flow.h>
 
 #include "aop.h"
 #include "aop-pointcut.h"
  * \{
  */
 
+static expanded_location
+get_function_entry_xloc()
+{
+  basic_block bb;
+  expanded_location xloc;
+  
+  bb = ENTRY_BLOCK_PTR_FOR_FUNCTION (cfun);
+  xloc = expand_location (gimple_location (first_stmt (bb->next_bb)));
+  return xloc;
+}
+
+
+
 static void
 op_join_on_function_entry (struct aop_pointcut *pc, join_callback cb,
                           void *callback_param)
 {
   struct aop_joinpoint jp;
   gimple_stmt_iterator gsi;
+  expanded_location xloc;
 
   aop_assert (pc->kind == ATP_ENTRY);
 
@@ -64,8 +79,8 @@ op_join_on_function_entry (struct aop_pointcut *pc, join_callback cb,
      op_prepare_entry when it is time to insert advice.  (We poison it
      just to make sure that initialization is getting called.)*/
   memset (&gsi, 0xfa, sizeof (gimple_stmt_iterator));
-
-  init_joinpoint (&jp, &gsi, pc, NULL);
+  xloc = get_function_entry_xloc ();
+  init_joinpoint (&jp, &gsi, pc, NULL, xloc.line, xloc.file);
   cb (&jp, callback_param);
 }
 
index ca31b762370e8f26571a60b274c6a62d4fc55166..cf1caf048b8c5882679c1313943de043b0e654ce 100644 (file)
@@ -48,6 +48,7 @@ op_join_on_function_exit (struct aop_pointcut *pc, join_callback cb,
 {
   basic_block bb;
   gimple stmt;
+  expanded_location xloc;
   aop_assert (pc->kind == ATP_EXIT);
   
   FOR_EACH_BB(bb)
@@ -60,7 +61,8 @@ op_join_on_function_exit (struct aop_pointcut *pc, join_callback cb,
          if (gimple_code (stmt) == GIMPLE_RETURN)
            {
              struct aop_joinpoint jp;
-             init_joinpoint (&jp, &gsi, pc, stmt);
+             xloc = expand_location (gimple_location (stmt)); 
+             init_joinpoint (&jp, &gsi, pc, stmt, xloc.line, xloc.file);
              cb (&jp, callback_param);
 
              /* It's possible that gsi is no longer a valid iterator
index 5cc0da07da8c802cad46934502d6d9017297556d..7293ab7894f6d4346ceec324ec29d5eb269f2769 100644 (file)
@@ -136,13 +136,14 @@ op_join_on_function_call (struct aop_pointcut *pc, join_callback cb,
 {
   basic_block my_basic_block;
   gimple_stmt_iterator gsi;
+  expanded_location xloc;
 
   aop_assert (pc->kind == ATP_CALL);
 
   FOR_EACH_BB(my_basic_block)
     {
       for (gsi = gsi_start_bb (my_basic_block) ; !gsi_end_p (gsi) ;
-          gsi_next (&gsi)) 
+          gsi_next (&gsi))
        {
          gimple stmt = gsi_stmt (gsi);
 
@@ -155,7 +156,8 @@ op_join_on_function_call (struct aop_pointcut *pc, join_callback cb,
              if (call_matches (pc, stmt))
                {                       
                  struct aop_joinpoint jp;
-                 init_joinpoint (&jp, &gsi, pc, stmt);
+                 xloc = expand_location (gimple_location (stmt));
+                 init_joinpoint (&jp, &gsi, pc, stmt, xloc.line, xloc.file);
                  cb (&jp, callback_param);             
                }
            }
@@ -256,7 +258,7 @@ op_get_return_value (struct aop_dynval *dv)
 
   struct aop_joinpoint *jp = dv->jp;
   stmt = gsi_stmt (*(jp->gsi));
-  
+
   /* If this function isn't on the right side of an assignment, we
      need to _put it_ on the right hand side of an assignment so
      we can grab its return value. */
@@ -265,7 +267,7 @@ op_get_return_value (struct aop_dynval *dv)
       tree new_lhs = create_tmp_var (gimple_call_return_type(stmt),
                                     "aop_return");
       gimple_call_set_lhs (stmt, new_lhs);
-      update_stmt (stmt); 
+      update_stmt (stmt);
     }
 
   return_value = stabilize_reference (gimple_call_lhs (stmt));
@@ -347,7 +349,7 @@ aop_capture_return_value (struct aop_joinpoint *jp)
   dv->type = pc->pc_call.return_type;
   dv->jp = jp;
   dv->get_dynval = op_get_return_value;
-  return dv;  
+  return dv;
 }
 
 /**
@@ -386,7 +388,7 @@ aop_capture_return_value_by_type (struct aop_joinpoint *jp,
   dv->type = type;
   dv->jp = jp;
   dv->get_dynval = op_get_return_value;
-  return dv;  
+  return dv;
 }
 
 static tree
index 587b097f55ed26e75f2355af34a6333a640792df..4c4727f5a4499406653ea375c8e395570837ed94 100644 (file)
@@ -54,10 +54,26 @@ create_pointcut (enum aop_pckind kind)
 /* Initializes a joinpoint with default values. */
 void
 init_joinpoint (struct aop_joinpoint *jp, gimple_stmt_iterator *gsi,
-               struct aop_pointcut *pc, gimple stmt)
+               struct aop_pointcut *pc, gimple stmt, int line,
+               const char *file)
 {
   jp->pc = pc;
   jp->gsi = gsi;
   jp->stmt = stmt;
+  jp->line = line;
+  jp->file = file;
   jp->is_prepared = false;
+  
+}
+
+int
+aop_capture_lineno (struct aop_joinpoint *jp)
+{
+  return jp->line;
+}
+
+const char *
+aop_capture_file_name (struct aop_joinpoint *jp)
+{
+  return jp->file;
 }
index 6c6ff8c51fb98911c2e3a3bc42a2546c44abb906..7f6a338d35094eb7e098afbef193a01296267863 100644 (file)
@@ -55,7 +55,7 @@ struct aop_pc_entry {
 struct aop_pc_fun_call {
   const char *function_name;
   const struct aop_type *return_type;
-  struct aop_param_desc *param_list_head; 
+  struct aop_param_desc *param_list_head;
 };
 
 /* An AOP pointcut represents the a set of joinponts: locations in the
@@ -70,7 +70,6 @@ struct aop_pointcut {
   void (*join_on) (struct aop_pointcut *, join_callback, void *);
   insert_callback insert_before;
   insert_callback insert_after;
-  
 
   /* prepare_for_weave() gets called once for each joinpoint before
      any advice gets inserted at that joinpoint.  */
@@ -104,12 +103,17 @@ struct aop_joinpoint {
   /* True if prepare_for_weave() has been called for this
      joinpoint. */
   bool is_prepared;
+  /* The line number corresponding to the joinpoint */
+  int line;
+  /* The file name corresponding to the joinpoint */
+  const char *file;
 };
 
 struct aop_pointcut *create_pointcut (enum aop_pckind kind);
 
 void init_joinpoint (struct aop_joinpoint *jp, gimple_stmt_iterator *gsi,
-                    struct aop_pointcut *pc, gimple stmt);
+                    struct aop_pointcut *pc, gimple stmt, int line, 
+                    const char *file);
 
 void op_default_prepare_for_weave (struct aop_joinpoint *jp);
 void op_default_insert_before (struct aop_joinpoint *jp, gimple stmt);
index 9e9b607dbf86e012fb43533ebaa72a1099dd141e..05714988b587931da2a6d47fe73c500e9198eaeb 100644 (file)
--- a/src/aop.h
+++ b/src/aop.h
@@ -299,4 +299,8 @@ extern struct aop_dynval *aop_capture_assigned_value (struct aop_joinpoint *jp);
  */
 
 extern int aop_capture_lhs_var_scope (struct aop_joinpoint *jp);
+
+extern int aop_capture_lineno (struct aop_joinpoint *jp);
+
+extern const char *aop_capture_file_name (struct aop_joinpoint *jp);
 #endif