Lluís Vilanova | b1bae81 | 2013-03-05 14:47:38 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Interface for configuring and controlling the state of tracing events. |
| 3 | * |
Lluís Vilanova | 17f7ac7 | 2016-07-11 12:53:24 +0200 | [diff] [blame] | 4 | * Copyright (C) 2011-2016 Lluís Vilanova <vilanova@ac.upc.edu> |
Lluís Vilanova | b1bae81 | 2013-03-05 14:47:38 +0100 | [diff] [blame] | 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 | |
Paolo Bonzini | 43b48cf | 2015-10-28 07:06:26 +0100 | [diff] [blame] | 13 | extern int trace_events_enabled_count; |
Lluís Vilanova | b1bae81 | 2013-03-05 14:47:38 +0100 | [diff] [blame] | 14 | |
| 15 | |
Lluís Vilanova | b1bae81 | 2013-03-05 14:47:38 +0100 | [diff] [blame] | 16 | static inline bool trace_event_is_pattern(const char *str) |
| 17 | { |
| 18 | assert(str != NULL); |
| 19 | return strchr(str, '*') != NULL; |
| 20 | } |
| 21 | |
Daniel P. Berrange | ef4c9fc | 2016-10-04 14:35:49 +0100 | [diff] [blame] | 22 | static inline uint32_t trace_event_get_id(TraceEvent *ev) |
Lluís Vilanova | b1bae81 | 2013-03-05 14:47:38 +0100 | [diff] [blame] | 23 | { |
| 24 | assert(ev != NULL); |
| 25 | return ev->id; |
| 26 | } |
| 27 | |
| 28 | static inline const char * trace_event_get_name(TraceEvent *ev) |
| 29 | { |
| 30 | assert(ev != NULL); |
| 31 | return ev->name; |
| 32 | } |
| 33 | |
| 34 | static inline bool trace_event_get_state_static(TraceEvent *ev) |
| 35 | { |
| 36 | assert(ev != NULL); |
| 37 | return ev->sstate; |
| 38 | } |
| 39 | |
Daniel P. Berrange | 9397740 | 2016-10-04 14:35:45 +0100 | [diff] [blame] | 40 | /* it's on fast path, avoid consistency checks (asserts) */ |
| 41 | #define trace_event_get_state_dynamic_by_id(id) \ |
| 42 | (unlikely(trace_events_enabled_count) && _ ## id ## _DSTATE) |
Paolo Bonzini | 585ec72 | 2015-10-28 07:06:27 +0100 | [diff] [blame] | 43 | |
Lluís Vilanova | b1bae81 | 2013-03-05 14:47:38 +0100 | [diff] [blame] | 44 | static inline bool trace_event_get_state_dynamic(TraceEvent *ev) |
| 45 | { |
Daniel P. Berrange | 9397740 | 2016-10-04 14:35:45 +0100 | [diff] [blame] | 46 | return unlikely(trace_events_enabled_count) && *ev->dstate; |
Lluís Vilanova | b1bae81 | 2013-03-05 14:47:38 +0100 | [diff] [blame] | 47 | } |
| 48 | |
Daniel P. Berrange | fe4db84 | 2016-10-04 14:35:52 +0100 | [diff] [blame] | 49 | void trace_event_register_group(TraceEvent **events); |
| 50 | |
Markus Armbruster | 175de52 | 2016-06-29 15:29:06 +0200 | [diff] [blame] | 51 | #endif /* TRACE__CONTROL_INTERNAL_H */ |