callgrind.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. ----------------------------------------------------------------
  3. Notice that the following BSD-style license applies to this one
  4. file (callgrind.h) only. The rest of Valgrind is licensed under the
  5. terms of the GNU General Public License, version 2, unless
  6. otherwise indicated. See the COPYING file in the source
  7. distribution for details.
  8. ----------------------------------------------------------------
  9. This file is part of callgrind, a valgrind tool for cache simulation
  10. and call tree tracing.
  11. Copyright (C) 2003-2017 Josef Weidendorfer. All rights reserved.
  12. Redistribution and use in source and binary forms, with or without
  13. modification, are permitted provided that the following conditions
  14. are met:
  15. 1. Redistributions of source code must retain the above copyright
  16. notice, this list of conditions and the following disclaimer.
  17. 2. The origin of this software must not be misrepresented; you must
  18. not claim that you wrote the original software. If you use this
  19. software in a product, an acknowledgment in the product
  20. documentation would be appreciated but is not required.
  21. 3. Altered source versions must be plainly marked as such, and must
  22. not be misrepresented as being the original software.
  23. 4. The name of the author may not be used to endorse or promote
  24. products derived from this software without specific prior written
  25. permission.
  26. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  27. OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  28. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29. ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  30. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  32. GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  34. WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  35. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  36. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  37. ----------------------------------------------------------------
  38. Notice that the above BSD-style license applies to this one file
  39. (callgrind.h) only. The entire rest of Valgrind is licensed under
  40. the terms of the GNU General Public License, version 2. See the
  41. COPYING file in the source distribution for details.
  42. ----------------------------------------------------------------
  43. */
  44. #ifndef __CALLGRIND_H
  45. #define __CALLGRIND_H
  46. #include "valgrind.h"
  47. /* !! ABIWARNING !! ABIWARNING !! ABIWARNING !! ABIWARNING !!
  48. This enum comprises an ABI exported by Valgrind to programs
  49. which use client requests. DO NOT CHANGE THE ORDER OF THESE
  50. ENTRIES, NOR DELETE ANY -- add new ones at the end.
  51. The identification ('C','T') for Callgrind has historical
  52. reasons: it was called "Calltree" before. Besides, ('C','G') would
  53. clash with cachegrind.
  54. */
  55. typedef
  56. enum {
  57. VG_USERREQ__DUMP_STATS = VG_USERREQ_TOOL_BASE('C','T'),
  58. VG_USERREQ__ZERO_STATS,
  59. VG_USERREQ__TOGGLE_COLLECT,
  60. VG_USERREQ__DUMP_STATS_AT,
  61. VG_USERREQ__START_INSTRUMENTATION,
  62. VG_USERREQ__STOP_INSTRUMENTATION
  63. } Vg_CallgrindClientRequest;
  64. /* Dump current state of cost centers, and zero them afterwards */
  65. #define CALLGRIND_DUMP_STATS \
  66. VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__DUMP_STATS, \
  67. 0, 0, 0, 0, 0)
  68. /* Dump current state of cost centers, and zero them afterwards.
  69. The argument is appended to a string stating the reason which triggered
  70. the dump. This string is written as a description field into the
  71. profile data dump. */
  72. #define CALLGRIND_DUMP_STATS_AT(pos_str) \
  73. VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__DUMP_STATS_AT, \
  74. pos_str, 0, 0, 0, 0)
  75. /* Zero cost centers */
  76. #define CALLGRIND_ZERO_STATS \
  77. VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__ZERO_STATS, \
  78. 0, 0, 0, 0, 0)
  79. /* Toggles collection state.
  80. The collection state specifies whether the happening of events
  81. should be noted or if they are to be ignored. Events are noted
  82. by increment of counters in a cost center */
  83. #define CALLGRIND_TOGGLE_COLLECT \
  84. VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__TOGGLE_COLLECT, \
  85. 0, 0, 0, 0, 0)
  86. /* Start full callgrind instrumentation if not already switched on.
  87. When cache simulation is done, it will flush the simulated cache;
  88. this will lead to an artificial cache warmup phase afterwards with
  89. cache misses which would not have happened in reality. */
  90. #define CALLGRIND_START_INSTRUMENTATION \
  91. VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__START_INSTRUMENTATION, \
  92. 0, 0, 0, 0, 0)
  93. /* Stop full callgrind instrumentation if not already switched off.
  94. This flushes Valgrinds translation cache, and does no additional
  95. instrumentation afterwards, which effectivly will run at the same
  96. speed as the "none" tool (ie. at minimal slowdown).
  97. Use this to bypass Callgrind aggregation for uninteresting code parts.
  98. To start Callgrind in this mode to ignore the setup phase, use
  99. the option "--instr-atstart=no". */
  100. #define CALLGRIND_STOP_INSTRUMENTATION \
  101. VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__STOP_INSTRUMENTATION, \
  102. 0, 0, 0, 0, 0)
  103. #endif /* __CALLGRIND_H */