[PATCH] Add FreeBSD support to sanitizers' procmaps facilities
Alexey Samsonov
samsonov at google.com
Tue Mar 18 02:29:54 PDT 2014
================
Comment at: lib/sanitizer_common/sanitizer_procmaps_linux.cc:31
@@ -24,1 +30,3 @@
+static void ReadProcMaps(char **data, uptr *data_len, uptr *data_size) {
+#if SANITIZER_FREEBSD
----------------
This function should take pointer to ProcSelfMapsBuff.
================
Comment at: lib/sanitizer_common/sanitizer_procmaps_linux.cc:20
@@ +19,3 @@
+#if SANITIZER_FREEBSD
+#include <unistd.h>
+#include <sys/sysctl.h>
----------------
Please sort the headers.
================
Comment at: lib/sanitizer_common/sanitizer_procmaps_linux.cc:45
@@ +44,3 @@
+
+ *data = (char*) VmMap;
+ *data_len = Size;
----------------
We generally write type conversions as:
*data = (char*)VmMap;
(i.e. w/o extra space after type name). Here and below.
================
Comment at: lib/sanitizer_common/sanitizer_procmaps_linux.cc:181
@@ +180,3 @@
+ *protection =
+ (((VmEntry->kve_protection & KVME_PROT_READ) == 0) ?
+ 0 : kProtectionRead) |
----------------
Please simplify this (as we do in Linux-specific code).
================
Comment at: lib/sanitizer_common/sanitizer_procmaps_linux.cc:191
@@ +190,3 @@
+ Min((size_t) filename_size, (size_t) PATH_MAX));
+ filename[filename_size - 1] = '\0';
+ }
----------------
Consider using internal_snprintf instead of manually setting terminating '/0'
================
Comment at: lib/sanitizer_common/sanitizer_procmaps_linux.cc:285
@@ -229,3 +284,3 @@
void GetMemoryProfile(fill_profile_f cb, uptr *stats, uptr stats_size) {
char *smaps = 0;
----------------
I doubt this function will work on FreeBSD as expected.
http://llvm-reviews.chandlerc.com/D3100
More information about the llvm-commits
mailing list