10 #include <linux/kernel.h> 17 #include "linux/string.h" 26 #define VDSO__TEMP_FILE_NAME "/tmp/perf-vdso.so-XXXXXX" 38 #if BITS_PER_LONG == 64 46 static const struct vdso_info vdso_info_init = {
51 #if BITS_PER_LONG == 64 55 .read_prog =
"perf-read-vdso32",
60 .read_prog =
"perf-read-vdsox32",
65 return memdup(&vdso_info_init,
sizeof(vdso_info_init));
84 buf = memdup(start, size);
92 if (size == (
size_t) write(fd, buf, size))
100 vdso_file->
found = (vdso != NULL);
114 #if BITS_PER_LONG == 64 115 if (vdso_info->vdso32.found)
116 unlink(vdso_info->vdso32.temp_file_name);
117 if (vdso_info->vdsox32.found)
118 unlink(vdso_info->vdsox32.temp_file_name);
156 #if BITS_PER_LONG == 64 158 static int vdso__do_copy_compat(FILE *
f,
int fd)
164 count = fread(buf, 1,
sizeof(buf),
f);
169 if (count &&
writen(fd, buf, count) != (ssize_t)count)
176 static int vdso__copy_compat(
const char *
prog,
int fd)
181 f = popen(
prog,
"r");
185 err = vdso__do_copy_compat(f, fd);
193 static int vdso__create_compat_file(
const char *
prog,
char *temp_name)
197 fd = mkstemp(temp_name);
201 err = vdso__copy_compat(
prog, fd);
213 if (vdso_file->
found)
216 if (vdso_file->
error)
219 err = vdso__create_compat_file(vdso_file->
read_prog,
223 vdso_file->
error =
true;
227 vdso_file->
found =
true;
233 struct vdso_file *vdso_file)
235 const char *file_name;
242 file_name = vdso__get_compat_file(vdso_file);
251 static int __machine__findnew_vdso_compat(
struct machine *machine,
260 #ifndef HAVE_PERF_READ_VDSO32 264 #ifndef HAVE_PERF_READ_VDSOX32 271 *dso = __machine__findnew_compat(machine, &vdso_info->vdso32);
274 *dso = __machine__findnew_compat(machine, &vdso_info->vdsox32);
286 struct thread *thread)
288 struct dso *dso = NULL;
298 if (dso && dso_type !=
dso__type(dso, machine))
316 struct thread *thread)
318 struct vdso_info *vdso_info;
319 struct dso *dso = NULL;
333 #if BITS_PER_LONG == 64 334 if (__machine__findnew_vdso_compat(machine, thread, vdso_info, &dso))
static enum dso_type machine__thread_dso_type(struct machine *machine, struct thread *thread)
enum dso_type dso__type(struct dso *dso, struct machine *machine)
void dso__set_long_name(struct dso *dso, const char *name, bool name_allocated)
struct map * map_groups__first(struct map_groups *mg)
void __dsos__add(struct dsos *dsos, struct dso *dso)
int up_write(struct rw_semaphore *sem)
struct vdso_info * vdso_info
struct dso * __dsos__find(struct dsos *dsos, const char *name, bool cmp_short)
char temp_file_name[sizeof(VDSO__TEMP_FILE_NAME)]
static struct vdso_info * vdso_info__new(void)
bool dso__is_vdso(struct dso *dso)
struct dso * dso__get(struct dso *dso)
void machine__exit_vdso(struct machine *machine)
static struct map * map_groups__next(struct map *map)
struct dso * dso__new(const char *name)
#define DSO__NAME_VDSOX32
static struct dso * __machine__addnew_vdso(struct machine *machine, const char *short_name, const char *long_name)
#define VDSO__TEMP_FILE_NAME
ssize_t writen(int fd, const void *buf, size_t n)
int down_write(struct rw_semaphore *sem)
static int find_vdso_map(void **start, void **end)
static struct dso * machine__find_vdso(struct machine *machine, struct thread *thread)
static char * get_file(struct vdso_file *vdso_file)
struct dso * machine__findnew_vdso(struct machine *machine, struct thread *thread)