Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf probe: Use perf_probe_event.target instead of passing as an argument

Use perf_probe_event.target field for the target binary instead of
passing it as an argument.

Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20150508010328.24812.67887.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Masami Hiramatsu and committed by
Arnaldo Carvalho de Melo
44225521 598adc5c

+27 -33
-1
tools/perf/builtin-probe.c
··· 478 478 479 479 ret = show_available_vars(params.events, params.nevents, 480 480 params.max_probe_points, 481 - params.target, 482 481 params.filter, 483 482 params.show_ext_vars); 484 483 if (ret < 0)
+25 -30
tools/perf/util/probe-event.c
··· 344 344 345 345 static int get_alternative_probe_event(struct debuginfo *dinfo, 346 346 struct perf_probe_event *pev, 347 - struct perf_probe_point *tmp, 348 - const char *target) 347 + struct perf_probe_point *tmp) 349 348 { 350 349 int ret; 351 350 352 351 memcpy(tmp, &pev->point, sizeof(*tmp)); 353 352 memset(&pev->point, 0, sizeof(pev->point)); 354 353 ret = find_alternative_probe_point(dinfo, tmp, &pev->point, 355 - target, pev->uprobes); 354 + pev->target, pev->uprobes); 356 355 if (ret < 0) 357 356 memcpy(&pev->point, tmp, sizeof(*tmp)); 358 357 ··· 600 601 /* Try to find perf_probe_event with debuginfo */ 601 602 static int try_to_find_probe_trace_events(struct perf_probe_event *pev, 602 603 struct probe_trace_event **tevs, 603 - int max_tevs, const char *target) 604 + int max_tevs) 604 605 { 605 606 bool need_dwarf = perf_probe_event_need_dwarf(pev); 606 607 struct perf_probe_point tmp; 607 608 struct debuginfo *dinfo; 608 609 int ntevs, ret = 0; 609 610 610 - dinfo = open_debuginfo(target, !need_dwarf); 611 - 611 + dinfo = open_debuginfo(pev->target, !need_dwarf); 612 612 if (!dinfo) { 613 613 if (need_dwarf) 614 614 return -ENOENT; ··· 620 622 ntevs = debuginfo__find_trace_events(dinfo, pev, tevs, max_tevs); 621 623 622 624 if (ntevs == 0) { /* Not found, retry with an alternative */ 623 - ret = get_alternative_probe_event(dinfo, pev, &tmp, target); 625 + ret = get_alternative_probe_event(dinfo, pev, &tmp); 624 626 if (!ret) { 625 627 ntevs = debuginfo__find_trace_events(dinfo, pev, 626 628 tevs, max_tevs); ··· 638 640 if (ntevs > 0) { /* Succeeded to find trace events */ 639 641 pr_debug("Found %d probe_trace_events.\n", ntevs); 640 642 ret = post_process_probe_trace_events(*tevs, ntevs, 641 - target, pev->uprobes); 643 + pev->target, pev->uprobes); 642 644 if (ret < 0 || ret == ntevs) { 643 645 clear_probe_trace_events(*tevs, ntevs); 644 646 zfree(tevs); ··· 822 824 static int show_available_vars_at(struct debuginfo *dinfo, 823 825 struct perf_probe_event *pev, 824 826 int max_vls, struct strfilter *_filter, 825 - bool externs, const char *target) 827 + bool externs) 826 828 { 827 829 char *buf; 828 830 int ret, i, nvars; ··· 839 841 ret = debuginfo__find_available_vars_at(dinfo, pev, &vls, 840 842 max_vls, externs); 841 843 if (!ret) { /* Not found, retry with an alternative */ 842 - ret = get_alternative_probe_event(dinfo, pev, &tmp, target); 844 + ret = get_alternative_probe_event(dinfo, pev, &tmp); 843 845 if (!ret) { 844 846 ret = debuginfo__find_available_vars_at(dinfo, pev, 845 847 &vls, max_vls, externs); ··· 889 891 890 892 /* Show available variables on given probe point */ 891 893 int show_available_vars(struct perf_probe_event *pevs, int npevs, 892 - int max_vls, const char *module, 893 - struct strfilter *_filter, bool externs) 894 + int max_vls, struct strfilter *_filter, bool externs) 894 895 { 895 896 int i, ret = 0; 896 897 struct debuginfo *dinfo; ··· 898 901 if (ret < 0) 899 902 return ret; 900 903 901 - dinfo = open_debuginfo(module, false); 904 + dinfo = open_debuginfo(pevs->target, false); 902 905 if (!dinfo) { 903 906 ret = -ENOENT; 904 907 goto out; ··· 908 911 909 912 for (i = 0; i < npevs && ret >= 0; i++) 910 913 ret = show_available_vars_at(dinfo, &pevs[i], max_vls, _filter, 911 - externs, module); 914 + externs); 912 915 913 916 debuginfo__delete(dinfo); 914 917 out: ··· 928 931 929 932 static int try_to_find_probe_trace_events(struct perf_probe_event *pev, 930 933 struct probe_trace_event **tevs __maybe_unused, 931 - int max_tevs __maybe_unused, 932 - const char *target __maybe_unused) 934 + int max_tevs __maybe_unused) 933 935 { 934 936 if (perf_probe_event_need_dwarf(pev)) { 935 937 pr_warning("Debuginfo-analysis is not supported.\n"); ··· 948 952 949 953 int show_available_vars(struct perf_probe_event *pevs __maybe_unused, 950 954 int npevs __maybe_unused, int max_vls __maybe_unused, 951 - const char *module __maybe_unused, 952 955 struct strfilter *filter __maybe_unused, 953 956 bool externs __maybe_unused) 954 957 { ··· 2515 2520 */ 2516 2521 static int find_probe_trace_events_from_map(struct perf_probe_event *pev, 2517 2522 struct probe_trace_event **tevs, 2518 - int max_tevs, const char *target) 2523 + int max_tevs) 2519 2524 { 2520 2525 struct map *map = NULL; 2521 2526 struct ref_reloc_sym *reloc_sym = NULL; ··· 2526 2531 int num_matched_functions; 2527 2532 int ret, i; 2528 2533 2529 - map = get_target_map(target, pev->uprobes); 2534 + map = get_target_map(pev->target, pev->uprobes); 2530 2535 if (!map) { 2531 2536 ret = -EINVAL; 2532 2537 goto out; ··· 2539 2544 num_matched_functions = find_probe_functions(map, pp->function); 2540 2545 if (num_matched_functions == 0) { 2541 2546 pr_err("Failed to find symbol %s in %s\n", pp->function, 2542 - target ? : "kernel"); 2547 + pev->target ? : "kernel"); 2543 2548 ret = -ENOENT; 2544 2549 goto out; 2545 2550 } else if (num_matched_functions > max_tevs) { 2546 2551 pr_err("Too many functions matched in %s\n", 2547 - target ? : "kernel"); 2552 + pev->target ? : "kernel"); 2548 2553 ret = -E2BIG; 2549 2554 goto out; 2550 2555 } ··· 2592 2597 tp->offset = pp->offset; 2593 2598 } 2594 2599 tp->retprobe = pp->retprobe; 2595 - if (target) 2596 - tev->point.module = strdup_or_goto(target, nomem_out); 2600 + if (pev->target) 2601 + tev->point.module = strdup_or_goto(pev->target, 2602 + nomem_out); 2597 2603 tev->uprobes = pev->uprobes; 2598 2604 tev->nargs = pev->nargs; 2599 2605 if (tev->nargs) { ··· 2635 2639 2636 2640 static int convert_to_probe_trace_events(struct perf_probe_event *pev, 2637 2641 struct probe_trace_event **tevs, 2638 - int max_tevs, const char *target) 2642 + int max_tevs) 2639 2643 { 2640 2644 int ret; 2641 2645 2642 2646 if (pev->uprobes && !pev->group) { 2643 2647 /* Replace group name if not given */ 2644 - ret = convert_exec_to_group(target, &pev->group); 2648 + ret = convert_exec_to_group(pev->target, &pev->group); 2645 2649 if (ret != 0) { 2646 2650 pr_warning("Failed to make a group name.\n"); 2647 2651 return ret; ··· 2649 2653 } 2650 2654 2651 2655 if (arch__prefers_symtab() && !perf_probe_event_need_dwarf(pev)) { 2652 - ret = find_probe_trace_events_from_map(pev, tevs, max_tevs, target); 2656 + ret = find_probe_trace_events_from_map(pev, tevs, max_tevs); 2653 2657 if (ret > 0) 2654 2658 return ret; /* Found in symbol table */ 2655 2659 } 2656 2660 2657 2661 /* Convert perf_probe_event with debuginfo */ 2658 - ret = try_to_find_probe_trace_events(pev, tevs, max_tevs, target); 2662 + ret = try_to_find_probe_trace_events(pev, tevs, max_tevs); 2659 2663 if (ret != 0) 2660 2664 return ret; /* Found in debuginfo or got an error */ 2661 2665 2662 - return find_probe_trace_events_from_map(pev, tevs, max_tevs, target); 2666 + return find_probe_trace_events_from_map(pev, tevs, max_tevs); 2663 2667 } 2664 2668 2665 2669 struct __event_package { ··· 2692 2696 /* Convert with or without debuginfo */ 2693 2697 ret = convert_to_probe_trace_events(pkgs[i].pev, 2694 2698 &pkgs[i].tevs, 2695 - max_tevs, 2696 - pkgs[i].pev->target); 2699 + max_tevs); 2697 2700 if (ret < 0) 2698 2701 goto end; 2699 2702 pkgs[i].ntevs = ret;
+2 -2
tools/perf/util/probe-event.h
··· 131 131 extern int show_line_range(struct line_range *lr, const char *module, 132 132 bool user); 133 133 extern int show_available_vars(struct perf_probe_event *pevs, int npevs, 134 - int max_probe_points, const char *module, 135 - struct strfilter *filter, bool externs); 134 + int max_probe_points, struct strfilter *filter, 135 + bool externs); 136 136 extern int show_available_funcs(const char *module, struct strfilter *filter, 137 137 bool user); 138 138 bool arch__prefers_symtab(void);