提交 e94d53eb 编写于 作者: N Namhyung Kim 提交者: Arnaldo Carvalho de Melo

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.comSigned-off-by: NNamhyung Kim <namhyung.kim@lge.com>
Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 5090c6ae
...@@ -10,11 +10,14 @@ static bool hists__filter_entry_by_dso(struct hists *hists, ...@@ -10,11 +10,14 @@ static bool hists__filter_entry_by_dso(struct hists *hists,
struct hist_entry *he); struct hist_entry *he);
static bool hists__filter_entry_by_thread(struct hists *hists, static bool hists__filter_entry_by_thread(struct hists *hists,
struct hist_entry *he); struct hist_entry *he);
static bool hists__filter_entry_by_symbol(struct hists *hists,
struct hist_entry *he);
enum hist_filter { enum hist_filter {
HIST_FILTER__DSO, HIST_FILTER__DSO,
HIST_FILTER__THREAD, HIST_FILTER__THREAD,
HIST_FILTER__PARENT, HIST_FILTER__PARENT,
HIST_FILTER__SYMBOL,
}; };
struct callchain_param callchain_param = { struct callchain_param callchain_param = {
...@@ -420,6 +423,7 @@ static void hists__apply_filters(struct hists *hists, struct hist_entry *he) ...@@ -420,6 +423,7 @@ static void hists__apply_filters(struct hists *hists, struct hist_entry *he)
{ {
hists__filter_entry_by_dso(hists, he); hists__filter_entry_by_dso(hists, he);
hists__filter_entry_by_thread(hists, he); hists__filter_entry_by_thread(hists, he);
hists__filter_entry_by_symbol(hists, he);
} }
static void __hists__collapse_resort(struct hists *hists, bool threaded) static void __hists__collapse_resort(struct hists *hists, bool threaded)
...@@ -1247,6 +1251,37 @@ void hists__filter_by_thread(struct hists *hists) ...@@ -1247,6 +1251,37 @@ void hists__filter_by_thread(struct hists *hists)
} }
} }
static bool hists__filter_entry_by_symbol(struct hists *hists,
struct hist_entry *he)
{
if (hists->symbol_filter_str != NULL &&
(!he->ms.sym || strstr(he->ms.sym->name,
hists->symbol_filter_str) == NULL)) {
he->filtered |= (1 << HIST_FILTER__SYMBOL);
return true;
}
return false;
}
void hists__filter_by_symbol(struct hists *hists)
{
struct rb_node *nd;
hists->nr_entries = hists->stats.total_period = 0;
hists->stats.nr_events[PERF_RECORD_SAMPLE] = 0;
hists__reset_col_len(hists);
for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
if (hists__filter_entry_by_symbol(hists, h))
continue;
hists__remove_entry_filter(hists, h, HIST_FILTER__SYMBOL);
}
}
int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 ip) int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 ip)
{ {
return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evidx, ip); return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evidx, ip);
......
...@@ -62,6 +62,7 @@ struct hists { ...@@ -62,6 +62,7 @@ struct hists {
const struct thread *thread_filter; const struct thread *thread_filter;
const struct dso *dso_filter; const struct dso *dso_filter;
const char *uid_filter_str; const char *uid_filter_str;
const char *symbol_filter_str;
pthread_mutex_t lock; pthread_mutex_t lock;
struct events_stats stats; struct events_stats stats;
u64 event_stream; u64 event_stream;
...@@ -107,6 +108,7 @@ int hist_entry__annotate(struct hist_entry *self, size_t privsize); ...@@ -107,6 +108,7 @@ int hist_entry__annotate(struct hist_entry *self, size_t privsize);
void hists__filter_by_dso(struct hists *hists); void hists__filter_by_dso(struct hists *hists);
void hists__filter_by_thread(struct hists *hists); void hists__filter_by_thread(struct hists *hists);
void hists__filter_by_symbol(struct hists *hists);
u16 hists__col_len(struct hists *self, enum hist_column col); u16 hists__col_len(struct hists *self, enum hist_column col);
void hists__set_col_len(struct hists *self, enum hist_column col, u16 len); void hists__set_col_len(struct hists *self, enum hist_column col, u16 len);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册