Added aop_capture_exit_return_value_by_type().
authorJustin Seyster <jseyster@cs.sunysb.edu>
Thu, 21 Oct 2010 03:17:10 +0000 (23:17 -0400)
committerJustin Seyster <jseyster@cs.sunysb.edu>
Thu, 21 Oct 2010 03:17:10 +0000 (23:17 -0400)
src/aop-pc-exit.c
src/aop.h

index cc78f028c12f70912f867be84e7b5f3c46d36dea..856577a2f3a1e2fd0c7396839d43897466c31913 100644 (file)
@@ -261,6 +261,42 @@ aop_capture_exit_return_value (struct aop_joinpoint *jp)
   return dv;
 }
 
+/**
+ * Get a dynval representing the value returned at a function exit
+ * join point if the function's return value matches the specified
+ * type.  This function makes it possible to capture the return value
+ * from an exit join point even if you have not filtered it with
+ * aop_filter_exit_by_return_type().  However, it returns NULL if the
+ * return value does not match the specified type.
+ * \param jp A function exit join point.  Function exit join points
+ * are obtained by joining on an aop_match_function_exit() pointcut.
+ * \param type A dynval with its type determined by the specified type
+ * or NULL if the return value does not match the specified type.
+ */
+struct aop_dynval *
+aop_capture_exit_return_value_by_type (struct aop_joinpoint *jp,
+                                      const struct aop_type *type)
+{
+  struct aop_pointcut *pc;
+  struct aop_dynval *dv;
+
+  pc = jp->pc;
+  if (pc->kind != ATP_EXIT)
+    fatal_error ("(InterAspect) Attempt to capture return value from an"
+                " unsupported join point.");
+
+  /* Does this join points match the specified type? */
+  if (!return_type_matches (type))
+    return NULL;
+
+  dv = ggc_alloc (sizeof (struct aop_dynval));
+  dv->kind = ADV_EXIT_RETVAL;
+  dv->type = type;
+  dv->jp = jp;
+  dv->get_dynval = op_get_exit_return_value;
+  return dv;
+}
+
 /* Close Doxygen defgroup block. */
 /**
  * \}
index 411e3c33654b206e52dd26d4f336774277fa078a..84e4fe52ec00a079cecef8aacab4280e2e066dab 100644 (file)
--- a/src/aop.h
+++ b/src/aop.h
@@ -338,8 +338,10 @@ extern void aop_filter_entry_by_name(struct aop_pointcut *pc_function_entry,
 extern struct aop_pointcut *aop_match_function_exit ();
 extern void aop_filter_exit_by_return_type (struct aop_pointcut *pc,
                                            const struct aop_type *type);
-struct aop_dynval *aop_capture_exit_return_value (struct aop_joinpoint *jp);
-
+extern struct aop_dynval *aop_capture_exit_return_value (
+  struct aop_joinpoint *jp);
+extern struct aop_dynval *aop_capture_exit_return_value_by_type (
+  struct aop_joinpoint *jp, const struct aop_type *type);
 
 extern struct aop_pointcut *aop_match_function_call ();