gcov.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. #ifndef GCOV_H
  14. #define GCOV_H GCOV_H
  15. #include <linux/types.h>
  16. /*
  17. * Profiling data types used for gcc 3.4 and above - these are defined by
  18. * gcc and need to be kept as close to the original definition as possible to
  19. * remain compatible.
  20. */
  21. #define GCOV_COUNTERS 5
  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. /**
  33. * struct gcov_fn_info - profiling meta data per function
  34. * @ident: object file-unique function identifier
  35. * @checksum: function checksum
  36. * @n_ctrs: number of values per counter type belonging to this function
  37. *
  38. * This data is generated by gcc during compilation and doesn't change
  39. * at run-time.
  40. */
  41. struct gcov_fn_info {
  42. unsigned int ident;
  43. unsigned int checksum;
  44. unsigned int n_ctrs[0];
  45. };
  46. /**
  47. * struct gcov_ctr_info - profiling data per counter type
  48. * @num: number of counter values for this type
  49. * @values: array of counter values for this type
  50. * @merge: merge function for counter values of this type (unused)
  51. *
  52. * This data is generated by gcc during compilation and doesn't change
  53. * at run-time with the exception of the values array.
  54. */
  55. struct gcov_ctr_info {
  56. unsigned int num;
  57. gcov_type *values;
  58. void (*merge)(gcov_type *, unsigned int);
  59. };
  60. /**
  61. * struct gcov_info - profiling data per object file
  62. * @version: gcov version magic indicating the gcc version used for compilation
  63. * @next: list head for a singly-linked list
  64. * @stamp: time stamp
  65. * @filename: name of the associated gcov data file
  66. * @n_functions: number of instrumented functions
  67. * @functions: function data
  68. * @ctr_mask: mask specifying which counter types are active
  69. * @counts: counter data per counter type
  70. *
  71. * This data is generated by gcc during compilation and doesn't change
  72. * at run-time with the exception of the next pointer.
  73. */
  74. struct gcov_info {
  75. unsigned int version;
  76. struct gcov_info *next;
  77. unsigned int stamp;
  78. const char *filename;
  79. unsigned int n_functions;
  80. const struct gcov_fn_info *functions;
  81. unsigned int ctr_mask;
  82. struct gcov_ctr_info counts[0];
  83. };
  84. /* Base interface. */
  85. enum gcov_action {
  86. GCOV_ADD,
  87. GCOV_REMOVE,
  88. };
  89. void gcov_event(enum gcov_action action, struct gcov_info *info);
  90. void gcov_enable_events(void);
  91. /* Iterator control. */
  92. struct seq_file;
  93. struct gcov_iterator;
  94. struct gcov_iterator *gcov_iter_new(struct gcov_info *info);
  95. void gcov_iter_free(struct gcov_iterator *iter);
  96. void gcov_iter_start(struct gcov_iterator *iter);
  97. int gcov_iter_next(struct gcov_iterator *iter);
  98. int gcov_iter_write(struct gcov_iterator *iter, struct seq_file *seq);
  99. struct gcov_info *gcov_iter_get_info(struct gcov_iterator *iter);
  100. /* gcov_info control. */
  101. void gcov_info_reset(struct gcov_info *info);
  102. int gcov_info_is_compatible(struct gcov_info *info1, struct gcov_info *info2);
  103. void gcov_info_add(struct gcov_info *dest, struct gcov_info *source);
  104. struct gcov_info *gcov_info_dup(struct gcov_info *info);
  105. void gcov_info_free(struct gcov_info *info);
  106. struct gcov_link {
  107. enum {
  108. OBJ_TREE,
  109. SRC_TREE,
  110. } dir;
  111. const char *ext;
  112. };
  113. extern const struct gcov_link gcov_link[];
  114. #endif /* GCOV_H */