Received: from eggs.gnu.org ([208.118.235.92]:52377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1US6J7-00065F-1v for qemu-devel@nongnu.org; Tue, 16 Apr 2013 09:52:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1US6IU-0003qO-H0 for qemu-devel@nongnu.org; Tue, 16 Apr 2013 09:51:49 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:44927) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1US6IU-0003px-43 for qemu-devel@nongnu.org; Tue, 16 Apr 2013 09:51:46 -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 r3GDpjsF030945 for ; Tue, 16 Apr 2013 15:51:45 +0200 Received: from localhost (unknown [84.88.51.85]) by gw.ac.upc.edu (Postfix) with ESMTP id 168946B01C9 for ; Tue, 16 Apr 2013 15:51:45 +0200 (CEST) From: =?utf-8?b?TGx1w61z?= Vilanova Date: Tue, 16 Apr 2013 15:51:45 +0200 Message-Id: <20130416135144.21588.46180.stgit@fimbulvetr.bsc.es> In-Reply-To: <20130416134949.21588.80064.stgit@fimbulvetr.bsc.es> References: <20130416134949.21588.80064.stgit@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v2 20/23] instrument: Add client-side API to control event instrumentation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Signed-off-by: Llu=C3=ADs Vilanova --- instrument/qemu-instr/control-internal.h | 16 ++++++++ instrument/qemu-instr/control.h | 61 ++++++++++++++++++++++++= ++++++ 2 files changed, 77 insertions(+) diff --git a/instrument/qemu-instr/control-internal.h b/instrument/qemu-i= nstr/control-internal.h index 6e419e7..0ddbc74 100644 --- a/instrument/qemu-instr/control-internal.h +++ b/instrument/qemu-instr/control-internal.h @@ -11,6 +11,7 @@ #define QI__CONTROL_INTERNAL_H =20 #include "trace/control.h" +#include "instrument/control.h" =20 =20 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(); } =20 +QI_IDEF bool qi_ctrl_dynamic(void) +{ + return instr_dynamic(); +} + +QI_IDEF bool qi_ctrl_event_is_available(QIEvent *ev) +{ + return instr_event_available((TraceEvent*)ev); +} + =20 =20 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); } =20 +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/cont= rol.h index d3fadd1..3509b71 100644 --- a/instrument/qemu-instr/control.h +++ b/instrument/qemu-instr/control.h @@ -96,6 +96,13 @@ QI_IDECL bool qi_ctrl_event_is_pattern(const char *str= ); */ QI_IDECL QIEventID qi_ctrl_event_count(void); =20 +/** + * qi_ctrl_dynamic: + * + * Returns: Whether dynamic trace instrumentation is available. + */ +QI_IDECL bool qi_ctrl_dynamic(void); + =20 =20 /** @@ -112,6 +119,60 @@ QI_IDECL QIEventID qi_ctrl_event_get_id(QIEvent *ev)= ; */ QI_IDECL const char * qi_ctrl_event_get_name(QIEvent *ev); =20 +/** + * 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 e= vent + * 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() =3D=3D true + * Pre-condition: qi_ctrl_event_is_available(ev) =3D=3D 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); + =20 #if !defined(QI_TYPE_DYNAMIC) #include "instrument/qemu-instr/control-internal.h"