Commit 8600ffcb authored by Vicent Marti's avatar Vicent Marti Committed by Brenden Blanco

proc: Enhance bcc_mapping_is_file_backed

Cleanup the `strncmp` code and add a few more ignored map names
parent e0d99edf
...@@ -61,14 +61,18 @@ char *bcc_procutils_which(const char *binpath) { ...@@ -61,14 +61,18 @@ char *bcc_procutils_which(const char *binpath) {
return 0; return 0;
} }
#define STARTS_WITH(mapname, prefix) (!strncmp(mapname, prefix, sizeof(prefix)-1))
int bcc_mapping_is_file_backed(const char *mapname) { int bcc_mapping_is_file_backed(const char *mapname) {
return mapname[0] && return mapname[0] && !(
strncmp(mapname, "//anon", sizeof("//anon") - 1) && STARTS_WITH(mapname, "//anon") ||
strncmp(mapname, "/dev/zero", sizeof("/dev/zero") - 1) && STARTS_WITH(mapname, "/dev/zero") ||
strncmp(mapname, "/anon_hugepage", sizeof("/anon_hugepage") - 1) && STARTS_WITH(mapname, "/anon_hugepage") ||
strncmp(mapname, "[stack", sizeof("[stack") - 1) && STARTS_WITH(mapname, "[stack") ||
strncmp(mapname, "/SYSV", sizeof("/SYSV") - 1) && STARTS_WITH(mapname, "/SYSV") ||
strncmp(mapname, "[heap]", sizeof("[heap]") - 1); STARTS_WITH(mapname, "[heap]") ||
STARTS_WITH(mapname, "[vsyscall]") ||
STARTS_WITH(mapname, "[vdso]"));
} }
int bcc_procutils_each_module(int pid, bcc_procutils_modulecb callback, int bcc_procutils_each_module(int pid, bcc_procutils_modulecb callback,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment