annotate.c (728d90bdc9e480dc93913e59a0aa3c896c7aa697) | annotate.c (2975489458c59ce2e348b1b3aef5d8d2acb5cc8d) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2#include "../browser.h" 3#include "../helpline.h" 4#include "../ui.h" 5#include "../../util/annotate.h" 6#include "../../util/debug.h" 7#include "../../util/dso.h" 8#include "../../util/hist.h" --- 396 unchanged lines hidden (view full) --- 405 * So all we check here is that dl->ops.target.sym is set, if it is, just 406 * go to that function and when exiting from its disassembly, come back 407 * to the calling function. 408 */ 409static bool annotate_browser__callq(struct annotate_browser *browser, 410 struct evsel *evsel, 411 struct hist_browser_timer *hbt) 412{ | 1// SPDX-License-Identifier: GPL-2.0 2#include "../browser.h" 3#include "../helpline.h" 4#include "../ui.h" 5#include "../../util/annotate.h" 6#include "../../util/debug.h" 7#include "../../util/dso.h" 8#include "../../util/hist.h" --- 396 unchanged lines hidden (view full) --- 405 * So all we check here is that dl->ops.target.sym is set, if it is, just 406 * go to that function and when exiting from its disassembly, come back 407 * to the calling function. 408 */ 409static bool annotate_browser__callq(struct annotate_browser *browser, 410 struct evsel *evsel, 411 struct hist_browser_timer *hbt) 412{ |
413 struct map_symbol *ms = browser->b.priv; | 413 struct map_symbol *ms = browser->b.priv, target_ms; |
414 struct disasm_line *dl = disasm_line(browser->selection); 415 struct annotation *notes; 416 char title[SYM_TITLE_MAX_SIZE]; 417 418 if (!dl->ops.target.sym) { 419 ui_helpline__puts("The called function was not found."); 420 return true; 421 } 422 423 notes = symbol__annotation(dl->ops.target.sym); 424 pthread_mutex_lock(¬es->lock); 425 426 if (!symbol__hists(dl->ops.target.sym, evsel->evlist->core.nr_entries)) { 427 pthread_mutex_unlock(¬es->lock); 428 ui__warning("Not enough memory for annotating '%s' symbol!\n", 429 dl->ops.target.sym->name); 430 return true; 431 } 432 | 414 struct disasm_line *dl = disasm_line(browser->selection); 415 struct annotation *notes; 416 char title[SYM_TITLE_MAX_SIZE]; 417 418 if (!dl->ops.target.sym) { 419 ui_helpline__puts("The called function was not found."); 420 return true; 421 } 422 423 notes = symbol__annotation(dl->ops.target.sym); 424 pthread_mutex_lock(¬es->lock); 425 426 if (!symbol__hists(dl->ops.target.sym, evsel->evlist->core.nr_entries)) { 427 pthread_mutex_unlock(¬es->lock); 428 ui__warning("Not enough memory for annotating '%s' symbol!\n", 429 dl->ops.target.sym->name); 430 return true; 431 } 432 |
433 target_ms.map = ms->map; 434 target_ms.sym = dl->ops.target.sym; |
|
433 pthread_mutex_unlock(¬es->lock); | 435 pthread_mutex_unlock(¬es->lock); |
434 symbol__tui_annotate(dl->ops.target.sym, ms->map, evsel, hbt, browser->opts); | 436 symbol__tui_annotate(&target_ms, evsel, hbt, browser->opts); |
435 sym_title(ms->sym, ms->map, title, sizeof(title), browser->opts->percent_type); 436 ui_browser__show_title(&browser->b, title); 437 return true; 438} 439 440static 441struct disasm_line *annotate_browser__find_offset(struct annotate_browser *browser, 442 s64 offset, s64 *idx) --- 426 unchanged lines hidden (view full) --- 869 ui_browser__hide(&browser->b); 870 return key; 871} 872 873int map_symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel, 874 struct hist_browser_timer *hbt, 875 struct annotation_options *opts) 876{ | 437 sym_title(ms->sym, ms->map, title, sizeof(title), browser->opts->percent_type); 438 ui_browser__show_title(&browser->b, title); 439 return true; 440} 441 442static 443struct disasm_line *annotate_browser__find_offset(struct annotate_browser *browser, 444 s64 offset, s64 *idx) --- 426 unchanged lines hidden (view full) --- 871 ui_browser__hide(&browser->b); 872 return key; 873} 874 875int map_symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel, 876 struct hist_browser_timer *hbt, 877 struct annotation_options *opts) 878{ |
877 return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt, opts); | 879 return symbol__tui_annotate(ms, evsel, hbt, opts); |
878} 879 880int hist_entry__tui_annotate(struct hist_entry *he, struct evsel *evsel, 881 struct hist_browser_timer *hbt, 882 struct annotation_options *opts) 883{ 884 /* reset abort key so that it can get Ctrl-C as a key */ 885 SLang_reset_tty(); 886 SLang_init_tty(0, 0, 0); 887 888 return map_symbol__tui_annotate(&he->ms, evsel, hbt, opts); 889} 890 | 880} 881 882int hist_entry__tui_annotate(struct hist_entry *he, struct evsel *evsel, 883 struct hist_browser_timer *hbt, 884 struct annotation_options *opts) 885{ 886 /* reset abort key so that it can get Ctrl-C as a key */ 887 SLang_reset_tty(); 888 SLang_init_tty(0, 0, 0); 889 890 return map_symbol__tui_annotate(&he->ms, evsel, hbt, opts); 891} 892 |
891int symbol__tui_annotate(struct symbol *sym, struct map *map, 892 struct evsel *evsel, | 893int symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel, |
893 struct hist_browser_timer *hbt, 894 struct annotation_options *opts) 895{ | 894 struct hist_browser_timer *hbt, 895 struct annotation_options *opts) 896{ |
897 struct symbol *sym = ms->sym; |
|
896 struct annotation *notes = symbol__annotation(sym); | 898 struct annotation *notes = symbol__annotation(sym); |
897 struct map_symbol ms = { 898 .map = map, 899 .sym = sym, 900 }; | |
901 struct annotate_browser browser = { 902 .b = { 903 .refresh = annotate_browser__refresh, 904 .seek = ui_browser__list_head_seek, 905 .write = annotate_browser__write, 906 .filter = disasm_line__filter, 907 .extra_title_lines = 1, /* for hists__scnprintf_title() */ | 899 struct annotate_browser browser = { 900 .b = { 901 .refresh = annotate_browser__refresh, 902 .seek = ui_browser__list_head_seek, 903 .write = annotate_browser__write, 904 .filter = disasm_line__filter, 905 .extra_title_lines = 1, /* for hists__scnprintf_title() */ |
908 .priv = &ms, | 906 .priv = ms, |
909 .use_navkeypressed = true, 910 }, 911 .opts = opts, 912 }; 913 int ret = -1, err; 914 915 if (sym == NULL) 916 return -1; 917 | 907 .use_navkeypressed = true, 908 }, 909 .opts = opts, 910 }; 911 int ret = -1, err; 912 913 if (sym == NULL) 914 return -1; 915 |
918 if (map->dso->annotate_warned) | 916 if (ms->map->dso->annotate_warned) |
919 return -1; 920 | 917 return -1; 918 |
921 err = symbol__annotate2(sym, map, evsel, opts, &browser.arch); | 919 err = symbol__annotate2(ms, evsel, opts, &browser.arch); |
922 if (err) { 923 char msg[BUFSIZ]; | 920 if (err) { 921 char msg[BUFSIZ]; |
924 symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg)); | 922 symbol__strerror_disassemble(ms, err, msg, sizeof(msg)); |
925 ui__error("Couldn't annotate %s:\n%s", sym->name, msg); 926 goto out_free_offsets; 927 } 928 929 ui_helpline__push("Press ESC to exit"); 930 931 browser.b.width = notes->max_line_len; 932 browser.b.nr_entries = notes->nr_entries; --- 14 unchanged lines hidden --- | 923 ui__error("Couldn't annotate %s:\n%s", sym->name, msg); 924 goto out_free_offsets; 925 } 926 927 ui_helpline__push("Press ESC to exit"); 928 929 browser.b.width = notes->max_line_len; 930 browser.b.nr_entries = notes->nr_entries; --- 14 unchanged lines hidden --- |