提交 f1f13af9 编写于 作者: N Namhyung Kim 提交者: Arnaldo Carvalho de Melo

perf callchain: Cache eh/debug frame offset for dwarf unwind

When libunwind tries to resolve callchains it needs to know the offset
of .eh_frame_hdr or .debug_frame to access the dso.

Since it will always return the same result for a given DSO, just cache
the result as an optimization.
Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1422518843-25818-41-git-send-email-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 459a3df7
...@@ -139,6 +139,7 @@ struct dso { ...@@ -139,6 +139,7 @@ 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;
} data; } data;
union { /* Tool specific area */ union { /* Tool specific area */
......
...@@ -266,14 +266,17 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine, ...@@ -266,14 +266,17 @@ 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; u64 offset = dso->data.frame_offset;
fd = dso__data_fd(dso, machine); if (offset == 0) {
if (fd < 0) fd = dso__data_fd(dso, machine);
return -EINVAL; if (fd < 0)
return -EINVAL;
/* 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;
}
if (offset) if (offset)
ret = unwind_spec_ehframe(dso, machine, offset, ret = unwind_spec_ehframe(dso, machine, offset,
...@@ -287,14 +290,20 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine, ...@@ -287,14 +290,20 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine,
static int read_unwind_spec_debug_frame(struct dso *dso, static int read_unwind_spec_debug_frame(struct dso *dso,
struct machine *machine, u64 *offset) struct machine *machine, u64 *offset)
{ {
int fd = dso__data_fd(dso, machine); int fd;
u64 ofs = dso->data.frame_offset;
if (fd < 0) if (ofs == 0) {
return -EINVAL; fd = dso__data_fd(dso, machine);
if (fd < 0)
return -EINVAL;
/* Check the .debug_frame section for unwinding info */ /* Check the .debug_frame section for unwinding info */
*offset = elf_section_offset(fd, ".debug_frame"); ofs = elf_section_offset(fd, ".debug_frame");
dso->data.frame_offset = ofs;
}
*offset = ofs;
if (*offset) if (*offset)
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册