qemu

FORK: QEMU emulator
git clone https://git.neptards.moe/neptards/qemu.git
Log | Files | Refs | Submodules | LICENSE

control-vcpu.h (1869B)


      1 /*
      2  * Interface for configuring and controlling the state of tracing events.
      3  *
      4  * Copyright (C) 2011-2016 LluĂ­s Vilanova <vilanova@ac.upc.edu>
      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_VCPU_H
     11 #define TRACE__CONTROL_VCPU_H
     12 
     13 #include "control.h"
     14 #include "event-internal.h"
     15 #include "hw/core/cpu.h"
     16 
     17 /**
     18  * trace_event_get_vcpu_state:
     19  * @vcpu: Target vCPU.
     20  * @id: Event identifier name.
     21  *
     22  * Get the tracing state of an event (both static and dynamic) for the given
     23  * vCPU.
     24  *
     25  * If the event has the disabled property, the check will have no performance
     26  * impact.
     27  */
     28 #define trace_event_get_vcpu_state(vcpu, id)                            \
     29     ((id ##_ENABLED) &&                                                 \
     30      trace_event_get_vcpu_state_dynamic_by_vcpu_id(                     \
     31          vcpu, _ ## id ## _EVENT.vcpu_id))
     32 
     33 /**
     34  * trace_event_get_vcpu_state_dynamic:
     35  *
     36  * Get the dynamic tracing state of an event for the given vCPU.
     37  */
     38 static bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu, TraceEvent *ev);
     39 
     40 #include "control-internal.h"
     41 
     42 static inline bool
     43 trace_event_get_vcpu_state_dynamic_by_vcpu_id(CPUState *vcpu,
     44                                               uint32_t vcpu_id)
     45 {
     46     /* it's on fast path, avoid consistency checks (asserts) */
     47     if (unlikely(trace_events_enabled_count)) {
     48         return test_bit(vcpu_id, vcpu->trace_dstate);
     49     } else {
     50         return false;
     51     }
     52 }
     53 
     54 static inline bool trace_event_get_vcpu_state_dynamic(CPUState *vcpu,
     55                                                       TraceEvent *ev)
     56 {
     57     uint32_t vcpu_id;
     58     assert(trace_event_is_vcpu(ev));
     59     vcpu_id = trace_event_get_vcpu_id(ev);
     60     return trace_event_get_vcpu_state_dynamic_by_vcpu_id(vcpu, vcpu_id);
     61 }
     62 
     63 #endif