--- /dev/null
+#include <stdint.h>
+#include <stdio.h>
+
+void _advice_assign(int32_t a, double b)
+{
+ printf("Assign advice: (%d, %f)\n", (int)a, b);
+}
+
+void _advice_printf(int32_t a, double b)
+{
+ printf("printf advice: (%d, %f)\n", (int)a, b);
+}
+
+void _advice_exit(int32_t a, double b)
+{
+ printf("Exit advice: (%d, %f)\n", (int)a, b);
+}
--- /dev/null
+#include <stdint.h>
+#include <stdio.h>
+
+void foo(int a, double b)
+{
+ a = a + (int)b;
+ printf("In foo: (%d, %f)\n", a, b);
+}
+
+/* Nothing in this function should get instrumented by
+ plugin-inparam-allpc because its parameters don't match the filter
+ parameters. */
+void bar(int a, int b)
+{
+ a = a + (int)b;
+ printf("In foo: (%d, %f)\n", a, (double)b);
+}
+
+void run_test()
+{
+ foo(12, 1.2);
+ bar(34, 3.4);
+}
<!DOCTYPE testcase SYSTEM "testcase.dtd">
<testcase name="In params">
<plugin id="plugin-inparam" source="plugin-inparam.c" />
+ <plugin id="plugin-allpc-inparam" source="plugin-allpc-inparam.c" />
<run name="Entry parameter capture" target="inparam-target.c" hooks="inparam-hooks.c">
<using plugin="plugin-inparam" />
<output>
void _advice_foo(ALL_SIGNED_T, ALL_FP_T);
</prototypes>
</run>
+ <run name="Entry parameter capture" target="allpc-inparam-target.c" hooks="allpc-inparam-hooks.c">
+ <using plugin="plugin-allpc-inparam" />
+ <output>
+ Assign advice: (12, 1.200000)
+ printf advice: (12, 1.200000)
+ In foo: (13, 1.200000)
+ Exit advice: (12, 1.200000)
+ In foo: (37, 3.000000)
+ </output>
+ <prototypes>
+ void _advice_assign(ALL_SIGNED_T, double);
+ void _advice_exit(ALL_SIGNED_T, double);
+ void _advice_printf(ALL_SIGNED_T, double);
+ </prototypes>
+ </run>
</testcase>
--- /dev/null
+#include <aop.h>
+#include <stdio.h>
+#include <string.h>
+
+AOP_I_AM_GPL_COMPATIBLE();
+
+static void plugin_join(struct aop_joinpoint *jp, void *data)
+{
+ const char *advice_name = data;
+ struct aop_dynval *p1;
+ struct aop_dynval *p2;
+
+ p1 = aop_capture_in_param(jp, 0);
+ p2 = aop_capture_in_param(jp, 1);
+ aop_insert_advice(jp, advice_name, AOP_INSERT_BEFORE, AOP_DYNVAL(p1), AOP_DYNVAL(p2), AOP_TERM_ARG);
+}
+
+static unsigned int plugin_int()
+{
+ struct aop_pointcut *pc;
+
+ pc = aop_match_assignment_by_type(aop_t_all_signed());
+ aop_filter_by_in_param(pc, 0, aop_t_all_signed());
+ aop_filter_by_in_param(pc, 1, aop_t_float64());
+ aop_join_on(pc, plugin_join, "_advice_assign");
+
+ pc = aop_match_function_call();
+ aop_filter_call_pc_by_name(pc, "printf");
+ aop_filter_by_in_param(pc, 0, aop_t_all_signed());
+ aop_filter_by_in_param(pc, 1, aop_t_float64());
+ aop_join_on(pc, plugin_join, "_advice_printf");
+
+ pc = aop_match_function_exit();
+ aop_filter_by_in_param(pc, 0, aop_t_all_signed());
+ aop_filter_by_in_param(pc, 1, aop_t_float64());
+ aop_join_on(pc, plugin_join, "_advice_exit");
+
+ return 0;
+}
+
+void aop_finish()
+{
+ const char *header;
+ header = aop_get_arg_value("header");
+
+ if (header != NULL) {
+ int res;
+ res = aop_write_c_header(header, NULL, NULL, NULL);
+ if (res != 0)
+ perror(header);
+ }
+}
+
+AOP_MAIN_PROTO aop_main()
+{
+ aop_register_pass("int", plugin_int);
+}