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>
This commit is contained in:
Arnaldo Carvalho de Melo 2010-04-27 21:20:43 -03:00
parent 48ea8f5470
commit d28c62232e
8 changed files with 74 additions and 81 deletions

View file

@ -72,8 +72,7 @@ static int e_snprintf(char *str, size_t size, const char *format, ...)
}
static char *synthesize_perf_probe_point(struct perf_probe_point *pp);
static struct map_groups kmap_groups;
static struct map *kmaps[MAP__NR_TYPES];
static struct machine machine;
/* Initialize symbol maps and path of vmlinux */
static int init_vmlinux(void)
@ -92,12 +91,15 @@ static int init_vmlinux(void)
goto out;
}
ret = machine__init(&machine, "/", 0);
if (ret < 0)
goto out;
kernel = dso__new_kernel(symbol_conf.vmlinux_name);
if (kernel == NULL)
die("Failed to create kernel dso.");
map_groups__init(&kmap_groups);
ret = __map_groups__create_kernel_maps(&kmap_groups, kmaps, kernel);
ret = __machine__create_kernel_maps(&machine, kernel);
if (ret < 0)
pr_debug("Failed to create kernel maps.\n");
@ -110,12 +112,12 @@ out:
#ifdef DWARF_SUPPORT
static int open_vmlinux(void)
{
if (map__load(kmaps[MAP__FUNCTION], NULL) < 0) {
if (map__load(machine.vmlinux_maps[MAP__FUNCTION], NULL) < 0) {
pr_debug("Failed to load kernel map.\n");
return -EINVAL;
}
pr_debug("Try to open %s\n", kmaps[MAP__FUNCTION]->dso->long_name);
return open(kmaps[MAP__FUNCTION]->dso->long_name, O_RDONLY);
pr_debug("Try to open %s\n", machine.vmlinux_maps[MAP__FUNCTION]->dso->long_name);
return open(machine.vmlinux_maps[MAP__FUNCTION]->dso->long_name, O_RDONLY);
}
/* Convert trace point to probe point with debuginfo */
@ -125,7 +127,7 @@ static int convert_to_perf_probe_point(struct kprobe_trace_point *tp,
struct symbol *sym;
int fd, ret = -ENOENT;
sym = map__find_symbol_by_name(kmaps[MAP__FUNCTION],
sym = map__find_symbol_by_name(machine.vmlinux_maps[MAP__FUNCTION],
tp->symbol, NULL);
if (sym) {
fd = open_vmlinux();
@ -1466,7 +1468,7 @@ static int convert_to_kprobe_trace_events(struct perf_probe_event *pev,
}
/* Currently just checking function name from symbol map */
sym = map__find_symbol_by_name(kmaps[MAP__FUNCTION],
sym = map__find_symbol_by_name(machine.vmlinux_maps[MAP__FUNCTION],
tev->point.symbol, NULL);
if (!sym) {
pr_warning("Kernel symbol \'%s\' not found.\n",