]>
Commit | Line | Data |
---|---|---|
c34984b2 ACM |
1 | /* |
2 | * builtin-buildid-list.c | |
3 | * | |
4 | * Builtin buildid-list command: list buildids in perf.data | |
5 | * | |
6 | * Copyright (C) 2009, Red Hat Inc. | |
7 | * Copyright (C) 2009, Arnaldo Carvalho de Melo <acme@redhat.com> | |
8 | */ | |
9 | #include "builtin.h" | |
10 | #include "perf.h" | |
7b2567c1 | 11 | #include "util/build-id.h" |
c34984b2 | 12 | #include "util/cache.h" |
c34984b2 | 13 | #include "util/debug.h" |
c34984b2 | 14 | #include "util/parse-options.h" |
94c744b6 | 15 | #include "util/session.h" |
c34984b2 ACM |
16 | #include "util/symbol.h" |
17 | ||
18 | static char const *input_name = "perf.data"; | |
19 | static int force; | |
88d3d9b7 | 20 | static bool with_hits; |
c34984b2 | 21 | |
0422a4fc | 22 | static const char * const buildid_list_usage[] = { |
b9b1e1c7 | 23 | "perf buildid-list [<options>]", |
c34984b2 ACM |
24 | NULL |
25 | }; | |
26 | ||
27 | static const struct option options[] = { | |
88d3d9b7 | 28 | OPT_BOOLEAN('H', "with-hits", &with_hits, "Show only DSOs with hits"), |
c34984b2 ACM |
29 | OPT_STRING('i', "input", &input_name, "file", |
30 | "input file name"), | |
31 | OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), | |
32 | OPT_BOOLEAN('v', "verbose", &verbose, | |
1124ba73 | 33 | "be more verbose"), |
c34984b2 ACM |
34 | OPT_END() |
35 | }; | |
36 | ||
c34984b2 ACM |
37 | static int __cmd_buildid_list(void) |
38 | { | |
39 | int err = -1; | |
75be6cf4 ACM |
40 | struct perf_session *session; |
41 | ||
42 | session = perf_session__new(input_name, O_RDONLY, force); | |
94c744b6 ACM |
43 | if (session == NULL) |
44 | return -1; | |
c34984b2 | 45 | |
88d3d9b7 | 46 | if (with_hits) |
7b2567c1 | 47 | perf_session__process_events(session, &build_id__mark_dso_hit_ops); |
88d3d9b7 ACM |
48 | |
49 | dsos__fprintf_buildid(stdout, with_hits); | |
c34984b2 | 50 | |
94c744b6 | 51 | perf_session__delete(session); |
c34984b2 ACM |
52 | return err; |
53 | } | |
54 | ||
55 | int cmd_buildid_list(int argc, const char **argv, const char *prefix __used) | |
56 | { | |
57 | argc = parse_options(argc, argv, options, buildid_list_usage, 0); | |
58 | setup_pager(); | |
59 | return __cmd_buildid_list(); | |
60 | } |