blob: d0675c02f81eb0a45f5d2b8185dc6b26a15f98fd [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";
19static int 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"),
32 OPT_BOOLEAN('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{
39 int err = -1;
Arnaldo Carvalho de Melo75be6cf2009-12-15 20:04:39 -020040 struct perf_session *session;
41
42 session = perf_session__new(input_name, O_RDONLY, force);
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020043 if (session == NULL)
44 return -1;
Arnaldo Carvalho de Meloc34984b2009-11-16 16:32:45 -020045
Arnaldo Carvalho de Melo88d3d9b72010-01-14 23:45:30 -020046 if (with_hits)
Arnaldo Carvalho de Melo7b2567c2010-02-03 16:52:04 -020047 perf_session__process_events(session, &build_id__mark_dso_hit_ops);
Arnaldo Carvalho de Melo88d3d9b72010-01-14 23:45:30 -020048
49 dsos__fprintf_buildid(stdout, with_hits);
Arnaldo Carvalho de Meloc34984b2009-11-16 16:32:45 -020050
Arnaldo Carvalho de Melo94c744b2009-12-11 21:24:02 -020051 perf_session__delete(session);
Arnaldo Carvalho de Meloc34984b2009-11-16 16:32:45 -020052 return err;
53}
54
55int 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}