From: Ketan Dixit Date: Fri, 21 May 2010 01:10:22 +0000 (-0400) Subject: Fixed the bugs for compilation with Bzip X-Git-Tag: release-v1.0~106 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=9e56cfc725670780f3ffbf9dce832c47e8de636d;p=interaspect.git Fixed the bugs for compilation with Bzip --- diff --git a/src/aop-dynval.h b/src/aop-dynval.h index 9edf7d7..7be303b 100644 --- a/src/aop-dynval.h +++ b/src/aop-dynval.h @@ -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 diff --git a/src/aop-main.c b/src/aop-main.c index b379c06..4cd0a33 100644 --- a/src/aop-main.c +++ b/src/aop-main.c @@ -53,7 +53,6 @@ #include "aop.h" #include "aop-pointcut.h" -#define PAUSE_ON_START static const char *aop_plugin_name; diff --git a/src/aop-pc-fun-call.c b/src/aop-pc-fun-call.c index d4d8e73..ef39617 100644 --- a/src/aop-pc-fun-call.c +++ b/src/aop-pc-fun-call.c @@ -22,7 +22,6 @@ #undef PACKAGE_VERSION #include - #include #include #include @@ -31,8 +30,10 @@ #include #include #include +#include #include + #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; } diff --git a/src/aop-pointcut.h b/src/aop-pointcut.h index 2433abf..7ef268e 100644 --- a/src/aop-pointcut.h +++ b/src/aop-pointcut.h @@ -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 diff --git a/src/aop-weave.c b/src/aop-weave.c index 22b42bc..17dd716 100644 --- a/src/aop-weave.c +++ b/src/aop-weave.c @@ -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); + } } diff --git a/src/aop.h b/src/aop.h index cfa5b22..ad067d3 100644 --- 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