public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, applied] fix comparing array subrange DIEs
@ 2023-01-01 17:34 Dodji Seketeli
  0 siblings, 0 replies; only message in thread
From: Dodji Seketeli @ 2023-01-01 17:34 UTC (permalink / raw)
  To: libabigail

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(-)

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);
       }
-- 
2.39.0


-- 
		Dodji

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-01 17:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-01 17:34 [PATCH, applied] fix comparing array subrange DIEs Dodji Seketeli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).