Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  *  Profiling infrastructure declarations.
0004  *
0005  *  This file is based on gcc-internal definitions. Data structures are
0006  *  defined to be compatible with gcc counterparts. For a better
0007  *  understanding, refer to gcc source: gcc/gcov-io.h.
0008  *
0009  *    Copyright IBM Corp. 2009
0010  *    Author(s): Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
0011  *
0012  *    Uses gcc-internal data definitions.
0013  */
0014 
0015 #ifndef GCOV_H
0016 #define GCOV_H GCOV_H
0017 
0018 #include <linux/module.h>
0019 #include <linux/types.h>
0020 
0021 /*
0022  * Profiling data types used for gcc 3.4 and above - these are defined by
0023  * gcc and need to be kept as close to the original definition as possible to
0024  * remain compatible.
0025  */
0026 #define GCOV_DATA_MAGIC     ((unsigned int) 0x67636461)
0027 #define GCOV_TAG_FUNCTION   ((unsigned int) 0x01000000)
0028 #define GCOV_TAG_COUNTER_BASE   ((unsigned int) 0x01a10000)
0029 #define GCOV_TAG_FOR_COUNTER(count)                 \
0030     (GCOV_TAG_COUNTER_BASE + ((unsigned int) (count) << 17))
0031 
0032 #if BITS_PER_LONG >= 64
0033 typedef long gcov_type;
0034 #else
0035 typedef long long gcov_type;
0036 #endif
0037 
0038 /* Opaque gcov_info. The gcov structures can change as for example in gcc 4.7 so
0039  * we cannot use full definition here and they need to be placed in gcc specific
0040  * implementation of gcov. This also means no direct access to the members in
0041  * generic code and usage of the interface below.*/
0042 struct gcov_info;
0043 
0044 /* Interface to access gcov_info data  */
0045 const char *gcov_info_filename(struct gcov_info *info);
0046 unsigned int gcov_info_version(struct gcov_info *info);
0047 struct gcov_info *gcov_info_next(struct gcov_info *info);
0048 void gcov_info_link(struct gcov_info *info);
0049 void gcov_info_unlink(struct gcov_info *prev, struct gcov_info *info);
0050 bool gcov_info_within_module(struct gcov_info *info, struct module *mod);
0051 size_t convert_to_gcda(char *buffer, struct gcov_info *info);
0052 
0053 /* Base interface. */
0054 enum gcov_action {
0055     GCOV_ADD,
0056     GCOV_REMOVE,
0057 };
0058 
0059 void gcov_event(enum gcov_action action, struct gcov_info *info);
0060 void gcov_enable_events(void);
0061 
0062 /* writing helpers */
0063 size_t store_gcov_u32(void *buffer, size_t off, u32 v);
0064 size_t store_gcov_u64(void *buffer, size_t off, u64 v);
0065 
0066 /* gcov_info control. */
0067 void gcov_info_reset(struct gcov_info *info);
0068 int gcov_info_is_compatible(struct gcov_info *info1, struct gcov_info *info2);
0069 void gcov_info_add(struct gcov_info *dest, struct gcov_info *source);
0070 struct gcov_info *gcov_info_dup(struct gcov_info *info);
0071 void gcov_info_free(struct gcov_info *info);
0072 
0073 struct gcov_link {
0074     enum {
0075         OBJ_TREE,
0076         SRC_TREE,
0077     } dir;
0078     const char *ext;
0079 };
0080 extern const struct gcov_link gcov_link[];
0081 
0082 extern int gcov_events_enabled;
0083 extern struct mutex gcov_lock;
0084 
0085 #endif /* GCOV_H */