From patchwork Wed Apr 6 11:37:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 90007 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 DE06BB6F01 for ; Wed, 6 Apr 2011 21:51:07 +1000 (EST) Received: from localhost ([127.0.0.1]:51738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7R4K-0007tL-6r for incoming@patchwork.ozlabs.org; Wed, 06 Apr 2011 07:38:40 -0400 Received: from [140.186.70.92] (port=60586 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q7R3N-0007qg-NZ for qemu-devel@nongnu.org; Wed, 06 Apr 2011 07:37:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q7R3M-0003Le-BJ for qemu-devel@nongnu.org; Wed, 06 Apr 2011 07:37:41 -0400 Received: from mail-gw0-f45.google.com ([74.125.83.45]:62151) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q7R3M-0003LZ-7p for qemu-devel@nongnu.org; Wed, 06 Apr 2011 07:37:40 -0400 Received: by gwb19 with SMTP id 19so451834gwb.4 for ; Wed, 06 Apr 2011 04:37:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=gYc8oz0aKwdhZolAR93YzHJn3h7fUrxP8BXYCzQXW7s=; b=UGOlSY4OQY/yGYQ0q5ueGDY4bEXdsyv0UorZLSpS9Zi455y+12R/bsx9QDt5GjWV1F 7zfh3ay4S3paYYYnlyx19dCuExN4K6Odh95m2/Is5PfAdQkn+3ADEdnFOqJCaRUHPLDY SSTflcOmaS9EKWOOl4fo/sTg5H/H8fCD77/jE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=Z9QM6/yeWXG+4zmLQElDIrgOHCrvVCGjoKMsB9mgQ3SbsKOZrCDd3R91p26u4jazDI H1ZKZu3CeYW7aBhU8PlRgKtlOgyqt54vj75nMYPjsXSsWVF7lRM2vLgX66TCI6Y80c4M w4gUdh7KPtFR4TSCpOLT5o7QFF8NBz3ylJWMI= MIME-Version: 1.0 Received: by 10.151.13.7 with SMTP id q7mr1673715ybi.304.1302089859423; Wed, 06 Apr 2011 04:37:39 -0700 (PDT) Received: by 10.147.40.2 with HTTP; Wed, 6 Apr 2011 04:37:38 -0700 (PDT) In-Reply-To: <20110404214933.9761.62154.stgit@ginnungagap.bsc.es> References: <20110404214900.9761.49418.stgit@ginnungagap.bsc.es> <20110404214933.9761.62154.stgit@ginnungagap.bsc.es> Date: Wed, 6 Apr 2011 12:37:38 +0100 Message-ID: From: Stefan Hajnoczi To: =?ISO-8859-1?Q?Llu=EDs?= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.83.45 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] Re: [PATCH 5/6] trace-state: [simple] add "-trace events" argument to control initial state 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 On Mon, Apr 4, 2011 at 10:49 PM, Lluís wrote: > When using the "simple" tracing backend, all events are in disabled state by > default. > > The "-trace events" argument can be used to provide a file with a list of trace > event names that will be enabled prior to starting execution. This saves the > user from manually toggling event states through the monitor interface, as well > as enables early tracing for the selected points, much like other > more-sophisticated backends like "ust" or "dtrace". > > Signed-off-by: Lluís Vilanova > --- >  docs/tracing.txt |    5 +++ >  qemu-config.c    |    5 ++- >  qemu-options.hx  |   18 ++++++++-- >  vl.c             |   94 +++++++++++++++++++++++++++++++++++------------------- >  4 files changed, 84 insertions(+), 38 deletions(-) Too many whitespace/indentation changes here. If you want to fix whitespace then please do it in a separate patch that is not part of this series. > @@ -2833,9 +2834,10 @@ int main(int argc, char **argv, char **envp) >                 break; >  #ifdef CONFIG_SIMPLE_TRACE >             case QEMU_OPTION_trace: > -                opts = qemu_opts_parse(qemu_find_opts("trace"), optarg, 0); > +                opts = qemu_opts_parse(qemu_find_opts("trace"), optarg, 1); Previously "qemu -trace asdf" failed: qemu: -trace asdf: Invalid parameter 'asdf' Please don't add an implied file= since there are no legacy users whom this would help. Let's strictly accept file= and events=. > @@ -2887,6 +2889,32 @@ int main(int argc, char **argv, char **envp) >     if (!st_init(trace_file)) { >         fprintf(stderr, "warning: unable to initialize simple trace backend\n"); >     } > +    if (trace_events_file) { > +        FILE *trace_events_fp = fopen(trace_events_file, "r"); > +        if (!trace_events_fp) { > +            fprintf(stderr, "could not open trace events file '%s': %s\n", > +                    trace_events_file, strerror(errno)); > +            exit(1); > +        } > +        char line_buf[1024]; > +        char *line; > +        for (line = fgets(line_buf, 1024, trace_events_fp); line != NULL; > +             line = fgets(line_buf, 1024, trace_events_fp)) { Without the line variable, hardcoded 1024, and duplicated fgets() call: while (fgets(line_buf, sizeof(line_buf), trace_events_fp)) { > +            int len = strlen(line); There's no reason to cast the size_t return value to int here. > +            if (len > 1) {              /* skip empty lines */ > +                line[len - 1] = '\0'; > +                if (!st_change_trace_event_state(line, true)) { The build breaks when --enable-trace-backend != simple because this code is outside an #ifdef CONFIG_SIMPLE_TRACE. Please add this: diff --git a/simpletrace.h b/simpletrace.h index 8d893bd..5d9d2ec 100644 --- a/simpletrace.h +++ b/simpletrace.h @@ -43,6 +43,11 @@ static inline bool st_init(const char *file) { return true; } + +static bool st_change_trace_event_state(const char *tname, bool tstate) +{ + return true; +} #endif /* !CONFIG_SIMPLE_TRACE */ #endif /* SIMPLETRACE_H */