diff options
Diffstat (limited to 'tools/perf/util/map.c')
| -rw-r--r-- | tools/perf/util/map.c | 38 | 
1 files changed, 33 insertions, 5 deletions
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index b7f890950909..f30d34903aa4 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c @@ -137,7 +137,7 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,  		no_dso = is_no_dso_memory(filename);  		map->prot = prot;  		map->flags = flags; -		nsi = nsinfo__get(thread->nsinfo); +		nsi = nsinfo__get(thread__nsinfo(thread));  		if ((anon || no_dso) && nsi && (prot & PROT_EXEC)) {  			snprintf(newfilename, sizeof(newfilename), @@ -431,14 +431,21 @@ size_t map__fprintf(struct map *map, FILE *fp)  		       map__start(map), map__end(map), map__pgoff(map), dso->name);  } -size_t map__fprintf_dsoname(struct map *map, FILE *fp) +static bool prefer_dso_long_name(const struct dso *dso, bool print_off) +{ +	return dso->long_name && +	       (symbol_conf.show_kernel_path || +		(print_off && (dso->name[0] == '[' || dso__is_kcore(dso)))); +} + +static size_t __map__fprintf_dsoname(struct map *map, bool print_off, FILE *fp)  {  	char buf[symbol_conf.pad_output_len_dso + 1];  	const char *dsoname = "[unknown]";  	const struct dso *dso = map ? map__dso(map) : NULL;  	if (dso) { -		if (symbol_conf.show_kernel_path && dso->long_name) +		if (prefer_dso_long_name(dso, print_off))  			dsoname = dso->long_name;  		else  			dsoname = dso->name; @@ -452,6 +459,27 @@ size_t map__fprintf_dsoname(struct map *map, FILE *fp)  	return fprintf(fp, "%s", dsoname);  } +size_t map__fprintf_dsoname(struct map *map, FILE *fp) +{ +	return __map__fprintf_dsoname(map, false, fp); +} + +size_t map__fprintf_dsoname_dsoff(struct map *map, bool print_off, u64 addr, FILE *fp) +{ +	const struct dso *dso = map ? map__dso(map) : NULL; +	int printed = 0; + +	if (print_off && (!dso || !dso__is_object_file(dso))) +		print_off = false; +	printed += fprintf(fp, " ("); +	printed += __map__fprintf_dsoname(map, print_off, fp); +	if (print_off) +		printed += fprintf(fp, "+0x%" PRIx64, addr); +	printed += fprintf(fp, ")"); + +	return printed; +} +  char *map__srcline(struct map *map, u64 addr, struct symbol *sym)  {  	if (map == NULL) @@ -468,9 +496,9 @@ int map__fprintf_srcline(struct map *map, u64 addr, const char *prefix,  	if (dso) {  		char *srcline = map__srcline(map, addr, NULL); -		if (strncmp(srcline, SRCLINE_UNKNOWN, strlen(SRCLINE_UNKNOWN)) != 0) +		if (srcline != SRCLINE_UNKNOWN)  			ret = fprintf(fp, "%s%s", prefix, srcline); -		free_srcline(srcline); +		zfree_srcline(&srcline);  	}  	return ret;  }  |