aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui/browsers
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/ui/browsers')
-rw-r--r--tools/perf/ui/browsers/annotate.c24
-rw-r--r--tools/perf/ui/browsers/hists.c23
-rw-r--r--tools/perf/ui/browsers/map.c40
-rw-r--r--tools/perf/ui/browsers/map.h2
-rw-r--r--tools/perf/ui/browsers/scripts.c8
5 files changed, 49 insertions, 48 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 08545ae46992..f0697a3aede0 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -442,35 +442,37 @@ static bool annotate_browser__callq(struct annotate_browser *browser,
442{ 442{
443 struct map_symbol *ms = browser->b.priv; 443 struct map_symbol *ms = browser->b.priv;
444 struct disasm_line *dl = browser->selection; 444 struct disasm_line *dl = browser->selection;
445 struct symbol *sym = ms->sym;
446 struct annotation *notes; 445 struct annotation *notes;
447 struct symbol *target; 446 struct addr_map_symbol target = {
448 u64 ip; 447 .map = ms->map,
448 .addr = map__objdump_2mem(ms->map, dl->ops.target.addr),
449 };
449 char title[SYM_TITLE_MAX_SIZE]; 450 char title[SYM_TITLE_MAX_SIZE];
450 451
451 if (!ins__is_call(dl->ins)) 452 if (!ins__is_call(dl->ins))
452 return false; 453 return false;
453 454
454 ip = ms->map->map_ip(ms->map, dl->ops.target.addr); 455 if (map_groups__find_ams(&target, NULL) ||
455 target = map__find_symbol(ms->map, ip, NULL); 456 map__rip_2objdump(target.map, target.map->map_ip(target.map,
456 if (target == NULL) { 457 target.addr)) !=
458 dl->ops.target.addr) {
457 ui_helpline__puts("The called function was not found."); 459 ui_helpline__puts("The called function was not found.");
458 return true; 460 return true;
459 } 461 }
460 462
461 notes = symbol__annotation(target); 463 notes = symbol__annotation(target.sym);
462 pthread_mutex_lock(&notes->lock); 464 pthread_mutex_lock(&notes->lock);
463 465
464 if (notes->src == NULL && symbol__alloc_hist(target) < 0) { 466 if (notes->src == NULL && symbol__alloc_hist(target.sym) < 0) {
465 pthread_mutex_unlock(&notes->lock); 467 pthread_mutex_unlock(&notes->lock);
466 ui__warning("Not enough memory for annotating '%s' symbol!\n", 468 ui__warning("Not enough memory for annotating '%s' symbol!\n",
467 target->name); 469 target.sym->name);
468 return true; 470 return true;
469 } 471 }
470 472
471 pthread_mutex_unlock(&notes->lock); 473 pthread_mutex_unlock(&notes->lock);
472 symbol__tui_annotate(target, ms->map, evsel, hbt); 474 symbol__tui_annotate(target.sym, target.map, evsel, hbt);
473 sym_title(sym, ms->map, title, sizeof(title)); 475 sym_title(ms->sym, ms->map, title, sizeof(title));
474 ui_browser__show_title(&browser->b, title); 476 ui_browser__show_title(&browser->b, title);
475 return true; 477 return true;
476} 478}
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 7ef36c360471..a440e03cd8c2 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -1255,7 +1255,7 @@ static int hists__browser_title(struct hists *hists, char *bf, size_t size,
1255 if (thread) 1255 if (thread)
1256 printed += scnprintf(bf + printed, size - printed, 1256 printed += scnprintf(bf + printed, size - printed,
1257 ", Thread: %s(%d)", 1257 ", Thread: %s(%d)",
1258 (thread->comm_set ? thread->comm : ""), 1258 (thread->comm_set ? thread__comm_str(thread) : ""),
1259 thread->tid); 1259 thread->tid);
1260 if (dso) 1260 if (dso)
1261 printed += scnprintf(bf + printed, size - printed, 1261 printed += scnprintf(bf + printed, size - printed,
@@ -1578,7 +1578,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
1578 if (thread != NULL && 1578 if (thread != NULL &&
1579 asprintf(&options[nr_options], "Zoom %s %s(%d) thread", 1579 asprintf(&options[nr_options], "Zoom %s %s(%d) thread",
1580 (browser->hists->thread_filter ? "out of" : "into"), 1580 (browser->hists->thread_filter ? "out of" : "into"),
1581 (thread->comm_set ? thread->comm : ""), 1581 (thread->comm_set ? thread__comm_str(thread) : ""),
1582 thread->tid) > 0) 1582 thread->tid) > 0)
1583 zoom_thread = nr_options++; 1583 zoom_thread = nr_options++;
1584 1584
@@ -1598,7 +1598,7 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events,
1598 struct symbol *sym; 1598 struct symbol *sym;
1599 1599
1600 if (asprintf(&options[nr_options], "Run scripts for samples of thread [%s]", 1600 if (asprintf(&options[nr_options], "Run scripts for samples of thread [%s]",
1601 browser->he_selection->thread->comm) > 0) 1601 thread__comm_str(browser->he_selection->thread)) > 0)
1602 scripts_comm = nr_options++; 1602 scripts_comm = nr_options++;
1603 1603
1604 sym = browser->he_selection->ms.sym; 1604 sym = browser->he_selection->ms.sym;
@@ -1701,7 +1701,7 @@ zoom_out_thread:
1701 sort_thread.elide = false; 1701 sort_thread.elide = false;
1702 } else { 1702 } else {
1703 ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s(%d) thread\"", 1703 ui_helpline__fpush("To zoom out press <- or -> + \"Zoom out of %s(%d) thread\"",
1704 thread->comm_set ? thread->comm : "", 1704 thread->comm_set ? thread__comm_str(thread) : "",
1705 thread->tid); 1705 thread->tid);
1706 browser->hists->thread_filter = thread; 1706 browser->hists->thread_filter = thread;
1707 sort_thread.elide = true; 1707 sort_thread.elide = true;
@@ -1717,7 +1717,7 @@ do_scripts:
1717 memset(script_opt, 0, 64); 1717 memset(script_opt, 0, 64);
1718 1718
1719 if (choice == scripts_comm) 1719 if (choice == scripts_comm)
1720 sprintf(script_opt, " -c %s ", browser->he_selection->thread->comm); 1720 sprintf(script_opt, " -c %s ", thread__comm_str(browser->he_selection->thread));
1721 1721
1722 if (choice == scripts_symbol) 1722 if (choice == scripts_symbol)
1723 sprintf(script_opt, " -S %s ", browser->he_selection->ms.sym->name); 1723 sprintf(script_opt, " -S %s ", browser->he_selection->ms.sym->name);
@@ -1847,15 +1847,15 @@ browse_hists:
1847 switch (key) { 1847 switch (key) {
1848 case K_TAB: 1848 case K_TAB:
1849 if (pos->node.next == &evlist->entries) 1849 if (pos->node.next == &evlist->entries)
1850 pos = list_entry(evlist->entries.next, struct perf_evsel, node); 1850 pos = perf_evlist__first(evlist);
1851 else 1851 else
1852 pos = list_entry(pos->node.next, struct perf_evsel, node); 1852 pos = perf_evsel__next(pos);
1853 goto browse_hists; 1853 goto browse_hists;
1854 case K_UNTAB: 1854 case K_UNTAB:
1855 if (pos->node.prev == &evlist->entries) 1855 if (pos->node.prev == &evlist->entries)
1856 pos = list_entry(evlist->entries.prev, struct perf_evsel, node); 1856 pos = perf_evlist__last(evlist);
1857 else 1857 else
1858 pos = list_entry(pos->node.prev, struct perf_evsel, node); 1858 pos = perf_evsel__prev(pos);
1859 goto browse_hists; 1859 goto browse_hists;
1860 case K_ESC: 1860 case K_ESC:
1861 if (!ui_browser__dialog_yesno(&menu->b, 1861 if (!ui_browser__dialog_yesno(&menu->b,
@@ -1889,7 +1889,7 @@ out:
1889 return key; 1889 return key;
1890} 1890}
1891 1891
1892static bool filter_group_entries(struct ui_browser *self __maybe_unused, 1892static bool filter_group_entries(struct ui_browser *browser __maybe_unused,
1893 void *entry) 1893 void *entry)
1894{ 1894{
1895 struct perf_evsel *evsel = list_entry(entry, struct perf_evsel, node); 1895 struct perf_evsel *evsel = list_entry(entry, struct perf_evsel, node);
@@ -1943,8 +1943,7 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help,
1943 1943
1944single_entry: 1944single_entry:
1945 if (nr_entries == 1) { 1945 if (nr_entries == 1) {
1946 struct perf_evsel *first = list_entry(evlist->entries.next, 1946 struct perf_evsel *first = perf_evlist__first(evlist);
1947 struct perf_evsel, node);
1948 const char *ev_name = perf_evsel__name(first); 1947 const char *ev_name = perf_evsel__name(first);
1949 1948
1950 return perf_evsel__hists_browse(first, nr_entries, help, 1949 return perf_evsel__hists_browse(first, nr_entries, help,
diff --git a/tools/perf/ui/browsers/map.c b/tools/perf/ui/browsers/map.c
index 95c7cfb8f2c6..b11639f33682 100644
--- a/tools/perf/ui/browsers/map.c
+++ b/tools/perf/ui/browsers/map.c
@@ -18,30 +18,30 @@ struct map_browser {
18 u8 addrlen; 18 u8 addrlen;
19}; 19};
20 20
21static void map_browser__write(struct ui_browser *self, void *nd, int row) 21static void map_browser__write(struct ui_browser *browser, void *nd, int row)
22{ 22{
23 struct symbol *sym = rb_entry(nd, struct symbol, rb_node); 23 struct symbol *sym = rb_entry(nd, struct symbol, rb_node);
24 struct map_browser *mb = container_of(self, struct map_browser, b); 24 struct map_browser *mb = container_of(browser, struct map_browser, b);
25 bool current_entry = ui_browser__is_current_entry(self, row); 25 bool current_entry = ui_browser__is_current_entry(browser, row);
26 int width; 26 int width;
27 27
28 ui_browser__set_percent_color(self, 0, current_entry); 28 ui_browser__set_percent_color(browser, 0, current_entry);
29 slsmg_printf("%*" PRIx64 " %*" PRIx64 " %c ", 29 slsmg_printf("%*" PRIx64 " %*" PRIx64 " %c ",
30 mb->addrlen, sym->start, mb->addrlen, sym->end, 30 mb->addrlen, sym->start, mb->addrlen, sym->end,
31 sym->binding == STB_GLOBAL ? 'g' : 31 sym->binding == STB_GLOBAL ? 'g' :
32 sym->binding == STB_LOCAL ? 'l' : 'w'); 32 sym->binding == STB_LOCAL ? 'l' : 'w');
33 width = self->width - ((mb->addrlen * 2) + 4); 33 width = browser->width - ((mb->addrlen * 2) + 4);
34 if (width > 0) 34 if (width > 0)
35 slsmg_write_nstring(sym->name, width); 35 slsmg_write_nstring(sym->name, width);
36} 36}
37 37
38/* FIXME uber-kludgy, see comment on cmd_report... */ 38/* FIXME uber-kludgy, see comment on cmd_report... */
39static u32 *symbol__browser_index(struct symbol *self) 39static u32 *symbol__browser_index(struct symbol *browser)
40{ 40{
41 return ((void *)self) - sizeof(struct rb_node) - sizeof(u32); 41 return ((void *)browser) - sizeof(struct rb_node) - sizeof(u32);
42} 42}
43 43
44static int map_browser__search(struct map_browser *self) 44static int map_browser__search(struct map_browser *browser)
45{ 45{
46 char target[512]; 46 char target[512];
47 struct symbol *sym; 47 struct symbol *sym;
@@ -53,37 +53,37 @@ static int map_browser__search(struct map_browser *self)
53 53
54 if (target[0] == '0' && tolower(target[1]) == 'x') { 54 if (target[0] == '0' && tolower(target[1]) == 'x') {
55 u64 addr = strtoull(target, NULL, 16); 55 u64 addr = strtoull(target, NULL, 16);
56 sym = map__find_symbol(self->map, addr, NULL); 56 sym = map__find_symbol(browser->map, addr, NULL);
57 } else 57 } else
58 sym = map__find_symbol_by_name(self->map, target, NULL); 58 sym = map__find_symbol_by_name(browser->map, target, NULL);
59 59
60 if (sym != NULL) { 60 if (sym != NULL) {
61 u32 *idx = symbol__browser_index(sym); 61 u32 *idx = symbol__browser_index(sym);
62 62
63 self->b.top = &sym->rb_node; 63 browser->b.top = &sym->rb_node;
64 self->b.index = self->b.top_idx = *idx; 64 browser->b.index = browser->b.top_idx = *idx;
65 } else 65 } else
66 ui_helpline__fpush("%s not found!", target); 66 ui_helpline__fpush("%s not found!", target);
67 67
68 return 0; 68 return 0;
69} 69}
70 70
71static int map_browser__run(struct map_browser *self) 71static int map_browser__run(struct map_browser *browser)
72{ 72{
73 int key; 73 int key;
74 74
75 if (ui_browser__show(&self->b, self->map->dso->long_name, 75 if (ui_browser__show(&browser->b, browser->map->dso->long_name,
76 "Press <- or ESC to exit, %s / to search", 76 "Press <- or ESC to exit, %s / to search",
77 verbose ? "" : "restart with -v to use") < 0) 77 verbose ? "" : "restart with -v to use") < 0)
78 return -1; 78 return -1;
79 79
80 while (1) { 80 while (1) {
81 key = ui_browser__run(&self->b, 0); 81 key = ui_browser__run(&browser->b, 0);
82 82
83 switch (key) { 83 switch (key) {
84 case '/': 84 case '/':
85 if (verbose) 85 if (verbose)
86 map_browser__search(self); 86 map_browser__search(browser);
87 default: 87 default:
88 break; 88 break;
89 case K_LEFT: 89 case K_LEFT:
@@ -94,20 +94,20 @@ static int map_browser__run(struct map_browser *self)
94 } 94 }
95 } 95 }
96out: 96out:
97 ui_browser__hide(&self->b); 97 ui_browser__hide(&browser->b);
98 return key; 98 return key;
99} 99}
100 100
101int map__browse(struct map *self) 101int map__browse(struct map *map)
102{ 102{
103 struct map_browser mb = { 103 struct map_browser mb = {
104 .b = { 104 .b = {
105 .entries = &self->dso->symbols[self->type], 105 .entries = &map->dso->symbols[map->type],
106 .refresh = ui_browser__rb_tree_refresh, 106 .refresh = ui_browser__rb_tree_refresh,
107 .seek = ui_browser__rb_tree_seek, 107 .seek = ui_browser__rb_tree_seek,
108 .write = map_browser__write, 108 .write = map_browser__write,
109 }, 109 },
110 .map = self, 110 .map = map,
111 }; 111 };
112 struct rb_node *nd; 112 struct rb_node *nd;
113 char tmp[BITS_PER_LONG / 4]; 113 char tmp[BITS_PER_LONG / 4];
diff --git a/tools/perf/ui/browsers/map.h b/tools/perf/ui/browsers/map.h
index df8581a43e17..2d58e4b3eb6f 100644
--- a/tools/perf/ui/browsers/map.h
+++ b/tools/perf/ui/browsers/map.h
@@ -2,5 +2,5 @@
2#define _PERF_UI_MAP_BROWSER_H_ 1 2#define _PERF_UI_MAP_BROWSER_H_ 1
3struct map; 3struct map;
4 4
5int map__browse(struct map *self); 5int map__browse(struct map *map);
6#endif /* _PERF_UI_MAP_BROWSER_H_ */ 6#endif /* _PERF_UI_MAP_BROWSER_H_ */
diff --git a/tools/perf/ui/browsers/scripts.c b/tools/perf/ui/browsers/scripts.c
index 12f009e61e94..d63c68ea02a8 100644
--- a/tools/perf/ui/browsers/scripts.c
+++ b/tools/perf/ui/browsers/scripts.c
@@ -84,22 +84,22 @@ static void script_browser__write(struct ui_browser *browser,
84 slsmg_write_nstring(sline->line, browser->width); 84 slsmg_write_nstring(sline->line, browser->width);
85} 85}
86 86
87static int script_browser__run(struct perf_script_browser *self) 87static int script_browser__run(struct perf_script_browser *browser)
88{ 88{
89 int key; 89 int key;
90 90
91 if (ui_browser__show(&self->b, self->script_name, 91 if (ui_browser__show(&browser->b, browser->script_name,
92 "Press <- or ESC to exit") < 0) 92 "Press <- or ESC to exit") < 0)
93 return -1; 93 return -1;
94 94
95 while (1) { 95 while (1) {
96 key = ui_browser__run(&self->b, 0); 96 key = ui_browser__run(&browser->b, 0);
97 97
98 /* We can add some special key handling here if needed */ 98 /* We can add some special key handling here if needed */
99 break; 99 break;
100 } 100 }
101 101
102 ui_browser__hide(&self->b); 102 ui_browser__hide(&browser->b);
103 return key; 103 return key;
104} 104}
105 105