diff options
Diffstat (limited to 'tools/perf/util/map.c')
| -rw-r--r-- | tools/perf/util/map.c | 24 |
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 | ||
| 516 | int 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 | |||
| 516 | struct machine *machines__add(struct rb_root *self, pid_t pid, | 529 | struct 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; |
