annotate.c (9d355b381b35be1ac4e77600d6b9b27c674c5d5f) | annotate.c (2975489458c59ce2e348b1b3aef5d8d2acb5cc8d) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2011, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com> 4 * 5 * Parts came from builtin-annotate.c, see those files for further 6 * copyright notes. 7 */ 8 --- 1569 unchanged lines hidden (view full) --- 1578 return; 1579 } 1580 1581 list_del_init(&dl->al.node); 1582 disasm_line__free(dl); 1583 } 1584} 1585 | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2011, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com> 4 * 5 * Parts came from builtin-annotate.c, see those files for further 6 * copyright notes. 7 */ 8 --- 1569 unchanged lines hidden (view full) --- 1578 return; 1579 } 1580 1581 list_del_init(&dl->al.node); 1582 disasm_line__free(dl); 1583 } 1584} 1585 |
1586int symbol__strerror_disassemble(struct symbol *sym __maybe_unused, struct map *map, 1587 int errnum, char *buf, size_t buflen) | 1586int symbol__strerror_disassemble(struct map_symbol *ms, int errnum, char *buf, size_t buflen) |
1588{ | 1587{ |
1589 struct dso *dso = map->dso; | 1588 struct dso *dso = ms->map->dso; |
1590 1591 BUG_ON(buflen == 0); 1592 1593 if (errnum >= 0) { 1594 str_error_r(errnum, buf, buflen); 1595 return 0; 1596 } 1597 --- 540 unchanged lines hidden (view full) --- 2138 2139void symbol__calc_percent(struct symbol *sym, struct evsel *evsel) 2140{ 2141 struct annotation *notes = symbol__annotation(sym); 2142 2143 annotation__calc_percent(notes, evsel, symbol__size(sym)); 2144} 2145 | 1589 1590 BUG_ON(buflen == 0); 1591 1592 if (errnum >= 0) { 1593 str_error_r(errnum, buf, buflen); 1594 return 0; 1595 } 1596 --- 540 unchanged lines hidden (view full) --- 2137 2138void symbol__calc_percent(struct symbol *sym, struct evsel *evsel) 2139{ 2140 struct annotation *notes = symbol__annotation(sym); 2141 2142 annotation__calc_percent(notes, evsel, symbol__size(sym)); 2143} 2144 |
2146int symbol__annotate(struct symbol *sym, struct map *map, 2147 struct evsel *evsel, size_t privsize, 2148 struct annotation_options *options, 2149 struct arch **parch) | 2145int symbol__annotate(struct map_symbol *ms, struct evsel *evsel, size_t privsize, 2146 struct annotation_options *options, struct arch **parch) |
2150{ | 2147{ |
2148 struct symbol *sym = ms->sym; |
|
2151 struct annotation *notes = symbol__annotation(sym); 2152 struct annotate_args args = { 2153 .privsize = privsize, 2154 .evsel = evsel, 2155 .options = options, 2156 }; 2157 struct perf_env *env = perf_evsel__env(evsel); 2158 const char *arch_name = perf_env__arch(env); --- 13 unchanged lines hidden (view full) --- 2172 if (arch->init) { 2173 err = arch->init(arch, env ? env->cpuid : NULL); 2174 if (err) { 2175 pr_err("%s: failed to initialize %s arch priv area\n", __func__, arch->name); 2176 return err; 2177 } 2178 } 2179 | 2149 struct annotation *notes = symbol__annotation(sym); 2150 struct annotate_args args = { 2151 .privsize = privsize, 2152 .evsel = evsel, 2153 .options = options, 2154 }; 2155 struct perf_env *env = perf_evsel__env(evsel); 2156 const char *arch_name = perf_env__arch(env); --- 13 unchanged lines hidden (view full) --- 2170 if (arch->init) { 2171 err = arch->init(arch, env ? env->cpuid : NULL); 2172 if (err) { 2173 pr_err("%s: failed to initialize %s arch priv area\n", __func__, arch->name); 2174 return err; 2175 } 2176 } 2177 |
2180 args.ms.map = map; 2181 args.ms.sym = sym; 2182 notes->start = map__rip_2objdump(map, sym->start); | 2178 args.ms = *ms; 2179 notes->start = map__rip_2objdump(ms->map, sym->start); |
2183 2184 return symbol__disassemble(sym, &args); 2185} 2186 2187static void insert_source_line(struct rb_root *root, struct annotation_line *al, 2188 struct annotation_options *opts) 2189{ 2190 struct annotation_line *iter; --- 139 unchanged lines hidden (view full) --- 2330 list_for_each_entry_reverse(line, lines, node) { 2331 if (line->offset != -1) 2332 return scnprintf(bf, sizeof(bf), "%" PRIx64, start + line->offset); 2333 } 2334 2335 return 0; 2336} 2337 | 2180 2181 return symbol__disassemble(sym, &args); 2182} 2183 2184static void insert_source_line(struct rb_root *root, struct annotation_line *al, 2185 struct annotation_options *opts) 2186{ 2187 struct annotation_line *iter; --- 139 unchanged lines hidden (view full) --- 2327 list_for_each_entry_reverse(line, lines, node) { 2328 if (line->offset != -1) 2329 return scnprintf(bf, sizeof(bf), "%" PRIx64, start + line->offset); 2330 } 2331 2332 return 0; 2333} 2334 |
2338int symbol__annotate_printf(struct symbol *sym, struct map *map, 2339 struct evsel *evsel, | 2335int symbol__annotate_printf(struct map_symbol *ms, struct evsel *evsel, |
2340 struct annotation_options *opts) 2341{ | 2336 struct annotation_options *opts) 2337{ |
2338 struct map *map = ms->map; 2339 struct symbol *sym = ms->sym; |
|
2342 struct dso *dso = map->dso; 2343 char *filename; 2344 const char *d_filename; 2345 const char *evsel_name = perf_evsel__name(evsel); 2346 struct annotation *notes = symbol__annotation(sym); 2347 struct sym_hist *h = annotation__histogram(notes, evsel->idx); 2348 struct annotation_line *pos, *queue = NULL; 2349 u64 start = map__rip_2objdump(map, sym->start); --- 387 unchanged lines hidden (view full) --- 2737 al->path = get_srcline(map->dso, notes->start + al->offset, NULL, 2738 false, true, notes->start + al->offset); 2739 insert_source_line(&tmp_root, al, opts); 2740 } 2741 2742 resort_source_line(root, &tmp_root); 2743} 2744 | 2340 struct dso *dso = map->dso; 2341 char *filename; 2342 const char *d_filename; 2343 const char *evsel_name = perf_evsel__name(evsel); 2344 struct annotation *notes = symbol__annotation(sym); 2345 struct sym_hist *h = annotation__histogram(notes, evsel->idx); 2346 struct annotation_line *pos, *queue = NULL; 2347 u64 start = map__rip_2objdump(map, sym->start); --- 387 unchanged lines hidden (view full) --- 2735 al->path = get_srcline(map->dso, notes->start + al->offset, NULL, 2736 false, true, notes->start + al->offset); 2737 insert_source_line(&tmp_root, al, opts); 2738 } 2739 2740 resort_source_line(root, &tmp_root); 2741} 2742 |
2745static void symbol__calc_lines(struct symbol *sym, struct map *map, 2746 struct rb_root *root, | 2743static void symbol__calc_lines(struct map_symbol *ms, struct rb_root *root, |
2747 struct annotation_options *opts) 2748{ | 2744 struct annotation_options *opts) 2745{ |
2749 struct annotation *notes = symbol__annotation(sym); | 2746 struct annotation *notes = symbol__annotation(ms->sym); |
2750 | 2747 |
2751 annotation__calc_lines(notes, map, root, opts); | 2748 annotation__calc_lines(notes, ms->map, root, opts); |
2752} 2753 | 2749} 2750 |
2754int symbol__tty_annotate2(struct symbol *sym, struct map *map, 2755 struct evsel *evsel, | 2751int symbol__tty_annotate2(struct map_symbol *ms, struct evsel *evsel, |
2756 struct annotation_options *opts) 2757{ | 2752 struct annotation_options *opts) 2753{ |
2758 struct dso *dso = map->dso; | 2754 struct dso *dso = ms->map->dso; 2755 struct symbol *sym = ms->sym; |
2759 struct rb_root source_line = RB_ROOT; 2760 struct hists *hists = evsel__hists(evsel); 2761 char buf[1024]; 2762 | 2756 struct rb_root source_line = RB_ROOT; 2757 struct hists *hists = evsel__hists(evsel); 2758 char buf[1024]; 2759 |
2763 if (symbol__annotate2(sym, map, evsel, opts, NULL) < 0) | 2760 if (symbol__annotate2(ms, evsel, opts, NULL) < 0) |
2764 return -1; 2765 2766 if (opts->print_lines) { 2767 srcline_full_filename = opts->full_path; | 2761 return -1; 2762 2763 if (opts->print_lines) { 2764 srcline_full_filename = opts->full_path; |
2768 symbol__calc_lines(sym, map, &source_line, opts); | 2765 symbol__calc_lines(ms, &source_line, opts); |
2769 print_summary(&source_line, dso->long_name); 2770 } 2771 2772 hists__scnprintf_title(hists, buf, sizeof(buf)); 2773 fprintf(stdout, "%s, [percent: %s]\n%s() %s\n", 2774 buf, percent_type_str(opts->percent_type), sym->name, dso->long_name); 2775 symbol__annotate_fprintf2(sym, stdout, opts); 2776 2777 annotated_source__purge(symbol__annotation(sym)->src); 2778 2779 return 0; 2780} 2781 | 2766 print_summary(&source_line, dso->long_name); 2767 } 2768 2769 hists__scnprintf_title(hists, buf, sizeof(buf)); 2770 fprintf(stdout, "%s, [percent: %s]\n%s() %s\n", 2771 buf, percent_type_str(opts->percent_type), sym->name, dso->long_name); 2772 symbol__annotate_fprintf2(sym, stdout, opts); 2773 2774 annotated_source__purge(symbol__annotation(sym)->src); 2775 2776 return 0; 2777} 2778 |
2782int symbol__tty_annotate(struct symbol *sym, struct map *map, 2783 struct evsel *evsel, | 2779int symbol__tty_annotate(struct map_symbol *ms, struct evsel *evsel, |
2784 struct annotation_options *opts) 2785{ | 2780 struct annotation_options *opts) 2781{ |
2786 struct dso *dso = map->dso; | 2782 struct dso *dso = ms->map->dso; 2783 struct symbol *sym = ms->sym; |
2787 struct rb_root source_line = RB_ROOT; 2788 | 2784 struct rb_root source_line = RB_ROOT; 2785 |
2789 if (symbol__annotate(sym, map, evsel, 0, opts, NULL) < 0) | 2786 if (symbol__annotate(ms, evsel, 0, opts, NULL) < 0) |
2790 return -1; 2791 2792 symbol__calc_percent(sym, evsel); 2793 2794 if (opts->print_lines) { 2795 srcline_full_filename = opts->full_path; | 2787 return -1; 2788 2789 symbol__calc_percent(sym, evsel); 2790 2791 if (opts->print_lines) { 2792 srcline_full_filename = opts->full_path; |
2796 symbol__calc_lines(sym, map, &source_line, opts); | 2793 symbol__calc_lines(ms, &source_line, opts); |
2797 print_summary(&source_line, dso->long_name); 2798 } 2799 | 2794 print_summary(&source_line, dso->long_name); 2795 } 2796 |
2800 symbol__annotate_printf(sym, map, evsel, opts); | 2797 symbol__annotate_printf(ms, evsel, opts); |
2801 2802 annotated_source__purge(symbol__annotation(sym)->src); 2803 2804 return 0; 2805} 2806 2807bool ui__has_annotation(void) 2808{ --- 237 unchanged lines hidden (view full) --- 3046 __annotation_line__write(al, notes, wops->first_line, wops->current_entry, 3047 wops->change_color, wops->width, wops->obj, 3048 opts->percent_type, 3049 wops->set_color, wops->set_percent_color, 3050 wops->set_jumps_percent_color, wops->printf, 3051 wops->write_graph); 3052} 3053 | 2798 2799 annotated_source__purge(symbol__annotation(sym)->src); 2800 2801 return 0; 2802} 2803 2804bool ui__has_annotation(void) 2805{ --- 237 unchanged lines hidden (view full) --- 3043 __annotation_line__write(al, notes, wops->first_line, wops->current_entry, 3044 wops->change_color, wops->width, wops->obj, 3045 opts->percent_type, 3046 wops->set_color, wops->set_percent_color, 3047 wops->set_jumps_percent_color, wops->printf, 3048 wops->write_graph); 3049} 3050 |
3054int symbol__annotate2(struct symbol *sym, struct map *map, struct evsel *evsel, | 3051int symbol__annotate2(struct map_symbol *ms, struct evsel *evsel, |
3055 struct annotation_options *options, struct arch **parch) 3056{ | 3052 struct annotation_options *options, struct arch **parch) 3053{ |
3054 struct symbol *sym = ms->sym; |
|
3057 struct annotation *notes = symbol__annotation(sym); 3058 size_t size = symbol__size(sym); 3059 int nr_pcnt = 1, err; 3060 3061 notes->offsets = zalloc(size * sizeof(struct annotation_line *)); 3062 if (notes->offsets == NULL) 3063 return ENOMEM; 3064 3065 if (perf_evsel__is_group_event(evsel)) 3066 nr_pcnt = evsel->core.nr_members; 3067 | 3055 struct annotation *notes = symbol__annotation(sym); 3056 size_t size = symbol__size(sym); 3057 int nr_pcnt = 1, err; 3058 3059 notes->offsets = zalloc(size * sizeof(struct annotation_line *)); 3060 if (notes->offsets == NULL) 3061 return ENOMEM; 3062 3063 if (perf_evsel__is_group_event(evsel)) 3064 nr_pcnt = evsel->core.nr_members; 3065 |
3068 err = symbol__annotate(sym, map, evsel, 0, options, parch); | 3066 err = symbol__annotate(ms, evsel, 0, options, parch); |
3069 if (err) 3070 goto out_free_offsets; 3071 3072 notes->options = options; 3073 3074 symbol__calc_percent(sym, evsel); 3075 3076 annotation__set_offsets(notes, size); --- 131 unchanged lines hidden --- | 3067 if (err) 3068 goto out_free_offsets; 3069 3070 notes->options = options; 3071 3072 symbol__calc_percent(sym, evsel); 3073 3074 annotation__set_offsets(notes, size); --- 131 unchanged lines hidden --- |