diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-12-10 13:08:44 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-12-10 14:51:09 -0500 |
commit | 7e155d4d5e2912f75443c18c02dd6f1dbd4eef84 (patch) | |
tree | 24bc86c6ee5154cd4556ecf0b4a003683b9303d4 /tools | |
parent | 5230fb7db42914e47786a6e920d2624739b0f896 (diff) |
perf symbols: Remove open coded management of long_name_allocated member
Instead of expecting callers to set this member accodingly so that later
at dso destruction it can, if needed, be correctly free()d, make it a
requirement by passing it as a parameter to dso__set_long_name.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-na7t1tqim22vuqkt4zq5n4ri@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/dso.c | 13 | ||||
-rw-r--r-- | tools/perf/util/dso.h | 2 | ||||
-rw-r--r-- | tools/perf/util/machine.c | 3 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 9 | ||||
-rw-r--r-- | tools/perf/util/vdso.c | 2 |
5 files changed, 16 insertions, 13 deletions
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index f8c849767c4d..ecb37d62f814 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c | |||
@@ -386,12 +386,17 @@ struct dso *dso__kernel_findnew(struct machine *machine, const char *name, | |||
386 | return dso; | 386 | return dso; |
387 | } | 387 | } |
388 | 388 | ||
389 | void dso__set_long_name(struct dso *dso, char *name) | 389 | void dso__set_long_name(struct dso *dso, char *name, bool name_allocated) |
390 | { | 390 | { |
391 | if (name == NULL) | 391 | if (name == NULL) |
392 | return; | 392 | return; |
393 | dso->long_name = name; | 393 | |
394 | dso->long_name_len = strlen(name); | 394 | if (dso->long_name_allocated) |
395 | free(dso->long_name); | ||
396 | |||
397 | dso->long_name = name; | ||
398 | dso->long_name_len = strlen(name); | ||
399 | dso->long_name_allocated = name_allocated; | ||
395 | } | 400 | } |
396 | 401 | ||
397 | void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated) | 402 | void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated) |
@@ -444,7 +449,7 @@ struct dso *dso__new(const char *name) | |||
444 | if (dso != NULL) { | 449 | if (dso != NULL) { |
445 | int i; | 450 | int i; |
446 | strcpy(dso->name, name); | 451 | strcpy(dso->name, name); |
447 | dso__set_long_name(dso, dso->name); | 452 | dso__set_long_name(dso, dso->name, false); |
448 | dso__set_short_name(dso, dso->name, false); | 453 | dso__set_short_name(dso, dso->name, false); |
449 | for (i = 0; i < MAP__NR_TYPES; ++i) | 454 | for (i = 0; i < MAP__NR_TYPES; ++i) |
450 | dso->symbols[i] = dso->symbol_names[i] = RB_ROOT; | 455 | dso->symbols[i] = dso->symbol_names[i] = RB_ROOT; |
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 8eceab78088f..7b434691525a 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h | |||
@@ -111,7 +111,7 @@ struct dso *dso__new(const char *name); | |||
111 | void dso__delete(struct dso *dso); | 111 | void dso__delete(struct dso *dso); |
112 | 112 | ||
113 | void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated); | 113 | void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated); |
114 | void dso__set_long_name(struct dso *dso, char *name); | 114 | void dso__set_long_name(struct dso *dso, char *name, bool name_allocated); |
115 | 115 | ||
116 | int dso__name_len(const struct dso *dso); | 116 | int dso__name_len(const struct dso *dso); |
117 | 117 | ||
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 09d5c66d4087..751454bcde69 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c | |||
@@ -763,8 +763,7 @@ static int map_groups__set_modules_path_dir(struct map_groups *mg, | |||
763 | ret = -1; | 763 | ret = -1; |
764 | goto out; | 764 | goto out; |
765 | } | 765 | } |
766 | dso__set_long_name(map->dso, long_name); | 766 | dso__set_long_name(map->dso, long_name, true); |
767 | map->dso->long_name_allocated = 1; | ||
768 | dso__kernel_module_get_build_id(map->dso, ""); | 767 | dso__kernel_module_get_build_id(map->dso, ""); |
769 | } | 768 | } |
770 | } | 769 | } |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 9a5de8837d6d..5029ee1a9421 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -1159,7 +1159,7 @@ static int dso__load_kcore(struct dso *dso, struct map *map, | |||
1159 | dso->data_type = DSO_BINARY_TYPE__GUEST_KCORE; | 1159 | dso->data_type = DSO_BINARY_TYPE__GUEST_KCORE; |
1160 | else | 1160 | else |
1161 | dso->data_type = DSO_BINARY_TYPE__KCORE; | 1161 | dso->data_type = DSO_BINARY_TYPE__KCORE; |
1162 | dso__set_long_name(dso, strdup(kcore_filename)); | 1162 | dso__set_long_name(dso, strdup(kcore_filename), true); |
1163 | 1163 | ||
1164 | close(fd); | 1164 | close(fd); |
1165 | 1165 | ||
@@ -1438,8 +1438,7 @@ int dso__load_vmlinux(struct dso *dso, struct map *map, | |||
1438 | dso->data_type = DSO_BINARY_TYPE__GUEST_VMLINUX; | 1438 | dso->data_type = DSO_BINARY_TYPE__GUEST_VMLINUX; |
1439 | else | 1439 | else |
1440 | dso->data_type = DSO_BINARY_TYPE__VMLINUX; | 1440 | dso->data_type = DSO_BINARY_TYPE__VMLINUX; |
1441 | dso__set_long_name(dso, (char *)vmlinux); | 1441 | dso__set_long_name(dso, (char *)vmlinux, vmlinux_allocated); |
1442 | dso->long_name_allocated = vmlinux_allocated; | ||
1443 | dso__set_loaded(dso, map->type); | 1442 | dso__set_loaded(dso, map->type); |
1444 | pr_debug("Using %s for symbols\n", symfs_vmlinux); | 1443 | pr_debug("Using %s for symbols\n", symfs_vmlinux); |
1445 | } | 1444 | } |
@@ -1631,7 +1630,7 @@ do_kallsyms: | |||
1631 | free(kallsyms_allocated_filename); | 1630 | free(kallsyms_allocated_filename); |
1632 | 1631 | ||
1633 | if (err > 0 && !dso__is_kcore(dso)) { | 1632 | if (err > 0 && !dso__is_kcore(dso)) { |
1634 | dso__set_long_name(dso, strdup("[kernel.kallsyms]")); | 1633 | dso__set_long_name(dso, strdup("[kernel.kallsyms]"), true); |
1635 | map__fixup_start(map); | 1634 | map__fixup_start(map); |
1636 | map__fixup_end(map); | 1635 | map__fixup_end(map); |
1637 | } | 1636 | } |
@@ -1679,7 +1678,7 @@ static int dso__load_guest_kernel_sym(struct dso *dso, struct map *map, | |||
1679 | pr_debug("Using %s for symbols\n", kallsyms_filename); | 1678 | pr_debug("Using %s for symbols\n", kallsyms_filename); |
1680 | if (err > 0 && !dso__is_kcore(dso)) { | 1679 | if (err > 0 && !dso__is_kcore(dso)) { |
1681 | machine__mmap_name(machine, path, sizeof(path)); | 1680 | machine__mmap_name(machine, path, sizeof(path)); |
1682 | dso__set_long_name(dso, strdup(path)); | 1681 | dso__set_long_name(dso, strdup(path), true); |
1683 | map__fixup_start(map); | 1682 | map__fixup_start(map); |
1684 | map__fixup_end(map); | 1683 | map__fixup_end(map); |
1685 | } | 1684 | } |
diff --git a/tools/perf/util/vdso.c b/tools/perf/util/vdso.c index 39159822d58f..0ddb3b8a89ec 100644 --- a/tools/perf/util/vdso.c +++ b/tools/perf/util/vdso.c | |||
@@ -103,7 +103,7 @@ struct dso *vdso__dso_findnew(struct list_head *head) | |||
103 | dso = dso__new(VDSO__MAP_NAME); | 103 | dso = dso__new(VDSO__MAP_NAME); |
104 | if (dso != NULL) { | 104 | if (dso != NULL) { |
105 | dsos__add(head, dso); | 105 | dsos__add(head, dso); |
106 | dso__set_long_name(dso, file); | 106 | dso__set_long_name(dso, file, false); |
107 | } | 107 | } |
108 | } | 108 | } |
109 | 109 | ||