1c34984b2SArnaldo Carvalho de Melo /* 2c34984b2SArnaldo Carvalho de Melo * builtin-buildid-list.c 3c34984b2SArnaldo Carvalho de Melo * 4c34984b2SArnaldo Carvalho de Melo * Builtin buildid-list command: list buildids in perf.data 5c34984b2SArnaldo Carvalho de Melo * 6c34984b2SArnaldo Carvalho de Melo * Copyright (C) 2009, Red Hat Inc. 7c34984b2SArnaldo Carvalho de Melo * Copyright (C) 2009, Arnaldo Carvalho de Melo <acme@redhat.com> 8c34984b2SArnaldo Carvalho de Melo */ 9c34984b2SArnaldo Carvalho de Melo #include "builtin.h" 10c34984b2SArnaldo Carvalho de Melo #include "perf.h" 117b2567c1SArnaldo Carvalho de Melo #include "util/build-id.h" 12c34984b2SArnaldo Carvalho de Melo #include "util/cache.h" 13c34984b2SArnaldo Carvalho de Melo #include "util/debug.h" 14c34984b2SArnaldo Carvalho de Melo #include "util/parse-options.h" 1594c744b6SArnaldo Carvalho de Melo #include "util/session.h" 16c34984b2SArnaldo Carvalho de Melo #include "util/symbol.h" 17c34984b2SArnaldo Carvalho de Melo 18c34984b2SArnaldo Carvalho de Melo static char const *input_name = "perf.data"; 19c0555642SIan Munsie static bool force; 2088d3d9b7SArnaldo Carvalho de Melo static bool with_hits; 21c34984b2SArnaldo Carvalho de Melo 22c34984b2SArnaldo Carvalho de Melo static const char * const buildid_list_usage[] = { 23b9b1e1c7SArnaldo Carvalho de Melo "perf buildid-list [<options>]", 24c34984b2SArnaldo Carvalho de Melo NULL 25c34984b2SArnaldo Carvalho de Melo }; 26c34984b2SArnaldo Carvalho de Melo 27c34984b2SArnaldo Carvalho de Melo static const struct option options[] = { 2888d3d9b7SArnaldo Carvalho de Melo OPT_BOOLEAN('H', "with-hits", &with_hits, "Show only DSOs with hits"), 29c34984b2SArnaldo Carvalho de Melo OPT_STRING('i', "input", &input_name, "file", 30c34984b2SArnaldo Carvalho de Melo "input file name"), 31c34984b2SArnaldo Carvalho de Melo OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), 32c0555642SIan Munsie OPT_INCR('v', "verbose", &verbose, 331124ba73SArnaldo Carvalho de Melo "be more verbose"), 34c34984b2SArnaldo Carvalho de Melo OPT_END() 35c34984b2SArnaldo Carvalho de Melo }; 36c34984b2SArnaldo Carvalho de Melo 37c34984b2SArnaldo Carvalho de Melo static int __cmd_buildid_list(void) 38c34984b2SArnaldo Carvalho de Melo { 39c34984b2SArnaldo Carvalho de Melo int err = -1; 4075be6cf4SArnaldo Carvalho de Melo struct perf_session *session; 4175be6cf4SArnaldo Carvalho de Melo 4275be6cf4SArnaldo Carvalho de Melo session = perf_session__new(input_name, O_RDONLY, force); 4394c744b6SArnaldo Carvalho de Melo if (session == NULL) 4494c744b6SArnaldo Carvalho de Melo return -1; 45c34984b2SArnaldo Carvalho de Melo 4688d3d9b7SArnaldo Carvalho de Melo if (with_hits) 477b2567c1SArnaldo Carvalho de Melo perf_session__process_events(session, &build_id__mark_dso_hit_ops); 4888d3d9b7SArnaldo Carvalho de Melo 49*cbf69680SArnaldo Carvalho de Melo perf_session__fprintf_dsos_buildid(session, stdout, with_hits); 5094c744b6SArnaldo Carvalho de Melo 5194c744b6SArnaldo Carvalho de Melo perf_session__delete(session); 52c34984b2SArnaldo Carvalho de Melo return err; 53c34984b2SArnaldo Carvalho de Melo } 54c34984b2SArnaldo Carvalho de Melo 55c34984b2SArnaldo Carvalho de Melo int cmd_buildid_list(int argc, const char **argv, const char *prefix __used) 56c34984b2SArnaldo Carvalho de Melo { 57c34984b2SArnaldo Carvalho de Melo argc = parse_options(argc, argv, options, buildid_list_usage, 0); 58c34984b2SArnaldo Carvalho de Melo setup_pager(); 59c34984b2SArnaldo Carvalho de Melo return __cmd_buildid_list(); 60c34984b2SArnaldo Carvalho de Melo } 61