lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Sat, 18 Feb 2012 12:29:16 -0800
From:	Sukadev Bhattiprolu <sukadev@...ux.vnet.ibm.com>
To:	a.p.zijlstra@...llo.nl, paulus@...ba.org, mingo@...e.hu,
	acme@...stprotocols.net
Cc:	anton@...ba.org, sukadev@...ibm.com, linux-kernel@...r.kernel.org
Subject: [PATCH 1/1] perf: Ignore tui when built with NO_NEWT

From: Sukadev Bhattiprolu <sukadev@...ux.vnet.ibm.com>
Date: Fri, 17 Feb 2012 17:20:05 -0800
Subject: [PATCH 1/1] perf: Ignore tui when built with NO_NEWT

If perf tools were built without tui support (eg if newt-devel package was
not installed), they __silently__ exit if tui was selected on command line
or in .perfconfig.

If the binary has no tui support, report error when --tui is specified. If
selected from .perfconfig, warn and fall back to stdio.

Signed-off-by: Sukadev Bhattiprolu <sukadev@...ux.vnet.ibm.com>
---
 tools/perf/builtin-annotate.c |   22 ++++++++++++++++++++++
 tools/perf/builtin-report.c   |   15 +++++++++++++++
 tools/perf/builtin-top.c      |   22 ++++++++++++++++++++++
 tools/perf/util/hist.h        |   10 ++++++++++
 4 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 806e0a2..5ee699b 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -287,6 +287,28 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __used)
 
 	argc = parse_options(argc, argv, options, annotate_usage, 0);
 
+	/*
+	 * If binary was built without the newt library, fall back to stdio.
+	 * But if --tui was explicitly requested, report error and exit.
+	 */
+	if (!tui_enabled()) {
+		if (annotate.use_tui) {
+			fprintf(stderr, "TUI not supported, use --stdio.\n");
+			return -1;
+		} else if (!annotate.use_stdio && use_browser > 0) {
+			/*
+			 * sleep(1) is hackish, but before we clear the screen,
+			 * they need know that we can't provide what their
+			 * .perfconfig asked for.
+			 */
+			fprintf(stderr, "TUI not supported, using stdio.\n");
+			sleep(1);
+		}
+
+		annotate.use_tui = 0;
+		annotate.use_stdio = 1;
+	}
+
 	if (annotate.use_stdio)
 		use_browser = 0;
 	else if (annotate.use_tui)
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 25d34d4..70175d6 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -522,6 +522,21 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
 
 	argc = parse_options(argc, argv, options, report_usage, 0);
 
+	/*
+	 * If binary was built without the newt library, fall back to stdio.
+	 * But if --tui was explicitly requested, report error and exit.
+	 */
+	if (!tui_enabled()) {
+		if (report.use_tui) {
+			fprintf(stderr, "TUI not supported, use --stdio.\n");
+			return -1;
+		} else if (!report.use_stdio && use_browser > 0)
+			fprintf(stderr, "TUI not supported, using stdio.\n");
+
+		report.use_tui = 0;
+		report.use_stdio = 1;
+	}
+
 	if (report.use_stdio)
 		use_browser = 0;
 	else if (report.use_tui)
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index dd162aa..2aa2bdf 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1187,6 +1187,28 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
 
 	setup_sorting(top_usage, options);
 
+	/*
+	 * If binary was built without the newt library, fall back to stdio.
+	 * But if --tui was explicitly requested, report error and exit.
+	 */
+	if (!tui_enabled()) {
+		if (top.use_tui) {
+			fprintf(stderr, "TUI not supported, use --stdio.\n");
+			return -1;
+		} else if (!top.use_stdio && use_browser > 0) {
+			/*
+			 * sleep(1) is hackish, but before we clear the screen,
+			 * they need know that we can't provide what their
+			 * .perfconfig asked for.
+			 */
+			fprintf(stderr, "TUI not supported, using stdio.\n");
+			sleep(1);
+		}
+
+		top.use_tui = 0;
+		top.use_stdio = 1;
+	}
+
 	if (top.use_stdio)
 		use_browser = 0;
 	else if (top.use_tui)
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index f55f0a8..2a3a3db 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -103,6 +103,11 @@ struct perf_evlist;
 
 #ifdef NO_NEWT_SUPPORT
 static inline
+int tui_enabled(void)
+{
+	return 0;
+}
+static inline
 int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __used,
 				  const char *help __used,
 				  void(*timer)(void *arg) __used,
@@ -130,6 +135,11 @@ int hist_entry__tui_annotate(struct hist_entry *he, int evidx,
 int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,
 				  void(*timer)(void *arg), void *arg,
 				  int refresh);
+static inline
+int tui_enabled(void)
+{
+	return 1;
+}
 #endif
 
 unsigned int hists__sort_list_width(struct hists *self);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ