diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-12-15 17:04:42 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-16 02:53:50 -0500 |
commit | d599db3fc5dd4f1e8432fdbc6d899584b25f4dff (patch) | |
tree | fa455d1b9dede3983680d8ccb9dc25c14f4b45f6 /tools/perf/util | |
parent | c410a33887c17cac95ed8b0d860cdfb5c087a7d8 (diff) |
perf report: Generalize perf_session__fprintf_hists()
Pull it out of builtin-report - further changes will be made and it
will then be reusable in 'perf diff' as well.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1260914682-29652-4-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/event.c | 30 | ||||
-rw-r--r-- | tools/perf/util/hist.c | 7 | ||||
-rw-r--r-- | tools/perf/util/session.c | 4 | ||||
-rw-r--r-- | tools/perf/util/session.h | 1 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 1 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 5 |
6 files changed, 39 insertions, 9 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index bf491fda1f47..bb0fd6da2d56 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -189,13 +189,41 @@ void event__synthesize_threads(int (*process)(event_t *event, | |||
189 | closedir(proc); | 189 | closedir(proc); |
190 | } | 190 | } |
191 | 191 | ||
192 | static void thread__comm_adjust(struct thread *self) | ||
193 | { | ||
194 | char *comm = self->comm; | ||
195 | |||
196 | if (!symbol_conf.col_width_list_str && !symbol_conf.field_sep && | ||
197 | (!symbol_conf.comm_list || | ||
198 | strlist__has_entry(symbol_conf.comm_list, comm))) { | ||
199 | unsigned int slen = strlen(comm); | ||
200 | |||
201 | if (slen > comms__col_width) { | ||
202 | comms__col_width = slen; | ||
203 | threads__col_width = slen + 6; | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | |||
208 | static int thread__set_comm_adjust(struct thread *self, const char *comm) | ||
209 | { | ||
210 | int ret = thread__set_comm(self, comm); | ||
211 | |||
212 | if (ret) | ||
213 | return ret; | ||
214 | |||
215 | thread__comm_adjust(self); | ||
216 | |||
217 | return 0; | ||
218 | } | ||
219 | |||
192 | int event__process_comm(event_t *self, struct perf_session *session) | 220 | int event__process_comm(event_t *self, struct perf_session *session) |
193 | { | 221 | { |
194 | struct thread *thread = perf_session__findnew(session, self->comm.pid); | 222 | struct thread *thread = perf_session__findnew(session, self->comm.pid); |
195 | 223 | ||
196 | dump_printf(": %s:%d\n", self->comm.comm, self->comm.pid); | 224 | dump_printf(": %s:%d\n", self->comm.comm, self->comm.pid); |
197 | 225 | ||
198 | if (thread == NULL || thread__set_comm(thread, self->comm.comm)) { | 226 | if (thread == NULL || thread__set_comm_adjust(thread, self->comm.comm)) { |
199 | dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n"); | 227 | dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n"); |
200 | return -1; | 228 | return -1; |
201 | } | 229 | } |
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index b9828fce7bf0..d9a5a19391dc 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -156,8 +156,7 @@ void perf_session__collapse_resort(struct perf_session *self) | |||
156 | * reverse the map, sort on count. | 156 | * reverse the map, sort on count. |
157 | */ | 157 | */ |
158 | 158 | ||
159 | static void perf_session__insert_output_hist_entry(struct perf_session *self, | 159 | static void perf_session__insert_output_hist_entry(struct rb_root *root, |
160 | struct rb_root *root, | ||
161 | struct hist_entry *he, | 160 | struct hist_entry *he, |
162 | u64 min_callchain_hits) | 161 | u64 min_callchain_hits) |
163 | { | 162 | { |
@@ -165,7 +164,7 @@ static void perf_session__insert_output_hist_entry(struct perf_session *self, | |||
165 | struct rb_node *parent = NULL; | 164 | struct rb_node *parent = NULL; |
166 | struct hist_entry *iter; | 165 | struct hist_entry *iter; |
167 | 166 | ||
168 | if (self->use_callchain) | 167 | if (symbol_conf.use_callchain) |
169 | callchain_param.sort(&he->sorted_chain, &he->callchain, | 168 | callchain_param.sort(&he->sorted_chain, &he->callchain, |
170 | min_callchain_hits, &callchain_param); | 169 | min_callchain_hits, &callchain_param); |
171 | 170 | ||
@@ -201,7 +200,7 @@ void perf_session__output_resort(struct perf_session *self, u64 total_samples) | |||
201 | next = rb_next(&n->rb_node); | 200 | next = rb_next(&n->rb_node); |
202 | 201 | ||
203 | rb_erase(&n->rb_node, &self->hists); | 202 | rb_erase(&n->rb_node, &self->hists); |
204 | perf_session__insert_output_hist_entry(self, &tmp, n, | 203 | perf_session__insert_output_hist_entry(&tmp, n, |
205 | min_callchain_hits); | 204 | min_callchain_hits); |
206 | } | 205 | } |
207 | 206 | ||
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index bceaa09f55a1..ce3a6c8abe76 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c | |||
@@ -108,7 +108,7 @@ struct symbol **perf_session__resolve_callchain(struct perf_session *self, | |||
108 | struct symbol **syms = NULL; | 108 | struct symbol **syms = NULL; |
109 | unsigned int i; | 109 | unsigned int i; |
110 | 110 | ||
111 | if (self->use_callchain) { | 111 | if (symbol_conf.use_callchain) { |
112 | syms = calloc(chain->nr, sizeof(*syms)); | 112 | syms = calloc(chain->nr, sizeof(*syms)); |
113 | if (!syms) { | 113 | if (!syms) { |
114 | fprintf(stderr, "Can't allocate memory for symbols\n"); | 114 | fprintf(stderr, "Can't allocate memory for symbols\n"); |
@@ -140,7 +140,7 @@ struct symbol **perf_session__resolve_callchain(struct perf_session *self, | |||
140 | if (sort__has_parent && !*parent && | 140 | if (sort__has_parent && !*parent && |
141 | symbol__match_parent_regex(al.sym)) | 141 | symbol__match_parent_regex(al.sym)) |
142 | *parent = al.sym; | 142 | *parent = al.sym; |
143 | if (!self->use_callchain) | 143 | if (!symbol_conf.use_callchain) |
144 | break; | 144 | break; |
145 | syms[i] = al.sym; | 145 | syms[i] = al.sym; |
146 | } | 146 | } |
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index faf18a8e0311..32eaa1bada06 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h | |||
@@ -25,7 +25,6 @@ struct perf_session { | |||
25 | int fd; | 25 | int fd; |
26 | int cwdlen; | 26 | int cwdlen; |
27 | char *cwd; | 27 | char *cwd; |
28 | bool use_callchain; | ||
29 | char filename[0]; | 28 | char filename[0]; |
30 | }; | 29 | }; |
31 | 30 | ||
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 7707897b59f1..ab92763edb03 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -38,6 +38,7 @@ static int vmlinux_path__nr_entries; | |||
38 | static char **vmlinux_path; | 38 | static char **vmlinux_path; |
39 | 39 | ||
40 | struct symbol_conf symbol_conf = { | 40 | struct symbol_conf symbol_conf = { |
41 | .exclude_other = true, | ||
41 | .use_modules = true, | 42 | .use_modules = true, |
42 | .try_vmlinux_path = true, | 43 | .try_vmlinux_path = true, |
43 | }; | 44 | }; |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 60151521f41d..8aded2356f79 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -55,7 +55,10 @@ struct symbol_conf { | |||
55 | unsigned short priv_size; | 55 | unsigned short priv_size; |
56 | bool try_vmlinux_path, | 56 | bool try_vmlinux_path, |
57 | use_modules, | 57 | use_modules, |
58 | sort_by_name; | 58 | sort_by_name, |
59 | show_nr_samples, | ||
60 | use_callchain, | ||
61 | exclude_other; | ||
59 | const char *vmlinux_name, | 62 | const char *vmlinux_name, |
60 | *field_sep; | 63 | *field_sep; |
61 | char *dso_list_str, | 64 | char *dso_list_str, |