^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Profiling infrastructure declarations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * This file is based on gcc-internal definitions. Data structures are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * defined to be compatible with gcc counterparts. For a better
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * understanding, refer to gcc source: gcc/gcov-io.h.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Copyright IBM Corp. 2009
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Author(s): Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Uses gcc-internal data definitions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #ifndef GCOV_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define GCOV_H GCOV_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * Profiling data types used for gcc 3.4 and above - these are defined by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * gcc and need to be kept as close to the original definition as possible to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * remain compatible.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define GCOV_DATA_MAGIC ((unsigned int) 0x67636461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define GCOV_TAG_FUNCTION ((unsigned int) 0x01000000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define GCOV_TAG_COUNTER_BASE ((unsigned int) 0x01a10000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define GCOV_TAG_FOR_COUNTER(count) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) (GCOV_TAG_COUNTER_BASE + ((unsigned int) (count) << 17))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #if BITS_PER_LONG >= 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) typedef long gcov_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) typedef long long gcov_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /* Opaque gcov_info. The gcov structures can change as for example in gcc 4.7 so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * we cannot use full definition here and they need to be placed in gcc specific
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * implementation of gcov. This also means no direct access to the members in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * generic code and usage of the interface below.*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct gcov_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /* Interface to access gcov_info data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) const char *gcov_info_filename(struct gcov_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) unsigned int gcov_info_version(struct gcov_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct gcov_info *gcov_info_next(struct gcov_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) void gcov_info_link(struct gcov_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) void gcov_info_unlink(struct gcov_info *prev, struct gcov_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) bool gcov_info_within_module(struct gcov_info *info, struct module *mod);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /* Base interface. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) enum gcov_action {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) GCOV_ADD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) GCOV_REMOVE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) void gcov_event(enum gcov_action action, struct gcov_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) void gcov_enable_events(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) /* Iterator control. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct seq_file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct gcov_iterator;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct gcov_iterator *gcov_iter_new(struct gcov_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) void gcov_iter_free(struct gcov_iterator *iter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) void gcov_iter_start(struct gcov_iterator *iter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) int gcov_iter_next(struct gcov_iterator *iter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) int gcov_iter_write(struct gcov_iterator *iter, struct seq_file *seq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct gcov_info *gcov_iter_get_info(struct gcov_iterator *iter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) /* gcov_info control. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) void gcov_info_reset(struct gcov_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) int gcov_info_is_compatible(struct gcov_info *info1, struct gcov_info *info2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) void gcov_info_add(struct gcov_info *dest, struct gcov_info *source);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) struct gcov_info *gcov_info_dup(struct gcov_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) void gcov_info_free(struct gcov_info *info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct gcov_link {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) OBJ_TREE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) SRC_TREE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) } dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) const char *ext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) extern const struct gcov_link gcov_link[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) extern int gcov_events_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) extern struct mutex gcov_lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #endif /* GCOV_H */