]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Split bm_has_any() into bm_has_any_load() and bm_has_any_store().
authorBart Van Assche <bvanassche@acm.org>
Sun, 30 Mar 2008 18:41:07 +0000 (18:41 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sun, 30 Mar 2008 18:41:07 +0000 (18:41 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7825

exp-drd/drd_bitmap.c
exp-drd/drd_suppression.c
exp-drd/pub_drd_bitmap.h

index 03ed89bc6085a68d952e215b1d8fe1159e928d91..097b43d830fa52a3597870441763f7bc9db594fd 100644 (file)
@@ -280,22 +280,110 @@ Bool bm_has(const struct bitmap* const bm, const Addr a1, const Addr a2,
   return True;
 }
 
-Bool bm_has_any(const struct bitmap* const bm,
-                const Addr a1, const Addr a2,
-                const BmAccessTypeT access_type)
+Bool bm_has_any_load(const struct bitmap* const bm,
+                     const Addr a1, const Addr a2)
 {
-  Addr b;
+  Addr b, b_next;
 
   tl_assert(bm);
 
-  for (b = a1; b < a2; b++)
+  for (b = a1; b < a2; b = b_next)
   {
-    if (bm_has_1(bm, b, access_type))
+    const struct bitmap2* bm2 = bm2_lookup(bm, b >> ADDR0_BITS);
+
+    b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+    if (b_next > a2)
     {
-      return True;
+      b_next = a2;
+    }
+
+    if (bm2)
+    {
+      Addr b_start;
+      Addr b_end;
+      UWord b0;
+      const struct bitmap1* const p1 = &bm2->bm1;
+
+      if ((bm2->addr << ADDR0_BITS) < a1)
+        b_start = a1;
+      else
+        if ((bm2->addr << ADDR0_BITS) < a2)
+          b_start = (bm2->addr << ADDR0_BITS);
+        else
+          break;
+      tl_assert(a1 <= b_start && b_start <= a2);
+
+      if ((bm2->addr << ADDR0_BITS) + ADDR0_COUNT < a2)
+        b_end = (bm2->addr << ADDR0_BITS) + ADDR0_COUNT;
+      else
+        b_end = a2;
+      tl_assert(a1 <= b_end && b_end <= a2);
+      tl_assert(b_start < b_end);
+      tl_assert((b_start & ADDR0_MASK) <= ((b_end - 1) & ADDR0_MASK));
+      
+      for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end-1) & ADDR0_MASK); b0++)
+      {
+        if (bm0_is_set(p1->bm0_r, b0))
+        {
+          return True;
+        }
+      }
     }
   }
-  return False;
+  return 0;
+}
+
+Bool bm_has_any_store(const struct bitmap* const bm,
+                      const Addr a1, const Addr a2)
+{
+  Addr b, b_next;
+
+  tl_assert(bm);
+
+  for (b = a1; b < a2; b = b_next)
+  {
+    const struct bitmap2* bm2 = bm2_lookup(bm, b >> ADDR0_BITS);
+
+    b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
+    if (b_next > a2)
+    {
+      b_next = a2;
+    }
+
+    if (bm2)
+    {
+      Addr b_start;
+      Addr b_end;
+      UWord b0;
+      const struct bitmap1* const p1 = &bm2->bm1;
+
+      if ((bm2->addr << ADDR0_BITS) < a1)
+        b_start = a1;
+      else
+        if ((bm2->addr << ADDR0_BITS) < a2)
+          b_start = (bm2->addr << ADDR0_BITS);
+        else
+          break;
+      tl_assert(a1 <= b_start && b_start <= a2);
+
+      if ((bm2->addr << ADDR0_BITS) + ADDR0_COUNT < a2)
+        b_end = (bm2->addr << ADDR0_BITS) + ADDR0_COUNT;
+      else
+        b_end = a2;
+      tl_assert(a1 <= b_end && b_end <= a2);
+      tl_assert(b_start < b_end);
+      tl_assert((b_start & ADDR0_MASK) <= ((b_end - 1) & ADDR0_MASK));
+      
+      for (b0 = b_start & ADDR0_MASK; b0 <= ((b_end-1) & ADDR0_MASK); b0++)
+      {
+        if (bm0_is_set(p1->bm0_w, b0))
+        {
+          return True;
+        }
+      }
+    }
+  }
+  return 0;
 }
 
 /* Return a non-zero value if there is a read access, write access or both */
index 63c7251d19aec161fb8df6227402583e12dc3913..a66eca0efc1473adb6286c84c6e24a2297e19092 100644 (file)
@@ -102,7 +102,7 @@ Bool drd_is_suppressed(const Addr a1, const Addr a2)
  */
 Bool drd_is_any_suppressed(const Addr a1, const Addr a2)
 {
-  return bm_has_any(s_suppressed, a1, a2, eStore);
+  return bm_has_any_store(s_suppressed, a1, a2);
 }
 
 void drd_start_tracing_address_range(const Addr a1, const Addr a2)
@@ -123,13 +123,13 @@ void drd_stop_tracing_address_range(const Addr a1, const Addr a2)
   bm_clear_load(s_suppressed, a1, a2);
   if (g_any_address_traced)
   {
-    g_any_address_traced = bm_has_any(s_suppressed, 0, ~(Addr)0, eLoad);
+    g_any_address_traced = bm_has_any_load(s_suppressed, 0, ~(Addr)0);
   }
 }
 
 Bool drd_is_any_traced(const Addr a1, const Addr a2)
 {
-  return bm_has_any(s_suppressed, a1, a2, eLoad);
+  return bm_has_any_load(s_suppressed, a1, a2);
 }
 
 void drd_suppression_stop_using_mem(const Addr a1, const Addr a2)
index 72470ace0a0c72d2ac66b660a5c5807e5ebba955..8bfdeeb504092e7d15bc9adb7e332125115b8c24 100644 (file)
@@ -71,9 +71,10 @@ void bm_access_range_store(struct bitmap* const bm,
 Bool bm_has(const struct bitmap* const bm,
             const Addr a1, const Addr a2,
             const BmAccessTypeT access_type);
-Bool bm_has_any(const struct bitmap* const bm,
-                const Addr a1, const Addr a2,
-                const BmAccessTypeT access_type);
+Bool bm_has_any_load(const struct bitmap* const bm,
+                     const Addr a1, const Addr a2);
+Bool bm_has_any_store(const struct bitmap* const bm,
+                      const Addr a1, const Addr a2);
 UWord bm_has_any_access(const struct bitmap* const bm,
                         const Addr a1, const Addr a2);
 UWord bm_has_1(const struct bitmap* const bm,