fix comparing array subrange DIEs
authorDodji Seketeli <dodji@redhat.com>
Fri, 30 Dec 2022 23:43:51 +0000 (00:43 +0100)
committerDodji Seketeli <dodji@redhat.com>
Sun, 1 Jan 2023 17:21:56 +0000 (18:21 +0100)
When looking at something else in the DWARF reader, I noticed that the
DIE comparison algorithm for DW_TAG_subprogram DIEs was not taking
into account non-set DW_AT_upper_bound attributes.

Fixed thus.

* src/abg-dwarf-reader.cc (compare_dies): For DW_TAG_subprogram,
non-set DW_AT_{lower,upper}_bound is not the same as when they are
set to zero.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-dwarf-reader.cc

index d2848a30862ad83347e08c000cb88c68ae3bd99e..e3a1348de59586ab453481db7110e2583cbf72f2 100644 (file)
@@ -10933,8 +10933,14 @@ compare_dies(const reader& rdr,
       {
        uint64_t l_lower_bound = 0, r_lower_bound = 0,
          l_upper_bound = 0, r_upper_bound = 0;
-       die_unsigned_constant_attribute(l, DW_AT_lower_bound, l_lower_bound);
-       die_unsigned_constant_attribute(r, DW_AT_lower_bound, r_lower_bound);
+       bool l_lower_bound_set = false, r_lower_bound_set = false,
+         l_upper_bound_set = false, r_upper_bound_set = false;
+
+       l_lower_bound_set =
+         die_unsigned_constant_attribute(l, DW_AT_lower_bound, l_lower_bound);
+       r_lower_bound_set =
+         die_unsigned_constant_attribute(r, DW_AT_lower_bound, r_lower_bound);
+
        if (!die_unsigned_constant_attribute(l, DW_AT_upper_bound,
                                             l_upper_bound))
          {
@@ -10942,10 +10948,14 @@ compare_dies(const reader& rdr,
            if (die_unsigned_constant_attribute(l, DW_AT_count, l_count))
              {
                l_upper_bound = l_lower_bound + l_count;
+               l_upper_bound_set = true;
                if (l_upper_bound)
                  --l_upper_bound;
              }
          }
+       else
+         l_upper_bound_set = true;
+
        if (!die_unsigned_constant_attribute(r, DW_AT_upper_bound,
                                             r_upper_bound))
          {
@@ -10953,12 +10963,17 @@ compare_dies(const reader& rdr,
            if (die_unsigned_constant_attribute(l, DW_AT_count, r_count))
              {
                r_upper_bound = r_lower_bound + r_count;
+               r_upper_bound_set = true;
                if (r_upper_bound)
                  --r_upper_bound;
              }
          }
+       else
+         r_upper_bound_set = true;
 
-       if ((l_lower_bound != r_lower_bound)
+       if ((l_lower_bound_set != r_lower_bound_set)
+           || (l_upper_bound_set != r_upper_bound_set)
+           || (l_lower_bound != r_lower_bound)
            || (l_upper_bound != r_upper_bound))
          SET_RESULT_TO_FALSE(result, l, r);
       }