From patchwork Thu Oct 20 06:42:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Wu X-Patchwork-Id: 120733 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 F35F2B70C2 for ; Thu, 20 Oct 2011 17:43:38 +1100 (EST) Received: from localhost ([::1]:41000 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGmLi-0003Ya-49 for incoming@patchwork.ozlabs.org; Thu, 20 Oct 2011 02:43:30 -0400 Received: from eggs.gnu.org ([140.186.70.92]:48205) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGmLQ-0003Ps-QU for qemu-devel@nongnu.org; Thu, 20 Oct 2011 02:43:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RGmLP-0007iQ-1r for qemu-devel@nongnu.org; Thu, 20 Oct 2011 02:43:12 -0400 Received: from e28smtp05.in.ibm.com ([122.248.162.5]:51493) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGmLN-0007he-R0 for qemu-devel@nongnu.org; Thu, 20 Oct 2011 02:43:10 -0400 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by e28smtp05.in.ibm.com (8.14.4/8.13.1) with ESMTP id p9K6h6Bw020542 for ; Thu, 20 Oct 2011 12:13:06 +0530 Received: from d28av05.in.ibm.com (d28av05.in.ibm.com [9.184.220.67]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p9K6h6of3420200 for ; Thu, 20 Oct 2011 12:13:06 +0530 Received: from d28av05.in.ibm.com (loopback [127.0.0.1]) by d28av05.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p9K6h5Nx006686 for ; Thu, 20 Oct 2011 17:43:05 +1100 Received: from oc4654482034.ibm.com ([9.115.122.78]) by d28av05.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p9K6h59I005997; Thu, 20 Oct 2011 17:43:05 +1100 Received: by oc4654482034.ibm.com (Postfix, from userid 500) id AD0B04485B; Thu, 20 Oct 2011 14:42:33 +0800 (CST) From: Mark Wu To: stefanha@linux.vnet.ibm.com Date: Thu, 20 Oct 2011 14:42:33 +0800 Message-Id: <1319092953-23904-1-git-send-email-wudxw@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 122.248.162.5 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH v2 4/6] trace: Add trace events group implementation in the backend "stderr" 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: Mark Wu --- trace/stderr.c | 32 ++++++++++++++++++++++++++++++++ trace/stderr.h | 7 +++++++ 2 files changed, 39 insertions(+), 0 deletions(-) diff --git a/trace/stderr.c b/trace/stderr.c index 7107c4a..c55bed4 100644 --- a/trace/stderr.c +++ b/trace/stderr.c @@ -12,6 +12,17 @@ void trace_print_events(FILE *stream, fprintf_function stream_printf) } } +void trace_print_groups(FILE *stream, fprintf_function stream_printf) +{ + unsigned int i; + + for (i = 0; i < NR_TRACE_EVENT_GROUPS; i++) { + stream_printf(stream, "%s [GROUP ID %u] : state %u\n", + trace_group_list[i].gp_name, i, + trace_group_list[i].state); + } +} + bool trace_event_set_state(const char *name, bool state) { unsigned int i; @@ -25,6 +36,27 @@ bool trace_event_set_state(const char *name, bool state) return false; } +bool trace_event_group_set_state(const char *gp_name, bool state) +{ + unsigned int i; + unsigned int j; + TraceEventGroup *group; + + for (i = 0; i < NR_TRACE_EVENT_GROUPS; i++) { + + group = &trace_group_list[i]; + if (!strcmp(group->gp_name, gp_name)) { + group->state = state; + + for (j = group->start; j <= group->end; j++) { + trace_list[j].state = state; + } + return true; + } + } + return false; +} + bool trace_backend_init(const char *events, const char *file) { if (file) { diff --git a/trace/stderr.h b/trace/stderr.h index d575b61..45499f6 100644 --- a/trace/stderr.h +++ b/trace/stderr.h @@ -8,4 +8,11 @@ typedef struct { bool state; } TraceEvent; +typedef struct { + const char *gp_name; + bool state; + int start; + int end; +} TraceEventGroup; + #endif /* ! TRACE_STDERR_H */