]>
Commit | Line | Data |
---|---|---|
b1bae816 LV |
1 | /* |
2 | * Interface for configuring and controlling the state of tracing events. | |
3 | * | |
5b808275 | 4 | * Copyright (C) 2011-2014 Lluís Vilanova <vilanova@ac.upc.edu> |
b1bae816 LV |
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 | ||
b1bae816 LV |
13 | |
14 | ||
15 | extern TraceEvent trace_events[]; | |
585ec727 | 16 | extern bool trace_events_dstate[]; |
43b48cfc | 17 | extern int trace_events_enabled_count; |
b1bae816 LV |
18 | |
19 | ||
84f3fe1b | 20 | static inline TraceEventID trace_event_count(void) |
b1bae816 | 21 | { |
84f3fe1b | 22 | return TRACE_EVENT_COUNT; |
b1bae816 LV |
23 | } |
24 | ||
84f3fe1b | 25 | static inline TraceEvent *trace_event_id(TraceEventID id) |
b1bae816 | 26 | { |
84f3fe1b PM |
27 | assert(id < trace_event_count()); |
28 | return &trace_events[id]; | |
b1bae816 LV |
29 | } |
30 | ||
31 | static inline bool trace_event_is_pattern(const char *str) | |
32 | { | |
33 | assert(str != NULL); | |
34 | return strchr(str, '*') != NULL; | |
35 | } | |
36 | ||
37 | static inline TraceEventID trace_event_get_id(TraceEvent *ev) | |
38 | { | |
39 | assert(ev != NULL); | |
40 | return ev->id; | |
41 | } | |
42 | ||
43 | static inline const char * trace_event_get_name(TraceEvent *ev) | |
44 | { | |
45 | assert(ev != NULL); | |
46 | return ev->name; | |
47 | } | |
48 | ||
49 | static inline bool trace_event_get_state_static(TraceEvent *ev) | |
50 | { | |
51 | assert(ev != NULL); | |
52 | return ev->sstate; | |
53 | } | |
54 | ||
585ec727 PB |
55 | static inline bool trace_event_get_state_dynamic_by_id(int id) |
56 | { | |
57 | return unlikely(trace_events_enabled_count) && trace_events_dstate[id]; | |
58 | } | |
59 | ||
b1bae816 LV |
60 | static inline bool trace_event_get_state_dynamic(TraceEvent *ev) |
61 | { | |
585ec727 PB |
62 | int id = trace_event_get_id(ev); |
63 | return trace_event_get_state_dynamic_by_id(id); | |
b1bae816 LV |
64 | } |
65 | ||
66 | static inline void trace_event_set_state_dynamic(TraceEvent *ev, bool state) | |
67 | { | |
585ec727 | 68 | int id = trace_event_get_id(ev); |
b1bae816 LV |
69 | assert(ev != NULL); |
70 | assert(trace_event_get_state_static(ev)); | |
585ec727 PB |
71 | trace_events_enabled_count += state - trace_events_dstate[id]; |
72 | trace_events_dstate[id] = state; | |
b1bae816 LV |
73 | } |
74 | ||
75 | #endif /* TRACE__CONTROL_INTERNAL_H */ |