mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
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: Namhyung Kim <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Andi Kleen <[email protected]> Cc: David Ahern <[email protected]> Cc: Frederic Weisbecker <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
This commit is contained in:
parent
459a3df76c
commit
f1f13af99a
2 changed files with 21 additions and 11 deletions
|
|
@ -139,6 +139,7 @@ struct dso {
|
|||
u32 status_seen;
|
||||
size_t file_size;
|
||||
struct list_head open_entry;
|
||||
u64 frame_offset;
|
||||
} data;
|
||||
|
||||
union { /* Tool specific area */
|
||||
|
|
|
|||
|
|
@ -266,14 +266,17 @@ static int read_unwind_spec_eh_frame(struct dso *dso, struct machine *machine,
|
|||
u64 *fde_count)
|
||||
{
|
||||
int ret = -EINVAL, fd;
|
||||
u64 offset;
|
||||
u64 offset = dso->data.frame_offset;
|
||||
|
||||
fd = dso__data_fd(dso, machine);
|
||||
if (fd < 0)
|
||||
return -EINVAL;
|
||||
if (offset == 0) {
|
||||
fd = dso__data_fd(dso, machine);
|
||||
if (fd < 0)
|
||||
return -EINVAL;
|
||||
|
||||
/* Check the .eh_frame section for unwinding info */
|
||||
offset = elf_section_offset(fd, ".eh_frame_hdr");
|
||||
/* Check the .eh_frame section for unwinding info */
|
||||
offset = elf_section_offset(fd, ".eh_frame_hdr");
|
||||
dso->data.frame_offset = offset;
|
||||
}
|
||||
|
||||
if (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,
|
|||
static int read_unwind_spec_debug_frame(struct dso *dso,
|
||||
struct machine *machine, u64 *offset)
|
||||
{
|
||||
int fd = dso__data_fd(dso, machine);
|
||||
int fd;
|
||||
u64 ofs = dso->data.frame_offset;
|
||||
|
||||
if (fd < 0)
|
||||
return -EINVAL;
|
||||
if (ofs == 0) {
|
||||
fd = dso__data_fd(dso, machine);
|
||||
if (fd < 0)
|
||||
return -EINVAL;
|
||||
|
||||
/* Check the .debug_frame section for unwinding info */
|
||||
*offset = elf_section_offset(fd, ".debug_frame");
|
||||
/* Check the .debug_frame section for unwinding info */
|
||||
ofs = elf_section_offset(fd, ".debug_frame");
|
||||
dso->data.frame_offset = ofs;
|
||||
}
|
||||
|
||||
*offset = ofs;
|
||||
if (*offset)
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue