blob: c49837de7d3f74eb9254d83e4f6457b11ae38c17 [file] [log] [blame]
Arnaldo Carvalho de Meloc34984b2009-11-16 16:32:45 -02001/*
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"
Arnaldo Carvalho de Melo7b2567c2010-02-03 16:52:04 -020011#include "util/build-id.h"
Arnaldo Carvalho de Meloc34984b2009-11-16 16:32:45 -020012#include "util/cache.h"
Arnaldo Carvalho de Meloc34984b2009-11-16 16:32:45 -020013#include "util/debug.h"
Arnaldo Carvalho de Meloc34984b2009-11-16 16:32:45 -020014#include "util/parse-options.h"
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020015#include "util/session.h"
Arnaldo Carvalho de Meloc34984b2009-11-16 16:32:45 -020016#include "util/symbol.h"
17
18static char const *input_name = "perf.data";
Ian Munsiec0555642010-04-13 18:37:33 +100019static bool force;
Arnaldo Carvalho de Melo88d3d9b72010-01-14 23:45:30 -020020static bool with_hits;
Arnaldo Carvalho de Meloc34984b2009-11-16 16:32:45 -020021
Arnaldo Carvalho de Melo0422a4f2009-12-18 16:35:58 -020022static const char * const buildid_list_usage[] = {
Arnaldo Carvalho de Melob9b1e1c2009-12-06 18:03:10 -020023 "perf buildid-list [<options>]",
Arnaldo Carvalho de Meloc34984b2009-11-16 16:32:45 -020024 NULL
25};
26
27static const struct option options[] = {
Arnaldo Carvalho de Melo88d3d9b72010-01-14 23:45:30 -020028 OPT_BOOLEAN('H', "with-hits", &with_hits, "Show only DSOs with hits"),
Arnaldo Carvalho de Meloc34984b2009-11-16 16:32:45 -020029 OPT_STRING('i', "input", &input_name, "file",
30 "input file name"),
31 OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
Ian Munsiec0555642010-04-13 18:37:33 +100032 OPT_INCR('v', "verbose", &verbose,
Arnaldo Carvalho de Melo1124ba72009-11-16 21:45:25 -020033 "be more verbose"),
Arnaldo Carvalho de Meloc34984b2009-11-16 16:32:45 -020034 OPT_END()
35};
36
Arnaldo Carvalho de Meloc34984b2009-11-16 16:32:45 -020037static int __cmd_buildid_list(void)
38{
Arnaldo Carvalho de Melo75be6cf2009-12-15 20:04:39 -020039 struct perf_session *session;
40
Tom Zanussi454c4072010-05-01 01:41:20 -050041 session = perf_session__new(input_name, O_RDONLY, force, false);
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020042 if (session == NULL)
43 return -1;
Arnaldo Carvalho de Meloc34984b2009-11-16 16:32:45 -020044
Dave Martin88ca8952010-07-27 11:46:12 -030045 if (with_hits)
Arnaldo Carvalho de Melo7b2567c2010-02-03 16:52:04 -020046 perf_session__process_events(session, &build_id__mark_dso_hit_ops);
Arnaldo Carvalho de Melo88d3d9b72010-01-14 23:45:30 -020047
Arnaldo Carvalho de Melocbf69682010-04-27 21:22:44 -030048 perf_session__fprintf_dsos_buildid(session, stdout, with_hits);
Arnaldo Carvalho de Meloc34984b2009-11-16 16:32:45 -020049
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020050 perf_session__delete(session);
Arnaldo Carvalho de Melobbde5882010-12-16 09:43:47 -020051 return 0;
Arnaldo Carvalho de Meloc34984b2009-11-16 16:32:45 -020052}
53
54int cmd_buildid_list(int argc, const char **argv, const char *prefix __used)
55{
56 argc = parse_options(argc, argv, options, buildid_list_usage, 0);
57 setup_pager();
58 return __cmd_buildid_list();
59}