Lines Matching +full:1 +full:br +full:- +full:100
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Parts came from builtin-annotate.c, see those files for further
16 #include "build-id.h"
30 #include "annotate-data.h"
33 #include "bpf-event.h"
34 #include "bpf-utils.h"
35 #include "block-range.h"
37 #include "dwarf-regs.h"
50 #include <subcmd/parse-options.h>
51 #include <subcmd/run-command.h>
64 #define UARROW_CHAR ((unsigned char)'-')
90 #define NO_TYPE ((struct annotated_data_type *)-1UL)
92 /* symbol histogram: key = offset << 16 | evsel->core.idx */
108 INIT_LIST_HEAD(&src->source); in annotated_source__new()
121 if (src->samples) { in annotated_source__delete()
122 hashmap__for_each_entry(src->samples, cur, bkt) in annotated_source__delete()
123 zfree(&cur->pvalue); in annotated_source__delete()
124 hashmap__free(src->samples); in annotated_source__delete()
126 zfree(&src->histograms); in annotated_source__delete()
133 src->nr_histograms = nr_hists; in annotated_source__alloc_histograms()
134 src->histograms = calloc(nr_hists, sizeof(*src->histograms)); in annotated_source__alloc_histograms()
136 if (src->histograms == NULL) in annotated_source__alloc_histograms()
137 return -1; in annotated_source__alloc_histograms()
139 src->samples = hashmap__new(sym_hist_hash, sym_hist_equal, NULL); in annotated_source__alloc_histograms()
140 if (src->samples == NULL) in annotated_source__alloc_histograms()
141 zfree(&src->histograms); in annotated_source__alloc_histograms()
143 return src->histograms ? 0 : -1; in annotated_source__alloc_histograms()
151 if (notes->src != NULL) { in symbol__annotate_zero_histograms()
152 memset(notes->src->histograms, 0, in symbol__annotate_zero_histograms()
153 notes->src->nr_histograms * sizeof(*notes->src->histograms)); in symbol__annotate_zero_histograms()
154 hashmap__clear(notes->src->samples); in symbol__annotate_zero_histograms()
156 if (notes->branch && notes->branch->cycles_hist) { in symbol__annotate_zero_histograms()
157 memset(notes->branch->cycles_hist, 0, in symbol__annotate_zero_histograms()
217 struct symbol *sym = ms->sym; in __symbol__inc_addr_samples()
223 pr_debug3("%s: addr=%#" PRIx64 "\n", __func__, map__unmap_ip(ms->map, addr)); in __symbol__inc_addr_samples()
225 if ((addr < sym->start || addr >= sym->end) && in __symbol__inc_addr_samples()
226 (addr != sym->end || sym->start != sym->end)) { in __symbol__inc_addr_samples()
227 …pr_debug("%s(%d): ERANGE! sym->name=%s, start=%#" PRIx64 ", addr=%#" PRIx64 ", end=%#" PRIx64 "\n", in __symbol__inc_addr_samples()
228 __func__, __LINE__, sym->name, sym->start, addr, sym->end); in __symbol__inc_addr_samples()
229 return -ERANGE; in __symbol__inc_addr_samples()
232 offset = addr - sym->start; in __symbol__inc_addr_samples()
235 …pr_debug("%s(%d): ENOMEM! sym->name=%s, start=%#" PRIx64 ", addr=%#" PRIx64 ", end=%#" PRIx64 ", f… in __symbol__inc_addr_samples()
236 __func__, __LINE__, sym->name, sym->start, addr, sym->end, sym->type == STT_FUNC); in __symbol__inc_addr_samples()
237 return -ENOMEM; in __symbol__inc_addr_samples()
240 hash_key = offset << 16 | evsel->core.idx; in __symbol__inc_addr_samples()
241 if (!hashmap__find(src->samples, hash_key, &entry)) { in __symbol__inc_addr_samples()
244 return -ENOMEM; in __symbol__inc_addr_samples()
246 if (hashmap__add(src->samples, hash_key, entry) < 0) in __symbol__inc_addr_samples()
247 return -ENOMEM; in __symbol__inc_addr_samples()
250 h->nr_samples++; in __symbol__inc_addr_samples()
251 h->period += sample->period; in __symbol__inc_addr_samples()
252 entry->nr_samples++; in __symbol__inc_addr_samples()
253 entry->period += sample->period; in __symbol__inc_addr_samples()
257 sym->start, sym->name, addr, addr - sym->start, evsel->core.idx, in __symbol__inc_addr_samples()
258 entry->nr_samples, entry->period); in __symbol__inc_addr_samples()
267 if (notes->branch == NULL) in annotation__get_branch()
268 notes->branch = zalloc(sizeof(*notes->branch)); in annotation__get_branch()
270 return notes->branch; in annotation__get_branch()
284 if (branch->cycles_hist == NULL) { in symbol__find_branch_hist()
285 branch->cycles_hist = calloc(size, sizeof(struct cyc_hist)); in symbol__find_branch_hist()
286 if (!branch->cycles_hist) in symbol__find_branch_hist()
290 if (br_cntr_nr && branch->br_cntr == NULL) { in symbol__find_branch_hist()
291 branch->br_cntr = calloc(br_cntr_nr * size, sizeof(u64)); in symbol__find_branch_hist()
292 if (!branch->br_cntr) in symbol__find_branch_hist()
303 if (notes->src == NULL) { in symbol__hists()
304 notes->src = annotated_source__new(); in symbol__hists()
305 if (notes->src == NULL) in symbol__hists()
310 if (notes->src->histograms == NULL) { in symbol__hists()
312 annotated_source__alloc_histograms(notes->src, nr_hists); in symbol__hists()
315 return notes->src; in symbol__hists()
322 struct symbol *sym = ms->sym; in symbol__inc_addr_samples()
327 src = symbol__hists(sym, evsel->evlist->core.nr_entries); in symbol__inc_addr_samples()
336 unsigned int br_cntr_nr = evsel__leader(evsel)->br_cntr_nr; in symbol__account_br_cntr()
337 unsigned int base = evsel__leader(evsel)->br_cntr_idx; in symbol__account_br_cntr()
338 unsigned int off = offset * evsel->evlist->nr_br_cntr; in symbol__account_br_cntr()
339 u64 *branch_br_cntr = branch->br_cntr; in symbol__account_br_cntr()
346 mask = (1L << width) - 1; in symbol__account_br_cntr()
368 branch = symbol__find_branch_hist(sym, evsel->evlist->nr_br_cntr); in symbol__account_cycles()
370 return -ENOMEM; in symbol__account_cycles()
371 if (addr < sym->start || addr >= sym->end) in symbol__account_cycles()
372 return -ERANGE; in symbol__account_cycles()
375 if (start < sym->start || start >= sym->end) in symbol__account_cycles()
376 return -ERANGE; in symbol__account_cycles()
380 offset = addr - sym->start; in symbol__account_cycles()
381 ret = __symbol__account_cycles(branch->cycles_hist, in symbol__account_cycles()
382 start ? start - sym->start : 0, in symbol__account_cycles()
412 (start->ms.sym == ams->ms.sym || in addr_map_symbol__account_cycles()
413 (ams->ms.sym && in addr_map_symbol__account_cycles()
414 start->addr == ams->ms.sym->start + map__start(ams->ms.map)))) in addr_map_symbol__account_cycles()
415 saddr = start->al_addr; in addr_map_symbol__account_cycles()
418 ams->addr, in addr_map_symbol__account_cycles()
419 start ? start->addr : 0, in addr_map_symbol__account_cycles()
420 ams->ms.sym ? ams->ms.sym->start + map__start(ams->ms.map) : 0, in addr_map_symbol__account_cycles()
422 err = symbol__account_cycles(ams->al_addr, saddr, ams->ms.sym, cycles, evsel, br_cntr); in addr_map_symbol__account_cycles()
433 list_for_each_entry(al, &src->source, node) { in annotated_source__get_line()
434 if (al->offset == offset) in annotated_source__get_line()
445 al = annotated_source__get_line(notes->src, start); in annotation__count_insn()
449 list_for_each_entry_from(al, ¬es->src->source, node) { in annotation__count_insn()
450 if (al->offset == -1) in annotation__count_insn()
452 if ((u64)al->offset > end) in annotation__count_insn()
462 zfree(&branch->cycles_hist); in annotated_branch__delete()
463 free(branch->br_cntr); in annotated_branch__delete()
474 if (n_insn && ch->num && ch->cycles) { in annotation__count_and_fill()
477 float ipc = n_insn / ((double)ch->cycles / (double)ch->num); in annotation__count_and_fill()
480 if (ch->reset >= 0x7fff) in annotation__count_and_fill()
483 al = annotated_source__get_line(notes->src, start); in annotation__count_and_fill()
487 list_for_each_entry_from(al, ¬es->src->source, node) { in annotation__count_and_fill()
488 if (al->offset == -1) in annotation__count_and_fill()
490 if ((u64)al->offset > end) in annotation__count_and_fill()
492 if (al->cycles && al->cycles->ipc == 0.0) { in annotation__count_and_fill()
493 al->cycles->ipc = ipc; in annotation__count_and_fill()
500 branch->hit_cycles += ch->cycles; in annotation__count_and_fill()
501 branch->hit_insn += n_insn * ch->num; in annotation__count_and_fill()
502 branch->cover_insn += cover_insn; in annotation__count_and_fill()
510 unsigned int br_cntr_nr = evsel->evlist->nr_br_cntr; in annotation__compute_ipc()
514 if (!notes->branch || !notes->branch->cycles_hist) in annotation__compute_ipc()
517 notes->branch->total_insn = annotation__count_insn(notes, 0, size - 1); in annotation__compute_ipc()
518 notes->branch->hit_cycles = 0; in annotation__compute_ipc()
519 notes->branch->hit_insn = 0; in annotation__compute_ipc()
520 notes->branch->cover_insn = 0; in annotation__compute_ipc()
523 for (offset = size - 1; offset >= 0; --offset) { in annotation__compute_ipc()
526 ch = ¬es->branch->cycles_hist[offset]; in annotation__compute_ipc()
527 if (ch && ch->cycles) { in annotation__compute_ipc()
530 al = annotated_source__get_line(notes->src, offset); in annotation__compute_ipc()
531 if (al && al->cycles == NULL) { in annotation__compute_ipc()
532 al->cycles = zalloc(sizeof(*al->cycles)); in annotation__compute_ipc()
533 if (al->cycles == NULL) { in annotation__compute_ipc()
538 if (ch->have_start) in annotation__compute_ipc()
539 annotation__count_and_fill(notes, ch->start, offset, ch); in annotation__compute_ipc()
540 if (al && ch->num_aggr) { in annotation__compute_ipc()
541 al->cycles->avg = ch->cycles_aggr / ch->num_aggr; in annotation__compute_ipc()
542 al->cycles->max = ch->cycles_max; in annotation__compute_ipc()
543 al->cycles->min = ch->cycles_min; in annotation__compute_ipc()
545 if (al && notes->branch->br_cntr) { in annotation__compute_ipc()
546 if (!al->br_cntr) { in annotation__compute_ipc()
547 al->br_cntr = calloc(br_cntr_nr, sizeof(u64)); in annotation__compute_ipc()
548 if (!al->br_cntr) { in annotation__compute_ipc()
553 al->num_aggr = ch->num_aggr; in annotation__compute_ipc()
554 al->br_cntr_nr = br_cntr_nr; in annotation__compute_ipc()
555 al->evsel = evsel; in annotation__compute_ipc()
556 memcpy(al->br_cntr, ¬es->branch->br_cntr[offset * br_cntr_nr], in annotation__compute_ipc()
564 struct cyc_hist *ch = ¬es->branch->cycles_hist[offset]; in annotation__compute_ipc()
566 if (ch && ch->cycles) { in annotation__compute_ipc()
569 al = annotated_source__get_line(notes->src, offset); in annotation__compute_ipc()
571 zfree(&al->cycles); in annotation__compute_ipc()
572 zfree(&al->br_cntr); in annotation__compute_ipc()
585 return symbol__inc_addr_samples(&ams->ms, evsel, ams->al_addr, sample); in addr_map_symbol__inc_samples()
591 return symbol__inc_addr_samples(&he->ms, evsel, ip, sample); in hist_entry__inc_addr_samples()
597 annotated_source__delete(notes->src); in annotation__exit()
598 annotated_branch__delete(notes->branch); in annotation__exit()
655 list_add_tail(&al->node, head); in annotation_line__add()
662 if (pos->offset >= 0) in annotation_line__next()
668 static const char *annotate__address_color(struct block_range *br) in annotate__address_color() argument
670 double cov = block_range__coverage(br); in annotate__address_color()
677 /* mark dull for <1% coverage */ in annotate__address_color()
685 static const char *annotate__asm_color(struct block_range *br) in annotate__asm_color() argument
687 double cov = block_range__coverage(br); in annotate__asm_color()
690 /* mark dull for <1% coverage */ in annotate__asm_color()
698 static void annotate__branch_printf(struct block_range *br, u64 addr) in annotate__branch_printf() argument
702 if (!br) in annotate__branch_printf()
705 #if 1 in annotate__branch_printf()
706 if (br->is_target && br->start == addr) { in annotate__branch_printf()
707 struct block_range *branch = br; in annotate__branch_printf()
713 while (!branch->is_branch) in annotate__branch_printf()
716 p = 100 *(double)br->entry / branch->coverage; in annotate__branch_printf()
732 if (br->is_branch && br->end == addr) { in annotate__branch_printf()
733 double p = 100*(double)br->taken / br->coverage; in annotate__branch_printf()
745 printf(" -%.2f%% (p:%.2f%%)", p, 100*(double)br->pred / br->taken); in annotate__branch_printf()
752 s64 offset = dl->al.offset; in disasm_line__print()
754 struct block_range *br; in disasm_line__print() local
756 br = block_range__find(addr); in disasm_line__print()
757 color_fprintf(stdout, annotate__address_color(br), " %*" PRIx64 ":", addr_fmt_width, addr); in disasm_line__print()
758 color_fprintf(stdout, annotate__asm_color(br), "%s", dl->al.line); in disasm_line__print()
759 annotate__branch_printf(br, addr); in disasm_line__print()
782 struct symbol *sym = apd->he->ms.sym; in annotation_line__print()
786 int max_lines = opts->max_lines; in annotation_line__print()
787 int percent_type = opts->percent_type; in annotation_line__print()
789 if (al->offset != -1) { in annotation_line__print()
791 int i, nr_percent = 1; in annotation_line__print()
794 for (i = 0; i < al->data_nr; i++) { in annotation_line__print()
797 percent = annotation_data__percent(&al->data[i], in annotation_line__print()
804 if (al->data_nr > nr_percent) in annotation_line__print()
805 nr_percent = al->data_nr; in annotation_line__print()
807 if (max_percent < opts->min_pcnt) in annotation_line__print()
808 return -1; in annotation_line__print()
811 return 1; in annotation_line__print()
815 .max_lines = 1, in annotation_line__print()
819 list_for_each_entry_from(queue, ¬es->src->source, node) { in annotation_line__print()
830 struct annotation_data *data = &al->data[i]; in annotation_line__print()
838 data->he.period); in annotation_line__print()
841 data->he.nr_samples); in annotation_line__print()
848 disasm_line__print(dl, apd->start, apd->addr_fmt_width); in annotation_line__print()
850 if (opts->code_with_type && apd->dbg) { in annotation_line__print()
854 data_type = __hist_entry__get_data_type(apd->he, apd->arch, in annotation_line__print()
855 apd->dbg, dl, &offset); in annotation_line__print()
859 printf("\t\t# data-type: %s", in annotation_line__print()
860 data_type->self.type_name); in annotation_line__print()
879 if (al->path) { in annotation_line__print()
880 if (!prev_line || strcmp(prev_line, al->path)) { in annotation_line__print()
881 color_fprintf(stdout, color, " // %s", al->path); in annotation_line__print()
882 prev_line = al->path; in annotation_line__print()
888 return 1; in annotation_line__print()
893 return -1; in annotation_line__print()
895 if (!*al->line) in annotation_line__print()
898 printf(" %*s: %-*d %s\n", width, " ", apd->addr_fmt_width, in annotation_line__print()
899 al->line_nr, al->line); in annotation_line__print()
918 entry = annotated_source__hist_entry(notes->src, evsel, offset); in calc_percent()
920 hits += entry->nr_samples; in calc_percent()
921 period += entry->period; in calc_percent()
926 if (sym_hist->nr_samples) { in calc_percent()
927 data->he.period = period; in calc_percent()
928 data->he.nr_samples = hits; in calc_percent()
929 data->percent[PERCENT_HITS_LOCAL] = 100.0 * hits / sym_hist->nr_samples; in calc_percent()
932 if (hists->stats.nr_non_filtered_samples) in calc_percent()
933 data->percent[PERCENT_HITS_GLOBAL] = 100.0 * hits / hists->stats.nr_non_filtered_samples; in calc_percent()
935 if (sym_hist->period) in calc_percent()
936 data->percent[PERCENT_PERIOD_LOCAL] = 100.0 * period / sym_hist->period; in calc_percent()
938 if (hists->stats.total_period) in calc_percent()
939 data->percent[PERCENT_PERIOD_GLOBAL] = 100.0 * period / hists->stats.total_period; in calc_percent()
948 list_for_each_entry(al, ¬es->src->source, node) { in annotation__calc_percent()
952 if (al->offset == -1) in annotation__calc_percent()
955 next = annotation_line__next(al, ¬es->src->source); in annotation__calc_percent()
956 end = next ? next->offset : len; in annotation__calc_percent()
961 BUG_ON(i >= al->data_nr); in annotation__calc_percent()
964 evsel__hists(evsel)->stats.nr_samples == 0) in annotation__calc_percent()
967 data = &al->data[i++]; in annotation__calc_percent()
969 calc_percent(notes, evsel, data, al->offset, end); in annotation__calc_percent()
999 if (arch->init) { in evsel__get_arch()
1000 err = arch->init(arch, env ? env->cpuid : NULL); in evsel__get_arch()
1003 __func__, arch->name); in evsel__get_arch()
1013 struct symbol *sym = ms->sym; in symbol__annotate()
1029 if (notes->src && !list_empty(¬es->src->source)) in symbol__annotate()
1035 if (notes->src == NULL) { in symbol__annotate()
1036 notes->src = annotated_source__new(); in symbol__annotate()
1037 if (notes->src == NULL) in symbol__annotate()
1038 return -1; in symbol__annotate()
1047 evsel__hists(pos)->stats.nr_samples == 0) in symbol__annotate()
1052 notes->src->nr_events = nr ? nr : 1; in symbol__annotate()
1055 notes->src->start = map__objdump_2mem(ms->map, ms->sym->start); in symbol__annotate()
1057 notes->src->start = map__rip_2objdump(ms->map, ms->sym->start); in symbol__annotate()
1065 struct rb_node **p = &root->rb_node; in insert_source_line()
1074 ret = strcmp(iter->path, al->path); in insert_source_line()
1076 for (i = 0; i < al->data_nr; i++) { in insert_source_line()
1077 iter->data[i].percent_sum += annotation_data__percent(&al->data[i], in insert_source_line()
1084 p = &(*p)->rb_left; in insert_source_line()
1086 p = &(*p)->rb_right; in insert_source_line()
1089 for (i = 0; i < al->data_nr; i++) { in insert_source_line()
1090 al->data[i].percent_sum = annotation_data__percent(&al->data[i], in insert_source_line()
1094 rb_link_node(&al->rb_node, parent, p); in insert_source_line()
1095 rb_insert_color(&al->rb_node, root); in insert_source_line()
1102 for (i = 0; i < a->data_nr; i++) { in cmp_source_line()
1103 if (a->data[i].percent_sum == b->data[i].percent_sum) in cmp_source_line()
1105 return a->data[i].percent_sum > b->data[i].percent_sum; in cmp_source_line()
1114 struct rb_node **p = &root->rb_node; in __resort_source_line()
1122 p = &(*p)->rb_left; in __resort_source_line()
1124 p = &(*p)->rb_right; in __resort_source_line()
1127 rb_link_node(&al->rb_node, parent, p); in __resort_source_line()
1128 rb_insert_color(&al->rb_node, root); in __resort_source_line()
1155 printf("----------------------------------------------\n\n"); in print_summary()
1170 for (i = 0; i < al->data_nr; i++) { in print_summary()
1171 percent = al->data[i].percent_sum; in print_summary()
1179 path = al->path; in print_summary()
1196 entry = annotated_source__hist_entry(notes->src, evsel, offset); in symbol__annotate_hits()
1197 if (entry && entry->nr_samples != 0) in symbol__annotate_hits()
1199 sym->start + offset, entry->nr_samples); in symbol__annotate_hits()
1201 printf("%*s: %" PRIu64 "\n", BITS_PER_LONG / 2, "h->nr_samples", h->nr_samples); in symbol__annotate_hits()
1210 if (line->offset != -1) in annotated_source__addr_fmt_width()
1211 return scnprintf(bf, sizeof(bf), "%" PRIx64, start + line->offset); in annotated_source__addr_fmt_width()
1219 struct map_symbol *ms = &he->ms; in hist_entry__annotate_printf()
1220 struct map *map = ms->map; in hist_entry__annotate_printf()
1221 struct symbol *sym = ms->sym; in hist_entry__annotate_printf()
1233 .start = map__rip_2objdump(map, sym->start), in hist_entry__annotate_printf()
1237 bool context = opts->context; in hist_entry__annotate_printf()
1244 return -ENOMEM; in hist_entry__annotate_printf()
1246 if (opts->full_path) in hist_entry__annotate_printf()
1256 graph_dotted_len = printf(" %-*.*s| Source code & Disassembly of %s for %s (%" PRIu64 " samples, " in hist_entry__annotate_printf()
1260 d_filename, evsel_name, h->nr_samples, in hist_entry__annotate_printf()
1261 percent_type_str(opts->percent_type)); in hist_entry__annotate_printf()
1263 printf("%-*.*s----\n", in hist_entry__annotate_printf()
1269 apd.addr_fmt_width = annotated_source__addr_fmt_width(¬es->src->source, in hist_entry__annotate_printf()
1274 list_for_each_entry(pos, ¬es->src->source, node) { in hist_entry__annotate_printf()
1293 case 1: in hist_entry__annotate_printf()
1297 case -1: in hist_entry__annotate_printf()
1306 queue = list_entry(queue->node.next, typeof(*queue), node); in hist_entry__annotate_printf()
1374 list_for_each_entry(al, ¬es->src->source, node) { in symbol__annotate_fprintf2()
1390 int err = -1; in map_symbol__annotation_dump()
1393 if (asprintf(&filename, "%s.annotation", ms->sym->name) < 0) in map_symbol__annotation_dump()
1394 return -1; in map_symbol__annotation_dump()
1406 ms->sym->name, dso__long_name(map__dso(ms->map)), ev_name); in map_symbol__annotation_dump()
1407 symbol__annotate_fprintf2(ms->sym, fp); in map_symbol__annotation_dump()
1421 memset(h, 0, sizeof(*notes->src->histograms) * notes->src->nr_histograms); in symbol__annotate_zero_histogram()
1430 h->nr_samples = 0; in symbol__annotate_decay_histogram()
1431 list_for_each_entry(al, ¬es->src->source, node) { in symbol__annotate_decay_histogram()
1434 if (al->offset == -1) in symbol__annotate_decay_histogram()
1437 entry = annotated_source__hist_entry(notes->src, evsel, al->offset); in symbol__annotate_decay_histogram()
1441 entry->nr_samples = entry->nr_samples * 7 / 8; in symbol__annotate_decay_histogram()
1442 h->nr_samples += entry->nr_samples; in symbol__annotate_decay_histogram()
1450 list_for_each_entry_safe(al, n, &as->source, node) { in annotated_source__purge()
1451 list_del_init(&al->node); in annotated_source__purge()
1460 if (dl->al.offset == -1) in disasm_line__fprintf()
1461 return fprintf(fp, "%s\n", dl->al.line); in disasm_line__fprintf()
1463 printed = fprintf(fp, "%#" PRIx64 " %s", dl->al.offset, dl->ins.name); in disasm_line__fprintf()
1465 if (dl->ops.raw[0] != '\0') { in disasm_line__fprintf()
1466 printed += fprintf(fp, "%.*s %s\n", 6 - (int)printed, " ", in disasm_line__fprintf()
1467 dl->ops.raw); in disasm_line__fprintf()
1486 if (!dl || !dl->ins.ops || !ins__is_jump(&dl->ins) || in disasm_line__is_valid_local_jump()
1487 !disasm_line__has_local_offset(dl) || dl->ops.target.offset < 0 || in disasm_line__is_valid_local_jump()
1488 dl->ops.target.offset >= (s64)symbol__size(sym)) in disasm_line__is_valid_local_jump()
1500 if (strstr(sym->name, "@plt")) in annotation__mark_jump_targets()
1503 list_for_each_entry(al, ¬es->src->source, node) { in annotation__mark_jump_targets()
1512 target = annotated_source__get_line(notes->src, in annotation__mark_jump_targets()
1513 dl->ops.target.offset); in annotation__mark_jump_targets()
1521 if (++target->jump_sources > notes->src->max_jump_sources) in annotation__mark_jump_targets()
1522 notes->src->max_jump_sources = target->jump_sources; in annotation__mark_jump_targets()
1529 struct annotated_source *src = notes->src; in annotation__set_index()
1531 src->widths.max_line_len = 0; in annotation__set_index()
1532 src->nr_entries = 0; in annotation__set_index()
1533 src->nr_asm_entries = 0; in annotation__set_index()
1535 list_for_each_entry(al, &src->source, node) { in annotation__set_index()
1536 size_t line_len = strlen(al->line); in annotation__set_index()
1538 if (src->widths.max_line_len < line_len) in annotation__set_index()
1539 src->widths.max_line_len = line_len; in annotation__set_index()
1540 al->idx = src->nr_entries++; in annotation__set_index()
1541 if (al->offset != -1) in annotation__set_index()
1542 al->idx_asm = src->nr_asm_entries++; in annotation__set_index()
1544 al->idx_asm = -1; in annotation__set_index()
1550 if (n >= 100) in width_jumps()
1554 return 1; in width_jumps()
1562 list_for_each_entry(al, ¬es->src->source, node) { in annotation__max_ins_name()
1563 if (al->offset == -1) in annotation__max_ins_name()
1566 len = strlen(disasm_line(al)->ins.name); in annotation__max_ins_name()
1577 notes->src->widths.addr = notes->src->widths.target = in annotation__init_column_widths()
1578 notes->src->widths.min_addr = hex_width(symbol__size(sym)); in annotation__init_column_widths()
1579 notes->src->widths.max_addr = hex_width(sym->end); in annotation__init_column_widths()
1580 notes->src->widths.jumps = width_jumps(notes->src->max_jump_sources); in annotation__init_column_widths()
1581 notes->src->widths.max_ins_name = annotation__max_ins_name(notes); in annotation__init_column_widths()
1587 notes->src->widths.target = notes->src->widths.min_addr; in annotation__update_column_widths()
1589 notes->src->widths.target = BITS_PER_LONG / 4; in annotation__update_column_widths()
1591 notes->src->widths.target = notes->src->widths.max_addr; in annotation__update_column_widths()
1593 notes->src->widths.addr = notes->src->widths.target; in annotation__update_column_widths()
1596 notes->src->widths.addr += notes->src->widths.jumps + 1; in annotation__update_column_widths()
1604 notes->src->start = map__objdump_2mem(ms->map, ms->sym->start); in annotation__toggle_full_addr()
1606 notes->src->start = map__rip_2objdump(ms->map, ms->sym->start); in annotation__toggle_full_addr()
1617 list_for_each_entry(al, ¬es->src->source, node) { in annotation__calc_lines()
1622 for (i = 0; i < al->data_nr; i++) { in annotation__calc_lines()
1625 percent = annotation_data__percent(&al->data[i], in annotation__calc_lines()
1635 addr = map__rip_2objdump(ms->map, ms->sym->start); in annotation__calc_lines()
1636 al->path = get_srcline(map__dso(ms->map), addr + al->offset, NULL, in annotation__calc_lines()
1637 false, true, ms->sym->start + al->offset); in annotation__calc_lines()
1646 struct annotation *notes = symbol__annotation(ms->sym); in symbol__calc_lines()
1653 struct map_symbol *ms = &he->ms; in hist_entry__tty_annotate2()
1654 struct dso *dso = map__dso(ms->map); in hist_entry__tty_annotate2()
1655 struct symbol *sym = ms->sym; in hist_entry__tty_annotate2()
1667 ui__error("Couldn't annotate %s:\n%s", sym->name, msg); in hist_entry__tty_annotate2()
1668 return -1; in hist_entry__tty_annotate2()
1679 buf, percent_type_str(annotate_opts.percent_type), sym->name, dso__long_name(dso)); in hist_entry__tty_annotate2()
1682 annotated_source__purge(symbol__annotation(sym)->src); in hist_entry__tty_annotate2()
1689 struct map_symbol *ms = &he->ms; in hist_entry__tty_annotate()
1690 struct dso *dso = map__dso(ms->map); in hist_entry__tty_annotate()
1691 struct symbol *sym = ms->sym; in hist_entry__tty_annotate()
1701 ui__error("Couldn't annotate %s:\n%s", sym->name, msg); in hist_entry__tty_annotate()
1702 return -1; in hist_entry__tty_annotate()
1715 annotated_source__purge(symbol__annotation(sym)->src); in hist_entry__tty_annotate()
1722 return use_browser == 1 && perf_hpp_list.sym; in ui__has_annotation()
1732 for (i = 0; i < al->data_nr; i++) { in annotation_line__max_percent()
1735 percent = annotation_data__percent(&al->data[i], in annotation_line__max_percent()
1750 if (dl->ins.ops && dl->ins.ops->scnprintf) { in disasm_line__write()
1751 if (ins__is_jump(&dl->ins)) { in disasm_line__write()
1754 if (dl->ops.target.outside) in disasm_line__write()
1756 fwd = dl->ops.target.offset > dl->al.offset; in disasm_line__write()
1759 } else if (ins__is_call(&dl->ins)) { in disasm_line__write()
1763 } else if (ins__is_ret(&dl->ins)) { in disasm_line__write()
1774 notes->src->widths.max_ins_name); in disasm_line__write()
1782 if (branch && branch->hit_cycles) in ipc_coverage_string()
1783 ipc = branch->hit_insn / ((double)branch->hit_cycles); in ipc_coverage_string()
1785 if (branch && branch->total_insn) { in ipc_coverage_string()
1786 coverage = branch->cover_insn * 100.0 / in ipc_coverage_string()
1787 ((double)branch->total_insn); in ipc_coverage_string()
1790 scnprintf(bf, size, "(Average IPC: %.2f, IPC Coverage: %.1f%%)", in ipc_coverage_string()
1799 if (evsel->evlist->nr_br_cntr <= 0) in annotation_br_cntr_abbr_list()
1800 return -ENOTSUP; in annotation_br_cntr_abbr_list()
1807 evlist__for_each_entry(evsel->evlist, pos) { in annotation_br_cntr_abbr_list()
1808 if (!(pos->core.attr.branch_sample_type & PERF_SAMPLE_BRANCH_COUNTERS)) in annotation_br_cntr_abbr_list()
1813 if (strbuf_addf(&sb, " %s = %s\n", pos->name, pos->abbr_name)) in annotation_br_cntr_abbr_list()
1819 if (strbuf_addf(&sb, " '-' No event occurs\n")) in annotation_br_cntr_abbr_list()
1832 return -ENOMEM; in annotation_br_cntr_abbr_list()
1842 struct evsel *pos = evsel ? evlist__first(evsel->evlist) : NULL; in annotation_br_cntr_entry()
1855 * With -v, the exact number of branch counter is displayed. in annotation_br_cntr_entry()
1858 evlist__for_each_entry_from(evsel->evlist, pos) { in annotation_br_cntr_entry()
1859 if ((pos->core.attr.branch_sample_type & PERF_SAMPLE_BRANCH_COUNTERS) && in annotation_br_cntr_entry()
1860 (pos->br_cntr_idx == i)) in annotation_br_cntr_entry()
1863 if (strbuf_addstr(&sb, pos->abbr_name)) in annotation_br_cntr_entry()
1867 if (strbuf_addstr(&sb, "=-")) in annotation_br_cntr_entry()
1881 if ((i < br_cntr_nr - 1) && strbuf_addch(&sb, ',')) in annotation_br_cntr_entry()
1890 if (strbuf_addch(&sb, '-')) in annotation_br_cntr_entry()
1894 evlist__for_each_entry_from(evsel->evlist, pos) { in annotation_br_cntr_entry()
1895 if ((pos->core.attr.branch_sample_type & PERF_SAMPLE_BRANCH_COUNTERS) && in annotation_br_cntr_entry()
1896 (pos->br_cntr_idx == i)) in annotation_br_cntr_entry()
1908 if (strbuf_addstr(&sb, pos->abbr_name)) in annotation_br_cntr_entry()
1920 for (j = used; j < ANNOTATION_BR_CNTR_SATURATION + 1; j++) { in annotation_br_cntr_entry()
1934 return -ENOMEM; in annotation_br_cntr_entry()
1954 if (first_line && (al->offset == -1 || percent_max == 0.0)) { in __annotation_line__write()
1955 if (notes->branch && al->cycles) { in __annotation_line__write()
1956 if (al->cycles->ipc == 0.0 && al->cycles->avg == 0) in __annotation_line__write()
1962 if (al->offset != -1 && percent_max != 0.0) { in __annotation_line__write()
1965 for (i = 0; i < al->data_nr; i++) { in __annotation_line__write()
1968 percent = annotation_data__percent(&al->data[i], percent_type); in __annotation_line__write()
1972 obj__printf(obj, "%11" PRIu64 " ", al->data[i].he.period); in __annotation_line__write()
1975 al->data[i].he.nr_samples); in __annotation_line__write()
1984 obj__printf(obj, "%-*s", pcnt_width, " "); in __annotation_line__write()
1986 obj__printf(obj, "%-*s", pcnt_width, in __annotation_line__write()
1992 if (notes->branch) { in __annotation_line__write()
1993 if (al->cycles && al->cycles->ipc) in __annotation_line__write()
1994 obj__printf(obj, "%*.2f ", ANNOTATION__IPC_WIDTH - 1, al->cycles->ipc); in __annotation_line__write()
1998 obj__printf(obj, "%*s ", ANNOTATION__IPC_WIDTH - 1, "IPC"); in __annotation_line__write()
2001 if (al->cycles && al->cycles->avg) in __annotation_line__write()
2003 ANNOTATION__CYCLES_WIDTH - 1, al->cycles->avg); in __annotation_line__write()
2009 ANNOTATION__CYCLES_WIDTH - 1, in __annotation_line__write()
2012 if (al->cycles) { in __annotation_line__write()
2017 al->cycles->avg, al->cycles->min, in __annotation_line__write()
2018 al->cycles->max); in __annotation_line__write()
2021 ANNOTATION__MINMAX_CYCLES_WIDTH - 1, in __annotation_line__write()
2029 ANNOTATION__MINMAX_CYCLES_WIDTH - 1, in __annotation_line__write()
2041 if (!annotation_br_cntr_entry(&buf, al->br_cntr_nr, al->br_cntr, in __annotation_line__write()
2042 al->num_aggr, al->evsel)) { in __annotation_line__write()
2049 if (show_title && !*al->line) { in __annotation_line__write()
2057 if (!*al->line) in __annotation_line__write()
2058 obj__printf(obj, "%-*s", width - pcnt_width - cycles_width, " "); in __annotation_line__write()
2059 else if (al->offset == -1) { in __annotation_line__write()
2060 if (al->line_nr && annotate_opts.show_linenr) in __annotation_line__write()
2061 printed = scnprintf(bf, sizeof(bf), "%-*d ", in __annotation_line__write()
2062 notes->src->widths.addr + 1, al->line_nr); in __annotation_line__write()
2064 printed = scnprintf(bf, sizeof(bf), "%-*s ", in __annotation_line__write()
2065 notes->src->widths.addr, " "); in __annotation_line__write()
2067 obj__printf(obj, "%-*s", width - printed - pcnt_width - cycles_width + 1, al->line); in __annotation_line__write()
2069 u64 addr = al->offset; in __annotation_line__write()
2070 int color = -1; in __annotation_line__write()
2073 addr += notes->src->start; in __annotation_line__write()
2078 if (al->jump_sources && in __annotation_line__write()
2083 notes->src->widths.jumps, in __annotation_line__write()
2084 al->jump_sources); in __annotation_line__write()
2085 prev = obj__set_jumps_percent_color(obj, al->jump_sources, in __annotation_line__write()
2092 notes->src->widths.target, addr); in __annotation_line__write()
2093 } else if (ins__is_call(&disasm_line(al)->ins) && in __annotation_line__write()
2099 printed = scnprintf(bf, sizeof(bf), "%-*s ", in __annotation_line__write()
2100 notes->src->widths.addr, " "); in __annotation_line__write()
2112 obj__printf(obj, "%-*s", width - pcnt_width - cycles_width - 3 - printed, bf); in __annotation_line__write()
2120 __annotation_line__write(al, notes, wops->first_line, wops->current_entry, in annotation_line__write()
2121 wops->change_color, wops->width, wops->obj, in annotation_line__write()
2123 wops->set_color, wops->set_percent_color, in annotation_line__write()
2124 wops->set_jumps_percent_color, wops->printf, in annotation_line__write()
2125 wops->write_graph); in annotation_line__write()
2131 struct symbol *sym = ms->sym; in symbol__annotate2()
2151 sym->annotate2 = 1; in symbol__annotate2()
2167 for (u8 i = 0; i < ARRAY_SIZE(options->disassemblers); i++) { in annotation_options__add_disassembler()
2168 if (options->disassemblers[i] == dis) { in annotation_options__add_disassembler()
2172 if (options->disassemblers[i] == PERF_DISASM_UNKNOWN) { in annotation_options__add_disassembler()
2174 options->disassemblers[i] = dis; in annotation_options__add_disassembler()
2186 int len = comma ? comma - str : (int)strlen(str); in annotation_options__add_disassemblers_str()
2200 return -1; in annotation_options__add_disassemblers_str()
2202 str = comma ? comma + 1 : NULL; in annotation_options__add_disassemblers_str()
2215 perf_config_u8(&opt->offset_level, "offset_level", value); in annotation__config()
2217 if (opt->offset_level > ANNOTATION__MAX_OFFSET_LEVEL) in annotation__config()
2218 opt->offset_level = ANNOTATION__MAX_OFFSET_LEVEL; in annotation__config()
2219 else if (opt->offset_level < ANNOTATION__MIN_OFFSET_LEVEL) in annotation__config()
2220 opt->offset_level = ANNOTATION__MIN_OFFSET_LEVEL; in annotation__config()
2227 opt->hide_src_code = perf_config_bool("hide_src_code", value); in annotation__config()
2229 opt->jump_arrows = perf_config_bool("jump_arrows", value); in annotation__config()
2231 opt->show_linenr = perf_config_bool("show_linenr", value); in annotation__config()
2233 opt->show_nr_jumps = perf_config_bool("show_nr_jumps", value); in annotation__config()
2241 opt->use_offset = perf_config_bool("use_offset", value); in annotation__config()
2243 opt->disassembler_style = strdup(value); in annotation__config()
2244 if (!opt->disassembler_style) { in annotation__config()
2246 return -1; in annotation__config()
2249 opt->objdump_path = strdup(value); in annotation__config()
2250 if (!opt->objdump_path) { in annotation__config()
2252 return -1; in annotation__config()
2258 return -1; in annotation__config()
2278 opt->use_offset = true; in annotation_options__init()
2279 opt->jump_arrows = true; in annotation_options__init()
2280 opt->annotate_src = true; in annotation_options__init()
2281 opt->offset_level = ANNOTATION__OFFSET_JUMP_TARGETS; in annotation_options__init()
2282 opt->percent_type = PERCENT_PERIOD_LOCAL; in annotation_options__init()
2293 if (options->disassemblers[0] != PERF_DISASM_UNKNOWN) { in annotation_options__default_init_disassemblers()
2314 unsigned int type = (unsigned int) -1; in parse_percent_type()
2338 int err = -1; in annotate_parse_percent_type()
2342 return -ENOMEM; in annotate_parse_percent_type()
2344 str2 = strchr(str1, '-'); in annotate_parse_percent_type()
2351 if (type == (unsigned int) -1) in annotate_parse_percent_type()
2353 if (type != (unsigned int) -1) { in annotate_parse_percent_type()
2367 if (args->prefix_strip && !args->prefix) { in annotate_check_args()
2368 pr_err("--prefix-strip requires --prefix\n"); in annotate_check_args()
2369 return -1; in annotate_check_args()
2386 if (arch->objdump.register_char == 0) in extract_reg_offset()
2387 return -1; in extract_reg_offset()
2396 if (*str == arch->objdump.register_char) { in extract_reg_offset()
2400 op_loc->segment = INSN_SEG_X86_GS; in extract_reg_offset()
2404 *str != arch->objdump.memory_ref_char) in extract_reg_offset()
2408 op_loc->offset = strtol(str, &p, 0); in extract_reg_offset()
2410 p = strchr(p, arch->objdump.register_char); in extract_reg_offset()
2412 return -1; in extract_reg_offset()
2416 return -1; in extract_reg_offset()
2418 op_loc->reg1 = get_dwarf_regnum(regname, arch->e_machine, arch->e_flags); in extract_reg_offset()
2422 if (op_loc->multi_regs) { in extract_reg_offset()
2423 p = strchr(p + 1, arch->objdump.register_char); in extract_reg_offset()
2425 return -1; in extract_reg_offset()
2429 return -1; in extract_reg_offset()
2431 op_loc->reg2 = get_dwarf_regnum(regname, arch->e_machine, arch->e_flags); in extract_reg_offset()
2438 * annotate_get_insn_location - Get location of instruction
2451 * mov (%rax), %rcx # src_reg1 = rax, src_mem = 1, src_offset = 0
2454 * mov 0x18, %r8 # src_reg1 = -1, src_mem = 0
2458 * # dst_reg1 = rbx, dst_reg2 = rcx, dst_mem = 1
2459 * # dst_multi_regs = 1, dst_offset = 8
2468 if (ins__is_lock(&dl->ins)) in annotate_get_insn_location()
2469 ops = dl->ops.locked.ops; in annotate_get_insn_location()
2471 ops = &dl->ops; in annotate_get_insn_location()
2474 return -1; in annotate_get_insn_location()
2479 const char *insn_str = ops->source.raw; in annotate_get_insn_location()
2480 bool multi_regs = ops->source.multi_regs; in annotate_get_insn_location()
2481 bool mem_ref = ops->source.mem_ref; in annotate_get_insn_location()
2484 insn_str = ops->target.raw; in annotate_get_insn_location()
2485 multi_regs = ops->target.multi_regs; in annotate_get_insn_location()
2486 mem_ref = ops->target.mem_ref; in annotate_get_insn_location()
2490 op_loc->reg1 = -1; in annotate_get_insn_location()
2491 op_loc->reg2 = -1; in annotate_get_insn_location()
2504 op_loc->mem_ref = mem_ref; in annotate_get_insn_location()
2505 op_loc->multi_regs = multi_regs; in annotate_get_insn_location()
2506 get_powerpc_regs(dl->raw.raw_insn, !i, op_loc); in annotate_get_insn_location()
2507 } else if (strchr(insn_str, arch->objdump.memory_ref_char)) { in annotate_get_insn_location()
2508 op_loc->mem_ref = true; in annotate_get_insn_location()
2509 op_loc->multi_regs = multi_regs; in annotate_get_insn_location()
2517 op_loc->segment = INSN_SEG_X86_GS; in annotate_get_insn_location()
2518 op_loc->offset = strtol(insn_str + 4, in annotate_get_insn_location()
2521 op_loc->imm = true; in annotate_get_insn_location()
2528 return -1; in annotate_get_insn_location()
2530 if (*s == arch->objdump.register_char) in annotate_get_insn_location()
2531 op_loc->reg1 = get_dwarf_regnum(s, arch->e_machine, arch->e_flags); in annotate_get_insn_location()
2532 else if (*s == arch->objdump.imm_char) { in annotate_get_insn_location()
2533 op_loc->offset = strtol(s + 1, &p, 0); in annotate_get_insn_location()
2534 if (p && p != s + 1) in annotate_get_insn_location()
2535 op_loc->imm = true; in annotate_get_insn_location()
2552 list_for_each_entry(dl, ¬es->src->source, al.node) { in find_disasm_line()
2553 if (dl->al.offset == -1) in find_disasm_line()
2556 if (sym->start + dl->al.offset == ip) { in find_disasm_line()
2558 * llvm-objdump places "lock" in a separate line and in find_disasm_line()
2561 if (ins__is_lock(&dl->ins) && in find_disasm_line()
2562 *dl->ops.raw == '\0' && allow_update) { in find_disasm_line()
2578 if (!strcmp(istat->name, name)) in annotate_data_stat()
2586 istat->name = strdup(name); in annotate_data_stat()
2587 if ((istat->name == NULL) || (!strlen(istat->name))) { in annotate_data_stat()
2592 list_add_tail(&istat->list, head); in annotate_data_stat()
2599 if (!strncmp(dl->ins.name, "push", 4) || in is_stack_operation()
2600 !strncmp(dl->ins.name, "pop", 3) || in is_stack_operation()
2601 !strncmp(dl->ins.name, "call", 4) || in is_stack_operation()
2602 !strncmp(dl->ins.name, "ret", 3)) in is_stack_operation()
2613 if (loc->segment == INSN_SEG_X86_GS && loc->imm && in is_stack_canary()
2614 loc->offset == 40) in is_stack_canary()
2624 struct list_head *sources = ¬es->src->source; in annotation__prev_asm_line()
2631 while (prev->al.offset == -1 && in annotation__prev_asm_line()
2635 if (prev->al.offset == -1) in annotation__prev_asm_line()
2644 struct list_head *sources = ¬es->src->source; in annotation__next_asm_line()
2651 while (next->al.offset == -1 && in annotation__next_asm_line()
2655 if (next->al.offset == -1) in annotation__next_asm_line()
2668 notes = symbol__annotation(ms->sym); in annotate_calc_pcrel()
2670 * PC-relative addressing starts from the next instruction address in annotate_calc_pcrel()
2678 addr = ms->sym->end + offset; in annotate_calc_pcrel()
2680 addr = ip + (next->al.offset - dl->al.offset) + offset; in annotate_calc_pcrel()
2682 return map__rip_2objdump(ms->map, addr); in annotate_calc_pcrel()
2704 struct map_symbol *ms = &he->ms; in __hist_entry__get_data_type()
2711 istat = annotate_data_stat(&ann_insn_stat, dl->ins.name); in __hist_entry__get_data_type()
2719 istat->bad++; in __hist_entry__get_data_type()
2724 istat->good++; in __hist_entry__get_data_type()
2732 .thread = he->thread, in __hist_entry__get_data_type()
2734 .ip = ms->sym->start + dl->al.offset, in __hist_entry__get_data_type()
2735 .cpumode = he->cpumode, in __hist_entry__get_data_type()
2740 if (!op_loc->mem_ref && op_loc->segment == INSN_SEG_NONE) in __hist_entry__get_data_type()
2743 /* PC-relative addressing */ in __hist_entry__get_data_type()
2744 if (op_loc->reg1 == DWARF_REG_PC) { in __hist_entry__get_data_type()
2746 op_loc->offset, dl); in __hist_entry__get_data_type()
2749 /* This CPU access in kernel - pretend PC-relative addressing */ in __hist_entry__get_data_type()
2750 if (dso__kernel(map__dso(ms->map)) && arch__is(arch, "x86") && in __hist_entry__get_data_type()
2751 op_loc->segment == INSN_SEG_X86_GS && op_loc->imm) { in __hist_entry__get_data_type()
2752 dloc.var_addr = op_loc->offset; in __hist_entry__get_data_type()
2753 op_loc->reg1 = DWARF_REG_PC; in __hist_entry__get_data_type()
2759 istat->good++; in __hist_entry__get_data_type()
2765 istat->good++; in __hist_entry__get_data_type()
2767 istat->bad++; in __hist_entry__get_data_type()
2770 struct evsel *evsel = hists_to_evsel(he->hists); in __hist_entry__get_data_type()
2774 he->stat.nr_events, in __hist_entry__get_data_type()
2775 he->stat.period); in __hist_entry__get_data_type()
2786 * hist_entry__get_data_type - find data type for given hist entry
2789 * This function first annotates the instruction at @he->ip and extracts
2796 struct map_symbol *ms = &he->ms; in hist_entry__get_data_type()
2797 struct evsel *evsel = hists_to_evsel(he->hists); in hist_entry__get_data_type()
2802 u64 ip = he->ip; in hist_entry__get_data_type()
2806 if (ms->map == NULL || ms->sym == NULL) { in hist_entry__get_data_type()
2824 if (map__dso(ms->map) != di_cache.dso) { in hist_entry__get_data_type()
2826 di_cache.dso = dso__get(map__dso(ms->map)); in hist_entry__get_data_type()
2847 dl = find_disasm_line(ms->sym, ip, /*allow_update=*/true); in hist_entry__get_data_type()
2855 &he->mem_type_off); in hist_entry__get_data_type()
2863 if (dl->al.offset > 0) { in hist_entry__get_data_type()
2867 notes = symbol__annotation(ms->sym); in hist_entry__get_data_type()
2870 if (prev_dl && ins__is_fused(arch, prev_dl->ins.name, dl->ins.name)) { in hist_entry__get_data_type()
2877 istat = annotate_data_stat(&ann_insn_stat, dl->ins.name); in hist_entry__get_data_type()
2879 istat->bad++; in hist_entry__get_data_type()
2906 s64 begin_offset = link->bb->begin->al.offset; in basic_block_has_offset()
2907 s64 end_offset = link->bb->end->al.offset; in basic_block_has_offset()
2918 s64 offset = dl->al.offset; in is_new_basic_block()
2920 if (basic_block_has_offset(&bb_data->visited, offset)) in is_new_basic_block()
2922 if (basic_block_has_offset(&bb_data->queue, offset)) in is_new_basic_block()
2936 return -1; in add_basic_block()
2943 return -1; in add_basic_block()
2945 bb->begin = dl; in add_basic_block()
2946 bb->end = dl; in add_basic_block()
2947 INIT_LIST_HEAD(&bb->list); in add_basic_block()
2952 return -1; in add_basic_block()
2955 link->bb = bb; in add_basic_block()
2956 link->parent = parent; in add_basic_block()
2957 list_add_tail(&link->node, &bb_data->queue); in add_basic_block()
2970 dl = link->bb->begin; in process_basic_block()
2972 if (basic_block_has_offset(&bb_data->visited, dl->al.offset)) in process_basic_block()
2975 last_dl = list_last_entry(¬es->src->source, in process_basic_block()
2977 if (last_dl->al.offset == -1) in process_basic_block()
2983 list_for_each_entry_from(dl, ¬es->src->source, al.node) { in process_basic_block()
2985 if (dl->al.offset == -1) in process_basic_block()
2988 if (sym->start + dl->al.offset == target) { in process_basic_block()
2996 if (ins__is_ret(&dl->ins)) in process_basic_block()
2999 if (!ins__is_jump(&dl->ins)) in process_basic_block()
3002 if (dl->ops.target.outside) in process_basic_block()
3005 next_dl = find_disasm_line(sym, sym->start + dl->ops.target.offset, in process_basic_block()
3015 if (!strstr(dl->ins.name, "jmp")) { in process_basic_block()
3023 link->bb->end = dl; in process_basic_block()
3035 struct basic_block_link *parent = link->parent; in link_found_basic_blocks()
3037 list_move(&link->bb->list, head); in link_found_basic_blocks()
3038 list_del(&link->node); in link_found_basic_blocks()
3049 list_for_each_entry_safe(link, tmp, &bb_data->queue, node) { in delete_basic_blocks()
3050 list_del(&link->node); in delete_basic_blocks()
3051 zfree(&link->bb); in delete_basic_blocks()
3055 list_for_each_entry_safe(link, tmp, &bb_data->visited, node) { in delete_basic_blocks()
3056 list_del(&link->node); in delete_basic_blocks()
3057 zfree(&link->bb); in delete_basic_blocks()
3063 * annotate_get_basic_blocks - Get basic blocks for given address range
3083 int ret = -1; in annotate_get_basic_blocks()
3087 return -1; in annotate_get_basic_blocks()
3090 return -1; in annotate_get_basic_blocks()
3101 list_move(&link->node, &bb_data.visited); in annotate_get_basic_blocks()