summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/perf_regs.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2014-01-07 13:47:29 +0100
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-02-18 13:34:49 +0100
commitc9b951c4d12f0b2e9a07dd459c554bc05628d092 (patch)
treecaa1bbe8ea8ccf5490589bf366215218068f0a4f /tools/perf/util/perf_regs.c
parentperf callchain: Introduce HAVE_DWARF_UNWIND_SUPPORT macro (diff)
downloadlinux-c9b951c4d12f0b2e9a07dd459c554bc05628d092.tar.xz
linux-c9b951c4d12f0b2e9a07dd459c554bc05628d092.zip
perf callchain: Separate perf_reg_value function in perf_regs object
Making perf_reg_value function global (formely reg_value), because it's going to be used globaly across all code providing the dwarf post unwind feature. Changing its prototype to be generic: -int reg_value(unw_word_t *valp, struct regs_dump *regs, int id) +int perf_reg_value(u64 *valp, struct regs_dump *regs, int id); Changing the valp type from libunwind specific 'unw_word_t' to u64. Signed-off-by: Jiri Olsa <jolsa@redhat.com> Acked-by: Jean Pihet <jean.pihet@linaro.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jean Pihet <jean.pihet@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1389098853-14466-13-git-send-email-jolsa@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/perf_regs.c')
-rw-r--r--tools/perf/util/perf_regs.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/perf/util/perf_regs.c b/tools/perf/util/perf_regs.c
new file mode 100644
index 000000000000..a3539ef30b15
--- /dev/null
+++ b/tools/perf/util/perf_regs.c
@@ -0,0 +1,19 @@
+#include <errno.h>
+#include "perf_regs.h"
+
+int perf_reg_value(u64 *valp, struct regs_dump *regs, int id)
+{
+ int i, idx = 0;
+ u64 mask = regs->mask;
+
+ if (!(mask & (1 << id)))
+ return -EINVAL;
+
+ for (i = 0; i < id; i++) {
+ if (mask & (1 << i))
+ idx++;
+ }
+
+ *valp = regs->regs[idx];
+ return 0;
+}