linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf symbols: Fix annotation of objects with debuginfo files
@ 2016-08-12  6:35 Anton Blanchard
  2016-08-12 13:00 ` Arnaldo Carvalho de Melo
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Anton Blanchard @ 2016-08-12  6:35 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Naveen N. Rao, Ravi Bangoria, Wang Nan, linux-kernel

From: Anton Blanchard <anton@samba.org>

Commit 73cdf0c6ea9c ("perf symbols: Record text offset in dso
to calculate objdump address") started storing the offset of
the text section for all DSOs: 

       if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
               dso->text_offset = tshdr.sh_addr - tshdr.sh_offset;

Unfortunately this breaks debuginfo files, because we need to calculate
the offset of the text section in the associated executable file. As a
result perf annotate returns junk for all debuginfo files.

Fix this by using runtime_ss->elf which should point at the executable
when parsing a debuginfo file.

Cc: stable@vger.kernel.org # v4.6+
Fixes: 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")
Signed-off-by: Anton Blanchard <anton@samba.org>
---

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index a34321e..9e36073 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -837,7 +837,7 @@ int dso__load_sym(struct dso *dso, struct map *map,
 	sec = syms_ss->symtab;
 	shdr = syms_ss->symshdr;
 
-	if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
+	if (elf_section_by_name(runtime_ss->elf, &ehdr, &tshdr, ".text", NULL))
 		dso->text_offset = tshdr.sh_addr - tshdr.sh_offset;
 
 	if (runtime_ss->opdsec)

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] perf symbols: Fix annotation of objects with debuginfo files
  2016-08-12  6:35 [PATCH] perf symbols: Fix annotation of objects with debuginfo files Anton Blanchard
@ 2016-08-12 13:00 ` Arnaldo Carvalho de Melo
  2016-08-12 16:47 ` Naveen N. Rao
  2016-08-13  1:55 ` [PATCH v2] " Anton Blanchard
  2 siblings, 0 replies; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-08-12 13:00 UTC (permalink / raw)
  To: Wang Nan
  Cc: Anton Blanchard, Peter Zijlstra, Ingo Molnar, Naveen N. Rao,
	Ravi Bangoria, linux-kernel

Em Fri, Aug 12, 2016 at 04:35:05PM +1000, Anton Blanchard escreveu:
> From: Anton Blanchard <anton@samba.org>
> 
> Commit 73cdf0c6ea9c ("perf symbols: Record text offset in dso
> to calculate objdump address") started storing the offset of
> the text section for all DSOs: 
> 
>        if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
>                dso->text_offset = tshdr.sh_addr - tshdr.sh_offset;
> 
> Unfortunately this breaks debuginfo files, because we need to calculate
> the offset of the text section in the associated executable file. As a
> result perf annotate returns junk for all debuginfo files.
> 
> Fix this by using runtime_ss->elf which should point at the executable
> when parsing a debuginfo file.

Wang, can I have your ack or reviewed-by?

- Arnaldo
 
> Cc: stable@vger.kernel.org # v4.6+
> Fixes: 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")
> Signed-off-by: Anton Blanchard <anton@samba.org>
> ---
> 
> diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> index a34321e..9e36073 100644
> --- a/tools/perf/util/symbol-elf.c
> +++ b/tools/perf/util/symbol-elf.c
> @@ -837,7 +837,7 @@ int dso__load_sym(struct dso *dso, struct map *map,
>  	sec = syms_ss->symtab;
>  	shdr = syms_ss->symshdr;
>  
> -	if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
> +	if (elf_section_by_name(runtime_ss->elf, &ehdr, &tshdr, ".text", NULL))
>  		dso->text_offset = tshdr.sh_addr - tshdr.sh_offset;
>  
>  	if (runtime_ss->opdsec)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] perf symbols: Fix annotation of objects with debuginfo files
  2016-08-12  6:35 [PATCH] perf symbols: Fix annotation of objects with debuginfo files Anton Blanchard
  2016-08-12 13:00 ` Arnaldo Carvalho de Melo
@ 2016-08-12 16:47 ` Naveen N. Rao
  2016-08-13  1:55 ` [PATCH v2] " Anton Blanchard
  2 siblings, 0 replies; 9+ messages in thread
From: Naveen N. Rao @ 2016-08-12 16:47 UTC (permalink / raw)
  To: Anton Blanchard
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Ravi Bangoria, Wang Nan, linux-kernel

On 2016/08/12 04:35PM, Anton Blanchard wrote:
> From: Anton Blanchard <anton@samba.org>
> 
> Commit 73cdf0c6ea9c ("perf symbols: Record text offset in dso
> to calculate objdump address") started storing the offset of
> the text section for all DSOs: 
> 
>        if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
>                dso->text_offset = tshdr.sh_addr - tshdr.sh_offset;
> 
> Unfortunately this breaks debuginfo files, because we need to calculate
> the offset of the text section in the associated executable file. As a
> result perf annotate returns junk for all debuginfo files.

I am able to reproduce this.

> 
> Fix this by using runtime_ss->elf which should point at the executable
> when parsing a debuginfo file.
> 
> Cc: stable@vger.kernel.org # v4.6+
> Fixes: 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")
> Signed-off-by: Anton Blanchard <anton@samba.org>
> ---
> 
> diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> index a34321e..9e36073 100644
> --- a/tools/perf/util/symbol-elf.c
> +++ b/tools/perf/util/symbol-elf.c
> @@ -837,7 +837,7 @@ int dso__load_sym(struct dso *dso, struct map *map,
>  	sec = syms_ss->symtab;
>  	shdr = syms_ss->symshdr;
> 
> -	if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
> +	if (elf_section_by_name(runtime_ss->elf, &ehdr, &tshdr, ".text", NULL))
                                                 ^^^^^
I suppose you missed updating ehdr to runtime_ss->ehdr?
With that change, perf annotate works for me.

- Naveen

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2] perf symbols: Fix annotation of objects with debuginfo files
  2016-08-12  6:35 [PATCH] perf symbols: Fix annotation of objects with debuginfo files Anton Blanchard
  2016-08-12 13:00 ` Arnaldo Carvalho de Melo
  2016-08-12 16:47 ` Naveen N. Rao
@ 2016-08-13  1:55 ` Anton Blanchard
  2016-08-14 16:56   ` Naveen N. Rao
                     ` (2 more replies)
  2 siblings, 3 replies; 9+ messages in thread
From: Anton Blanchard @ 2016-08-13  1:55 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Naveen N. Rao, Ravi Bangoria, Wang Nan, linux-kernel

From: Anton Blanchard <anton@samba.org>

Commit 73cdf0c6ea9c ("perf symbols: Record text offset in dso
to calculate objdump address") started storing the offset of
the text section for all DSOs: 

       if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
               dso->text_offset = tshdr.sh_addr - tshdr.sh_offset;

Unfortunately this breaks debuginfo files, because we need to calculate
the offset of the text section in the associated executable file. As a
result perf annotate returns junk for all debuginfo files.

Fix this by using runtime_ss->elf which should point at the executable
when parsing a debuginfo file.

Cc: stable@vger.kernel.org # v4.6+
Fixes: 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")
Signed-off-by: Anton Blanchard <anton@samba.org>
---

v2: Fix from Naveen

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index a34321e..a811c13 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -837,7 +837,8 @@ int dso__load_sym(struct dso *dso, struct map *map,
 	sec = syms_ss->symtab;
 	shdr = syms_ss->symshdr;
 
-	if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
+	if (elf_section_by_name(runtime_ss->elf, &runtime_ss->ehdr, &tshdr,
+				".text", NULL))
 		dso->text_offset = tshdr.sh_addr - tshdr.sh_offset;
 
 	if (runtime_ss->opdsec)

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] perf symbols: Fix annotation of objects with debuginfo files
  2016-08-13  1:55 ` [PATCH v2] " Anton Blanchard
@ 2016-08-14 16:56   ` Naveen N. Rao
  2016-08-15  7:13   ` Wangnan (F)
  2016-08-16 18:15   ` [tip:perf/urgent] " tip-bot for Anton Blanchard
  2 siblings, 0 replies; 9+ messages in thread
From: Naveen N. Rao @ 2016-08-14 16:56 UTC (permalink / raw)
  To: Anton Blanchard
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Ravi Bangoria, Wang Nan, linux-kernel

On 2016/08/13 11:55AM, Anton Blanchard wrote:
> From: Anton Blanchard <anton@samba.org>
> 
> Commit 73cdf0c6ea9c ("perf symbols: Record text offset in dso
> to calculate objdump address") started storing the offset of
> the text section for all DSOs: 
> 
>        if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
>                dso->text_offset = tshdr.sh_addr - tshdr.sh_offset;
> 
> Unfortunately this breaks debuginfo files, because we need to calculate
> the offset of the text section in the associated executable file. As a
> result perf annotate returns junk for all debuginfo files.
> 
> Fix this by using runtime_ss->elf which should point at the executable
> when parsing a debuginfo file.
> 
> Cc: stable@vger.kernel.org # v4.6+
> Fixes: 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")
> Signed-off-by: Anton Blanchard <anton@samba.org>
> ---
> 
> v2: Fix from Naveen
> 
> diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> index a34321e..a811c13 100644
> --- a/tools/perf/util/symbol-elf.c
> +++ b/tools/perf/util/symbol-elf.c
> @@ -837,7 +837,8 @@ int dso__load_sym(struct dso *dso, struct map *map,
>  	sec = syms_ss->symtab;
>  	shdr = syms_ss->symshdr;
> 
> -	if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
> +	if (elf_section_by_name(runtime_ss->elf, &runtime_ss->ehdr, &tshdr,
> +				".text", NULL))
>  		dso->text_offset = tshdr.sh_addr - tshdr.sh_offset;
> 
>  	if (runtime_ss->opdsec)

Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>

Thanks Anton!
- Naveen

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] perf symbols: Fix annotation of objects with debuginfo files
  2016-08-13  1:55 ` [PATCH v2] " Anton Blanchard
  2016-08-14 16:56   ` Naveen N. Rao
@ 2016-08-15  7:13   ` Wangnan (F)
  2016-08-15 16:46     ` Naveen N. Rao
  2016-08-15 19:48     ` Arnaldo Carvalho de Melo
  2016-08-16 18:15   ` [tip:perf/urgent] " tip-bot for Anton Blanchard
  2 siblings, 2 replies; 9+ messages in thread
From: Wangnan (F) @ 2016-08-15  7:13 UTC (permalink / raw)
  To: Anton Blanchard, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Naveen N. Rao, Ravi Bangoria,
	linux-kernel



On 2016/8/13 9:55, Anton Blanchard wrote:
> From: Anton Blanchard <anton@samba.org>
>
> Commit 73cdf0c6ea9c ("perf symbols: Record text offset in dso
> to calculate objdump address") started storing the offset of
> the text section for all DSOs:
>
>         if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
>                 dso->text_offset = tshdr.sh_addr - tshdr.sh_offset;
>
> Unfortunately this breaks debuginfo files, because we need to calculate
> the offset of the text section in the associated executable file. As a
> result perf annotate returns junk for all debuginfo files.
>
> Fix this by using runtime_ss->elf which should point at the executable
> when parsing a debuginfo file.
>
> Cc: stable@vger.kernel.org # v4.6+
> Fixes: 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")
> Signed-off-by: Anton Blanchard <anton@samba.org>

I don't quite understand the debuginfo problem. I tested
this patch follow steps recorded in commit 99e87f7 and
see no problem.

Tested-by: Wang Nan <wangnan0@huawei.com>

Thank you.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] perf symbols: Fix annotation of objects with debuginfo files
  2016-08-15  7:13   ` Wangnan (F)
@ 2016-08-15 16:46     ` Naveen N. Rao
  2016-08-15 19:48     ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 9+ messages in thread
From: Naveen N. Rao @ 2016-08-15 16:46 UTC (permalink / raw)
  To: Wangnan (F)
  Cc: Anton Blanchard, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Ravi Bangoria, linux-kernel

On 2016/08/15 03:13PM, Wang Nan wrote:
> 
> 
> On 2016/8/13 9:55, Anton Blanchard wrote:
> > From: Anton Blanchard <anton@samba.org>
> > 
> > Commit 73cdf0c6ea9c ("perf symbols: Record text offset in dso
> > to calculate objdump address") started storing the offset of
> > the text section for all DSOs:
> > 
> >         if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
> >                 dso->text_offset = tshdr.sh_addr - tshdr.sh_offset;
> > 
> > Unfortunately this breaks debuginfo files, because we need to calculate
> > the offset of the text section in the associated executable file. As a
> > result perf annotate returns junk for all debuginfo files.
> > 
> > Fix this by using runtime_ss->elf which should point at the executable
> > when parsing a debuginfo file.
> > 
> > Cc: stable@vger.kernel.org # v4.6+
> > Fixes: 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")
> > Signed-off-by: Anton Blanchard <anton@samba.org>
> 
> I don't quite understand the debuginfo problem. I tested

Some distributions package debuginfo (DWARF, symbol table, ...) separate 
from the actual binary. As an example, on RHEL, if you install both 
findutils and findutils-debuginfo, you'll get /usr/bin/find (stripped 
binary) and /usr/lib/debug/bin/find.debug, which contains the actual 
symbol table and DWARF debug data.

> this patch follow steps recorded in commit 99e87f7 and
> see no problem.
> 
> Tested-by: Wang Nan <wangnan0@huawei.com>
> 
> Thank you.

Thanks,
- Naveen

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] perf symbols: Fix annotation of objects with debuginfo files
  2016-08-15  7:13   ` Wangnan (F)
  2016-08-15 16:46     ` Naveen N. Rao
@ 2016-08-15 19:48     ` Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 9+ messages in thread
From: Arnaldo Carvalho de Melo @ 2016-08-15 19:48 UTC (permalink / raw)
  To: Wangnan (F)
  Cc: Anton Blanchard, Peter Zijlstra, Ingo Molnar, Naveen N. Rao,
	Ravi Bangoria, linux-kernel

Em Mon, Aug 15, 2016 at 03:13:47PM +0800, Wangnan (F) escreveu:
> 
> 
> On 2016/8/13 9:55, Anton Blanchard wrote:
> > From: Anton Blanchard <anton@samba.org>
> > 
> > Commit 73cdf0c6ea9c ("perf symbols: Record text offset in dso
> > to calculate objdump address") started storing the offset of
> > the text section for all DSOs:
> > 
> >         if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
> >                 dso->text_offset = tshdr.sh_addr - tshdr.sh_offset;
> > 
> > Unfortunately this breaks debuginfo files, because we need to calculate
> > the offset of the text section in the associated executable file. As a
> > result perf annotate returns junk for all debuginfo files.
> > 
> > Fix this by using runtime_ss->elf which should point at the executable
> > when parsing a debuginfo file.
> > 
> > Cc: stable@vger.kernel.org # v4.6+
> > Fixes: 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")
> > Signed-off-by: Anton Blanchard <anton@samba.org>
> 
> I don't quite understand the debuginfo problem. I tested
> this patch follow steps recorded in commit 99e87f7 and
> see no problem.
> 
> Tested-by: Wang Nan <wangnan0@huawei.com>

Thanks, applied.

- Arnaldo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [tip:perf/urgent] perf symbols: Fix annotation of objects with debuginfo files
  2016-08-13  1:55 ` [PATCH v2] " Anton Blanchard
  2016-08-14 16:56   ` Naveen N. Rao
  2016-08-15  7:13   ` Wangnan (F)
@ 2016-08-16 18:15   ` tip-bot for Anton Blanchard
  2 siblings, 0 replies; 9+ messages in thread
From: tip-bot for Anton Blanchard @ 2016-08-16 18:15 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, acme, mingo, linux-kernel, naveen.n.rao, hpa, wangnan0,
	ravi.bangoria, tglx, anton

Commit-ID:  50de1a0c54cdbc69a6dbcbc323f53daf95a4050e
Gitweb:     http://git.kernel.org/tip/50de1a0c54cdbc69a6dbcbc323f53daf95a4050e
Author:     Anton Blanchard <anton@samba.org>
AuthorDate: Sat, 13 Aug 2016 11:55:33 +1000
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 15 Aug 2016 16:49:57 -0300

perf symbols: Fix annotation of objects with debuginfo files

Commit 73cdf0c6ea9c ("perf symbols: Record text offset in dso
to calculate objdump address") started storing the offset of
the text section for all DSOs:

       if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
               dso->text_offset = tshdr.sh_addr - tshdr.sh_offset;

Unfortunately this breaks debuginfo files, because we need to calculate
the offset of the text section in the associated executable file. As a
result perf annotate returns junk for all debuginfo files.

Fix this by using runtime_ss->elf which should point at the executable
when parsing a debuginfo file.

Signed-off-by: Anton Blanchard <anton@samba.org>
Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Tested-by: Wang Nan <wangnan0@huawei.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Cc: stable@vger.kernel.org # v4.6+
Fixes: 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")
Link: http://lkml.kernel.org/r/20160813115533.6de17912@kryten
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/symbol-elf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index a34321e..a811c13 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -837,7 +837,8 @@ int dso__load_sym(struct dso *dso, struct map *map,
 	sec = syms_ss->symtab;
 	shdr = syms_ss->symshdr;
 
-	if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL))
+	if (elf_section_by_name(runtime_ss->elf, &runtime_ss->ehdr, &tshdr,
+				".text", NULL))
 		dso->text_offset = tshdr.sh_addr - tshdr.sh_offset;
 
 	if (runtime_ss->opdsec)

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-08-16 18:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-12  6:35 [PATCH] perf symbols: Fix annotation of objects with debuginfo files Anton Blanchard
2016-08-12 13:00 ` Arnaldo Carvalho de Melo
2016-08-12 16:47 ` Naveen N. Rao
2016-08-13  1:55 ` [PATCH v2] " Anton Blanchard
2016-08-14 16:56   ` Naveen N. Rao
2016-08-15  7:13   ` Wangnan (F)
2016-08-15 16:46     ` Naveen N. Rao
2016-08-15 19:48     ` Arnaldo Carvalho de Melo
2016-08-16 18:15   ` [tip:perf/urgent] " tip-bot for Anton Blanchard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).