]> Git Repo - qemu.git/blob - trace/control-internal.h
Merge remote-tracking branch 'remotes/jnsnow/tags/ide-pull-request' into staging
[qemu.git] / trace / control-internal.h
1 /*
2  * Interface for configuring and controlling the state of tracing events.
3  *
4  * Copyright (C) 2011-2014 LluĂ­s Vilanova <[email protected]>
5  *
6  * This work is licensed under the terms of the GNU GPL, version 2 or later.
7  * See the COPYING file in the top-level directory.
8  */
9
10 #ifndef TRACE__CONTROL_INTERNAL_H
11 #define TRACE__CONTROL_INTERNAL_H
12
13 #include <string.h>
14
15
16 extern TraceEvent trace_events[];
17 extern bool trace_events_dstate[];
18 extern int trace_events_enabled_count;
19
20
21 static inline TraceEventID trace_event_count(void)
22 {
23     return TRACE_EVENT_COUNT;
24 }
25
26 static inline TraceEvent *trace_event_id(TraceEventID id)
27 {
28     assert(id < trace_event_count());
29     return &trace_events[id];
30 }
31
32 static inline bool trace_event_is_pattern(const char *str)
33 {
34     assert(str != NULL);
35     return strchr(str, '*') != NULL;
36 }
37
38 static inline TraceEventID trace_event_get_id(TraceEvent *ev)
39 {
40     assert(ev != NULL);
41     return ev->id;
42 }
43
44 static inline const char * trace_event_get_name(TraceEvent *ev)
45 {
46     assert(ev != NULL);
47     return ev->name;
48 }
49
50 static inline bool trace_event_get_state_static(TraceEvent *ev)
51 {
52     assert(ev != NULL);
53     return ev->sstate;
54 }
55
56 static inline bool trace_event_get_state_dynamic_by_id(int id)
57 {
58     return unlikely(trace_events_enabled_count) && trace_events_dstate[id];
59 }
60
61 static inline bool trace_event_get_state_dynamic(TraceEvent *ev)
62 {
63     int id = trace_event_get_id(ev);
64     return trace_event_get_state_dynamic_by_id(id);
65 }
66
67 static inline void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
68 {
69     int id = trace_event_get_id(ev);
70     assert(ev != NULL);
71     assert(trace_event_get_state_static(ev));
72     trace_events_enabled_count += state - trace_events_dstate[id];
73     trace_events_dstate[id] = state;
74 }
75
76 #endif  /* TRACE__CONTROL_INTERNAL_H */
This page took 0.046866 seconds and 4 git commands to generate.