From patchwork Thu Oct 20 06:42:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Wu X-Patchwork-Id: 120742 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 4AC81B70C2 for ; Thu, 20 Oct 2011 18:05:51 +1100 (EST) Received: from localhost ([::1]:43302 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGmMD-0004kc-De for incoming@patchwork.ozlabs.org; Thu, 20 Oct 2011 02:44:01 -0400 Received: from eggs.gnu.org ([140.186.70.92]:48271) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGmLp-00049t-AC for qemu-devel@nongnu.org; Thu, 20 Oct 2011 02:43:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RGmLi-0007mp-C9 for qemu-devel@nongnu.org; Thu, 20 Oct 2011 02:43:32 -0400 Received: from e28smtp01.in.ibm.com ([122.248.162.1]:52575) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGmLh-0007mG-9l for qemu-devel@nongnu.org; Thu, 20 Oct 2011 02:43:30 -0400 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by e28smtp01.in.ibm.com (8.14.4/8.13.1) with ESMTP id p9K6hP36023238 for ; Thu, 20 Oct 2011 12:13:25 +0530 Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p9K6hOVm3715244 for ; Thu, 20 Oct 2011 12:13:25 +0530 Received: from d28av03.in.ibm.com (loopback [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p9K6hOvE016216 for ; Thu, 20 Oct 2011 17:43:24 +1100 Received: from oc4654482034.ibm.com ([9.115.122.78]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p9K6hO2I014808; Thu, 20 Oct 2011 17:43:24 +1100 Received: by oc4654482034.ibm.com (Postfix, from userid 500) id 2CC694485C; Thu, 20 Oct 2011 14:42:39 +0800 (CST) From: Mark Wu To: stefanha@linux.vnet.ibm.com Date: Thu, 20 Oct 2011 14:42:39 +0800 Message-Id: <1319092959-23944-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.1 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH v2 5/6] trace: Enable "-trace events" argument to control initial state of groups 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 A group of trace events can be enabled in early running stage through adding its group name prefixed with "group:" to trace events list file which is passed to "-trace events". Signed-off-by: Mark Wu --- trace/control.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/trace/control.c b/trace/control.c index 4c5527d..18e14a1 100644 --- a/trace/control.c +++ b/trace/control.c @@ -23,10 +23,27 @@ void trace_backend_init_events(const char *fname) exit(1); } char line_buf[1024]; + char *group; + while (fgets(line_buf, sizeof(line_buf), fp)) { size_t len = strlen(line_buf); if (len > 1) { /* skip empty lines */ line_buf[len - 1] = '\0'; + group = strstr(line_buf, "group:"); + if (group != NULL) { + group += strlen("group:"); + if (group == NULL) { + fprintf(stderr, "error: empty group name\n"); + exit(1); + } + if (!trace_event_group_set_state(group, true)) { + fprintf(stderr, "error: trace event group '%s'" + "does not exist\n", group); + exit(1); + } + continue; + } + if (!trace_event_set_state(line_buf, true)) { fprintf(stderr, "error: trace event '%s' does not exist\n", line_buf);