浏览代码

perf tools: Make Ctrl-C stop processing on TUI

It was inconvenient that perf cannot be quit with SIGINT during
processing samples on TUI especially for large data files.

This was because the first argument of SLang_init_tty(), abort_char,
being 0.  The manual says it's the ascii value of the control character
that will be used to generate the interrupt signal [1].  Passing -1
means to use the default value (Ctrl-C).

However, after processing samples, Ctrl-C was used to in other cases as
well - like stepping back from annotate.  So recover the original
behavior after processing.

[1] http://jedsoft.org/slang/doc/html/cslang-6.html#ss6.1

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1432904024-13170-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Namhyung Kim 10 年之前
父节点
当前提交
ed42691590
共有 3 个文件被更改,包括 9 次插入1 次删除
  1. 4 0
      tools/perf/ui/browsers/annotate.c
  2. 4 0
      tools/perf/ui/browsers/hists.c
  3. 1 1
      tools/perf/ui/tui/setup.c

+ 4 - 0
tools/perf/ui/browsers/annotate.c

@@ -838,6 +838,10 @@ int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel,
 int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel,
 int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel,
 			     struct hist_browser_timer *hbt)
 			     struct hist_browser_timer *hbt)
 {
 {
+	/* reset abort key so that it can get Ctrl-C as a key */
+	SLang_reset_tty();
+	SLang_init_tty(0, 0, 0);
+
 	return map_symbol__tui_annotate(&he->ms, evsel, hbt);
 	return map_symbol__tui_annotate(&he->ms, evsel, hbt);
 }
 }
 
 

+ 4 - 0
tools/perf/ui/browsers/hists.c

@@ -1741,6 +1741,10 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
 	if (browser == NULL)
 	if (browser == NULL)
 		return -1;
 		return -1;
 
 
+	/* reset abort key so that it can get Ctrl-C as a key */
+	SLang_reset_tty();
+	SLang_init_tty(0, 0, 0);
+
 	if (min_pcnt) {
 	if (min_pcnt) {
 		browser->min_pcnt = min_pcnt;
 		browser->min_pcnt = min_pcnt;
 		hist_browser__update_nr_entries(browser);
 		hist_browser__update_nr_entries(browser);

+ 1 - 1
tools/perf/ui/tui/setup.c

@@ -129,7 +129,7 @@ int ui__init(void)
 	err = SLsmg_init_smg();
 	err = SLsmg_init_smg();
 	if (err < 0)
 	if (err < 0)
 		goto out;
 		goto out;
-	err = SLang_init_tty(0, 0, 0);
+	err = SLang_init_tty(-1, 0, 0);
 	if (err < 0)
 	if (err < 0)
 		goto out;
 		goto out;