Mark Wielaard fa24ab
commit 3528f84037833a799538a2fc48ed30dd09c77b5e
Mark Wielaard fa24ab
Author: Mark Wielaard <mark@klomp.org>
Mark Wielaard fa24ab
Date:   Fri Jan 11 21:52:26 2019 +0100
Mark Wielaard fa24ab
Mark Wielaard fa24ab
    readdwarf3.c (parse_type_DIE): Accept DW_TAG_subrange_type with DW_AT_count
Mark Wielaard fa24ab
    
Mark Wielaard fa24ab
    GCC9 generates a subrange_type with a lower_bound and count, but no
Mark Wielaard fa24ab
    upper_bound attribute. This simply means the upper bound is lower
Mark Wielaard fa24ab
    plus count.
Mark Wielaard fa24ab
Mark Wielaard fa24ab
diff --git a/coregrind/m_debuginfo/readdwarf3.c b/coregrind/m_debuginfo/readdwarf3.c
Mark Wielaard fa24ab
index e9a3816..1b49ba4 100644
Mark Wielaard fa24ab
--- a/coregrind/m_debuginfo/readdwarf3.c
Mark Wielaard fa24ab
+++ b/coregrind/m_debuginfo/readdwarf3.c
Mark Wielaard fa24ab
@@ -3610,6 +3610,7 @@ static void parse_type_DIE ( /*MOD*/XArray* /* of TyEnt */ tyents,
Mark Wielaard fa24ab
       Bool have_count = False;
Mark Wielaard fa24ab
       Long lower = 0;
Mark Wielaard fa24ab
       Long upper = 0;
Mark Wielaard fa24ab
+      Long count = 0;
Mark Wielaard fa24ab
 
Mark Wielaard fa24ab
       switch (parser->language) {
Mark Wielaard fa24ab
          case 'C': have_lower = True;  lower = 0; break;
Mark Wielaard fa24ab
@@ -3641,7 +3642,7 @@ static void parse_type_DIE ( /*MOD*/XArray* /* of TyEnt */ tyents,
Mark Wielaard fa24ab
             have_upper = True;
Mark Wielaard fa24ab
          }
Mark Wielaard fa24ab
          if (attr == DW_AT_count && cts.szB > 0) {
Mark Wielaard fa24ab
-            /*count    = (Long)cts.u.val;*/
Mark Wielaard fa24ab
+            count    = (Long)cts.u.val;
Mark Wielaard fa24ab
             have_count = True;
Mark Wielaard fa24ab
          }
Mark Wielaard fa24ab
       }
Mark Wielaard fa24ab
@@ -3680,6 +3681,11 @@ static void parse_type_DIE ( /*MOD*/XArray* /* of TyEnt */ tyents,
Mark Wielaard fa24ab
          boundE.Te.Bound.knownU = False;
Mark Wielaard fa24ab
          boundE.Te.Bound.boundL = 0;
Mark Wielaard fa24ab
          boundE.Te.Bound.boundU = 0;
Mark Wielaard fa24ab
+      } else if (have_lower && (!have_upper) && (have_count)) {
Mark Wielaard fa24ab
+         boundE.Te.Bound.knownL = True;
Mark Wielaard fa24ab
+         boundE.Te.Bound.knownU = True;
Mark Wielaard fa24ab
+         boundE.Te.Bound.boundL = lower;
Mark Wielaard fa24ab
+         boundE.Te.Bound.boundU = lower + count;
Mark Wielaard fa24ab
       } else {
Mark Wielaard fa24ab
          /* FIXME: handle more cases */
Mark Wielaard fa24ab
          goto_bad_DIE;