aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/dso.c17
-rw-r--r--tools/perf/util/dso.h2
-rw-r--r--tools/perf/util/machine.c3
3 files changed, 13 insertions, 9 deletions
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index 55c983586b05..f8c849767c4d 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -379,7 +379,7 @@ struct dso *dso__kernel_findnew(struct machine *machine, const char *name,
379 * processing we had no idea this was the kernel dso. 379 * processing we had no idea this was the kernel dso.
380 */ 380 */
381 if (dso != NULL) { 381 if (dso != NULL) {
382 dso__set_short_name(dso, short_name); 382 dso__set_short_name(dso, short_name, false);
383 dso->kernel = dso_type; 383 dso->kernel = dso_type;
384 } 384 }
385 385
@@ -394,17 +394,22 @@ void dso__set_long_name(struct dso *dso, char *name)
394 dso->long_name_len = strlen(name); 394 dso->long_name_len = strlen(name);
395} 395}
396 396
397void dso__set_short_name(struct dso *dso, const char *name) 397void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated)
398{ 398{
399 if (name == NULL) 399 if (name == NULL)
400 return; 400 return;
401 dso->short_name = name; 401
402 dso->short_name_len = strlen(name); 402 if (dso->short_name_allocated)
403 free((char *)dso->short_name);
404
405 dso->short_name = name;
406 dso->short_name_len = strlen(name);
407 dso->short_name_allocated = name_allocated;
403} 408}
404 409
405static void dso__set_basename(struct dso *dso) 410static void dso__set_basename(struct dso *dso)
406{ 411{
407 dso__set_short_name(dso, basename(dso->long_name)); 412 dso__set_short_name(dso, basename(dso->long_name), false);
408} 413}
409 414
410int dso__name_len(const struct dso *dso) 415int dso__name_len(const struct dso *dso)
@@ -440,7 +445,7 @@ struct dso *dso__new(const char *name)
440 int i; 445 int i;
441 strcpy(dso->name, name); 446 strcpy(dso->name, name);
442 dso__set_long_name(dso, dso->name); 447 dso__set_long_name(dso, dso->name);
443 dso__set_short_name(dso, dso->name); 448 dso__set_short_name(dso, dso->name, false);
444 for (i = 0; i < MAP__NR_TYPES; ++i) 449 for (i = 0; i < MAP__NR_TYPES; ++i)
445 dso->symbols[i] = dso->symbol_names[i] = RB_ROOT; 450 dso->symbols[i] = dso->symbol_names[i] = RB_ROOT;
446 dso->cache = RB_ROOT; 451 dso->cache = RB_ROOT;
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 00a232d89607..8eceab78088f 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -110,7 +110,7 @@ static inline void dso__set_loaded(struct dso *dso, enum map_type type)
110struct dso *dso__new(const char *name); 110struct dso *dso__new(const char *name);
111void dso__delete(struct dso *dso); 111void dso__delete(struct dso *dso);
112 112
113void dso__set_short_name(struct dso *dso, const char *name); 113void dso__set_short_name(struct dso *dso, const char *name, bool name_allocated);
114void dso__set_long_name(struct dso *dso, char *name); 114void dso__set_long_name(struct dso *dso, char *name);
115 115
116int dso__name_len(const struct dso *dso); 116int dso__name_len(const struct dso *dso);
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index f85da9a9a5d9..09d5c66d4087 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -935,8 +935,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
935 if (name == NULL) 935 if (name == NULL)
936 goto out_problem; 936 goto out_problem;
937 937
938 dso__set_short_name(map->dso, name); 938 dso__set_short_name(map->dso, name, true);
939 map->dso->short_name_allocated = 1;
940 map->end = map->start + event->mmap.len; 939 map->end = map->start + event->mmap.len;
941 } else if (is_kernel_mmap) { 940 } else if (is_kernel_mmap) {
942 const char *symbol_name = (event->mmap.filename + 941 const char *symbol_name = (event->mmap.filename +