gcov.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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/types.h>
  17. /*
  18. * Profiling data types used for gcc 3.4 and above - these are defined by
  19. * gcc and need to be kept as close to the original definition as possible to
  20. * remain compatible.
  21. */
  22. #define GCOV_DATA_MAGIC ((unsigned int) 0x67636461)
  23. #define GCOV_TAG_FUNCTION ((unsigned int) 0x01000000)
  24. #define GCOV_TAG_COUNTER_BASE ((unsigned int) 0x01a10000)
  25. #define GCOV_TAG_FOR_COUNTER(count) \
  26. (GCOV_TAG_COUNTER_BASE + ((unsigned int) (count) << 17))
  27. #if BITS_PER_LONG >= 64
  28. typedef long gcov_type;
  29. #else
  30. typedef long long gcov_type;
  31. #endif
  32. /* Opaque gcov_info. The gcov structures can change as for example in gcc 4.7 so
  33. * we cannot use full definition here and they need to be placed in gcc specific
  34. * implementation of gcov. This also means no direct access to the members in
  35. * generic code and usage of the interface below.*/
  36. struct gcov_info;
  37. /* Interface to access gcov_info data */
  38. const char *gcov_info_filename(struct gcov_info *info);
  39. unsigned int gcov_info_version(struct gcov_info *info);
  40. struct gcov_info *gcov_info_next(struct gcov_info *info);
  41. void gcov_info_link(struct gcov_info *info);
  42. void gcov_info_unlink(struct gcov_info *prev, struct gcov_info *info);
  43. /* Base interface. */
  44. enum gcov_action {
  45. GCOV_ADD,
  46. GCOV_REMOVE,
  47. };
  48. void gcov_event(enum gcov_action action, struct gcov_info *info);
  49. void gcov_enable_events(void);
  50. /* Iterator control. */
  51. struct seq_file;
  52. struct gcov_iterator;
  53. struct gcov_iterator *gcov_iter_new(struct gcov_info *info);
  54. void gcov_iter_free(struct gcov_iterator *iter);
  55. void gcov_iter_start(struct gcov_iterator *iter);
  56. int gcov_iter_next(struct gcov_iterator *iter);
  57. int gcov_iter_write(struct gcov_iterator *iter, struct seq_file *seq);
  58. struct gcov_info *gcov_iter_get_info(struct gcov_iterator *iter);
  59. /* gcov_info control. */
  60. void gcov_info_reset(struct gcov_info *info);
  61. int gcov_info_is_compatible(struct gcov_info *info1, struct gcov_info *info2);
  62. void gcov_info_add(struct gcov_info *dest, struct gcov_info *source);
  63. struct gcov_info *gcov_info_dup(struct gcov_info *info);
  64. void gcov_info_free(struct gcov_info *info);
  65. struct gcov_link {
  66. enum {
  67. OBJ_TREE,
  68. SRC_TREE,
  69. } dir;
  70. const char *ext;
  71. };
  72. extern const struct gcov_link gcov_link[];
  73. #endif /* GCOV_H */