gcov.h 2.8 KB

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