From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757155AbaIXAVI (ORCPT ); Tue, 23 Sep 2014 20:21:08 -0400 Received: from lgeamrelo02.lge.com ([156.147.1.126]:55536 "EHLO lgeamrelo02.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752121AbaIXAVG (ORCPT ); Tue, 23 Sep 2014 20:21:06 -0400 X-Original-SENDERIP: 10.177.222.235 X-Original-MAILFROM: namhyung@gmail.com From: Namhyung Kim To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Paul Mackerras , Namhyung Kim , LKML , David Ahern , Milian Wolff Subject: Re: [PATCH] perf tools: Fix line number in the config file error message References: <1411434104-5307-1-git-send-email-namhyung@kernel.org> <20140923115656.GC2979@krava.brq.redhat.com> Date: Wed, 24 Sep 2014 09:21:02 +0900 In-Reply-To: <20140923115656.GC2979@krava.brq.redhat.com> (Jiri Olsa's message of "Tue, 23 Sep 2014 13:56:56 +0200") Message-ID: <87d2allvgx.fsf@sejong.aot.lge.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jiri, On Tue, 23 Sep 2014 13:56:56 +0200, Jiri Olsa wrote: > On Tue, Sep 23, 2014 at 10:01:39AM +0900, Namhyung Kim wrote: >> Hello, >> >> This is patchset to add new callchain related config options so that >> users don't need to pass their preference to the cmdline everytime. >> >> Following config options will be added, and users can set appropriate >> values to ~/.perfconfig file. Note that the dump-size option is >> meaningful only if record-mode = dwarf. >> >> $ cat ~/.perfconfig >> [call-graph] >> record-mode = dwarf >> dump-size = 4096 >> print-type = graph >> order = callee >> threshold = 0.5 >> print-limit = 128 >> sort-key = function >> >> $ perf record -vg sleep 1 >> callchain: type DWARF >> callchain: stack dump size 4096 >> mmap size 528384B >> [ perf record: Woken up 1 times to write data ] >> [ perf record: Captured and wrote 0.054 MB perf.data (~2378 samples) ] >> Looking at the vmlinux_path (7 entries long) >> Using /lib/modules/3.16.3-1-ARCH/build/vmlinux for symbols >> >> >> Jiri and David, I kept your Acked-by and Reviewed-by in this version. >> Please take a look at the patch 4/5 which splits parser functions that >> it still looks okay to you. > > looks ok to me, ACK for the patchset Thanks! > > During the testing I found wrong line is displayed in the parsing > error message. It's bug in the config code, attached patch should > fix it. Didn't notice that.. thanks for the quick fix. :) > > > --- > If we fail to parse the config file within the callback function, > the line number counter 'could be' already on the next line. > > This results in wrong line number report like: > > $ cat ~/.perfconfig > [call-graph] > sort-key = krava > $ perf record ls > Fatal: bad config file line 3 in /home/jolsa/.perfconfig > > Fixing this by saving the current line number for this case. > > Cc: Arnaldo Carvalho de Melo > Cc: Corey Ashford > Cc: David Ahern > Cc: Ingo Molnar > Cc: Paul Mackerras > Cc: Peter Zijlstra > Signed-off-by: Jiri Olsa Acked-by: Namhyung Kim Thanks, Namhyung > --- > tools/perf/util/config.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c > index 953512ed72ba..57ff826f150b 100644 > --- a/tools/perf/util/config.c > +++ b/tools/perf/util/config.c > @@ -222,7 +222,8 @@ static int perf_parse_file(config_fn_t fn, void *data) > const unsigned char *bomptr = utf8_bom; > > for (;;) { > - int c = get_next_char(); > + int line, c = get_next_char(); > + > if (bomptr && *bomptr) { > /* We are at the file beginning; skip UTF8-encoded BOM > * if present. Sane editors won't put this in on their > @@ -261,8 +262,16 @@ static int perf_parse_file(config_fn_t fn, void *data) > if (!isalpha(c)) > break; > var[baselen] = tolower(c); > - if (get_value(fn, data, var, baselen+1) < 0) > + > + /* > + * The get_value function might or might not reach the '\n', > + * so saving the current line number for error reporting. > + */ > + line = config_linenr; > + if (get_value(fn, data, var, baselen+1) < 0) { > + config_linenr = line; > break; > + } > } > die("bad config file line %d in %s", config_linenr, config_file_name); > }