From patchwork Tue Mar 26 14:02:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Llu=C3=ADs_Vilanova?= X-Patchwork-Id: 231219 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D08F22C00DB for ; Wed, 27 Mar 2013 01:11:10 +1100 (EST) Received: from localhost ([::1]:49050 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKUae-0004WK-Gb for incoming@patchwork.ozlabs.org; Tue, 26 Mar 2013 10:11:04 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKURx-000054-SR for qemu-devel@nongnu.org; Tue, 26 Mar 2013 10:02:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UKURv-0008FX-Jx for qemu-devel@nongnu.org; Tue, 26 Mar 2013 10:02:05 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:37490) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKURv-0008FP-5O for qemu-devel@nongnu.org; Tue, 26 Mar 2013 10:02:03 -0400 Received: from gw.ac.upc.edu (gw.ac.upc.es [147.83.30.3]) by roura.ac.upc.es (8.13.8/8.13.8) with ESMTP id r2QE22oi005239 for ; Tue, 26 Mar 2013 15:02:02 +0100 Received: from localhost (unknown [84.88.51.85]) by gw.ac.upc.edu (Postfix) with ESMTP id 0312F6B01C4 for ; Tue, 26 Mar 2013 15:02:02 +0100 (CET) From: =?utf-8?b?TGx1w61z?= Vilanova To: qemu-devel@nongnu.org Date: Tue, 26 Mar 2013 15:02:02 +0100 Message-Id: <20130326140201.4471.37046.stgit@fimbulvetr.bsc.es> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <20130326140021.4471.99597.stgit@fimbulvetr.bsc.es> References: <20130326140021.4471.99597.stgit@fimbulvetr.bsc.es> User-Agent: StGit/0.16 MIME-Version: 1.0 X-MIME-Autoconverted: from 8bit to quoted-printable by roura.ac.upc.es id r2QE22oi005239 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 147.83.33.10 Subject: [Qemu-devel] [PATCH 18/22] instrument: Add client-side API to control tracing state of events X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Lluís Vilanova --- instrument/Makefile.objs | 1 instrument/api-trace.c | 14 +++++ instrument/qemu-instr/trace-internal.h | 27 +++++++++ instrument/qemu-instr/trace.h | 91 ++++++++++++++++++++++++++++++++ 4 files changed, 133 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 40a2b81..79b539c 100644 --- a/instrument/Makefile.objs +++ b/instrument/Makefile.objs @@ -81,5 +81,6 @@ common-obj-$(CONFIG_SOFTMMU) += hmp.o common-obj-$(CONFIG_SOFTMMU) += qmp.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..ec3a244 --- /dev/null +++ b/instrument/api-trace.c @@ -0,0 +1,14 @@ +/* + * Interface for controlling the tracing state of events. + * + * Copyright (C) 2012 Lluís Vilanova + * + * 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_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..5d23dd7 --- /dev/null +++ b/instrument/qemu-instr/trace-internal.h @@ -0,0 +1,27 @@ +/* + * Interface for controlling the tracing state of events. + * + * Copyright (C) 2012 Lluís Vilanova + * + * 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 "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); +} diff --git a/instrument/qemu-instr/trace.h b/instrument/qemu-instr/trace.h new file mode 100644 index 0000000..1f29f77 --- /dev/null +++ b/instrument/qemu-instr/trace.h @@ -0,0 +1,91 @@ +/* + * Interface for controlling the tracing state of events. + * + * Copyright (C) 2012 Lluís Vilanova + * + * 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 + +#include + + +/** + * 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_DYNAMIC) +#include "instrument/qemu-instr/trace-internal.h" +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* QI__TRACE_H */