[PATCH] Support getting process maps for sanitizers needs on FreeBSD in 32-bit mode

Viktor Kutuzov vkutuzov at accesssoftek.com
Wed Aug 6 05:53:18 PDT 2014


Hi kcc, samsonov,

http://reviews.llvm.org/D4807

Files:
  lib/sanitizer_common/sanitizer_freebsd.h
  lib/sanitizer_common/sanitizer_procmaps_freebsd.cc

Index: lib/sanitizer_common/sanitizer_freebsd.h
===================================================================
--- lib/sanitizer_common/sanitizer_freebsd.h
+++ lib/sanitizer_common/sanitizer_freebsd.h
@@ -23,10 +23,13 @@
 # include <osreldate.h>
 # if __FreeBSD_version <= 902001  // v9.2
 #  include <link.h>
+#  include <sys/param.h>
 #  include <ucontext.h>
 
 namespace __sanitizer {
 
+typedef unsigned long long __xuint64_t;
+
 typedef __int32_t __xregister_t;
 
 typedef struct __xmcontext {
@@ -75,6 +78,29 @@
   int __spare__[4];
 } xucontext_t;
 
+struct xkinfo_vmentry {
+  int kve_structsize;
+  int kve_type;
+  __xuint64_t kve_start;
+  __xuint64_t kve_end;
+  __xuint64_t kve_offset;
+  __xuint64_t kve_vn_fileid;
+  __uint32_t kve_vn_fsid;
+  int kve_flags;
+  int kve_resident;
+  int kve_private_resident;
+  int kve_protection;
+  int kve_ref_count;
+  int kve_shadow_count;
+  int kve_vn_type;
+  __xuint64_t kve_vn_size;
+  __uint32_t kve_vn_rdev;
+  __uint16_t kve_vn_mode;
+  __uint16_t kve_status;
+  int _kve_ispare[12];
+  char kve_path[PATH_MAX];
+};
+
 typedef struct {
   __uint32_t p_type;
   __uint32_t p_offset;
Index: lib/sanitizer_common/sanitizer_procmaps_freebsd.cc
===================================================================
--- lib/sanitizer_common/sanitizer_procmaps_freebsd.cc
+++ lib/sanitizer_common/sanitizer_procmaps_freebsd.cc
@@ -20,6 +20,14 @@
 #include <sys/sysctl.h>
 #include <sys/user.h>
 
+// Fix 'kinfo_vmentry' definition on FreeBSD prior v9.2 in 32-bit mode.
+#if SANITIZER_FREEBSD && (SANITIZER_WORDSIZE == 32)
+# include <osreldate.h>
+# if __FreeBSD_version <= 902001  // v9.2
+#  define kinfo_vmentry xkinfo_vmentry
+# endif
+#endif
+
 namespace __sanitizer {
 
 void ReadProcMaps(ProcSelfMapsBuff *proc_maps) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4807.12230.patch
Type: text/x-patch
Size: 1784 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140806/d34286e5/attachment.bin>


More information about the llvm-commits mailing list