bzip bug fix with prepare_for_weave changes
authorKetan Dixit <ketan.dixit@gmail.com>
Mon, 24 May 2010 19:19:05 +0000 (15:19 -0400)
committerKetan Dixit <ketan.dixit@gmail.com>
Mon, 24 May 2010 19:19:05 +0000 (15:19 -0400)
src/aop-pc-entry.c
src/aop-pc-exit.c
src/aop-pc-fun-call.c

index 95129c8fa200f25cf818a10865990d69b96efe72..4d22e68ac19d7b631ef326cc7044c03e128b7c5e 100644 (file)
@@ -45,10 +45,10 @@ op_join_on_function_entry (struct aop_pointcut *pc, join_callback cb,
   basic_block bb;
   aop_assert (pc->kind == ATP_ENTRY);
 
-  if(pc->pc_entry.function_name!= NULL)
+  if(pc->pc_entry.function_name != NULL)
     {   
-      if (strcmp(IDENTIFIER_POINTER (DECL_NAME (current_function_decl))
-                ,pc->pc_entry.function_name)!=0)
+      if (strcmp( IDENTIFIER_POINTER (DECL_NAME (current_function_decl))
+                 ,pc->pc_entry.function_name)!=0)
        {
          fprintf(stderr,"%s function does not match the pointcut specifier",
                  pc->pc_entry.function_name);
@@ -60,11 +60,12 @@ op_join_on_function_entry (struct aop_pointcut *pc, join_callback cb,
     {
       gimple_stmt_iterator gsi;
 
-      for (gsi = gsi_start_bb (bb) ; !gsi_end_p (gsi) ; gsi_next (&gsi))
+      for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
        {
          struct aop_joinpoint jp;
          jp.pc = pc;
          jp.gsi = &gsi;
+         jp.is_prepared = false;
          cb (&jp, callback_param);
          return;
        }
@@ -75,18 +76,17 @@ struct aop_pointcut *
 aop_match_function_entry ()
 {
   struct aop_pointcut *pc;
-
   pc = ggc_alloc (sizeof (struct aop_pointcut));
   pc->kind = ATP_ENTRY;
   pc->join_on = op_join_on_function_entry;
   pc->insert_before = op_default_insert_before;
-
+  pc->prepare_for_weave = op_default_prepare_for_weave;
   return pc;
 }
 
 void aop_filter_function_entry_pointcut(struct aop_pointcut *pc_function_entry,
                                        const char *advice_function_entry)
 {
-  pc_function_entry->pc_entry.function_name=advice_function_entry;
+  pc_function_entry->pc_entry.function_name = advice_function_entry;
 }
 
index ac762776654f424bf40e27be918ccb4acd9771f8..3dbe43b717c3efc0f45048d3853087c17c9fcaf7 100644 (file)
@@ -44,7 +44,7 @@ op_join_on_function_exit (struct aop_pointcut *pc, join_callback cb,
   basic_block bb;
   gimple stmt;
   aop_assert (pc->kind == ATP_EXIT);
-
+  
   FOR_EACH_BB(bb)
     {
       gimple_stmt_iterator gsi;
@@ -57,6 +57,7 @@ op_join_on_function_exit (struct aop_pointcut *pc, join_callback cb,
              struct aop_joinpoint jp;
              jp.pc = pc;
              jp.gsi = &gsi;
+             jp.is_prepared = false;
              cb (&jp, callback_param);
            }
        }
@@ -66,12 +67,11 @@ op_join_on_function_exit (struct aop_pointcut *pc, join_callback cb,
 struct aop_pointcut *
 aop_match_function_exit ()
 {
-  struct aop_pointcut *pc;
-  
+  struct aop_pointcut *pc;  
   pc = ggc_alloc (sizeof (struct aop_pointcut));
   pc->kind = ATP_EXIT;
   pc->join_on = op_join_on_function_exit;
   pc->insert_before = op_default_insert_before;
-  
+  pc->prepare_for_weave = op_default_prepare_for_weave;
   return pc;
 }
index ef3961787a93ccb31f1f6f0e12ac1b6cdbba9f36..5f7d70777078b2601c3ac4623e1f03662e1455d5 100644 (file)
@@ -39,7 +39,7 @@
 #include "aop-type.h"
 #include "aop-dynval.h"
 
-
+//123456789012345678901234567890123456789012345678901234567890123456789012345678
 static void
 op_join_on_function_call (struct aop_pointcut *pc, join_callback cb,
                           void *callback_param)
@@ -55,41 +55,42 @@ op_join_on_function_call (struct aop_pointcut *pc, join_callback cb,
 
   FOR_EACH_BB(my_basic_block)
   {
-    for (gsi = gsi_start_bb (my_basic_block);
-         !gsi_end_p (gsi);
-         gsi_next (&gsi)) 
+    for (gsi = gsi_start_bb (my_basic_block) ; !gsi_end_p (gsi) ;
+        gsi_next (&gsi)) 
       {
        gimple my_statement = gsi_stmt (gsi);
 
-       /* At this stage, there should be no GIMPLE statements with sub-statements. */
+       /* At this stage, there should be no GIMPLE 
+          statements with sub-statements. */
        gcc_assert(!gimple_has_substatements (my_statement));
 
        if (gimple_code (my_statement) == GIMPLE_CALL)
          {
-           func = gimple_call_fn(my_statement);
+           func = gimple_call_fn (my_statement);
            
-           if (TREE_CODE(func) != ADDR_EXPR)
+           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");
+               /* This is a call to a function pointer. 
+                  Don't worry about it. */
                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);
+               int num_args = gimple_call_num_args (my_statement);
+               
                struct aop_param_desc *iter = NULL;     
                if(pc->pc_call.param_list_head != NULL ) {
-                       iter =  pc->pc_call.param_list_head;
+                 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; 
+                         iter = iter->next;    
+                          
+                          if(iter->param_id > num_args - 1 ||
+                             iter->param_id < 0) {
+                            return; 
                           }                       
                        }                       
                }   
@@ -97,8 +98,8 @@ op_join_on_function_call (struct aop_pointcut *pc, join_callback cb,
                struct aop_joinpoint jp;
                jp.pc = pc;
                jp.gsi = &gsi;
+               jp.is_prepared = false;
                cb (&jp, callback_param);               
-               fprintf (stderr,"Function call to %s captured...\n",pc->pc_call.function_name);
              }
          }
 
@@ -115,6 +116,8 @@ aop_match_function_call ()
   pc->kind = ATP_CALL;
   pc->join_on = op_join_on_function_call;
   pc->insert_after = op_default_insert_after;
+  pc->insert_before = op_default_insert_before;
+  pc->prepare_for_weave = op_default_prepare_for_weave;
   /*
        Initialize the list to NULL
   */
@@ -122,36 +125,35 @@ aop_match_function_call ()
   return pc;
 }
 
-void aop_filter_function_call_pointcut(struct aop_pointcut *pc_function_call,
+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;
+  pc_function_call->pc_call.function_name = advice_function_call;
 }
 
-void aop_add_param_descriptor(struct aop_pointcut *pc,int param_id)
+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;
+   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;
+     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;      
+     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)
 {
-  aop_add_param_descriptor(pc,param_id);
+  aop_add_param_descriptor (pc, param_id);
 }
 
 
@@ -174,17 +176,17 @@ op_get_return_value (struct aop_dynval *dv)
      we can grab its return value. */
   if (gimple_call_lhs(stmt) == NULL)
     {
-      fprintf(stderr,"call_lhs is NULL\n");
       /*
-      tree new_lhs = create_tmp_var(gimple_call_return_type(stmt), "aop_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); 
       */
     }
-  return_value = stabilize_reference(gimple_call_lhs(stmt));
-  debug_gimple_stmt(stmt);
+  return_value = stabilize_reference (gimple_call_lhs (stmt));
+  debug_gimple_stmt (stmt);
   return return_value;
  
 }
@@ -208,12 +210,11 @@ op_get_param (struct aop_dynval *dv)
   gimple stmt;
   tree param;
   struct aop_joinpoint *jp = dv->jp;
-
   aop_assert (dv->kind == ADV_FUN_PARAM);
   aop_assert (jp->pc->kind == ATP_CALL);
   stmt = gsi_stmt (*(jp->gsi));
 
-  param = stabilize_reference(gimple_call_arg(stmt, dv->dynval_call.param_id));
+  param = stabilize_reference (gimple_call_arg (stmt, dv->dynval_call.param_id));
   return param;
 }