aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/probe-event.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-04-27 20:20:43 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-04-27 20:21:18 -0400
commitd28c62232e50eab202bcd3f19b5c7a25b8b900b6 (patch)
tree544aca2fe1c7a6c813cf2bf319a8ceb4d212b649 /tools/perf/util/probe-event.c
parent48ea8f5470aa6f35244d1b218316705ea88c0259 (diff)
perf machine: Adopt some map_groups functions
Those functions operated on members now grouped in 'struct machine', so move those methods to this new class. The changes made to 'perf probe' shows that using this abstraction inserting probes on guests almost got supported for free. Cc: Avi Kivity <avi@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Masami Hiramatsu <mhiramat@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Zhang, Yanmin <yanmin_zhang@linux.intel.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/probe-event.c')
-rw-r--r--tools/perf/util/probe-event.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 9ded38ced234..914c67095d96 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -72,8 +72,7 @@ static int e_snprintf(char *str, size_t size, const char *format, ...)
72} 72}
73 73
74static char *synthesize_perf_probe_point(struct perf_probe_point *pp); 74static char *synthesize_perf_probe_point(struct perf_probe_point *pp);
75static struct map_groups kmap_groups; 75static struct machine machine;
76static struct map *kmaps[MAP__NR_TYPES];
77 76
78/* Initialize symbol maps and path of vmlinux */ 77/* Initialize symbol maps and path of vmlinux */
79static int init_vmlinux(void) 78static int init_vmlinux(void)
@@ -92,12 +91,15 @@ static int init_vmlinux(void)
92 goto out; 91 goto out;
93 } 92 }
94 93
94 ret = machine__init(&machine, "/", 0);
95 if (ret < 0)
96 goto out;
97
95 kernel = dso__new_kernel(symbol_conf.vmlinux_name); 98 kernel = dso__new_kernel(symbol_conf.vmlinux_name);
96 if (kernel == NULL) 99 if (kernel == NULL)
97 die("Failed to create kernel dso."); 100 die("Failed to create kernel dso.");
98 101
99 map_groups__init(&kmap_groups); 102 ret = __machine__create_kernel_maps(&machine, kernel);
100 ret = __map_groups__create_kernel_maps(&kmap_groups, kmaps, kernel);
101 if (ret < 0) 103 if (ret < 0)
102 pr_debug("Failed to create kernel maps.\n"); 104 pr_debug("Failed to create kernel maps.\n");
103 105
@@ -110,12 +112,12 @@ out:
110#ifdef DWARF_SUPPORT 112#ifdef DWARF_SUPPORT
111static int open_vmlinux(void) 113static int open_vmlinux(void)
112{ 114{
113 if (map__load(kmaps[MAP__FUNCTION], NULL) < 0) { 115 if (map__load(machine.vmlinux_maps[MAP__FUNCTION], NULL) < 0) {
114 pr_debug("Failed to load kernel map.\n"); 116 pr_debug("Failed to load kernel map.\n");
115 return -EINVAL; 117 return -EINVAL;
116 } 118 }
117 pr_debug("Try to open %s\n", kmaps[MAP__FUNCTION]->dso->long_name); 119 pr_debug("Try to open %s\n", machine.vmlinux_maps[MAP__FUNCTION]->dso->long_name);
118 return open(kmaps[MAP__FUNCTION]->dso->long_name, O_RDONLY); 120 return open(machine.vmlinux_maps[MAP__FUNCTION]->dso->long_name, O_RDONLY);
119} 121}
120 122
121/* Convert trace point to probe point with debuginfo */ 123/* Convert trace point to probe point with debuginfo */
@@ -125,7 +127,7 @@ static int convert_to_perf_probe_point(struct kprobe_trace_point *tp,
125 struct symbol *sym; 127 struct symbol *sym;
126 int fd, ret = -ENOENT; 128 int fd, ret = -ENOENT;
127 129
128 sym = map__find_symbol_by_name(kmaps[MAP__FUNCTION], 130 sym = map__find_symbol_by_name(machine.vmlinux_maps[MAP__FUNCTION],
129 tp->symbol, NULL); 131 tp->symbol, NULL);
130 if (sym) { 132 if (sym) {
131 fd = open_vmlinux(); 133 fd = open_vmlinux();
@@ -1466,7 +1468,7 @@ static int convert_to_kprobe_trace_events(struct perf_probe_event *pev,
1466 } 1468 }
1467 1469
1468 /* Currently just checking function name from symbol map */ 1470 /* Currently just checking function name from symbol map */
1469 sym = map__find_symbol_by_name(kmaps[MAP__FUNCTION], 1471 sym = map__find_symbol_by_name(machine.vmlinux_maps[MAP__FUNCTION],
1470 tev->point.symbol, NULL); 1472 tev->point.symbol, NULL);
1471 if (!sym) { 1473 if (!sym) {
1472 pr_warning("Kernel symbol \'%s\' not found.\n", 1474 pr_warning("Kernel symbol \'%s\' not found.\n",