[PATCH 03/23] perf buildid-list: Add -q/--quiet option

From: Namhyung Kim
Date: Tue Mar 07 2017 - 10:19:00 EST


The -q/--quiet option is to suppress any message. Sometimes users just
want to run the command and it can be used for that case.

Before:

$ perf buildid-list -H
No kallsyms or vmlinux with build-id 0dde46afc62ef46be224391d5c64379f984901e5 was found
/lib/modules/4.8.3-1-ARCH/build/vmlinux with build id 0dde46afc62ef46be224391d5c64379f984901e5 not found, continuing without symbols
Failed to open /lib/modules/4.8.3-1-ARCH/kernel/drivers/ata/libata.ko.gz, continuing without symbols
0dde46afc62ef46be224391d5c64379f984901e5 /lib/modules/4.8.3-1-ARCH/build/vmlinux
2524206aeba0015f174f320fad4b301a59ac311d /home/namhyung/project/linux/tools/perf/perf
c778954ffb0e2239cd454d40c9de504e8601d990 /usr/lib/ld-2.24.so
13d24a5495ae34f58e52403f9153263488b62cf4 /usr/lib/libpthread-2.24.so
17ec69093fc89b16363635ea7f76f46145a08384 /usr/lib/libdl-2.24.so
...

After:

$ perf buildid-list -H -q
0dde46afc62ef46be224391d5c64379f984901e5 /lib/modules/4.8.3-1-ARCH/build/vmlinux
2524206aeba0015f174f320fad4b301a59ac311d /home/namhyung/project/linux/tools/perf/perf
c778954ffb0e2239cd454d40c9de504e8601d990 /usr/lib/ld-2.24.so
13d24a5495ae34f58e52403f9153263488b62cf4 /usr/lib/libpthread-2.24.so
17ec69093fc89b16363635ea7f76f46145a08384 /usr/lib/libdl-2.24.so
...

Suggested-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
---
tools/perf/Documentation/perf-buildid-list.txt | 3 +++
tools/perf/builtin-buildid-list.c | 4 ++++
2 files changed, 7 insertions(+)

diff --git a/tools/perf/Documentation/perf-buildid-list.txt b/tools/perf/Documentation/perf-buildid-list.txt
index 25c52efcc7f0..a892f883d8b5 100644
--- a/tools/perf/Documentation/perf-buildid-list.txt
+++ b/tools/perf/Documentation/perf-buildid-list.txt
@@ -36,6 +36,9 @@ OPTIONS
-v::
--verbose::
Be more verbose.
+-q::
+--quiet::
+ Do not show any message.

SEE ALSO
--------
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c
index 5e914ee79eb3..6fc2a2fe6627 100644
--- a/tools/perf/builtin-buildid-list.c
+++ b/tools/perf/builtin-buildid-list.c
@@ -99,6 +99,7 @@ int cmd_buildid_list(int argc, const char **argv,
OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
OPT_BOOLEAN('k', "kernel", &show_kernel, "Show current kernel build id"),
OPT_INCR('v', "verbose", &verbose, "be more verbose"),
+ OPT_BOOLEAN('q', "quiet", &quiet, "Do not show any message"),
OPT_END()
};
const char * const buildid_list_usage[] = {
@@ -109,6 +110,9 @@ int cmd_buildid_list(int argc, const char **argv,
argc = parse_options(argc, argv, options, buildid_list_usage, 0);
setup_pager();

+ if (quiet)
+ perf_quiet_option();
+
if (show_kernel)
return !(sysfs__fprintf_build_id(stdout) > 0);

--
2.11.0