diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-12-15 17:04:41 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-16 02:53:49 -0500 |
commit | c410a33887c17cac95ed8b0d860cdfb5c087a7d8 (patch) | |
tree | 54fe6ed5ac64ff77763ff686af58bd36b04e73d6 /tools/perf/util | |
parent | 655000e7c75a559681ee7f15f6fa870c80ae3194 (diff) |
perf symbols: Move symbol filtering to event__preprocess_sample()
So that --dsos, --comm, --symbols can bem used in more tools,
like in perf diff:
$ perf record -f find / > /dev/null
$ perf record -f find / > /dev/null
$ perf diff --dsos /lib64/libc-2.10.1.so | head -5
1 +22392124 /lib64/libc-2.10.1.so _IO_vfprintf_internal
2 +6410655 /lib64/libc-2.10.1.so __GI_memmove
3 +1 +9192692 /lib64/libc-2.10.1.so _int_malloc
4 -1 -15158605 /lib64/libc-2.10.1.so _int_free
5 +45669 /lib64/libc-2.10.1.so _IO_new_file_xsputn
$
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-3-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 | 42 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 5 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 4 |
3 files changed, 50 insertions, 1 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 375fb6dca1cf..bf491fda1f47 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -2,7 +2,9 @@ | |||
2 | #include "event.h" | 2 | #include "event.h" |
3 | #include "debug.h" | 3 | #include "debug.h" |
4 | #include "session.h" | 4 | #include "session.h" |
5 | #include "sort.h" | ||
5 | #include "string.h" | 6 | #include "string.h" |
7 | #include "strlist.h" | ||
6 | #include "thread.h" | 8 | #include "thread.h" |
7 | 9 | ||
8 | static pid_t event__synthesize_comm(pid_t pid, int full, | 10 | static pid_t event__synthesize_comm(pid_t pid, int full, |
@@ -299,6 +301,19 @@ try_again: | |||
299 | } | 301 | } |
300 | } | 302 | } |
301 | 303 | ||
304 | static void dso__calc_col_width(struct dso *self) | ||
305 | { | ||
306 | if (!symbol_conf.col_width_list_str && !symbol_conf.field_sep && | ||
307 | (!symbol_conf.dso_list || | ||
308 | strlist__has_entry(symbol_conf.dso_list, self->name))) { | ||
309 | unsigned int slen = strlen(self->name); | ||
310 | if (slen > dsos__col_width) | ||
311 | dsos__col_width = slen; | ||
312 | } | ||
313 | |||
314 | self->slen_calculated = 1; | ||
315 | } | ||
316 | |||
302 | int event__preprocess_sample(const event_t *self, struct perf_session *session, | 317 | int event__preprocess_sample(const event_t *self, struct perf_session *session, |
303 | struct addr_location *al, symbol_filter_t filter) | 318 | struct addr_location *al, symbol_filter_t filter) |
304 | { | 319 | { |
@@ -308,6 +323,10 @@ int event__preprocess_sample(const event_t *self, struct perf_session *session, | |||
308 | if (thread == NULL) | 323 | if (thread == NULL) |
309 | return -1; | 324 | return -1; |
310 | 325 | ||
326 | if (symbol_conf.comm_list && | ||
327 | !strlist__has_entry(symbol_conf.comm_list, thread->comm)) | ||
328 | goto out_filtered; | ||
329 | |||
311 | dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid); | 330 | dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid); |
312 | 331 | ||
313 | thread__find_addr_location(thread, session, cpumode, MAP__FUNCTION, | 332 | thread__find_addr_location(thread, session, cpumode, MAP__FUNCTION, |
@@ -315,6 +334,29 @@ int event__preprocess_sample(const event_t *self, struct perf_session *session, | |||
315 | dump_printf(" ...... dso: %s\n", | 334 | dump_printf(" ...... dso: %s\n", |
316 | al->map ? al->map->dso->long_name : | 335 | al->map ? al->map->dso->long_name : |
317 | al->level == 'H' ? "[hypervisor]" : "<not found>"); | 336 | al->level == 'H' ? "[hypervisor]" : "<not found>"); |
337 | /* | ||
338 | * We have to do this here as we may have a dso with no symbol hit that | ||
339 | * has a name longer than the ones with symbols sampled. | ||
340 | */ | ||
341 | if (al->map && !sort_dso.elide && !al->map->dso->slen_calculated) | ||
342 | dso__calc_col_width(al->map->dso); | ||
343 | |||
344 | if (symbol_conf.dso_list && | ||
345 | (!al->map || !al->map->dso || | ||
346 | !(strlist__has_entry(symbol_conf.dso_list, al->map->dso->short_name) || | ||
347 | (al->map->dso->short_name != al->map->dso->long_name && | ||
348 | strlist__has_entry(symbol_conf.dso_list, al->map->dso->long_name))))) | ||
349 | goto out_filtered; | ||
350 | |||
351 | if (symbol_conf.sym_list && al->sym && | ||
352 | !strlist__has_entry(symbol_conf.sym_list, al->sym->name)) | ||
353 | goto out_filtered; | ||
354 | |||
355 | al->filtered = false; | ||
356 | return 0; | ||
357 | |||
358 | out_filtered: | ||
359 | al->filtered = true; | ||
318 | return 0; | 360 | return 0; |
319 | } | 361 | } |
320 | 362 | ||
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 164286ace7df..7707897b59f1 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -1764,6 +1764,11 @@ int symbol__init(void) | |||
1764 | if (symbol_conf.try_vmlinux_path && vmlinux_path__init() < 0) | 1764 | if (symbol_conf.try_vmlinux_path && vmlinux_path__init() < 0) |
1765 | return -1; | 1765 | return -1; |
1766 | 1766 | ||
1767 | if (symbol_conf.field_sep && *symbol_conf.field_sep == '.') { | ||
1768 | pr_err("'.' is the only non valid --field-separator argument\n"); | ||
1769 | return -1; | ||
1770 | } | ||
1771 | |||
1767 | if (setup_list(&symbol_conf.dso_list, | 1772 | if (setup_list(&symbol_conf.dso_list, |
1768 | symbol_conf.dso_list_str, "dso") < 0) | 1773 | symbol_conf.dso_list_str, "dso") < 0) |
1769 | return -1; | 1774 | return -1; |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index d61f35074997..60151521f41d 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -56,7 +56,8 @@ struct symbol_conf { | |||
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 | const char *vmlinux_name; | 59 | const char *vmlinux_name, |
60 | *field_sep; | ||
60 | char *dso_list_str, | 61 | char *dso_list_str, |
61 | *comm_list_str, | 62 | *comm_list_str, |
62 | *sym_list_str, | 63 | *sym_list_str, |
@@ -79,6 +80,7 @@ struct addr_location { | |||
79 | struct symbol *sym; | 80 | struct symbol *sym; |
80 | u64 addr; | 81 | u64 addr; |
81 | char level; | 82 | char level; |
83 | bool filtered; | ||
82 | }; | 84 | }; |
83 | 85 | ||
84 | struct dso { | 86 | struct dso { |