aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/machine.c
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2017-10-09 16:32:56 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-10-24 08:59:55 -0400
commit40a342cda2cd9bc8f7bf81c5ce1a141584760757 (patch)
tree21f9ebf584f25c45e7fe8bf0280c2d6d9c6cac8a /tools/perf/util/machine.c
parent2a704fc8db7b0080a67d9f4f4cb2a7bcaf79949d (diff)
perf callchain: Store srcline in callchain_cursor_node
This is mostly a preparation to enable the creation of full callchain nodes for inline frames. Such frames will reference the IP of the non-inlined frame, but hold the symbol and srcline for an inlined location. As such, we won't be able to query the srcline on-demand based on the IP alone. Instead, we will leverage the functionality provided by this patch here, and store the srcline for the inlined nodes in the new srcline member of callchain_cursor_node. Note that this patch on its own leaks the srcline, as there is no free_callchain_cursor_node or similar. A future patch will add caching of the srcline and handle deletion properly. Signed-off-by: Milian Wolff <milian.wolff@kdab.com> Reviewed-by: Jiri Olsa <jolsa@redhat.com> Reviewed-by: Namhyung Kim <namhyung@kernel.org> Cc: David Ahern <dsahern@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Yao Jin <yao.jin@linux.intel.com> Link: http://lkml.kernel.org/r/20171009203310.17362-3-milian.wolff@kdab.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/machine.c')
-rw-r--r--tools/perf/util/machine.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 7c3aa479201a..a37e1c056415 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1709,6 +1709,15 @@ struct mem_info *sample__resolve_mem(struct perf_sample *sample,
1709 return mi; 1709 return mi;
1710} 1710}
1711 1711
1712static char *callchain_srcline(struct map *map, struct symbol *sym, u64 ip)
1713{
1714 if (!map || callchain_param.key == CCKEY_FUNCTION)
1715 return NULL;
1716
1717 return get_srcline(map->dso, map__rip_2objdump(map, ip),
1718 sym, false, callchain_param.key == CCKEY_ADDRESS);
1719}
1720
1712struct iterations { 1721struct iterations {
1713 int nr_loop_iter; 1722 int nr_loop_iter;
1714 u64 cycles; 1723 u64 cycles;
@@ -1728,6 +1737,7 @@ static int add_callchain_ip(struct thread *thread,
1728 struct addr_location al; 1737 struct addr_location al;
1729 int nr_loop_iter = 0; 1738 int nr_loop_iter = 0;
1730 u64 iter_cycles = 0; 1739 u64 iter_cycles = 0;
1740 const char *srcline = NULL;
1731 1741
1732 al.filtered = 0; 1742 al.filtered = 0;
1733 al.sym = NULL; 1743 al.sym = NULL;
@@ -1783,9 +1793,10 @@ static int add_callchain_ip(struct thread *thread,
1783 iter_cycles = iter->cycles; 1793 iter_cycles = iter->cycles;
1784 } 1794 }
1785 1795
1796 srcline = callchain_srcline(al.map, al.sym, al.addr);
1786 return callchain_cursor_append(cursor, al.addr, al.map, al.sym, 1797 return callchain_cursor_append(cursor, al.addr, al.map, al.sym,
1787 branch, flags, nr_loop_iter, 1798 branch, flags, nr_loop_iter,
1788 iter_cycles, branch_from); 1799 iter_cycles, branch_from, srcline);
1789} 1800}
1790 1801
1791struct branch_info *sample__resolve_bstack(struct perf_sample *sample, 1802struct branch_info *sample__resolve_bstack(struct perf_sample *sample,
@@ -2101,12 +2112,15 @@ check_calls:
2101static int unwind_entry(struct unwind_entry *entry, void *arg) 2112static int unwind_entry(struct unwind_entry *entry, void *arg)
2102{ 2113{
2103 struct callchain_cursor *cursor = arg; 2114 struct callchain_cursor *cursor = arg;
2115 const char *srcline = NULL;
2104 2116
2105 if (symbol_conf.hide_unresolved && entry->sym == NULL) 2117 if (symbol_conf.hide_unresolved && entry->sym == NULL)
2106 return 0; 2118 return 0;
2119
2120 srcline = callchain_srcline(entry->map, entry->sym, entry->ip);
2107 return callchain_cursor_append(cursor, entry->ip, 2121 return callchain_cursor_append(cursor, entry->ip,
2108 entry->map, entry->sym, 2122 entry->map, entry->sym,
2109 false, NULL, 0, 0, 0); 2123 false, NULL, 0, 0, 0, srcline);
2110} 2124}
2111 2125
2112static int thread__resolve_callchain_unwind(struct thread *thread, 2126static int thread__resolve_callchain_unwind(struct thread *thread,