Commit 303cb89a authored by Wang Nan's avatar Wang Nan Committed by Arnaldo Carvalho de Melo

perf callchain: Separate eh/debug frame offset cache.

Commit f1f13af9 ("perf callchain: Cache eh/debug frame offset for
dwarf unwind") introduces a cache for .debug_frame and .eh_frame_hdr.
Unfortunately, it makes them share a same cache (dso->frame_offset).
Which causes unwind failure on ARM:

   $ perf test unwind
  Test dwarf unwind: FAILED!

The reason is that, if a dso has '.debug_frame' but doesn't have
'.eh_frame_hdr' (like ARM), dso->frame_offset will be filled by offset
of '.debug_frame' during the first time calling of find_proc_info() ->
read_unwind_spec_debug_frame(), and be regarded to '.eh_frame_hdr' when
the second time calling of find_proc_info() ->
read_unwind_spec_eh_frame(), since '.eh_frame_hdr' is checked prior to
'.debug_frame'.

This patch solves the problem by creating two cache fields for
'.eh_frame_hdr' and '.debug_frame'.
Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Link: http://lkml.kernel.org/r/55028BA0.1030701@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 1312c8a8
...@@ -139,7 +139,8 @@ struct dso { ...@@ -139,7 +139,8 @@ struct dso {
u32 status_seen; u32 status_seen;
size_t file_size; size_t file_size;
struct list_head open_entry; struct list_head open_entry;
u64 frame_offset; u64 debug_frame_offset;
u64 eh_frame_hdr_offset;
} data; } data;
union { /* Tool specific area */ union { /* Tool specific area */
......
...@@ -266,7 +266,7 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine, ...@@ -266,7 +266,7 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine,
u64 *fde_count) u64 *fde_count)
{ {
int ret = -EINVAL, fd; int ret = -EINVAL, fd;
u64 offset = dso->data.frame_offset; u64 offset = dso->data.eh_frame_hdr_offset;
if (offset == 0) { if (offset == 0) {
fd = dso__data_fd(dso, machine); fd = dso__data_fd(dso, machine);
...@@ -275,7 +275,7 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine, ...@@ -275,7 +275,7 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine,
/* Check the .eh_frame section for unwinding info */ /* Check the .eh_frame section for unwinding info */
offset = elf_section_offset(fd, ".eh_frame_hdr"); offset = elf_section_offset(fd, ".eh_frame_hdr");
dso->data.frame_offset = offset; dso->data.eh_frame_hdr_offset = offset;
} }
if (offset) if (offset)
...@@ -291,7 +291,7 @@ static int read_unwind_spec_debug_frame(struct dso *dso, ...@@ -291,7 +291,7 @@ static int read_unwind_spec_debug_frame(struct dso *dso,
struct machine *machine, u64 *offset) struct machine *machine, u64 *offset)
{ {
int fd; int fd;
u64 ofs = dso->data.frame_offset; u64 ofs = dso->data.debug_frame_offset;
if (ofs == 0) { if (ofs == 0) {
fd = dso__data_fd(dso, machine); fd = dso__data_fd(dso, machine);
...@@ -300,7 +300,7 @@ static int read_unwind_spec_debug_frame(struct dso *dso, ...@@ -300,7 +300,7 @@ static int read_unwind_spec_debug_frame(struct dso *dso,
/* Check the .debug_frame section for unwinding info */ /* Check the .debug_frame section for unwinding info */
ofs = elf_section_offset(fd, ".debug_frame"); ofs = elf_section_offset(fd, ".debug_frame");
dso->data.frame_offset = ofs; dso->data.debug_frame_offset = ofs;
} }
*offset = ofs; *offset = ofs;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment