From: Justin Seyster Date: Thu, 1 Apr 2010 20:21:56 +0000 (-0400) Subject: Added support for including aop_dynval objects in advice calls. X-Git-Tag: release-v1.0~112 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=11a61437e509c62a15a0041d7efac7b772ec4d07;p=interaspect.git Added support for including aop_dynval objects in advice calls. --- diff --git a/src/aop-callback.h b/src/aop-callback.h new file mode 100644 index 0000000..af9da82 --- /dev/null +++ b/src/aop-callback.h @@ -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 . +*/ + +/* 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 index 0000000..0af81f1 --- /dev/null +++ b/src/aop-dynval.h @@ -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 . +*/ + +/* 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 diff --git a/src/aop-weave.c b/src/aop-weave.c index a883a80..550a5d4 100644 --- a/src/aop-weave.c +++ b/src/aop-weave.c @@ -33,6 +33,7 @@ #include #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); }