thread.c (4e9816d012dbc28dc89559261c6ffbf8ffc440dd) | thread.c (bf49c35f630452d85c9cd7205a72df841e8d99b9) |
---|---|
1#include "../perf.h" 2#include <stdlib.h> 3#include <stdio.h> 4#include <string.h> 5#include "session.h" 6#include "thread.h" 7#include "util.h" 8#include "debug.h" 9#include "comm.h" 10 11int thread__init_map_groups(struct thread *thread, struct machine *machine) 12{ 13 struct thread *leader; 14 pid_t pid = thread->pid_; 15 | 1#include "../perf.h" 2#include <stdlib.h> 3#include <stdio.h> 4#include <string.h> 5#include "session.h" 6#include "thread.h" 7#include "util.h" 8#include "debug.h" 9#include "comm.h" 10 11int thread__init_map_groups(struct thread *thread, struct machine *machine) 12{ 13 struct thread *leader; 14 pid_t pid = thread->pid_; 15 |
16 if (pid == thread->tid) { | 16 if (pid == thread->tid || pid == -1) { |
17 thread->mg = map_groups__new(); 18 } else { 19 leader = machine__findnew_thread(machine, pid, pid); 20 if (leader) 21 thread->mg = map_groups__get(leader->mg); 22 } 23 24 return thread->mg ? 0 : -1; --- 4 unchanged lines hidden (view full) --- 29 char *comm_str; 30 struct comm *comm; 31 struct thread *thread = zalloc(sizeof(*thread)); 32 33 if (thread != NULL) { 34 thread->pid_ = pid; 35 thread->tid = tid; 36 thread->ppid = -1; | 17 thread->mg = map_groups__new(); 18 } else { 19 leader = machine__findnew_thread(machine, pid, pid); 20 if (leader) 21 thread->mg = map_groups__get(leader->mg); 22 } 23 24 return thread->mg ? 0 : -1; --- 4 unchanged lines hidden (view full) --- 29 char *comm_str; 30 struct comm *comm; 31 struct thread *thread = zalloc(sizeof(*thread)); 32 33 if (thread != NULL) { 34 thread->pid_ = pid; 35 thread->tid = tid; 36 thread->ppid = -1; |
37 thread->cpu = -1; |
|
37 INIT_LIST_HEAD(&thread->comm_list); 38 39 comm_str = malloc(32); 40 if (!comm_str) 41 goto err_thread; 42 43 snprintf(comm_str, 32, ":%d", tid); 44 comm = comm__new(comm_str, 0); --- 10 unchanged lines hidden (view full) --- 55 free(thread); 56 return NULL; 57} 58 59void thread__delete(struct thread *thread) 60{ 61 struct comm *comm, *tmp; 62 | 38 INIT_LIST_HEAD(&thread->comm_list); 39 40 comm_str = malloc(32); 41 if (!comm_str) 42 goto err_thread; 43 44 snprintf(comm_str, 32, ":%d", tid); 45 comm = comm__new(comm_str, 0); --- 10 unchanged lines hidden (view full) --- 56 free(thread); 57 return NULL; 58} 59 60void thread__delete(struct thread *thread) 61{ 62 struct comm *comm, *tmp; 63 |
63 map_groups__put(thread->mg); 64 thread->mg = NULL; | 64 if (thread->mg) { 65 map_groups__put(thread->mg); 66 thread->mg = NULL; 67 } |
65 list_for_each_entry_safe(comm, tmp, &thread->comm_list, list) { 66 list_del(&comm->list); 67 comm__free(comm); 68 } 69 70 free(thread); 71} 72 --- 49 unchanged lines hidden (view full) --- 122 } 123 124 return thread->comm_len; 125} 126 127size_t thread__fprintf(struct thread *thread, FILE *fp) 128{ 129 return fprintf(fp, "Thread %d %s\n", thread->tid, thread__comm_str(thread)) + | 68 list_for_each_entry_safe(comm, tmp, &thread->comm_list, list) { 69 list_del(&comm->list); 70 comm__free(comm); 71 } 72 73 free(thread); 74} 75 --- 49 unchanged lines hidden (view full) --- 125 } 126 127 return thread->comm_len; 128} 129 130size_t thread__fprintf(struct thread *thread, FILE *fp) 131{ 132 return fprintf(fp, "Thread %d %s\n", thread->tid, thread__comm_str(thread)) + |
130 map_groups__fprintf(thread->mg, verbose, fp); | 133 map_groups__fprintf(thread->mg, fp); |
131} 132 133void thread__insert_map(struct thread *thread, struct map *map) 134{ | 134} 135 136void thread__insert_map(struct thread *thread, struct map *map) 137{ |
135 map_groups__fixup_overlappings(thread->mg, map, verbose, stderr); | 138 map_groups__fixup_overlappings(thread->mg, map, stderr); |
136 map_groups__insert(thread->mg, map); 137} 138 139static int thread__clone_map_groups(struct thread *thread, 140 struct thread *parent) 141{ 142 int i; 143 --- 50 unchanged lines hidden --- | 139 map_groups__insert(thread->mg, map); 140} 141 142static int thread__clone_map_groups(struct thread *thread, 143 struct thread *parent) 144{ 145 int i; 146 --- 50 unchanged lines hidden --- |