aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-buildid-list.c55
1 files changed, 24 insertions, 31 deletions
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c
index 1159feeebb19..a0e94fffa03e 100644
--- a/tools/perf/builtin-buildid-list.c
+++ b/tools/perf/builtin-buildid-list.c
@@ -16,27 +16,6 @@
16#include "util/session.h" 16#include "util/session.h"
17#include "util/symbol.h" 17#include "util/symbol.h"
18 18
19static const char *input_name;
20static bool force;
21static bool show_kernel;
22static bool with_hits;
23
24static const char * const buildid_list_usage[] = {
25 "perf buildid-list [<options>]",
26 NULL
27};
28
29static const struct option options[] = {
30 OPT_BOOLEAN('H', "with-hits", &with_hits, "Show only DSOs with hits"),
31 OPT_STRING('i', "input", &input_name, "file",
32 "input file name"),
33 OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
34 OPT_BOOLEAN('k', "kernel", &show_kernel, "Show current kernel build id"),
35 OPT_INCR('v', "verbose", &verbose,
36 "be more verbose"),
37 OPT_END()
38};
39
40static int sysfs__fprintf_build_id(FILE *fp) 19static int sysfs__fprintf_build_id(FILE *fp)
41{ 20{
42 u8 kallsyms_build_id[BUILD_ID_SIZE]; 21 u8 kallsyms_build_id[BUILD_ID_SIZE];
@@ -65,7 +44,8 @@ static int filename__fprintf_build_id(const char *name, FILE *fp)
65 return fprintf(fp, "%s\n", sbuild_id); 44 return fprintf(fp, "%s\n", sbuild_id);
66} 45}
67 46
68static int perf_session__list_build_ids(void) 47static int perf_session__list_build_ids(const char *input_name,
48 bool force, bool with_hits)
69{ 49{
70 struct perf_session *session; 50 struct perf_session *session;
71 51
@@ -95,18 +75,31 @@ out:
95 return 0; 75 return 0;
96} 76}
97 77
98static int __cmd_buildid_list(void)
99{
100 if (show_kernel)
101 return sysfs__fprintf_build_id(stdout);
102
103 return perf_session__list_build_ids();
104}
105
106int cmd_buildid_list(int argc, const char **argv, 78int cmd_buildid_list(int argc, const char **argv,
107 const char *prefix __maybe_unused) 79 const char *prefix __maybe_unused)
108{ 80{
81 bool show_kernel = false;
82 bool with_hits = false;
83 bool force = false;
84 const char *input_name = NULL;
85 const struct option options[] = {
86 OPT_BOOLEAN('H', "with-hits", &with_hits, "Show only DSOs with hits"),
87 OPT_STRING('i', "input", &input_name, "file", "input file name"),
88 OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
89 OPT_BOOLEAN('k', "kernel", &show_kernel, "Show current kernel build id"),
90 OPT_INCR('v', "verbose", &verbose, "be more verbose"),
91 OPT_END()
92 };
93 const char * const buildid_list_usage[] = {
94 "perf buildid-list [<options>]",
95 NULL
96 };
97
109 argc = parse_options(argc, argv, options, buildid_list_usage, 0); 98 argc = parse_options(argc, argv, options, buildid_list_usage, 0);
110 setup_pager(); 99 setup_pager();
111 return __cmd_buildid_list(); 100
101 if (show_kernel)
102 return sysfs__fprintf_build_id(stdout);
103
104 return perf_session__list_build_ids(input_name, force, with_hits);
112} 105}