aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/map.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/map.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/map.c')
-rw-r--r--tools/perf/util/map.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index ee25ee91504b..44a4df68b3cf 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -513,6 +513,19 @@ struct map *maps__find(struct rb_root *maps, u64 ip)
513 return NULL; 513 return NULL;
514} 514}
515 515
516int machine__init(struct machine *self, const char *root_dir, pid_t pid)
517{
518 map_groups__init(&self->kmaps);
519 RB_CLEAR_NODE(&self->rb_node);
520 INIT_LIST_HEAD(&self->user_dsos);
521 INIT_LIST_HEAD(&self->kernel_dsos);
522
523 self->kmaps.machine = self;
524 self->pid = pid;
525 self->root_dir = strdup(root_dir);
526 return self->root_dir == NULL ? -ENOMEM : 0;
527}
528
516struct machine *machines__add(struct rb_root *self, pid_t pid, 529struct machine *machines__add(struct rb_root *self, pid_t pid,
517 const char *root_dir) 530 const char *root_dir)
518{ 531{
@@ -523,13 +536,10 @@ struct machine *machines__add(struct rb_root *self, pid_t pid,
523 if (!machine) 536 if (!machine)
524 return NULL; 537 return NULL;
525 538
526 machine->pid = pid; 539 if (machine__init(machine, root_dir, pid) != 0) {
527 map_groups__init(&machine->kmaps); 540 free(machine);
528 machine->root_dir = strdup(root_dir); 541 return NULL;
529 RB_CLEAR_NODE(&machine->rb_node); 542 }
530 INIT_LIST_HEAD(&machine->user_dsos);
531 INIT_LIST_HEAD(&machine->kernel_dsos);
532 machine->kmaps.machine = machine;
533 543
534 while (*p != NULL) { 544 while (*p != NULL) {
535 parent = *p; 545 parent = *p;