If multiple executables (-x) are specified with 'perf probe',
listing variables only considers first executable. Ex,

  $ perf probe -V do_sys_open -x ./test -V fun
    Failed to find debug information for address 40
    Debuginfo analysis failed.
      Error: Failed to show vars.
    Available variables at do_sys_open
            @<do_sys_open+0>
                    char*   filename
                    int     dfd
                    int     flags
                    struct open_flags       op
                    umode_t mode

Here, first executable is kernel and second is 'test'. Instead
of finding 'fun()' from 'test', perf is looking for 'fun()' in
kernel. Fix this by restricting user to use only one executable
with -V.

  $ perf probe -V do_sys_open -x ./test -V fun
    Error: Multiple executables are not allowed.

  $ perf probe -V do_sys_open 
    Available variables at do_sys_open
            @<do_sys_open+0>
                    char*   filename
                    int     dfd
                    int     flags
                    struct open_flags       op
                    umode_t mode

  $ perf probe -x ./test -V fun
    Available variables at fun
            @<fun+0>
                    int     arg

Signed-off-by: Ravi Bangoria <ravi.bango...@linux.vnet.ibm.com>
---
 tools/perf/util/probe-event.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index b7aaf9b..0e04015 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1128,6 +1128,11 @@ int show_available_vars(struct perf_probe_event *pevs, 
int npevs,
        int i, ret = 0;
        struct debuginfo *dinfo;
 
+       if (npevs > 1) {
+               pr_err("Error: Multiple executables are not allowed.\n");
+               return 0;
+       }
+
        ret = init_probe_symbol_maps(pevs->uprobes);
        if (ret < 0)
                return ret;
-- 
1.8.3.1

Reply via email to