19 static inline int is_anon_memory(
const char *
filename)
21 return strcmp(filename,
"//anon") == 0;
24 static inline int is_no_dso_memory(
const char *
filename)
26 return !
strcmp(filename,
"[stack]") ||
27 !
strcmp(filename,
"[heap]");
38 self->map_ip = map__map_ip;
39 self->unmap_ip = map__unmap_ip;
42 self->referenced =
false;
43 self->erange_warned =
false;
55 int anon, no_dso, vdso;
57 anon = is_anon_memory(filename);
58 vdso = is_vdso_map(filename);
59 no_dso = is_no_dso_memory(filename);
62 snprintf(newfilename,
sizeof(newfilename),
"/tmp/perf-%d.map", pid);
63 filename = newfilename;
75 map__init(
self, type, start, start + len, pgoff, dso);
78 self->map_ip =
self->unmap_ip = identity__map_ip;
86 dso__set_loaded(dso, self->type);
102 struct map *
map = calloc(1, (
sizeof(*map) +
125 self->start = sym->
start;
135 self->end = sym->
end;
139 #define DSO__DELETED "(deleted)"
143 const char *
name =
self->dso->long_name;
151 if (self->dso->has_build_id) {
155 sizeof(self->dso->build_id),
164 }
else if (nr == 0) {
165 #ifdef LIBELF_SUPPORT
171 pr_warning(
"%.*s was updated (is prelink enabled?). "
172 "Restart the long running apps that use it!\n",
173 (
int)real_len, name);
175 pr_warning(
"no symbols found in %s, maybe install "
176 "a debug package?\n", name);
185 if (self->dso->kernel)
219 memcpy(map,
self,
sizeof(*
self));
241 self->start, self->end, self->pgoff, self->dso->name);
246 const char *dsoname =
"[unknown]";
248 if (map && map->
dso && (map->
dso->name || map->
dso->long_name)) {
250 dsoname = map->
dso->long_name;
251 else if (map->
dso->name)
252 dsoname = map->
dso->name;
255 return fprintf(fp,
"%s", dsoname);
280 static void maps__delete(
struct rb_root *maps)
293 static void maps__delete_removed(
struct list_head *maps)
308 maps__delete(&mg->
maps[i]);
340 struct map *
map = map_groups__find(mg, type, addr);
381 printed +=
fprintf(fp,
"Map:");
385 printed +=
fprintf(fp,
"--\n");
394 size_t printed = 0,
i;
400 static size_t __map_groups__fprintf_removed_maps(
struct map_groups *mg,
408 printed +=
fprintf(fp,
"Map:");
412 printed +=
fprintf(fp,
"--\n");
418 static size_t map_groups__fprintf_removed_maps(
struct map_groups *mg,
419 int verbose, FILE *fp)
421 size_t printed = 0,
i;
423 printed += __map_groups__fprintf_removed_maps(mg,
i, verbose, fp);
430 printed +=
fprintf(fp,
"Removed maps:\n");
431 return printed + map_groups__fprintf_removed_maps(mg, verbose, fp);
435 int verbose, FILE *fp)
449 fputs(
"overlapping maps:\n", fp);
462 if (before ==
NULL) {
468 map_groups__insert(mg, before);
473 if (map->
end < pos->
end) {
482 map_groups__insert(mg, after);
514 map_groups__insert(mg,
new);
531 struct kmap *
kmap = map__kmap(
self);
543 self->map_ip = map__reloc_map_ip;
544 self->unmap_ip = map__reloc_unmap_ip;
564 rb_link_node(&map->
rb_node, parent, p);
584 else if (ip > m->
end)
597 INIT_LIST_HEAD(&self->user_dsos);
598 INIT_LIST_HEAD(&self->kernel_dsos);
601 INIT_LIST_HEAD(&self->dead_threads);
602 self->last_match =
NULL;
604 self->kmaps.machine =
self;
606 self->root_dir = strdup(root_dir);
607 if (self->root_dir ==
NULL)
617 snprintf(comm,
sizeof(comm),
"[guest/%d]", pid);
624 static void dsos__delete(
struct list_head *
self)
637 dsos__delete(&self->user_dsos);
638 dsos__delete(&self->kernel_dsos);
639 free(self->root_dir);
640 self->root_dir =
NULL;
652 struct rb_node **
p = &
self->rb_node;
673 rb_link_node(&machine->
rb_node, parent, p);
681 struct rb_node **
p = &
self->rb_node;
684 struct machine *default_machine =
NULL;
691 else if (pid > machine->
pid)
699 return default_machine;
708 if (machine && (machine->
pid == pid))
721 if (!strlist__has_entry(seen, path)) {
722 pr_err(
"Can't access file %s\n", path);
749 if (machine__is_host(
self))
750 snprintf(bf, size,
"[%s]",
"kernel.kallsyms");
751 else if (machine__is_default_guest(
self))
752 snprintf(bf, size,
"[%s]",
"guest.kernel.kallsyms");
754 snprintf(bf, size,
"[%s.%d]",
"guest.kernel.kallsyms", self->pid);