From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@kernel.org>,
Namhyung Kim <namhyung.kim@lge.com>,
LKML <linux-kernel@vger.kernel.org>, Jiri Olsa <jolsa@redhat.com>,
David Ahern <dsahern@gmail.com>
Subject: [PATCH 7/7] perf ui/tui: Filter messages in log window
Date: Fri, 20 Dec 2013 14:11:18 +0900 [thread overview]
Message-ID: <1387516278-17024-8-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1387516278-17024-1-git-send-email-namhyung@kernel.org>
From: Namhyung Kim <namhyung.kim@lge.com>
Press '/' key to input filter string like main hist browser does.
Requested-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
tools/perf/ui/browsers/log.c | 62 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 61 insertions(+), 1 deletion(-)
diff --git a/tools/perf/ui/browsers/log.c b/tools/perf/ui/browsers/log.c
index 592e2774e919..84b708073441 100644
--- a/tools/perf/ui/browsers/log.c
+++ b/tools/perf/ui/browsers/log.c
@@ -25,7 +25,7 @@ static void ui_browser__file_write(struct ui_browser *browser,
char empty[] = " ";
FILE *fp = perf_log.fp;
bool current_entry = ui_browser__is_current_entry(browser, row);
- off_t *linemap = perf_log.linemap;
+ off_t *linemap = browser->entries;
unsigned int idx = *(unsigned int *)entry;
unsigned long offset = (unsigned long)browser->priv;
@@ -59,9 +59,60 @@ static unsigned int ui_browser__file_refresh(struct ui_browser *browser)
return row;
}
+static void log_menu__filter(struct ui_browser *menu, char *filter)
+{
+ char buf[1024];
+ off_t *linemap = NULL;
+ u32 lines = 0;
+ u32 alloc = 0;
+ u32 i;
+
+ if (*filter == '\0') {
+ linemap = perf_log.linemap;
+ lines = perf_log.lines;
+ goto out;
+ }
+
+ if (menu->entries != perf_log.linemap)
+ free(menu->entries);
+
+ for (i = 0; i < perf_log.lines; i++) {
+ fseek(perf_log.fp, perf_log.linemap[i], SEEK_SET);
+ if (fgets(buf, sizeof(buf), perf_log.fp) == NULL)
+ goto error;
+
+ if (strstr(buf, filter) == NULL)
+ continue;
+
+ if (lines == alloc) {
+ off_t *map;
+
+ map = realloc(linemap, (alloc + 128) * sizeof(*linemap));
+ if (map == NULL)
+ goto error;
+
+ linemap = map;
+ alloc += 128;
+ }
+
+ linemap[lines++] = perf_log.linemap[i];
+ }
+out:
+ menu->entries = linemap;
+ menu->nr_entries = lines;
+
+ menu->top_idx = 0;
+ menu->index = 0;
+ return;
+
+error:
+ free(linemap);
+}
+
static int log_menu__run(struct ui_browser *menu)
{
int key;
+ char buf[64];
unsigned long offset;
if (ui_browser__show(menu, "Log messages", "Press 'q' to exit") < 0)
@@ -82,6 +133,14 @@ static int log_menu__run(struct ui_browser *menu)
offset -= 10;
menu->priv = (void *)offset;
continue;
+ case '/':
+ if (ui_browser__input_window("Symbol to show",
+ "Please enter the name of symbol you want to see",
+ buf, "ENTER: OK, ESC: Cancel",
+ 0) == K_ENTER) {
+ log_menu__filter(menu, buf);
+ }
+ continue;
case K_ESC:
case 'q':
case CTRL('c'):
@@ -104,6 +163,7 @@ int tui__log_window(void)
.refresh = ui_browser__file_refresh,
.seek = ui_browser__file_seek,
.write = ui_browser__file_write,
+ .entries = perf_log.linemap,
.nr_entries = perf_log.lines,
};
--
1.7.11.7
next prev parent reply other threads:[~2013-12-20 5:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-20 5:11 [PATCHSET 0/7] perf tools: A couple of TUI improvements (v2) Namhyung Kim
2013-12-20 5:11 ` [PATCH 1/7] perf report: Use pr_*() functions if possible Namhyung Kim
2014-01-12 18:36 ` [tip:perf/core] perf report: Use pr_*() functions where applicable tip-bot for Namhyung Kim
2013-12-20 5:11 ` [PATCH 2/7] perf report: Print session information only if --stdio is given Namhyung Kim
2014-01-12 18:36 ` [tip:perf/core] " tip-bot for Namhyung Kim
2013-12-20 5:11 ` [PATCH 3/7] perf tools: Introduce struct perf_log Namhyung Kim
2013-12-20 5:11 ` [PATCH 4/7] perf tools: Save message when pr_*() was called Namhyung Kim
2013-12-20 5:11 ` [PATCH 5/7] perf ui/tui: Implement log window Namhyung Kim
2013-12-20 5:11 ` [PATCH 6/7] perf ui/tui: Implement header window Namhyung Kim
2013-12-20 5:11 ` Namhyung Kim [this message]
2013-12-20 5:21 ` [PATCH v2.1 7/7] perf ui/tui: Filter messages in log window Namhyung Kim
2013-12-20 8:13 ` [PATCHSET 0/7] perf tools: A couple of TUI improvements (v2) Ingo Molnar
2013-12-23 5:13 ` Namhyung Kim
2013-12-23 13:06 ` Ingo Molnar
2013-12-20 17:33 ` Jiri Olsa
2013-12-23 5:23 ` Namhyung Kim
2013-12-23 11:26 ` Jiri Olsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1387516278-17024-8-git-send-email-namhyung@kernel.org \
--to=namhyung@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=dsahern@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung.kim@lge.com \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®