From: Ketan Dixit Date: Fri, 21 May 2010 02:33:36 +0000 (-0400) Subject: Merge branch 'master' of ssh://ketand@git.fsl.cs.sunysb.edu/home/fslgit/interaspect X-Git-Tag: release-v1.0~105 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=e5743a20e65ab10b435771286ef0d9f2234af386;p=interaspect.git Merge branch 'master' of ssh://ketand@git.fsl.cs.sunysb.edu/home/fslgit/interaspect Conflicts: src/aop-dynval.h src/aop-pointcut.h src/aop-weave.c --- e5743a20e65ab10b435771286ef0d9f2234af386 diff --cc src/aop-dynval.h index 7be303b,b63bc0e..d1a0fd3 --- a/src/aop-dynval.h +++ b/src/aop-dynval.h @@@ -23,14 -23,9 +23,15 @@@ struct aop_type enum aop_dvkind { ADV_LHS_ADDR, + ADV_FUN_PARAM, - ADV_FUN_RETVAL ++ 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 @@@ -38,13 -33,9 +39,12 @@@ 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 diff --cc src/aop-pointcut.h index 7ef268e,d462ec4..3c96036 --- a/src/aop-pointcut.h +++ b/src/aop-pointcut.h @@@ -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 17dd716,2d02e4c..f5465b7 --- a/src/aop-weave.c +++ b/src/aop-weave.c @@@ -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; + + /* Make sure this joinpoint is prepared for advice. */ + if (!jp->is_prepared) + { + pc->prepare_for_weave (jp); + jp->is_prepared = true; + } + - 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); + 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 ad067d3,cae23b3..150182d --- a/src/aop.h +++ 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