perf probe: Don't use a perf_session instance just to resolve symbols
[deliverable/linux.git] / tools / perf / builtin-buildid-list.c
CommitLineData
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"
11#include "util/cache.h"
c34984b2 12#include "util/debug.h"
c34984b2 13#include "util/parse-options.h"
94c744b6 14#include "util/session.h"
c34984b2
ACM
15#include "util/symbol.h"
16
17static char const *input_name = "perf.data";
18static int force;
88d3d9b7 19static bool with_hits;
c34984b2 20
0422a4fc 21static const char * const buildid_list_usage[] = {
b9b1e1c7 22 "perf buildid-list [<options>]",
c34984b2
ACM
23 NULL
24};
25
26static const struct option options[] = {
88d3d9b7 27 OPT_BOOLEAN('H', "with-hits", &with_hits, "Show only DSOs with hits"),
c34984b2
ACM
28 OPT_STRING('i', "input", &input_name, "file",
29 "input file name"),
30 OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
31 OPT_BOOLEAN('v', "verbose", &verbose,
1124ba73 32 "be more verbose"),
c34984b2
ACM
33 OPT_END()
34};
35
88d3d9b7
ACM
36static int build_id_list__process_event(event_t *event,
37 struct perf_session *session)
38{
39 struct addr_location al;
40 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
41 struct thread *thread = perf_session__findnew(session, event->ip.pid);
42
43 if (thread == NULL) {
44 pr_err("problem processing %d event, skipping it.\n",
45 event->header.type);
46 return -1;
47 }
48
49 thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION,
50 event->ip.ip, &al);
51
52 if (al.map != NULL)
53 al.map->dso->hit = 1;
54
55 return 0;
56}
57
58static struct perf_event_ops build_id_list__event_ops = {
59 .sample = build_id_list__process_event,
60 .mmap = event__process_mmap,
61 .fork = event__process_task,
62};
63
c34984b2
ACM
64static int __cmd_buildid_list(void)
65{
66 int err = -1;
75be6cf4
ACM
67 struct perf_session *session;
68
69 session = perf_session__new(input_name, O_RDONLY, force);
94c744b6
ACM
70 if (session == NULL)
71 return -1;
c34984b2 72
88d3d9b7
ACM
73 if (with_hits)
74 perf_session__process_events(session, &build_id_list__event_ops);
75
76 dsos__fprintf_buildid(stdout, with_hits);
c34984b2 77
94c744b6 78 perf_session__delete(session);
c34984b2
ACM
79 return err;
80}
81
82int cmd_buildid_list(int argc, const char **argv, const char *prefix __used)
83{
84 argc = parse_options(argc, argv, options, buildid_list_usage, 0);
85 setup_pager();
86 return __cmd_buildid_list();
87}
This page took 0.091386 seconds and 5 git commands to generate.