Merge branch 'master' of ssh://ketand@git.fsl.cs.sunysb.edu/home/fslgit/interaspect
authorKetan Dixit <ketan.dixit@gmail.com>
Fri, 21 May 2010 02:33:36 +0000 (22:33 -0400)
committerKetan Dixit <ketan.dixit@gmail.com>
Fri, 21 May 2010 02:33:36 +0000 (22:33 -0400)
Conflicts:
src/aop-dynval.h
src/aop-pointcut.h
src/aop-weave.c

1  2 
src/aop-dynval.h
src/aop-pointcut.h
src/aop-weave.c
src/aop.h

index 7be303b6ede79282fb5c6b1dad5dd35deb1f447d,b63bc0e3a4cb145a7ead32c19d8935d33f878582..d1a0fd3c45a2d34c3fd3a8418e903b6c47fa210e
@@@ -23,14 -23,9 +23,15 @@@ struct aop_type
  
  enum aop_dvkind {
    ADV_LHS_ADDR,
-   ADV_FUN_RETVAL
 +  ADV_FUN_PARAM,
++  ADV_FUN_RETVAL,
+   ADV_ASSIGN_VAL,
  };
  
 +struct aop_dynval_fun_call {
 +  int param_id;
 +};
 +
  /* An aop-dynval represents a dynamic value in the target program that
     can be passed to an advice function.  AOP weaving functions (such
     as aop_insert_advice()) use a dynval to create instrumentation that
  struct aop_dynval
  {
    enum aop_dvkind kind;
--
    const struct aop_type *type;
    struct aop_joinpoint *jp;
 + 
 +  union {
 +    struct aop_dynval_fun_call dynval_call;
 +  };
  
    /* Ops vector for aop_dynval. */
    /* The get_dynval() op gets called when an advice call gets
index 7ef268e2240a486852c794cc0ebcaadb83fc4a03,d462ec44af10c27e9ff8304cec506f398ae1daef..3c960361a1bef40abf058b2ec2ae34c5b623552b
@@@ -67,12 -49,13 +68,17 @@@ 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.  */
+   void (*prepare_for_weave) (struct aop_joinpoint *);
    union {
      struct aop_pc_assign pc_assign;
 +    struct aop_pc_entry pc_entry;
 +    struct aop_pc_fun_call pc_call;
    };
  };
  
@@@ -90,9 -73,13 +96,14 @@@ struct aop_joinpoint 
  
    /* The GIMPLE statement being instrumented (where relevant). */
    gimple stmt;
+   /* True if prepare_for_weave() has been called for this
+      joinpoint. */
+   bool is_prepared;
  };
  
+ void op_default_prepare_for_weave (struct aop_joinpoint *jp);
  void op_default_insert_before (struct aop_joinpoint *jp, gimple stmt);
 +void op_default_insert_after (struct aop_joinpoint *jp, gimple stmt);
  
  #endif
diff --cc src/aop-weave.c
index 17dd716ab3ac70dc38b981c4ce04804c32d36c06,2d02e4cb786e6f4fffa3385d4d893cf516de8bb6..f5465b778bec8189cb7acea4e479c9357a991cea
@@@ -146,38 -145,33 +146,51 @@@ op_default_insert_before (struct aop_jo
    gsi_insert_before (jp->gsi, stmt, GSI_SAME_STMT);
  }
  
 +
 +/* This is the default insert_after() operation for aop_pointcut
 +   objects.  It just inserts a gimple statement before the iterator in
 +   the aop_joinpoint object.  This function holds to the requirement
 +   that inserting multiple gimple statements at the joinpoint will
 +   result in those statements appearing in the order they were
 +   added. */
 +void
 +op_default_insert_after (struct aop_joinpoint *jp, gimple stmt)
 +{
 +  gsi_insert_after (jp->gsi, stmt, GSI_SAME_STMT);
 +}
 +
+ /* This is the default prepare_for_weave() operation for aop_pointcut
+    objects.  It does nothing. */
+ void
+ op_default_prepare_for_weave (struct aop_joinpoint *jp)
+ {
+   /* This space intentionally left blank. */
+ }
  void
 -aop_insert_advice (struct aop_joinpoint *jp, const char *func_name, ...)
 +aop_insert_advice (struct aop_joinpoint *jp, const char *func_name, 
 +                 enum aop_insert_location location, ...)
  {
    va_list argp;
    gimple func_call;
    struct aop_pointcut *pc;
  
 +  va_start (argp, location);
 +  func_call = build_gcc_call (func_name, void_type_node, argp);
 +  va_end (argp);
 +
    pc = jp->pc;
 -  va_start (argp, func_name);
 -  func_call = build_gcc_call (func_name, void_type_node, argp);
 -  va_end (argp);
 -
 -  pc->insert_before(jp, func_call);
+   /* Make sure this joinpoint is prepared for advice. */
+   if (!jp->is_prepared)
+     {
+       pc->prepare_for_weave (jp);
+       jp->is_prepared = true;
+     }
-   {
 +  if(location == AOP_INSERT_BEFORE)
-   }
 +    pc->insert_before(jp, func_call);
-   {
 +  else if(location == AOP_INSERT_AFTER)
-   }
 +    pc->insert_after(jp, func_call);
++  pc = jp->pc;
  }
diff --cc src/aop.h
index ad067d339e0bf5c4038e349d02c5b77d2726bdb5,cae23b3c3b973921185d2bbe53c086a66824155f..150182de3813ec045fc37436ddf2589313ed6230
+++ b/src/aop.h
@@@ -97,23 -92,8 +97,24 @@@ enum aop_argkind 
  
  const char *aop_capture_function_name (struct aop_joinpoint *jp);
  struct aop_dynval *aop_capture_lhs_addr (struct aop_joinpoint *jp);
+ struct aop_dynval *aop_capture_assigned_value (struct aop_joinpoint *jp);
  struct aop_pointcut *aop_match_function_entry ();
  struct aop_pointcut *aop_match_function_exit ();
 +struct aop_pointcut *aop_match_function_call ();
 +
 +void aop_filter_function_entry_pointcut(struct aop_pointcut *pc_function_entry,
 +                                      const char *advice_function_entry);
 +
 +void aop_filter_function_call_pointcut(struct aop_pointcut *pc_function_call,
 +                                      const char *advice_function_call);
 +
 +void aop_filter_function_call_pointcut_by_param_index(struct aop_pointcut *pc,
 +                                                    int param_index);  
 +
 +struct aop_dynval *
 +aop_capture_return_value (struct aop_joinpoint *jp);
 +
 +struct aop_dynval *
 +aop_capture_param (struct aop_joinpoint *jp, int param_index);
  
  #endif