[PATCH] Add FreeBSD support to sanitizers' procmaps facilities

Alexey Samsonov samsonov at google.com
Wed Mar 19 08:45:36 PDT 2014



================
Comment at: lib/sanitizer_common/sanitizer_procmaps_linux.cc:177
@@ +176,3 @@
+
+  uptr local_protection = 0;
+  if ((VmEntry->kve_protection & KVME_PROT_READ) != 0)
----------------
... and now you can get rid of local_protection (both in FreeBSD and Linux code).

================
Comment at: lib/sanitizer_common/sanitizer_procmaps_linux.cc:186
@@ +185,3 @@
+
+  if (filename != NULL && filename_size > 0)
+    internal_snprintf(filename,
----------------
add {} here

================
Comment at: lib/sanitizer_common/sanitizer_procmaps_linux.cc:188
@@ +187,3 @@
+    internal_snprintf(filename,
+                      Min((size_t)filename_size, (size_t)PATH_MAX),
+                      "%s", VmEntry->kve_path);
----------------
use (uptr)PATH_MAX instead - internal_snprintf takes uptr.

================
Comment at: lib/sanitizer_common/sanitizer_procmaps_linux.cc:34
@@ +33,3 @@
+  const int Mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_VMMAP, getpid() };
+  size_t Size = 0;
+  int Err = sysctl(Mib, 4, NULL, &Size, NULL, 0);
----------------
Can you use uptr here as well? (e.g. that's what MmapOrDie takes)

================
Comment at: lib/sanitizer_common/sanitizer_procmaps_linux.cc:41
@@ +40,3 @@
+  void *VmMap = MmapOrDie(MmapedSize, "ReadProcMaps()");
+  Size = MmapedSize;
+  Err = sysctl(Mib, 4, VmMap, &Size, NULL, 0);
----------------
do you really need this assignment? Why not pass &MmapedSize to sysctl, and leave Size <= MmapedSize?


http://llvm-reviews.chandlerc.com/D3100



More information about the llvm-commits mailing list