From patchwork Fri Feb 3 21:20:32 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: 139475 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 52168104796 for ; Sat, 4 Feb 2012 08:21:00 +1100 (EST) Received: from localhost ([::1]:48894 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtQYz-00026L-Ev for incoming@patchwork.ozlabs.org; Fri, 03 Feb 2012 16:20:57 -0500 Received: from eggs.gnu.org ([140.186.70.92]:38922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtQYm-0001hX-Vc for qemu-devel@nongnu.org; Fri, 03 Feb 2012 16:20:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RtQYl-0000aw-SQ for qemu-devel@nongnu.org; Fri, 03 Feb 2012 16:20:44 -0500 Received: from gw.ac.upc.edu ([147.83.30.3]:52819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RtQYl-0000ak-B5 for qemu-devel@nongnu.org; Fri, 03 Feb 2012 16:20:43 -0500 Received: from localhost (unknown [84.88.53.92]) by gw.ac.upc.edu (Postfix) with ESMTP id 1D6282D000D; Fri, 3 Feb 2012 22:20:42 +0100 (CET) To: qemu-devel@nongnu.org From: =?utf-8?b?TGx1w61z?= Vilanova Date: Fri, 03 Feb 2012 22:20:32 +0100 Message-ID: <20120203212032.339.25224.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 5/6] trace: [simple] 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 | 28 +++++++++------------------- trace/simple.c | 32 +++++--------------------------- trace/simple.h | 6 +----- trace/stderr.h | 11 ----------- 4 files changed, 15 insertions(+), 62 deletions(-) delete mode 100644 trace/stderr.h diff --git a/scripts/tracetool.py b/scripts/tracetool.py index 91da998..f4ce927 100755 --- a/scripts/tracetool.py +++ b/scripts/tracetool.py @@ -261,28 +261,17 @@ def simple_h(events): 'name': event.name, 'args': event.args } - print - print '#define NR_TRACE_EVENTS %d' % len(events) - print 'extern TraceEvent trace_list[NR_TRACE_EVENTS];' @for_backend("simple", "c") def simple_c(events): rec_off = 0 - print '#include "trace.h"' - print '#include "trace/simple.h"' - print - print 'TraceEvent trace_list[] = {' - print - for event in events: - print '{.tp_name = "%(name)s", .state=0},' % { - 'name': event.name -} - print - print '};' - print + print """\ +#include "trace.h" +#include "trace/simple.h" +""" - for num, event in enumerate(events): - sizes = [] + for event in events: + sizes = ["0"] for type_, name in event.args: if type_is_string(type_): sizes.append("4 + strlen(%s)" % name) @@ -297,7 +286,8 @@ def simple_c(events): uint64_t pvar64 __attribute__ ((unused)); uint32_t slen __attribute__ ((unused)); - if (!trace_list[%(event_id)s].state) { + bool _state = trace_event_get_state(%(event_id)s); + if (!_state) { return; } @@ -306,7 +296,7 @@ def simple_c(events): ''' % { 'name': event.name, 'args': event.args, - 'event_id': num, + 'event_id': "TRACE_" + event.name.upper(), 'sizestr' : sizestr, } diff --git a/trace/simple.c b/trace/simple.c index f5aa3bd..d4da9d3 100644 --- a/trace/simple.c +++ b/trace/simple.c @@ -263,38 +263,16 @@ void trace_print_events(FILE *stream, fprintf_function stream_printf) { unsigned int 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; } /* Helper function to create a thread with signals blocked. Use glib's diff --git a/trace/simple.h b/trace/simple.h index 671cbeb..6850ac5 100644 --- a/trace/simple.h +++ b/trace/simple.h @@ -15,12 +15,8 @@ #include #include -typedef uint64_t TraceEventID; +#include "trace-events.h" -typedef struct { - const char *tp_name; - bool state; -} TraceEvent; void st_print_trace(FILE *stream, fprintf_function stream_printf); void st_print_trace_file_status(FILE *stream, fprintf_function stream_printf); diff --git a/trace/stderr.h b/trace/stderr.h deleted file mode 100644 index d575b61..0000000 --- a/trace/stderr.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef TRACE_STDERR_H -#define TRACE_STDERR_H - -typedef uint64_t TraceEventID; - -typedef struct { - const char *tp_name; - bool state; -} TraceEvent; - -#endif /* ! TRACE_STDERR_H */