Added support for including aop_dynval objects in advice calls.
authorJustin Seyster <jseyster@cs.sunysb.edu>
Thu, 1 Apr 2010 20:21:56 +0000 (16:21 -0400)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Thu, 1 Apr 2010 20:26:25 +0000 (16:26 -0400)
src/aop-callback.h [new file with mode: 0644]
src/aop-dynval.h [new file with mode: 0644]
src/aop-weave.c

diff --git a/src/aop-callback.h b/src/aop-callback.h
new file mode 100644 (file)
index 0000000..af9da82
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef __AOP_CALLBACK_H__
+#define __AOP_CALLBACK_H__
+
+/* This program is free software: you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation, either version 3 of the
+   License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/* This is a private header.  Do not include it in source files for
+   client plug-ins. */
+
+/* Insert callbacks take a joinpoint and insert a gimple statement at
+   that joinpoint.  Insert callbacks must maintain the order
+   invariant: statements occur at the joinpoint in the order they were
+   inserted. */
+struct aop_joinpoint;
+typedef void (*insert_callback)(struct aop_joinpoint *, gimple);
+
+#endif
diff --git a/src/aop-dynval.h b/src/aop-dynval.h
new file mode 100644 (file)
index 0000000..0af81f1
--- /dev/null
@@ -0,0 +1,47 @@
+#ifndef __AOP_DYNVAL_H__
+#define __AOP_DYNVAL_H__
+
+/* This program is free software: you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation, either version 3 of the
+   License, or (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/* This is a private header.  Do not include it in source files for
+   client plug-ins. */
+
+struct aop_joinpoint;
+struct aop_type;
+
+enum aop_dvkind {
+  ADV_LHS_ADDR,
+};
+
+/* An aop-dynval represents a dynamic value in the target program that
+   can be passed to an advice function.  AOP weaving functions (such
+   as aop_insert_advice()) use a dynval to create instrumentation that
+   extract the dynamic value at run time. */
+struct aop_dynval
+{
+  enum aop_dvkind kind;
+
+  const struct aop_type *type;
+  struct aop_joinpoint *jp;
+
+  /* Ops vector for aop_dynval. */
+  /* The get_dynval() op gets called when an advice call gets
+     inserted.  It should add whatever gimple statements are necessary
+     to create a GCC tree object that can be used as an argument to a
+     GIMPLE call and then return that tree. */
+  tree (*get_dynval)(struct aop_dynval *);
+};
+
+#endif
index a883a80ad54632dd9c7ea7430885c7be6327c366..550a5d4892c60677dbf710deef45cc116ad325bb 100644 (file)
@@ -33,6 +33,7 @@
 #include <gimple.h>
 
 #include "aop.h"
+#include "aop-dynval.h"
 #include "aop-pointcut.h"
 
 static tree
@@ -64,6 +65,12 @@ build_string_ptr (const char *string)
   return ret;
 }
 
+static tree
+build_dynval (struct aop_dynval *dv)
+{
+  return dv->get_dynval (dv);
+}
+
 /* Weaving functions all take varags parameters that represent the
    arguments to pass to the new advice function.  This function
    iterates through those arguments and creates GIMPLE tree nodes for
@@ -88,6 +95,7 @@ build_gcc_call (const char *func_name, tree return_type, va_list argp)
     {
       tree new_arg;
       const char *str_cst;
+      struct aop_dynval *dv;
 
       switch (kind)
        {
@@ -96,6 +104,11 @@ build_gcc_call (const char *func_name, tree return_type, va_list argp)
          new_arg = build_string_ptr (str_cst);
          VEC_safe_push (tree, heap, arg_list, new_arg);
          break;
+       case ATA_DYNVAL:
+         dv = va_arg (argp, struct aop_dynval *);
+         new_arg = build_dynval (dv);
+         VEC_safe_push (tree, heap, arg_list, new_arg);
+         break;
        default:
          aop_assert (0);
        }