builtin-buildid-list.c 1.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/*
 * builtin-buildid-list.c
 *
 * Builtin buildid-list command: list buildids in perf.data
 *
 * Copyright (C) 2009, Red Hat Inc.
 * Copyright (C) 2009, Arnaldo Carvalho de Melo <acme@redhat.com>
 */
#include "builtin.h"
#include "perf.h"
11
#include "util/build-id.h"
12 13 14
#include "util/cache.h"
#include "util/debug.h"
#include "util/parse-options.h"
15
#include "util/session.h"
16 17 18
#include "util/symbol.h"

static char const *input_name = "perf.data";
19
static bool force;
20
static bool with_hits;
21

22
static const char * const buildid_list_usage[] = {
23
	"perf buildid-list [<options>]",
24 25 26 27
	NULL
};

static const struct option options[] = {
28
	OPT_BOOLEAN('H', "with-hits", &with_hits, "Show only DSOs with hits"),
29 30 31
	OPT_STRING('i', "input", &input_name, "file",
		    "input file name"),
	OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
32
	OPT_INCR('v', "verbose", &verbose,
33
		    "be more verbose"),
34 35 36 37 38 39
	OPT_END()
};

static int __cmd_buildid_list(void)
{
	int err = -1;
40 41
	struct perf_session *session;

T
Tom Zanussi 已提交
42
	session = perf_session__new(input_name, O_RDONLY, force, false);
43 44
	if (session == NULL)
		return -1;
45

46 47
	if (with_hits) {
		symbol_conf.full_paths = true;
48
		perf_session__process_events(session, &build_id__mark_dso_hit_ops);
49
	}
50

51
	perf_session__fprintf_dsos_buildid(session, stdout, with_hits);
52

53
	perf_session__delete(session);
54 55 56 57 58 59 60 61 62
	return err;
}

int cmd_buildid_list(int argc, const char **argv, const char *prefix __used)
{
	argc = parse_options(argc, argv, options, buildid_list_usage, 0);
	setup_pager();
	return __cmd_buildid_list();
}