#include "sort.h"
#include "strlist.h"
#include "thread.h"
+#include "vdso.h"
#include <stdbool.h>
#include <symbol/kallsyms.h>
#include "unwind.h"
INIT_LIST_HEAD(&machine->dead_threads);
machine->last_match = NULL;
+ machine->vdso_info = NULL;
+
machine->kmaps.machine = machine;
machine->pid = pid;
map_groups__exit(&machine->kmaps);
dsos__delete(&machine->user_dsos);
dsos__delete(&machine->kernel_dsos);
+ vdso__exit(machine);
zfree(&machine->root_dir);
zfree(&machine->current_tid);
}
extern const char *ref_reloc_sym_names[];
+struct vdso_info;
+
struct machine {
struct rb_node rb_node;
pid_t pid;
struct rb_root threads;
struct list_head dead_threads;
struct thread *last_match;
+ struct vdso_info *vdso_info;
struct list_head user_dsos;
struct list_head kernel_dsos;
struct map_groups kmaps;
struct vdso_file vdso;
};
-static struct vdso_info vdso_info_ = {
- .vdso = {
- .temp_file_name = VDSO__TEMP_FILE_NAME,
- .dso_name = VDSO__MAP_NAME,
- },
-};
-
-static struct vdso_info *vdso_info = &vdso_info_;
+static struct vdso_info *vdso_info__new(void)
+{
+ static const struct vdso_info vdso_info_init = {
+ .vdso = {
+ .temp_file_name = VDSO__TEMP_FILE_NAME,
+ .dso_name = VDSO__MAP_NAME,
+ },
+ };
+
+ return memdup(&vdso_info_init, sizeof(vdso_info_init));
+}
static int find_vdso_map(void **start, void **end)
{
return vdso;
}
-void vdso__exit(void)
+void vdso__exit(struct machine *machine)
{
+ struct vdso_info *vdso_info = machine->vdso_info;
+
+ if (!vdso_info)
+ return;
+
if (vdso_info->vdso.found)
unlink(vdso_info->vdso.temp_file_name);
+
+ zfree(&machine->vdso_info);
}
struct dso *vdso__dso_findnew(struct machine *machine)
{
- struct dso *dso = dsos__find(&machine->user_dsos, VDSO__MAP_NAME, true);
+ struct vdso_info *vdso_info;
+ struct dso *dso;
+
+ if (!machine->vdso_info)
+ machine->vdso_info = vdso_info__new();
+
+ vdso_info = machine->vdso_info;
+ if (!vdso_info)
+ return NULL;
+ dso = dsos__find(&machine->user_dsos, VDSO__MAP_NAME, true);
if (!dso) {
char *file;