aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-script.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r--tools/perf/builtin-script.c60
1 files changed, 19 insertions, 41 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 9e9c91f5b7fa..f57035b89c15 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -358,27 +358,6 @@ static void print_sample_start(struct perf_sample *sample,
358 } 358 }
359} 359}
360 360
361static bool is_bts_event(struct perf_event_attr *attr)
362{
363 return ((attr->type == PERF_TYPE_HARDWARE) &&
364 (attr->config & PERF_COUNT_HW_BRANCH_INSTRUCTIONS) &&
365 (attr->sample_period == 1));
366}
367
368static bool sample_addr_correlates_sym(struct perf_event_attr *attr)
369{
370 if ((attr->type == PERF_TYPE_SOFTWARE) &&
371 ((attr->config == PERF_COUNT_SW_PAGE_FAULTS) ||
372 (attr->config == PERF_COUNT_SW_PAGE_FAULTS_MIN) ||
373 (attr->config == PERF_COUNT_SW_PAGE_FAULTS_MAJ)))
374 return true;
375
376 if (is_bts_event(attr))
377 return true;
378
379 return false;
380}
381
382static void print_sample_addr(union perf_event *event, 361static void print_sample_addr(union perf_event *event,
383 struct perf_sample *sample, 362 struct perf_sample *sample,
384 struct machine *machine, 363 struct machine *machine,
@@ -386,24 +365,13 @@ static void print_sample_addr(union perf_event *event,
386 struct perf_event_attr *attr) 365 struct perf_event_attr *attr)
387{ 366{
388 struct addr_location al; 367 struct addr_location al;
389 u8 cpumode = event->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
390 368
391 printf("%16" PRIx64, sample->addr); 369 printf("%16" PRIx64, sample->addr);
392 370
393 if (!sample_addr_correlates_sym(attr)) 371 if (!sample_addr_correlates_sym(attr))
394 return; 372 return;
395 373
396 thread__find_addr_map(thread, machine, cpumode, MAP__FUNCTION, 374 perf_event__preprocess_sample_addr(event, sample, machine, thread, &al);
397 sample->addr, &al);
398 if (!al.map)
399 thread__find_addr_map(thread, machine, cpumode, MAP__VARIABLE,
400 sample->addr, &al);
401
402 al.cpu = sample->cpu;
403 al.sym = NULL;
404
405 if (al.map)
406 al.sym = map__find_symbol(al.map, al.addr, NULL);
407 375
408 if (PRINT_FIELD(SYM)) { 376 if (PRINT_FIELD(SYM)) {
409 printf(" "); 377 printf(" ");
@@ -427,25 +395,35 @@ static void print_sample_bts(union perf_event *event,
427 struct addr_location *al) 395 struct addr_location *al)
428{ 396{
429 struct perf_event_attr *attr = &evsel->attr; 397 struct perf_event_attr *attr = &evsel->attr;
398 bool print_srcline_last = false;
430 399
431 /* print branch_from information */ 400 /* print branch_from information */
432 if (PRINT_FIELD(IP)) { 401 if (PRINT_FIELD(IP)) {
433 if (!symbol_conf.use_callchain) 402 unsigned int print_opts = output[attr->type].print_ip_opts;
434 printf(" "); 403
435 else 404 if (symbol_conf.use_callchain && sample->callchain) {
436 printf("\n"); 405 printf("\n");
437 perf_evsel__print_ip(evsel, sample, al, 406 } else {
438 output[attr->type].print_ip_opts, 407 printf(" ");
408 if (print_opts & PRINT_IP_OPT_SRCLINE) {
409 print_srcline_last = true;
410 print_opts &= ~PRINT_IP_OPT_SRCLINE;
411 }
412 }
413 perf_evsel__print_ip(evsel, sample, al, print_opts,
439 PERF_MAX_STACK_DEPTH); 414 PERF_MAX_STACK_DEPTH);
440 } 415 }
441 416
442 printf(" => ");
443
444 /* print branch_to information */ 417 /* print branch_to information */
445 if (PRINT_FIELD(ADDR) || 418 if (PRINT_FIELD(ADDR) ||
446 ((evsel->attr.sample_type & PERF_SAMPLE_ADDR) && 419 ((evsel->attr.sample_type & PERF_SAMPLE_ADDR) &&
447 !output[attr->type].user_set)) 420 !output[attr->type].user_set)) {
421 printf(" => ");
448 print_sample_addr(event, sample, al->machine, thread, attr); 422 print_sample_addr(event, sample, al->machine, thread, attr);
423 }
424
425 if (print_srcline_last)
426 map__fprintf_srcline(al->map, al->addr, "\n ", stdout);
449 427
450 printf("\n"); 428 printf("\n");
451} 429}