00001 #ifndef __AOP_H__
00002 #define __AOP_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00067 #define AOP_I_AM_GPL_COMPATIBLE() \
00068 __attribute__((visibility("default"))) int plugin_is_GPL_compatible;
00069
00083 #define AOP_MAIN_PROTO __attribute__((visibility("hidden"))) void
00084
00085
00086 #ifndef AOP_NO_ASSERT_CHECK
00087
00095 #define aop_assert(EXPR) \
00096 ((void)(!(EXPR) ? aop_abort (__FILE__, __LINE__, __FUNCTION__), 0 : 0))
00097 #else
00098
00099 #define aop_assert(EXPR) ((void)(0 && (EXPR)))
00100 #endif
00101
00102 struct aop_dynval;
00103 struct aop_joinpoint;
00104 struct aop_pointcut;
00105 struct aop_type;
00106
00114 typedef unsigned int (*pass_callback) ();
00115
00127 typedef void (*join_callback) (struct aop_joinpoint *, void *callback_param);
00128
00129 extern void aop_filter_include_temps (struct aop_pointcut *pc);
00130 extern void aop_filter_exclude_temps (struct aop_pointcut *pc);
00131
00154 enum aop_insert_location {
00165 AOP_INSERT_BEFORE,
00166
00178 AOP_INSERT_AFTER,
00179 };
00180
00181 extern void aop_insert_advice (struct aop_joinpoint *jp, const char *name,
00182 enum aop_insert_location location, ...);
00183 extern void aop_duplicate (struct aop_joinpoint *jp, const char *name, ...);
00184
00185 extern const struct aop_type *aop_t_all_signed ();
00186 extern const struct aop_type *aop_t_all_unsigned ();
00187 extern const struct aop_type *aop_t_all_fp ();
00188 extern const struct aop_type *aop_t_all_pointer ();
00189
00190 extern const struct aop_type *aop_t_signed8 ();
00191 extern const struct aop_type *aop_t_signed16 ();
00192 extern const struct aop_type *aop_t_signed32 ();
00193 extern const struct aop_type *aop_t_signed64 ();
00194 extern const struct aop_type *aop_t_signed128 ();
00195 extern const struct aop_type *aop_t_unsigned8 ();
00196 extern const struct aop_type *aop_t_unsigned16 ();
00197 extern const struct aop_type *aop_t_unsigned32 ();
00198 extern const struct aop_type *aop_t_unsigned64 ();
00199 extern const struct aop_type *aop_t_unsigned128 ();
00200 extern const struct aop_type *aop_t_float32 ();
00201 extern const struct aop_type *aop_t_float64 ();
00202 extern const struct aop_type *aop_t_long_double ();
00203 extern const struct aop_type *aop_t_cstring ();
00204 extern const struct aop_type *aop_t_struct (const char *tag);
00205 extern const struct aop_type *aop_t_struct_ptr (const char *tag);
00206 extern const struct aop_type *aop_t_union (const char *tag);
00207 extern const struct aop_type *aop_t_union_ptr (const char *tag);
00208 extern const struct aop_type *aop_t_enum (const char *tag);
00209 extern const struct aop_type *aop_t_pointer_to (const struct aop_type *type);
00210
00211 extern int aop_is_pointer_type (const struct aop_type *type);
00212 extern int aop_is_all_signed_subtype(const struct aop_type *type);
00213 extern int aop_is_all_unsigned_subtype(const struct aop_type *type);
00214 extern void aop_cast_to_all_pointer (struct aop_dynval *dv);
00215 extern void aop_cast_to_all_signed(struct aop_dynval *dv);
00216 extern void aop_cast_to_all_unsigned(struct aop_dynval *dv);
00217 extern int aop_is_all_fp_subtype (const struct aop_type *type);
00218 extern void aop_cast_to_all_fp(struct aop_dynval *dv);
00219 extern const struct aop_type *aop_get_dynval_type (struct aop_dynval *dv);
00220
00221 extern void aop_register_pass (const char *pass_name, pass_callback callback);
00222 extern void aop_join_on (struct aop_pointcut *pc, join_callback callback,
00223 void *callback_param);
00224 extern void aop_join_on_copy (struct aop_pointcut *pc, int copy,
00225 join_callback callback, void *callback_param);
00226
00241 extern void aop_main ();
00242
00253 extern void aop_finish ();
00254
00262 extern void aop_abort (const char *filename, int lineno, const char *function)
00263 __attribute__((noreturn));
00268
00269
00270
00271 enum aop_argkind {
00272 ATA_STR_CST,
00273 ATA_INT_CST,
00274 ATA_DOUBLE_CST,
00275 ATA_VOIDP_CST,
00276 ATA_DYNVAL,
00277 AOP_TERM_ARG,
00278 };
00279
00292 #define AOP_STR_CST(VAL) ATA_STR_CST, VAL
00293
00303 #define AOP_INT_CST(VAL) ATA_INT_CST, VAL
00304
00315 #define AOP_DOUBLE_CST(VAL) ATA_DOUBLE_CST, VAL
00316
00323 #define AOP_VOIDP_CST(VAL) ATA_VOIDP_CST, VAL
00324
00332 #define AOP_DYNVAL(VAL) ATA_DYNVAL, VAL
00333
00334
00335
00336 #ifdef DOXY_ONLY
00337 #error Do not define the DOXY_ONLY preprocessor variable.
00338
00346 #define AOP_TERM_ARG
00347 #endif
00348
00353 extern const char *aop_get_function_name (void);
00354
00355 extern struct aop_pointcut *aop_match_function_entry ();
00356 extern void aop_filter_by_in_param (struct aop_pointcut *pc, int n,
00357 const struct aop_type *type);
00358 extern struct aop_dynval *aop_capture_in_param (struct aop_joinpoint *jp,
00359 int param_index);
00360
00361 extern void aop_filter_entry_by_name(struct aop_pointcut *pc, const char *name);
00362
00363 extern struct aop_pointcut *aop_match_function_exit ();
00364 extern void aop_filter_exit_by_return_type (struct aop_pointcut *pc,
00365 const struct aop_type *type);
00366 extern struct aop_dynval *aop_capture_exit_return_value (
00367 struct aop_joinpoint *jp);
00368 extern struct aop_dynval *aop_capture_exit_return_value_by_type (
00369 struct aop_joinpoint *jp, const struct aop_type *type);
00370
00371 extern struct aop_pointcut *aop_match_function_call ();
00372
00373 extern void aop_filter_call_pc_by_name (struct aop_pointcut *pc,
00374 const char *advice_function_call);
00375 extern void aop_filter_call_pc_by_param (struct aop_pointcut *pc, int n,
00376 const struct aop_type *type);
00377 extern void aop_filter_call_pc_by_return_type (struct aop_pointcut *pc,
00378 const struct aop_type *type);
00379
00380 extern const char *aop_capture_called_function_name(struct aop_joinpoint *jp);
00381 extern struct aop_dynval *aop_capture_call_return_value (
00382 struct aop_joinpoint *jp);
00383 extern struct aop_dynval *aop_capture_call_return_value_by_type (
00384 struct aop_joinpoint *jp, const struct aop_type *type);
00385 extern struct aop_dynval *aop_capture_call_param (struct aop_joinpoint *jp,
00386 int param_index);
00387 extern struct aop_dynval *aop_capture_call_param_by_type (
00388 struct aop_joinpoint *jp, int n, const struct aop_type *type);
00389
00390 extern struct aop_pointcut *aop_match_assignment_by_type (
00391 const struct aop_type *type);
00392
00393 extern struct aop_dynval *aop_capture_lhs_addr (struct aop_joinpoint *jp);
00394 extern const char *aop_capture_lhs_name (struct aop_joinpoint *jp);
00395 extern struct aop_dynval *aop_capture_assigned_value (struct aop_joinpoint *jp);
00396
00397 extern int aop_write_c_header (const char *filename, const char *guard,
00398 const char *license, const char *preamble);
00399
00400 extern const char *aop_get_arg_value (const char *key);
00401
00413 #define AOP_GLOBAL_SCOPE -1
00414
00418 #define AOP_FILE_SCOPE -2
00419
00425 #define AOP_MEMORY_SCOPE -3
00426
00430 #define AOP_LOCAL_SCOPE(SCOPE) (SCOPE >= 0)
00431
00432
00437 extern int aop_capture_lhs_var_scope (struct aop_joinpoint *jp);
00438
00439 extern int aop_capture_lineno (struct aop_joinpoint *jp);
00440
00441 extern const char *aop_capture_file_name (struct aop_joinpoint *jp);
00442
00443 extern struct aop_dynval *
00444 aop_capture_in_param_by_type (struct aop_joinpoint *jp, int n,
00445 const struct aop_type *type);
00446
00447 #endif