Bug 1297773 - Fix thread filter to use case insensitive substring matching. r=mstange draft
authorBenoit Girard <b56girard@gmail.com>
Wed, 24 Aug 2016 16:22:53 -0400
changeset 405123 4358a4cf8d8b6e613097449e90a1cbb92f668552
parent 401500 fe895421dfbe1f1f8f1fc6a39bb20774423a6d74
child 529360 b3801c82c497e5878b89f8dcd49792c55c149ca6
push id27398
push userb56girard@gmail.com
push dateWed, 24 Aug 2016 20:22:08 +0000
reviewersmstange
bugs1297773
milestone51.0a1
Bug 1297773 - Fix thread filter to use case insensitive substring matching. r=mstange MozReview-Commit-ID: 9umKsSQ9a73
tools/profiler/core/GeckoSampler.h
--- a/tools/profiler/core/GeckoSampler.h
+++ b/tools/profiler/core/GeckoSampler.h
@@ -13,31 +13,40 @@
 #include "ThreadInfo.h"
 #ifndef SPS_STANDALONE
 #include "IntelPowerGadget.h"
 #endif
 #ifdef MOZ_TASK_TRACER
 #include "GeckoTaskTracer.h"
 #endif
 
+#include <algorithm>
+
 namespace mozilla {
 class ProfileGatherer;
 } // namespace mozilla
 
 typedef mozilla::Vector<std::string> ThreadNameFilterList;
 typedef mozilla::Vector<std::string> FeatureList;
 
 static bool
 threadSelected(ThreadInfo* aInfo, const ThreadNameFilterList &aThreadNameFilters) {
   if (aThreadNameFilters.empty()) {
     return true;
   }
 
+  std::string name = aInfo->Name();
+  std::transform(name.begin(), name.end(), name.begin(), ::tolower);
+
   for (uint32_t i = 0; i < aThreadNameFilters.length(); ++i) {
-    if (aThreadNameFilters[i] == aInfo->Name()) {
+    std::string filter = aThreadNameFilters[i];
+    std::transform(filter.begin(), filter.end(), filter.begin(), ::tolower);
+
+    // Crude, non UTF-8 compatible, case insensitive substring search
+    if (name.find(filter) != std::string::npos) {
       return true;
     }
   }
 
   return false;
 }
 
 extern mozilla::TimeStamp sLastTracerEvent;