diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-08-29 07:07:22 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2011-09-29 15:41:37 -0400 |
commit | f2add9cd66c87baea6762b099ee38ee742207699 (patch) | |
tree | 3c25e91bb38b2098fa2640b93caa1080b85cfbda /tools/perf/builtin-buildid-list.c | |
parent | 63e03724b51e7315a66a3f1fee6cb8b4a16dc8cc (diff) |
perf buildid-list: Add option to show the running kernel build id
[root@emilia ~]# perf buildid-list -k
07b0c016a2b30004e86132d0239945b1e88f5d75
Useful when diagnosing build id problems in debuginfo packages, etc.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-po1bl7acn6e1hhne90opmvtl@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-buildid-list.c')
-rw-r--r-- | tools/perf/builtin-buildid-list.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index 5af32ae9031e..4102eadcf849 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c | |||
@@ -1,7 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * builtin-buildid-list.c | 2 | * builtin-buildid-list.c |
3 | * | 3 | * |
4 | * Builtin buildid-list command: list buildids in perf.data | 4 | * Builtin buildid-list command: list buildids in perf.data or in the running |
5 | * kernel. | ||
5 | * | 6 | * |
6 | * Copyright (C) 2009, Red Hat Inc. | 7 | * Copyright (C) 2009, Red Hat Inc. |
7 | * Copyright (C) 2009, Arnaldo Carvalho de Melo <acme@redhat.com> | 8 | * Copyright (C) 2009, Arnaldo Carvalho de Melo <acme@redhat.com> |
@@ -17,6 +18,7 @@ | |||
17 | 18 | ||
18 | static char const *input_name = "perf.data"; | 19 | static char const *input_name = "perf.data"; |
19 | static bool force; | 20 | static bool force; |
21 | static bool show_kernel; | ||
20 | static bool with_hits; | 22 | static bool with_hits; |
21 | 23 | ||
22 | static const char * const buildid_list_usage[] = { | 24 | static const char * const buildid_list_usage[] = { |
@@ -29,12 +31,13 @@ static const struct option options[] = { | |||
29 | OPT_STRING('i', "input", &input_name, "file", | 31 | OPT_STRING('i', "input", &input_name, "file", |
30 | "input file name"), | 32 | "input file name"), |
31 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), | 33 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), |
34 | OPT_BOOLEAN('k', "kernel", &show_kernel, "Show current kernel build id"), | ||
32 | OPT_INCR('v', "verbose", &verbose, | 35 | OPT_INCR('v', "verbose", &verbose, |
33 | "be more verbose"), | 36 | "be more verbose"), |
34 | OPT_END() | 37 | OPT_END() |
35 | }; | 38 | }; |
36 | 39 | ||
37 | static int __cmd_buildid_list(void) | 40 | static int perf_session__list_build_ids(void) |
38 | { | 41 | { |
39 | struct perf_session *session; | 42 | struct perf_session *session; |
40 | 43 | ||
@@ -52,6 +55,30 @@ static int __cmd_buildid_list(void) | |||
52 | return 0; | 55 | return 0; |
53 | } | 56 | } |
54 | 57 | ||
58 | static int sysfs__fprintf_build_id(FILE *fp) | ||
59 | { | ||
60 | u8 kallsyms_build_id[BUILD_ID_SIZE]; | ||
61 | char sbuild_id[BUILD_ID_SIZE * 2 + 1]; | ||
62 | |||
63 | if (sysfs__read_build_id("/sys/kernel/notes", kallsyms_build_id, | ||
64 | sizeof(kallsyms_build_id)) != 0) | ||
65 | return -1; | ||
66 | |||
67 | build_id__sprintf(kallsyms_build_id, sizeof(kallsyms_build_id), | ||
68 | sbuild_id); | ||
69 | fprintf(fp, "%s\n", sbuild_id); | ||
70 | return 0; | ||
71 | } | ||
72 | |||
73 | static int __cmd_buildid_list(void) | ||
74 | { | ||
75 | |||
76 | if (show_kernel) | ||
77 | return sysfs__fprintf_build_id(stdout); | ||
78 | |||
79 | return perf_session__list_build_ids(); | ||
80 | } | ||
81 | |||
55 | int cmd_buildid_list(int argc, const char **argv, const char *prefix __used) | 82 | int cmd_buildid_list(int argc, const char **argv, const char *prefix __used) |
56 | { | 83 | { |
57 | argc = parse_options(argc, argv, options, buildid_list_usage, 0); | 84 | argc = parse_options(argc, argv, options, buildid_list_usage, 0); |