Commit fc8ed7be738ffb1b3b0140ed2de6def38b9a7101

Authored by Arnaldo Carvalho de Melo
1 parent 981c125269

perf top browser: Remove spurious helpline update

It will be immediately replaced in perf_top_browser__run.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-q7e2jzb44elqpkvdllk94x0i@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Showing 1 changed file with 0 additions and 1 deletions Inline Diff

tools/perf/util/ui/browsers/top.c
1 /* 1 /*
2 * Copyright (C) 2011, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com> 2 * Copyright (C) 2011, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
3 * 3 *
4 * Parts came from builtin-{top,stat,record}.c, see those files for further 4 * Parts came from builtin-{top,stat,record}.c, see those files for further
5 * copyright notes. 5 * copyright notes.
6 * 6 *
7 * Released under the GPL v2. (and only v2, not any later version) 7 * Released under the GPL v2. (and only v2, not any later version)
8 */ 8 */
9 #include "../browser.h" 9 #include "../browser.h"
10 #include "../../annotate.h" 10 #include "../../annotate.h"
11 #include "../helpline.h" 11 #include "../helpline.h"
12 #include "../libslang.h" 12 #include "../libslang.h"
13 #include "../util.h" 13 #include "../util.h"
14 #include "../../evlist.h" 14 #include "../../evlist.h"
15 #include "../../hist.h" 15 #include "../../hist.h"
16 #include "../../sort.h" 16 #include "../../sort.h"
17 #include "../../symbol.h" 17 #include "../../symbol.h"
18 #include "../../top.h" 18 #include "../../top.h"
19 19
20 struct perf_top_browser { 20 struct perf_top_browser {
21 struct ui_browser b; 21 struct ui_browser b;
22 struct rb_root root; 22 struct rb_root root;
23 struct sym_entry *selection; 23 struct sym_entry *selection;
24 float sum_ksamples; 24 float sum_ksamples;
25 int dso_width; 25 int dso_width;
26 int dso_short_width; 26 int dso_short_width;
27 int sym_width; 27 int sym_width;
28 }; 28 };
29 29
30 static void perf_top_browser__write(struct ui_browser *browser, void *entry, int row) 30 static void perf_top_browser__write(struct ui_browser *browser, void *entry, int row)
31 { 31 {
32 struct perf_top_browser *top_browser = container_of(browser, struct perf_top_browser, b); 32 struct perf_top_browser *top_browser = container_of(browser, struct perf_top_browser, b);
33 struct sym_entry *syme = rb_entry(entry, struct sym_entry, rb_node); 33 struct sym_entry *syme = rb_entry(entry, struct sym_entry, rb_node);
34 bool current_entry = ui_browser__is_current_entry(browser, row); 34 bool current_entry = ui_browser__is_current_entry(browser, row);
35 struct symbol *symbol = sym_entry__symbol(syme); 35 struct symbol *symbol = sym_entry__symbol(syme);
36 struct perf_top *top = browser->priv; 36 struct perf_top *top = browser->priv;
37 int width = browser->width; 37 int width = browser->width;
38 double pcnt; 38 double pcnt;
39 39
40 pcnt = 100.0 - (100.0 * ((top_browser->sum_ksamples - syme->snap_count) / 40 pcnt = 100.0 - (100.0 * ((top_browser->sum_ksamples - syme->snap_count) /
41 top_browser->sum_ksamples)); 41 top_browser->sum_ksamples));
42 ui_browser__set_percent_color(browser, pcnt, current_entry); 42 ui_browser__set_percent_color(browser, pcnt, current_entry);
43 43
44 if (top->evlist->nr_entries == 1 || !top->display_weighted) { 44 if (top->evlist->nr_entries == 1 || !top->display_weighted) {
45 slsmg_printf("%20.2f ", syme->weight); 45 slsmg_printf("%20.2f ", syme->weight);
46 width -= 24; 46 width -= 24;
47 } else { 47 } else {
48 slsmg_printf("%9.1f %10ld ", syme->weight, syme->snap_count); 48 slsmg_printf("%9.1f %10ld ", syme->weight, syme->snap_count);
49 width -= 23; 49 width -= 23;
50 } 50 }
51 51
52 slsmg_printf("%4.1f%%", pcnt); 52 slsmg_printf("%4.1f%%", pcnt);
53 width -= 7; 53 width -= 7;
54 54
55 if (verbose) { 55 if (verbose) {
56 slsmg_printf(" %016" PRIx64, symbol->start); 56 slsmg_printf(" %016" PRIx64, symbol->start);
57 width -= 17; 57 width -= 17;
58 } 58 }
59 59
60 slsmg_printf(" %-*.*s ", top_browser->sym_width, top_browser->sym_width, 60 slsmg_printf(" %-*.*s ", top_browser->sym_width, top_browser->sym_width,
61 symbol->name); 61 symbol->name);
62 width -= top_browser->sym_width; 62 width -= top_browser->sym_width;
63 slsmg_write_nstring(width >= syme->map->dso->long_name_len ? 63 slsmg_write_nstring(width >= syme->map->dso->long_name_len ?
64 syme->map->dso->long_name : 64 syme->map->dso->long_name :
65 syme->map->dso->short_name, width); 65 syme->map->dso->short_name, width);
66 66
67 if (current_entry) 67 if (current_entry)
68 top_browser->selection = syme; 68 top_browser->selection = syme;
69 } 69 }
70 70
71 static void perf_top_browser__update_rb_tree(struct perf_top_browser *browser) 71 static void perf_top_browser__update_rb_tree(struct perf_top_browser *browser)
72 { 72 {
73 struct perf_top *top = browser->b.priv; 73 struct perf_top *top = browser->b.priv;
74 u64 top_idx = browser->b.top_idx; 74 u64 top_idx = browser->b.top_idx;
75 75
76 browser->root = RB_ROOT; 76 browser->root = RB_ROOT;
77 browser->b.top = NULL; 77 browser->b.top = NULL;
78 browser->sum_ksamples = perf_top__decay_samples(top, &browser->root); 78 browser->sum_ksamples = perf_top__decay_samples(top, &browser->root);
79 /* 79 /*
80 * No active symbols 80 * No active symbols
81 */ 81 */
82 if (top->rb_entries == 0) 82 if (top->rb_entries == 0)
83 return; 83 return;
84 84
85 perf_top__find_widths(top, &browser->root, &browser->dso_width, 85 perf_top__find_widths(top, &browser->root, &browser->dso_width,
86 &browser->dso_short_width, 86 &browser->dso_short_width,
87 &browser->sym_width); 87 &browser->sym_width);
88 if (browser->sym_width + browser->dso_width > browser->b.width - 29) { 88 if (browser->sym_width + browser->dso_width > browser->b.width - 29) {
89 browser->dso_width = browser->dso_short_width; 89 browser->dso_width = browser->dso_short_width;
90 if (browser->sym_width + browser->dso_width > browser->b.width - 29) 90 if (browser->sym_width + browser->dso_width > browser->b.width - 29)
91 browser->sym_width = browser->b.width - browser->dso_width - 29; 91 browser->sym_width = browser->b.width - browser->dso_width - 29;
92 } 92 }
93 93
94 /* 94 /*
95 * Adjust the ui_browser indexes since the entries in the browser->root 95 * Adjust the ui_browser indexes since the entries in the browser->root
96 * rb_tree may have changed, then seek it from start, so that we get a 96 * rb_tree may have changed, then seek it from start, so that we get a
97 * possible new top of the screen. 97 * possible new top of the screen.
98 */ 98 */
99 browser->b.nr_entries = top->rb_entries; 99 browser->b.nr_entries = top->rb_entries;
100 100
101 if (top_idx >= browser->b.nr_entries) { 101 if (top_idx >= browser->b.nr_entries) {
102 if (browser->b.height >= browser->b.nr_entries) 102 if (browser->b.height >= browser->b.nr_entries)
103 top_idx = browser->b.nr_entries - browser->b.height; 103 top_idx = browser->b.nr_entries - browser->b.height;
104 else 104 else
105 top_idx = 0; 105 top_idx = 0;
106 } 106 }
107 107
108 if (browser->b.index >= top_idx + browser->b.height) 108 if (browser->b.index >= top_idx + browser->b.height)
109 browser->b.index = top_idx + browser->b.index - browser->b.top_idx; 109 browser->b.index = top_idx + browser->b.index - browser->b.top_idx;
110 110
111 if (browser->b.index >= browser->b.nr_entries) 111 if (browser->b.index >= browser->b.nr_entries)
112 browser->b.index = browser->b.nr_entries - 1; 112 browser->b.index = browser->b.nr_entries - 1;
113 113
114 browser->b.top_idx = top_idx; 114 browser->b.top_idx = top_idx;
115 browser->b.seek(&browser->b, top_idx, SEEK_SET); 115 browser->b.seek(&browser->b, top_idx, SEEK_SET);
116 } 116 }
117 117
118 static void perf_top_browser__annotate(struct perf_top_browser *browser) 118 static void perf_top_browser__annotate(struct perf_top_browser *browser)
119 { 119 {
120 struct sym_entry *syme = browser->selection; 120 struct sym_entry *syme = browser->selection;
121 struct symbol *sym = sym_entry__symbol(syme); 121 struct symbol *sym = sym_entry__symbol(syme);
122 struct annotation *notes = symbol__annotation(sym); 122 struct annotation *notes = symbol__annotation(sym);
123 struct perf_top *top = browser->b.priv; 123 struct perf_top *top = browser->b.priv;
124 124
125 if (notes->src != NULL) 125 if (notes->src != NULL)
126 goto do_annotation; 126 goto do_annotation;
127 127
128 pthread_mutex_lock(&notes->lock); 128 pthread_mutex_lock(&notes->lock);
129 129
130 top->sym_filter_entry = NULL; 130 top->sym_filter_entry = NULL;
131 131
132 if (symbol__alloc_hist(sym, top->evlist->nr_entries) < 0) { 132 if (symbol__alloc_hist(sym, top->evlist->nr_entries) < 0) {
133 pr_err("Not enough memory for annotating '%s' symbol!\n", 133 pr_err("Not enough memory for annotating '%s' symbol!\n",
134 sym->name); 134 sym->name);
135 pthread_mutex_unlock(&notes->lock); 135 pthread_mutex_unlock(&notes->lock);
136 return; 136 return;
137 } 137 }
138 138
139 top->sym_filter_entry = syme; 139 top->sym_filter_entry = syme;
140 140
141 pthread_mutex_unlock(&notes->lock); 141 pthread_mutex_unlock(&notes->lock);
142 do_annotation: 142 do_annotation:
143 symbol__tui_annotate(sym, syme->map, 0, top->delay_secs * 1000); 143 symbol__tui_annotate(sym, syme->map, 0, top->delay_secs * 1000);
144 } 144 }
145 145
146 static int perf_top_browser__run(struct perf_top_browser *browser) 146 static int perf_top_browser__run(struct perf_top_browser *browser)
147 { 147 {
148 int key; 148 int key;
149 char title[160]; 149 char title[160];
150 struct perf_top *top = browser->b.priv; 150 struct perf_top *top = browser->b.priv;
151 int delay_msecs = top->delay_secs * 1000; 151 int delay_msecs = top->delay_secs * 1000;
152 int exit_keys[] = { 'a', NEWT_KEY_ENTER, NEWT_KEY_RIGHT, 0, }; 152 int exit_keys[] = { 'a', NEWT_KEY_ENTER, NEWT_KEY_RIGHT, 0, };
153 153
154 perf_top_browser__update_rb_tree(browser); 154 perf_top_browser__update_rb_tree(browser);
155 perf_top__header_snprintf(top, title, sizeof(title)); 155 perf_top__header_snprintf(top, title, sizeof(title));
156 perf_top__reset_sample_counters(top); 156 perf_top__reset_sample_counters(top);
157 157
158 if (ui_browser__show(&browser->b, title, 158 if (ui_browser__show(&browser->b, title,
159 "ESC: exit, ENTER|->|a: Live Annotate") < 0) 159 "ESC: exit, ENTER|->|a: Live Annotate") < 0)
160 return -1; 160 return -1;
161 161
162 newtFormSetTimer(browser->b.form, delay_msecs); 162 newtFormSetTimer(browser->b.form, delay_msecs);
163 ui_browser__add_exit_keys(&browser->b, exit_keys); 163 ui_browser__add_exit_keys(&browser->b, exit_keys);
164 164
165 while (1) { 165 while (1) {
166 key = ui_browser__run(&browser->b); 166 key = ui_browser__run(&browser->b);
167 167
168 switch (key) { 168 switch (key) {
169 case -1: 169 case -1:
170 /* FIXME we need to check if it was es.reason == NEWT_EXIT_TIMER */ 170 /* FIXME we need to check if it was es.reason == NEWT_EXIT_TIMER */
171 perf_top_browser__update_rb_tree(browser); 171 perf_top_browser__update_rb_tree(browser);
172 perf_top__header_snprintf(top, title, sizeof(title)); 172 perf_top__header_snprintf(top, title, sizeof(title));
173 perf_top__reset_sample_counters(top); 173 perf_top__reset_sample_counters(top);
174 ui_browser__set_color(&browser->b, NEWT_COLORSET_ROOT); 174 ui_browser__set_color(&browser->b, NEWT_COLORSET_ROOT);
175 SLsmg_gotorc(0, 0); 175 SLsmg_gotorc(0, 0);
176 slsmg_write_nstring(title, browser->b.width); 176 slsmg_write_nstring(title, browser->b.width);
177 break; 177 break;
178 case 'a': 178 case 'a':
179 case NEWT_KEY_RIGHT: 179 case NEWT_KEY_RIGHT:
180 case NEWT_KEY_ENTER: 180 case NEWT_KEY_ENTER:
181 if (browser->selection) 181 if (browser->selection)
182 perf_top_browser__annotate(browser); 182 perf_top_browser__annotate(browser);
183 break; 183 break;
184 case NEWT_KEY_LEFT: 184 case NEWT_KEY_LEFT:
185 continue; 185 continue;
186 case NEWT_KEY_ESCAPE: 186 case NEWT_KEY_ESCAPE:
187 if (!ui__dialog_yesno("Do you really want to exit?")) 187 if (!ui__dialog_yesno("Do you really want to exit?"))
188 continue; 188 continue;
189 /* Fall thru */ 189 /* Fall thru */
190 default: 190 default:
191 goto out; 191 goto out;
192 } 192 }
193 } 193 }
194 out: 194 out:
195 ui_browser__hide(&browser->b); 195 ui_browser__hide(&browser->b);
196 return key; 196 return key;
197 } 197 }
198 198
199 int perf_top__tui_browser(struct perf_top *top) 199 int perf_top__tui_browser(struct perf_top *top)
200 { 200 {
201 struct perf_top_browser browser = { 201 struct perf_top_browser browser = {
202 .b = { 202 .b = {
203 .entries = &browser.root, 203 .entries = &browser.root,
204 .refresh = ui_browser__rb_tree_refresh, 204 .refresh = ui_browser__rb_tree_refresh,
205 .seek = ui_browser__rb_tree_seek, 205 .seek = ui_browser__rb_tree_seek,
206 .write = perf_top_browser__write, 206 .write = perf_top_browser__write,
207 .priv = top, 207 .priv = top,
208 }, 208 },
209 }; 209 };
210 210
211 ui_helpline__push("Press <- or ESC to exit");
212 return perf_top_browser__run(&browser); 211 return perf_top_browser__run(&browser);
213 } 212 }
214 213