--- /dev/null
+#include <aop.h>
+#include <tracecut.h>
+#include <stddef.h>
+
+AOP_I_AM_GPL_COMPATIBLE();
+
+static struct tc_tracecut *tc_foo;
+static struct tc_tracecut *tc_bar;
+static struct tc_tracecut *tc_both;
+static struct tc_tracecut *tc_int;
+static struct tc_tracecut *tc_uint;
+static struct tc_tracecut *tc_fp;
+
+static void join_on_main(struct aop_joinpoint *jp, void *data)
+{
+ tc_insert_tracecut_init_advice(jp);
+}
+
+static unsigned int init_pass()
+{
+ struct aop_pointcut *pc;
+
+ pc = aop_match_function_entry();
+ aop_filter_entry_by_name(pc, "main");
+ aop_join_on(pc, join_on_main, NULL);
+
+ return 0;
+}
+
+#include <stdio.h>
+
+AOP_MAIN_PROTO aop_main()
+{
+ enum tc_error tcerr;
+
+ /* Tracecut for foo objects. */
+ tc_foo = tc_create_tracecut();
+
+ tc_add_param(tc_foo, "foo", aop_t_struct_ptr("foo"));
+
+ tcerr = tc_declare_call_symbol(tc_foo, "get", "(foo) get_foo()", AOP_INSERT_AFTER);
+
+ tcerr = tc_declare_call_symbol(tc_foo, "inc", "inc_foo(foo)", AOP_INSERT_AFTER);
+
+ tcerr = tc_declare_call_symbol(tc_foo, "dec", "dec_foo(foo)", AOP_INSERT_AFTER);
+
+ tc_add_rule(tc_foo, "inc* dec");
+
+ aop_assert(tc_error_code(tc_foo) == TC_SUCCESS);
+
+ /* Tracecut for bar objects. */
+ tc_bar = tc_create_tracecut();
+
+ tc_add_param(tc_bar, "bar", aop_t_struct_ptr("bar"));
+
+ tcerr = tc_declare_call_symbol(tc_bar, "get", "get_bar(bar)", AOP_INSERT_AFTER);
+
+ tcerr = tc_declare_call_symbol(tc_bar, "double", "double_bar(bar)", AOP_INSERT_AFTER);
+
+ tcerr = tc_declare_call_symbol(tc_bar, "half", "half_bar(bar)", AOP_INSERT_AFTER);
+
+ tc_add_rule(tc_bar, "get double* half");
+
+ aop_assert(tc_error_code(tc_bar) == TC_SUCCESS);
+
+ /* Tracecut for both objects. */
+ tc_both = tc_create_tracecut();
+
+ tc_add_param(tc_both, "foo", aop_t_struct_ptr("foo"));
+ tc_add_param(tc_both, "bar", aop_t_struct_ptr("bar"));
+
+ tcerr = tc_declare_call_symbol(tc_both, "transfer", "transfer(foo, bar)", AOP_INSERT_AFTER);
+
+ tc_add_rule(tc_both, "transfer transfer");
+
+ aop_assert(tc_error_code(tc_both) == TC_SUCCESS);
+
+ /* Tracecut for signed int objects. */
+ tc_int = tc_create_tracecut();
+
+ tcerr = tc_add_param(tc_int, "int_val", aop_t_signed32());
+
+ tcerr = tc_declare_call_symbol(tc_int, "inc_int", "inc_int(int_val)", AOP_INSERT_AFTER);
+
+ tcerr = tc_declare_call_symbol(tc_int, "dec_int", "dec_int(int_val)", AOP_INSERT_AFTER);
+
+ tcerr = tc_add_rule(tc_int, "inc_int* dec_int");
+
+ aop_assert(tc_error_code(tc_int) == TC_SUCCESS);
+
+ /* Tracecut for unsigned int objects. */
+ tc_uint = tc_create_tracecut();
+
+ tcerr = tc_add_param(tc_uint, "uint_val", aop_t_unsigned32());
+
+ tcerr = tc_declare_call_symbol(tc_uint, "inc_uint", "inc_uint(uint_val)", AOP_INSERT_AFTER);
+
+ tcerr = tc_declare_call_symbol(tc_uint, "dec_uint", "dec_uint(uint_val)", AOP_INSERT_AFTER);
+
+ tcerr = tc_add_rule(tc_uint, "inc_uint* dec_uint");
+
+ aop_assert(tc_error_code(tc_uint) == TC_SUCCESS);
+
+ /* Tracecut for float objects. */
+ tc_fp = tc_create_tracecut();
+
+ tcerr = tc_add_param(tc_fp, "fp_val", aop_t_float32());
+ aop_assert (tcerr == TC_SUCCESS);
+
+ tcerr = tc_declare_call_symbol(tc_fp, "inc_fp", "inc_fp(fp_val)", AOP_INSERT_AFTER);
+
+ tcerr = tc_declare_call_symbol(tc_fp, "dec_fp", "dec_fp(fp_val)", AOP_INSERT_AFTER);
+
+ tcerr = tc_add_rule(tc_fp, "inc_fp* dec_fp");
+
+ aop_assert(tc_error_code(tc_fp) == TC_SUCCESS);
+
+ aop_register_pass("init_tracecut", init_pass);
+ tc_register_tracecut_pass();
+}
+
+void aop_finish()
+{
+ tc_free_tracecut(tc_foo);
+ tc_free_tracecut(tc_bar);
+ tc_free_tracecut(tc_both);
+}
#include <stdio.h>
+#include <stdint.h>
void _tc_init(int num_tracecuts)
{
printf("Param -- tc: %d, symbol: %d, param: %d, value: %p\n", tc, symbol, param_index, param_val);
}
+void _tc_capture_signed_int_param (int tc, int symbol, int param_index, int64_t param_val)
+{
+ printf("Param -- tc: %d, symbol: %d, param: %d, value: %ld\n", tc, symbol, param_index, param_val);
+}
+
+void _tc_capture_unsigned_int_param (int tc, int symbol, int param_index, uint64_t param_val)
+{
+ printf("Param -- tc: %d, symbol: %d, param: %d, value: %ld\n", tc, symbol, param_index, param_val);
+}
+
+void _tc_capture_float_param (int tc, int symbol, int param_index, double param_val)
+{
+ printf("Param -- tc: %d, symbol: %d, param: %d, value: %f\n", tc, symbol, param_index, param_val);
+}
+
void _tc_event_transition(int tc, int symbol)
{
printf("Transition event -- tc: %d, symbol: %d\n", tc, symbol);
Transition event -- tc: 0, symbol: 0
</output>
</run>
+ <plugin id="plugin-declare" source="plugin-declare.c" />
+ <run name="Tracecut declare" target="tracecut-target.c" hooks="tracecut-hooks.c">
+ <using plugin="plugin-declare" />
+ <output>
+ Beginning event -- tc: 5
+ Param -- tc: 5, symbol: 0, param: 0, value: 0x8
+ Transition event -- tc: 5, symbol: 0
+ Beginning event -- tc: 5
+ Param -- tc: 5, symbol: 1, param: 0, value: 0x8
+ Transition event -- tc: 5, symbol: 1
+ Beginning event -- tc: 4
+ Param -- tc: 4, symbol: 1, param: 0, value: 0x16
+ Transition event -- tc: 4, symbol: 1
+ Beginning event -- tc: 5
+ Param -- tc: 5, symbol: 2, param: 0, value: 0x8
+ Transition event -- tc: 5, symbol: 2
+ Beginning event -- tc: 4
+ Param -- tc: 4, symbol: 2, param: 0, value: 0x16
+ Transition event -- tc: 4, symbol: 2
+ Beginning event -- tc: 3
+ Param -- tc: 3, symbol: 0, param: 0, value: 0x8
+ Param -- tc: 3, symbol: 0, param: 1, value: 0x16
+ Transition event -- tc: 3, symbol: 0
+ Beginning event -- tc: 2
+ Param -- tc: 2, symbol: 0, param: 0, value: 10
+ Transition event -- tc: 2, symbol: 0
+ Beginning event -- tc: 2
+ Param -- tc: 2, symbol: 1, param: 0, value: 10
+ Transition event -- tc: 2, symbol: 1
+ Beginning event -- tc: 1
+ Param -- tc: 1, symbol: 0, param: 0, value: 10
+ Transition event -- tc: 1, symbol: 0
+ Beginning event -- tc: 1
+ Param -- tc: 1, symbol: 1, param: 0, value: 10
+ Transition event -- tc: 1, symbol: 1
+ Beginning event -- tc: 0
+ Param -- tc: 0, symbol: 0, param: 0, value: 10.000000
+ Transition event -- tc: 0, symbol: 0
+ </output>
+ </run>
</testcase>