perf symbols: Fix annotation of objects with debuginfo files
PATCH 1/1 perf symbols: Fix annotation of objects with debuginfo files
From: Anton Blanchard <[email protected]>
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.
---
tools/perf/util/symbol-elf.c +1 -1
@@ -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)
Arnaldo Carvalho de Melo
maintainerEm Fri, Aug 12, 2016 at 04:35:05PM +1000, Anton Blanchard escreveu:
Quoted 9 lines
From: Anton Blanchard <[email protected]>
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;
Quoted 6 lines
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->elfwhich should point at the executable when parsing a debuginfo file.
Wang, can I have your ack or reviewed-by?
- Arnaldo
Quoted 18 lines
Cc [email protected] # v4.6+Fixes 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")Signed-off-by Anton Blanchard <[email protected]>---
tools/perf/util/symbol-elf.c +1
-1@@ -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)
Quoted 6 lines · Anton Blanchard
From: Anton Blanchard <[email protected]>
Commit
73cdf0c6ea9c("perf symbols: Record text offset in dso to calculate objdump address") started storing the offset of the text section for all DSOs:
Quoted 6 lines
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.
Quoted 14 lines
Fix this by using
runtime_ss->elfwhich should point at the executable when parsing a debuginfo file.Cc [email protected] # v4.6+Fixes 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")Signed-off-by Anton Blanchard <[email protected]>---
tools/perf/util/symbol-elf.c +0
-0
tools/perf/util/symbol-elf.c int dso__load_sym(struct dso *dso, struct map *map, · line 840
Quoted 5 lines
tools/perf/util/symbol-elf.c +1
-1@@ -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
PATCH v2 1/1 perf symbols: Fix annotation of objects with debuginfo files
In reply to Anton BlanchardFrom: Anton Blanchard <[email protected]>
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.
---
v2: Fix from Naveen
tools/perf/util/symbol-elf.c +2 -1
@@ -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)
Quoted 28 lines · Anton Blanchard
From: Anton Blanchard <[email protected]>
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->elfwhich should point at the executable when parsing a debuginfo file.Cc [email protected] # v4.6+Fixes 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")Signed-off-by Anton Blanchard <[email protected]>---
v2: Fix from Naveen
tools/perf/util/symbol-elf.c +0
-0
tools/perf/util/symbol-elf.c int dso__load_sym(struct dso *dso, struct map *map, · line 844
Quoted 9 lines
tools/perf/util/symbol-elf.c +2
-1@@ -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)
Thanks Anton!
- Naveen
Quoted 13 lines · Anton Blanchard
From: Anton Blanchard <[email protected]>
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.
Quoted 6 lines
Fix this by using
runtime_ss->elfwhich should point at the executable when parsing a debuginfo file.Cc [email protected] # v4.6+Fixes 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")Signed-off-by Anton Blanchard <[email protected]>
I don't quite understand the debuginfo problem. I tested this patch follow steps recorded in commit 99e87f7 and see no problem.
Thank you.
Quoted 16 lines · Wang Nan
Quoted 13 lines · Anton Blanchard
From: Anton Blanchard <[email protected]>
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.
Quoted 8 lines
Quoted 6 lines
Fix this by using
runtime_ss->elfwhich should point at the executable when parsing a debuginfo file.Cc [email protected] # v4.6+Fixes 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")Signed-off-by Anton Blanchard <[email protected]>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.
Quoted 6 lines
this patch follow steps recorded in commit 99e87f7 and see no problem.
Tested-by Wang Nan <[email protected]>Thank you.
Thanks,
- Naveen
Em Mon, Aug 15, 2016 at 03:13:47PM +0800, Wangnan (F) escreveu:
Quoted 23 lines · Anton Blanchard
Quoted 13 lines
From: Anton Blanchard <[email protected]>
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.
Quoted 6 lines
Fix this by using
runtime_ss->elfwhich should point at the executable when parsing a debuginfo file.Cc [email protected] # v4.6+Fixes 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")Signed-off-by Anton Blanchard <[email protected]>
Quoted 5 lines
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 <[email protected]>
Thanks, applied.
- Arnaldo
tip-bot for Anton Blanchard
merge botperf symbols: Fix annotation of objects with debuginfo files
Commit-ID: 50de1a0c54cdbc69a6dbcbc323f53daf95a4050e Gitweb: http://git.kernel.org/tip/50de1a0c54cdbc69a6dbcbc323f53daf95a4050e Author: Anton Blanchard <[email protected]> AuthorDate: Sat, 13 Aug 2016 11:55:33 +1000 Committer: Arnaldo Carvalho de Melo <[email protected]> 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.
--- tools/perf/util/symbol-elf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/symbol-elf.c +2 -1
@@ -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)