libsanitizer: add filtering of sleep intervals for BackgroundThread.
[platform/upstream/linaro-gcc.git] / libsanitizer / asan / asan_memory_profile.cc
index 8a8ae22..9671fdf 100644 (file)
 #include <time.h>
 #endif
 
+namespace __sanitizer {
+  // provided by sanitizer_common_libcdep.cc
+  extern SleepInterval last_sleep_int;
+}
+
 namespace __asan {
 
 class HeapProfile;                      // Pointer to the global object
@@ -116,6 +121,16 @@ class HeapProfile {
     return res;
   }
 
+  void HPUpdateSleepInt(HPProfileType hp_prof_type) {
+    switch(hp_prof_type) {
+    case HPProfileType::NONE:
+      break;
+    case HPProfileType::SHORT:
+    case HPProfileType::FULL:
+      __sanitizer::last_sleep_int.ends_with_event = true;
+    }
+  }
+
   void HPPrintHeader(HPProfileType hp_prof_type) {
     switch (hp_prof_type) {
     case HPProfileType::NONE:
@@ -363,6 +378,7 @@ void __sanitizer_print_memory_profile(uptr top_percent) {
 
   __asan::HeapProfile::HPProfileType hp_prof_type =
                               __asan::heap_profile->NeededProfileType();
+  __asan::heap_profile->HPUpdateSleepInt(hp_prof_type);
   __asan::heap_profile->HPPrintHeader(hp_prof_type);
   if (hp_prof_type == __asan::HeapProfile::HPProfileType::FULL) {
     __sanitizer::StopTheWorld(__asan::MemoryProfileCB, (void*)top_percent);