Added the testcase for tc_declare_call_symbol.
authorSiddhi Tadpatrikar <siddhi@agora.fsl.cs.sunysb.edu>
Fri, 1 Apr 2011 18:39:31 +0000 (14:39 -0400)
committerSiddhi Tadpatrikar <siddhi@agora.fsl.cs.sunysb.edu>
Fri, 1 Apr 2011 19:10:02 +0000 (15:10 -0400)
test/plugin-declare.c [new file with mode: 0644]
test/tracecut-hooks.c
test/tracecut-target.c
test/tracecut.xml

diff --git a/test/plugin-declare.c b/test/plugin-declare.c
new file mode 100644 (file)
index 0000000..f6081ae
--- /dev/null
@@ -0,0 +1,127 @@
+#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);
+}
index 46b75f070018ae288b1dd6a507d51572663b0d1b..96c90853e57f0d8b5e3b1a140a7c437b63631795 100644 (file)
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <stdint.h>
 
 void _tc_init(int num_tracecuts)
 {
@@ -35,6 +36,21 @@ void _tc_capture_pointer_param(int tc, int symbol, int param_index, void *param_
   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);
index 9c76dfa0b39b61dc2056ca3fea313bd8bd0aaa4e..12f539f81a207b9f2c29870067d5c90fc9162083 100644 (file)
@@ -42,11 +42,40 @@ void transfer(struct foo *foo, struct bar *bar)
 {
 }
 
+void inc_int(int int_val)
+{
+}
+
+void dec_int(int int_val)
+{
+}
+
+void inc_uint(unsigned uint_val)
+{
+}
+
+void dec_uint(unsigned uint_val)
+{
+}
+
+void inc_fp(float fp_val)
+{
+}
+
+void dec_fp(int fp_val)
+{
+}
+
+
 void run_test()
 {
   struct foo *foo;
   struct bar *bar;
 
+  int      int_val = 10;
+  unsigned uint_val = 10;
+  float    fp_val = 10.0;
+  
   foo = get_foo();
   bar = get_bar();
 
@@ -56,4 +85,13 @@ void run_test()
   half_bar(bar);
 
   transfer(foo, bar);
+  
+  inc_int(int_val);
+  dec_int(int_val);
+
+  inc_uint(uint_val);
+  dec_uint(uint_val);
+  
+  inc_fp(fp_val);
+  dec_fp(fp_val);
 }
index 072e7a31b434a3302146389d30b72969d6b132ec..4f3231c88b9d7e26f6b70a3b5e401060d943af32 100644 (file)
       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>