From: Masami Hiramatsu <mhiramat@kernel.org>
To: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Cc: jolsa@redhat.com, acme@redhat.com, kstewart@linuxfoundation.org,
tglx@linutronix.de, pombredanne@nexb.com,
linux-kernel@vger.kernel.org, peterz@infradead.org,
mingo@redhat.com, alexander.shishkin@linux.intel.com,
namhyung@kernel.org, uneedsihyeon@gmail.com,
kjlx@templeofstupid.com
Subject: Re: [PATCH v2 2/3] perf/buildid-cache: Support --list option
Date: Mon, 23 Apr 2018 15:59:46 +0900 [thread overview]
Message-ID: <20180423155946.7e1a68d1a77dabcbce2269b4@kernel.org> (raw)
In-Reply-To: <20180417041346.5617-3-ravi.bangoria@linux.vnet.ibm.com>
On Tue, 17 Apr 2018 09:43:45 +0530
Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> wrote:
> Perf buildid-cache allows to add/remove files into cache but there
> is no option to list all cached files. Add --list option to list
> all _valid_ cached files.
>
> Ex,
> # perf buildid-cache --add /tmp/a.out
> # perf buildid-cache -l
> 8a86ef73e44067bca52cc3f6cd3e5446c783391c /tmp/a.out
>
Looks good to me.
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Thanks!
> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
> ---
> tools/perf/Documentation/perf-buildid-cache.txt | 4 ++-
> tools/perf/builtin-buildid-cache.c | 43 +++++++++++++++++++++++--
> 2 files changed, 43 insertions(+), 4 deletions(-)
>
> diff --git a/tools/perf/Documentation/perf-buildid-cache.txt b/tools/perf/Documentation/perf-buildid-cache.txt
> index 73c2650bd0db..3f285ba6e1f9 100644
> --- a/tools/perf/Documentation/perf-buildid-cache.txt
> +++ b/tools/perf/Documentation/perf-buildid-cache.txt
> @@ -59,7 +59,9 @@ OPTIONS
> exactly same build-id, that is replaced by new one. It can be used
> to update kallsyms and kernel dso to vmlinux in order to support
> annotation.
> -
> +-l::
> +--list::
> + List all valid binaries from cache.
> -v::
> --verbose::
> Be more verbose.
> diff --git a/tools/perf/builtin-buildid-cache.c b/tools/perf/builtin-buildid-cache.c
> index 41db2cba77eb..fd0a08661b42 100644
> --- a/tools/perf/builtin-buildid-cache.c
> +++ b/tools/perf/builtin-buildid-cache.c
> @@ -25,6 +25,7 @@
> #include "util/session.h"
> #include "util/symbol.h"
> #include "util/time-utils.h"
> +#include "util/probe-file.h"
>
> static int build_id_cache__kcore_buildid(const char *proc_dir, char *sbuildid)
> {
> @@ -297,6 +298,26 @@ static int build_id_cache__update_file(const char *filename, struct nsinfo *nsi)
> return err;
> }
>
> +static int build_id_cache__show_all(void)
> +{
> + struct strlist *bidlist;
> + struct str_node *nd;
> + char *buf;
> +
> + bidlist = build_id_cache__list_all(true);
> + if (!bidlist) {
> + pr_debug("Failed to get buildids: -%d\n", errno);
> + return -1;
> + }
> + strlist__for_each_entry(nd, bidlist) {
> + buf = build_id_cache__origname(nd->s);
> + fprintf(stdout, "%s %s\n", nd->s, buf);
> + free(buf);
> + }
> + strlist__delete(bidlist);
> + return 0;
> +}
> +
> int cmd_buildid_cache(int argc, const char **argv)
> {
> struct strlist *list;
> @@ -304,6 +325,8 @@ int cmd_buildid_cache(int argc, const char **argv)
> int ret = 0;
> int ns_id = -1;
> bool force = false;
> + bool list_files = false;
> + bool opts_flag = false;
> char const *add_name_list_str = NULL,
> *remove_name_list_str = NULL,
> *purge_name_list_str = NULL,
> @@ -327,6 +350,7 @@ int cmd_buildid_cache(int argc, const char **argv)
> "file(s) to remove"),
> OPT_STRING('p', "purge", &purge_name_list_str, "file list",
> "file(s) to remove (remove old caches too)"),
> + OPT_BOOLEAN('l', "list", &list_files, "list all cached files"),
> OPT_STRING('M', "missing", &missing_filename, "file",
> "to find missing build ids in the cache"),
> OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
> @@ -344,11 +368,19 @@ int cmd_buildid_cache(int argc, const char **argv)
> argc = parse_options(argc, argv, buildid_cache_options,
> buildid_cache_usage, 0);
>
> - if (argc || (!add_name_list_str && !kcore_filename &&
> - !remove_name_list_str && !purge_name_list_str &&
> - !missing_filename && !update_name_list_str))
> + opts_flag = add_name_list_str || kcore_filename ||
> + remove_name_list_str || purge_name_list_str ||
> + missing_filename || update_name_list_str;
> +
> + if (argc || !(list_files || opts_flag))
> usage_with_options(buildid_cache_usage, buildid_cache_options);
>
> + /* -l is exclusive. It can not be used with other options. */
> + if (list_files && opts_flag) {
> + usage_with_options_msg(buildid_cache_usage,
> + buildid_cache_options, "-l is exclusive.\n");
> + }
> +
> if (ns_id > 0)
> nsi = nsinfo__new(ns_id);
>
> @@ -366,6 +398,11 @@ int cmd_buildid_cache(int argc, const char **argv)
>
> setup_pager();
>
> + if (list_files) {
> + ret = build_id_cache__show_all();
> + goto out;
> + }
> +
> if (add_name_list_str) {
> list = strlist__new(add_name_list_str, NULL);
> if (list) {
> --
> 2.14.3
>
--
Masami Hiramatsu <mhiramat@kernel.org>
next prev parent reply other threads:[~2018-04-23 6:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-17 4:13 [PATCH v2 0/3] perf/buildid-cache: Add --list and --purge-all options Ravi Bangoria
2018-04-17 4:13 ` [PATCH v2 1/3] tools/parse-options: Add '\n' at the end of error messages Ravi Bangoria
2018-04-21 7:52 ` [tip:perf/urgent] perf tools: Add '\n' at the end of parse-options " tip-bot for Ravi Bangoria
2018-04-17 4:13 ` [PATCH v2 2/3] perf/buildid-cache: Support --list option Ravi Bangoria
2018-04-23 6:59 ` Masami Hiramatsu [this message]
2018-05-02 17:39 ` [tip:perf/core] perf buildid-cache: " tip-bot for Ravi Bangoria
2018-04-17 4:13 ` [PATCH v2 3/3] perf/buildid-cache: Support --purge-all option Ravi Bangoria
2018-04-23 7:02 ` Masami Hiramatsu
2018-05-03 8:54 ` Ravi Bangoria
2018-05-08 15:42 ` Masami Hiramatsu
2018-05-09 6:00 ` Ravi Bangoria
2018-04-23 18:59 ` Arnaldo Carvalho de Melo
2018-05-02 17:40 ` [tip:perf/core] perf buildid-cache: " tip-bot for Ravi Bangoria
2018-04-17 7:57 ` [PATCH v2 0/3] perf/buildid-cache: Add --list and --purge-all options Jiri Olsa
2018-04-17 13:58 ` Arnaldo Carvalho de Melo
2018-04-18 5:54 ` Masami Hiramatsu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180423155946.7e1a68d1a77dabcbce2269b4@kernel.org \
--to=mhiramat@kernel.org \
--cc=acme@redhat.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@redhat.com \
--cc=kjlx@templeofstupid.com \
--cc=kstewart@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=pombredanne@nexb.com \
--cc=ravi.bangoria@linux.vnet.ibm.com \
--cc=tglx@linutronix.de \
--cc=uneedsihyeon@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome