Fixed the bugs for compilation with Bzip
authorKetan Dixit <ketan.dixit@gmail.com>
Fri, 21 May 2010 01:10:22 +0000 (21:10 -0400)
committerKetan Dixit <ketan.dixit@gmail.com>
Fri, 21 May 2010 01:10:22 +0000 (21:10 -0400)
src/aop-dynval.h
src/aop-main.c
src/aop-pc-fun-call.c
src/aop-pointcut.h
src/aop-weave.c
src/aop.h

index 9edf7d73f905d30f950cdda277fd256dbcd9ad34..7be303b6ede79282fb5c6b1dad5dd35deb1f447d 100644 (file)
@@ -27,6 +27,10 @@ enum aop_dvkind {
   ADV_FUN_RETVAL
 };
 
+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
@@ -37,6 +41,10 @@ struct aop_dynval
 
   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 b379c067f540ce295981d632c9e6dfc2fdc35a29..4cd0a33e917a9fd6c2a98dc4cbcde4de54b78d32 100644 (file)
@@ -53,7 +53,6 @@
 #include "aop.h"
 #include "aop-pointcut.h"
 
-#define PAUSE_ON_START
 
 static const char *aop_plugin_name;
 
index d4d8e73792b42fef8917edeae6206589e94e6c6d..ef3961787a93ccb31f1f6f0e12ac1b6cdbba9f36 100644 (file)
@@ -22,7 +22,6 @@
 #undef PACKAGE_VERSION
 
 #include <locale.h>
-
 #include <config.h>
 #include <system.h>
 #include <coretypes.h>
 #include <ggc.h>
 #include <basic-block.h>
 #include <gimple.h>
+#include <diagnostic.h>
 #include <string.h>
 
+
 #include "aop.h"
 #include "aop-pointcut.h"
 #include "aop-type.h"
@@ -66,15 +67,38 @@ op_join_on_function_call (struct aop_pointcut *pc, join_callback cb,
        if (gimple_code (my_statement) == GIMPLE_CALL)
          {
            func = gimple_call_fn(my_statement);
+           
+           if (TREE_CODE(func) != ADDR_EXPR)
+             {
+               /* This is a call to a function pointer.  Don't worry about it. */
+               fprintf(stderr, "CALL_EXPR with non-ADDR_EXPR function.\n");
+               continue;
+             }
            func_decl = TREE_OPERAND (func, 0);
            func_name = IDENTIFIER_POINTER (DECL_NAME (func_decl));
+   
            if (strcmp (pc->pc_call.function_name, func_name) == 0) 
              {
+               int num_args = gimple_call_num_args(my_statement);
+               fprintf(stderr," Function call to %s has %d parameters passed.\n",pc->pc_call.function_name,num_args);
+               struct aop_param_desc *iter = NULL;     
+               if(pc->pc_call.param_list_head != NULL ) {
+                       iter =  pc->pc_call.param_list_head;
+                       while( iter->next != NULL ) {
+                          iter = iter->next;   
+                          if(iter->param_id > num_args - 1 || iter->param_id < 0) {
+                               fprintf(stderr," Function call to %s does not satisfy the pointcut.\n",pc->pc_call.function_name);
+                               return; 
+                          }                       
+                       }                       
+               }   
+                                       
                struct aop_joinpoint jp;
                jp.pc = pc;
                jp.gsi = &gsi;
-               cb (&jp, callback_param);
-               fprintf (stderr,"Function call to %s captured...",pc->pc_call.function_name);
+               cb (&jp, callback_param);               
+               fprintf (stderr,"Function call to %s captured...\n",pc->pc_call.function_name);
              }
          }
 
@@ -90,7 +114,11 @@ aop_match_function_call ()
   pc = ggc_alloc (sizeof (struct aop_pointcut));
   pc->kind = ATP_CALL;
   pc->join_on = op_join_on_function_call;
-  pc->insert_before = op_default_insert_before;
+  pc->insert_after = op_default_insert_after;
+  /*
+       Initialize the list to NULL
+  */
+  pc->pc_call.param_list_head = NULL;
   return pc;
 }
 
@@ -98,24 +126,35 @@ void aop_filter_function_call_pointcut(struct aop_pointcut *pc_function_call,
                                        const char *advice_function_call)
 {
   pc_function_call->pc_call.function_name=advice_function_call;
+}
 
+void aop_add_param_descriptor(struct aop_pointcut *pc,int param_id)
+{
+   struct aop_param_desc *iter = NULL; 
+  struct aop_param_desc *desc = ggc_alloc (sizeof (struct aop_param_desc)); 
+  desc->param_id=param_id;
+  desc->next = NULL;
+   if(pc->pc_call.param_list_head == NULL ) {
+               
+       pc->pc_call.param_list_head= desc;
+   }
+   else {
+       iter =  pc->pc_call.param_list_head;
+       while( iter->next != NULL ) {
+          iter = iter->next;   
+       }
+       iter->next = desc;      
+   }   
 }
 
 void aop_filter_function_call_pointcut_by_param_index(struct aop_pointcut *pc,
                                                      int param_id)
 {
-  pc->pc_call.param_id=param_id;
-
+  aop_add_param_descriptor(pc,param_id);
 }
 
-/*
-void aop_filter_function_call_pointcut(struct aop_pointcut *pc_function_call,
-                                       const char *advice_function_call)
-{
-  pc_function_call->pc_call.function_name=advice_function_call;
 
-}
-*/
 static tree
 op_get_return_value (struct aop_dynval *dv)
 {
@@ -137,16 +176,15 @@ op_get_return_value (struct aop_dynval *dv)
     {
       fprintf(stderr,"call_lhs is NULL\n");
       /*
-      tree new_lhs = create_tmp_var(gimple_call_return_type(stmt), "hcos_mem_result");
+      tree new_lhs = create_tmp_var(gimple_call_return_type(stmt), "aop_result");
       add_referenced_var(new_lhs);
       new_lhs = make_ssa_name(new_lhs, stmt);
-      
       gimple_call_set_lhs(stmt, new_lhs);
       update_stmt(stmt); 
       */
     }
-  fprintf(stderr,"Before stabilize_reference\n");
   return_value = stabilize_reference(gimple_call_lhs(stmt));
+  debug_gimple_stmt(stmt);
   return return_value;
  
 }
@@ -160,7 +198,6 @@ aop_capture_return_value (struct aop_joinpoint *jp)
   dv->type = aop_t_all_unsigned ();
   dv->jp = jp;
   dv->get_dynval = op_get_return_value;
-  fprintf(stderr,"Came here.......\n");
   return dv;
   
 }
@@ -170,34 +207,19 @@ op_get_param (struct aop_dynval *dv)
 {
   gimple stmt;
   tree param;
-
   struct aop_joinpoint *jp = dv->jp;
-  fprintf(stderr,"In op_get_param\n");
 
   aop_assert (dv->kind == ADV_FUN_PARAM);
   aop_assert (jp->pc->kind == ATP_CALL);
-
-  fprintf(stderr,"op_get_param after assert\n");
   stmt = gsi_stmt (*(jp->gsi));
 
-  /*
-  if (gimple_call_num_args(stmt) < 1)
-    {
-      error("Invalid argument specification in ptcut.\n");
-      return NULL;
-    }
-  */
-  fprintf(stderr,"op_get_param before stab ref \n");
-  param = stabilize_reference(gimple_call_arg(stmt, 0));
-//  param = gimple_call_arg(stmt, 0);  
-//   param = build_int_cst(integer_type_node, 0);
-  fprintf(stderr,"op_get_param after stab ref \n");        
+  param = stabilize_reference(gimple_call_arg(stmt, dv->dynval_call.param_id));
   return param;
 }
 
 
 struct aop_dynval *
-aop_capture_param (struct aop_joinpoint *jp)
+aop_capture_param (struct aop_joinpoint *jp, int param_index)
 {
   struct aop_dynval *dv;
   dv = ggc_alloc (sizeof (struct aop_dynval));
@@ -205,6 +227,7 @@ aop_capture_param (struct aop_joinpoint *jp)
   dv->type = aop_t_all_unsigned ();
   dv->jp = jp;
   dv->get_dynval = op_get_param;
+  dv->dynval_call.param_id = param_index;
   return dv;
 }
 
index 2433abf700601ab2688bfa122d28a3ae6c822c7a..7ef268e2240a486852c794cc0ebcaadb83fc4a03 100644 (file)
@@ -42,13 +42,21 @@ struct aop_pc_entry {
   const char *function_name;
 };
 
+struct aop_param_desc;
+
+struct aop_param_desc {
+  int param_id;
+  struct aop_param_desc * next;  
+};
+
+
 struct aop_pc_fun_call {
   const char *function_name;
   int param_id;  
+  struct aop_param_desc *param_list_head; 
 };
 
 /* An AOP pointcut represents the a set of joinponts: locations in the
->>>>>>> Stashed changes:src/aop-pointcut.h
    source code that are available for inserting instrumentation.
 
    In practice, we do not directly store the set of joinpoints.
@@ -59,7 +67,8 @@ struct aop_pointcut {
 
   void (*join_on) (struct aop_pointcut *, join_callback, void *);
   insert_callback insert_before;
-
+  insert_callback insert_after;
+  
   union {
     struct aop_pc_assign pc_assign;
     struct aop_pc_entry pc_entry;
@@ -84,5 +93,6 @@ struct aop_joinpoint {
 };
 
 void op_default_insert_before (struct aop_joinpoint *jp, gimple stmt);
+void op_default_insert_after (struct aop_joinpoint *jp, gimple stmt);
 
 #endif
index 22b42bc01d4799053c1746240ffa35b55afb7aea..17dd716ab3ac70dc38b981c4ce04804c32d36c06 100644 (file)
@@ -146,17 +146,38 @@ op_default_insert_before (struct aop_joinpoint *jp, gimple stmt)
   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);
+}
+
 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, func_name);
+  va_start (argp, location);
   func_call = build_gcc_call (func_name, void_type_node, argp);
   va_end (argp);
 
   pc = jp->pc;
-  pc->insert_before(jp, func_call);
+  if(location == AOP_INSERT_BEFORE)
+  {
+    pc->insert_before(jp, func_call);
+  }
+  else if(location == AOP_INSERT_AFTER)
+  {
+    pc->insert_after(jp, func_call);
+  }
 }
index cfa5b2297254a6fb1e2e01e2123f19fc9ba63351..ad067d339e0bf5c4038e349d02c5b77d2726bdb5 100644 (file)
--- a/src/aop.h
+++ b/src/aop.h
@@ -63,7 +63,12 @@ extern void aop_filter_exclude_temps (struct aop_pointcut *pc);
 
 extern const char *aop_capture_lhs_name (struct aop_joinpoint *jp);
 
-extern void aop_insert_advice (struct aop_joinpoint *jp, const char *name, ...);
+enum aop_insert_location {
+  AOP_INSERT_BEFORE,
+  AOP_INSERT_AFTER
+};
+
+extern void aop_insert_advice (struct aop_joinpoint *jp, const char *name,enum  aop_insert_location location, ...);
 
 extern const struct aop_type *aop_t_all_signed ();
 extern const struct aop_type *aop_t_all_unsigned ();
@@ -109,5 +114,6 @@ struct aop_dynval *
 aop_capture_return_value (struct aop_joinpoint *jp);
 
 struct aop_dynval *
-aop_capture_param (struct aop_joinpoint *jp);
+aop_capture_param (struct aop_joinpoint *jp, int param_index);
+
 #endif