Example #1
0
/* to any of the addresses in the range [ a1, a2 [ in bitmap bm. */
Bool bm_has_any_access(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_r, b0) | bm0_is_set(p1->bm0_w, b0))
        {
          return True;
        }
      }
    }
  }
  return False;
}
Example #2
0
/** Report whether an access of type access_type at address a is recorded in
 *  bitmap bm.
 */
Bool bm_has_1(struct bitmap* const bm,
              const Addr a, const BmAccessTypeT access_type)
{
  const struct bitmap2* p2;
  const struct bitmap1* p1;
  const UWord* p0;
  const UWord a0 = a & ADDR0_MASK;

  tl_assert(bm);

  p2 = bm2_lookup(bm, a >> ADDR0_BITS);
  if (p2)
  {
    p1 = &p2->bm1;
    p0 = (access_type == eLoad) ? p1->bm0_r : p1->bm0_w;
    return bm0_is_set(p0, a0) ? True : False;
  }
  return False;
}
Example #3
0
/**
 * Report whether an access of type access_type at address a is recorded in
 * bitmap bm.
 * @return != 0 means true, and == 0 means false
 */
UWord bm_has_1(const struct bitmap* const bm,
               const Addr a,
               const BmAccessTypeT access_type)
{
   struct bitmap2* p2;
   struct bitmap1* p1;
   UWord* p0;
   const UWord a0 = a & ADDR0_MASK;

   tl_assert(bm);

   p2 = bm_lookup(bm, a);
   if (p2)
   {
      p1 = &p2->bm1;
      p0 = (access_type == eLoad) ? p1->bm0_r : p1->bm0_w;
      return bm0_is_set(p0, a0);
   }
   return 0;
}
Example #4
0
/* to any of the addresses in the range [ a1, a2 [ in bitmap bm.           */
UWord bm_has_any_access(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)
   {
      struct bitmap2* bm2 = bm_lookup(bm, b);

      b_next = (b & ~ADDR0_MASK) + ADDR0_COUNT;
      if (b_next > a2)
      {
         b_next = a2;
      }

      if (bm2)
      {
         Addr b_start;
         Addr b_end;
         UWord b0;

         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;
#if 0
         VG_(message)(Vg_DebugMsg,
                      "in 0x%lx 0x%lx / cur 0x%lx 0x%lx / out 0x%lx 0x%lx",
                      a1, a2,
                      (bm2->addr << ADDR0_BITS),
                      (bm2->addr << ADDR0_BITS) + ADDR0_COUNT,
                      b_start, b_end);
#endif
         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++)
         {
            const struct bitmap1* const p1 = &bm2->bm1;
            const UWord mask
               = bm0_is_set(p1->bm0_r, b0) | bm0_is_set(p1->bm0_w, b0);
            if (mask)
            {
               return mask;
            }
         }
      }
   }
   return 0;
}