[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 12/23] instrument: [hmp] Add control interface
From: |
Lluís Vilanova |
Subject: |
[Qemu-devel] [PATCH v2 12/23] instrument: [hmp] Add control interface |
Date: |
Tue, 16 Apr 2013 15:50:58 +0200 |
User-agent: |
StGit/0.16 |
Add HMP commands to control (un)loading of dynamic instrumentation library.
Signed-off-by: Lluís Vilanova <address@hidden>
---
Makefile.objs | 1 +
hmp-commands.hx | 42 +++++++++++++++++++++++++++++
instrument/Makefile.objs | 2 +
instrument/hmp.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++
instrument/hmp.h | 21 +++++++++++++++
monitor.c | 1 +
6 files changed, 133 insertions(+)
create mode 100644 instrument/hmp.c
create mode 100644 instrument/hmp.h
diff --git a/Makefile.objs b/Makefile.objs
index 4fb565b..151183d 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -95,6 +95,7 @@ common-obj-y += disas/
tools-obj-y += instrument/
target-obj-y += instrument/
+common-obj-y += instrument/
######################################################################
# guest agent
diff --git a/hmp-commands.hx b/hmp-commands.hx
index 3d98604..7b5ae2a 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1653,6 +1653,48 @@ STEXI
show available trace events and their state
ETEXI
+ {
+ .name = "instr-dynamic",
+ .args_type = "",
+ .params = "",
+ .help = "whether dynamic trace instrumentation is available",
+ .mhandler.cmd = hmp_instr_dynamic,
+ },
+
+STEXI
address@hidden instr-dynamic
address@hidden instr-dynamic
+Whether dynamic trace instrumentation is available.
+ETEXI
+
+ {
+ .name = "instr-load",
+ .args_type = "path:F,args:s?",
+ .params = "path [args]",
+ .help = "load a dynamic instrumentation library",
+ .mhandler.cmd = hmp_instr_load,
+ },
+
+STEXI
address@hidden instr-load @var{path} [name=value[,...]]
address@hidden instr-load
+Load a dynamic instrumentation library.
+ETEXI
+
+ {
+ .name = "instr-unload",
+ .args_type = "",
+ .params = "",
+ .help = "unload the current dynamic instrumentation library",
+ .mhandler.cmd = hmp_instr_unload,
+ },
+
+STEXI
address@hidden instr-unload
address@hidden instr-unload
+Unload the current dynamic instrumentation library.
+ETEXI
+
STEXI
@end table
ETEXI
diff --git a/instrument/Makefile.objs b/instrument/Makefile.objs
index e571c71..02cc5b7 100644
--- a/instrument/Makefile.objs
+++ b/instrument/Makefile.objs
@@ -66,3 +66,5 @@ endif
# Control code
target-obj-y += control.o
+
+common-obj-$(CONFIG_SOFTMMU) += hmp.o
diff --git a/instrument/hmp.c b/instrument/hmp.c
new file mode 100644
index 0000000..53c2da7
--- /dev/null
+++ b/instrument/hmp.c
@@ -0,0 +1,66 @@
+/*
+ * HMP interface for dynamic trace instrumentation control commands.
+ *
+ * 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/hmp.h"
+
+#include <dlfcn.h>
+
+#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 = qdict_get_try_str(qdict, "path");
+ const char *args = qdict_get_try_str(qdict, "args");
+ const char *argv[1] = {args};
+ InstrLoadError err = instr_load(path, 1, argv);
+ 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 = 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..a91b6bc
--- /dev/null
+++ b/instrument/hmp.h
@@ -0,0 +1,21 @@
+/*
+ * HMP interface for dynamic trace instrumentation control commands.
+ *
+ * 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 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 a8f49d9..22284cb 100644
--- a/monitor.c
+++ b/monitor.c
@@ -69,6 +69,7 @@
#include "exec/memory.h"
#include "qmp-commands.h"
#include "hmp.h"
+#include "instrument/hmp.h"
#include "qemu/thread.h"
/* for pic/irq_info */
- [Qemu-devel] [PATCH v2 14/23] [trivial] Set the input root directory when parsing QAPI files, (continued)
- [Qemu-devel] [PATCH v2 14/23] [trivial] Set the input root directory when parsing QAPI files, Lluís Vilanova, 2013/04/16
- [Qemu-devel] [PATCH v2 10/23] instrument: [dynamic] Call dynamically linked user-provided routines, Lluís Vilanova, 2013/04/16
- [Qemu-devel] [PATCH v2 16/23] Let makefiles add entries to the set of target architecture objects, Lluís Vilanova, 2013/04/16
- [Qemu-devel] [PATCH v2 01/23] instrument: Add documentation, Lluís Vilanova, 2013/04/16
- [Qemu-devel] [PATCH v2 15/23] instrument: [qmp, qapi] Add control interface, Lluís Vilanova, 2013/04/16
- [Qemu-devel] [PATCH v2 03/23] trace: Let the user specify her own trace-events file, Lluís Vilanova, 2013/04/16
- [Qemu-devel] [PATCH v2 11/23] instrument: Add internal control interface, Lluís Vilanova, 2013/04/16
- [Qemu-devel] [PATCH v2 05/23] trace: Minimize inclusions of "qemu-common.h" to avoid inclusion loops, Lluís Vilanova, 2013/04/16
- [Qemu-devel] [PATCH v2 12/23] instrument: [hmp] Add control interface,
Lluís Vilanova <=
- [Qemu-devel] [PATCH v2 23/23] trace: Do not use the word 'new' in event arguments, Lluís Vilanova, 2013/04/16
- Re: [Qemu-devel] [RFC][PATCH v2 00/23] instrument: Let the user wrap/override specific event tracing routines, Lluís Vilanova, 2013/04/16