[PATCH] Make caching of memory mappings in sanitizer_procmaps optional
Sergey Matveev
earthdok at google.com
Fri Mar 22 10:13:26 PDT 2013
- addressed comments by glider
Hi kcc, glider, samsonov,
http://llvm-reviews.chandlerc.com/D569
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D569?vs=1364&id=1369#toc
Files:
lib/sanitizer_common/sanitizer_linux.cc
lib/sanitizer_common/sanitizer_mac.cc
lib/sanitizer_common/sanitizer_procmaps.h
Index: lib/sanitizer_common/sanitizer_linux.cc
===================================================================
--- lib/sanitizer_common/sanitizer_linux.cc
+++ lib/sanitizer_common/sanitizer_linux.cc
@@ -328,17 +328,27 @@
StaticSpinMutex MemoryMappingLayout::cache_lock_; // Linker initialized.
MemoryMappingLayout::MemoryMappingLayout() {
+ Init(/*use_cache*/ true);
+}
+
+MemoryMappingLayout::MemoryMappingLayout(bool use_cache) {
+ Init(use_cache);
+}
+
+void MemoryMappingLayout::Init(bool use_cache) {
proc_self_maps_.len =
ReadFileToBuffer("/proc/self/maps", &proc_self_maps_.data,
&proc_self_maps_.mmaped_size, 1 << 26);
if (proc_self_maps_.mmaped_size == 0) {
+ CHECK(use_cache);
LoadFromCache();
CHECK_GT(proc_self_maps_.len, 0);
}
// internal_write(2, proc_self_maps_.data, proc_self_maps_.len);
Reset();
// FIXME: in the future we may want to cache the mappings on demand only.
- CacheMemoryMappings();
+ if (use_cache)
+ CacheMemoryMappings();
}
MemoryMappingLayout::~MemoryMappingLayout() {
Index: lib/sanitizer_common/sanitizer_mac.cc
===================================================================
--- lib/sanitizer_common/sanitizer_mac.cc
+++ lib/sanitizer_common/sanitizer_mac.cc
@@ -166,6 +166,14 @@
// ----------------- sanitizer_procmaps.h
MemoryMappingLayout::MemoryMappingLayout() {
+ Init(/*use_cache*/true);
+}
+
+MemoryMappingLayout::MemoryMappingLayout(bool use_cache) {
+ Init(use_cache);
+}
+
+void MemoryMappingLayout::Init(bool use_cache) {
Reset();
}
Index: lib/sanitizer_common/sanitizer_procmaps.h
===================================================================
--- lib/sanitizer_common/sanitizer_procmaps.h
+++ lib/sanitizer_common/sanitizer_procmaps.h
@@ -42,6 +42,7 @@
class MemoryMappingLayout {
public:
MemoryMappingLayout();
+ explicit MemoryMappingLayout(bool use_cache);
bool Next(uptr *start, uptr *end, uptr *offset,
char filename[], uptr filename_size, uptr *protection);
void Reset();
@@ -63,6 +64,7 @@
static const uptr kProtectionShared = 8;
private:
+ void Init(bool use_cache);
void LoadFromCache();
// Default implementation of GetObjectNameAndOffset.
// Quite slow, because it iterates through the whole process map for each
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D569.2.patch
Type: text/x-patch
Size: 2320 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130322/d09dbdbe/attachment.bin>
More information about the llvm-commits
mailing list