]> git.proxmox.com Git - mirror_qemu.git/blame - trace/control-internal.h
i386: Update new x86_apicid parsing rules with die_offset support
[mirror_qemu.git] / trace / control-internal.h
CommitLineData
b1bae816
LV
1/*
2 * Interface for configuring and controlling the state of tracing events.
3 *
17f7ac75 4 * Copyright (C) 2011-2016 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
48151859
LV
13#include "qom/cpu.h"
14
15
43b48cfc 16extern int trace_events_enabled_count;
b1bae816
LV
17
18
b1bae816
LV
19static inline bool trace_event_is_pattern(const char *str)
20{
21 assert(str != NULL);
22 return strchr(str, '*') != NULL;
23}
24
ef4c9fc8 25static inline uint32_t trace_event_get_id(TraceEvent *ev)
b1bae816
LV
26{
27 assert(ev != NULL);
28 return ev->id;
29}
30
ef4c9fc8 31static inline uint32_t trace_event_get_vcpu_id(TraceEvent *ev)
17f7ac75
LV
32{
33 return ev->vcpu_id;
34}
35
36static inline bool trace_event_is_vcpu(TraceEvent *ev)
37{
ef4c9fc8 38 return ev->vcpu_id != TRACE_VCPU_EVENT_NONE;
17f7ac75
LV
39}
40
b1bae816
LV
41static inline const char * trace_event_get_name(TraceEvent *ev)
42{
43 assert(ev != NULL);
44 return ev->name;
45}
46
47static inline bool trace_event_get_state_static(TraceEvent *ev)
48{
49 assert(ev != NULL);
50 return ev->sstate;
51}
52
93977402
DB
53/* it's on fast path, avoid consistency checks (asserts) */
54#define trace_event_get_state_dynamic_by_id(id) \
55 (unlikely(trace_events_enabled_count) && _ ## id ## _DSTATE)
585ec727 56
b1bae816
LV
57static inline bool trace_event_get_state_dynamic(TraceEvent *ev)
58{
93977402 59 return unlikely(trace_events_enabled_count) && *ev->dstate;
b1bae816
LV
60}
61
ef4c9fc8
DB
62static inline bool
63trace_event_get_vcpu_state_dynamic_by_vcpu_id(CPUState *vcpu,
64 uint32_t vcpu_id)
b1bae816 65{
48151859
LV
66 /* it's on fast path, avoid consistency checks (asserts) */
67 if (unlikely(trace_events_enabled_count)) {
ef4c9fc8 68 return test_bit(vcpu_id, vcpu->trace_dstate);
48151859
LV
69 } else {
70 return false;
71 }
72}
73
74static inline bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu,
75 TraceEvent *ev)
76{
ef4c9fc8 77 uint32_t vcpu_id;
48151859 78 assert(trace_event_is_vcpu(ev));
ef4c9fc8
DB
79 vcpu_id = trace_event_get_vcpu_id(ev);
80 return trace_event_get_vcpu_state_dynamic_by_vcpu_id(vcpu, vcpu_id);
b1bae816
LV
81}
82
fe4db84d
DB
83
84void trace_event_register_group(TraceEvent **events);
85
175de524 86#endif /* TRACE__CONTROL_INTERNAL_H */