Wed Jun 14 12:16:27 2017 UTC ()
Detach <sys/user.h> from sanitizer_procmaps_netbsd.cc (GCC)

This header in this context is freebsdism.

Sponsored by <The NetBSD Foundation>


(kamil)
diff -r1.2 -r1.3 src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_procmaps_netbsd.cc

cvs diff -r1.2 -r1.3 src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/Attic/sanitizer_procmaps_netbsd.cc (switch to unified diff)

--- src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/Attic/sanitizer_procmaps_netbsd.cc 2016/06/01 04:06:15 1.2
+++ src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/Attic/sanitizer_procmaps_netbsd.cc 2017/06/14 12:16:27 1.3
@@ -1,78 +1,77 @@ @@ -1,78 +1,77 @@
1//===-- sanitizer_procmaps_freebsd.cc -------------------------------------===// 1//===-- sanitizer_procmaps_freebsd.cc -------------------------------------===//
2// 2//
3// This file is distributed under the University of Illinois Open Source 3// This file is distributed under the University of Illinois Open Source
4// License. See LICENSE.TXT for details. 4// License. See LICENSE.TXT for details.
5// 5//
6//===----------------------------------------------------------------------===// 6//===----------------------------------------------------------------------===//
7// 7//
8// Information about the process mappings (FreeBSD-specific parts). 8// Information about the process mappings (FreeBSD-specific parts).
9//===----------------------------------------------------------------------===// 9//===----------------------------------------------------------------------===//
10 10
11#include "sanitizer_platform.h" 11#include "sanitizer_platform.h"
12#if SANITIZER_NETBSD 12#if SANITIZER_NETBSD
13#include "sanitizer_common.h" 13#include "sanitizer_common.h"
14#include "sanitizer_procmaps.h" 14#include "sanitizer_procmaps.h"
15 15
16#include <unistd.h> 16#include <unistd.h>
17#include <sys/sysctl.h> 17#include <sys/sysctl.h>
18#include <sys/user.h> 
19 18
20namespace __sanitizer { 19namespace __sanitizer {
21 20
22void ReadProcMaps(ProcSelfMapsBuff *proc_maps) { 21void ReadProcMaps(ProcSelfMapsBuff *proc_maps) {
23 struct kinfo_vmentry *kiv; 22 struct kinfo_vmentry *kiv;
24 const int Mib[] = { CTL_VM, VM_PROC, VM_PROC_MAP, getpid(), sizeof(*kiv) }; 23 const int Mib[] = { CTL_VM, VM_PROC, VM_PROC_MAP, getpid(), sizeof(*kiv) };
25 size_t Size = 0; 24 size_t Size = 0;
26 int Err = sysctl(Mib, __arraycount(Mib), NULL, &Size, NULL, 0); 25 int Err = sysctl(Mib, __arraycount(Mib), NULL, &Size, NULL, 0);
27 CHECK_EQ(Err, 0); 26 CHECK_EQ(Err, 0);
28 CHECK_GT(Size, 0); 27 CHECK_GT(Size, 0);
29 28
30 size_t MmapedSize = Size * 4 / 3; 29 size_t MmapedSize = Size * 4 / 3;
31 void *VmMap = MmapOrDie(MmapedSize, "ReadProcMaps()"); 30 void *VmMap = MmapOrDie(MmapedSize, "ReadProcMaps()");
32 Size = MmapedSize; 31 Size = MmapedSize;
33 Err = sysctl(Mib, __arraycount(Mib), VmMap, &Size, NULL, 0); 32 Err = sysctl(Mib, __arraycount(Mib), VmMap, &Size, NULL, 0);
34 CHECK_EQ(Err, 0); 33 CHECK_EQ(Err, 0);
35 34
36 proc_maps->data = (char*)VmMap; 35 proc_maps->data = (char*)VmMap;
37 proc_maps->mmaped_size = MmapedSize; 36 proc_maps->mmaped_size = MmapedSize;
38 proc_maps->len = Size; 37 proc_maps->len = Size;
39} 38}
40 39
41bool MemoryMappingLayout::Next(uptr *start, uptr *end, uptr *offset, 40bool MemoryMappingLayout::Next(uptr *start, uptr *end, uptr *offset,
42 char filename[], uptr filename_size, 41 char filename[], uptr filename_size,
43 uptr *protection) { 42 uptr *protection) {
44 char *last = proc_self_maps_.data + proc_self_maps_.len; 43 char *last = proc_self_maps_.data + proc_self_maps_.len;
45 if (current_ >= last) return false; 44 if (current_ >= last) return false;
46 uptr dummy; 45 uptr dummy;
47 if (!start) start = &dummy; 46 if (!start) start = &dummy;
48 if (!end) end = &dummy; 47 if (!end) end = &dummy;
49 if (!offset) offset = &dummy; 48 if (!offset) offset = &dummy;
50 if (!protection) protection = &dummy; 49 if (!protection) protection = &dummy;
51 struct kinfo_vmentry *VmEntry = (struct kinfo_vmentry*)current_; 50 struct kinfo_vmentry *VmEntry = (struct kinfo_vmentry*)current_;
52 51
53 *start = (uptr)VmEntry->kve_start; 52 *start = (uptr)VmEntry->kve_start;
54 *end = (uptr)VmEntry->kve_end; 53 *end = (uptr)VmEntry->kve_end;
55 *offset = (uptr)VmEntry->kve_offset; 54 *offset = (uptr)VmEntry->kve_offset;
56 55
57 *protection = 0; 56 *protection = 0;
58 if ((VmEntry->kve_protection & KVME_PROT_READ) != 0) 57 if ((VmEntry->kve_protection & KVME_PROT_READ) != 0)
59 *protection |= kProtectionRead; 58 *protection |= kProtectionRead;
60 if ((VmEntry->kve_protection & KVME_PROT_WRITE) != 0) 59 if ((VmEntry->kve_protection & KVME_PROT_WRITE) != 0)
61 *protection |= kProtectionWrite; 60 *protection |= kProtectionWrite;
62 if ((VmEntry->kve_protection & KVME_PROT_EXEC) != 0) 61 if ((VmEntry->kve_protection & KVME_PROT_EXEC) != 0)
63 *protection |= kProtectionExecute; 62 *protection |= kProtectionExecute;
64 63
65 if (filename != NULL && filename_size > 0) { 64 if (filename != NULL && filename_size > 0) {
66 internal_snprintf(filename, 65 internal_snprintf(filename,
67 Min(filename_size, (uptr)PATH_MAX), 66 Min(filename_size, (uptr)PATH_MAX),
68 "%s", VmEntry->kve_path); 67 "%s", VmEntry->kve_path);
69 } 68 }
70 69
71 current_ += sizeof(*VmEntry); 70 current_ += sizeof(*VmEntry);
72 71
73 return true; 72 return true;
74} 73}
75 74
76} // namespace __sanitizer 75} // namespace __sanitizer
77 76
78#endif // SANITIZER_NETBSD 77#endif // SANITIZER_NETBSD