#include "aop-pointcut.h"
#include "aop-type.h"
-
static void
op_join_on_function_entry (struct aop_pointcut *pc, join_callback cb,
void *callback_param)
aop_assert (pc->kind == ATP_ENTRY);
if(pc->pc_entry.function_name != NULL)
- {
- if (strcmp( IDENTIFIER_POINTER (DECL_NAME (current_function_decl))
- ,pc->pc_entry.function_name)!=0)
- {
- fprintf(stderr,"%s function does not match the pointcut specifier",
- pc->pc_entry.function_name);
- return;
- }
+ {
+ const char *func_name =
+ IDENTIFIER_POINTER (DECL_NAME (current_function_decl));
+ if (strcmp (func_name, pc->pc_entry.function_name) != 0)
+ return;
}
FOR_EACH_BB(bb)
{
gimple_stmt_iterator gsi;
- for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+ for (gsi = gsi_start_bb (bb) ; !gsi_end_p (gsi) ; gsi_next (&gsi))
{
struct aop_joinpoint jp;
jp.pc = pc;
{
pc_function_entry->pc_entry.function_name = advice_function_entry;
}
-
#include <diagnostic.h>
#include <string.h>
-
#include "aop.h"
#include "aop-pointcut.h"
#include "aop-type.h"
#include "aop-dynval.h"
-//123456789012345678901234567890123456789012345678901234567890123456789012345678
+/* Returns true if func_decl matches the arguments described in
+ param_list by type. */
+static bool
+param_desc_matches (struct aop_param_desc *param_list, gimple func_stmt)
+{
+ int num_args = gimple_call_num_args (func_stmt);
+
+ while (param_list != NULL)
+ {
+ /* The param_list wants to match an argument that isn't
+ there. */
+ if (param_list->param_id >= num_args)
+ return false;
+
+ param_list = param_list->next;
+ }
+
+ return true;
+}
+
static void
op_join_on_function_call (struct aop_pointcut *pc, join_callback cb,
- void *callback_param)
+ void *callback_param)
{
- aop_assert (pc->kind == ATP_CALL);
-
basic_block my_basic_block;
gimple_stmt_iterator gsi;
tree func_decl;
tree func;
- const char * func_name;
+ aop_assert (pc->kind == ATP_CALL);
FOR_EACH_BB(my_basic_block)
- {
- for (gsi = gsi_start_bb (my_basic_block) ; !gsi_end_p (gsi) ;
- gsi_next (&gsi))
- {
- gimple my_statement = gsi_stmt (gsi);
-
- /* At this stage, there should be no GIMPLE
- statements with sub-statements. */
- gcc_assert(!gimple_has_substatements (my_statement));
-
- if (gimple_code (my_statement) == GIMPLE_CALL)
- {
- func = gimple_call_fn (my_statement);
+ {
+ for (gsi = gsi_start_bb (my_basic_block) ; !gsi_end_p (gsi) ;
+ gsi_next (&gsi))
+ {
+ gimple stmt = gsi_stmt (gsi);
+
+ /* At this stage, there should be no GIMPLE statements with
+ sub-statements. */
+ gcc_assert(!gimple_has_substatements (stmt));
+
+ if (gimple_code (stmt) == GIMPLE_CALL)
+ {
+ const char *func_name;
+
+ func = gimple_call_fn (stmt);
- if (TREE_CODE (func) != ADDR_EXPR)
- {
- /* This is a call to a function pointer.
- Don't worry about it. */
- continue;
- }
+ if (TREE_CODE (func) != ADDR_EXPR)
+ {
+ /* This is a call to a function pointer. Don't
+ worry about it. */
+ continue;
+ }
- func_decl = TREE_OPERAND (func, 0);
- func_name = IDENTIFIER_POINTER (DECL_NAME (func_decl));
+ func_decl = TREE_OPERAND (func, 0);
+ func_name = IDENTIFIER_POINTER (DECL_NAME (func_decl));
- if (strcmp (pc->pc_call.function_name, func_name) == 0)
- {
- int num_args = gimple_call_num_args (my_statement);
-
- struct aop_param_desc *iter = NULL;
- if(pc->pc_call.param_list_head != NULL ) {
- iter = pc->pc_call.param_list_head;
- while( iter->next != NULL ) {
- iter = iter->next;
-
- if(iter->param_id > num_args - 1 ||
- iter->param_id < 0) {
- return;
- }
- }
- }
+ if (strcmp (pc->pc_call.function_name, func_name) == 0)
+ {
+ if (!param_desc_matches (pc->pc_call.param_list_head, stmt))
+ continue;
- struct aop_joinpoint jp;
- jp.pc = pc;
- jp.gsi = &gsi;
- jp.is_prepared = false;
- cb (&jp, callback_param);
- }
- }
-
- }
- }
+ struct aop_joinpoint jp;
+ jp.pc = pc;
+ jp.gsi = &gsi;
+ jp.is_prepared = false;
+ cb (&jp, callback_param);
+ }
+ }
+ }
+ }
}
struct aop_pointcut *
pc->insert_after = op_default_insert_after;
pc->insert_before = op_default_insert_before;
pc->prepare_for_weave = op_default_prepare_for_weave;
- /*
- Initialize the list to NULL
- */
+
+ /* Initialize the list to NULL */
pc->pc_call.param_list_head = NULL;
return pc;
}
aop_add_param_descriptor (pc, param_id);
}
-
static tree
op_get_return_value (struct aop_dynval *dv)
{
gimple stmt;
tree return_value;
- /*
- If this function isn't on the right side of an assignment, we
- need to _put it_ on the right hand side of an assignment so
- we can grab its return value.
- */
+ /* If this function isn't on the right side of an assignment, we
+ need to _put it_ on the right hand side of an assignment so we
+ can grab its return value. */
struct aop_joinpoint *jp = dv->jp;
stmt = gsi_stmt (*(jp->gsi));
return_value = stabilize_reference (gimple_call_lhs (stmt));
debug_gimple_stmt (stmt);
return return_value;
-
}
struct aop_dynval *
dv->type = aop_t_all_unsigned ();
dv->jp = jp;
dv->get_dynval = op_get_return_value;
- return dv;
-
+ return dv;
}
static tree
return param;
}
-
struct aop_dynval *
aop_capture_param (struct aop_joinpoint *jp, int param_index)
{