samples/bpf: add example to test reading address
[linux-2.6-microblaze.git] / samples / bpf / trace_event_kern.c
index a77a583..7068fbd 100644 (file)
@@ -39,6 +39,7 @@ int bpf_prog1(struct bpf_perf_event_data *ctx)
 {
        char time_fmt1[] = "Time Enabled: %llu, Time Running: %llu";
        char time_fmt2[] = "Get Time Failed, ErrCode: %d";
+       char addr_fmt[] = "Address recorded on event: %llx";
        char fmt[] = "CPU-%d period %lld ip %llx";
        u32 cpu = bpf_get_smp_processor_id();
        struct bpf_perf_event_value value_buf;
@@ -64,6 +65,9 @@ int bpf_prog1(struct bpf_perf_event_data *ctx)
        else
          bpf_trace_printk(time_fmt2, sizeof(time_fmt2), ret);
 
+       if (ctx->addr != 0)
+         bpf_trace_printk(addr_fmt, sizeof(addr_fmt), ctx->addr);
+
        val = bpf_map_lookup_elem(&counts, &key);
        if (val)
                (*val)++;