[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 20/24] instrument: Add client-side API to control
From: |
Lluís Vilanova |
Subject: |
[Qemu-devel] [PATCH v3 20/24] instrument: Add client-side API to control tracing state of events |
Date: |
Sun, 21 Apr 2013 21:13:22 +0200 |
User-agent: |
StGit/0.16 |
Signed-off-by: Lluís Vilanova <address@hidden>
---
instrument/Makefile.objs | 1
instrument/api-trace.c | 14 +++++
instrument/qemu-instr/trace-internal.h | 32 +++++++++++
instrument/qemu-instr/trace.h | 91 ++++++++++++++++++++++++++++++++
4 files changed, 138 insertions(+)
create mode 100644 instrument/api-trace.c
create mode 100644 instrument/qemu-instr/trace-internal.h
create mode 100644 instrument/qemu-instr/trace.h
diff --git a/instrument/Makefile.objs b/instrument/Makefile.objs
index 1fcf77e..cd55f6f 100644
--- a/instrument/Makefile.objs
+++ b/instrument/Makefile.objs
@@ -82,5 +82,6 @@ common-obj-$(CONFIG_SOFTMMU) += qmp.o
common-obj-$(CONFIG_SOFTMMU) += hmp.o
target-obj-y += api-control.o
+target-obj-y += api-trace.o
QEMU_CFLAGS += -I$(BUILD_DIR)/instrument -I$(SRC_PATH)/instrument
diff --git a/instrument/api-trace.c b/instrument/api-trace.c
new file mode 100644
index 0000000..97e135a
--- /dev/null
+++ b/instrument/api-trace.c
@@ -0,0 +1,14 @@
+/*
+ * Interface for controlling the tracing state of events.
+ *
+ * Copyright (C) 2012-2013 Lluís Vilanova <address@hidden>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "instrument/qemu-instr/trace.h"
+
+#if defined(QI_TYPE_CONFIG_DYNAMIC)
+#include "instrument/qemu-instr/trace-internal.h"
+#endif
diff --git a/instrument/qemu-instr/trace-internal.h
b/instrument/qemu-instr/trace-internal.h
new file mode 100644
index 0000000..2d6eec4
--- /dev/null
+++ b/instrument/qemu-instr/trace-internal.h
@@ -0,0 +1,32 @@
+/*
+ * Interface for controlling the tracing state of events.
+ *
+ * Copyright (C) 2012-2013 Lluís Vilanova <address@hidden>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef QI__TRACE_INTERNAL_H
+#define QI__TRACE_INTERNAL_H
+
+#include "trace/control.h"
+
+
+QI_IDEF bool qi_trace_event_get_state_static(QIEvent *ev)
+{
+ return trace_event_get_state_static((TraceEvent*)ev);
+}
+
+QI_IDEF bool qi_trace_event_get_state_dynamic(QIEvent *ev)
+{
+ return trace_event_get_state_dynamic((TraceEvent*)ev);
+}
+
+QI_IDEF void qi_trace_event_set_state_dynamic(QIEvent *ev, bool state)
+{
+ assert(qi_trace_event_get_state_static(ev));
+ return trace_event_set_state_dynamic((TraceEvent*)ev, state);
+}
+
+#endif /* QI__TRACE_INTERNAL_H */
diff --git a/instrument/qemu-instr/trace.h b/instrument/qemu-instr/trace.h
new file mode 100644
index 0000000..fd9172a
--- /dev/null
+++ b/instrument/qemu-instr/trace.h
@@ -0,0 +1,91 @@
+/*
+ * Interface for controlling the tracing state of events.
+ *
+ * Copyright (C) 2012-2013 Lluís Vilanova <address@hidden>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef QI__TRACE_H
+#define QI__TRACE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdbool.h>
+
+#include <qemu-instr/control.h>
+
+
+/**
+ * SECTION: trace
+ * @section_id: qi-trace
+ * @title: QEMU tracing event control interface
+ */
+
+/**
+ * qi_trace_event_get_state:
+ * @id: Event identifier.
+ *
+ * Get the tracing state of an event (both static and dynamic).
+ *
+ * If the event has the disabled property, the check will have no performance
+ * impact.
+ *
+ * As a down side, you must always use an immediate #QIEventID value.
+ */
+#define qi_trace_event_get_state(id) \
+ ((id ##_ENABLED) && qi_trace_event_get_state_dynamic(qi_ctrl_event_id(id)))
+
+/**
+ * qi_trace_event_get_state_static:
+ * @id: Event identifier.
+ *
+ * Get the static tracing state of an event.
+ *
+ * Use the define 'QI_EVENT_${EVENT}_ENABLED' for compile-time checks (it will
+ * be set to 1 or 0 according to the presence of the disabled property).
+ */
+QI_IDECL bool qi_trace_event_get_state_static(QIEvent *ev);
+
+/**
+ * qi_trace_event_get_state_dynamic:
+ *
+ * Get the dynamic tracing state of an event.
+ */
+QI_IDECL bool qi_trace_event_get_state_dynamic(QIEvent *ev);
+
+/**
+ * qi_trace_event_set_state:
+ *
+ * Set the tracing state of an event.
+ */
+#define qi_trace_event_set_state(id, state) \
+ do { \
+ if ((id ##_ENABLED)) { \
+ QIEvent *_e = qi_ctrl_event_id(id); \
+ qi_trace_event_set_state_dynamic(_e, state); \
+ } \
+ } while (0)
+
+/**
+ * qi_trace_event_set_state_dynamic:
+ *
+ * Set the dynamic tracing state of an event.
+ *
+ * Pre-condition: qi_trace_event_get_state_static(ev) == true
+ */
+QI_IDECL void qi_trace_event_set_state_dynamic(QIEvent *ev, bool state);
+
+
+#if !defined(QI_TYPE_CONFIG_DYNAMIC)
+#include "instrument/qemu-instr/trace-internal.h"
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* QI__TRACE_H */
- [Qemu-devel] [PATCH v3 14/24] instrument: Add internal control interface, (continued)
- [Qemu-devel] [PATCH v3 15/24] instrument: [qmp, qapi] Add control interface, Lluís Vilanova, 2013/04/21
- [Qemu-devel] [PATCH v3 16/24] instrument: [hmp] Add control interface, Lluís Vilanova, 2013/04/21
- [Qemu-devel] [PATCH v3 17/24] Let makefiles add entries to the set of target architecture objects, Lluís Vilanova, 2013/04/21
- [Qemu-devel] [PATCH v3 18/24] instrument: Add commandline options to start with an instrumentation library, Lluís Vilanova, 2013/04/21
- [Qemu-devel] [PATCH v3 19/24] instrument: Add client-side API to enumerate events, Lluís Vilanova, 2013/04/21
- [Qemu-devel] [PATCH v3 20/24] instrument: Add client-side API to control tracing state of events,
Lluís Vilanova <=
- [Qemu-devel] [PATCH v3 21/24] instrument: Add client-side API to control event instrumentation, Lluís Vilanova, 2013/04/21
- [Qemu-devel] [PATCH v3 22/24] build: Fix installation of target-dependant files, Lluís Vilanova, 2013/04/21
- [Qemu-devel] [PATCH v3 23/24] instrument: Install headers for dynamic instrumentation clients, Lluís Vilanova, 2013/04/21
- [Qemu-devel] [PATCH v3 24/24] trace: Do not use the word 'new' in event arguments, Lluís Vilanova, 2013/04/21
- Re: [Qemu-devel] [RFC][PATCH v3 00/24] instrument: Let the user wrap/override specific event tracing routines, Stefan Hajnoczi, 2013/04/24