aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung.kim@lge.com>2012-03-16 04:50:51 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-03-16 15:31:09 -0400
commite94d53ebec2fb4795c18ad2e76ec633390b1e794 (patch)
treee73b5b765d3383b7d09e713f6d5659fc1062c5e5 /tools/perf/util
parent5090c6aea84dcc474d0aabf9f66f1eab68a143eb (diff)
perf hists: Add hists__filter_by_symbol
This function will be used for simple (sub-)string matching filter based on user input. Cc: Ingo Molnar <mingo@elte.hu> Cc: Namhyung Kim <namhyung@gmail.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1331887855-874-1-git-send-email-namhyung.kim@lge.com Signed-off-by: Namhyung Kim <namhyung.kim@lge.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/hist.c35
-rw-r--r--tools/perf/util/hist.h2
2 files changed, 37 insertions, 0 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 8380c3db1c92..2c624ad371a7 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -10,11 +10,14 @@ static bool hists__filter_entry_by_dso(struct hists *hists,
10 struct hist_entry *he); 10 struct hist_entry *he);
11static bool hists__filter_entry_by_thread(struct hists *hists, 11static bool hists__filter_entry_by_thread(struct hists *hists,
12 struct hist_entry *he); 12 struct hist_entry *he);
13static bool hists__filter_entry_by_symbol(struct hists *hists,
14 struct hist_entry *he);
13 15
14enum hist_filter { 16enum hist_filter {
15 HIST_FILTER__DSO, 17 HIST_FILTER__DSO,
16 HIST_FILTER__THREAD, 18 HIST_FILTER__THREAD,
17 HIST_FILTER__PARENT, 19 HIST_FILTER__PARENT,
20 HIST_FILTER__SYMBOL,
18}; 21};
19 22
20struct callchain_param callchain_param = { 23struct callchain_param callchain_param = {
@@ -420,6 +423,7 @@ static void hists__apply_filters(struct hists *hists, struct hist_entry *he)
420{ 423{
421 hists__filter_entry_by_dso(hists, he); 424 hists__filter_entry_by_dso(hists, he);
422 hists__filter_entry_by_thread(hists, he); 425 hists__filter_entry_by_thread(hists, he);
426 hists__filter_entry_by_symbol(hists, he);
423} 427}
424 428
425static void __hists__collapse_resort(struct hists *hists, bool threaded) 429static void __hists__collapse_resort(struct hists *hists, bool threaded)
@@ -1247,6 +1251,37 @@ void hists__filter_by_thread(struct hists *hists)
1247 } 1251 }
1248} 1252}
1249 1253
1254static bool hists__filter_entry_by_symbol(struct hists *hists,
1255 struct hist_entry *he)
1256{
1257 if (hists->symbol_filter_str != NULL &&
1258 (!he->ms.sym || strstr(he->ms.sym->name,
1259 hists->symbol_filter_str) == NULL)) {
1260 he->filtered |= (1 << HIST_FILTER__SYMBOL);
1261 return true;
1262 }
1263
1264 return false;
1265}
1266
1267void hists__filter_by_symbol(struct hists *hists)
1268{
1269 struct rb_node *nd;
1270
1271 hists->nr_entries = hists->stats.total_period = 0;
1272 hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
1273 hists__reset_col_len(hists);
1274
1275 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
1276 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
1277
1278 if (hists__filter_entry_by_symbol(hists, h))
1279 continue;
1280
1281 hists__remove_entry_filter(hists, h, HIST_FILTER__SYMBOL);
1282 }
1283}
1284
1250int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 ip) 1285int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 ip)
1251{ 1286{
1252 return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evidx, ip); 1287 return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evidx, ip);
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index 9413f3e31fea..10343c081e19 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -62,6 +62,7 @@ struct hists {
62 const struct thread *thread_filter; 62 const struct thread *thread_filter;
63 const struct dso *dso_filter; 63 const struct dso *dso_filter;
64 const char *uid_filter_str; 64 const char *uid_filter_str;
65 const char *symbol_filter_str;
65 pthread_mutex_t lock; 66 pthread_mutex_t lock;
66 struct events_stats stats; 67 struct events_stats stats;
67 u64 event_stream; 68 u64 event_stream;
@@ -107,6 +108,7 @@ int hist_entry__annotate(struct hist_entry *self, size_t privsize);
107 108
108void hists__filter_by_dso(struct hists *hists); 109void hists__filter_by_dso(struct hists *hists);
109void hists__filter_by_thread(struct hists *hists); 110void hists__filter_by_thread(struct hists *hists);
111void hists__filter_by_symbol(struct hists *hists);
110 112
111u16 hists__col_len(struct hists *self, enum hist_column col); 113u16 hists__col_len(struct hists *self, enum hist_column col);
112void hists__set_col_len(struct hists *self, enum hist_column col, u16 len); 114void hists__set_col_len(struct hists *self, enum hist_column col, u16 len);