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