Merge branch 'in_param'
authorJustin Seyster <jseyster@cs.sunysb.edu>
Tue, 26 Oct 2010 01:33:42 +0000 (21:33 -0400)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Tue, 26 Oct 2010 01:33:42 +0000 (21:33 -0400)
Conflicts:
src/aop-pointcut.c

1  2 
src/aop-pc-entry.c
src/aop-pointcut.c
src/aop.h

index 162fad54794cd9f13cdde9eedb2a7b03de1c5a2a,6960592d2e05d399d94ad17149eebacfd75dc49e..86b7d2adc26fbbf8b98da1ce39ee98c9b444cb0f
@@@ -222,20 -204,13 +221,21 @@@ aop_match_function_entry (
    return pc;
  }
  
 -void aop_filter_entry_by_name(struct aop_pointcut *pc_function_entry,
 -                            const char *advice_function_entry)
 +/**
 + * Filter a function entry pointcut so it will contain the current
 + * function's entry join point only if the current function's name
 + * matches the specified name.  This filter is a convenient way to
 + * target the entry point of a specific function for instrumentation.
 + * \param pc The function entry pointcut to filter.  Function entry
 + * pointcuts are created with aop_match_function_entry().
 + * \param name The name to filter by.
 + */
 +void aop_filter_entry_by_name(struct aop_pointcut *pc, const char *name)
  {
 -  pc_function_entry->pc_entry.function_name = advice_function_entry;
 +  pc->pc_entry.function_name = name;
  }
  
  /* Close Doxygen defgroup block. */
  /**
   * \}
index aa111591425b3844d1713f3f1d8cb4ad2143e4b8,4acd224208cb6231eccf5d9a637bd99af3d398c5..ca1cae88440b7a37c373b88335b9b98676974a51
@@@ -133,53 -140,6 +133,53 @@@ op_get_in_param (struct aop_dynval *dv
    return param;
  }
  
- check_in_param (struct aop_param_desc *param_desc)
 +bool
-    tree param_type;
-    tree param_decl;
-    int index = 0;
-    bool index_found = false;
-    for (param_decl = DECL_ARGUMENTS (current_function_decl);
-       param_decl; param_decl = TREE_CHAIN (param_decl))
-      {
-        if (index == param_desc->param_index)
-        {
-          /* Index found check the type */
-          if ((param_type = TREE_TYPE (param_decl)) == NULL
-              || !does_type_match (param_type, param_desc->type))
-            index_found = false;
-          else
-            index_found = true;
-          break;
-        }
-        index++;
-      }
-    return index_found;
++check_in_param (int param_index, const struct aop_type *type)
 +{
-       if(!check_in_param (param_desc))
++  tree param_decl;
++  tree param_type;
++  int index = 0;
++  bool index_found = false;
++  for (param_decl = DECL_ARGUMENTS (current_function_decl);
++       param_decl; param_decl = TREE_CHAIN (param_decl))
++    {
++      if (index == param_index)
++      {
++        /* Index found check the type */
++        if ((param_type = TREE_TYPE (param_decl)) == NULL
++            || !does_type_match (param_type, type))
++          index_found = false;
++        else
++          index_found = true;
++        
++        break;
++      }
++      index++;
++    }
++  return index_found;
 +}
 +
 +bool
 +check_in_params (struct aop_pointcut *pc)
 +{
 +  struct aop_param_desc *param_desc;
 +
 +  /* Check parameter types. */
 +  for (param_desc = pc->in_param_list_head ; param_desc != NULL ;
 +       param_desc = param_desc->next)
 +    {     
++      if(!check_in_param (param_desc->param_index, param_desc->type))
 +      return false;
 +    }
 +
 +  return true;
 +}
 +
 +/**
 + * \defgroup all_pc Functions for All Pointcuts
 + * \{
 + */
 +
  /**
   * Get a dynval representing the nth parameter passed to the current
   * fuction.  Be careful not to capture the <code>in_param</code> of
@@@ -278,31 -280,43 +278,72 @@@ aop_filter_by_in_param (struct aop_poin
    param->type = type;
  }
  
+ /**
+  * Get a dynval representing the nth parameter passed to the current
+  * function if there is a parameter n and it matches the specified
+  * type.  This function makes it possible to capture a parameter even
+  * if you have not filtered on its type with
+  * aop_filter_call_pc_by_param().  However, it returns NULL if there
+  * is no parameter n or if parameter n does not match the specified
+  * type.
+  * \param jp A function call join point.  Function call join points
+  * are obtained by joining on an aop_match_function_call() pointcut.
+  * \param n The index of the parameter to capture.  Parameters are
+  * indexed from zero.
+  * \param type This function verifies that the captured parameter
+  * matches the specified type.
+  * \return dynval with its type determined by the specified type or
+  * NULL if there is no matching parameter n.
+  */
+ struct aop_dynval *
+ aop_capture_in_param_by_type (struct aop_joinpoint *jp, int n,
+                          const struct aop_type *type)
+ {
+   struct aop_pointcut *pc;
+   struct aop_dynval *dv;
+   pc = jp->pc;
+   /* Check that there is a nth parameter and that it matches the
+      type. */
+   
+   if (!check_in_param (n, type))
+     return NULL;
+   
+   dv = ggc_alloc (sizeof (struct aop_dynval));
+   dv->kind = ADV_FUN_PARAM;
+   dv->type = type;
+   dv->jp = jp;
+   dv->get_dynval = op_get_in_param;
+   dv->dynval_call.param_index = n;
+   return dv;
+ }
++
 +/**
 + * Get the line number of join point.  You usually want to call this
 + * with aop_capture_file_name() to fully identify the line of code the
 + * join point is from.
 + * \param jp Any join point.
 + */
 +int
 +aop_capture_lineno (struct aop_joinpoint *jp)
 +{
 +  return jp->line;
 +}
 +
 +/**
 + * Get the name of the file this join point is in.  This function will
 + * usually return the name of the file that is currently being
 + * compiled, but compiler macros make it possible for their to be join
 + * points from other files.
 + * \param jp Any join point.
 + */
 +const char *
 +aop_capture_file_name (struct aop_joinpoint *jp)
 +{
 +  return jp->file;
 +}
 +
 +/**
 + * \}
 + */
diff --cc src/aop.h
Simple merge