may happen, for instance, when a thread gets migrated to a different CPU
        while processing a syscall.
 
+--map-dump::
+       Dump BPF maps setup by events passed via -e, for instance the augmented_raw_syscalls
+       living in tools/perf/examples/bpf/augmented_raw_syscalls.c. For now this
+       dumps just boolean map values and integer keys, in time this will print in hex
+       by default and use BTF when available, as well as use functions to do pretty
+       printing using the existing 'perf trace' syscall arg beautifiers to map integer
+       arguments to strings (pid to comm, syscall id to syscall name, etc).
+
 
 PAGEFAULTS
 ----------
 
 #include <traceevent/event-parse.h>
 #include <api/fs/tracing_path.h>
 #include <bpf/bpf.h>
+#include "util/bpf_map.h"
 #include "builtin.h"
 #include "util/cgroup.h"
 #include "util/color.h"
                                          *augmented;
                }               events;
        } syscalls;
+       struct {
+               struct bpf_map *map;
+       } dump;
        struct record_opts      opts;
        struct perf_evlist      *evlist;
        struct machine          *host;
        if (err < 0)
                goto out_error_apply_filters;
 
+       if (trace->dump.map)
+               bpf_map__fprintf(trace->dump.map, trace->output);
+
        err = perf_evlist__mmap(evlist, trace->opts.mmap_pages);
        if (err < 0)
                goto out_error_mmap;
                .max_stack = UINT_MAX,
                .max_events = ULONG_MAX,
        };
+       const char *map_dump_str = NULL;
        const char *output_name = NULL;
        const struct option trace_options[] = {
        OPT_CALLBACK('e', "event", &trace, "event",
        OPT_CALLBACK(0, "duration", &trace, "float",
                     "show only events with duration > N.M ms",
                     trace__set_duration),
+#ifdef HAVE_LIBBPF_SUPPORT
+       OPT_STRING(0, "map-dump", &map_dump_str, "BPF map", "BPF map to periodically dump"),
+#endif
        OPT_BOOLEAN(0, "sched", &trace.sched, "show blocking scheduler events"),
        OPT_INCR('v', "verbose", &verbose, "be more verbose"),
        OPT_BOOLEAN('T', "time", &trace.full_time,
 
        err = -1;
 
+       if (map_dump_str) {
+               trace.dump.map = bpf__find_map_by_name(map_dump_str);
+               if (trace.dump.map == NULL) {
+                       pr_err("ERROR: BPF map \"%s\" not found\n", map_dump_str);
+                       goto out;
+               }
+       }
+
        if (trace.trace_pgfaults) {
                trace.opts.sample_address = true;
                trace.opts.sample_time = true;