From patchwork Sun Apr 21 19:13:28 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: 238236 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 A1D422C00F2 for ; Mon, 22 Apr 2013 05:14:15 +1000 (EST) Received: from localhost ([::1]:46965 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UTziH-0001nS-PM for incoming@patchwork.ozlabs.org; Sun, 21 Apr 2013 15:14:13 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UTzha-0001VE-K7 for qemu-devel@nongnu.org; Sun, 21 Apr 2013 15:13:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UTzhZ-00020X-A1 for qemu-devel@nongnu.org; Sun, 21 Apr 2013 15:13:30 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:33220) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UTzhZ-00020P-07 for qemu-devel@nongnu.org; Sun, 21 Apr 2013 15:13:29 -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 r3LJDS3b001883 for ; Sun, 21 Apr 2013 21:13:28 +0200 Received: from localhost (unknown [84.88.51.85]) by gw.ac.upc.edu (Postfix) with ESMTP id 3DFAE6B01A4 for ; Sun, 21 Apr 2013 21:13:28 +0200 (CEST) From: =?utf-8?b?TGx1w61z?= Vilanova To: qemu-devel@nongnu.org Date: Sun, 21 Apr 2013 21:13:28 +0200 Message-Id: <20130421191327.8947.70105.stgit@fimbulvetr.bsc.es> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <20130421191129.8947.77964.stgit@fimbulvetr.bsc.es> References: <20130421191129.8947.77964.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 r3LJDS3b001883 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 147.83.33.10 Subject: [Qemu-devel] [PATCH v3 21/24] instrument: Add client-side API to control event instrumentation 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/qemu-instr/control-internal.h | 16 ++++++ instrument/qemu-instr/control.h | 75 ++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/instrument/qemu-instr/control-internal.h b/instrument/qemu-instr/control-internal.h index 6e419e7..953f2d1 100644 --- a/instrument/qemu-instr/control-internal.h +++ b/instrument/qemu-instr/control-internal.h @@ -11,6 +11,7 @@ #define QI__CONTROL_INTERNAL_H #include "trace/control.h" +#include "instrument/control.h" QI_IDEF QIEvent* qi_ctrl_event_id(QIEventID id) @@ -38,6 +39,16 @@ QI_IDEF QIEventID qi_ctrl_event_count(void) return (QIEventID)trace_event_count(); } +QI_IDEF QIType qi_ctrl_type(void) +{ + return instr_type(); +} + +QI_IDEF bool qi_ctrl_event_is_available(QIEvent *ev) +{ + return instr_event_available((TraceEvent*)ev); +} + QI_IDEF QIEventID qi_ctrl_event_get_id(QIEvent *ev) @@ -50,4 +61,9 @@ QI_IDEF const char * qi_ctrl_event_get_name(QIEvent *ev) return trace_event_get_name((TraceEvent*)ev); } +QI_IDEF bool qi_ctrl_event_set(QIEvent *ev, void *cb) +{ + return instr_event_set((TraceEvent*)ev, cb); +} + #endif /* QI__CONTROL_INTERNAL_H */ diff --git a/instrument/qemu-instr/control.h b/instrument/qemu-instr/control.h index 8687b1d..037897b 100644 --- a/instrument/qemu-instr/control.h +++ b/instrument/qemu-instr/control.h @@ -96,6 +96,27 @@ QI_IDECL bool qi_ctrl_event_is_pattern(const char *str); */ QI_IDECL QIEventID qi_ctrl_event_count(void); +/** + * QIType: + * @QI_TYPE_NONE: No instrumentation support. + * @QI_TYPE_STATIC: Static instrumentation support. + * @QI_TYPE_DYNAMIC: Dynamic instrumentation support. + * + * Instrumentation type supported by the system. + */ +typedef enum { + QI_TYPE_NONE, + QI_TYPE_STATIC, + QI_TYPE_DYNAMIC, +} QIType; + +/** + * qi_ctrl_type: + * + * Returns: Instrumentation type supported by the system. + */ +QI_IDECL QIType qi_ctrl_type(void); + /** @@ -112,6 +133,60 @@ QI_IDECL QIEventID qi_ctrl_event_get_id(QIEvent *ev); */ QI_IDECL const char * qi_ctrl_event_get_name(QIEvent *ev); +/** + * qi_ctrl_event_is_available: + * + * Returns: Whether the given event has the 'instrument' property. + */ +QI_IDECL bool qi_ctrl_event_is_available(QIEvent *ev); + + +/** + * QI_CTRL_INSTR_NOP: + * + * Set instrumentation callback to no-operation. + * (qi_event_${name}_nop). + */ +#define QI_CTRL_INSTR_NOP ((void*)NULL) + +/** + * QI_CTRL_INSTR_NEXT: + * + * Set instrumentation callback to the "next logical step" + * (qi_event_${name}_trace). + */ +#define QI_CTRL_INSTR_NEXT ((void*)1) + +/** + * QI_CTRL_INSTR_AUTO: + * + * Automatically set callback to proper routine. + * + * Looks for a symbol name in the instrumentation library matching the event + * name (qi_event_${name}). + */ +#define QI_CTRL_INSTR_AUTO ((void*)2) + +/** + * qi_ctrl_event_set: + * @ev: Event descriptor. + * @cb: Pointer to instrumentation callback. + * + * Set the instrumentation callback for the given event. + * + * @cb can also be set to any of the QI_CTRL_INSTR_* special values. + * + * #false indicates that the instrumentation library does not export the + * appropriate symbol for the instrumentation routine. + * + * Pre-condition: qi_ctrl_dynamic() == true + * Pre-condition: qi_ctrl_event_is_available(ev) == true + * + * Returns: Whether the callback could be set (if @cb was QI_CTRL_INSTR_AUTO, + * otherwise always #true). + */ +QI_IDECL bool qi_ctrl_event_set(QIEvent *ev, void *cb); + #if !defined(QI_TYPE_CONFIG_DYNAMIC) #include "instrument/qemu-instr/control-internal.h"