[applied] fix comparing array subrange DIEs

Message ID 87edsema5i.fsf@seketeli.org
State New
Headers
Series [applied] fix comparing array subrange DIEs |

Commit Message

Dodji Seketeli Jan. 1, 2023, 5:34 p.m. UTC
  Hello,

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 | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
  

Patch

diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index d2848a30..e3a1348d 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -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);
       }