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>
This commit is contained in:
Arnaldo Carvalho de Melo
2009-12-15 20:04:42 -02:00
committed by Ingo Molnar
parent c410a33887
commit d599db3fc5
7 changed files with 68 additions and 94 deletions
+29 -1
View File
@@ -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;
}
+3 -4
View File
@@ -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);
}
+2 -2
View File
@@ -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;
}
-1
View File
@@ -25,7 +25,6 @@ struct perf_session {
int fd;
int cwdlen;
char *cwd;
bool use_callchain;
char filename[0];
};
+1
View File
@@ -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,
};
+4 -1
View File
@@ -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,