Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20160714' into...
[qemu/kevin.git] / trace / control-internal.h
blobdeacc8f89468746c2532c31ba2bf533ff964e109
1 /*
2 * Interface for configuring and controlling the state of tracing events.
4 * Copyright (C) 2011-2014 LluĂ­s Vilanova <vilanova@ac.upc.edu>
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 */
10 #ifndef TRACE__CONTROL_INTERNAL_H
11 #define TRACE__CONTROL_INTERNAL_H
13 extern TraceEvent trace_events[];
14 extern bool trace_events_dstate[];
15 extern int trace_events_enabled_count;
18 static inline TraceEventID trace_event_count(void)
20 return TRACE_EVENT_COUNT;
23 static inline TraceEvent *trace_event_id(TraceEventID id)
25 assert(id < trace_event_count());
26 return &trace_events[id];
29 static inline bool trace_event_is_pattern(const char *str)
31 assert(str != NULL);
32 return strchr(str, '*') != NULL;
35 static inline TraceEventID trace_event_get_id(TraceEvent *ev)
37 assert(ev != NULL);
38 return ev->id;
41 static inline const char * trace_event_get_name(TraceEvent *ev)
43 assert(ev != NULL);
44 return ev->name;
47 static inline bool trace_event_get_state_static(TraceEvent *ev)
49 assert(ev != NULL);
50 return ev->sstate;
53 static inline bool trace_event_get_state_dynamic_by_id(int id)
55 return unlikely(trace_events_enabled_count) && trace_events_dstate[id];
58 static inline bool trace_event_get_state_dynamic(TraceEvent *ev)
60 int id = trace_event_get_id(ev);
61 return trace_event_get_state_dynamic_by_id(id);
64 static inline void trace_event_set_state_dynamic(TraceEvent *ev, bool state)
66 int id = trace_event_get_id(ev);
67 assert(ev != NULL);
68 assert(trace_event_get_state_static(ev));
69 trace_events_enabled_count += state - trace_events_dstate[id];
70 trace_events_dstate[id] = state;
73 #endif /* TRACE__CONTROL_INTERNAL_H */