--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
+ reinst.xml noinstrument.xml duplicate.xml inparam.xml constants.xml
endif
--- /dev/null
+#include <stdint.h>
+#include <stdio.h>
+
+void _foo_advice(const char *str1, int32_t int1, double double1, void *voidp1, const char *str2)
+{
+ printf("In advice: %s, %d, %f, %p, %s\n", str1, int1, double1, voidp1, str2);
+}
--- /dev/null
+#include <stdio.h>
+
+static void foo()
+{
+ printf("In foo\n");
+}
+
+void run_test()
+{
+ foo();
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE testcase SYSTEM "testcase.dtd">
+<testcase name="Constants">
+ <plugin id="plugin-constants" source="plugin-constants.c" />
+ <run name="Passing constants to advice" target="constants-target.c" hooks="constants-hooks.c">
+ <using plugin="plugin-constants" />
+ <output>
+ In advice: dead, 10, 2.500000, 0xdeadbeef, beef
+ In foo
+ </output>
+ <prototypes>
+ void _foo_advice(signed char *, int32_t, double, ALL_POINTER_T, signed char *);
+ </prototypes>
+ </run>
+</testcase>
--- /dev/null
+#include <aop.h>
+#include <stdio.h>
+
+AOP_I_AM_GPL_COMPATIBLE();
+
+static void plugin_join_on_entry(struct aop_joinpoint *jp, void *data)
+{
+ double blah = 2.5;
+ aop_insert_advice(jp, "_foo_advice", AOP_INSERT_BEFORE, AOP_STR_CST("dead"), AOP_INT_CST(10),
+ AOP_DOUBLE_CST(blah), AOP_VOIDP_CST((void *)0xdeadbeef), AOP_STR_CST("beef"),
+ AOP_TERM_ARG);
+}
+
+static unsigned int plugin_cst()
+{
+ struct aop_pointcut *pc;
+
+ pc = aop_match_function_entry();
+ aop_filter_entry_by_name(pc, "foo");
+ aop_join_on(pc, plugin_join_on_entry, NULL);
+
+ 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, "_INT_HEADER_", NULL, NULL);
+ if (res != 0)
+ perror(header);
+ }
+}
+
+AOP_MAIN_PROTO aop_main()
+{
+ aop_register_pass("cst", plugin_cst);
+}