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.c45
1 files changed, 16 insertions, 29 deletions
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index 882461a42830..fbd4e32d0743 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -271,7 +271,7 @@ static size_t hist_entry_callchain__fprintf(struct hist_entry *he,
271{ 271{
272 switch (callchain_param.mode) { 272 switch (callchain_param.mode) {
273 case CHAIN_GRAPH_REL: 273 case CHAIN_GRAPH_REL:
274 return callchain__fprintf_graph(fp, &he->sorted_chain, he->period, 274 return callchain__fprintf_graph(fp, &he->sorted_chain, he->stat.period,
275 left_margin); 275 left_margin);
276 break; 276 break;
277 case CHAIN_GRAPH_ABS: 277 case CHAIN_GRAPH_ABS:
@@ -292,9 +292,10 @@ static size_t hist_entry_callchain__fprintf(struct hist_entry *he,
292 292
293static size_t hist_entry__callchain_fprintf(struct hist_entry *he, 293static size_t hist_entry__callchain_fprintf(struct hist_entry *he,
294 struct hists *hists, 294 struct hists *hists,
295 u64 total_period, FILE *fp) 295 FILE *fp)
296{ 296{
297 int left_margin = 0; 297 int left_margin = 0;
298 u64 total_period = hists->stats.total_period;
298 299
299 if (sort__first_dimension == SORT_COMM) { 300 if (sort__first_dimension == SORT_COMM) {
300 struct sort_entry *se = list_first_entry(&hist_entry__sort_list, 301 struct sort_entry *se = list_first_entry(&hist_entry__sort_list,
@@ -307,17 +308,13 @@ static size_t hist_entry__callchain_fprintf(struct hist_entry *he,
307} 308}
308 309
309static int hist_entry__fprintf(struct hist_entry *he, size_t size, 310static int hist_entry__fprintf(struct hist_entry *he, size_t size,
310 struct hists *hists, struct hists *pair_hists, 311 struct hists *hists, FILE *fp)
311 long displacement, u64 total_period, FILE *fp)
312{ 312{
313 char bf[512]; 313 char bf[512];
314 int ret; 314 int ret;
315 struct perf_hpp hpp = { 315 struct perf_hpp hpp = {
316 .buf = bf, 316 .buf = bf,
317 .size = size, 317 .size = size,
318 .total_period = total_period,
319 .displacement = displacement,
320 .ptr = pair_hists,
321 }; 318 };
322 bool color = !symbol_conf.field_sep; 319 bool color = !symbol_conf.field_sep;
323 320
@@ -330,22 +327,17 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size,
330 ret = fprintf(fp, "%s\n", bf); 327 ret = fprintf(fp, "%s\n", bf);
331 328
332 if (symbol_conf.use_callchain) 329 if (symbol_conf.use_callchain)
333 ret += hist_entry__callchain_fprintf(he, hists, 330 ret += hist_entry__callchain_fprintf(he, hists, fp);
334 total_period, fp);
335 331
336 return ret; 332 return ret;
337} 333}
338 334
339size_t hists__fprintf(struct hists *hists, struct hists *pair, 335size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
340 bool show_displacement, bool show_header, int max_rows,
341 int max_cols, FILE *fp) 336 int max_cols, FILE *fp)
342{ 337{
343 struct sort_entry *se; 338 struct sort_entry *se;
344 struct rb_node *nd; 339 struct rb_node *nd;
345 size_t ret = 0; 340 size_t ret = 0;
346 u64 total_period;
347 unsigned long position = 1;
348 long displacement = 0;
349 unsigned int width; 341 unsigned int width;
350 const char *sep = symbol_conf.field_sep; 342 const char *sep = symbol_conf.field_sep;
351 const char *col_width = symbol_conf.col_width_list_str; 343 const char *col_width = symbol_conf.col_width_list_str;
@@ -354,8 +346,8 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair,
354 struct perf_hpp dummy_hpp = { 346 struct perf_hpp dummy_hpp = {
355 .buf = bf, 347 .buf = bf,
356 .size = sizeof(bf), 348 .size = sizeof(bf),
357 .ptr = pair,
358 }; 349 };
350 bool first = true;
359 351
360 init_rem_hits(); 352 init_rem_hits();
361 353
@@ -367,8 +359,10 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair,
367 if (!perf_hpp__format[idx].cond) 359 if (!perf_hpp__format[idx].cond)
368 continue; 360 continue;
369 361
370 if (idx) 362 if (!first)
371 fprintf(fp, "%s", sep ?: " "); 363 fprintf(fp, "%s", sep ?: " ");
364 else
365 first = false;
372 366
373 perf_hpp__format[idx].header(&dummy_hpp); 367 perf_hpp__format[idx].header(&dummy_hpp);
374 fprintf(fp, "%s", bf); 368 fprintf(fp, "%s", bf);
@@ -403,6 +397,8 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair,
403 if (sep) 397 if (sep)
404 goto print_entries; 398 goto print_entries;
405 399
400 first = true;
401
406 fprintf(fp, "# "); 402 fprintf(fp, "# ");
407 for (idx = 0; idx < PERF_HPP__MAX_INDEX; idx++) { 403 for (idx = 0; idx < PERF_HPP__MAX_INDEX; idx++) {
408 unsigned int i; 404 unsigned int i;
@@ -410,8 +406,10 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair,
410 if (!perf_hpp__format[idx].cond) 406 if (!perf_hpp__format[idx].cond)
411 continue; 407 continue;
412 408
413 if (idx) 409 if (!first)
414 fprintf(fp, "%s", sep ?: " "); 410 fprintf(fp, "%s", sep ?: " ");
411 else
412 first = false;
415 413
416 width = perf_hpp__format[idx].width(&dummy_hpp); 414 width = perf_hpp__format[idx].width(&dummy_hpp);
417 for (i = 0; i < width; i++) 415 for (i = 0; i < width; i++)
@@ -441,24 +439,13 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair,
441 goto out; 439 goto out;
442 440
443print_entries: 441print_entries:
444 total_period = hists->stats.total_period;
445
446 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { 442 for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
447 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); 443 struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
448 444
449 if (h->filtered) 445 if (h->filtered)
450 continue; 446 continue;
451 447
452 if (show_displacement) { 448 ret += hist_entry__fprintf(h, max_cols, hists, fp);
453 if (h->pair != NULL)
454 displacement = ((long)h->pair->position -
455 (long)position);
456 else
457 displacement = 0;
458 ++position;
459 }
460 ret += hist_entry__fprintf(h, max_cols, hists, pair, displacement,
461 total_period, fp);
462 449
463 if (max_rows && ++nr_rows >= max_rows) 450 if (max_rows && ++nr_rows >= max_rows)
464 goto out; 451 goto out;