Received: from eggs.gnu.org ([208.118.235.92]:36557) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKURN-0007Qa-IT for qemu-devel@nongnu.org; Tue, 26 Mar 2013 10:01:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UKURI-00085n-EY for qemu-devel@nongnu.org; Tue, 26 Mar 2013 10:01:29 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:37449) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKURI-00085g-51 for qemu-devel@nongnu.org; Tue, 26 Mar 2013 10:01:24 -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 r2QE1NOI005147 for ; Tue, 26 Mar 2013 15:01:23 +0100 Received: from localhost (unknown [84.88.51.85]) by gw.ac.upc.edu (Postfix) with ESMTP id F2BA76B01C4 for ; Tue, 26 Mar 2013 15:01:22 +0100 (CET) From: =?utf-8?b?TGx1w61z?= Vilanova Date: Tue, 26 Mar 2013 15:01:23 +0100 Message-Id: <20130326140122.4471.89648.stgit@fimbulvetr.bsc.es> In-Reply-To: <20130326140021.4471.99597.stgit@fimbulvetr.bsc.es> References: <20130326140021.4471.99597.stgit@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 11/22] instrument: [hmp] Add control interface List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Add HMP commands to control (un)loading of dynamic instrumentation librar= y. Signed-off-by: Llu=C3=ADs Vilanova --- Makefile.objs | 1 + hmp-commands.hx | 42 ++++++++++++++++++++++++++++++ instrument/Makefile.objs | 2 + instrument/hmp.c | 65 ++++++++++++++++++++++++++++++++++++++++= ++++++ instrument/hmp.h | 21 +++++++++++++++ monitor.c | 1 + 6 files changed, 132 insertions(+) create mode 100644 instrument/hmp.c create mode 100644 instrument/hmp.h diff --git a/Makefile.objs b/Makefile.objs index fd6779e..cc4f43e 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -102,6 +102,7 @@ common-obj-y +=3D disas/ =20 util-obj-y +=3D instrument/ target-obj-y +=3D instrument/ +common-obj-y +=3D instrument/ =20 ###################################################################### # guest agent diff --git a/hmp-commands.hx b/hmp-commands.hx index cef7708..6cce724 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1650,6 +1650,48 @@ STEXI show available trace events and their state ETEXI =20 + { + .name =3D "instr-dynamic", + .args_type =3D "", + .params =3D "", + .help =3D "whether dynamic trace instrumentation is availa= ble", + .mhandler.cmd =3D hmp_instr_dynamic, + }, + +STEXI +@item instr-dynamic +@findex instr-dynamic +Whether dynamic trace instrumentation is available. +ETEXI + + { + .name =3D "instr-load", + .args_type =3D "path:F,args:s?", + .params =3D "path [args]", + .help =3D "load a dynamic instrumentation library", + .mhandler.cmd =3D hmp_instr_load, + }, + +STEXI +@item instr-load @var{path} [name=3Dvalue[,...]] +@findex instr-load +Load a dynamic instrumentation library. +ETEXI + + { + .name =3D "instr-unload", + .args_type =3D "", + .params =3D "", + .help =3D "unload the current dynamic instrumentation libr= ary", + .mhandler.cmd =3D hmp_instr_unload, + }, + +STEXI +@item instr-unload +@findex instr-unload +Unload the current dynamic instrumentation library. +ETEXI + STEXI @end table ETEXI diff --git a/instrument/Makefile.objs b/instrument/Makefile.objs index 0d3b70b..adae4a9 100644 --- a/instrument/Makefile.objs +++ b/instrument/Makefile.objs @@ -65,3 +65,5 @@ endif # Control code =20 target-obj-y +=3D control.o + +common-obj-$(CONFIG_SOFTMMU) +=3D hmp.o diff --git a/instrument/hmp.c b/instrument/hmp.c new file mode 100644 index 0000000..82fdcd7 --- /dev/null +++ b/instrument/hmp.c @@ -0,0 +1,65 @@ +/* + * HMP interface for dynamic trace instrumentation control commands. + * + * Copyright (C) 2012 Llu=C3=ADs Vilanova + * + * This work is licensed under the terms of the GNU GPL, version 2 or la= ter. + * See the COPYING file in the top-level directory. + */ + +#include "instrument/hmp.h" + +#include + +#include "monitor/monitor.h" +#include "instrument/control.h" + + +void hmp_instr_dynamic(Monitor *mon, const QDict *qdict) +{ + monitor_printf(mon, instr_dynamic() ? "true\n" : "false\n"); +} + +void hmp_instr_load(Monitor *mon, const QDict *qdict) +{ + /* @todo: Unify with qerror messages? */ + + const char *path =3D qdict_get_try_str(qdict, "path"); + const char *args =3D qdict_get_try_str(qdict, "args"); + InstrLoadError err =3D instr_load(path, args); + switch (err) { + case INSTR_LOAD_OK: + monitor_printf(mon, "OK\n"); + break; + case INSTR_LOAD_UNAVAILABLE: + monitor_printf(mon, "Not available\n"); + break; + case INSTR_LOAD_LOADED: + monitor_printf(mon, "Already loaded\n"); + break; + case INSTR_LOAD_DL: + monitor_printf(mon, "Error loading library: %s\n", dlerror()); + break; + } +} + +void hmp_instr_unload(Monitor *mon, const QDict *qdict) +{ + /* @todo: Unify with qerror messages? */ + + InstrLoadError err =3D instr_unload(); + switch (err) { + case INSTR_UNLOAD_OK: + monitor_printf(mon, "OK\n"); + break; + case INSTR_UNLOAD_UNAVAILABLE: + monitor_printf(mon, "Not available\n"); + break; + case INSTR_UNLOAD_UNLOADED: + monitor_printf(mon, "Already unloaded\n"); + break; + case INSTR_UNLOAD_DL: + monitor_printf(mon, "Error unloading library: %s\n", dlerror()); + break; + } +} diff --git a/instrument/hmp.h b/instrument/hmp.h new file mode 100644 index 0000000..b7d56dd --- /dev/null +++ b/instrument/hmp.h @@ -0,0 +1,21 @@ +/* + * HMP interface for dynamic trace instrumentation control commands. + * + * Copyright (C) 2012 Llu=C3=ADs Vilanova + * + * This work is licensed under the terms of the GNU GPL, version 2 or la= ter. + * See the COPYING file in the top-level directory. + */ + +#ifndef INSTRUMENT__HMP_H +#define INSTRUMENT__HMP_H + +#include "qemu-common.h" +#include "qapi/qmp/qdict.h" + + +void hmp_instr_dynamic(Monitor *mon, const QDict *qdict); +void hmp_instr_load(Monitor *mon, const QDict *qdict); +void hmp_instr_unload(Monitor *mon, const QDict *qdict); + +#endif /* INSTRUMENT__HMP_H */ diff --git a/monitor.c b/monitor.c index 2fff049..de4403d 100644 --- a/monitor.c +++ b/monitor.c @@ -68,6 +68,7 @@ #include "exec/memory.h" #include "qmp-commands.h" #include "hmp.h" +#include "instrument/hmp.h" #include "qemu/thread.h" =20 /* for pic/irq_info */