gmon.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * Copyright (c) 1983, 1991, 1993, 2001
  3. * The Regents of the University of California. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of the University nor the names of its contributors
  14. * may be used to endorse or promote products derived from this software
  15. * without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  21. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. * SUCH DAMAGE.
  28. */
  29. #ifndef gmon_h
  30. #define gmon_h
  31. /* Size of the 4.4BSD gmon header */
  32. #define GMON_HDRSIZE_BSD44_32 (4 + 4 + 4 + 4 + 4 + (3 * 4))
  33. #define GMON_HDRSIZE_BSD44_64 (8 + 8 + 4 + 4 + 4 + (3 * 4))
  34. /* *INDENT-OFF* */
  35. /* For documentation purposes only.
  36. struct raw_phdr
  37. {
  38. char low_pc[sizeof(void *)]; -- base pc address of sample buffer
  39. char high_pc[sizeof(void *)]; -- max pc address of sampled buffer
  40. char ncnt[4]; -- size of sample buffer (plus this
  41. header)
  42. char version[4]; -- version number
  43. char profrate[4]; -- profiling clock rate
  44. char spare[3*4]; -- reserved
  45. };
  46. */
  47. /* *INDENT-ON* */
  48. #define GMONVERSION 0x00051879
  49. /* Size of the old BSD gmon header */
  50. #define GMON_HDRSIZE_OLDBSD_32 (4 + 4 + 4)
  51. /* FIXME: Checking host compiler defines here means that we can't
  52. use a cross gprof alpha OSF. */
  53. #if defined(__alpha__) && defined (__osf__)
  54. #define GMON_HDRSIZE_OLDBSD_64 (8 + 8 + 4 + 4)
  55. #else
  56. #define GMON_HDRSIZE_OLDBSD_64 (8 + 8 + 4)
  57. #endif
  58. /* *INDENT-OFF* */
  59. /* For documentation purposes only.
  60. struct old_raw_phdr
  61. {
  62. char low_pc[sizeof(void *)]; -- base pc address of sample buffer
  63. char high_pc[sizeof(void *)] -- max pc address of sampled buffer
  64. char ncnt[4]; -- size of sample buffer (plus this
  65. header)
  66. if defined (__alpha__) && defined (__osf__)
  67. char pad[4]; -- DEC's OSF v3.0 uses 4 bytes of padding
  68. -- to bring the header to a size that is a
  69. -- multiple of 8.
  70. endif
  71. };
  72. */
  73. /* *INDENT-ON* */
  74. /*
  75. * Histogram counters are unsigned shorts:
  76. */
  77. #define HISTCOUNTER unsigned short
  78. /*
  79. * Fraction of text space to allocate for histogram counters here, 1/2:
  80. */
  81. #define HISTFRACTION 2
  82. /*
  83. * Fraction of text space to allocate for from hash buckets. The
  84. * value of HASHFRACTION is based on the minimum number of bytes of
  85. * separation between two subroutine call points in the object code.
  86. * Given MIN_SUBR_SEPARATION bytes of separation the value of
  87. * HASHFRACTION is calculated as:
  88. *
  89. * HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1);
  90. *
  91. * For the VAX, the shortest two call sequence is:
  92. *
  93. * calls $0,(r0)
  94. * calls $0,(r0)
  95. *
  96. * which is separated by only three bytes, thus HASHFRACTION is
  97. * calculated as:
  98. *
  99. * HASHFRACTION = 3 / (2 * 2 - 1) = 1
  100. *
  101. * Note that the division above rounds down, thus if MIN_SUBR_FRACTION
  102. * is less than three, this algorithm will not work!
  103. */
  104. #define HASHFRACTION 1
  105. /*
  106. * Percent of text space to allocate for tostructs with a minimum:
  107. */
  108. #define ARCDENSITY 2
  109. #define MINARCS 50
  110. struct tostruct
  111. {
  112. char *selfpc;
  113. int count;
  114. unsigned short link;
  115. };
  116. /*
  117. * A raw arc, with pointers to the calling site and the called site
  118. * and a count. Everything is defined in terms of characters so
  119. * as to get a packed representation (otherwise, different compilers
  120. * might introduce different padding):
  121. */
  122. /* *INDENT-OFF* */
  123. /* For documentation purposes only.
  124. struct raw_arc
  125. {
  126. char from_pc[sizeof(void *)];
  127. char self_pc[sizeof(void *)];
  128. char count[sizeof(long)];
  129. };
  130. */
  131. /* *INDENT-ON* */
  132. /*
  133. * General rounding functions:
  134. */
  135. #define ROUNDDOWN(x,y) (((x)/(y))*(y))
  136. #define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y))
  137. #endif /* gmon_h */