--with-ia-lib-dir=$(top_builddir)/src/.libs \
--with-ia-src-dir=$(top_srcdir) --with-tests-dir=$(srcdir)
TESTS = int-types.xml float-types.xml pointer-types.xml struct-types.xml \
- reinst.xml noinstrument.xml duplicate.xml inparam.xml constants.xml
+ reinst.xml noinstrument.xml duplicate.xml inparam.xml constants.xml \
+ return.xml
endif
--- /dev/null
+#include <aop.h>
+#include <stdio.h>
+
+AOP_I_AM_GPL_COMPATIBLE();
+
+static void plugin_join_on_float_exit(struct aop_joinpoint *jp, void *data)
+{
+ struct aop_dynval *retval = aop_capture_exit_return_value(jp);
+ aop_insert_advice(jp, "_float_advice", AOP_INSERT_BEFORE, AOP_DYNVAL(retval), AOP_TERM_ARG);
+}
+
+static void plugin_join_on_string_exit(struct aop_joinpoint *jp, void *data)
+{
+ const struct aop_type *char_star;
+ struct aop_dynval *retval;
+
+ char_star = aop_t_pointer_to(aop_t_signed8());
+
+ retval = aop_capture_exit_return_value_by_type(jp, char_star);
+ if (retval != NULL)
+ aop_insert_advice(jp, "_string_advice", AOP_INSERT_BEFORE, AOP_DYNVAL(retval), AOP_TERM_ARG);
+}
+
+static unsigned int plugin_return()
+{
+ struct aop_pointcut *pc;
+
+ pc = aop_match_function_exit();
+ aop_filter_exit_by_return_type(pc, aop_t_all_fp());
+ aop_join_on(pc, plugin_join_on_float_exit, NULL);
+
+ pc = aop_match_function_exit();
+ /* Do the filtering inside the join iterator instead. */
+ /* aop_filter_exit_by_return_type(pc, char_star); */
+ aop_join_on(pc, plugin_join_on_string_exit, NULL);
+
+ return 0;
+}
+
+AOP_MAIN_PROTO aop_main()
+{
+ aop_register_pass("return", plugin_return);
+}
--- /dev/null
+#include <stdio.h>
+
+void _string_advice(const char *str)
+{
+ printf("In string advice: %s\n", str);
+}
+
+void _float_advice(double num)
+{
+ printf("In float advice: %f\n", num);
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE testcase SYSTEM "testcase.dtd">
+<testcase name="Return Values">
+ <plugin id="plugin-return" source="plugin-return.c" />
+ <run name="Capturing return value from exit join point" target="return-target.c" hooks="return-hooks.c">
+ <using plugin="plugin-return" />
+ <output>
+ In float advice: 1.200000
+ In string advice: bro
+ Don't tase me, bro. 1.200000
+ </output>
+ </run>
+</testcase>