]> git.ipfire.org Git - thirdparty/kernel/linux.git/blobdiff - tools/perf/util/map.c
perf tools: Check maps for bpf programs
[thirdparty/kernel/linux.git] / tools / perf / util / map.c
index e32628cd20a7f36e0e06efb3ee5c2e6cae09dabb..28d484ef74ae88ae2a8d4ee00987fda55754c9ab 100644 (file)
@@ -261,6 +261,22 @@ bool __map__is_extra_kernel_map(const struct map *map)
        return kmap && kmap->name[0];
 }
 
+bool __map__is_bpf_prog(const struct map *map)
+{
+       const char *name;
+
+       if (map->dso->binary_type == DSO_BINARY_TYPE__BPF_PROG_INFO)
+               return true;
+
+       /*
+        * If PERF_RECORD_BPF_EVENT is not included, the dso will not have
+        * type of DSO_BINARY_TYPE__BPF_PROG_INFO. In such cases, we can
+        * guess the type based on name.
+        */
+       name = map->dso->short_name;
+       return name && (strstr(name, "bpf_prog_") == name);
+}
+
 bool map__has_symbols(const struct map *map)
 {
        return dso__has_symbols(map->dso);