From patchwork Fri Feb 3 21:20:47 2012 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: 139476 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A27D7104792 for ; Sat, 4 Feb 2012 08:21:11 +1100 (EST) Received: from localhost ([::1]:50011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtQZB-0002g4-I8 for incoming@patchwork.ozlabs.org; Fri, 03 Feb 2012 16:21:09 -0500 Received: from eggs.gnu.org ([140.186.70.92]:38946) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtQZ2-0002UL-3Y for qemu-devel@nongnu.org; Fri, 03 Feb 2012 16:21:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RtQZ1-0000bm-1n for qemu-devel@nongnu.org; Fri, 03 Feb 2012 16:21:00 -0500 Received: from gw.ac.upc.edu ([147.83.30.3]:52823) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtQZ0-0000bi-OE for qemu-devel@nongnu.org; Fri, 03 Feb 2012 16:20:59 -0500 Received: from localhost (unknown [84.88.53.92]) by gw.ac.upc.edu (Postfix) with ESMTP id 60D642D000D; Fri, 3 Feb 2012 22:20:57 +0100 (CET) To: qemu-devel@nongnu.org From: =?utf-8?b?TGx1w61z?= Vilanova Date: Fri, 03 Feb 2012 22:20:47 +0100 Message-ID: <20120203212047.339.83050.stgit@ginnungagap.bsc.es> In-Reply-To: <20120203211915.339.99432.stgit@ginnungagap.bsc.es> References: <20120203211915.339.99432.stgit@ginnungagap.bsc.es> User-Agent: StGit/0.15 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 147.83.30.3 Cc: blauwirbel@gmail.com, stefanha@gmail.com Subject: [Qemu-devel] [PATCH 6/6] trace: [stderr] Port to generic event information and new control interface 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 --- scripts/tracetool.py | 26 ++++++++------------------ trace/stderr.c | 34 ++++++---------------------------- 2 files changed, 14 insertions(+), 46 deletions(-) diff --git a/scripts/tracetool.py b/scripts/tracetool.py index f4ce927..c6f5ea6 100755 --- a/scripts/tracetool.py +++ b/scripts/tracetool.py @@ -343,10 +343,10 @@ def simple_c(events): @for_backend("stderr", "h", "Stderr built-in backend") def stderr_h(events): - print '''#include -#include "trace/stderr.h" - -extern TraceEvent trace_list[];''' + print """\ +#include +#include "trace/control.h" +""" for num, event in enumerate(events): argnames = ", ".join(event.args.names()) @@ -355,31 +355,21 @@ extern TraceEvent trace_list[];''' print ''' static inline void trace_%(name)s(%(args)s) { - if (trace_list[%(event_num)s].state != 0) { + bool _state = trace_event_get_state(%(event_id)s); + if (_state) { fprintf(stderr, "%(name)s " %(fmt)s "\\n" %(argnames)s); } }''' % { 'name': event.name, 'args': event.args, - 'event_num': num, + 'event_id': "TRACE_" + event.name.upper(), 'fmt': event.fmt.rstrip('\n'), 'argnames': argnames } - print - print '#define NR_TRACE_EVENTS %d' % len(events) @for_backend("stderr", "c") def stderr_c(events): - print '''#include "trace.h" - -TraceEvent trace_list[] = { -''' - for event in events: - print '{.tp_name = "%(name)s", .state=0},' % { - 'name': event.name -} - print - print '};' + pass ################################################## diff --git a/trace/stderr.c b/trace/stderr.c index 0810d6f..6685aeb 100644 --- a/trace/stderr.c +++ b/trace/stderr.c @@ -4,40 +4,18 @@ void trace_print_events(FILE *stream, fprintf_function stream_printf) { - unsigned int i; + TraceEventID i; - for (i = 0; i < NR_TRACE_EVENTS; i++) { + for (i = 0; i < trace_event_count(); i++) { + TraceEvent *ev = trace_event_id(i); stream_printf(stream, "%s [Event ID %u] : state %u\n", - trace_list[i].tp_name, i, trace_list[i].state); + trace_event_get_name(ev), i, trace_event_get_state_dynamic(ev)); } } -bool trace_event_set_state(const char *name, bool state) +void trace_event_set_state_dynamic(TraceEvent *ev, bool state) { - unsigned int i; - unsigned int len; - bool wildcard = false; - bool matched = false; - - len = strlen(name); - if (len > 0 && name[len - 1] == '*') { - wildcard = true; - len -= 1; - } - for (i = 0; i < NR_TRACE_EVENTS; i++) { - if (wildcard) { - if (!strncmp(trace_list[i].tp_name, name, len)) { - trace_list[i].state = state; - matched = true; - } - continue; - } - if (!strcmp(trace_list[i].tp_name, name)) { - trace_list[i].state = state; - return true; - } - } - return matched; + ev->dstate = state; } bool trace_backend_init(const char *events, const char *file)