8 static inline int is_anon_memory(const char *filename
)
10 return strcmp(filename
, "//anon") == 0;
13 static int strcommon(const char *pathname
, char *cwd
, int cwdlen
)
17 while (n
< cwdlen
&& pathname
[n
] == cwd
[n
])
23 struct map
*map__new(struct mmap_event
*event
, char *cwd
, int cwdlen
,
24 unsigned int sym_priv_size
, symbol_filter_t filter
)
26 struct map
*self
= malloc(sizeof(*self
));
29 const char *filename
= event
->filename
;
30 char newfilename
[PATH_MAX
];
35 int n
= strcommon(filename
, cwd
, cwdlen
);
38 snprintf(newfilename
, sizeof(newfilename
),
40 filename
= newfilename
;
44 anon
= is_anon_memory(filename
);
47 snprintf(newfilename
, sizeof(newfilename
), "/tmp/perf-%d.map", event
->pid
);
48 filename
= newfilename
;
51 self
->start
= event
->start
;
52 self
->end
= event
->start
+ event
->len
;
53 self
->pgoff
= event
->pgoff
;
55 self
->dso
= dsos__findnew(filename
, sym_priv_size
, &new_dso
);
56 if (self
->dso
== NULL
)
60 int nr
= dso__load(self
->dso
, self
, filter
);
63 pr_warning("Failed to open %s, continuing "
65 self
->dso
->long_name
);
67 pr_warning("No symbols found in %s, maybe "
68 "install a debug package?\n",
69 self
->dso
->long_name
);
72 if (self
->dso
== vdso
|| anon
)
73 self
->map_ip
= self
->unmap_ip
= identity__map_ip
;
75 self
->map_ip
= map__map_ip
;
76 self
->unmap_ip
= map__unmap_ip
;
85 struct map
*map__clone(struct map
*self
)
87 struct map
*map
= malloc(sizeof(*self
));
92 memcpy(map
, self
, sizeof(*self
));
97 int map__overlap(struct map
*l
, struct map
*r
)
99 if (l
->start
> r
->start
) {
105 if (l
->end
> r
->start
)
111 size_t map__fprintf(struct map
*self
, FILE *fp
)
113 return fprintf(fp
, " %Lx-%Lx %Lx %s\n",
114 self
->start
, self
->end
, self
->pgoff
, self
->dso
->name
);