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 void aop_register_pass (const char *pass_name, pass_callback callback);
00212 extern void aop_join_on (struct aop_pointcut *pc, join_callback callback,
00213 void *callback_param);
00214 extern void aop_join_on_copy (struct aop_pointcut *pc, int copy,
00215 join_callback callback, void *callback_param);
00216
00231 extern void aop_main ();
00232
00243 extern void aop_finish ();
00244
00252 extern void aop_abort (const char *filename, int lineno, const char *function)
00253 __attribute__((noreturn));
00258
00259
00260
00261 enum aop_argkind {
00262 ATA_STR_CST,
00263 ATA_INT_CST,
00264 ATA_DOUBLE_CST,
00265 ATA_VOIDP_CST,
00266 ATA_DYNVAL,
00267 AOP_TERM_ARG,
00268 };
00269
00282 #define AOP_STR_CST(VAL) ATA_STR_CST, VAL
00283
00293 #define AOP_INT_CST(VAL) ATA_INT_CST, VAL
00294
00305 #define AOP_DOUBLE_CST(VAL) ATA_DOUBLE_CST, VAL
00306
00313 #define AOP_VOIDP_CST(VAL) ATA_VOIDP_CST, VAL
00314
00322 #define AOP_DYNVAL(VAL) ATA_DYNVAL, VAL
00323
00324
00325
00326 #ifdef DOXY_ONLY
00327 #error Do not define the DOXY_ONLY preprocessor variable.
00328
00336 #define AOP_TERM_ARG
00337 #endif
00338
00343 extern const char *aop_get_function_name (void);
00344
00345 extern struct aop_pointcut *aop_match_function_entry ();
00346 extern void aop_filter_by_in_param (struct aop_pointcut *pc, int n,
00347 const struct aop_type *type);
00348 extern struct aop_dynval *aop_capture_in_param (struct aop_joinpoint *jp,
00349 int param_index);
00350
00351 extern void aop_filter_entry_by_name(struct aop_pointcut *pc, const char *name);
00352
00353 extern struct aop_pointcut *aop_match_function_exit ();
00354 extern void aop_filter_exit_by_return_type (struct aop_pointcut *pc,
00355 const struct aop_type *type);
00356 extern struct aop_dynval *aop_capture_exit_return_value (
00357 struct aop_joinpoint *jp);
00358 extern struct aop_dynval *aop_capture_exit_return_value_by_type (
00359 struct aop_joinpoint *jp, const struct aop_type *type);
00360
00361 extern struct aop_pointcut *aop_match_function_call ();
00362
00363 extern void aop_filter_call_pc_by_name (struct aop_pointcut *pc,
00364 const char *advice_function_call);
00365 extern void aop_filter_call_pc_by_param (struct aop_pointcut *pc, int n,
00366 const struct aop_type *type);
00367 extern void aop_filter_call_pc_by_return_type (struct aop_pointcut *pc,
00368 const struct aop_type *type);
00369
00370 extern const char *aop_capture_called_function_name(struct aop_joinpoint *jp);
00371 extern struct aop_dynval *aop_capture_call_return_value (
00372 struct aop_joinpoint *jp);
00373 extern struct aop_dynval *aop_capture_call_return_value_by_type (
00374 struct aop_joinpoint *jp, const struct aop_type *type);
00375 extern struct aop_dynval *aop_capture_call_param (struct aop_joinpoint *jp,
00376 int param_index);
00377 extern struct aop_dynval *aop_capture_call_param_by_type (
00378 struct aop_joinpoint *jp, int n, const struct aop_type *type);
00379
00380 extern struct aop_pointcut *aop_match_assignment_by_type (
00381 const struct aop_type *type);
00382
00383 extern struct aop_dynval *aop_capture_lhs_addr (struct aop_joinpoint *jp);
00384 extern const char *aop_capture_lhs_name (struct aop_joinpoint *jp);
00385 extern struct aop_dynval *aop_capture_assigned_value (struct aop_joinpoint *jp);
00386
00387 extern int aop_write_c_header (const char *filename, const char *guard,
00388 const char *license, const char *preamble);
00389
00390 extern const char *aop_get_arg_value (const char *key);
00391
00403 #define AOP_GLOBAL_SCOPE -1
00404
00408 #define AOP_FILE_SCOPE -2
00409
00415 #define AOP_MEMORY_SCOPE -3
00416
00420 #define AOP_LOCAL_SCOPE(SCOPE) (SCOPE >= 0)
00421
00422
00427 extern int aop_capture_lhs_var_scope (struct aop_joinpoint *jp);
00428
00429 extern int aop_capture_lineno (struct aop_joinpoint *jp);
00430
00431 extern const char *aop_capture_file_name (struct aop_joinpoint *jp);
00432
00433 extern struct aop_dynval *
00434 aop_capture_in_param_by_type (struct aop_joinpoint *jp, int n,
00435 const struct aop_type *type);
00436
00437 #endif