From: Justin Seyster Date: Thu, 21 Oct 2010 03:17:10 +0000 (-0400) Subject: Added aop_capture_exit_return_value_by_type(). X-Git-Tag: release-v1.0~24 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=f7954908b13cae6074ce6d3b425ac7b96c63f0b0;p=interaspect.git Added aop_capture_exit_return_value_by_type(). --- diff --git a/src/aop-pc-exit.c b/src/aop-pc-exit.c index cc78f02..856577a 100644 --- a/src/aop-pc-exit.c +++ b/src/aop-pc-exit.c @@ -261,6 +261,42 @@ aop_capture_exit_return_value (struct aop_joinpoint *jp) return dv; } +/** + * Get a dynval representing the value returned at a function exit + * join point if the function's return value matches the specified + * type. This function makes it possible to capture the return value + * from an exit join point even if you have not filtered it with + * aop_filter_exit_by_return_type(). However, it returns NULL if the + * return value does not match the specified type. + * \param jp A function exit join point. Function exit join points + * are obtained by joining on an aop_match_function_exit() pointcut. + * \param type A dynval with its type determined by the specified type + * or NULL if the return value does not match the specified type. + */ +struct aop_dynval * +aop_capture_exit_return_value_by_type (struct aop_joinpoint *jp, + const struct aop_type *type) +{ + struct aop_pointcut *pc; + struct aop_dynval *dv; + + pc = jp->pc; + if (pc->kind != ATP_EXIT) + fatal_error ("(InterAspect) Attempt to capture return value from an" + " unsupported join point."); + + /* Does this join points match the specified type? */ + if (!return_type_matches (type)) + return NULL; + + dv = ggc_alloc (sizeof (struct aop_dynval)); + dv->kind = ADV_EXIT_RETVAL; + dv->type = type; + dv->jp = jp; + dv->get_dynval = op_get_exit_return_value; + return dv; +} + /* Close Doxygen defgroup block. */ /** * \} diff --git a/src/aop.h b/src/aop.h index 411e3c3..84e4fe5 100644 --- a/src/aop.h +++ b/src/aop.h @@ -338,8 +338,10 @@ extern void aop_filter_entry_by_name(struct aop_pointcut *pc_function_entry, extern struct aop_pointcut *aop_match_function_exit (); extern void aop_filter_exit_by_return_type (struct aop_pointcut *pc, const struct aop_type *type); -struct aop_dynval *aop_capture_exit_return_value (struct aop_joinpoint *jp); - +extern struct aop_dynval *aop_capture_exit_return_value ( + struct aop_joinpoint *jp); +extern struct aop_dynval *aop_capture_exit_return_value_by_type ( + struct aop_joinpoint *jp, const struct aop_type *type); extern struct aop_pointcut *aop_match_function_call ();