[PATCH] Make caching of memory mappings in sanitizer_procmaps optional
Sergey Matveev
earthdok at google.com
Thu Mar 21 21:10:58 PDT 2013
Hi kcc, glider, samsonov,
Unmapping the old cache partially invalidates the memory layout, so add
a flag to skip cache update for cases when that's unacceptable (e.g. lsan).
http://llvm-reviews.chandlerc.com/D569
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,6 +328,14 @@
StaticSpinMutex MemoryMappingLayout::cache_lock_; // Linker initialized.
MemoryMappingLayout::MemoryMappingLayout() {
+ Init(/*update_cache*/ true);
+}
+
+MemoryMappingLayout::MemoryMappingLayout(bool update_cache) {
+ Init(update_cache);
+}
+
+void MemoryMappingLayout::Init(bool update_cache) {
proc_self_maps_.len =
ReadFileToBuffer("/proc/self/maps", &proc_self_maps_.data,
&proc_self_maps_.mmaped_size, 1 << 26);
@@ -337,8 +345,8 @@
}
// 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 (update_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(/*update_cache*/true);
+}
+
+MemoryMappingLayout::MemoryMappingLayout(bool update_cache) {
+ Init(update_cache);
+}
+
+void MemoryMappingLayout::Init(bool update_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 update_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 update_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.1.patch
Type: text/x-patch
Size: 2245 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130321/9cb59439/attachment.bin>
More information about the llvm-commits
mailing list