diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-05-29 21:42:18 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-05-29 21:42:18 -0400 |
commit | 05e8b0804ec423a440882e7adecb36e7ac43e56f (patch) | |
tree | 1cefdeac3112e790afc275d9e57cd56674084fa4 /tools/perf/ui/browsers/hists.c | |
parent | c323cf0400c1fed853738e6d81e83c6ac7ff5105 (diff) |
perf ui browser: Stop using 'self'
Stop using this python/OOP convention, doesn't really helps. Will do
more from time to time till we get it cleaned up in all of /perf.
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
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-5dyxyb8o0gf4yndk27kafbd1@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui/browsers/hists.c')
-rw-r--r-- | tools/perf/ui/browsers/hists.c | 338 |
1 files changed, 169 insertions, 169 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index a372a4b02635..53f6697d014e 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -26,21 +26,21 @@ struct hist_browser { | |||
26 | bool has_symbols; | 26 | bool has_symbols; |
27 | }; | 27 | }; |
28 | 28 | ||
29 | static int hists__browser_title(struct hists *self, char *bf, size_t size, | 29 | static int hists__browser_title(struct hists *hists, char *bf, size_t size, |
30 | const char *ev_name); | 30 | const char *ev_name); |
31 | 31 | ||
32 | static void hist_browser__refresh_dimensions(struct hist_browser *self) | 32 | static void hist_browser__refresh_dimensions(struct hist_browser *browser) |
33 | { | 33 | { |
34 | /* 3 == +/- toggle symbol before actual hist_entry rendering */ | 34 | /* 3 == +/- toggle symbol before actual hist_entry rendering */ |
35 | self->b.width = 3 + (hists__sort_list_width(self->hists) + | 35 | browser->b.width = 3 + (hists__sort_list_width(browser->hists) + |
36 | sizeof("[k]")); | 36 | sizeof("[k]")); |
37 | } | 37 | } |
38 | 38 | ||
39 | static void hist_browser__reset(struct hist_browser *self) | 39 | static void hist_browser__reset(struct hist_browser *browser) |
40 | { | 40 | { |
41 | self->b.nr_entries = self->hists->nr_entries; | 41 | browser->b.nr_entries = browser->hists->nr_entries; |
42 | hist_browser__refresh_dimensions(self); | 42 | hist_browser__refresh_dimensions(browser); |
43 | ui_browser__reset_index(&self->b); | 43 | ui_browser__reset_index(&browser->b); |
44 | } | 44 | } |
45 | 45 | ||
46 | static char tree__folded_sign(bool unfolded) | 46 | static char tree__folded_sign(bool unfolded) |
@@ -48,32 +48,32 @@ static char tree__folded_sign(bool unfolded) | |||
48 | return unfolded ? '-' : '+'; | 48 | return unfolded ? '-' : '+'; |
49 | } | 49 | } |
50 | 50 | ||
51 | static char map_symbol__folded(const struct map_symbol *self) | 51 | static char map_symbol__folded(const struct map_symbol *ms) |
52 | { | 52 | { |
53 | return self->has_children ? tree__folded_sign(self->unfolded) : ' '; | 53 | return ms->has_children ? tree__folded_sign(ms->unfolded) : ' '; |
54 | } | 54 | } |
55 | 55 | ||
56 | static char hist_entry__folded(const struct hist_entry *self) | 56 | static char hist_entry__folded(const struct hist_entry *he) |
57 | { | 57 | { |
58 | return map_symbol__folded(&self->ms); | 58 | return map_symbol__folded(&he->ms); |
59 | } | 59 | } |
60 | 60 | ||
61 | static char callchain_list__folded(const struct callchain_list *self) | 61 | static char callchain_list__folded(const struct callchain_list *cl) |
62 | { | 62 | { |
63 | return map_symbol__folded(&self->ms); | 63 | return map_symbol__folded(&cl->ms); |
64 | } | 64 | } |
65 | 65 | ||
66 | static void map_symbol__set_folding(struct map_symbol *self, bool unfold) | 66 | static void map_symbol__set_folding(struct map_symbol *ms, bool unfold) |
67 | { | 67 | { |
68 | self->unfolded = unfold ? self->has_children : false; | 68 | ms->unfolded = unfold ? ms->has_children : false; |
69 | } | 69 | } |
70 | 70 | ||
71 | static int callchain_node__count_rows_rb_tree(struct callchain_node *self) | 71 | static int callchain_node__count_rows_rb_tree(struct callchain_node *node) |
72 | { | 72 | { |
73 | int n = 0; | 73 | int n = 0; |
74 | struct rb_node *nd; | 74 | struct rb_node *nd; |
75 | 75 | ||
76 | for (nd = rb_first(&self->rb_root); nd; nd = rb_next(nd)) { | 76 | for (nd = rb_first(&node->rb_root); nd; nd = rb_next(nd)) { |
77 | struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node); | 77 | struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node); |
78 | struct callchain_list *chain; | 78 | struct callchain_list *chain; |
79 | char folded_sign = ' '; /* No children */ | 79 | char folded_sign = ' '; /* No children */ |
@@ -123,23 +123,23 @@ static int callchain__count_rows(struct rb_root *chain) | |||
123 | return n; | 123 | return n; |
124 | } | 124 | } |
125 | 125 | ||
126 | static bool map_symbol__toggle_fold(struct map_symbol *self) | 126 | static bool map_symbol__toggle_fold(struct map_symbol *ms) |
127 | { | 127 | { |
128 | if (!self) | 128 | if (!ms) |
129 | return false; | 129 | return false; |
130 | 130 | ||
131 | if (!self->has_children) | 131 | if (!ms->has_children) |
132 | return false; | 132 | return false; |
133 | 133 | ||
134 | self->unfolded = !self->unfolded; | 134 | ms->unfolded = !ms->unfolded; |
135 | return true; | 135 | return true; |
136 | } | 136 | } |
137 | 137 | ||
138 | static void callchain_node__init_have_children_rb_tree(struct callchain_node *self) | 138 | static void callchain_node__init_have_children_rb_tree(struct callchain_node *node) |
139 | { | 139 | { |
140 | struct rb_node *nd = rb_first(&self->rb_root); | 140 | struct rb_node *nd = rb_first(&node->rb_root); |
141 | 141 | ||
142 | for (nd = rb_first(&self->rb_root); nd; nd = rb_next(nd)) { | 142 | for (nd = rb_first(&node->rb_root); nd; nd = rb_next(nd)) { |
143 | struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node); | 143 | struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node); |
144 | struct callchain_list *chain; | 144 | struct callchain_list *chain; |
145 | bool first = true; | 145 | bool first = true; |
@@ -158,49 +158,49 @@ static void callchain_node__init_have_children_rb_tree(struct callchain_node *se | |||
158 | } | 158 | } |
159 | } | 159 | } |
160 | 160 | ||
161 | static void callchain_node__init_have_children(struct callchain_node *self) | 161 | static void callchain_node__init_have_children(struct callchain_node *node) |
162 | { | 162 | { |
163 | struct callchain_list *chain; | 163 | struct callchain_list *chain; |
164 | 164 | ||
165 | list_for_each_entry(chain, &self->val, list) | 165 | list_for_each_entry(chain, &node->val, list) |
166 | chain->ms.has_children = !RB_EMPTY_ROOT(&self->rb_root); | 166 | chain->ms.has_children = !RB_EMPTY_ROOT(&node->rb_root); |
167 | 167 | ||
168 | callchain_node__init_have_children_rb_tree(self); | 168 | callchain_node__init_have_children_rb_tree(node); |
169 | } | 169 | } |
170 | 170 | ||
171 | static void callchain__init_have_children(struct rb_root *self) | 171 | static void callchain__init_have_children(struct rb_root *root) |
172 | { | 172 | { |
173 | struct rb_node *nd; | 173 | struct rb_node *nd; |
174 | 174 | ||
175 | for (nd = rb_first(self); nd; nd = rb_next(nd)) { | 175 | for (nd = rb_first(root); nd; nd = rb_next(nd)) { |
176 | struct callchain_node *node = rb_entry(nd, struct callchain_node, rb_node); | 176 | struct callchain_node *node = rb_entry(nd, struct callchain_node, rb_node); |
177 | callchain_node__init_have_children(node); | 177 | callchain_node__init_have_children(node); |
178 | } | 178 | } |
179 | } | 179 | } |
180 | 180 | ||
181 | static void hist_entry__init_have_children(struct hist_entry *self) | 181 | static void hist_entry__init_have_children(struct hist_entry *he) |
182 | { | 182 | { |
183 | if (!self->init_have_children) { | 183 | if (!he->init_have_children) { |
184 | self->ms.has_children = !RB_EMPTY_ROOT(&self->sorted_chain); | 184 | he->ms.has_children = !RB_EMPTY_ROOT(&he->sorted_chain); |
185 | callchain__init_have_children(&self->sorted_chain); | 185 | callchain__init_have_children(&he->sorted_chain); |
186 | self->init_have_children = true; | 186 | he->init_have_children = true; |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | static bool hist_browser__toggle_fold(struct hist_browser *self) | 190 | static bool hist_browser__toggle_fold(struct hist_browser *browser) |
191 | { | 191 | { |
192 | if (map_symbol__toggle_fold(self->selection)) { | 192 | if (map_symbol__toggle_fold(browser->selection)) { |
193 | struct hist_entry *he = self->he_selection; | 193 | struct hist_entry *he = browser->he_selection; |
194 | 194 | ||
195 | hist_entry__init_have_children(he); | 195 | hist_entry__init_have_children(he); |
196 | self->hists->nr_entries -= he->nr_rows; | 196 | browser->hists->nr_entries -= he->nr_rows; |
197 | 197 | ||
198 | if (he->ms.unfolded) | 198 | if (he->ms.unfolded) |
199 | he->nr_rows = callchain__count_rows(&he->sorted_chain); | 199 | he->nr_rows = callchain__count_rows(&he->sorted_chain); |
200 | else | 200 | else |
201 | he->nr_rows = 0; | 201 | he->nr_rows = 0; |
202 | self->hists->nr_entries += he->nr_rows; | 202 | browser->hists->nr_entries += he->nr_rows; |
203 | self->b.nr_entries = self->hists->nr_entries; | 203 | browser->b.nr_entries = browser->hists->nr_entries; |
204 | 204 | ||
205 | return true; | 205 | return true; |
206 | } | 206 | } |
@@ -209,12 +209,12 @@ static bool hist_browser__toggle_fold(struct hist_browser *self) | |||
209 | return false; | 209 | return false; |
210 | } | 210 | } |
211 | 211 | ||
212 | static int callchain_node__set_folding_rb_tree(struct callchain_node *self, bool unfold) | 212 | static int callchain_node__set_folding_rb_tree(struct callchain_node *node, bool unfold) |
213 | { | 213 | { |
214 | int n = 0; | 214 | int n = 0; |
215 | struct rb_node *nd; | 215 | struct rb_node *nd; |
216 | 216 | ||
217 | for (nd = rb_first(&self->rb_root); nd; nd = rb_next(nd)) { | 217 | for (nd = rb_first(&node->rb_root); nd; nd = rb_next(nd)) { |
218 | struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node); | 218 | struct callchain_node *child = rb_entry(nd, struct callchain_node, rb_node); |
219 | struct callchain_list *chain; | 219 | struct callchain_list *chain; |
220 | bool has_children = false; | 220 | bool has_children = false; |
@@ -263,37 +263,37 @@ static int callchain__set_folding(struct rb_root *chain, bool unfold) | |||
263 | return n; | 263 | return n; |
264 | } | 264 | } |
265 | 265 | ||
266 | static void hist_entry__set_folding(struct hist_entry *self, bool unfold) | 266 | static void hist_entry__set_folding(struct hist_entry *he, bool unfold) |
267 | { | 267 | { |
268 | hist_entry__init_have_children(self); | 268 | hist_entry__init_have_children(he); |
269 | map_symbol__set_folding(&self->ms, unfold); | 269 | map_symbol__set_folding(&he->ms, unfold); |
270 | 270 | ||
271 | if (self->ms.has_children) { | 271 | if (he->ms.has_children) { |
272 | int n = callchain__set_folding(&self->sorted_chain, unfold); | 272 | int n = callchain__set_folding(&he->sorted_chain, unfold); |
273 | self->nr_rows = unfold ? n : 0; | 273 | he->nr_rows = unfold ? n : 0; |
274 | } else | 274 | } else |
275 | self->nr_rows = 0; | 275 | he->nr_rows = 0; |
276 | } | 276 | } |
277 | 277 | ||
278 | static void hists__set_folding(struct hists *self, bool unfold) | 278 | static void hists__set_folding(struct hists *hists, bool unfold) |
279 | { | 279 | { |
280 | struct rb_node *nd; | 280 | struct rb_node *nd; |
281 | 281 | ||
282 | self->nr_entries = 0; | 282 | hists->nr_entries = 0; |
283 | 283 | ||
284 | for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { | 284 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { |
285 | struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node); | 285 | struct hist_entry *he = rb_entry(nd, struct hist_entry, rb_node); |
286 | hist_entry__set_folding(he, unfold); | 286 | hist_entry__set_folding(he, unfold); |
287 | self->nr_entries += 1 + he->nr_rows; | 287 | hists->nr_entries += 1 + he->nr_rows; |
288 | } | 288 | } |
289 | } | 289 | } |
290 | 290 | ||
291 | static void hist_browser__set_folding(struct hist_browser *self, bool unfold) | 291 | static void hist_browser__set_folding(struct hist_browser *browser, bool unfold) |
292 | { | 292 | { |
293 | hists__set_folding(self->hists, unfold); | 293 | hists__set_folding(browser->hists, unfold); |
294 | self->b.nr_entries = self->hists->nr_entries; | 294 | browser->b.nr_entries = browser->hists->nr_entries; |
295 | /* Go to the start, we may be way after valid entries after a collapse */ | 295 | /* Go to the start, we may be way after valid entries after a collapse */ |
296 | ui_browser__reset_index(&self->b); | 296 | ui_browser__reset_index(&browser->b); |
297 | } | 297 | } |
298 | 298 | ||
299 | static void ui_browser__warn_lost_events(struct ui_browser *browser) | 299 | static void ui_browser__warn_lost_events(struct ui_browser *browser) |
@@ -305,64 +305,64 @@ static void ui_browser__warn_lost_events(struct ui_browser *browser) | |||
305 | "Or reduce the sampling frequency."); | 305 | "Or reduce the sampling frequency."); |
306 | } | 306 | } |
307 | 307 | ||
308 | static int hist_browser__run(struct hist_browser *self, const char *ev_name, | 308 | static int hist_browser__run(struct hist_browser *browser, const char *ev_name, |
309 | void(*timer)(void *arg), void *arg, int delay_secs) | 309 | void(*timer)(void *arg), void *arg, int delay_secs) |
310 | { | 310 | { |
311 | int key; | 311 | int key; |
312 | char title[160]; | 312 | char title[160]; |
313 | 313 | ||
314 | self->b.entries = &self->hists->entries; | 314 | browser->b.entries = &browser->hists->entries; |
315 | self->b.nr_entries = self->hists->nr_entries; | 315 | browser->b.nr_entries = browser->hists->nr_entries; |
316 | 316 | ||
317 | hist_browser__refresh_dimensions(self); | 317 | hist_browser__refresh_dimensions(browser); |
318 | hists__browser_title(self->hists, title, sizeof(title), ev_name); | 318 | hists__browser_title(browser->hists, title, sizeof(title), ev_name); |
319 | 319 | ||
320 | if (ui_browser__show(&self->b, title, | 320 | if (ui_browser__show(&browser->b, title, |
321 | "Press '?' for help on key bindings") < 0) | 321 | "Press '?' for help on key bindings") < 0) |
322 | return -1; | 322 | return -1; |
323 | 323 | ||
324 | while (1) { | 324 | while (1) { |
325 | key = ui_browser__run(&self->b, delay_secs); | 325 | key = ui_browser__run(&browser->b, delay_secs); |
326 | 326 | ||
327 | switch (key) { | 327 | switch (key) { |
328 | case K_TIMER: | 328 | case K_TIMER: |
329 | timer(arg); | 329 | timer(arg); |
330 | ui_browser__update_nr_entries(&self->b, self->hists->nr_entries); | 330 | ui_browser__update_nr_entries(&browser->b, browser->hists->nr_entries); |
331 | 331 | ||
332 | if (self->hists->stats.nr_lost_warned != | 332 | if (browser->hists->stats.nr_lost_warned != |
333 | self->hists->stats.nr_events[PERF_RECORD_LOST]) { | 333 | browser->hists->stats.nr_events[PERF_RECORD_LOST]) { |
334 | self->hists->stats.nr_lost_warned = | 334 | browser->hists->stats.nr_lost_warned = |
335 | self->hists->stats.nr_events[PERF_RECORD_LOST]; | 335 | browser->hists->stats.nr_events[PERF_RECORD_LOST]; |
336 | ui_browser__warn_lost_events(&self->b); | 336 | ui_browser__warn_lost_events(&browser->b); |
337 | } | 337 | } |
338 | 338 | ||
339 | hists__browser_title(self->hists, title, sizeof(title), ev_name); | 339 | hists__browser_title(browser->hists, title, sizeof(title), ev_name); |
340 | ui_browser__show_title(&self->b, title); | 340 | ui_browser__show_title(&browser->b, title); |
341 | continue; | 341 | continue; |
342 | case 'D': { /* Debug */ | 342 | case 'D': { /* Debug */ |
343 | static int seq; | 343 | static int seq; |
344 | struct hist_entry *h = rb_entry(self->b.top, | 344 | struct hist_entry *h = rb_entry(browser->b.top, |
345 | struct hist_entry, rb_node); | 345 | struct hist_entry, rb_node); |
346 | ui_helpline__pop(); | 346 | ui_helpline__pop(); |
347 | ui_helpline__fpush("%d: nr_ent=(%d,%d), height=%d, idx=%d, fve: idx=%d, row_off=%d, nrows=%d", | 347 | ui_helpline__fpush("%d: nr_ent=(%d,%d), height=%d, idx=%d, fve: idx=%d, row_off=%d, nrows=%d", |
348 | seq++, self->b.nr_entries, | 348 | seq++, browser->b.nr_entries, |
349 | self->hists->nr_entries, | 349 | browser->hists->nr_entries, |
350 | self->b.height, | 350 | browser->b.height, |
351 | self->b.index, | 351 | browser->b.index, |
352 | self->b.top_idx, | 352 | browser->b.top_idx, |
353 | h->row_offset, h->nr_rows); | 353 | h->row_offset, h->nr_rows); |
354 | } | 354 | } |
355 | break; | 355 | break; |
356 | case 'C': | 356 | case 'C': |
357 | /* Collapse the whole world. */ | 357 | /* Collapse the whole world. */ |
358 | hist_browser__set_folding(self, false); | 358 | hist_browser__set_folding(browser, false); |
359 | break; | 359 | break; |
360 | case 'E': | 360 | case 'E': |
361 | /* Expand the whole world. */ | 361 | /* Expand the whole world. */ |
362 | hist_browser__set_folding(self, true); | 362 | hist_browser__set_folding(browser, true); |
363 | break; | 363 | break; |
364 | case K_ENTER: | 364 | case K_ENTER: |
365 | if (hist_browser__toggle_fold(self)) | 365 | if (hist_browser__toggle_fold(browser)) |
366 | break; | 366 | break; |
367 | /* fall thru */ | 367 | /* fall thru */ |
368 | default: | 368 | default: |
@@ -370,23 +370,23 @@ static int hist_browser__run(struct hist_browser *self, const char *ev_name, | |||
370 | } | 370 | } |
371 | } | 371 | } |
372 | out: | 372 | out: |
373 | ui_browser__hide(&self->b); | 373 | ui_browser__hide(&browser->b); |
374 | return key; | 374 | return key; |
375 | } | 375 | } |
376 | 376 | ||
377 | static char *callchain_list__sym_name(struct callchain_list *self, | 377 | static char *callchain_list__sym_name(struct callchain_list *cl, |
378 | char *bf, size_t bfsize) | 378 | char *bf, size_t bfsize) |
379 | { | 379 | { |
380 | if (self->ms.sym) | 380 | if (cl->ms.sym) |
381 | return self->ms.sym->name; | 381 | return cl->ms.sym->name; |
382 | 382 | ||
383 | snprintf(bf, bfsize, "%#" PRIx64, self->ip); | 383 | snprintf(bf, bfsize, "%#" PRIx64, cl->ip); |
384 | return bf; | 384 | return bf; |
385 | } | 385 | } |
386 | 386 | ||
387 | #define LEVEL_OFFSET_STEP 3 | 387 | #define LEVEL_OFFSET_STEP 3 |
388 | 388 | ||
389 | static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *self, | 389 | static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *browser, |
390 | struct callchain_node *chain_node, | 390 | struct callchain_node *chain_node, |
391 | u64 total, int level, | 391 | u64 total, int level, |
392 | unsigned short row, | 392 | unsigned short row, |
@@ -444,21 +444,21 @@ static int hist_browser__show_callchain_node_rb_tree(struct hist_browser *self, | |||
444 | } | 444 | } |
445 | 445 | ||
446 | color = HE_COLORSET_NORMAL; | 446 | color = HE_COLORSET_NORMAL; |
447 | width = self->b.width - (offset + extra_offset + 2); | 447 | width = browser->b.width - (offset + extra_offset + 2); |
448 | if (ui_browser__is_current_entry(&self->b, row)) { | 448 | if (ui_browser__is_current_entry(&browser->b, row)) { |
449 | self->selection = &chain->ms; | 449 | browser->selection = &chain->ms; |
450 | color = HE_COLORSET_SELECTED; | 450 | color = HE_COLORSET_SELECTED; |
451 | *is_current_entry = true; | 451 | *is_current_entry = true; |
452 | } | 452 | } |
453 | 453 | ||
454 | ui_browser__set_color(&self->b, color); | 454 | ui_browser__set_color(&browser->b, color); |
455 | ui_browser__gotorc(&self->b, row, 0); | 455 | ui_browser__gotorc(&browser->b, row, 0); |
456 | slsmg_write_nstring(" ", offset + extra_offset); | 456 | slsmg_write_nstring(" ", offset + extra_offset); |
457 | slsmg_printf("%c ", folded_sign); | 457 | slsmg_printf("%c ", folded_sign); |
458 | slsmg_write_nstring(str, width); | 458 | slsmg_write_nstring(str, width); |
459 | free(alloc_str); | 459 | free(alloc_str); |
460 | 460 | ||
461 | if (++row == self->b.height) | 461 | if (++row == browser->b.height) |
462 | goto out; | 462 | goto out; |
463 | do_next: | 463 | do_next: |
464 | if (folded_sign == '+') | 464 | if (folded_sign == '+') |
@@ -467,11 +467,11 @@ do_next: | |||
467 | 467 | ||
468 | if (folded_sign == '-') { | 468 | if (folded_sign == '-') { |
469 | const int new_level = level + (extra_offset ? 2 : 1); | 469 | const int new_level = level + (extra_offset ? 2 : 1); |
470 | row += hist_browser__show_callchain_node_rb_tree(self, child, new_total, | 470 | row += hist_browser__show_callchain_node_rb_tree(browser, child, new_total, |
471 | new_level, row, row_offset, | 471 | new_level, row, row_offset, |
472 | is_current_entry); | 472 | is_current_entry); |
473 | } | 473 | } |
474 | if (row == self->b.height) | 474 | if (row == browser->b.height) |
475 | goto out; | 475 | goto out; |
476 | node = next; | 476 | node = next; |
477 | } | 477 | } |
@@ -479,7 +479,7 @@ out: | |||
479 | return row - first_row; | 479 | return row - first_row; |
480 | } | 480 | } |
481 | 481 | ||
482 | static int hist_browser__show_callchain_node(struct hist_browser *self, | 482 | static int hist_browser__show_callchain_node(struct hist_browser *browser, |
483 | struct callchain_node *node, | 483 | struct callchain_node *node, |
484 | int level, unsigned short row, | 484 | int level, unsigned short row, |
485 | off_t *row_offset, | 485 | off_t *row_offset, |
@@ -488,7 +488,7 @@ static int hist_browser__show_callchain_node(struct hist_browser *self, | |||
488 | struct callchain_list *chain; | 488 | struct callchain_list *chain; |
489 | int first_row = row, | 489 | int first_row = row, |
490 | offset = level * LEVEL_OFFSET_STEP, | 490 | offset = level * LEVEL_OFFSET_STEP, |
491 | width = self->b.width - offset; | 491 | width = browser->b.width - offset; |
492 | char folded_sign = ' '; | 492 | char folded_sign = ' '; |
493 | 493 | ||
494 | list_for_each_entry(chain, &node->val, list) { | 494 | list_for_each_entry(chain, &node->val, list) { |
@@ -503,26 +503,26 @@ static int hist_browser__show_callchain_node(struct hist_browser *self, | |||
503 | } | 503 | } |
504 | 504 | ||
505 | color = HE_COLORSET_NORMAL; | 505 | color = HE_COLORSET_NORMAL; |
506 | if (ui_browser__is_current_entry(&self->b, row)) { | 506 | if (ui_browser__is_current_entry(&browser->b, row)) { |
507 | self->selection = &chain->ms; | 507 | browser->selection = &chain->ms; |
508 | color = HE_COLORSET_SELECTED; | 508 | color = HE_COLORSET_SELECTED; |
509 | *is_current_entry = true; | 509 | *is_current_entry = true; |
510 | } | 510 | } |
511 | 511 | ||
512 | s = callchain_list__sym_name(chain, ipstr, sizeof(ipstr)); | 512 | s = callchain_list__sym_name(chain, ipstr, sizeof(ipstr)); |
513 | ui_browser__gotorc(&self->b, row, 0); | 513 | ui_browser__gotorc(&browser->b, row, 0); |
514 | ui_browser__set_color(&self->b, color); | 514 | ui_browser__set_color(&browser->b, color); |
515 | slsmg_write_nstring(" ", offset); | 515 | slsmg_write_nstring(" ", offset); |
516 | slsmg_printf("%c ", folded_sign); | 516 | slsmg_printf("%c ", folded_sign); |
517 | slsmg_write_nstring(s, width - 2); | 517 | slsmg_write_nstring(s, width - 2); |
518 | 518 | ||
519 | if (++row == self->b.height) | 519 | if (++row == browser->b.height) |
520 | goto out; | 520 | goto out; |
521 | } | 521 | } |
522 | 522 | ||
523 | if (folded_sign == '-') | 523 | if (folded_sign == '-') |
524 | row += hist_browser__show_callchain_node_rb_tree(self, node, | 524 | row += hist_browser__show_callchain_node_rb_tree(browser, node, |
525 | self->hists->stats.total_period, | 525 | browser->hists->stats.total_period, |
526 | level + 1, row, | 526 | level + 1, row, |
527 | row_offset, | 527 | row_offset, |
528 | is_current_entry); | 528 | is_current_entry); |
@@ -530,7 +530,7 @@ out: | |||
530 | return row - first_row; | 530 | return row - first_row; |
531 | } | 531 | } |
532 | 532 | ||
533 | static int hist_browser__show_callchain(struct hist_browser *self, | 533 | static int hist_browser__show_callchain(struct hist_browser *browser, |
534 | struct rb_root *chain, | 534 | struct rb_root *chain, |
535 | int level, unsigned short row, | 535 | int level, unsigned short row, |
536 | off_t *row_offset, | 536 | off_t *row_offset, |
@@ -542,31 +542,31 @@ static int hist_browser__show_callchain(struct hist_browser *self, | |||
542 | for (nd = rb_first(chain); nd; nd = rb_next(nd)) { | 542 | for (nd = rb_first(chain); nd; nd = rb_next(nd)) { |
543 | struct callchain_node *node = rb_entry(nd, struct callchain_node, rb_node); | 543 | struct callchain_node *node = rb_entry(nd, struct callchain_node, rb_node); |
544 | 544 | ||
545 | row += hist_browser__show_callchain_node(self, node, level, | 545 | row += hist_browser__show_callchain_node(browser, node, level, |
546 | row, row_offset, | 546 | row, row_offset, |
547 | is_current_entry); | 547 | is_current_entry); |
548 | if (row == self->b.height) | 548 | if (row == browser->b.height) |
549 | break; | 549 | break; |
550 | } | 550 | } |
551 | 551 | ||
552 | return row - first_row; | 552 | return row - first_row; |
553 | } | 553 | } |
554 | 554 | ||
555 | static int hist_browser__show_entry(struct hist_browser *self, | 555 | static int hist_browser__show_entry(struct hist_browser *browser, |
556 | struct hist_entry *entry, | 556 | struct hist_entry *entry, |
557 | unsigned short row) | 557 | unsigned short row) |
558 | { | 558 | { |
559 | char s[256]; | 559 | char s[256]; |
560 | double percent; | 560 | double percent; |
561 | int printed = 0; | 561 | int printed = 0; |
562 | int width = self->b.width - 6; /* The percentage */ | 562 | int width = browser->b.width - 6; /* The percentage */ |
563 | char folded_sign = ' '; | 563 | char folded_sign = ' '; |
564 | bool current_entry = ui_browser__is_current_entry(&self->b, row); | 564 | bool current_entry = ui_browser__is_current_entry(&browser->b, row); |
565 | off_t row_offset = entry->row_offset; | 565 | off_t row_offset = entry->row_offset; |
566 | 566 | ||
567 | if (current_entry) { | 567 | if (current_entry) { |
568 | self->he_selection = entry; | 568 | browser->he_selection = entry; |
569 | self->selection = &entry->ms; | 569 | browser->selection = &entry->ms; |
570 | } | 570 | } |
571 | 571 | ||
572 | if (symbol_conf.use_callchain) { | 572 | if (symbol_conf.use_callchain) { |
@@ -575,11 +575,11 @@ static int hist_browser__show_entry(struct hist_browser *self, | |||
575 | } | 575 | } |
576 | 576 | ||
577 | if (row_offset == 0) { | 577 | if (row_offset == 0) { |
578 | hist_entry__snprintf(entry, s, sizeof(s), self->hists); | 578 | hist_entry__snprintf(entry, s, sizeof(s), browser->hists); |
579 | percent = (entry->period * 100.0) / self->hists->stats.total_period; | 579 | percent = (entry->period * 100.0) / browser->hists->stats.total_period; |
580 | 580 | ||
581 | ui_browser__set_percent_color(&self->b, percent, current_entry); | 581 | ui_browser__set_percent_color(&browser->b, percent, current_entry); |
582 | ui_browser__gotorc(&self->b, row, 0); | 582 | ui_browser__gotorc(&browser->b, row, 0); |
583 | if (symbol_conf.use_callchain) { | 583 | if (symbol_conf.use_callchain) { |
584 | slsmg_printf("%c ", folded_sign); | 584 | slsmg_printf("%c ", folded_sign); |
585 | width -= 2; | 585 | width -= 2; |
@@ -588,11 +588,11 @@ static int hist_browser__show_entry(struct hist_browser *self, | |||
588 | slsmg_printf(" %5.2f%%", percent); | 588 | slsmg_printf(" %5.2f%%", percent); |
589 | 589 | ||
590 | /* The scroll bar isn't being used */ | 590 | /* The scroll bar isn't being used */ |
591 | if (!self->b.navkeypressed) | 591 | if (!browser->b.navkeypressed) |
592 | width += 1; | 592 | width += 1; |
593 | 593 | ||
594 | if (!current_entry || !self->b.navkeypressed) | 594 | if (!current_entry || !browser->b.navkeypressed) |
595 | ui_browser__set_color(&self->b, HE_COLORSET_NORMAL); | 595 | ui_browser__set_color(&browser->b, HE_COLORSET_NORMAL); |
596 | 596 | ||
597 | if (symbol_conf.show_nr_samples) { | 597 | if (symbol_conf.show_nr_samples) { |
598 | slsmg_printf(" %11u", entry->nr_events); | 598 | slsmg_printf(" %11u", entry->nr_events); |
@@ -610,12 +610,12 @@ static int hist_browser__show_entry(struct hist_browser *self, | |||
610 | } else | 610 | } else |
611 | --row_offset; | 611 | --row_offset; |
612 | 612 | ||
613 | if (folded_sign == '-' && row != self->b.height) { | 613 | if (folded_sign == '-' && row != browser->b.height) { |
614 | printed += hist_browser__show_callchain(self, &entry->sorted_chain, | 614 | printed += hist_browser__show_callchain(browser, &entry->sorted_chain, |
615 | 1, row, &row_offset, | 615 | 1, row, &row_offset, |
616 | ¤t_entry); | 616 | ¤t_entry); |
617 | if (current_entry) | 617 | if (current_entry) |
618 | self->he_selection = entry; | 618 | browser->he_selection = entry; |
619 | } | 619 | } |
620 | 620 | ||
621 | return printed; | 621 | return printed; |
@@ -631,22 +631,22 @@ static void ui_browser__hists_init_top(struct ui_browser *browser) | |||
631 | } | 631 | } |
632 | } | 632 | } |
633 | 633 | ||
634 | static unsigned int hist_browser__refresh(struct ui_browser *self) | 634 | static unsigned int hist_browser__refresh(struct ui_browser *browser) |
635 | { | 635 | { |
636 | unsigned row = 0; | 636 | unsigned row = 0; |
637 | struct rb_node *nd; | 637 | struct rb_node *nd; |
638 | struct hist_browser *hb = container_of(self, struct hist_browser, b); | 638 | struct hist_browser *hb = container_of(browser, struct hist_browser, b); |
639 | 639 | ||
640 | ui_browser__hists_init_top(self); | 640 | ui_browser__hists_init_top(browser); |
641 | 641 | ||
642 | for (nd = self->top; nd; nd = rb_next(nd)) { | 642 | for (nd = browser->top; nd; nd = rb_next(nd)) { |
643 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); | 643 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
644 | 644 | ||
645 | if (h->filtered) | 645 | if (h->filtered) |
646 | continue; | 646 | continue; |
647 | 647 | ||
648 | row += hist_browser__show_entry(hb, h, row); | 648 | row += hist_browser__show_entry(hb, h, row); |
649 | if (row == self->height) | 649 | if (row == browser->height) |
650 | break; | 650 | break; |
651 | } | 651 | } |
652 | 652 | ||
@@ -679,27 +679,27 @@ static struct rb_node *hists__filter_prev_entries(struct rb_node *nd) | |||
679 | return NULL; | 679 | return NULL; |
680 | } | 680 | } |
681 | 681 | ||
682 | static void ui_browser__hists_seek(struct ui_browser *self, | 682 | static void ui_browser__hists_seek(struct ui_browser *browser, |
683 | off_t offset, int whence) | 683 | off_t offset, int whence) |
684 | { | 684 | { |
685 | struct hist_entry *h; | 685 | struct hist_entry *h; |
686 | struct rb_node *nd; | 686 | struct rb_node *nd; |
687 | bool first = true; | 687 | bool first = true; |
688 | 688 | ||
689 | if (self->nr_entries == 0) | 689 | if (browser->nr_entries == 0) |
690 | return; | 690 | return; |
691 | 691 | ||
692 | ui_browser__hists_init_top(self); | 692 | ui_browser__hists_init_top(browser); |
693 | 693 | ||
694 | switch (whence) { | 694 | switch (whence) { |
695 | case SEEK_SET: | 695 | case SEEK_SET: |
696 | nd = hists__filter_entries(rb_first(self->entries)); | 696 | nd = hists__filter_entries(rb_first(browser->entries)); |
697 | break; | 697 | break; |
698 | case SEEK_CUR: | 698 | case SEEK_CUR: |
699 | nd = self->top; | 699 | nd = browser->top; |
700 | goto do_offset; | 700 | goto do_offset; |
701 | case SEEK_END: | 701 | case SEEK_END: |
702 | nd = hists__filter_prev_entries(rb_last(self->entries)); | 702 | nd = hists__filter_prev_entries(rb_last(browser->entries)); |
703 | first = false; | 703 | first = false; |
704 | break; | 704 | break; |
705 | default: | 705 | default: |
@@ -710,7 +710,7 @@ static void ui_browser__hists_seek(struct ui_browser *self, | |||
710 | * Moves not relative to the first visible entry invalidates its | 710 | * Moves not relative to the first visible entry invalidates its |
711 | * row_offset: | 711 | * row_offset: |
712 | */ | 712 | */ |
713 | h = rb_entry(self->top, struct hist_entry, rb_node); | 713 | h = rb_entry(browser->top, struct hist_entry, rb_node); |
714 | h->row_offset = 0; | 714 | h->row_offset = 0; |
715 | 715 | ||
716 | /* | 716 | /* |
@@ -738,7 +738,7 @@ do_offset: | |||
738 | } else { | 738 | } else { |
739 | h->row_offset += offset; | 739 | h->row_offset += offset; |
740 | offset = 0; | 740 | offset = 0; |
741 | self->top = nd; | 741 | browser->top = nd; |
742 | break; | 742 | break; |
743 | } | 743 | } |
744 | } | 744 | } |
@@ -746,7 +746,7 @@ do_offset: | |||
746 | if (nd == NULL) | 746 | if (nd == NULL) |
747 | break; | 747 | break; |
748 | --offset; | 748 | --offset; |
749 | self->top = nd; | 749 | browser->top = nd; |
750 | } while (offset != 0); | 750 | } while (offset != 0); |
751 | } else if (offset < 0) { | 751 | } else if (offset < 0) { |
752 | while (1) { | 752 | while (1) { |
@@ -759,7 +759,7 @@ do_offset: | |||
759 | } else { | 759 | } else { |
760 | h->row_offset += offset; | 760 | h->row_offset += offset; |
761 | offset = 0; | 761 | offset = 0; |
762 | self->top = nd; | 762 | browser->top = nd; |
763 | break; | 763 | break; |
764 | } | 764 | } |
765 | } else { | 765 | } else { |
@@ -769,7 +769,7 @@ do_offset: | |||
769 | } else { | 769 | } else { |
770 | h->row_offset = h->nr_rows + offset; | 770 | h->row_offset = h->nr_rows + offset; |
771 | offset = 0; | 771 | offset = 0; |
772 | self->top = nd; | 772 | browser->top = nd; |
773 | break; | 773 | break; |
774 | } | 774 | } |
775 | } | 775 | } |
@@ -779,7 +779,7 @@ do_offset: | |||
779 | if (nd == NULL) | 779 | if (nd == NULL) |
780 | break; | 780 | break; |
781 | ++offset; | 781 | ++offset; |
782 | self->top = nd; | 782 | browser->top = nd; |
783 | if (offset == 0) { | 783 | if (offset == 0) { |
784 | /* | 784 | /* |
785 | * Last unfiltered hist_entry, check if it is | 785 | * Last unfiltered hist_entry, check if it is |
@@ -794,7 +794,7 @@ do_offset: | |||
794 | first = false; | 794 | first = false; |
795 | } | 795 | } |
796 | } else { | 796 | } else { |
797 | self->top = nd; | 797 | browser->top = nd; |
798 | h = rb_entry(nd, struct hist_entry, rb_node); | 798 | h = rb_entry(nd, struct hist_entry, rb_node); |
799 | h->row_offset = 0; | 799 | h->row_offset = 0; |
800 | } | 800 | } |
@@ -802,46 +802,46 @@ do_offset: | |||
802 | 802 | ||
803 | static struct hist_browser *hist_browser__new(struct hists *hists) | 803 | static struct hist_browser *hist_browser__new(struct hists *hists) |
804 | { | 804 | { |
805 | struct hist_browser *self = zalloc(sizeof(*self)); | 805 | struct hist_browser *browser = zalloc(sizeof(*browser)); |
806 | 806 | ||
807 | if (self) { | 807 | if (browser) { |
808 | self->hists = hists; | 808 | browser->hists = hists; |
809 | self->b.refresh = hist_browser__refresh; | 809 | browser->b.refresh = hist_browser__refresh; |
810 | self->b.seek = ui_browser__hists_seek; | 810 | browser->b.seek = ui_browser__hists_seek; |
811 | self->b.use_navkeypressed = true; | 811 | browser->b.use_navkeypressed = true; |
812 | if (sort__branch_mode == 1) | 812 | if (sort__branch_mode == 1) |
813 | self->has_symbols = sort_sym_from.list.next != NULL; | 813 | browser->has_symbols = sort_sym_from.list.next != NULL; |
814 | else | 814 | else |
815 | self->has_symbols = sort_sym.list.next != NULL; | 815 | browser->has_symbols = sort_sym.list.next != NULL; |
816 | } | 816 | } |
817 | 817 | ||
818 | return self; | 818 | return browser; |
819 | } | 819 | } |
820 | 820 | ||
821 | static void hist_browser__delete(struct hist_browser *self) | 821 | static void hist_browser__delete(struct hist_browser *browser) |
822 | { | 822 | { |
823 | free(self); | 823 | free(browser); |
824 | } | 824 | } |
825 | 825 | ||
826 | static struct hist_entry *hist_browser__selected_entry(struct hist_browser *self) | 826 | static struct hist_entry *hist_browser__selected_entry(struct hist_browser *browser) |
827 | { | 827 | { |
828 | return self->he_selection; | 828 | return browser->he_selection; |
829 | } | 829 | } |
830 | 830 | ||
831 | static struct thread *hist_browser__selected_thread(struct hist_browser *self) | 831 | static struct thread *hist_browser__selected_thread(struct hist_browser *browser) |
832 | { | 832 | { |
833 | return self->he_selection->thread; | 833 | return browser->he_selection->thread; |
834 | } | 834 | } |
835 | 835 | ||
836 | static int hists__browser_title(struct hists *self, char *bf, size_t size, | 836 | static int hists__browser_title(struct hists *hists, char *bf, size_t size, |
837 | const char *ev_name) | 837 | const char *ev_name) |
838 | { | 838 | { |
839 | char unit; | 839 | char unit; |
840 | int printed; | 840 | int printed; |
841 | const struct dso *dso = self->dso_filter; | 841 | const struct dso *dso = hists->dso_filter; |
842 | const struct thread *thread = self->thread_filter; | 842 | const struct thread *thread = hists->thread_filter; |
843 | unsigned long nr_samples = self->stats.nr_events[PERF_RECORD_SAMPLE]; | 843 | unsigned long nr_samples = hists->stats.nr_events[PERF_RECORD_SAMPLE]; |
844 | u64 nr_events = self->stats.total_period; | 844 | u64 nr_events = hists->stats.total_period; |
845 | 845 | ||
846 | nr_samples = convert_unit(nr_samples, &unit); | 846 | nr_samples = convert_unit(nr_samples, &unit); |
847 | printed = scnprintf(bf, size, | 847 | printed = scnprintf(bf, size, |
@@ -849,9 +849,9 @@ static int hists__browser_title(struct hists *self, char *bf, size_t size, | |||
849 | nr_samples, unit, ev_name, nr_events); | 849 | nr_samples, unit, ev_name, nr_events); |
850 | 850 | ||
851 | 851 | ||
852 | if (self->uid_filter_str) | 852 | if (hists->uid_filter_str) |
853 | printed += snprintf(bf + printed, size - printed, | 853 | printed += snprintf(bf + printed, size - printed, |
854 | ", UID: %s", self->uid_filter_str); | 854 | ", UID: %s", hists->uid_filter_str); |
855 | if (thread) | 855 | if (thread) |
856 | printed += scnprintf(bf + printed, size - printed, | 856 | printed += scnprintf(bf + printed, size - printed, |
857 | ", Thread: %s(%d)", | 857 | ", Thread: %s(%d)", |
@@ -879,8 +879,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
879 | void(*timer)(void *arg), void *arg, | 879 | void(*timer)(void *arg), void *arg, |
880 | int delay_secs) | 880 | int delay_secs) |
881 | { | 881 | { |
882 | struct hists *self = &evsel->hists; | 882 | struct hists *hists = &evsel->hists; |
883 | struct hist_browser *browser = hist_browser__new(self); | 883 | struct hist_browser *browser = hist_browser__new(hists); |
884 | struct branch_info *bi; | 884 | struct branch_info *bi; |
885 | struct pstack *fstack; | 885 | struct pstack *fstack; |
886 | char *options[16]; | 886 | char *options[16]; |
@@ -946,8 +946,8 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
946 | "Please enter the name of symbol you want to see", | 946 | "Please enter the name of symbol you want to see", |
947 | buf, "ENTER: OK, ESC: Cancel", | 947 | buf, "ENTER: OK, ESC: Cancel", |
948 | delay_secs * 2) == K_ENTER) { | 948 | delay_secs * 2) == K_ENTER) { |
949 | self->symbol_filter_str = *buf ? buf : NULL; | 949 | hists->symbol_filter_str = *buf ? buf : NULL; |
950 | hists__filter_by_symbol(self); | 950 | hists__filter_by_symbol(hists); |
951 | hist_browser__reset(browser); | 951 | hist_browser__reset(browser); |
952 | } | 952 | } |
953 | continue; | 953 | continue; |
@@ -1128,7 +1128,7 @@ zoom_out_dso: | |||
1128 | sort_dso.elide = true; | 1128 | sort_dso.elide = true; |
1129 | pstack__push(fstack, &browser->hists->dso_filter); | 1129 | pstack__push(fstack, &browser->hists->dso_filter); |
1130 | } | 1130 | } |
1131 | hists__filter_by_dso(self); | 1131 | hists__filter_by_dso(hists); |
1132 | hist_browser__reset(browser); | 1132 | hist_browser__reset(browser); |
1133 | } else if (choice == zoom_thread) { | 1133 | } else if (choice == zoom_thread) { |
1134 | zoom_thread: | 1134 | zoom_thread: |
@@ -1146,7 +1146,7 @@ zoom_out_thread: | |||
1146 | sort_thread.elide = true; | 1146 | sort_thread.elide = true; |
1147 | pstack__push(fstack, &browser->hists->thread_filter); | 1147 | pstack__push(fstack, &browser->hists->thread_filter); |
1148 | } | 1148 | } |
1149 | hists__filter_by_thread(self); | 1149 | hists__filter_by_thread(hists); |
1150 | hist_browser__reset(browser); | 1150 | hist_browser__reset(browser); |
1151 | } | 1151 | } |
1152 | } | 1152 | } |