13 #include <linux/list.h> 15 #include <linux/rbtree.h> 25 #include <subcmd/parse-options.h> 38 #include <linux/bitmap.h> 138 for (i = bs->
nr - 1; i >= 0; i--) {
152 bool single __maybe_unused,
153 void *arg __maybe_unused)
229 if (al->
sym != NULL) {
267 pr_warning(
"problem processing %d event, skipping it.\n",
272 if (ann->
cpu_list && !test_bit(sample->
cpu, ann->cpu_bitmap))
277 pr_warning(
"problem incrementing symbol count, " 300 struct rb_node *nd = rb_first(&hists->
entries), *next;
315 if (notes->
src == NULL) {
331 "hist_entry__gtk_annotate");
332 if (annotate == NULL) {
337 ret = annotate(he, evsel, NULL);
382 u64 total_nr_samples;
414 total_nr_samples = 0;
419 if (nr_samples > 0) {
420 total_nr_samples += nr_samples;
434 if (total_nr_samples == 0) {
440 void (*show_annotations)(void);
443 "perf_gtk__show_annotations");
444 if (show_annotations == NULL) {
456 "perf annotate [<options>]",
475 .ordered_events =
true,
476 .ordering_requires_timestamps =
true,
483 struct option options[] = {
487 "only consider symbols in these dsos"),
489 "symbol to annotate"),
490 OPT_BOOLEAN(
'f',
"force", &data.
force,
"don't complain, do it"),
491 OPT_INCR(
'v',
"verbose", &
verbose,
492 "be more verbose (show symbol address, etc)"),
493 OPT_BOOLEAN(
'q',
"quiet", &
quiet,
"do now show any message"),
494 OPT_BOOLEAN(
'D',
"dump-raw-trace", &
dump_trace,
495 "dump raw trace in ASCII"),
496 OPT_BOOLEAN(0,
"gtk", &annotate.
use_gtk,
"Use the GTK interface"),
497 OPT_BOOLEAN(0,
"tui", &annotate.
use_tui,
"Use the TUI interface"),
498 OPT_BOOLEAN(0,
"stdio", &annotate.
use_stdio,
"Use the stdio interface"),
499 OPT_BOOLEAN(0,
"stdio2", &annotate.
use_stdio2,
"Use the stdio interface"),
501 "don't load vmlinux even if found"),
503 "file",
"vmlinux pathname"),
505 "load module symbols - WARNING: use only with -k and LIVE kernel"),
507 "print matching source lines (may be slow)"),
509 "Don't shorten the displayed pathnames"),
511 "Skip symbols that cannot be annotated"),
514 "Show event group information together"),
515 OPT_STRING(
'C',
"cpu", &annotate.
cpu_list,
"cpu",
"list of cpus to profile"),
516 OPT_CALLBACK(0,
"symfs", NULL,
"directory",
517 "Look for files with symbols relative to this directory",
520 "Interleave source code with assembly code (default)"),
522 "Display raw encoding of assembly instructions (default)"),
524 "Specify disassembler style (e.g. -M intel for intel syntax)"),
526 "objdump binary to use for disassembly and annotations"),
528 "Show event group information together"),
530 "Show a column with the sum of periods"),
532 "Show a column with the number of samples"),
533 OPT_CALLBACK_DEFAULT(0,
"stdio-color", NULL,
"mode",
534 "'always' (default), 'never' or 'auto' only applicable to --stdio mode",
540 set_option_flag(options, 0,
"show-total-period", PARSE_OPT_EXCLUSIVE);
541 set_option_flag(options, 0,
"show-nr-samples", PARSE_OPT_EXCLUSIVE);
561 pr_err(
"--show-nr-samples is not available in --gtk mode at this time\n");
static void setup_sorting(struct perf_sched *sched, const struct option *options, const char *const usage_msg[])
struct perf_sample * sample
struct perf_evlist * evlist
int stdio__config_color(const struct option *opt __maybe_unused, const char *mode, int unset __maybe_unused)
int machine__resolve(struct machine *machine, struct addr_location *al, struct perf_sample *sample)
size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp)
int hist_entry__tui_annotate(struct hist_entry *he, struct perf_evsel *evsel, struct hist_browser_timer *hbt, struct annotation_options *opts)
const char * vmlinux_name
static int __cmd_annotate(struct perf_annotate *ann)
enum sort_mode sort__mode
int ui__error(const char *format,...)
int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample *sample, struct perf_evsel *evsel, u64 ip)
struct cyc_hist * cycles_hist
int perf_event__process_mmap(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine)
static int hist_entry__tty_annotate(struct hist_entry *he, struct perf_evsel *evsel, struct perf_annotate *ann)
static const char *const annotate_usage[]
static int process_sample_event(struct perf_tool *tool, union perf_event *event, struct perf_sample *sample, struct perf_evsel *evsel, struct machine *machine)
struct hist_entry * hists__add_entry(struct hists *hists, struct addr_location *al, struct symbol *sym_parent, struct branch_info *bi, struct mem_info *mi, struct perf_sample *sample, bool sample_self)
int hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
struct perf_data_file file
static struct block_range * block_range_iter(struct block_range_iter *iter)
size_t perf_session__fprintf_dsos(struct perf_session *session, FILE *fp)
size_t perf_session__fprintf(struct perf_session *session, FILE *fp)
int perf_event__process_comm(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine)
static bool block_range_iter__valid(struct block_range_iter *iter)
int perf_event__process_exit(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine)
static struct hists * evsel__hists(struct perf_evsel *evsel)
int perf_event__process_fork(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine)
const char * sym_hist_filter
static int perf_evsel__add_sample(struct perf_evsel *evsel, struct perf_sample *sample, struct addr_location *al, struct perf_annotate *ann, struct machine *machine)
int perf_quiet_option(void)
struct annotation_options opts
void addr_location__put(struct addr_location *al)
void setup_browser(bool fallback_to_pager)
int symbol__config_symfs(const struct option *opt __maybe_unused, const char *dir, int unset __maybe_unused)
const char * objdump_path
int perf_env__lookup_objdump(struct perf_env *env, const char **path)
#define evlist__for_each_entry(evlist, evsel)
static int entry(u64 ip, struct unwind_info *ui)
int symbol__annotation_init(void)
int symbol__tty_annotate2(struct symbol *sym, struct map *map, struct perf_evsel *evsel, struct annotation_options *opts)
static struct annotation * symbol__annotation(struct symbol *sym)
int symbol__tty_annotate(struct symbol *sym, struct map *map, struct perf_evsel *evsel, struct annotation_options *opts)
struct branch_stack * branch_stack
const char * disassembler_style
const char * dso_list_str
static void process_branch_stack(struct branch_stack *bs, struct addr_location *al, struct perf_sample *sample)
bool ui__has_annotation(void)
struct perf_event_header header
struct branch_info * branch_info
void hist__account_cycles(struct branch_stack *bs, struct addr_location *al, struct perf_sample *sample, bool nonany_branch_mode)
struct perf_session * perf_session__new(struct perf_data *data, bool repipe, struct perf_tool *tool)
int perf_event__process_mmap2(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine)
void perf_evlist__force_leader(struct perf_evlist *evlist)
void dso__reset_find_symbol_cache(struct dso *dso)
struct annotation_options annotation__default_options
int perf_session__process_events(struct perf_session *session)
static bool has_annotation(struct perf_annotate *ann)
struct annotated_source * src
DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS)
static int hist_iter__branch_callback(struct hist_entry_iter *iter, struct addr_location *al __maybe_unused, bool single __maybe_unused, void *arg __maybe_unused)
static int sym(yyscan_t scanner, int type, int config)
struct block_range_iter block_range__create(u64 start, u64 end)
struct perf_evsel * evsel
struct perf_header header
size_t perf_evlist__fprintf_nr_events(struct perf_evlist *evlist, FILE *fp)
int symbol__init(struct perf_env *env)
struct addr_map_symbol to
struct addr_map_symbol from
struct events_stats stats
const struct hist_iter_ops hist_iter_branch
u32 nr_events[PERF_RECORD_HEADER_MAX]
void symbol__delete(struct symbol *sym)
static bool perf_evsel__is_group_leader(const struct perf_evsel *evsel)
static bool block_range_iter__next(struct block_range_iter *iter)
static int process_branch_callback(struct perf_evsel *evsel, struct perf_sample *sample, struct addr_location *al __maybe_unused, struct perf_annotate *ann, struct machine *machine)
#define perf_evsel__reset_sample_bit(evsel, bit)
void perf_evsel__output_resort(struct perf_evsel *evsel, struct ui_progress *prog)
struct branch_info * sample__resolve_bstack(struct perf_sample *sample, struct addr_location *al)
void annotation_config__init(void)
#define pr_warning(fmt,...)
int perf_session__cpu_bitmap(struct perf_session *session, const char *cpu_list, unsigned long *cpu_bitmap)
static void hists__find_annotations(struct hists *hists, struct perf_evsel *evsel, struct perf_annotate *ann)
int cmd_annotate(int argc, const char **argv)
int perf_event__process_namespaces(struct perf_tool *tool __maybe_unused, union perf_event *event, struct perf_sample *sample, struct machine *machine)
int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_sample *sample, struct perf_evsel *evsel)
void hists__inc_nr_samples(struct hists *hists, bool filtered)
struct perf_session * session
static void process_basic_block(struct addr_map_symbol *start, struct addr_map_symbol *end, struct branch_flags *flags)
int hist_entry_iter__add(struct hist_entry_iter *iter, struct addr_location *al, int max_stack_depth, void *arg)