Skip to contentSkip to conversation

perf trace: Warn the user when not available

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Jun 5, 2014 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  1b5726220fe16ac38eb2db43e7bc82e69f449fca
Gitweb:     http://git.kernel.org/tip/1b5726220fe16ac38eb2db43e7bc82e69f449fca
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Mon, 26 May 2014 16:02:29 -0300
Committer:  Jiri Olsa <[email protected]>
CommitDate: Tue, 3 Jun 2014 21:34:00 +0200

perf trace: Warn the user when not available

When the audit-libs devel package is not found at build time we disable the 'trace' command, as we are not able to map syscall numbers to strings, but then the message the user is presented is cryptic:

[root@zoo linux]# trace ls
perf: 'ls' is not a perf-command. See 'perf --help'.

Fix it by presenting a more helpful message:

[root@zoo linux]# trace l
trace command not available: missing audit-libs devel package at build time.

Cc Adrian Hunter <[email protected]>
Cc David Ahern <[email protected]>
Cc Don Zickus <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/perf.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
tools/perf/perf.c +6 -2
index 431798a..78f7b92 100644
@@ -481,14 +481,18 @@ int main(int argc, const char **argv)
 		fprintf(stderr, "cannot handle %s internally", cmd);
 		goto out;
 	}
-#ifdef HAVE_LIBAUDIT_SUPPORT
 	if (!prefixcmp(cmd, "trace")) {
+#ifdef HAVE_LIBAUDIT_SUPPORT
 		set_buildid_dir();
 		setup_path();
 		argv[0] = "trace";
 		return cmd_trace(argc, argv, NULL);
-	}
+#else
+		fprintf(stderr,
+			"trace command not available: missing audit-libs devel package at build time.\n");
+		goto out;
 #endif
+	}
 	/* Look for flags.. */
 	argv++;
 	argc--;