From d599db3fc5dd4f1e8432fdbc6d899584b25f4dff Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Tue, 15 Dec 2009 20:04:42 -0200 Subject: perf report: Generalize perf_session__fprintf_hists() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Cc: Frédéric Weisbecker Cc: Mike Galbraith Cc: Peter Zijlstra Cc: Paul Mackerras LKML-Reference: <1260914682-29652-4-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar --- tools/perf/util/event.c | 30 +++++++++++++++++++++++++++++- tools/perf/util/hist.c | 7 +++---- tools/perf/util/session.c | 4 ++-- tools/perf/util/session.h | 1 - tools/perf/util/symbol.c | 1 + tools/perf/util/symbol.h | 5 ++++- 6 files changed, 39 insertions(+), 9 deletions(-) (limited to 'tools/perf/util') 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, closedir(proc); } +static void thread__comm_adjust(struct thread *self) +{ + char *comm = self->comm; + + if (!symbol_conf.col_width_list_str && !symbol_conf.field_sep && + (!symbol_conf.comm_list || + strlist__has_entry(symbol_conf.comm_list, comm))) { + unsigned int slen = strlen(comm); + + if (slen > comms__col_width) { + comms__col_width = slen; + threads__col_width = slen + 6; + } + } +} + +static int thread__set_comm_adjust(struct thread *self, const char *comm) +{ + int ret = thread__set_comm(self, comm); + + if (ret) + return ret; + + thread__comm_adjust(self); + + return 0; +} + int event__process_comm(event_t *self, struct perf_session *session) { struct thread *thread = perf_session__findnew(session, self->comm.pid); dump_printf(": %s:%d\n", self->comm.comm, self->comm.pid); - if (thread == NULL || thread__set_comm(thread, self->comm.comm)) { + if (thread == NULL || thread__set_comm_adjust(thread, self->comm.comm)) { dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n"); return -1; } 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) * reverse the map, sort on count. */ -static void perf_session__insert_output_hist_entry(struct perf_session *self, - struct rb_root *root, +static void perf_session__insert_output_hist_entry(struct rb_root *root, struct hist_entry *he, u64 min_callchain_hits) { @@ -165,7 +164,7 @@ static void perf_session__insert_output_hist_entry(struct perf_session *self, struct rb_node *parent = NULL; struct hist_entry *iter; - if (self->use_callchain) + if (symbol_conf.use_callchain) callchain_param.sort(&he->sorted_chain, &he->callchain, min_callchain_hits, &callchain_param); @@ -201,7 +200,7 @@ void perf_session__output_resort(struct perf_session *self, u64 total_samples) next = rb_next(&n->rb_node); rb_erase(&n->rb_node, &self->hists); - perf_session__insert_output_hist_entry(self, &tmp, n, + perf_session__insert_output_hist_entry(&tmp, n, min_callchain_hits); } 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, struct symbol **syms = NULL; unsigned int i; - if (self->use_callchain) { + if (symbol_conf.use_callchain) { syms = calloc(chain->nr, sizeof(*syms)); if (!syms) { fprintf(stderr, "Can't allocate memory for symbols\n"); @@ -140,7 +140,7 @@ struct symbol **perf_session__resolve_callchain(struct perf_session *self, if (sort__has_parent && !*parent && symbol__match_parent_regex(al.sym)) *parent = al.sym; - if (!self->use_callchain) + if (!symbol_conf.use_callchain) break; syms[i] = al.sym; } 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 { int fd; int cwdlen; char *cwd; - bool use_callchain; char filename[0]; }; 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; static char **vmlinux_path; struct symbol_conf symbol_conf = { + .exclude_other = true, .use_modules = true, .try_vmlinux_path = true, }; 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 { unsigned short priv_size; bool try_vmlinux_path, use_modules, - sort_by_name; + sort_by_name, + show_nr_samples, + use_callchain, + exclude_other; const char *vmlinux_name, *field_sep; char *dso_list_str, -- cgit v1.2.3