From: Taeung Song <treeze.taeung@gmail.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>,
Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Wang Nan <wangnan0@huawei.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
Jiri Olsa <jolsa@redhat.com>, Andi Kleen <andi@firstfloor.org>,
kernel-team@lge.com
Subject: Re: [PATCH v2 1/3] perf annotate: Get correct line numbers matched with addr
Date: Fri, 3 Mar 2017 12:25:28 +0900 [thread overview]
Message-ID: <974fba56-36a1-45de-3f54-7e58acc18a22@gmail.com> (raw)
In-Reply-To: <20170303024018.GJ30710@sejong>
On 03/03/2017 11:40 AM, Namhyung Kim wrote:
> + Andi Kleen who wrote the code.
>
> On Thu, Mar 02, 2017 at 03:05:14PM +0900, Taeung Song wrote:
>>
>>
>> On 03/01/2017 10:17 PM, Namhyung Kim wrote:
>>> Hi Taeung,
>>>
>>> On Wed, Mar 01, 2017 at 04:59:51AM +0900, Taeung Song wrote:
>>>> Currently perf-annotate show wrong line numbers.
>>>>
>>>> For example,
>>>> Actual source code is as below
>>>>
>>>> ...
>>>> 21 };
>>>> 22
>>>> 23 unsigned int limited_wgt;
>>>> 24
>>>> 25 unsigned int get_cond_maxprice(int wgt)
>>>> 26 {
>>>> ...
>>>>
>>>> However, the output of perf-annotate is as below.
>>>>
>>>> 4 Disassembly of section .text:
>>>>
>>>> 6 0000000000400966 <get_cond_maxprice>:
>>>> 7 get_cond_maxprice():
>>>> 26 };
>>>>
>>>> 28 unsigned int limited_wgt;
>>>>
>>>> 30 unsigned int get_cond_maxprice(int wgt)
>>>> 31 {
>>>>
>>>> The cause is the wrong way counting line numbers
>>>> in symbol__parse_objdump_line().
>>>> So remove wrong current code counting line number and
>>>> use other method for it using functions related to addr2line
>>>> instead of the output of '-l' of objdump.
>>>
>>> Hmm.. do you think it's a bug of objdump or it's perf failing to parse
>>> the line number correctly? I'd like to see the output of `objdump -l`
>>>
>>
>> Both are ok.
>> 'objdump -l' hasn't a bug related to line number
>> and perf's method parsing the line number is ok.
>>
>> But symbol__parse_objdump_line() wrongly count line numbers
>> after parsing it as below.
>>
>> 1172 /* /filename:linenr ? Save line number and ignore. */
>> 1173 if (regexec(&file_lineno, line, 2, match, 0) == 0) {
>> 1174 *line_nr = atoi(line + match[1].rm_so);
>> 1175 return 0;
>> 1176 }
>> ...
>> 1208 dl = disasm_line__new(offset, parsed_line, privsize, *line_nr,
>> arch, map);
>> 1209 free(line);
>> 1210 (*line_nr)++;
>>
>> Increasing line_nr each asm line is wrong method.
>> Because 'line_nr' means actual source code line number.
>
> Hmm.. ok. It looks like that it should reuse the old line_nr as is.
>
>>
>> Sure, I can fix only the wrong counting way.
>> But the above parsing method(1172~1176) is never used because of 'grep -v'
>> in command as below.
>> (the grep already remove lines containing filename:linenr of output)
>
> Right, but only if filename is same as binary name.
>
>>
>> 1435 snprintf(command, sizeof(command),
>> 1436 "%s %s%s --start-address=0x%016" PRIx64
>> 1437 " --stop-address=0x%016" PRIx64
>> 1438 " -l -d %s %s -C %s 2>/dev/null|grep -v %s|expand",
>> 1439 objdump_path ? objdump_path : "objdump",
>> 1440 disassembler_style ? "-M " : "",
>> 1441 disassembler_style ? disassembler_style : "",
>> 1442 map__rip_2objdump(map, sym->start),
>> 1443 map__rip_2objdump(map, sym->end),
>> 1444 symbol_conf.annotate_asm_raw ? "" : "--no-show-raw",
>> 1445 symbol_conf.annotate_src ? "-S" : "",
>> 1446 symfs_filename, symfs_filename);
>>
>> Therefore, I think it is better to do three things
>>
>> 1) fix the wrong counting line number problem
>> 2) remove unused the line number parsing method
>> 3) In addtion, a bit reduce objdump dependency
>> using functions related to addr2line of perf.
>>
>> What do you think about that ?
>> Is it bad idea ?
>
> I think we need to fix 1) definitely, but not sure about 2) and 3).
> If objdump could do all necessary works, why not use it? :)
>
> Thanks,
> Namhyung
>
>
Okey! I'll concentrate on fixing 1)
,not removing objdump -l :)
Thanks,
Taeung
next prev parent reply other threads:[~2017-03-03 3:34 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-28 19:59 [PATCH v2 0/3] perf annotate: Introduce the new source code view Taeung Song
2017-02-28 19:59 ` [PATCH v2 1/3] perf annotate: Get correct line numbers matched with addr Taeung Song
2017-03-01 13:17 ` Namhyung Kim
2017-03-02 6:05 ` Taeung Song
2017-03-03 2:40 ` Namhyung Kim
2017-03-03 3:25 ` Taeung Song [this message]
2017-02-28 19:59 ` [PATCH v2 2/3] perf annotate: Introduce the new source code view Taeung Song
2017-03-01 13:58 ` Namhyung Kim
2017-03-01 14:08 ` Peter Zijlstra
2017-03-01 14:21 ` Namhyung Kim
2017-03-01 14:30 ` Peter Zijlstra
2017-03-01 14:56 ` Namhyung Kim
2017-03-01 15:07 ` Peter Zijlstra
2017-03-01 15:52 ` Taeung Song
2017-03-03 5:09 ` Namhyung Kim
2017-02-28 19:59 ` [PATCH v2 3/3] perf annotate: Support the new source code view for TUI Taeung Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=974fba56-36a1-45de-3f54-7e58acc18a22@gmail.com \
--to=treeze.taeung@gmail.com \
--cc=acme@kernel.org \
--cc=andi@firstfloor.org \
--cc=jolsa@kernel.org \
--cc=jolsa@redhat.com \
--cc=kernel-team@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=wangnan0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®