[PATCH 1/1] perf: Ignore tui when built with NO_NEWT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Sukadev Bhattiprolu <sukadev@xxxxxxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[Other Archives]     [Linux Kernel Newbies]     [Linux Driver Development]     [Fedora Kernel]     [Linux Kernel Testers]     [Linux SH]     [Linux Omap]     [Linux Kbuild]     [Linux Tape]     [Linux Input]     [Linux Kernel Janitors]     [Linux Kernel Packagers]     [Linux Doc]     [Linux Man Pages]     [Linux API]     [Linux Memory Management]     [Linux Modules]     [Linux Standards]     [Kernel Announce]     [Netdev]     [Git]     [Linux PCI]     Linux CAN Development     [Linux I2C]     [Linux RDMA]     [Linux NUMA]     [Netfilter]     [Netfilter Devel]     [SELinux]     [Bugtraq]     [FIO]     [Linux Perf Users]     [Linux Serial]     [Linux PPP]     [Linux ISDN]     [Linux Next]     [Kernel Stable Commits]     [Linux Tip Commits]     [Kernel MM Commits]     [Linux Security Module]     [Filesystem Development]     [Ext3 Filesystem]     [Linux bcache]     [Ext4 Filesystem]     [Linux BTRFS]     [Linux CEPH Filesystem]     [Linux XFS]     [XFS]     [Linux NFS]     [Linux CIFS]     [Ecryptfs]     [Linux NILFS]     [Linux Cachefs]     [Reiser FS]     [Initramfs]     [Linux FB Devel]     [Linux OpenGL]     [DRI Devel]     [Fastboot]     [Linux RT Users]     [Linux RT Stable]     [eCos]     [Corosync]     [Linux Clusters]     [LVS Devel]     [Hot Plug]     [Linux Virtualization]     [KVM]     [KVM PPC]     [KVM ia64]     [Linux Containers]     [Linux Hexagon]     [Linux Cgroups]     [Util Linux]     [Wireless]     [Linux Bluetooth]     [Bluez Devel]     [Ethernet Bridging]     [Embedded Linux]     [Barebox]     [Linux MMC]     [Linux IIO]     [Sparse]     [Smatch]     [Linux Arch]     [x86 Platform Driver]     [Linux ACPI]     [Linux IBM ACPI]     [LM Sensors]     [CPU Freq]     [Linux Power Management]     [Linmodems]     [Linux DCCP]     [Linux SCTP]     [ALSA Devel]     [Linux USB]     [Linux PA RISC]     [Linux Samsung SOC]     [MIPS Linux]     [IBM S/390 Linux]     [ARM Linux]     [ARM Kernel]     [ARM MSM]     [Tegra Devel]     [Sparc Linux]     [Linux Security]     [Linux Sound]     [Linux Media]     [Video 4 Linux]     [Linux IRDA Users]     [Linux for the blind]     [Linux RAID]     [Linux ATA RAID]     [Device Mapper]     [Linux SCSI]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Linux IDE]     [Linux SMP]     [Linux AXP]     [Linux Alpha]     [Linux M68K]     [Linux ia64]     [Linux 8086]     [Linux x86_64]     [Linux Config]     [Linux Apps]     [Linux MSDOS]     [Linux X.25]     [Linux Crypto]     [DM Crypt]     [Linux Trace Users]     [Linux Btrace]     [Linux Watchdog]     [Utrace Devel]     [Linux C Programming]     [Linux Assembly]     [Dash]     [DWARVES]     [Hail Devel]     [Linux Kernel Debugger]     [Linux gcc]     [Gcc Help]     [X.Org]     [Wine]

Add to Google Powered by Linux

[Older Kernel Discussion]     [Yosemite National Park Forum]     [Large Format Photos]     [Gimp]     [Yosemite Photos]     [Stuff]