From patchwork Wed Apr 6 18:35:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?Q?Llu=C3=ADs?= X-Patchwork-Id: 90054 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 69785B6F0B for ; Thu, 7 Apr 2011 04:47:00 +1000 (EST) Received: from localhost ([127.0.0.1]:51707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7XkE-0000Uw-Jm for incoming@patchwork.ozlabs.org; Wed, 06 Apr 2011 14:46:22 -0400 Received: from [140.186.70.92] (port=36103 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7XaO-0004ZP-E1 for qemu-devel@nongnu.org; Wed, 06 Apr 2011 14:36:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q7XaM-0001vp-Io for qemu-devel@nongnu.org; Wed, 06 Apr 2011 14:36:12 -0400 Received: from mailout-de.gmx.net ([213.165.64.23]:36812) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Q7XaM-0001vc-7H for qemu-devel@nongnu.org; Wed, 06 Apr 2011 14:36:10 -0400 Received: (qmail invoked by alias); 06 Apr 2011 18:36:06 -0000 Received: from unknown (EHLO localhost) [84.88.53.92] by mail.gmx.net (mp013) with SMTP; 06 Apr 2011 20:36:06 +0200 X-Authenticated: #12333383 X-Provags-ID: V01U2FsdGVkX18y7V0C7ZMyzZWRy6rrcoOidTCdJUCVGSSqGwHqS7 nwaGXOlV4nJW9Y To: qemu-devel@nongnu.org From: =?utf-8?b?TGx1w61z?= Date: Wed, 06 Apr 2011 20:35:03 +0200 Message-ID: <20110406183503.22854.39534.stgit@ginnungagap.bsc.es> In-Reply-To: <20110406183341.22854.93929.stgit@ginnungagap.bsc.es> References: <20110406183341.22854.93929.stgit@ginnungagap.bsc.es> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 213.165.64.23 Cc: stefanha@gmail.com, chouteau@adacore.com Subject: [Qemu-devel] [PATCH v2 10/11] trace-state: [stderr] add support for dynamically enabling/disabling events X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This includes all the control interfaces already provided by the "simple" backend (i.e., command line, programmatic and monitor). Signed-off-by: Fabien Chouteau Signed-off-by: LluĂ­s Vilanova --- Makefile.objs | 8 +++++++- configure | 3 +++ docs/tracing.txt | 6 ++---- hmp-commands.hx | 10 ++++++++-- monitor.c | 8 +++++++- qemu-config.c | 7 ++++--- qemu-options.hx | 8 +++++++- scripts/tracetool | 33 ++++++++++++++++++++++++++++----- stderrtrace.c | 24 ++++++++++++++++++++++++ stderrtrace.h | 14 ++++++++++++++ vl.c | 11 +++++++++-- 11 files changed, 113 insertions(+), 19 deletions(-) create mode 100644 stderrtrace.c create mode 100644 stderrtrace.h diff --git a/Makefile.objs b/Makefile.objs index c05f5e5..f7cd67b 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -342,15 +342,22 @@ trace-dtrace.o: trace-dtrace.dtrace $(GENERATED_HEADERS) $(call quiet-command,dtrace -o $@ -G -s $<, " GEN trace-dtrace.o") simpletrace.o: simpletrace.c $(GENERATED_HEADERS) +stderrtrace.o: stderrtrace.c $(GENERATED_HEADERS) ifeq ($(TRACE_BACKEND),dtrace) trace-obj-y = trace-dtrace.o else trace-obj-y = trace.o + ifeq ($(TRACE_BACKEND),simple) trace-obj-y += simpletrace.o user-obj-y += qemu-timer-common.o endif + +ifeq ($(TRACE_BACKEND),stderr) +trace-obj-y += stderrtrace.o +endif + endif ###################################################################### @@ -361,4 +368,3 @@ libcacard-y = cac.o event.o vcard.o vreader.o vcard_emul_nss.o vcard_emul_type.o vl.o: QEMU_CFLAGS+=$(GPROF_CFLAGS) vl.o: QEMU_CFLAGS+=$(SDL_CFLAGS) - diff --git a/configure b/configure index 8754060..7dc9bdc 100755 --- a/configure +++ b/configure @@ -2933,6 +2933,9 @@ echo "TRACE_BACKEND=$trace_backend" >> $config_host_mak if test "$trace_backend" = "simple"; then echo "CONFIG_SIMPLE_TRACE=y" >> $config_host_mak fi +if test "$trace_backend" = "stderr"; then + echo "CONFIG_STDERR_TRACE=y" >> $config_host_mak +fi # Set the appropriate trace file. if test "$trace_backend" = "simple"; then trace_file="\"$trace_file-%u\"" diff --git a/docs/tracing.txt b/docs/tracing.txt index 26b221f..51fe0ad 100644 --- a/docs/tracing.txt +++ b/docs/tracing.txt @@ -134,10 +134,8 @@ effectively turns trace events into debug printfs. This is the simplest backend and can be used together with existing code that uses DPRINTF(). -Note that with this backend trace events cannot be programmatically -enabled/disabled. Thus, in order to trim down the amount of output and the -performance impact of tracing, you might want to add the "disable" property in -the "trace-events" file for those events you are not interested in. +See the documentation in the "simple" backend for instruction on how to control +trace event states from the command line, the monitor and/or programmatically. === Simpletrace === diff --git a/hmp-commands.hx b/hmp-commands.hx index c3be311..7cca351 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -180,7 +180,7 @@ STEXI Output logs to @var{filename}. ETEXI -#ifdef CONFIG_SIMPLE_TRACE +#if defined(CONFIG_SIMPLE_TRACE) || defined(CONFIG_STDERR_TRACE) { .name = "trace-event", .args_type = "name:s,option:b", @@ -194,7 +194,9 @@ STEXI @findex trace-event changes status of a trace event ETEXI +#endif +#if defined(CONFIG_SIMPLE_TRACE) { .name = "trace-file", .args_type = "op:s?,arg:F?", @@ -1355,10 +1357,14 @@ show roms @end table ETEXI -#ifdef CONFIG_SIMPLE_TRACE +#if defined(CONFIG_SIMPLE_TRACE) STEXI @item info trace show contents of trace buffer +ETEXI +#endif +#if defined(CONFIG_SIMPLE_TRACE) || defined(CONFIG_STDERR_TRACE) +STEXI @item info trace-events show available trace events and their state ETEXI diff --git a/monitor.c b/monitor.c index 377424e..7991c6c 100644 --- a/monitor.c +++ b/monitor.c @@ -590,7 +590,7 @@ static void do_help_cmd(Monitor *mon, const QDict *qdict) help_cmd(mon, qdict_get_try_str(qdict, "name")); } -#if defined(CONFIG_SIMPLE_TRACE) +#if defined(CONFIG_SIMPLE_TRACE) || defined(CONFIG_STDERR_TRACE) static void do_change_trace_event_state(Monitor *mon, const QDict *qdict) { const char *tp_name = qdict_get_str(qdict, "name"); @@ -601,7 +601,9 @@ static void do_change_trace_event_state(Monitor *mon, const QDict *qdict) monitor_printf(mon, "unknown event name \"%s\"\n", tp_name); } } +#endif +#if defined(CONFIG_SIMPLE_TRACE) static void do_trace_file(Monitor *mon, const QDict *qdict) { const char *op = qdict_get_try_str(qdict, "op"); @@ -999,7 +1001,9 @@ static void do_info_trace(Monitor *mon) { st_print_trace((FILE *)mon, &monitor_fprintf); } +#endif +#if defined(CONFIG_SIMPLE_TRACE) || defined(CONFIG_STDERR_TRACE) static void do_info_trace_events(Monitor *mon) { st_print_trace_events((FILE *)mon, &monitor_fprintf); @@ -3103,6 +3107,8 @@ static const mon_cmd_t info_cmds[] = { .help = "show current contents of trace buffer", .mhandler.info = do_info_trace, }, +#endif +#if defined(CONFIG_SIMPLE_TRACE) || defined(CONFIG_STDERR_TRACE) { .name = "trace-events", .args_type = "", diff --git a/qemu-config.c b/qemu-config.c index 7c7357f..7a20971 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -297,7 +297,7 @@ static QemuOptsList qemu_mon_opts = { }, }; -#if defined(CONFIG_SIMPLE_TRACE) +#if defined(CONFIG_SIMPLE_TRACE) || defined(CONFIG_STDERR_TRACE) static QemuOptsList qemu_trace_opts = { .name = "trace", .implied_opt_name = "trace", @@ -306,7 +306,8 @@ static QemuOptsList qemu_trace_opts = { { .name = "file", .type = QEMU_OPT_STRING, - },{ + }, + { .name = "events", .type = QEMU_OPT_STRING, }, @@ -464,7 +465,7 @@ static QemuOptsList *vm_config_groups[32] = { &qemu_global_opts, &qemu_mon_opts, &qemu_cpudef_opts, -#if defined(CONFIG_SIMPLE_TRACE) +#if defined(CONFIG_SIMPLE_TRACE) || defined(CONFIG_STDERR_TRACE) &qemu_trace_opts, #endif &qemu_option_rom_opts, diff --git a/qemu-options.hx b/qemu-options.hx index ff8e75d..1bcc27b 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2356,9 +2356,13 @@ Normally QEMU loads a configuration file from @var{sysconfdir}/qemu.conf and @var{sysconfdir}/target-@var{ARCH}.conf on startup. The @code{-nodefconfig} option will prevent QEMU from loading these configuration files at startup. ETEXI -#ifdef CONFIG_SIMPLE_TRACE +#if defined(CONFIG_SIMPLE_TRACE) || defined(CONFIG_STDERR_TRACE) DEF("trace", HAS_ARG, QEMU_OPTION_trace, +#if defined(CONFIG_SIMPLE_TRACE) "-trace [file=][,events=]\n" +#elif defined(CONFIG_STDERR_TRACE) + "-trace [events=]\n" +#endif " specify tracing options\n", QEMU_ARCH_ALL) STEXI @@ -2368,7 +2372,9 @@ STEXI Specify tracing options. @table @option +#if defined(CONFIG_SIMPLE_TRACE) @item file=@var{file} +#endif Log output traces to @var{file}. @item events=@var{file} Immediately enable events listed in @var{file}. diff --git a/scripts/tracetool b/scripts/tracetool index e3aec89..17e3f37 100755 --- a/scripts/tracetool +++ b/scripts/tracetool @@ -241,7 +241,12 @@ linetoh_begin_stderr() { cat < +#include "stderrtrace.h" + +extern TraceEvent trace_list[]; EOF + + stderr_event_num=0 } linetoh_stderr() @@ -260,29 +265,47 @@ linetoh_stderr() cat <