[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87d2allvgx.fsf@sejong.aot.lge.com>
Date: Wed, 24 Sep 2014 09:21:02 +0900
From: Namhyung Kim <namhyung@...nel.org>
To: Jiri Olsa <jolsa@...hat.com>
Cc: Arnaldo Carvalho de Melo <acme@...nel.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Ingo Molnar <mingo@...nel.org>,
Paul Mackerras <paulus@...ba.org>,
Namhyung Kim <namhyung.kim@....com>,
LKML <linux-kernel@...r.kernel.org>,
David Ahern <dsahern@...il.com>, Milian Wolff <mail@...ianw.de>
Subject: Re: [PATCH] perf tools: Fix line number in the config file error message
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 <acme@...nel.org>
> Cc: Corey Ashford <cjashfor@...ux.vnet.ibm.com>
> Cc: David Ahern <dsahern@...il.com>
> Cc: Ingo Molnar <mingo@...nel.org>
> Cc: Paul Mackerras <paulus@...ba.org>
> Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
> Signed-off-by: Jiri Olsa <jolsa@...nel.org>
Acked-by: Namhyung Kim <namhyung@...nel.org>
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);
> }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists