aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-script.c36
-rw-r--r--tools/perf/builtin-trace.c8
-rw-r--r--tools/perf/util/evsel.c39
-rw-r--r--tools/perf/util/evsel.h19
4 files changed, 48 insertions, 54 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 717ba0215234..875d84e7ba5b 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -569,19 +569,23 @@ static void print_sample_bts(struct perf_sample *sample,
569 /* print branch_from information */ 569 /* print branch_from information */
570 if (PRINT_FIELD(IP)) { 570 if (PRINT_FIELD(IP)) {
571 unsigned int print_opts = output[attr->type].print_ip_opts; 571 unsigned int print_opts = output[attr->type].print_ip_opts;
572 struct callchain_cursor *cursor = NULL, cursor_callchain;
572 573
573 if (symbol_conf.use_callchain && sample->callchain) { 574 if (symbol_conf.use_callchain && sample->callchain &&
574 printf("\n"); 575 thread__resolve_callchain(al->thread, &cursor_callchain, evsel,
575 } else { 576 sample, NULL, NULL, scripting_max_stack) == 0)
576 printf(" "); 577 cursor = &cursor_callchain;
578
579 if (cursor == NULL) {
580 putchar(' ');
577 if (print_opts & EVSEL__PRINT_SRCLINE) { 581 if (print_opts & EVSEL__PRINT_SRCLINE) {
578 print_srcline_last = true; 582 print_srcline_last = true;
579 print_opts &= ~EVSEL__PRINT_SRCLINE; 583 print_opts &= ~EVSEL__PRINT_SRCLINE;
580 } 584 }
581 } 585 } else
582 perf_evsel__fprintf_sym(evsel, sample, al, 0, print_opts, 586 putchar('\n');
583 symbol_conf.use_callchain, 587
584 scripting_max_stack, stdout); 588 sample__fprintf_sym(sample, al, 0, print_opts, cursor, stdout);
585 } 589 }
586 590
587 /* print branch_to information */ 591 /* print branch_to information */
@@ -784,15 +788,15 @@ static void process_event(struct perf_script *script,
784 printf("%16" PRIu64, sample->weight); 788 printf("%16" PRIu64, sample->weight);
785 789
786 if (PRINT_FIELD(IP)) { 790 if (PRINT_FIELD(IP)) {
787 if (!symbol_conf.use_callchain) 791 struct callchain_cursor *cursor = NULL, cursor_callchain;
788 printf(" "); 792
789 else 793 if (symbol_conf.use_callchain &&
790 printf("\n"); 794 thread__resolve_callchain(al->thread, &cursor_callchain, evsel,
795 sample, NULL, NULL, scripting_max_stack) == 0)
796 cursor = &cursor_callchain;
791 797
792 perf_evsel__fprintf_sym(evsel, sample, al, 0, 798 putchar(cursor ? '\n' : ' ');
793 output[attr->type].print_ip_opts, 799 sample__fprintf_sym(sample, al, 0, output[attr->type].print_ip_opts, cursor, stdout);
794 symbol_conf.use_callchain,
795 scripting_max_stack, stdout);
796 } 800 }
797 801
798 if (PRINT_FIELD(IREGS)) 802 if (PRINT_FIELD(IREGS))
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index e5f0cc16bb93..0e2a82bda22f 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1890,14 +1890,16 @@ static int trace__fprintf_callchain(struct trace *trace, struct perf_evsel *evse
1890 if (sample->callchain == NULL) 1890 if (sample->callchain == NULL)
1891 return 0; 1891 return 0;
1892 1892
1893 if (machine__resolve(trace->host, &al, sample) < 0) { 1893 if (machine__resolve(trace->host, &al, sample) < 0 ||
1894 thread__resolve_callchain(al.thread, &callchain_cursor, evsel,
1895 sample, NULL, NULL, scripting_max_stack)) {
1894 pr_err("Problem processing %s callchain, skipping...\n", 1896 pr_err("Problem processing %s callchain, skipping...\n",
1895 perf_evsel__name(evsel)); 1897 perf_evsel__name(evsel));
1896 return 0; 1898 return 0;
1897 } 1899 }
1898 1900
1899 return perf_evsel__fprintf_callchain(evsel, sample, &al, 38, print_opts, 1901 return sample__fprintf_callchain(sample, &al, 38, print_opts,
1900 scripting_max_stack, trace->output); 1902 &callchain_cursor, trace->output);
1901} 1903}
1902 1904
1903static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel, 1905static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 60bba67e6959..35c5a5282239 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2343,13 +2343,12 @@ out:
2343 return ++printed; 2343 return ++printed;
2344} 2344}
2345 2345
2346int perf_evsel__fprintf_callchain(struct perf_evsel *evsel, struct perf_sample *sample, 2346int sample__fprintf_callchain(struct perf_sample *sample,
2347 struct addr_location *al, int left_alignment, 2347 struct addr_location *al, int left_alignment,
2348 unsigned int print_opts, unsigned int stack_depth, 2348 unsigned int print_opts, struct callchain_cursor *cursor,
2349 FILE *fp) 2349 FILE *fp)
2350{ 2350{
2351 int printed = 0; 2351 int printed = 0;
2352 struct callchain_cursor cursor;
2353 struct callchain_cursor_node *node; 2352 struct callchain_cursor_node *node;
2354 int print_ip = print_opts & EVSEL__PRINT_IP; 2353 int print_ip = print_opts & EVSEL__PRINT_IP;
2355 int print_sym = print_opts & EVSEL__PRINT_SYM; 2354 int print_sym = print_opts & EVSEL__PRINT_SYM;
@@ -2363,22 +2362,15 @@ int perf_evsel__fprintf_callchain(struct perf_evsel *evsel, struct perf_sample *
2363 if (sample->callchain) { 2362 if (sample->callchain) {
2364 struct addr_location node_al; 2363 struct addr_location node_al;
2365 2364
2366 if (thread__resolve_callchain(al->thread, &cursor, evsel, 2365 callchain_cursor_commit(cursor);
2367 sample, NULL, NULL,
2368 stack_depth) != 0) {
2369 if (verbose)
2370 error("Failed to resolve callchain. Skipping\n");
2371 return printed;
2372 }
2373 callchain_cursor_commit(&cursor);
2374 2366
2375 if (print_symoffset) 2367 if (print_symoffset)
2376 node_al = *al; 2368 node_al = *al;
2377 2369
2378 while (stack_depth) { 2370 while (1) {
2379 u64 addr = 0; 2371 u64 addr = 0;
2380 2372
2381 node = callchain_cursor_current(&cursor); 2373 node = callchain_cursor_current(cursor);
2382 if (!node) 2374 if (!node)
2383 break; 2375 break;
2384 2376
@@ -2418,20 +2410,17 @@ int perf_evsel__fprintf_callchain(struct perf_evsel *evsel, struct perf_sample *
2418 2410
2419 if (!print_oneline) 2411 if (!print_oneline)
2420 printed += fprintf(fp, "\n"); 2412 printed += fprintf(fp, "\n");
2421
2422 stack_depth--;
2423next: 2413next:
2424 callchain_cursor_advance(&cursor); 2414 callchain_cursor_advance(cursor);
2425 } 2415 }
2426 } 2416 }
2427 2417
2428 return printed; 2418 return printed;
2429} 2419}
2430 2420
2431int perf_evsel__fprintf_sym(struct perf_evsel *evsel, struct perf_sample *sample, 2421int sample__fprintf_sym(struct perf_sample *sample, struct addr_location *al,
2432 struct addr_location *al, int left_alignment, 2422 int left_alignment, unsigned int print_opts,
2433 unsigned int print_opts, bool print_callchain, 2423 struct callchain_cursor *cursor, FILE *fp)
2434 unsigned int stack_depth, FILE *fp)
2435{ 2424{
2436 int printed = 0; 2425 int printed = 0;
2437 int print_ip = print_opts & EVSEL__PRINT_IP; 2426 int print_ip = print_opts & EVSEL__PRINT_IP;
@@ -2441,9 +2430,9 @@ int perf_evsel__fprintf_sym(struct perf_evsel *evsel, struct perf_sample *sample
2441 int print_srcline = print_opts & EVSEL__PRINT_SRCLINE; 2430 int print_srcline = print_opts & EVSEL__PRINT_SRCLINE;
2442 int print_unknown_as_addr = print_opts & EVSEL__PRINT_UNKNOWN_AS_ADDR; 2431 int print_unknown_as_addr = print_opts & EVSEL__PRINT_UNKNOWN_AS_ADDR;
2443 2432
2444 if (print_callchain && sample->callchain) { 2433 if (cursor != NULL) {
2445 printed += perf_evsel__fprintf_callchain(evsel, sample, al, left_alignment, 2434 printed += sample__fprintf_callchain(sample, al, left_alignment,
2446 print_opts, stack_depth, fp); 2435 print_opts, cursor, fp);
2447 } else if (!(al->sym && al->sym->ignore)) { 2436 } else if (!(al->sym && al->sym->ignore)) {
2448 printed += fprintf(fp, "%-*.*s", left_alignment, left_alignment, " "); 2437 printed += fprintf(fp, "%-*.*s", left_alignment, left_alignment, " ");
2449 2438
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 013f3615730b..abadfea1dbaa 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -395,16 +395,15 @@ int perf_evsel__fprintf(struct perf_evsel *evsel,
395#define EVSEL__PRINT_SRCLINE (1<<5) 395#define EVSEL__PRINT_SRCLINE (1<<5)
396#define EVSEL__PRINT_UNKNOWN_AS_ADDR (1<<6) 396#define EVSEL__PRINT_UNKNOWN_AS_ADDR (1<<6)
397 397
398int perf_evsel__fprintf_callchain(struct perf_evsel *evsel, 398struct callchain_cursor;
399 struct perf_sample *sample, 399
400 struct addr_location *al, int left_alignment, 400int sample__fprintf_callchain(struct perf_sample *sample, struct addr_location *al,
401 unsigned int print_opts, 401 int left_alignment, unsigned int print_opts,
402 unsigned int stack_depth, FILE *fp); 402 struct callchain_cursor *cursor, FILE *fp);
403 403
404int perf_evsel__fprintf_sym(struct perf_evsel *evsel, struct perf_sample *sample, 404int sample__fprintf_sym(struct perf_sample *sample, struct addr_location *al,
405 struct addr_location *al, int left_alignment, 405 int left_alignment, unsigned int print_opts,
406 unsigned int print_opts, bool print_callchain, 406 struct callchain_cursor *cursor, FILE *fp);
407 unsigned int stack_depth, FILE *fp);
408 407
409bool perf_evsel__fallback(struct perf_evsel *evsel, int err, 408bool perf_evsel__fallback(struct perf_evsel *evsel, int err,
410 char *msg, size_t msgsize); 409 char *msg, size_t msgsize);