Skip to contentSkip to conversation

perf symbols: Fix annotation of objects with debuginfo files

PATCH Superseded Anton Blanchard 5 participants 9 messages Aug 12, 2016 – Aug 16, 2016 perf events

lore
Share & tools
lore
#0 lore raw

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.

Fixes 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")

---

tools/perf/util/symbol-elf.c +1 -1
index a34321e..9e36073 100644
@@ -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)
#1 lore raw

Em 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->elf which should point at the executable when parsing a debuginfo file.

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

- Arnaldo

Quoted 18 lines
Fixes 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")

---

tools/perf/util/symbol-elf.c +1 -1
index a34321e..9e36073 100644
@@ -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)
#2 lore raw
In reply to Anton Blanchard
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->elf which should point at the executable when parsing a debuginfo file.

Fixes 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")

---

tools/perf/util/symbol-elf.c +0 -0
index a34321e..9e36073 100644

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

#3 lore raw

PATCH v2 1/1 perf symbols: Fix annotation of objects with debuginfo files

In reply to 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->elf which should point at the executable when parsing a debuginfo file.

Fixes 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")

---

v2: Fix from Naveen

tools/perf/util/symbol-elf.c +2 -1
index a34321e..a811c13 100644
@@ -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 on v2 1/1
#4 lore raw
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->elf which should point at the executable when parsing a debuginfo file.

Fixes 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")

---

v2: Fix from Naveen

tools/perf/util/symbol-elf.c +0 -0
index a34321e..a811c13 100644

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

Tested-by on v2 1/1
#5 lore raw
In reply to Anton Blanchard
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->elf which should point at the executable when parsing a debuginfo file.

Fixes 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")

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

Thank you.

#6 lore raw
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->elf which should point at the executable when parsing a debuginfo file.

Fixes 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")

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.

Thank you.

Thanks,
- Naveen

maintainer Applied
#7 lore raw
In reply to Wangnan (F)

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->elf which should point at the executable when parsing a debuginfo file.

Fixes 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")
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.

Thanks, applied.

- Arnaldo

#8 lore raw
In reply to Anton Blanchard
perf 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.

Cc Peter Zijlstra <[email protected]>
Cc Ravi Bangoria <[email protected]>
Fixes 73cdf0c6ea9c ("perf symbols: Record text offset in dso to calculate objdump address")
---
 tools/perf/util/symbol-elf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/symbol-elf.c +2 -1
index a34321e..a811c13 100644
@@ -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)