From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Gleb Natapov <gleb@redhat.com>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu,
peterz@infradead.org, paulus@samba.org
Subject: [PATCH] Re: perf annotate segfaults when source code has goto label that looks like hex number
Date: Thu, 22 Jul 2010 11:33:45 -0300 [thread overview]
Message-ID: <20100722143345.GC17631@ghostprotocols.net> (raw)
In-Reply-To: <20100722072044.GD27177@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2972 bytes --]
Em Thu, Jul 22, 2010 at 10:20:44AM +0300, Gleb Natapov escreveu:
> strtoull() returns valid number when it gets line with label and following
> test passes too. I can't think of a way to unambiguously distinguish between
> label and valid rip. May be running objdump with --prefix-addresses will
> help, but it may make other thing unambiguous.
[root@emilia ~]# objdump --start-address=0x0000000000400474 --stop-address=0x0000000000400496 -dS ./a.out | grep -P ':\t'
400474: 55 push %rbp
400475: 48 89 e5 mov %rsp,%rbp
400478: 89 7d ec mov %edi,-0x14(%rbp)
40047b: 48 89 75 e0 mov %rsi,-0x20(%rbp)
40047f: eb 01 jmp 400482 <main+0xe>
400481: 90 nop
400482: 83 45 fc 01 addl $0x1,-0x4(%rbp)
400486: 81 7d fc 80 96 98 00 cmpl $0x989680,-0x4(%rbp)
40048d: 75 f2 jne 400481 <main+0xd>
40048f: 90 nop
400490: b8 00 00 00 00 mov $0x0,%eax
400495: c9 leaveq
[root@emilia ~]# objdump --start-address=0x0000000000400474
--stop-address=0x0000000000400496 -dS ./a.out | grep ':$'
Disassembly of section .text:
0000000000400474 <main>:
add:
[root@emilia ~]#
Can you try the attached patch?
With it we get:
[root@emilia ~]# perf annotate
------------------------------------------------
Percent | Source code & Disassembly of a.out
------------------------------------------------
:
:
:
: Disassembly of section .text:
:
: 0000000000400474 <main>:
: int main(int argc, char **argv)
: {
0.00 : 400474: 55 push %rbp
0.00 : 400475: 48 89 e5 mov %rsp,%rbp
0.00 : 400478: 89 7d ec mov %edi,-0x14(%rbp)
0.00 : 40047b: 48 89 75 e0 mov %rsi,-0x20(%rbp)
0.00 : 40047f: eb 01 jmp 400482 <main+0xe>
:
: while(1) {
: i++;
: if (i == 10000000)
: goto add;
: }
21.05 : 400481: 90 nop
: int main(int argc, char **argv)
: {
: int i;
:
: while(1) {
: i++;
0.00 : 400482: 83 45 fc 01 addl $0x1,-0x4(%rbp)
: if (i == 10000000)
15.79 : 400486: 81 7d fc 80 96 98 00 cmpl $0x989680,-0x4(%rbp)
63.16 : 40048d: 75 f2 jne 400481 <main+0xd>
: goto add;
0.00 : 40048f: 90 nop
: }
: add:
: return 0;
0.00 : 400490: b8 00 00 00 00 mov $0x0,%eax
: }
0.00 : 400495: c9 leaveq
[-- Attachment #2: annotate_fix.patch --]
[-- Type: text/plain, Size: 452 bytes --]
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 699cf81..e3486d5 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -976,7 +976,7 @@ static int hist_entry__parse_objdump_line(struct hist_entry *self, FILE *file,
* Parse hexa addresses followed by ':'
*/
line_ip = strtoull(tmp, &tmp2, 16);
- if (*tmp2 != ':' || tmp == tmp2)
+ if (*tmp2 != ':' || tmp == tmp2 || tmp2[1] == '\0')
line_ip = -1;
}
next prev parent reply other threads:[~2010-07-22 14:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-22 7:20 perf annotate segfaults when source code has goto label that looks like hex number Gleb Natapov
2010-07-22 14:33 ` Arnaldo Carvalho de Melo [this message]
2010-07-22 16:38 ` [PATCH] " Gleb Natapov
2010-07-22 16:47 ` Arnaldo Carvalho de Melo
2010-07-22 16:52 ` Arnaldo Carvalho de Melo
2010-07-22 17:05 ` [PATCH v2] " Arnaldo Carvalho de Melo
2010-07-22 18:05 ` Gleb Natapov
2010-07-22 19:11 ` Arnaldo Carvalho de Melo
2010-07-22 19:16 ` Gleb Natapov
2010-08-02 9:02 ` Peter Zijlstra
2010-08-02 14:52 ` Arnaldo Carvalho de Melo
2010-07-23 12:11 ` [tip:perf/urgent] perf annotate: Fix handling of goto labels that are valid hex numbers tip-bot for Arnaldo Carvalho de Melo
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=20100722143345.GC17631@ghostprotocols.net \
--to=acme@infradead.org \
--cc=gleb@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
/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