aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/ui/stdio/hist.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/ui/stdio/hist.c')
-rw-r--r--tools/perf/ui/stdio/hist.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 194e2f42ff5d..c244cb524ef2 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -213,20 +213,19 @@ static size_t callchain__fprintf_graph(FILE *fp, struct rb_root *root,
213 return ret; 213 return ret;
214} 214}
215 215
216static size_t __callchain__fprintf_flat(FILE *fp, 216static size_t __callchain__fprintf_flat(FILE *fp, struct callchain_node *node,
217 struct callchain_node *self,
218 u64 total_samples) 217 u64 total_samples)
219{ 218{
220 struct callchain_list *chain; 219 struct callchain_list *chain;
221 size_t ret = 0; 220 size_t ret = 0;
222 221
223 if (!self) 222 if (!node)
224 return 0; 223 return 0;
225 224
226 ret += __callchain__fprintf_flat(fp, self->parent, total_samples); 225 ret += __callchain__fprintf_flat(fp, node->parent, total_samples);
227 226
228 227
229 list_for_each_entry(chain, &self->val, list) { 228 list_for_each_entry(chain, &node->val, list) {
230 if (chain->ip >= PERF_CONTEXT_MAX) 229 if (chain->ip >= PERF_CONTEXT_MAX)
231 continue; 230 continue;
232 if (chain->ms.sym) 231 if (chain->ms.sym)
@@ -239,15 +238,14 @@ static size_t __callchain__fprintf_flat(FILE *fp,
239 return ret; 238 return ret;
240} 239}
241 240
242static size_t callchain__fprintf_flat(FILE *fp, struct rb_root *self, 241static size_t callchain__fprintf_flat(FILE *fp, struct rb_root *tree,
243 u64 total_samples) 242 u64 total_samples)
244{ 243{
245 size_t ret = 0; 244 size_t ret = 0;
246 u32 entries_printed = 0; 245 u32 entries_printed = 0;
247 struct rb_node *rb_node;
248 struct callchain_node *chain; 246 struct callchain_node *chain;
247 struct rb_node *rb_node = rb_first(tree);
249 248
250 rb_node = rb_first(self);
251 while (rb_node) { 249 while (rb_node) {
252 double percent; 250 double percent;
253 251
@@ -315,8 +313,7 @@ static inline void advance_hpp(struct perf_hpp *hpp, int inc)
315} 313}
316 314
317static int hist_entry__period_snprintf(struct perf_hpp *hpp, 315static int hist_entry__period_snprintf(struct perf_hpp *hpp,
318 struct hist_entry *he, 316 struct hist_entry *he)
319 bool color)
320{ 317{
321 const char *sep = symbol_conf.field_sep; 318 const char *sep = symbol_conf.field_sep;
322 struct perf_hpp_fmt *fmt; 319 struct perf_hpp_fmt *fmt;
@@ -338,7 +335,7 @@ static int hist_entry__period_snprintf(struct perf_hpp *hpp,
338 } else 335 } else
339 first = false; 336 first = false;
340 337
341 if (color && fmt->color) 338 if (perf_hpp__use_color() && fmt->color)
342 ret = fmt->color(fmt, hpp, he); 339 ret = fmt->color(fmt, hpp, he);
343 else 340 else
344 ret = fmt->entry(fmt, hpp, he); 341 ret = fmt->entry(fmt, hpp, he);
@@ -358,12 +355,11 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size,
358 .buf = bf, 355 .buf = bf,
359 .size = size, 356 .size = size,
360 }; 357 };
361 bool color = !symbol_conf.field_sep;
362 358
363 if (size == 0 || size > bfsz) 359 if (size == 0 || size > bfsz)
364 size = hpp.size = bfsz; 360 size = hpp.size = bfsz;
365 361
366 ret = hist_entry__period_snprintf(&hpp, he, color); 362 ret = hist_entry__period_snprintf(&hpp, he);
367 hist_entry__sort_snprintf(he, bf + ret, size - ret, hists); 363 hist_entry__sort_snprintf(he, bf + ret, size - ret, hists);
368 364
369 ret = fprintf(fp, "%s\n", bf); 365 ret = fprintf(fp, "%s\n", bf);
@@ -482,6 +478,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
482 478
483print_entries: 479print_entries:
484 linesz = hists__sort_list_width(hists) + 3 + 1; 480 linesz = hists__sort_list_width(hists) + 3 + 1;
481 linesz += perf_hpp__color_overhead();
485 line = malloc(linesz); 482 line = malloc(linesz);
486 if (line == NULL) { 483 if (line == NULL) {
487 ret = -1; 484 ret = -1;