|
@@ -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) {
|