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.c81
1 files changed, 31 insertions, 50 deletions
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index d59893edf031..9f57991025a9 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -183,7 +183,8 @@ static size_t callchain__fprintf_graph(FILE *fp, struct rb_root *root,
183 * the symbol. No need to print it otherwise it appears as 183 * the symbol. No need to print it otherwise it appears as
184 * displayed twice. 184 * displayed twice.
185 */ 185 */
186 if (!i++ && sort__first_dimension == SORT_SYM) 186 if (!i++ && field_order == NULL &&
187 sort_order && !prefixcmp(sort_order, "sym"))
187 continue; 188 continue;
188 if (!printed) { 189 if (!printed) {
189 ret += callchain__fprintf_left_margin(fp, left_margin); 190 ret += callchain__fprintf_left_margin(fp, left_margin);
@@ -296,18 +297,24 @@ static size_t hist_entry__callchain_fprintf(struct hist_entry *he,
296 int left_margin = 0; 297 int left_margin = 0;
297 u64 total_period = hists->stats.total_period; 298 u64 total_period = hists->stats.total_period;
298 299
299 if (sort__first_dimension == SORT_COMM) { 300 if (field_order == NULL && (sort_order == NULL ||
300 struct sort_entry *se = list_first_entry(&hist_entry__sort_list, 301 !prefixcmp(sort_order, "comm"))) {
301 typeof(*se), list); 302 struct perf_hpp_fmt *fmt;
302 left_margin = hists__col_len(hists, se->se_width_idx); 303
303 left_margin -= thread__comm_len(he->thread); 304 perf_hpp__for_each_format(fmt) {
304 } 305 if (!perf_hpp__is_sort_entry(fmt))
306 continue;
305 307
308 /* must be 'comm' sort entry */
309 left_margin = fmt->width(fmt, NULL, hists_to_evsel(hists));
310 left_margin -= thread__comm_len(he->thread);
311 break;
312 }
313 }
306 return hist_entry_callchain__fprintf(he, total_period, left_margin, fp); 314 return hist_entry_callchain__fprintf(he, total_period, left_margin, fp);
307} 315}
308 316
309static int hist_entry__period_snprintf(struct perf_hpp *hpp, 317static int hist_entry__snprintf(struct hist_entry *he, struct perf_hpp *hpp)
310 struct hist_entry *he)
311{ 318{
312 const char *sep = symbol_conf.field_sep; 319 const char *sep = symbol_conf.field_sep;
313 struct perf_hpp_fmt *fmt; 320 struct perf_hpp_fmt *fmt;
@@ -319,6 +326,9 @@ static int hist_entry__period_snprintf(struct perf_hpp *hpp,
319 return 0; 326 return 0;
320 327
321 perf_hpp__for_each_format(fmt) { 328 perf_hpp__for_each_format(fmt) {
329 if (perf_hpp__should_skip(fmt))
330 continue;
331
322 /* 332 /*
323 * If there's no field_sep, we still need 333 * If there's no field_sep, we still need
324 * to display initial ' '. 334 * to display initial ' '.
@@ -353,8 +363,7 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size,
353 if (size == 0 || size > bfsz) 363 if (size == 0 || size > bfsz)
354 size = hpp.size = bfsz; 364 size = hpp.size = bfsz;
355 365
356 ret = hist_entry__period_snprintf(&hpp, he); 366 hist_entry__snprintf(he, &hpp);
357 hist_entry__sort_snprintf(he, bf + ret, size - ret, hists);
358 367
359 ret = fprintf(fp, "%s\n", bf); 368 ret = fprintf(fp, "%s\n", bf);
360 369
@@ -368,12 +377,10 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
368 int max_cols, float min_pcnt, FILE *fp) 377 int max_cols, float min_pcnt, FILE *fp)
369{ 378{
370 struct perf_hpp_fmt *fmt; 379 struct perf_hpp_fmt *fmt;
371 struct sort_entry *se;
372 struct rb_node *nd; 380 struct rb_node *nd;
373 size_t ret = 0; 381 size_t ret = 0;
374 unsigned int width; 382 unsigned int width;
375 const char *sep = symbol_conf.field_sep; 383 const char *sep = symbol_conf.field_sep;
376 const char *col_width = symbol_conf.col_width_list_str;
377 int nr_rows = 0; 384 int nr_rows = 0;
378 char bf[96]; 385 char bf[96];
379 struct perf_hpp dummy_hpp = { 386 struct perf_hpp dummy_hpp = {
@@ -386,12 +393,19 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
386 393
387 init_rem_hits(); 394 init_rem_hits();
388 395
396
397 perf_hpp__for_each_format(fmt)
398 perf_hpp__reset_width(fmt, hists);
399
389 if (!show_header) 400 if (!show_header)
390 goto print_entries; 401 goto print_entries;
391 402
392 fprintf(fp, "# "); 403 fprintf(fp, "# ");
393 404
394 perf_hpp__for_each_format(fmt) { 405 perf_hpp__for_each_format(fmt) {
406 if (perf_hpp__should_skip(fmt))
407 continue;
408
395 if (!first) 409 if (!first)
396 fprintf(fp, "%s", sep ?: " "); 410 fprintf(fp, "%s", sep ?: " ");
397 else 411 else
@@ -401,28 +415,6 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
401 fprintf(fp, "%s", bf); 415 fprintf(fp, "%s", bf);
402 } 416 }
403 417
404 list_for_each_entry(se, &hist_entry__sort_list, list) {
405 if (se->elide)
406 continue;
407 if (sep) {
408 fprintf(fp, "%c%s", *sep, se->se_header);
409 continue;
410 }
411 width = strlen(se->se_header);
412 if (symbol_conf.col_width_list_str) {
413 if (col_width) {
414 hists__set_col_len(hists, se->se_width_idx,
415 atoi(col_width));
416 col_width = strchr(col_width, ',');
417 if (col_width)
418 ++col_width;
419 }
420 }
421 if (!hists__new_col_len(hists, se->se_width_idx, width))
422 width = hists__col_len(hists, se->se_width_idx);
423 fprintf(fp, " %*s", width, se->se_header);
424 }
425
426 fprintf(fp, "\n"); 418 fprintf(fp, "\n");
427 if (max_rows && ++nr_rows >= max_rows) 419 if (max_rows && ++nr_rows >= max_rows)
428 goto out; 420 goto out;
@@ -437,6 +429,9 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
437 perf_hpp__for_each_format(fmt) { 429 perf_hpp__for_each_format(fmt) {
438 unsigned int i; 430 unsigned int i;
439 431
432 if (perf_hpp__should_skip(fmt))
433 continue;
434
440 if (!first) 435 if (!first)
441 fprintf(fp, "%s", sep ?: " "); 436 fprintf(fp, "%s", sep ?: " ");
442 else 437 else
@@ -447,20 +442,6 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
447 fprintf(fp, "."); 442 fprintf(fp, ".");
448 } 443 }
449 444
450 list_for_each_entry(se, &hist_entry__sort_list, list) {
451 unsigned int i;
452
453 if (se->elide)
454 continue;
455
456 fprintf(fp, " ");
457 width = hists__col_len(hists, se->se_width_idx);
458 if (width == 0)
459 width = strlen(se->se_header);
460 for (i = 0; i < width; i++)
461 fprintf(fp, ".");
462 }
463
464 fprintf(fp, "\n"); 445 fprintf(fp, "\n");
465 if (max_rows && ++nr_rows >= max_rows) 446 if (max_rows && ++nr_rows >= max_rows)
466 goto out; 447 goto out;
@@ -495,7 +476,7 @@ print_entries:
495 break; 476 break;
496 477
497 if (h->ms.map == NULL && verbose > 1) { 478 if (h->ms.map == NULL && verbose > 1) {
498 __map_groups__fprintf_maps(&h->thread->mg, 479 __map_groups__fprintf_maps(h->thread->mg,
499 MAP__FUNCTION, verbose, fp); 480 MAP__FUNCTION, verbose, fp);
500 fprintf(fp, "%.10s end\n", graph_dotted_line); 481 fprintf(fp, "%.10s end\n", graph_dotted_line);
501 } 482 }