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