diff options
-rw-r--r-- | tools/perf/arch/x86/tests/dwarf-unwind.c | 2 | ||||
-rw-r--r-- | tools/perf/ui/stdio/hist.c | 2 | ||||
-rw-r--r-- | tools/perf/util/event.c | 2 | ||||
-rw-r--r-- | tools/perf/util/map.c | 16 | ||||
-rw-r--r-- | tools/perf/util/map.h | 3 | ||||
-rw-r--r-- | tools/perf/util/thread.c | 18 | ||||
-rw-r--r-- | tools/perf/util/thread.h | 2 |
7 files changed, 35 insertions, 10 deletions
diff --git a/tools/perf/arch/x86/tests/dwarf-unwind.c b/tools/perf/arch/x86/tests/dwarf-unwind.c index b8c0102c70c8..c916656259f7 100644 --- a/tools/perf/arch/x86/tests/dwarf-unwind.c +++ b/tools/perf/arch/x86/tests/dwarf-unwind.c | |||
@@ -23,7 +23,7 @@ static int sample_ustack(struct perf_sample *sample, | |||
23 | 23 | ||
24 | sp = (unsigned long) regs[PERF_REG_X86_SP]; | 24 | sp = (unsigned long) regs[PERF_REG_X86_SP]; |
25 | 25 | ||
26 | map = map_groups__find(&thread->mg, MAP__FUNCTION, (u64) sp); | 26 | map = map_groups__find(thread->mg, MAP__FUNCTION, (u64) sp); |
27 | if (!map) { | 27 | if (!map) { |
28 | pr_debug("failed to get stack map\n"); | 28 | pr_debug("failed to get stack map\n"); |
29 | free(buf); | 29 | free(buf); |
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index d59893edf031..9eccf7f4f367 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c | |||
@@ -495,7 +495,7 @@ print_entries: | |||
495 | break; | 495 | break; |
496 | 496 | ||
497 | if (h->ms.map == NULL && verbose > 1) { | 497 | if (h->ms.map == NULL && verbose > 1) { |
498 | __map_groups__fprintf_maps(&h->thread->mg, | 498 | __map_groups__fprintf_maps(h->thread->mg, |
499 | MAP__FUNCTION, verbose, fp); | 499 | MAP__FUNCTION, verbose, fp); |
500 | fprintf(fp, "%.10s end\n", graph_dotted_line); | 500 | fprintf(fp, "%.10s end\n", graph_dotted_line); |
501 | } | 501 | } |
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 9d12aa6dd485..dbcaea1a8180 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -699,7 +699,7 @@ void thread__find_addr_map(struct thread *thread, | |||
699 | enum map_type type, u64 addr, | 699 | enum map_type type, u64 addr, |
700 | struct addr_location *al) | 700 | struct addr_location *al) |
701 | { | 701 | { |
702 | struct map_groups *mg = &thread->mg; | 702 | struct map_groups *mg = thread->mg; |
703 | bool load_map = false; | 703 | bool load_map = false; |
704 | 704 | ||
705 | al->machine = machine; | 705 | al->machine = machine; |
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 39cd2d0faff6..ae4c5e12debd 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
@@ -358,6 +358,22 @@ void map_groups__exit(struct map_groups *mg) | |||
358 | } | 358 | } |
359 | } | 359 | } |
360 | 360 | ||
361 | struct map_groups *map_groups__new(void) | ||
362 | { | ||
363 | struct map_groups *mg = malloc(sizeof(*mg)); | ||
364 | |||
365 | if (mg != NULL) | ||
366 | map_groups__init(mg); | ||
367 | |||
368 | return mg; | ||
369 | } | ||
370 | |||
371 | void map_groups__delete(struct map_groups *mg) | ||
372 | { | ||
373 | map_groups__exit(mg); | ||
374 | free(mg); | ||
375 | } | ||
376 | |||
361 | void map_groups__flush(struct map_groups *mg) | 377 | void map_groups__flush(struct map_groups *mg) |
362 | { | 378 | { |
363 | int type; | 379 | int type; |
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h index f00f058afb3b..1073e2d8b797 100644 --- a/tools/perf/util/map.h +++ b/tools/perf/util/map.h | |||
@@ -61,6 +61,9 @@ struct map_groups { | |||
61 | struct machine *machine; | 61 | struct machine *machine; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | struct map_groups *map_groups__new(void); | ||
65 | void map_groups__delete(struct map_groups *mg); | ||
66 | |||
64 | static inline struct kmap *map__kmap(struct map *map) | 67 | static inline struct kmap *map__kmap(struct map *map) |
65 | { | 68 | { |
66 | return (struct kmap *)(map + 1); | 69 | return (struct kmap *)(map + 1); |
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index 3ce0498bdae6..dc51d1632e92 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c | |||
@@ -15,7 +15,10 @@ struct thread *thread__new(pid_t pid, pid_t tid) | |||
15 | struct thread *thread = zalloc(sizeof(*thread)); | 15 | struct thread *thread = zalloc(sizeof(*thread)); |
16 | 16 | ||
17 | if (thread != NULL) { | 17 | if (thread != NULL) { |
18 | map_groups__init(&thread->mg); | 18 | thread->mg = map_groups__new(); |
19 | if (thread->mg == NULL) | ||
20 | goto out_free; | ||
21 | |||
19 | thread->pid_ = pid; | 22 | thread->pid_ = pid; |
20 | thread->tid = tid; | 23 | thread->tid = tid; |
21 | thread->ppid = -1; | 24 | thread->ppid = -1; |
@@ -37,6 +40,8 @@ struct thread *thread__new(pid_t pid, pid_t tid) | |||
37 | return thread; | 40 | return thread; |
38 | 41 | ||
39 | err_thread: | 42 | err_thread: |
43 | map_groups__delete(thread->mg); | ||
44 | out_free: | ||
40 | free(thread); | 45 | free(thread); |
41 | return NULL; | 46 | return NULL; |
42 | } | 47 | } |
@@ -45,7 +50,8 @@ void thread__delete(struct thread *thread) | |||
45 | { | 50 | { |
46 | struct comm *comm, *tmp; | 51 | struct comm *comm, *tmp; |
47 | 52 | ||
48 | map_groups__exit(&thread->mg); | 53 | map_groups__delete(thread->mg); |
54 | thread->mg = NULL; | ||
49 | list_for_each_entry_safe(comm, tmp, &thread->comm_list, list) { | 55 | list_for_each_entry_safe(comm, tmp, &thread->comm_list, list) { |
50 | list_del(&comm->list); | 56 | list_del(&comm->list); |
51 | comm__free(comm); | 57 | comm__free(comm); |
@@ -111,13 +117,13 @@ int thread__comm_len(struct thread *thread) | |||
111 | size_t thread__fprintf(struct thread *thread, FILE *fp) | 117 | size_t thread__fprintf(struct thread *thread, FILE *fp) |
112 | { | 118 | { |
113 | return fprintf(fp, "Thread %d %s\n", thread->tid, thread__comm_str(thread)) + | 119 | return fprintf(fp, "Thread %d %s\n", thread->tid, thread__comm_str(thread)) + |
114 | map_groups__fprintf(&thread->mg, verbose, fp); | 120 | map_groups__fprintf(thread->mg, verbose, fp); |
115 | } | 121 | } |
116 | 122 | ||
117 | void thread__insert_map(struct thread *thread, struct map *map) | 123 | void thread__insert_map(struct thread *thread, struct map *map) |
118 | { | 124 | { |
119 | map_groups__fixup_overlappings(&thread->mg, map, verbose, stderr); | 125 | map_groups__fixup_overlappings(thread->mg, map, verbose, stderr); |
120 | map_groups__insert(&thread->mg, map); | 126 | map_groups__insert(thread->mg, map); |
121 | } | 127 | } |
122 | 128 | ||
123 | int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp) | 129 | int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp) |
@@ -135,7 +141,7 @@ int thread__fork(struct thread *thread, struct thread *parent, u64 timestamp) | |||
135 | } | 141 | } |
136 | 142 | ||
137 | for (i = 0; i < MAP__NR_TYPES; ++i) | 143 | for (i = 0; i < MAP__NR_TYPES; ++i) |
138 | if (map_groups__clone(&thread->mg, &parent->mg, i) < 0) | 144 | if (map_groups__clone(thread->mg, parent->mg, i) < 0) |
139 | return -ENOMEM; | 145 | return -ENOMEM; |
140 | 146 | ||
141 | thread->ppid = parent->tid; | 147 | thread->ppid = parent->tid; |
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h index 9b29f085aede..bee1eb0f73bc 100644 --- a/tools/perf/util/thread.h +++ b/tools/perf/util/thread.h | |||
@@ -13,7 +13,7 @@ struct thread { | |||
13 | struct rb_node rb_node; | 13 | struct rb_node rb_node; |
14 | struct list_head node; | 14 | struct list_head node; |
15 | }; | 15 | }; |
16 | struct map_groups mg; | 16 | struct map_groups *mg; |
17 | pid_t pid_; /* Not all tools update this */ | 17 | pid_t pid_; /* Not all tools update this */ |
18 | pid_t tid; | 18 | pid_t tid; |
19 | pid_t ppid; | 19 | pid_t ppid; |