10 struct thread
*thread__new(pid_t pid
)
12 struct thread
*self
= zalloc(sizeof(*self
));
15 map_groups__init(&self
->mg
);
17 self
->comm
= malloc(32);
19 snprintf(self
->comm
, 32, ":%d", self
->pid
);
25 void thread__delete(struct thread
*self
)
27 map_groups__exit(&self
->mg
);
32 int thread__set_comm(struct thread
*self
, const char *comm
)
38 self
->comm
= strdup(comm
);
39 err
= self
->comm
== NULL
? -ENOMEM
: 0;
41 self
->comm_set
= true;
46 int thread__comm_len(struct thread
*self
)
48 if (!self
->comm_len
) {
51 self
->comm_len
= strlen(self
->comm
);
54 return self
->comm_len
;
57 size_t thread__fprintf(struct thread
*thread
, FILE *fp
)
59 return fprintf(fp
, "Thread %d %s\n", thread
->pid
, thread
->comm
) +
60 map_groups__fprintf(&thread
->mg
, verbose
, fp
);
63 void thread__insert_map(struct thread
*self
, struct map
*map
)
65 map_groups__fixup_overlappings(&self
->mg
, map
, verbose
, stderr
);
66 map_groups__insert(&self
->mg
, map
);
69 int thread__fork(struct thread
*self
, struct thread
*parent
)
73 if (parent
->comm_set
) {
76 self
->comm
= strdup(parent
->comm
);
79 self
->comm_set
= true;
82 for (i
= 0; i
< MAP__NR_TYPES
; ++i
)
83 if (map_groups__clone(&self
->mg
, &parent
->mg
, i
) < 0)
This page took 0.088857 seconds and 5 git commands to generate.