aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/probe-finder.c
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2010-03-16 18:06:19 -0400
committerIngo Molnar <mingo@elte.hu>2010-03-17 06:32:32 -0400
commitfb1587d869a399554220e166d4b90b581a8ade01 (patch)
tree64ae42dc601f702f6d8409a74d4c3b2e242cdc93 /tools/perf/util/probe-finder.c
parent4235b0454ebeefc2295ad8417e18a8761425b19e (diff)
perf probe: List probes with line number and file name
Improve --list to show current exist probes with line number and file name. This enables user easily to check which line is already probed. for example: ./perf probe --list probe:vfs_read (on vfs_read:8@linux-2.6-tip/fs/read_write.c) Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com> Cc: systemtap <systemtap@sources.redhat.com> Cc: DLE <dle-develop@lists.sourceforge.net> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <20100316220619.32050.48702.stgit@localhost6.localdomain6> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/probe-finder.c')
-rw-r--r--tools/perf/util/probe-finder.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 251b4c49653e..e02b60770485 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -693,6 +693,76 @@ int find_kprobe_trace_events(int fd, struct perf_probe_event *pev,
693 return pf.ntevs; 693 return pf.ntevs;
694} 694}
695 695
696/* Reverse search */
697int find_perf_probe_point(int fd, unsigned long addr,
698 struct perf_probe_point *ppt)
699{
700 Dwarf_Die cudie, spdie, indie;
701 Dwarf *dbg;
702 Dwarf_Line *line;
703 Dwarf_Addr laddr, eaddr;
704 const char *tmp;
705 int lineno, ret = 0;
706
707 dbg = dwarf_begin(fd, DWARF_C_READ);
708 if (!dbg)
709 return -ENOENT;
710
711 /* Find cu die */
712 if (!dwarf_addrdie(dbg, (Dwarf_Addr)addr, &cudie))
713 return -EINVAL;
714
715 /* Find a corresponding line */
716 line = dwarf_getsrc_die(&cudie, (Dwarf_Addr)addr);
717 if (line) {
718 dwarf_lineaddr(line, &laddr);
719 if ((Dwarf_Addr)addr == laddr) {
720 dwarf_lineno(line, &lineno);
721 ppt->line = lineno;
722
723 tmp = dwarf_linesrc(line, NULL, NULL);
724 DIE_IF(!tmp);
725 ppt->file = xstrdup(tmp);
726 ret = 1;
727 }
728 }
729
730 /* Find a corresponding function */
731 if (die_find_real_subprogram(&cudie, (Dwarf_Addr)addr, &spdie)) {
732 tmp = dwarf_diename(&spdie);
733 if (!tmp)
734 goto end;
735
736 dwarf_entrypc(&spdie, &eaddr);
737 if (!lineno) {
738 /* We don't have a line number, let's use offset */
739 ppt->function = xstrdup(tmp);
740 ppt->offset = addr - (unsigned long)eaddr;
741 ret = 1;
742 goto end;
743 }
744 if (die_find_inlinefunc(&spdie, (Dwarf_Addr)addr, &indie)) {
745 /* addr in an inline function */
746 tmp = dwarf_diename(&indie);
747 if (!tmp)
748 goto end;
749 dwarf_decl_line(&indie, &lineno);
750 } else {
751 if (eaddr == addr) /* No offset: function entry */
752 lineno = ppt->line;
753 else
754 dwarf_decl_line(&spdie, &lineno);
755 }
756 ppt->function = xstrdup(tmp);
757 ppt->line -= lineno; /* Make a relative line number */
758 }
759
760end:
761 dwarf_end(dbg);
762 return ret;
763}
764
765
696/* Find line range from its line number */ 766/* Find line range from its line number */
697static void find_line_range_by_line(Dwarf_Die *sp_die, struct line_finder *lf) 767static void find_line_range_by_line(Dwarf_Die *sp_die, struct line_finder *lf)
698{ 768{