Add 469782 to NEWS
[valgrind.git] / callgrind / events.h
bloba4ca93300bebf1058584ac1c0cfc1c02bc226791
1 /*--------------------------------------------------------------------*/
2 /*--- Callgrind ---*/
3 /*--- events.h ---*/
4 /*--------------------------------------------------------------------*/
6 /*
7 This file is part of Callgrind, a Valgrind tool for call tracing.
9 Copyright (C) 2002-2017, Josef Weidendorfer (Josef.Weidendorfer@gmx.de)
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation; either version 2 of the
14 License, or (at your option) any later version.
16 This program is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, see <http://www.gnu.org/licenses/>.
24 The GNU General Public License is contained in the file COPYING.
27 /* Abstractions for 64-bit cost lists (events.h) */
29 #ifndef CLG_EVENTS
30 #define CLG_EVENTS
32 #include "pub_tool_basics.h"
34 #define CLG_(str) VGAPPEND(vgCallgrind_,str)
36 /* Event groups consist of one or more named event types.
37 * Event sets are constructed from such event groups.
39 * Event groups have to be registered globally with a unique ID
40 * before they can be used in an event set.
41 * A group can appear at most once in a event set.
44 #define MAX_EVENTGROUP_COUNT 10
46 typedef struct _EventGroup EventGroup;
47 struct _EventGroup {
48 Int size;
49 const HChar* name[0];
52 /* return 0 if event group can not be registered */
53 EventGroup* CLG_(register_event_group) (int id, const HChar*);
54 EventGroup* CLG_(register_event_group2)(int id, const HChar*, const HChar*);
55 EventGroup* CLG_(register_event_group3)(int id, const HChar*, const HChar*,
56 const HChar*);
57 EventGroup* CLG_(register_event_group4)(int id, const HChar*, const HChar*,
58 const HChar*, const HChar*);
59 EventGroup* CLG_(get_event_group)(int id);
61 /* Event sets are defined by event groups they consist of. */
63 typedef struct _EventSet EventSet;
64 struct _EventSet {
65 /* if subset with ID x is in the set, then bit x is set */
66 UInt mask;
67 Int count;
68 Int size;
69 Int offset[MAX_EVENTGROUP_COUNT];
72 /* Same event set is returned when requesting same event groups */
73 EventSet* CLG_(get_event_set)(Int id);
74 EventSet* CLG_(get_event_set2)(Int id1, Int id2);
75 EventSet* CLG_(add_event_group)(EventSet*, Int id);
76 EventSet* CLG_(add_event_group2)(EventSet*, Int id1, Int id2);
77 EventSet* CLG_(add_event_set)(EventSet*, EventSet*);
80 /* Operations on costs. A cost pointer of 0 means zero cost.
81 * Functions ending in _lz allocate cost arrays only when needed
83 ULong* CLG_(get_eventset_cost)(EventSet*);
84 /* Set costs of event set to 0 */
85 void CLG_(init_cost)(EventSet*,ULong*);
86 /* This always allocates counter and sets them to 0 */
87 void CLG_(init_cost_lz)(EventSet*,ULong**);
88 /* Set costs of an event set to zero */
89 void CLG_(zero_cost)(EventSet*,ULong*);
90 Bool CLG_(is_zero_cost)(EventSet*,ULong*);
91 void CLG_(copy_cost)(EventSet*,ULong* dst, ULong* src);
92 void CLG_(copy_cost_lz)(EventSet*,ULong** pdst, ULong* src);
93 void CLG_(add_cost)(EventSet*,ULong* dst, ULong* src);
94 void CLG_(add_cost_lz)(EventSet*,ULong** pdst, ULong* src);
95 /* Adds src to dst and zeros src. Returns false if nothing changed */
96 Bool CLG_(add_and_zero_cost)(EventSet*,ULong* dst, ULong* src);
97 Bool CLG_(add_and_zero_cost2)(EventSet*,ULong* dst,EventSet*,ULong* src);
98 /* Adds difference of new and old to to dst, and set old to new.
99 * Returns false if nothing changed */
100 Bool CLG_(add_diff_cost)(EventSet*,ULong* dst, ULong* old, ULong* new_cost);
101 Bool CLG_(add_diff_cost_lz)(EventSet*,ULong** pdst, ULong* old, ULong* new_cost);
103 /* EventMapping: An ordered subset of events from an event set.
104 * This is used to print out part of an EventSet, or in another order.
106 struct EventMappingEntry {
107 Int group;
108 Int index;
109 Int offset;
111 typedef struct _EventMapping EventMapping;
112 struct _EventMapping {
113 EventSet* es;
114 Int size;
115 Int capacity;
116 struct EventMappingEntry entry[0];
119 /* Allocate space for an event mapping */
120 EventMapping* CLG_(get_eventmapping)(EventSet*);
121 void CLG_(append_event)(EventMapping*, const HChar*);
122 /* Returns event mapping as a character string. That string is dynamically
123 allocated and it is the caller's responsibility to free it.
124 The function never returns NULL. */
125 HChar *CLG_(eventmapping_as_string)(const EventMapping*);
126 /* Returns mapping cost as a character string. That string is dynamically
127 allocated and it is the caller's responsibility to free it.
128 The function never returns NULL. */
129 HChar *CLG_(mappingcost_as_string)(const EventMapping*, const ULong*);
131 #endif /* CLG_EVENTS */