OSDN Git Service

perf trace: Add pointer to BPF object containing __augmented_syscalls__
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 15 Jul 2019 19:58:23 +0000 (16:58 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 29 Jul 2019 21:34:41 +0000 (18:34 -0300)
So that we can use it when looking for other components of that object
file, such as other programs to add to the BPF_MAP_TYPE_PROG_ARRAY and
use with bpf_tail_call().

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-1ibmz7ouv6llqxajy7m8igtd@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-trace.c

index 4f0bbff..6aa0808 100644 (file)
@@ -96,6 +96,7 @@ struct trace {
        struct perf_evlist      *evlist;
        struct machine          *host;
        struct thread           *current;
+       struct bpf_object       *bpf_obj;
        struct cgroup           *cgroup;
        u64                     base_time;
        FILE                    *output;
@@ -3895,6 +3896,20 @@ int cmd_trace(int argc, const char **argv)
 
        if (evsel) {
                trace.syscalls.events.augmented = evsel;
+
+               evsel = perf_evlist__find_tracepoint_by_name(trace.evlist, "raw_syscalls:sys_enter");
+               if (evsel == NULL) {
+                       pr_err("ERROR: raw_syscalls:sys_enter not found in the augmented BPF object\n");
+                       goto out;
+               }
+
+               if (evsel->bpf_obj == NULL) {
+                       pr_err("ERROR: raw_syscalls:sys_enter not associated to a BPF object\n");
+                       goto out;
+               }
+
+               trace.bpf_obj = evsel->bpf_obj;
+
                trace__set_bpf_map_filtered_pids(&trace);
                trace__set_bpf_map_syscalls(&trace);
        }